Changeset 415 for cafu/trunk
- Timestamp:
- 10/30/11 14:15:06 (7 months ago)
- Location:
- cafu/trunk
- Files:
-
- 26 modified
-
Ca3DE/MainCanvas.cpp (modified) (7 diffs)
-
Ca3DE/MainCanvas.hpp (modified) (2 diffs)
-
CaWE/AppCaWE.cpp (modified) (2 diffs)
-
CaWE/GameConfig.cpp (modified) (1 diff)
-
CaWE/GameConfig.hpp (modified) (3 diffs)
-
CaWE/GuiEditor/ChildFrame.cpp (modified) (1 diff)
-
CaWE/GuiEditor/Commands/ModifyWindow.cpp (modified) (3 diffs)
-
CaWE/GuiEditor/Commands/SetWinProp.cpp (modified) (1 diff)
-
CaWE/GuiEditor/GuiDocument.cpp (modified) (2 diffs)
-
CaWE/GuiEditor/GuiDocument.hpp (modified) (1 diff)
-
CaWE/GuiEditor/LivePreview.cpp (modified) (1 diff)
-
CaWE/GuiEditor/RenderWindow.cpp (modified) (1 diff)
-
CaWE/GuiEditor/Windows/EditorWindow.cpp (modified) (2 diffs)
-
CaWE/ModelEditor/ModelDocument.cpp (modified) (1 diff)
-
CaWE/Options.cpp (modified) (2 diffs)
-
CaWE/Options.hpp (modified) (1 diff)
-
CaWE/ParentFrame.cpp (modified) (3 diffs)
-
Libs/GuiSys/Gui.hpp (modified) (1 diff)
-
Libs/GuiSys/GuiImpl.cpp (modified) (5 diffs)
-
Libs/GuiSys/GuiImpl.hpp (modified) (5 diffs)
-
Libs/GuiSys/GuiMan.hpp (modified) (2 diffs)
-
Libs/GuiSys/GuiManImpl.cpp (modified) (6 diffs)
-
Libs/GuiSys/GuiManImpl.hpp (modified) (4 diffs)
-
Libs/GuiSys/Window.cpp (modified) (3 diffs)
-
Libs/Models/AnimPose.hpp (modified) (1 diff)
-
Libs/Models/ModelManager.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/Ca3DE/MainCanvas.cpp
r359 r415 41 41 #include "MaterialSystem/Renderer.hpp" 42 42 #include "MaterialSystem/TextureMap.hpp" 43 #include "Models/ModelManager.hpp" 43 44 #include "OpenGL/OpenGLWindow.hpp" // For CaMouseEventT and CaKeyboardEventT. 44 45 #include "SoundSystem/SoundShaderManager.hpp" … … 113 114 m_GLContext(NULL), 114 115 m_RendererDLL(NULL), 116 m_ModelManager(NULL), 117 m_GuiResources(NULL), 115 118 m_SoundSysDLL(NULL), 116 119 m_GameDLL(NULL), … … 184 187 FreeLibrary(m_SoundSysDLL); 185 188 m_SoundSysDLL=NULL; 189 } 190 191 192 // Release the GUI resources. 193 if (m_GuiResources) 194 { 195 delete m_GuiResources; 196 m_GuiResources=NULL; 197 } 198 199 200 // Release the model manager. 201 if (m_ModelManager) 202 { 203 delete m_ModelManager; 204 m_ModelManager=NULL; 186 205 } 187 206 … … 316 335 case 2: MatSys::TextureMapManager->SetMaxTextureSize(128); break; 317 336 } 337 338 339 // Initialize the model manager and the GUI resources. 340 m_ModelManager=new ModelManagerT(); 341 m_GuiResources=new cf::GuiSys::GuiResourcesT(*m_ModelManager); 318 342 319 343 … … 373 397 // - It has to be done *before* the game is initialized, because even the server needs access to it 374 398 // when it loads static detail model entities that have world/entity-GUIs. 375 cf::GuiSys::GuiMan=new cf::GuiSys::GuiManImplT ;399 cf::GuiSys::GuiMan=new cf::GuiSys::GuiManImplT(*m_GuiResources); 376 400 377 401 … … 397 421 // Note that in the line below, the call to gui:setMousePos() is important, because it sets "MouseOverWindow" in the GUI properly to "Cl". 398 422 // Without this, a left mouse button click that was not preceeded by a mouse movement would erroneously remove the input focus from "Cl". 399 cf::GuiSys::GuiImplT* ClientGui =new cf::GuiSys::GuiImplT( "Cl=gui:new('ClientWindowT'); gui:SetRootWindow(Cl); gui:showMouse(false); gui:setMousePos(320, 240); gui:setFocus(Cl); Cl:SetName('Client');", true);423 cf::GuiSys::GuiImplT* ClientGui =new cf::GuiSys::GuiImplT(*m_GuiResources, "Cl=gui:new('ClientWindowT'); gui:SetRootWindow(Cl); gui:showMouse(false); gui:setMousePos(320, 240); gui:setFocus(Cl); Cl:SetName('Client');", true); 400 424 cf::GuiSys::WindowT* ClientWindow=ClientGui->GetRootWindow()->Find("Client"); 401 425 ClientWindowT* ClWin =dynamic_cast<ClientWindowT*>(ClientWindow); … … 409 433 if (MainMenuGui==NULL) 410 434 { 411 MainMenuGui=new cf::GuiSys::GuiImplT( "Err=gui:new('WindowT'); gui:SetRootWindow(Err); gui:activate(true); gui:setInteractive(true); gui:showMouse(true); Err:set('rect', 0, 0, 640, 480); Err:set('text', 'Error loading MainMenu_main.cgui,\\nsee console <F1> for details.');", true);435 MainMenuGui=new cf::GuiSys::GuiImplT(*m_GuiResources, "Err=gui:new('WindowT'); gui:SetRootWindow(Err); gui:activate(true); gui:setInteractive(true); gui:showMouse(true); Err:set('rect', 0, 0, 640, 480); Err:set('text', 'Error loading MainMenu_main.cgui,\\nsee console <F1> for details.');", true); 412 436 cf::GuiSys::GuiMan->Register(MainMenuGui); 413 437 } -
cafu/trunk/Ca3DE/MainCanvas.hpp
r285 r415 37 37 class ServerT; 38 38 class SvGuiCallbT; 39 class ModelManagerT; 40 namespace cf { namespace GuiSys { class GuiResourcesT; } } 39 41 namespace cf { class ConsoleI; } 40 42 … … 75 77 void OnKeyChar(wxKeyEvent& KE); 76 78 77 MainFrameT* m_Parent; 78 InitStateT m_InitState; ///< Indicates whether initialization is still required, was attempted but failed, or completed successfully. 79 wxGLContext* m_GLContext; ///< The OpenGL rendering context that represents our app-global OpenGL state. 80 HMODULE m_RendererDLL; 81 HMODULE m_SoundSysDLL; 82 HMODULE m_GameDLL; 83 ClientT* m_Client; 84 ServerT* m_Server; 85 SvGuiCallbT* m_SvGuiCallback; 86 cf::ConsoleI* m_ConByGuiWin; ///< This points to an instance of cf::GuiSys::ConsoleByWindowT. 87 TimerT m_Timer; 88 double m_TotalTime; 89 LastMousePosT m_LastMousePos; ///< Used to prevent unwanted changes to the players heading and pitch when we're switching back from a 2D GUI to the 3D client view. 79 MainFrameT* m_Parent; 80 InitStateT m_InitState; ///< Indicates whether initialization is still required, was attempted but failed, or completed successfully. 81 wxGLContext* m_GLContext; ///< The OpenGL rendering context that represents our app-global OpenGL state. 82 HMODULE m_RendererDLL; 83 ModelManagerT* m_ModelManager; 84 cf::GuiSys::GuiResourcesT* m_GuiResources; 85 HMODULE m_SoundSysDLL; 86 HMODULE m_GameDLL; 87 ClientT* m_Client; 88 ServerT* m_Server; 89 SvGuiCallbT* m_SvGuiCallback; 90 cf::ConsoleI* m_ConByGuiWin; ///< This points to an instance of cf::GuiSys::ConsoleByWindowT. 91 TimerT m_Timer; 92 double m_TotalTime; 93 LastMousePosT m_LastMousePos; ///< Used to prevent unwanted changes to the players heading and pitch when we're switching back from a 2D GUI to the 3D client view. 90 94 91 95 DECLARE_EVENT_TABLE() -
cafu/trunk/CaWE/AppCaWE.cpp
r370 r415 53 53 #include "ConsoleCommands/ConFunc.hpp" 54 54 #include "FileSys/FileManImpl.hpp" 55 #include "GuiSys/GuiMan.hpp"56 55 #include "GuiSys/Window.hpp" 57 56 #include "MaterialSystem/MaterialManagerImpl.hpp" … … 75 74 ConsoleInterpreterI* ConsoleInterpreter=NULL; 76 75 MaterialManagerI* MaterialManager =NULL; 77 cf::GuiSys::GuiManI* cf::GuiSys::GuiMan=NULL;78 76 79 77 -
cafu/trunk/CaWE/GameConfig.cpp
r414 r415 37 37 ModDir(ModDir_), 38 38 m_MatMan(*this), 39 m_ModelMan(), 40 m_GuiResources(m_ModelMan), 39 41 m_MaxMapCoord(8192) 40 42 { -
cafu/trunk/CaWE/GameConfig.hpp
r414 r415 24 24 25 25 #include "EditorMaterialManager.hpp" 26 #include "GuiSys/GuiImpl.hpp" 26 27 #include "Math3D/BoundingBox.hpp" 27 28 #include "Models/ModelManager.hpp" … … 63 64 const CafuModelT* GetModel(const wxString& FileName, wxString* ErrorMsg=NULL) const; 64 65 66 /// All GUIs that are created in this game config (no matter if in the Map Editor, the Gui Editor, or the Model Editor) 67 /// share their font and model resources via the returned GuiResourcesT instance. 68 cf::GuiSys::GuiResourcesT& GetGuiResources() { return m_GuiResources; } 69 65 70 int GetMaxMapCoord() const { return m_MaxMapCoord; } 66 71 int GetMinMapCoord() const { return -m_MaxMapCoord; } … … 92 97 EditorMatManT m_MatMan; ///< The material manager for this game config. 93 98 ModelManagerT m_ModelMan; ///< The model manager for this game config. 99 cf::GuiSys::GuiResourcesT m_GuiResources; ///< The provider for resources (fonts and models) for all GUIs in this game config (no matter if in the Map Editor, the Gui Editor, or the Model Editor). 94 100 int m_MaxMapCoord; 95 101 }; -
cafu/trunk/CaWE/GuiEditor/ChildFrame.cpp
r375 r415 674 674 try 675 675 { 676 cf::GuiSys::GuiImplT* Gui=new cf::GuiSys::GuiImplT( std::string(MainScriptFileName));676 cf::GuiSys::GuiImplT* Gui=new cf::GuiSys::GuiImplT(m_GameConfig->GetGuiResources(), std::string(MainScriptFileName)); 677 677 678 678 if (Gui->GetScriptInitResult()!="") -
cafu/trunk/CaWE/GuiEditor/Commands/ModifyWindow.cpp
r388 r415 24 24 #include "../Windows/EditorWindow.hpp" 25 25 26 #include "GuiSys/GuiMan.hpp"27 26 #include "GuiSys/GuiImpl.hpp" 28 27 #include "GuiSys/WindowModel.hpp" … … 125 124 m_Window->BackRenderMat=m_Window->BackRenderMatName.empty() ? NULL : MatSys::Renderer->RegisterMaterial(m_GuiDocument->GetGui()->GetMaterialManager().GetMaterial(m_Window->BackRenderMatName)); 126 125 } 127 else if (m_PropertyName=="FontName")128 {129 m_OldString=m_Window->Font->GetName();130 131 m_Window->Font=cf::GuiSys::GuiMan->GetFont(m_NewString);132 }133 126 else if (m_PropertyName=="Model") 134 127 { … … 200 193 m_Window->BackRenderMat=m_Window->BackRenderMatName.empty() ? NULL : MatSys::Renderer->RegisterMaterial(m_GuiDocument->GetGui()->GetMaterialManager().GetMaterial(m_Window->BackRenderMatName)); 201 194 } 202 else if (m_PropertyName=="FontName")203 {204 m_Window->Font=cf::GuiSys::GuiMan->GetFont(m_OldString);205 }206 195 else if (m_PropertyName=="Model") 207 196 { -
cafu/trunk/CaWE/GuiEditor/Commands/SetWinProp.cpp
r378 r415 76 76 77 77 78 namespace cf { class TrueTypeFontT; } 79 78 80 template class CommandSetWinPropT< ArrayT<std::string> >; 81 template class CommandSetWinPropT< cf::TrueTypeFontT* >; -
cafu/trunk/CaWE/GuiEditor/GuiDocument.cpp
r388 r415 57 57 const std::string gifn(GuiInitFileName); 58 58 59 m_Gui=new cf::GuiSys::GuiImplT( gifn);59 m_Gui=new cf::GuiSys::GuiImplT(GameConfig->GetGuiResources(), gifn); 60 60 61 61 if (m_Gui->GetScriptInitResult()!="") … … 77 77 else 78 78 { 79 m_Gui=new cf::GuiSys::GuiImplT("Win=gui:new('WindowT'); gui:SetRootWindow(Win); gui:showMouse(false); gui:setFocus(Win); Win:SetName('Root'); Win:set(\"rect\", 0, 0, 640, 480);", true); 79 m_Gui=new cf::GuiSys::GuiImplT(GameConfig->GetGuiResources(), 80 "Win=gui:new('WindowT'); gui:SetRootWindow(Win); gui:showMouse(false); gui:setFocus(Win); Win:SetName('Root'); Win:set(\"rect\", 0, 0, 640, 480);", true); 80 81 81 82 m_GuiProperties=GuiPropertiesT(*m_Gui); -
cafu/trunk/CaWE/GuiEditor/GuiDocument.hpp
r388 r415 24 24 25 25 #include "ObserverPattern.hpp" 26 27 26 #include "wx/wx.h" 28 27 -
cafu/trunk/CaWE/GuiEditor/LivePreview.cpp
r285 r415 24 24 #include "../AppCaWE.hpp" 25 25 26 #include "GuiSys/GuiMan.hpp" // For virtual screen sizes.27 26 #include "GuiSys/GuiImpl.hpp" 28 27 #include "OpenGL/OpenGLWindow.hpp" // For CaMouseEventT and CaKeyboardEventT. -
cafu/trunk/CaWE/GuiEditor/RenderWindow.cpp
r374 r415 28 28 29 29 #include "MaterialSystem/Renderer.hpp" 30 #include "GuiSys/Gui Man.hpp" // For virtual screen sizes.30 #include "GuiSys/Gui.hpp" 31 31 #include "GuiSys/Window.hpp" 32 32 -
cafu/trunk/CaWE/GuiEditor/Windows/EditorWindow.cpp
r389 r415 24 24 #include "../GuiDocument.hpp" 25 25 #include "../Commands/ModifyWindow.hpp" 26 #include "../Commands/SetWinProp.hpp" 26 27 #include "../../EditorMaterial.hpp" 27 28 #include "../../MaterialBrowser/DocAccess.hpp" … … 322 323 else if (PropName=="FontName") 323 324 { 324 // Specially treated by command. 325 ChildFrame->SubmitCommand(new CommandModifyWindowT(m_GuiDoc, m_Win, PropName, DummyVar, Prop->GetValueAsString())); 325 cf::TrueTypeFontT* NewFont=m_Win->GetGui().GetGuiResources().GetFont(std::string(Prop->GetValueAsString())); 326 327 ChildFrame->SubmitCommand(new CommandSetWinPropT<cf::TrueTypeFontT*>(m_GuiDoc, this, PropName, m_Win->Font, NewFont)); 326 328 } 327 329 else if (PropName=="Text") -
cafu/trunk/CaWE/ModelEditor/ModelDocument.cpp
r408 r415 71 71 m_AnimState(*m_Model), 72 72 m_Submodels(), 73 m_Gui(new cf::GuiSys::GuiImplT("Win1=gui:new('WindowT'); gui:SetRootWindow(Win1); gui:activate(true); " 73 m_Gui(new cf::GuiSys::GuiImplT(GameConfig->GetGuiResources(), 74 "Win1=gui:new('WindowT'); gui:SetRootWindow(Win1); gui:activate(true); " 74 75 "gui:setInteractive(true); gui:showMouse(true); Win1:set('rect', 0, 0, 640, 480); " 75 76 "Win1:set('backColor', 150/255, 170/255, 204/255, 0.8); " -
cafu/trunk/CaWE/Options.cpp
r285 r415 34 34 OptionsT::~OptionsT() 35 35 { 36 for (unsigned long i=0; i<GameConfigs.Size(); i++) 37 delete GameConfigs[i]; 36 DeleteGameConfigs(); 38 37 } 39 38 … … 221 220 } 222 221 } 222 223 224 void OptionsT::DeleteGameConfigs() 225 { 226 for (unsigned long i=0; i<GameConfigs.Size(); i++) 227 delete GameConfigs[i]; 228 229 GameConfigs.Clear(); 230 } -
cafu/trunk/CaWE/Options.hpp
r285 r415 102 102 void Init(); 103 103 void Write() const; 104 void DeleteGameConfigs(); 104 105 105 106 GeneralT general; -
cafu/trunk/CaWE/ParentFrame.cpp
r376 r415 36 36 #include "FileSys/FileManImpl.hpp" 37 37 #include "GuiSys/GuiImpl.hpp" // Needed to catch InitErrorT if GUI document creation fails. 38 #include "GuiSys/GuiManImpl.hpp"39 38 #include "MaterialSystem/MapComposition.hpp" 40 39 #include "MaterialSystem/Renderer.hpp" … … 185 184 m_FileHistory.Save(*wxConfigBase::Get()); 186 185 187 // Release the GuiManager (BEFORE the renderer). 188 if (cf::GuiSys::GuiMan!=NULL) 189 { 190 delete cf::GuiSys::GuiMan; 191 cf::GuiSys::GuiMan=NULL; 192 } 186 // Release the resources in the game configs before releasing the material system below. 187 Options.DeleteGameConfigs(); 193 188 194 189 // Release the Cafu Material System. … … 305 300 MatSys::Renderer->SetCurrentLightMap(m_WhiteTexture); 306 301 MatSys::Renderer->SetCurrentLightDirMap(NULL); // The MatSys provides a default for LightDirMaps when NULL is set. 307 308 309 // Initialize the GUI manager.310 // This has to be done after all materials are loaded (AppCaWE::OnInit()) and after the MatSys::Renderer has been initialized,311 // so that the GuiManager finds its default material and can register it for rendering.312 // (This is no longer exactly true: each GUI has now its own local material manager! See r359 from 2011-08-29 for details.)313 cf::GuiSys::GuiMan=new cf::GuiSys::GuiManImplT();314 302 } 315 303 } -
cafu/trunk/Libs/GuiSys/Gui.hpp
r367 r415 36 36 namespace GuiSys 37 37 { 38 /// Note that it is very difficult to change these constants later, because then all GUI scripts 39 /// in the world had to be changed too (and in a non-trivial way)! 40 const float VIRTUAL_SCREEN_SIZE_X=640.0f; 41 const float VIRTUAL_SCREEN_SIZE_Y=480.0f; 42 43 38 44 /// General GUI interface. 39 45 class GuiI -
cafu/trunk/Libs/GuiSys/GuiImpl.cpp
r364 r415 21 21 22 22 #include "GuiImpl.hpp" 23 #include "GuiMan.hpp"24 23 #include "Window.hpp" 25 24 #include "WindowCreateParams.hpp" … … 27 26 #include "ConsoleCommands/Console_Lua.hpp" 28 27 #include "ConsoleCommands/ConsoleInterpreter.hpp" 28 #include "Fonts/FontTT.hpp" 29 29 #include "MaterialSystem/Material.hpp" 30 30 #include "MaterialSystem/Mesh.hpp" 31 31 #include "MaterialSystem/Renderer.hpp" 32 #include "Models/ModelManager.hpp" 32 33 #include "OpenGL/OpenGLWindow.hpp" // Just for the Ca*EventT classes... 33 34 #include "String.hpp" … … 57 58 58 59 60 GuiResourcesT::GuiResourcesT(ModelManagerT& ModelMan) 61 : m_ModelMan(ModelMan) 62 { 63 } 64 65 66 GuiResourcesT::~GuiResourcesT() 67 { 68 for (unsigned long FontNr=0; FontNr<m_Fonts.Size(); FontNr++) 69 delete m_Fonts[FontNr]; 70 } 71 72 73 cf::TrueTypeFontT* GuiResourcesT::GetFont(const std::string& FontName) 74 { 75 // See if FontName has been loaded successfully before. 76 for (unsigned long FontNr=0; FontNr<m_Fonts.Size(); FontNr++) 77 if (m_Fonts[FontNr]->GetName()==FontName) 78 return m_Fonts[FontNr]; 79 80 // See if FontName has been loaded UNsuccessfully before. 81 // for (unsigned long FontNr=0; FontNr<m_FontsFailed.Size(); FontNr++) 82 // if (m_FontsFailed[FontNr]==FontName) 83 // return NULL; 84 85 // FontName has never been attempted to be loaded, try now. 86 try 87 { 88 m_Fonts.PushBack(new cf::TrueTypeFontT(FontName)); 89 return m_Fonts[m_Fonts.Size()-1]; 90 } 91 catch (const TextParserT::ParseError&) { } 92 93 Console->Warning(std::string("Failed to load font \"")+FontName+"\".\n"); 94 // FontsFailed.PushBack(FontName); 95 return m_Fonts.Size()>0 ? m_Fonts[0] : NULL; 96 } 97 98 99 const CafuModelT* GuiResourcesT::GetModel(const std::string& FileName, std::string& ErrorMsg) 100 { 101 return m_ModelMan.GetModel(FileName, ErrorMsg); 102 } 103 104 59 105 GuiImplT::InitErrorT::InitErrorT(const std::string& Message) 60 106 : std::runtime_error(Message) … … 63 109 64 110 65 GuiImplT::GuiImplT( const std::string& GuiScriptName, bool IsInlineCode)111 GuiImplT::GuiImplT(GuiResourcesT& GuiRes, const std::string& GuiScriptName, bool IsInlineCode) 66 112 : ScriptName(IsInlineCode ? "" : GuiScriptName), 67 113 LuaState(NULL), … … 70 116 m_GuiDefaultRM(NULL), 71 117 m_GuiPointerRM(NULL), 118 m_GuiResources(GuiRes), 72 119 RootWindow(NULL), 73 120 FocusWindow(NULL), -
cafu/trunk/Libs/GuiSys/GuiImpl.hpp
r367 r415 32 32 33 33 namespace cf { namespace TypeSys { class TypeInfoT; } } 34 namespace cf { class TrueTypeFontT; } 34 35 namespace MatSys { class RenderMaterialT; } 36 class CafuModelT; 37 class ModelManagerT; 35 38 struct lua_State; 36 39 … … 40 43 namespace GuiSys 41 44 { 45 /// This class manages and provides resources (fonts and models) for GuiImplT instances. 46 /// One GuiResourcesT can be commonly used for several GuiImplT instances at once. 47 class GuiResourcesT 48 { 49 public: 50 51 /// The constructor. 52 GuiResourcesT(ModelManagerT& ModelMan); 53 54 /// The destructor. 55 ~GuiResourcesT(); 56 57 /// Returns (a pointer to) a font instance for the given filename. 58 /// The returned font instance is possibly shared with other users, and must not be deleted. 59 /// @param FontName The name of the font to return. 60 /// @returns A pointer to the specified font, or NULL if there was an error (e.g. the font could not be loaded). 61 TrueTypeFontT* GetFont(const std::string& FontName); 62 63 /// Returns (a pointer to) a model instance for the given filename. 64 /// @see ModelManagerT::GetModel() for more details. 65 const CafuModelT* GetModel(const std::string& FileName, std::string& ErrorMsg); 66 67 68 private: 69 70 GuiResourcesT(const GuiResourcesT&); ///< Use of the Copy Constructor is not allowed. 71 void operator = (const GuiResourcesT&); ///< Use of the Assignment Operator is not allowed. 72 73 ArrayT<TrueTypeFontT*> m_Fonts; ///< The fonts that are used within the GUIs. 74 ModelManagerT& m_ModelMan; ///< The model manager from which any models that occur in the GUIs are aquired. 75 }; 76 77 42 78 /// This class implements the GuiI interface. 43 79 /// TODO / FIXME: … … 55 91 56 92 /// Constructor for creating a window hierarchy (=="a GUI") from the GUI script file GuiScriptName. 57 /// @param GuiScriptName The file name of the GUI script to load or inline script code (depending on IsInlineCode). 58 /// @param IsInlineCode Whether GuIScriptName is inline script code or a filename. 93 /// @param GuiRes The provider for resources (fonts and models) that are used in this GUI. 94 /// @param GuiScriptName The file name of the GUI script to load or inline script code (depending on IsInlineCode). 95 /// @param IsInlineCode Whether GuiScriptName is inline script code or a filename. 59 96 /// @throws an InitErrorT object on problems initializing the GUI. 60 GuiImplT( const std::string& GuiScriptName, bool IsInlineCode=false);97 GuiImplT(GuiResourcesT& GuiRes, const std::string& GuiScriptName, bool IsInlineCode=false); 61 98 62 99 /// The destructor. … … 76 113 /// Returns the (default) RenderMaterialT for the mouse pointer. 77 114 MatSys::RenderMaterialT* GetPointerRM() const; 115 116 /// Returns the resource provider for fonts and models that are used in this GUI. 117 GuiResourcesT& GetGuiResources() const { return m_GuiResources; } 78 118 79 119 … … 133 173 MatSys::RenderMaterialT* m_GuiDefaultRM; ///< Used for the window borders and the backgrounds if no other material is specified. 134 174 MatSys::RenderMaterialT* m_GuiPointerRM; ///< Used for the mouse pointer. 175 GuiResourcesT& m_GuiResources; ///< The provider for resources (fonts and models) that are used in this GUI. 135 176 136 177 WindowPtrT RootWindow; ///< The root window of the window hierarchy that forms this GUI. -
cafu/trunk/Libs/GuiSys/GuiMan.hpp
r359 r415 32 32 namespace cf 33 33 { 34 class TrueTypeFontT;35 36 37 34 namespace GuiSys 38 35 { 39 36 class GuiI; 40 41 /// Note that it is very difficult to change these constants later, because then all GUI scripts42 /// in the world had to be changed too (and in a non-trivial way)!43 const float VIRTUAL_SCREEN_SIZE_X=640.0f;44 const float VIRTUAL_SCREEN_SIZE_Y=480.0f;45 37 46 38 … … 97 89 virtual void DistributeClockTickEvents(float t)=0; 98 90 99 /// Returns (a pointer to) the font with name FontName.100 /// The returned pointer is valid throughout the lifetime of the implementation of this GuiManI,101 /// and must not be freed (the GuiMan retains the ownership of the font).102 /// @param FontName Name of the font to get.103 /// @returns a pointer to the desired font, or NULL if there was an error (e.g. the font could not be loaded).104 virtual TrueTypeFontT* GetFont(const std::string& FontName)=0;105 106 91 /// The destructor. 107 92 /// This ABC does neither have nor need a destructor, because no implementation will ever be deleted via a pointer to a GuiManI. -
cafu/trunk/Libs/GuiSys/GuiManImpl.cpp
r359 r415 28 28 #include "MaterialSystem/Renderer.hpp" 29 29 #include "Math3D/Matrix.hpp" 30 #include "Fonts/FontTT.hpp" // For dealing with the default font.31 30 #include "OpenGL/OpenGLWindow.hpp" // Just for the Ca*EventT classes... 32 31 … … 39 38 40 39 41 GuiManImplT::GuiManImplT() 42 : SuppressNextChar(false) 40 GuiManImplT::GuiManImplT(GuiResourcesT& GuiRes) 41 : m_GuiResources(GuiRes), 42 SuppressNextChar(false) 43 43 { 44 44 assert(MatSys::Renderer!=NULL); … … 51 51 for (unsigned long GuiNr=0; GuiNr<Guis.Size(); GuiNr++) 52 52 delete Guis[GuiNr]; 53 54 // Free the Fonts.55 for (unsigned long FontNr=0; FontNr<Fonts.Size(); FontNr++)56 delete Fonts[FontNr];57 53 } 58 54 … … 62 58 try 63 59 { 64 Guis.PushBack(new GuiImplT( GuiScriptName));60 Guis.PushBack(new GuiImplT(m_GuiResources, GuiScriptName)); 65 61 66 62 return Guis[Guis.Size()-1]; … … 139 135 try 140 136 { 141 GuiI* Reloaded=new GuiImplT( Guis[GuiNr]->GetScriptName());137 GuiI* Reloaded=new GuiImplT(m_GuiResources, Guis[GuiNr]->GetScriptName()); 142 138 143 139 delete Guis[GuiNr]; … … 236 232 } 237 233 } 238 239 240 cf::TrueTypeFontT* GuiManImplT::GetFont(const std::string& FontName)241 {242 // See if FontName has been loaded successfully before.243 for (unsigned long FontNr=0; FontNr<Fonts.Size(); FontNr++)244 if (Fonts[FontNr]->GetName()==FontName)245 return Fonts[FontNr];246 247 // See if FontName has been loaded UNsuccessfully before.248 // for (unsigned long FontNr=0; FontNr<FontsFailed.Size(); FontNr++)249 // if (FontsFailed[FontNr]==FontName)250 // return NULL;251 252 // FontName has never been attempted to be loaded, try now.253 try254 {255 Fonts.PushBack(new cf::TrueTypeFontT(FontName));256 return Fonts[Fonts.Size()-1];257 }258 catch (const TextParserT::ParseError&) { }259 260 Console->Warning(std::string("Failed to load font \"")+FontName+"\".\n");261 // FontsFailed.PushBack(FontName);262 return Fonts.Size()>0 ? Fonts[0] : NULL;263 } -
cafu/trunk/Libs/GuiSys/GuiManImpl.hpp
r359 r415 31 31 namespace GuiSys 32 32 { 33 class GuiResourcesT; 34 35 33 36 /// This class implements the GuiManI interface. 34 37 class GuiManImplT : public GuiManI … … 38 41 /// The constructor. 39 42 /// The MatSys *must* be initialized *before* this constructor is called (i.e. a GuiManImplT is instantiated)! 40 GuiManImplT( );43 GuiManImplT(GuiResourcesT& GuiRes); 41 44 42 45 /// The destructor. … … 56 59 void ProcessDeviceEvent(const CaMouseEventT& ME); 57 60 void DistributeClockTickEvents(float t); 58 TrueTypeFontT* GetFont(const std::string& FontName);59 61 60 62 … … 64 66 void operator = (const GuiManImplT&); ///< Use of the Assignment Operator is not allowed. 65 67 66 ArrayT<GuiI*> Guis; 67 ArrayT<TrueTypeFontT*> Fonts; ///< The fonts that are used with the GUIs. We manage a GuiMan-global pool here in order to avoid instance duplication if multiple GUIs use the same font. 68 // ArrayT<std::string> FontsFailed; ///< The fonts that have been attempted to load, but failed (kept in order to avoid retries). 69 bool SuppressNextChar; ///< Whether the next character (CaKeyboardEventT::CKE_CHAR) event should be suppressed. This is true whenever the preceeding CaKeyboardEventT::CKE_KEYDOWN event was positively processed. 68 GuiResourcesT& m_GuiResources; ///< The provider for resources (fonts and models) that are used in the GUIs created by this GuiMan. 69 ArrayT<GuiI*> Guis; 70 bool SuppressNextChar; ///< Whether the next character (CaKeyboardEventT::CKE_CHAR) event should be suppressed. This is true whenever the preceeding CaKeyboardEventT::CKE_KEYDOWN event was positively processed. 70 71 }; 71 72 } -
cafu/trunk/Libs/GuiSys/Window.cpp
r386 r415 106 106 BorderWidth(0.0f), 107 107 // BorderColor(), 108 Font( GuiMan->GetFont(DEFAULT_FONT_NAME)),108 Font(Params.Gui.GetGuiResources().GetFont(DEFAULT_FONT_NAME)), 109 109 Text(""), 110 110 TextScale(1.0f), … … 140 140 BackRenderMatName(Window.BackRenderMatName), 141 141 BorderWidth(Window.BorderWidth), 142 Font( GuiMan->GetFont(Window.Font->GetName())),142 Font(Window.Font), 143 143 Text(Window.Text), 144 144 TextScale(Window.TextScale), … … 727 727 const std::string FontName=luaL_checkstring(LuaState, 3); 728 728 729 Win->Font= GuiMan->GetFont(FontName);729 Win->Font=Win->m_Gui.GetGuiResources().GetFont(FontName); 730 730 return 0; 731 731 } -
cafu/trunk/Libs/Models/AnimPose.hpp
r406 r415 105 105 ~AnimPoseT(); 106 106 107 /// @param Sequ enceNr The number of the animation sequence to use, -1 for the bind pose.107 /// @param SequNr The number of the animation sequence to use, -1 for the bind pose. 108 108 void SetSequNr(int SequNr); 109 109 -
cafu/trunk/Libs/Models/ModelManager.hpp
r414 r415 24 24 25 25 #include <map> 26 #include <string> 26 27 27 28
