Ticket #2007: CGuiManager.patch
File CGuiManager.patch, 3.7 KB (added by , 11 years ago) |
---|
-
gui/GUIManager.cpp
117 117 page.gui.reset(new CGUI()); 118 118 page.gui->Initialize(); 119 119 120 VfsPath path = VfsPath("gui") / page.name; 120 VfsPath guiPath("gui"); 121 VfsPath path = guiPath / page.name; 121 122 page.inputs.insert(path); 122 123 123 124 CXeromyces xero; … … 136 137 return; 137 138 } 138 139 140 // @note 2013.06.26 - pulled this outside the loop so it acts like a proper buffer 141 CStrW name; 142 139 143 XERO_ITER_EL(root, node) 140 144 { 141 145 if (node.GetNodeName() != elmt_include) … … 144 148 continue; 145 149 } 146 150 147 CStrW name (node.GetText().FromUTF8());151 node.GetTextW(name); 148 152 149 153 PROFILE2("load gui xml"); 150 154 PROFILE2_ATTR("name: %ls", name.c_str()); 151 155 152 156 TIMER(name.c_str()); 153 VfsPath path = VfsPath("gui")/ name;157 path = guiPath / name; 154 158 page.gui->LoadXmlFile(path, page.inputs); 155 159 } 156 160 … … 171 175 172 176 Status CGUIManager::ReloadChangedFiles(const VfsPath& path) 173 177 { 174 for (PageStackType::iterator it = m_PageStack.begin(); it != m_PageStack.end(); ++it) 178 PageStackType::iterator end = m_PageStack.end(); 179 for (PageStackType::iterator it = m_PageStack.begin(); it != end; ++it) 175 180 { 176 181 if (it->inputs.count(path)) 177 182 { … … 261 266 { 262 267 PROFILE3("gui tick"); 263 268 264 // Save an immutable copy so iterators aren't invalidated by tick handlers 265 PageStackType pageStack = m_PageStack; 266 267 for (PageStackType::iterator it = pageStack.begin(); it != pageStack.end(); ++it) 269 // @note Using i to avoid iterator invalidation when scripts PushPage/SwitchPage 270 // @note Need to always check m_PageStack.size() 271 for (int i = 0; i < m_PageStack.size(); ++i) 268 272 { 269 m_CurrentGUI = it->gui;270 it->gui->TickObjects();273 m_CurrentGUI = m_PageStack[i].gui; 274 m_CurrentGUI->TickObjects(); 271 275 } 272 276 m_CurrentGUI.reset(); 273 277 } … … 276 280 { 277 281 PROFILE3_GPU("gui"); 278 282 279 for (PageStackType::iterator it = m_PageStack.begin(); it != m_PageStack.end(); ++it) 283 PageStackType::iterator end = m_PageStack.end(); 284 for (PageStackType::iterator it = m_PageStack.begin(); it != end; ++it) 280 285 it->gui->Draw(); 281 286 } 282 287 283 288 void CGUIManager::UpdateResolution() 284 289 { 285 for (PageStackType::iterator it = m_PageStack.begin(); it != m_PageStack.end(); ++it) 290 PageStackType::iterator end = m_PageStack.end(); 291 for (PageStackType::iterator it = m_PageStack.begin(); it != end; ++it) 286 292 it->gui->UpdateResolution(); 287 293 } 288 294 -
ps/XML/XeroXMB.cpp
199 199 if (m_Pointer == NULL || *(int*)(m_Pointer + 20) == 0) 200 200 return CStr8(); 201 201 202 // @note - This is really nasty stuff. Should read up on: http://www.joelonsoftware.com/articles/Unicode.html 202 203 return CStrW(utf16string((utf16_t*)(m_Pointer + 28))).ToUTF8(); 203 204 } 204 205 206 void XMBElement::GetTextW(CStrW& out) const 207 { 208 // Return empty string if there's no text 209 if (m_Pointer == NULL || *(int*)(m_Pointer + 20) == 0) 210 { 211 out.clear(); 212 return; 213 } 214 out = CStrW(utf16string((utf16_t*)(m_Pointer + 28))); 215 } 216 205 217 int XMBElement::GetLineNumber() const 206 218 { 207 219 // Make sure there actually was some text to record the line of -
ps/XML/XeroXMB.h
179 179 XMBElementList GetChildNodes() const; 180 180 XMBAttributeList GetAttributes() const; 181 181 CStr8 GetText() const; 182 void GetTextW(CStrW& out) const; 182 183 // Returns the line number of the text within this element, 183 184 // or -1 if there is no text 184 185 int GetLineNumber() const;