diff --git a/source/gui/CButton.cpp b/source/gui/CButton.cpp index c4db8746c7..51d36e73ad 100755 --- a/source/gui/CButton.cpp +++ b/source/gui/CButton.cpp @@ -140,8 +140,8 @@ void CButton::Draw() ////////// glPushMatrix(); -/// glTranslatef(0.0f, 0.0f, GetBaseSettings().m_Z); - glTranslatef(0.0f, 0.0f, 0.0f); + glTranslatef(0.0f, 0.0f, GetBaseSettings().m_Z); +/// glTranslatef(0.0f, 0.0f, 0.0f); // Do this glBegin(GL_QUADS); @@ -151,12 +151,12 @@ void CButton::Draw() glVertex2i(GetBaseSettings().m_Size.right, GetBaseSettings().m_Size.top); glEnd(); - glDisable(GL_DEPTH_TEST); + //glDisable(GL_DEPTH_TEST); - glColor3f(0,0,0); -/// font.print(GetBaseSettings().m_Size.left + 3, GetBaseSettings().m_Size.top - 15, LEFT, "Object: %s", GetName().c_str()); + //glColor3f(0,0,0); + //font.print(GetBaseSettings().m_Size.left + 3, GetBaseSettings().m_Size.top - 15, LEFT, "Object: %s", GetName().c_str()); - glEnable(GL_DEPTH_TEST); + //glEnable(GL_DEPTH_TEST); glPopMatrix(); } \ No newline at end of file diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index aa9a690a1d..8e908dc7e9 100755 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -84,7 +84,7 @@ bool CGUI::HandleEvent(const SDL_Event& ev) //------------------------------------------------------------------- CGUI::CGUI() { - m_BaseObject = new CButton; // Big todo! + m_BaseObject = new CGUIDummyObject; m_BaseObject->SetGUI(this); // This will make this invisible, not add @@ -355,7 +355,7 @@ void CGUI::LoadXMLFile(const CStr &Filename) parser->setDoSchema(false); // Set cosutomized error handler - XercesErrorHandler *errorHandler = new XercesErrorHandler(); + CXercesErrorHandler *errorHandler = new CXercesErrorHandler(); parser->setErrorHandler(errorHandler); parser->setCreateEntityReferenceNodes(false); diff --git a/source/gui/CGUIObject.cpp b/source/gui/CGUIObject.cpp index ed907e9a58..c3e2745151 100755 --- a/source/gui/CGUIObject.cpp +++ b/source/gui/CGUIObject.cpp @@ -25,7 +25,7 @@ map_Settings CGUIObject::m_SettingsInfo; // m_SettingsInfo, GeeTODO, I'm not sure if this is // the appropriate file, but it crashes if it's not // in this file. -CGUI g_GUI; +//CGUI g_GUI; //------------------------------------------------------------------- // Implementation Macros diff --git a/source/gui/CGUIObject.h b/source/gui/CGUIObject.h index 78318097da..4fc0e99a72 100755 --- a/source/gui/CGUIObject.h +++ b/source/gui/CGUIObject.h @@ -8,6 +8,9 @@ gee@pyro.nu All objects are derived from this class, it's an ADT so it can't be used per se + Also contains a Dummy object which is used for + completely blank objects. + --Usage-- Write about how to use it here @@ -35,7 +38,7 @@ gee@pyro.nu struct SGUISetting; class CGUI; -extern CGUI g_GUI; +//extern CGUI g_GUI; //-------------------------------------------------------- // Macros @@ -234,8 +237,8 @@ protected: // void UpdateObjects(); // Get cached mouse x/y from CGUI - u16 GetMouseX() const; //{ return ((GetGUI())?(GetGUI()->m_MouseX):0); } - u16 GetMouseY() const; //{ return ((GetGUI())?(GetGUI()->m_MouseY):0); } + u16 GetMouseX() const; + u16 GetMouseY() const; private: @@ -282,4 +285,15 @@ private: CGUI *m_pGUI; }; + +//-------------------------------------------------------- +// Dummy object used primarily for the root object +// which isn't a *real* object in the GUI. +//-------------------------------------------------------- +class CGUIDummyObject : public CGUIObject +{ + virtual void HandleMessage(const EGUIMessage &Message) {} + virtual void Draw() {} +}; + #endif \ No newline at end of file diff --git a/source/gui/GUIbase.h b/source/gui/GUIbase.h index eeaf59d40f..7f683249dd 100755 --- a/source/gui/GUIbase.h +++ b/source/gui/GUIbase.h @@ -38,6 +38,10 @@ class CGUIObject; //-------------------------------------------------------- // Macros //-------------------------------------------------------- + +// Global CGUI +#define g_GUI CGUI::GetSingleton() + // Temp #define CInput nemInput #define CStr std::string diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp index d97b37c68e..7dac640a7e 100755 --- a/source/gui/GUIutil.cpp +++ b/source/gui/GUIutil.cpp @@ -9,6 +9,9 @@ gee@pyro.nu using namespace std; +//-------------------------------------------------------- +// Utilities implementation +//-------------------------------------------------------- CGUIObject * CInternalCGUIAccessorBase::GetObjectPointer(CGUI &GUIinstance, const CStr &Object) { // if (!GUIinstance.ObjectExists(Object)) diff --git a/source/gui/XercesErrorHandler.cpp b/source/gui/XercesErrorHandler.cpp index a62db7f01c..a678608e52 100755 --- a/source/gui/XercesErrorHandler.cpp +++ b/source/gui/XercesErrorHandler.cpp @@ -17,14 +17,14 @@ gee@pyro.nu XERCES_CPP_NAMESPACE_USE -void XercesErrorHandler::warning(const SAXParseException&) +void CXercesErrorHandler::warning(const SAXParseException&) { // // Ignore all warnings. // } -void XercesErrorHandler::error(const SAXParseException& toCatch) +void CXercesErrorHandler::error(const SAXParseException& toCatch) { char * buf = XMLString::transcode(toCatch.getMessage()); fSawErrors = true; @@ -39,7 +39,7 @@ void XercesErrorHandler::error(const SAXParseException& toCatch) /// g_nemLog(" Error: %s", XMLString::transcode(toCatch.getMessage())); } -void XercesErrorHandler::fatalError(const SAXParseException& toCatch) +void CXercesErrorHandler::fatalError(const SAXParseException& toCatch) { char * buf = XMLString::transcode(toCatch.getMessage()); fSawErrors = true; @@ -55,7 +55,7 @@ void XercesErrorHandler::fatalError(const SAXParseException& toCatch) /// g_nemLog(" Error: %s", XMLString::transcode(toCatch.getMessage())); } -void XercesErrorHandler::resetErrors() +void CXercesErrorHandler::resetErrors() { fSawErrors = false; } diff --git a/source/gui/XercesErrorHandler.h b/source/gui/XercesErrorHandler.h index cda37824b0..636c95b1da 100755 --- a/source/gui/XercesErrorHandler.h +++ b/source/gui/XercesErrorHandler.h @@ -25,18 +25,18 @@ gee@pyro.nu #include -class XercesErrorHandler : public XERCES_CPP_NAMESPACE::ErrorHandler +class CXercesErrorHandler : public XERCES_CPP_NAMESPACE::ErrorHandler { public: // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - XercesErrorHandler() : + CXercesErrorHandler() : fSawErrors(false) { } - ~XercesErrorHandler() + ~CXercesErrorHandler() { } @@ -66,7 +66,7 @@ private: bool fSawErrors; }; -inline bool XercesErrorHandler::getSawErrors() const +inline bool CXercesErrorHandler::getSawErrors() const { return fSawErrors; } diff --git a/source/main.cpp b/source/main.cpp index ae01d865bf..046ee855d7 100755 --- a/source/main.cpp +++ b/source/main.cpp @@ -164,7 +164,9 @@ glColor3f(1.0f, 1.0f, 1.0f); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho(0., xres, 0., yres, -1., 1.); + ////// janwas: I changed to some more for the GUI, we can talk about how to set this up + glOrtho(0., xres, 0., yres, -1000., 1.); + ////// glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -229,8 +231,8 @@ int main(int argc, char* argv[]) detect(); ///// janwas: place this wherever + new CGUI; // we should have a place for all singleton news g_GUI.Initialize(); - g_GUI.LoadXMLFile("hello.xml"); //g_GUI.LoadXMLFile("sprite1.xml"); ///// @@ -305,6 +307,7 @@ in_add_handler(terr_handler); ///// Janwas place this wherever g_GUI.Destroy(); + delete CGUI::GetSingletonPtr(); // again, we should have all singleton deletes somewhere ///// return 0;