From: <sv...@ww...> - 2007-04-20 11:18:43
|
Author: nsmoooose Date: 2007-04-20 04:18:35 -0700 (Fri, 20 Apr 2007) New Revision: 2082 Added: branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.cpp branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.h Modified: branches/python_bindings_for_ui/csp/bin/sim.ini branches/python_bindings_for_ui/csp/cspsim/SConscript branches/python_bindings_for_ui/csp/cspsim/wf/Serialization.cpp branches/python_bindings_for_ui/csp/cspsim/wf/Window.cpp branches/python_bindings_for_ui/csp/cspsim/wf/Window.h Log: Added stubs for a string resource manager. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2082 Modified: branches/python_bindings_for_ui/csp/bin/sim.ini =================================================================== --- branches/python_bindings_for_ui/csp/bin/sim.ini 2007-04-18 19:07:22 UTC (rev 2081) +++ branches/python_bindings_for_ui/csp/bin/sim.ini 2007-04-20 11:18:35 UTC (rev 2082) @@ -43,8 +43,8 @@ AirBubbleRadius = 80000 VisualRadius = 40000 Theater = sim:theater.balkan +Date = 2006-07-10 02:00:00 ;Date = 2006-07-10 23:00:00 -Date = 2006-07-10 02:00:00 ;Date = 2004-05-09 12:00:00 ;Date = 2006-07-10 12:00:00 ; balkan theater (demeter) @@ -62,3 +62,7 @@ IncomingBandwidth = 20000 OutgoingBandwidth = 20000 + +[UI] +ThemeName = default +Language = english Modified: branches/python_bindings_for_ui/csp/cspsim/SConscript =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/SConscript 2007-04-18 19:07:22 UTC (rev 2081) +++ branches/python_bindings_for_ui/csp/cspsim/SConscript 2007-04-20 11:18:35 UTC (rev 2082) @@ -410,6 +410,8 @@ 'wf/SingleControlContainer.h', 'wf/Slot.cpp', 'wf/Slot.h', + 'wf/StringResourceManager.cpp', + 'wf/StringResourceManager.h', 'wf/Style.h', 'wf/StyleBuilder.cpp', 'wf/StyleBuilder.h', Modified: branches/python_bindings_for_ui/csp/cspsim/wf/Serialization.cpp =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/wf/Serialization.cpp 2007-04-18 19:07:22 UTC (rev 2081) +++ branches/python_bindings_for_ui/csp/cspsim/wf/Serialization.cpp 2007-04-20 11:18:35 UTC (rev 2082) @@ -34,6 +34,7 @@ #include <csp/cspsim/wf/Label.h> #include <csp/cspsim/wf/ListBox.h> #include <csp/cspsim/wf/MultiControlContainer.h> +#include <csp/cspsim/wf/ResourceLocator.h> #include <csp/cspsim/wf/Serialization.h> #include <csp/cspsim/wf/Tab.h> #include <csp/cspsim/wf/TableControlContainer.h> @@ -211,20 +212,29 @@ } std::string includeFile = includeNode.getText(0); - std::string includeFilePath = ospath::join(themePath, includeFile); - if(!ospath::exists(includeFilePath)) { - CSPLOG(ERROR, APP) << "UI Include document not found."; - continue; + + std::string includeNodeName = includeNode.getName(); + if(includeNodeName == "StringTableInclude") { + Ref<StringResourceManager> loadedResources = new StringResourceManager; + Ref<ResourceLocator> resourceLocator = new WindowResourceLocator(window); + loadedResources->loadFromFile(includeFile, resourceLocator.get()); + window->getStringResourceManager()->merge(loadedResources.get()); } - - XMLNode includeDocument = XMLNode::parseFile(includeFilePath.c_str()); - XMLNode namedStylesNode = includeDocument.selectSingleNode("StyleDocument/NamedStyles"); - NamedStyleMap styles; - ToValue(namedStylesNode, "", &styles); - - NamedStyleMap::iterator style = styles.begin(); - for(;style != styles.end();++style) { - window->addNamedStyle(style->first, style->second); + else if(includeNodeName == "StyleInclude") { + std::string includeFilePath = ospath::join(themePath, includeFile); + if(!ospath::exists(includeFilePath)) { + CSPLOG(ERROR, APP) << "UI Include document not found."; + continue; + } + XMLNode includeDocument = XMLNode::parseFile(includeFilePath.c_str()); + XMLNode namedStylesNode = includeDocument.selectSingleNode("StyleDocument/NamedStyles"); + NamedStyleMap styles; + ToValue(namedStylesNode, "", &styles); + + NamedStyleMap::iterator style = styles.begin(); + for(;style != styles.end();++style) { + window->addNamedStyle(style->first, style->second); + } } } } Added: branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.cpp =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.cpp 2007-04-18 19:07:22 UTC (rev 2081) +++ branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.cpp 2007-04-20 11:18:35 UTC (rev 2082) @@ -0,0 +1,49 @@ +// Combat Simulator Project +// Copyright (C) 2002 The Combat Simulator Project +// http://csp.sourceforge.net +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * @file StringResourceManager.cpp + * + **/ + +#include <csp/cspsim/wf/StringResourceManager.h> + +CSP_NAMESPACE + +namespace wf { + +StringResourceManager::StringResourceManager() { +} + +StringResourceManager::~StringResourceManager() { +} + +void StringResourceManager::loadFromFile(const std::string& fileName, ResourceLocator* resourceLocator) { +} + +std::string StringResourceManager::getString(const std::string& key) const { + return ""; +} + +void StringResourceManager::merge(StringResourceManager* stringsToMerge) { +} + +} // namespace wf + +CSP_NAMESPACE_END Added: branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.h =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.h 2007-04-18 19:07:22 UTC (rev 2081) +++ branches/python_bindings_for_ui/csp/cspsim/wf/StringResourceManager.h 2007-04-20 11:18:35 UTC (rev 2082) @@ -0,0 +1,58 @@ +// Combat Simulator Project +// Copyright (C) 2002 The Combat Simulator Project +// http://csp.sourceforge.net +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * @file StringResourceManager.h + * + **/ + +#ifndef __CSPSIM_WF_STRINGRESOURCEMANAGER_H__ +#define __CSPSIM_WF_STRINGRESOURCEMANAGER_H__ + +#include <map> +#include <csp/csplib/util/Referenced.h> +#include <csp/cspsim/Export.h> + +CSP_NAMESPACE + +namespace wf { + +class ResourceLocator; + +class CSPSIM_EXPORT StringResourceManager : public Referenced { +public: + StringResourceManager(); + virtual ~StringResourceManager(); + + virtual void loadFromFile(const std::string& fileName, ResourceLocator* resourceLocator); + + virtual std::string getString(const std::string& key) const; + virtual void merge(StringResourceManager* stringsToMerge); + +private: + typedef std::map<std::string, std::string> StringMap; + StringMap m_Values; +}; + +} // namespace wf + +CSP_NAMESPACE_END + +#endif // __CSPSIM_WF_STRINGRESOURCEMANAGER_H__ + Modified: branches/python_bindings_for_ui/csp/cspsim/wf/Window.cpp =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/wf/Window.cpp 2007-04-18 19:07:22 UTC (rev 2081) +++ branches/python_bindings_for_ui/csp/cspsim/wf/Window.cpp 2007-04-20 11:18:35 UTC (rev 2082) @@ -33,7 +33,7 @@ namespace wf { Window::Window() : - m_WindowManager(NULL) { + m_WindowManager(NULL), m_StringResources(new StringResourceManager) { } Window::~Window() { @@ -102,6 +102,10 @@ return m_Theme; } +StringResourceManager* Window::getStringResourceManager() { + return m_StringResources.get(); +} + optional<Style> Window::getNamedStyle(const std::string& name) const { optional<Style> style; // Assign the style to the optional if it exists in the map. Modified: branches/python_bindings_for_ui/csp/cspsim/wf/Window.h =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/wf/Window.h 2007-04-18 19:07:22 UTC (rev 2081) +++ branches/python_bindings_for_ui/csp/cspsim/wf/Window.h 2007-04-20 11:18:35 UTC (rev 2082) @@ -28,6 +28,7 @@ #include <map> #include <csp/csplib/util/Ref.h> #include <csp/cspsim/wf/SingleControlContainer.h> +#include <csp/cspsim/wf/StringResourceManager.h> namespace osg { class Group; @@ -71,6 +72,8 @@ virtual void setTheme(const std::string& theme); virtual std::string getTheme() const; + virtual StringResourceManager* getStringResourceManager(); + template<class Archive> void serialize(Archive & ar) { SingleControlContainer::serialize(ar); @@ -80,6 +83,7 @@ private: WindowManager* m_WindowManager; std::string m_Theme; + Ref<StringResourceManager> m_StringResources; NamedStyleMap m_Styles; }; |