From 09dc33d07ed94f644817c8000077d429e1746a3d Mon Sep 17 00:00:00 2001 From: hikerstk Date: Mon, 9 Dec 2013 12:24:26 +0000 Subject: [PATCH] Moved the glowing data from stk_config.xml to items.xml. Unfortunately I can't test (since the shaders don't work for me). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14683 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/items.xml | 10 ++++----- data/stk_config.xml | 3 --- src/config/stk_config.cpp | 45 -------------------------------------- src/config/stk_config.hpp | 6 ----- src/graphics/render.cpp | 32 ++++----------------------- src/io/xml_node.cpp | 21 +++++++++++++----- src/items/item_manager.cpp | 6 +++++ src/items/item_manager.hpp | 16 ++++++++++---- 8 files changed, 43 insertions(+), 96 deletions(-) diff --git a/data/items.xml b/data/items.xml index 32c1110f2..2a9819794 100644 --- a/data/items.xml +++ b/data/items.xml @@ -1,13 +1,13 @@ - - - - + + + + - + diff --git a/data/stk_config.xml b/data/stk_config.xml index 94dcee975..18d1cb51c 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -135,9 +135,6 @@ - - - diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index 638f23da8..ef0d9a9bc 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -181,19 +181,6 @@ void STKConfig::init_defaults() m_disable_steer_while_unskid = false; m_camera_follow_skid = false; - m_nitro_glow_color[0] = 1.0f; - m_nitro_glow_color[1] = 1.0f; - m_nitro_glow_color[2] = 1.0f; - m_box_glow_color[0] = 1.0f; - m_box_glow_color[1] = 1.0f; - m_box_glow_color[2] = 1.0f; - m_banana_glow_color[0] = 1.0f; - m_banana_glow_color[1] = 1.0f; - m_banana_glow_color[2] = 1.0f; - m_bubblegum_glow_color[0] = 1.0f; - m_bubblegum_glow_color[1] = 1.0f; - m_bubblegum_glow_color[2] = 1.0f; - m_score_increase.clear(); m_leader_intervals.clear(); m_switch_items.clear(); @@ -376,38 +363,6 @@ void STKConfig::getAllData(const XMLNode * root) replay_node->get("delta-t", &m_replay_dt ); } - if(const XMLNode *colors = root->getNode("glow-colors")) - { - video::SColor tmpcol; - if (colors->get("nitro", &tmpcol)) - { - m_nitro_glow_color[0] = tmpcol.getRed() / 255.0f; - m_nitro_glow_color[1] = tmpcol.getGreen() / 255.0f; - m_nitro_glow_color[2] = tmpcol.getBlue() / 255.0f; - } - - if (colors->get("box", &tmpcol)) - { - m_box_glow_color[0] = tmpcol.getRed() / 255.0f; - m_box_glow_color[1] = tmpcol.getGreen() / 255.0f; - m_box_glow_color[2] = tmpcol.getBlue() / 255.0f; - } - - if (colors->get("banana", &tmpcol)) - { - m_banana_glow_color[0] = tmpcol.getRed() / 255.0f; - m_banana_glow_color[1] = tmpcol.getGreen() / 255.0f; - m_banana_glow_color[2] = tmpcol.getBlue() / 255.0f; - } - - if (colors->get("bubblegum", &tmpcol)) - { - m_bubblegum_glow_color[0] = tmpcol.getRed() / 255.0f; - m_bubblegum_glow_color[1] = tmpcol.getGreen() / 255.0f; - m_bubblegum_glow_color[2] = tmpcol.getBlue() / 255.0f; - } - } - // Get the default KartProperties // ------------------------------ const XMLNode *node = root -> getNode("general-kart-defaults"); diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index 958201878..2fcdbeed5 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -148,12 +148,6 @@ public: * be generated. */ float m_replay_delta_angle; - /** Colors for glows */ - float m_nitro_glow_color[3]; - float m_box_glow_color[3]; - float m_banana_glow_color[3]; - float m_bubblegum_glow_color[3]; - private: /** True if stk_config has been loaded. This is necessary if the * --stk-config command line parameter has been specified to avoid diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index ce18b8682..b313fe3a0 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -115,34 +115,10 @@ void IrrDriver::renderGLSL(float dt) dat.g = 1.0f; dat.b = 1.0f; - // Item colors - switch (type) - { - case Item::ITEM_NITRO_BIG: - case Item::ITEM_NITRO_SMALL: - dat.r = stk_config->m_nitro_glow_color[0]; - dat.g = stk_config->m_nitro_glow_color[1]; - dat.b = stk_config->m_nitro_glow_color[2]; - break; - case Item::ITEM_BONUS_BOX: - dat.r = stk_config->m_box_glow_color[0]; - dat.g = stk_config->m_box_glow_color[1]; - dat.b = stk_config->m_box_glow_color[2]; - break; - case Item::ITEM_BANANA: - dat.r = stk_config->m_banana_glow_color[0]; - dat.g = stk_config->m_banana_glow_color[1]; - dat.b = stk_config->m_banana_glow_color[2]; - break; - case Item::ITEM_BUBBLEGUM: - dat.r = stk_config->m_bubblegum_glow_color[0]; - dat.g = stk_config->m_bubblegum_glow_color[1]; - dat.b = stk_config->m_bubblegum_glow_color[2]; - break; - default: - Log::fatal("render", "Unknown item type got through"); - break; - } + const video::SColorf &c = ItemManager::getGlowColor(type); + dat.r = c.getRed(); + dat.g = c.getGreen(); + dat.b = c.getBlue(); glows.push_back(dat); diff --git a/src/io/xml_node.cpp b/src/io/xml_node.cpp index d78dc379f..6ce38abf3 100644 --- a/src/io/xml_node.cpp +++ b/src/io/xml_node.cpp @@ -279,11 +279,22 @@ int XMLNode::get(const std::string &attribute, video::SColorf *color) const if(!get(attribute, &s)) return 0; std::vector v = StringUtils::split(s,' '); - if(v.size()!=4) return 0; - color->set((float)atof(v[3].c_str()), // set takes ARGB, but we use RGBA - (float)atof(v[0].c_str()), - (float)atof(v[1].c_str()), - (float)atof(v[2].c_str())); + if(v.size()==3) + { + color->set((float)atof(v[0].c_str()), + (float)atof(v[1].c_str()), + (float)atof(v[2].c_str())); + } + else if(v.size()==4) + { + color->set((float)atof(v[3].c_str()), // set takes ARGB, but we use RGBA + (float)atof(v[0].c_str()), + (float)atof(v[1].c_str()), + (float)atof(v[2].c_str())); + } + else + return 0; + return 1; } // get(SColor) // ---------------------------------------------------------------------------- diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp index 761cddd3e..cec19f795 100644 --- a/src/items/item_manager.cpp +++ b/src/items/item_manager.cpp @@ -40,8 +40,10 @@ std::vector ItemManager::m_item_mesh; std::vector ItemManager::m_item_lowres_mesh; +std::vector ItemManager::m_glow_color; ItemManager * ItemManager::m_item_manager = NULL; + //----------------------------------------------------------------------------- /** Creates one instance of the item manager. */ void ItemManager::create() @@ -65,6 +67,9 @@ void ItemManager::destroy() void ItemManager::loadDefaultItemMeshes() { m_item_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL); + m_glow_color.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, + video::SColorf(255.0f, 255.0f, 255.0f) ); + m_item_lowres_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL); // A temporary mapping of items to names used in the XML file: @@ -98,6 +103,7 @@ void ItemManager::loadDefaultItemMeshes() } mesh->grab(); m_item_mesh[i] = mesh; + node->get("glow", &(m_glow_color[i])); std::string lowres_model_filename; node->get("lowmodel", &lowres_model_filename); diff --git a/src/items/item_manager.hpp b/src/items/item_manager.hpp index a69736153..66c986829 100644 --- a/src/items/item_manager.hpp +++ b/src/items/item_manager.hpp @@ -19,15 +19,16 @@ #ifndef HEADER_ITEMMANAGER_HPP #define HEADER_ITEMMANAGER_HPP +#include "items/item.hpp" +#include "utils/no_copy.hpp" + +#include #include #include #include #include -#include "items/item.hpp" -#include "utils/no_copy.hpp" - class Kart; /** @@ -40,6 +41,9 @@ private: /** Stores all item models. */ static std::vector m_item_mesh; + /** Stores the glow color for all items. */ + static std::vector m_glow_color; + /** Stores all low-resolution item models. */ static std::vector m_item_lowres_mesh; @@ -54,7 +58,11 @@ public: // ------------------------------------------------------------------------ /** Returns the mesh for a certain item. */ static scene::IMesh* getItemModel(Item::ItemType type) - {return m_item_mesh[type];} + { return m_item_mesh[type]; } + // ------------------------------------------------------------------------ + /** Returns the glow color for an item. */ + static video::SColorf& getGlowColor(Item::ItemType type) + { return m_glow_color[type]; } // ------------------------------------------------------------------------ /** Return an instance of the item manager (it does not automatically * create one, call create for that). */