Changeset 374 for cafu/trunk
- Timestamp:
- 09/10/11 10:57:11 (9 months ago)
- Location:
- cafu/trunk
- Files:
-
- 2 added
- 15 modified
-
CaWE/GuiEditor/Commands/ModifyWindow.cpp (modified) (3 diffs)
-
CaWE/GuiEditor/Commands/SetStrings.cpp (added)
-
CaWE/GuiEditor/Commands/SetStrings.hpp (added)
-
CaWE/GuiEditor/ObserverPattern.cpp (modified) (1 diff)
-
CaWE/GuiEditor/ObserverPattern.hpp (modified) (3 diffs)
-
CaWE/GuiEditor/RenderWindow.cpp (modified) (1 diff)
-
CaWE/GuiEditor/RenderWindow.hpp (modified) (1 diff)
-
CaWE/GuiEditor/WindowInspector.cpp (modified) (3 diffs)
-
CaWE/GuiEditor/WindowInspector.hpp (modified) (2 diffs)
-
CaWE/GuiEditor/WindowTree.cpp (modified) (1 diff)
-
CaWE/GuiEditor/WindowTree.hpp (modified) (1 diff)
-
CaWE/GuiEditor/Windows/EditorChoiceWindow.cpp (modified) (4 diffs)
-
CaWE/GuiEditor/Windows/EditorWindow.hpp (modified) (1 diff)
-
CaWE/ModelEditor/ObserverPattern.hpp (modified) (1 diff)
-
Games/DeathMatch/GUIs/MainMenu/MainMenu_init.cgui (modified) (1 diff)
-
Libs/GuiSys/Window.hpp (modified) (1 diff)
-
Libs/GuiSys/WindowChoice.hpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/GuiEditor/Commands/ModifyWindow.cpp
r367 r374 26 26 #include "GuiSys/GuiMan.hpp" 27 27 #include "GuiSys/GuiImpl.hpp" 28 #include "GuiSys/WindowChoice.hpp"29 28 #include "GuiSys/WindowModel.hpp" 30 29 #include "MaterialSystem/Renderer.hpp" 31 30 #include "MaterialSystem/MaterialManager.hpp" 32 31 #include "Fonts/FontTT.hpp" 33 #include "TextParser/TextParser.hpp"34 32 35 33 … … 138 136 m_Window->Font=cf::GuiSys::GuiMan->GetFont(m_NewString); 139 137 } 140 else if (m_PropertyName=="Choices")141 {142 cf::GuiSys::ChoiceT* ChoiceWindow=dynamic_cast<cf::GuiSys::ChoiceT*>(m_Window);143 wxASSERT(ChoiceWindow!=NULL);144 145 m_OldString="";146 147 ArrayT<std::string>& Choices=ChoiceWindow->GetChoices();148 149 for (unsigned long ChoiceNr=0; ChoiceNr<Choices.Size(); ChoiceNr++)150 m_OldString+=Choices[ChoiceNr]+";";151 152 // Parse choice list and update the window choices.153 TextParserT ChoiceParser(m_NewString.c_str(), ";", false);154 Choices.Clear();155 156 try157 {158 while (!ChoiceParser.IsAtEOF())159 {160 Choices.PushBack(ChoiceParser.GetNextToken());161 ChoiceParser.AssertAndSkipToken(";");162 }163 }164 catch (const TextParserT::ParseError&)165 {166 // Undo all changes made up to this point.167 try168 {169 TextParserT ChoiceParser(m_OldString.c_str(), ";", false);170 Choices.Clear();171 172 while (!ChoiceParser.IsAtEOF())173 {174 Choices.PushBack(ChoiceParser.GetNextToken());175 ChoiceParser.AssertAndSkipToken(";");176 }177 }178 catch (const TextParserT::ParseError&)179 {180 wxASSERT(false);181 return false;182 }183 184 return false;185 }186 }187 138 else if (m_PropertyName=="Model") 188 139 { … … 258 209 m_Window->Font=cf::GuiSys::GuiMan->GetFont(m_OldString); 259 210 } 260 else if (m_PropertyName=="Choices")261 {262 cf::GuiSys::ChoiceT* ChoiceWindow=dynamic_cast<cf::GuiSys::ChoiceT*>(m_Window);263 wxASSERT(ChoiceWindow!=NULL);264 265 ArrayT<std::string>& Choices=ChoiceWindow->GetChoices();266 267 // Parse choice list and update the window choices.268 TextParserT ChoiceParser(m_OldString.c_str(), ";", false);269 Choices.Clear();270 271 try272 {273 while (!ChoiceParser.IsAtEOF())274 {275 Choices.PushBack(ChoiceParser.GetNextToken());276 ChoiceParser.AssertAndSkipToken(";");277 }278 }279 catch (const TextParserT::ParseError&)280 {281 wxASSERT(false);282 }283 }284 211 else if (m_PropertyName=="Model") 285 212 { -
cafu/trunk/CaWE/GuiEditor/ObserverPattern.cpp
r285 r374 138 138 139 139 140 void SubjectT::UpdateAllObservers_Modified(const EditorWindowT* Win, const wxString& PropName) 141 { 142 for (unsigned long ObsNr=0; ObsNr<m_Observers.Size(); ObsNr++) 143 m_Observers[ObsNr]->Notify_WinChanged(this, Win, PropName); 144 } 145 146 140 147 SubjectT::~SubjectT() 141 148 { -
cafu/trunk/CaWE/GuiEditor/ObserverPattern.hpp
r316 r374 42 42 namespace GuiEditor 43 43 { 44 class EditorWindowT; 44 45 class SubjectT; 45 46 class UpdateBoxT; … … 98 99 //@} 99 100 101 /// Notifies the observer that a property of a window has changed. 102 /// @param Subject The GUI document whose window has changed. 103 /// @param Win The window whose property has changed. 104 /// @param PropName The name of the property whose value has changed. 105 virtual void Notify_WinChanged(SubjectT* Subject, const EditorWindowT* Win, const wxString& PropName) { } 106 100 107 /// This method is called whenever a subject is about the be destroyed (and become unavailable). 101 /// \param dyingSubject The subject that is being destroyed.108 /// @param dyingSubject The subject that is being destroyed. 102 109 virtual void NotifySubjectDies(SubjectT* dyingSubject)=0; 103 110 … … 135 142 virtual void UpdateAllObservers_Modified(const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail, const wxString& PropertyName); 136 143 virtual void UpdateAllObservers_Modified(cf::GuiSys::WindowT* Window, WindowModDetailE Detail, const wxString& PropertyName); 144 virtual void UpdateAllObservers_Modified(const EditorWindowT* Win, const wxString& PropName); 137 145 138 146 /// The virtual destructor. -
cafu/trunk/CaWE/GuiEditor/RenderWindow.cpp
r367 r374 101 101 102 102 103 void RenderWindowT::Notify_WinChanged(SubjectT* Subject, const EditorWindowT* Win, const wxString& PropName) 104 { 105 Refresh(false); 106 } 107 108 103 109 void RenderWindowT::NotifySubjectDies(SubjectT* dyingSubject) 104 110 { -
cafu/trunk/CaWE/GuiEditor/RenderWindow.hpp
r285 r374 47 47 void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail); 48 48 void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail, const wxString& PropertyName); 49 void Notify_WinChanged(SubjectT* Subject, const EditorWindowT* Win, const wxString& PropName); 49 50 void NotifySubjectDies(SubjectT* dyingSubject); 50 51 -
cafu/trunk/CaWE/GuiEditor/WindowInspector.cpp
r367 r374 73 73 void WindowInspectorT::NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail) 74 74 { 75 if (!m_SelectedWindow) return; 76 77 if (Detail==WMD_HIERARCHY) return; // The ordner doesn't affect the window inspector. 78 79 for (unsigned long WindowNr=0; WindowNr<Windows.Size(); WindowNr++) 80 { 81 if (m_SelectedWindow==Windows[WindowNr]) 82 { 83 if (Detail==WMD_GENERIC) 84 { 85 RefreshPropGrid(); 86 return; 87 } 88 89 if (Detail==WMD_TRANSFORMED) 90 { 91 // Update all transformation related properties (position, size, rotation). 92 wxPGProperty* Property=GetProperty("Position.X"); 93 Property->SetValue(wxVariant(m_SelectedWindow->Rect[0])); 94 95 Property=GetProperty("Position.Y"); 96 Property->SetValue(wxVariant(m_SelectedWindow->Rect[1])); 97 98 Property=GetProperty("Size.Width"); 99 Property->SetValue(wxVariant(m_SelectedWindow->Rect[2])); 100 101 Property=GetProperty("Size.Height"); 102 Property->SetValue(wxVariant(m_SelectedWindow->Rect[3])); 103 104 Property=GetProperty("Rotation"); 105 Property->SetValue(wxVariant(m_SelectedWindow->RotAngle)); 106 107 RefreshGrid(); 108 109 return; 110 } 111 112 if (Detail==WMD_HOR_TEXT_ALIGN) 113 { 114 wxPGProperty* Property=GetProperty("HorizontalAlign"); 115 Property->SetValueFromInt(int(m_SelectedWindow->TextAlignHor)); 116 117 RefreshGrid(); 118 119 return; 120 } 75 if (m_IsRecursiveSelfNotify) return; 76 if (!m_SelectedWindow) return; 77 if (Windows.Find(m_SelectedWindow)==-1) return; 78 79 switch (Detail) 80 { 81 case WMD_HIERARCHY: 82 { 83 // The window hierarchy doesn't affect the window inspector. 84 break; 85 } 86 87 case WMD_GENERIC: 88 { 89 RefreshPropGrid(); 90 break; 91 } 92 93 case WMD_TRANSFORMED: 94 { 95 // Update all transformation related properties (position, size, rotation). 96 wxPGProperty* Property=GetProperty("Position.X"); 97 Property->SetValue(wxVariant(m_SelectedWindow->Rect[0])); 98 99 Property=GetProperty("Position.Y"); 100 Property->SetValue(wxVariant(m_SelectedWindow->Rect[1])); 101 102 Property=GetProperty("Size.Width"); 103 Property->SetValue(wxVariant(m_SelectedWindow->Rect[2])); 104 105 Property=GetProperty("Size.Height"); 106 Property->SetValue(wxVariant(m_SelectedWindow->Rect[3])); 107 108 Property=GetProperty("Rotation"); 109 Property->SetValue(wxVariant(m_SelectedWindow->RotAngle)); 110 111 RefreshGrid(); 112 break; 113 } 114 115 case WMD_HOR_TEXT_ALIGN: 116 { 117 wxPGProperty* Property=GetProperty("HorizontalAlign"); 118 Property->SetValueFromInt(int(m_SelectedWindow->TextAlignHor)); 119 120 RefreshGrid(); 121 break; 121 122 } 122 123 } … … 127 128 { 128 129 if (m_IsRecursiveSelfNotify) return; 129 130 if (!m_SelectedWindow) return; 131 132 for (unsigned long WindowNr=0; WindowNr<Windows.Size(); WindowNr++) 133 { 134 if (m_SelectedWindow==Windows[WindowNr]) 135 { 136 wxPGProperty* Property=GetProperty(PropertyName); 137 wxASSERT(Property); 138 139 GuiDocumentT::GetSibling(m_SelectedWindow)->UpdateProperty(Property); 140 141 RefreshGrid(); 142 return; 143 } 144 } 130 if (!m_SelectedWindow) return; 131 if (Windows.Find(m_SelectedWindow)==-1) return; 132 133 wxPGProperty* Property=GetProperty(PropertyName); 134 wxASSERT(Property); 135 136 GuiDocumentT::GetSibling(m_SelectedWindow)->UpdateProperty(Property); 137 RefreshGrid(); 138 } 139 140 141 void WindowInspectorT::Notify_WinChanged(SubjectT* Subject, const EditorWindowT* Win, const wxString& PropName) 142 { 143 if (m_IsRecursiveSelfNotify) return; 144 if (!m_SelectedWindow) return; 145 if (Win->GetDual()!=m_SelectedWindow) return; 146 147 wxPGProperty* Property=GetProperty(PropName); 148 wxASSERT(Property); 149 150 GuiDocumentT::GetSibling(m_SelectedWindow)->UpdateProperty(Property); 151 RefreshGrid(); 145 152 } 146 153 … … 196 203 ClearSelection(); 197 204 205 m_IsRecursiveSelfNotify=true; 198 206 GuiDocumentT::GetSibling(m_SelectedWindow)->HandlePGChange(Event, m_Parent); 199 } 207 m_IsRecursiveSelfNotify=false; 208 } -
cafu/trunk/CaWE/GuiEditor/WindowInspector.hpp
r285 r374 48 48 void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail); 49 49 void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail, const wxString& PropertyName); 50 void Notify_WinChanged(SubjectT* Subject, const EditorWindowT* Win, const wxString& PropName); 50 51 void NotifySubjectDies(SubjectT* dyingSubject); 51 52 … … 60 61 bool m_IsRecursiveSelfNotify; 61 62 62 63 63 void OnPropertyGridChanged(wxPropertyGridEvent& Event); 64 64 -
cafu/trunk/CaWE/GuiEditor/WindowTree.cpp
r367 r374 240 240 241 241 242 void WindowTreeT::Notify_WinChanged(SubjectT* Subject, const EditorWindowT* Win, const wxString& PropName) 243 { 244 } 245 246 242 247 void WindowTreeT::RefreshTree() 243 248 { -
cafu/trunk/CaWE/GuiEditor/WindowTree.hpp
r293 r374 64 64 void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail); 65 65 void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<cf::GuiSys::WindowT*>& Windows, WindowModDetailE Detail, const wxString& PropertyName); 66 void Notify_WinChanged(SubjectT* Subject, const EditorWindowT* Win, const wxString& PropName); 66 67 void NotifySubjectDies(SubjectT* dyingSubject); 67 68 -
cafu/trunk/CaWE/GuiEditor/Windows/EditorChoiceWindow.cpp
r373 r374 24 24 #include "../GuiDocument.hpp" 25 25 #include "../Commands/ModifyWindow.hpp" 26 #include "../Commands/SetStrings.hpp" 26 27 27 28 #include "GuiSys/WindowChoice.hpp" … … 45 46 EditorWindowT::FillInPG(PropMan); 46 47 47 wxString ChoicesString;48 wxString Str; 48 49 49 50 for (unsigned long ChoiceNr=0; ChoiceNr<m_Choice->GetChoices().Size(); ChoiceNr++) 50 ChoicesString+=m_Choice->GetChoices()[ChoiceNr]+";\n"; 51 { 52 if (ChoiceNr>0) Str+="\n"; 53 Str+=m_Choice->GetChoices()[ChoiceNr]; 54 } 51 55 52 PropMan->Append(new wxLongStringProperty("Choices", wxPG_LABEL, ChoicesString));56 PropMan->Append(new wxLongStringProperty("Choices", wxPG_LABEL, Str)); 53 57 PropMan->Append(new wxIntProperty("DefaultChoice", wxPG_LABEL, m_Choice->GetSelectedChoice())); 54 58 } … … 63 67 if (PropName=="Choices") 64 68 { 65 wxString ChoicesString;69 wxString Str; 66 70 67 71 for (unsigned long ChoiceNr=0; ChoiceNr<m_Choice->GetChoices().Size(); ChoiceNr++) 68 ChoicesString+=m_Choice->GetChoices()[ChoiceNr]+";\n"; 72 { 73 if (ChoiceNr>0) Str+="\n"; 74 Str+=m_Choice->GetChoices()[ChoiceNr]; 75 } 69 76 70 Property->SetValueFromString( ChoicesString);77 Property->SetValueFromString(Str); 71 78 return true; 72 79 } … … 91 98 if (PropName=="Choices") 92 99 { 93 static cf::GuiSys::WindowT::MemberVarT DummyVar; 100 ArrayT<std::string> NewStrings; 101 wxStringTokenizer Tokenizer(Prop->GetValueAsString(), "\r\n"); 94 102 95 // Remove all newline characters from the string since they break the choices display. 96 wxString FormattedString=Prop->GetValueAsString(); 97 FormattedString.Replace("\\n", ""); 98 // Remove all trailing characters after the last delimiter (;). 99 FormattedString=FormattedString.Mid(0, FormattedString.Find(';', true)+1); 103 while (Tokenizer.HasMoreTokens()) 104 NewStrings.PushBack(std::string(Tokenizer.GetNextToken())); 100 105 101 // Specially treated by command. 102 ChildFrame->SubmitCommand(new CommandModifyWindowT(m_GuiDoc, m_Choice, PropName, DummyVar, FormattedString)); 106 ChildFrame->SubmitCommand(new CommandSetStringsT(m_GuiDoc, this, PropName, m_Choice->m_Choices, NewStrings)); 103 107 return true; 104 108 } -
cafu/trunk/CaWE/GuiEditor/Windows/EditorWindow.hpp
r367 r374 48 48 /// The destructor. 49 49 virtual ~EditorWindowT() { } 50 51 /// Returns the GuiSys "dual" or "sibling" of this window. 52 const cf::GuiSys::WindowT* GetDual() const { return m_Win; } 50 53 51 54 /// Returns the GuiDocumentT instance that this window lives in. -
cafu/trunk/CaWE/ModelEditor/ObserverPattern.hpp
r341 r374 88 88 virtual void Notify_AnimStateChanged(SubjectT* Subject) { } 89 89 90 /// Notifies the observer that the list zof submodels has changed.90 /// Notifies the observer that the list of submodels has changed. 91 91 /// @param Subject The model document with the model in which the list of submodels has changed. 92 92 virtual void Notify_SubmodelsChanged(SubjectT* Subject) { } -
cafu/trunk/Games/DeathMatch/GUIs/MainMenu/MainMenu_init.cgui
r51 r374 1258 1258 self:set("backColor", 0, 0, 0, 0); 1259 1259 self:set("font", "Fonts/Impact"); 1260 self:set("text", "Cafu is copyright © 2001-201 0Carsten Fuchs Software.\nAll rights reserved. http://www.cafu.de");1260 self:set("text", "Cafu is copyright © 2001-2011 Carsten Fuchs Software.\nAll rights reserved. http://www.cafu.de"); 1261 1261 self:set("textScale", 0.22); 1262 1262 self:set("textColor", 0.5, 0.5, 0.5, 1); -
cafu/trunk/Libs/GuiSys/Window.hpp
r367 r374 117 117 118 118 /// Extra / extern / extension data that user code can derive from and assign to this window 119 /// in order to "configure" it with "callbacks" (e \.g\.the \c Render() method) and to have it119 /// in order to "configure" it with "callbacks" (e.g.\ the \c Render() method) and to have it 120 120 /// store additional user-specific data and functions. 121 121 struct ExtDataT -
cafu/trunk/Libs/GuiSys/WindowChoice.hpp
r373 r374 26 26 27 27 28 namespace GuiEditor { class EditorChoiceWindowT; } 29 30 28 31 namespace cf 29 32 { … … 31 34 { 32 35 /// A choice window. 33 /// This was initially intended to look-n-feel like a combobox under Windows, 34 /// but it turns out that for speed and ease of implementation, an entirely 35 /// different approach is more feasible (for now). 36 /// This was initially intended to look and feel like a "combobox" under Windows, 37 /// but for ease of implementation, the current approach works slightly different. 36 38 class ChoiceT : public WindowT 37 39 { 38 40 public: 39 41 40 /// Constructor for creating a listbox.41 /// @param Params Choice creation parameters.42 /// Constructor for creating a choice. 43 /// @param Params Choice creation parameters. 42 44 ChoiceT(const cf::GuiSys::WindowCreateParamsT& Params); 43 45 44 /// The Copy Constructor.45 /// @param Window Window to copy.46 /// @param Recursive Whether to copy the whole window hierarchy of the window and its children.46 /// The copy constructor. 47 /// @param Window Window to copy. 48 /// @param Recursive Whether to copy the whole window hierarchy of the window and its children. 47 49 ChoiceT(const ChoiceT& Window, bool Recursive=false); 48 50 … … 53 55 54 56 /// Returns an array of the choices of this window. 55 ArrayT<std::string>& GetChoices(){ return m_Choices; }57 const ArrayT<std::string>& GetChoices() const { return m_Choices; } 56 58 59 /// Returns the currently selected choice, -1 for none. 57 60 int GetSelectedChoice() const { return m_SelectedChoice; } 58 61 … … 69 72 70 73 protected: 74 75 friend class GuiEditor::EditorChoiceWindowT; 71 76 72 77 void FillMemberVars(); ///< Helper method that fills the MemberVars array with entries for each class member.
