diff options
Diffstat (limited to 'src/ui')
48 files changed, 448 insertions, 529 deletions
diff --git a/src/ui/button.cpp b/src/ui/button.cpp index e3dbc30..a68b34d 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -16,7 +16,6 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. - #include "ui/button.h" #include "common/event.h" diff --git a/src/ui/button.h b/src/ui/button.h index 33a48ee..a9aa020 100644 --- a/src/ui/button.h +++ b/src/ui/button.h @@ -25,31 +25,29 @@ namespace Ui { - class CButton : public CControl - { - public: - CButton(); - virtual ~CButton(); +class CButton : public CControl +{ +public: + CButton(); + virtual ~CButton(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - bool EventProcess(const Event &event); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); - void SetImmediat(bool bRepeat); - bool GetImmediat(); + void SetImmediat(bool bRepeat); + bool GetImmediat(); - void SetRepeat(bool bRepeat); - bool GetRepeat(); + void SetRepeat(bool bRepeat); + bool GetRepeat(); - protected: - - protected: - bool m_bCapture; - bool m_bImmediat; - bool m_bRepeat; - float m_repeat; - }; +protected: + bool m_bCapture; + bool m_bImmediat; + bool m_bRepeat; + float m_repeat; +}; } diff --git a/src/ui/check.cpp b/src/ui/check.cpp index bc80b7c..761264d 100644 --- a/src/ui/check.cpp +++ b/src/ui/check.cpp @@ -19,7 +19,6 @@ #include "ui/check.h" #include "common/event.h" -#include "common/iman.h" #include "common/misc.h" #include "common/restext.h" diff --git a/src/ui/check.h b/src/ui/check.h index af26add..65bc367 100644 --- a/src/ui/check.h +++ b/src/ui/check.h @@ -22,27 +22,24 @@ #include "ui/control.h" -namespace Gfx{ - class CEngine; +namespace Gfx { +class CEngine; } namespace Ui { - class CCheck : public CControl - { - public: - CCheck(); - virtual ~CCheck(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); +class CCheck : public CControl +{ +public: + CCheck(); + virtual ~CCheck(); - bool EventProcess(const Event &event); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - void Draw(); + bool EventProcess(const Event &event); - protected: - - protected: - }; + void Draw(); +}; } diff --git a/src/ui/color.cpp b/src/ui/color.cpp index 65f9770..fd05bd9 100644 --- a/src/ui/color.cpp +++ b/src/ui/color.cpp @@ -19,7 +19,6 @@ #include "ui/color.h" #include "common/event.h" -#include "common/iman.h" #include "common/misc.h" #include "common/restext.h" @@ -37,7 +36,6 @@ const float DELAY2 = 0.1f; // Object's constructor. -//CColor::CColor(CInstanceManager* iMan) : CControl(iMan) CColor::CColor() : CControl() { m_bRepeat = false; diff --git a/src/ui/color.h b/src/ui/color.h index 311a532..ec2c537 100644 --- a/src/ui/color.h +++ b/src/ui/color.h @@ -23,37 +23,34 @@ namespace Gfx{ - class CEngine; - struct Color; +class CEngine; +struct Color; } namespace Ui { - class CColor : public CControl - { - public: - // CColor(CInstanceManager* iMan); - CColor(); - virtual ~CColor(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); +class CColor : public CControl +{ +public: + CColor(); + virtual ~CColor(); - bool EventProcess(const Event &event); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - void Draw(); + bool EventProcess(const Event &event); - void SetRepeat(bool bRepeat); - bool GetRepeat(); + void Draw(); - void SetColor(Gfx::Color color); - Gfx::Color GetColor(); + void SetRepeat(bool bRepeat); + bool GetRepeat(); - protected: - - protected: - bool m_bRepeat; - float m_repeat; - Gfx::Color m_color; - }; + void SetColor(Gfx::Color color); + Gfx::Color GetColor(); +protected: + bool m_bRepeat; + float m_repeat; + Gfx::Color m_color; +}; } diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp index 1bc0f8c..ac97cb8 100644 --- a/src/ui/compass.cpp +++ b/src/ui/compass.cpp @@ -15,10 +15,10 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. + #include "ui/compass.h" #include "common/event.h" -#include "common/iman.h" #include "common/misc.h" #include "graphics/core/device.h" @@ -29,7 +29,6 @@ namespace Ui { // Object's constructor. -//CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan) CCompass::CCompass() : CControl() { m_dir = 0.0f; diff --git a/src/ui/compass.h b/src/ui/compass.h index 09eec9d..18546e5 100644 --- a/src/ui/compass.h +++ b/src/ui/compass.h @@ -23,32 +23,29 @@ namespace Gfx { - class CEngine; +class CEngine; } namespace Ui { - class CCompass : public CControl - { - public: - // CCompass(CInstanceManager* iMan); - CCompass(); - virtual ~CCompass(); +class CCompass : public CControl +{ +public: + CCompass(); + virtual ~CCompass(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - bool EventProcess(const Event &event); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); - void SetDirection(float dir); - float GetDirection(); + void SetDirection(float dir); + float GetDirection(); - protected: - - protected: - float m_dir; - }; +protected: + float m_dir; +}; } diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 718ad3b..6dc92cd 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -18,25 +18,23 @@ #include "ui/control.h" +#include "app/app.h" + namespace Ui { // Object's constructor. CControl::CControl() { - m_iMan = CInstanceManager::GetInstancePointer(); - - m_engine = static_cast< Gfx::CEngine* > ( m_iMan->SearchInstance(CLASS_ENGINE) ); - m_event = static_cast< CEventQueue* > ( m_iMan->SearchInstance(CLASS_EVENT) ); - m_main = static_cast< CRobotMain* > ( m_iMan->SearchInstance(CLASS_MAIN) ); - m_particle = static_cast< Gfx::CParticle* > (m_iMan->SearchInstance(CLASS_PARTICULE)); - m_sound = static_cast< CSoundInterface* > (m_iMan->SearchInstance(CLASS_SOUND)); - m_eventType = EVENT_NULL; + m_event = CApplication::GetInstancePointer()->GetEventQueue(); + m_sound = CApplication::GetInstancePointer()->GetSound(); + m_engine = Gfx::CEngine::GetInstancePointer(); + m_main = CRobotMain::GetInstancePointer(); + m_particle = m_engine->GetParticle(); + m_eventType = EVENT_NULL; m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT; m_fontSize = Gfx::FONT_SIZE_SMALL; -// m_fontStretch = Gfx::FONT_NORM_STRETCH; //there is font stretching no more master m_fontType = Gfx::FONT_COLOBOT; m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify -// m_justif = 0; m_bFocus = false; m_bCapture = false; diff --git a/src/ui/control.h b/src/ui/control.h index 635ae12..7f5077d 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -22,7 +22,6 @@ #include <string> #include "common/event.h" -#include "common/iman.h" #include "common/misc.h" #include "common/restext.h" @@ -39,108 +38,106 @@ namespace Ui { - enum ControlState - { - STATE_ENABLE = (1<<0), // active - STATE_CHECK = (1<<1), // pressed - STATE_HILIGHT = (1<<2), // overflown by mouse - STATE_PRESS = (1<<3), // pressed by mouse - STATE_VISIBLE = (1<<4), // visible - STATE_DEAD = (1<<5), // inaccessible (x) - STATE_DEFAULT = (1<<6), // actuated by RETURN - STATE_OKAY = (1<<7), // green point at the bottom right - STATE_SHADOW = (1<<8), // shadow - STATE_GLINT = (1<<9), // dynamic reflection - STATE_CARD = (1<<10), // tab - STATE_EXTEND = (1<<11), // extended mode - STATE_SIMPLY = (1<<12), // undecorated - STATE_FRAME = (1<<13), // framework highlighting - STATE_WARNING = (1<<14), // framework hatched yellow / black - STATE_VALUE = (1<<15), // displays the value - STATE_RUN = (1<<16) // running program - }; - - - - class CControl - { - public: - CControl(); - virtual ~CControl(); - - virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - - virtual bool EventProcess(const Event &event); - - virtual void SetPos(Math::Point pos); - virtual Math::Point GetPos(); - virtual void SetDim(Math::Point dim); - virtual Math::Point GetDim(); - virtual bool SetState(int state, bool bState); - virtual bool SetState(int state); - virtual bool ClearState(int state); - virtual bool TestState(int state); - virtual int GetState(); - virtual void SetIcon(int icon); - virtual int GetIcon(); - virtual void SetName(std::string name, bool bTooltip=true); - virtual std::string GetName(); - virtual void SetTextAlign(Gfx::TextAlign mode); - virtual int GetTextAlign(); - virtual void SetFontSize(float size); - virtual float GetFontSize(); - virtual void SetFontStretch(float stretch); - virtual float GetFontStretch(); - virtual void SetFontType(Gfx::FontType font); - virtual Gfx::FontType GetFontType(); - virtual bool SetTooltip(std::string name); - virtual bool GetTooltip(Math::Point pos, std::string &name); - virtual void SetFocus(bool bFocus); - virtual bool GetFocus(); - - virtual EventType GetEventType(); - - virtual void Draw(); - - protected: - void GlintDelete(); - void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true); - void GlintFrame(const Event &event); - void DrawPart(int icon, float zoom, float ex); - void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f); - void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex); - void DrawWarning(Math::Point pos, Math::Point dim); - void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f); - virtual bool Detect(Math::Point pos); - - protected: - CInstanceManager* m_iMan; - Gfx::CEngine* m_engine; - Gfx::CParticle* m_particle; - CEventQueue* m_event; - CRobotMain* m_main; - CSoundInterface* m_sound; - - Math::Point m_pos; // corner upper / left - Math::Point m_dim; // dimensions - int m_icon; - EventType m_eventType; // message to send when clicking - int m_state; // states (STATE_ *) - float m_fontSize; // size of the button name - float m_fontStretch; // stretch of the font - Gfx::FontType m_fontType; // type of font - Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif - // int m_justif; // type of justification (-1,0,1) - std::string m_name; // name of the button - std::string m_tooltip; // name of tooltip - bool m_bFocus; - bool m_bCapture; - - bool m_bGlint; - Math::Point m_glintCorner1; - Math::Point m_glintCorner2; - float m_glintProgress; - Math::Point m_glintMouse; - }; - -} +enum ControlState +{ + STATE_ENABLE = (1<<0), // active + STATE_CHECK = (1<<1), // pressed + STATE_HILIGHT = (1<<2), // overflown by mouse + STATE_PRESS = (1<<3), // pressed by mouse + STATE_VISIBLE = (1<<4), // visible + STATE_DEAD = (1<<5), // inaccessible (x) + STATE_DEFAULT = (1<<6), // actuated by RETURN + STATE_OKAY = (1<<7), // green point at the bottom right + STATE_SHADOW = (1<<8), // shadow + STATE_GLINT = (1<<9), // dynamic reflection + STATE_CARD = (1<<10), // tab + STATE_EXTEND = (1<<11), // extended mode + STATE_SIMPLY = (1<<12), // undecorated + STATE_FRAME = (1<<13), // framework highlighting + STATE_WARNING = (1<<14), // framework hatched yellow / black + STATE_VALUE = (1<<15), // displays the value + STATE_RUN = (1<<16) // running program +}; + + + +class CControl +{ +public: + CControl(); + virtual ~CControl(); + + virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); + + virtual bool EventProcess(const Event &event); + + virtual void SetPos(Math::Point pos); + virtual Math::Point GetPos(); + virtual void SetDim(Math::Point dim); + virtual Math::Point GetDim(); + virtual bool SetState(int state, bool bState); + virtual bool SetState(int state); + virtual bool ClearState(int state); + virtual bool TestState(int state); + virtual int GetState(); + virtual void SetIcon(int icon); + virtual int GetIcon(); + virtual void SetName(std::string name, bool bTooltip=true); + virtual std::string GetName(); + virtual void SetTextAlign(Gfx::TextAlign mode); + virtual int GetTextAlign(); + virtual void SetFontSize(float size); + virtual float GetFontSize(); + virtual void SetFontStretch(float stretch); + virtual float GetFontStretch(); + virtual void SetFontType(Gfx::FontType font); + virtual Gfx::FontType GetFontType(); + virtual bool SetTooltip(std::string name); + virtual bool GetTooltip(Math::Point pos, std::string &name); + virtual void SetFocus(bool bFocus); + virtual bool GetFocus(); + + virtual EventType GetEventType(); + + virtual void Draw(); + +protected: + void GlintDelete(); + void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true); + void GlintFrame(const Event &event); + void DrawPart(int icon, float zoom, float ex); + void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f); + void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex); + void DrawWarning(Math::Point pos, Math::Point dim); + void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f); + virtual bool Detect(Math::Point pos); + +protected: + Gfx::CEngine* m_engine; + Gfx::CParticle* m_particle; + CEventQueue* m_event; + CRobotMain* m_main; + CSoundInterface* m_sound; + + Math::Point m_pos; // corner upper / left + Math::Point m_dim; // dimensions + int m_icon; + EventType m_eventType; // message to send when clicking + int m_state; // states (STATE_ *) + float m_fontSize; // size of the button name + float m_fontStretch; // stretch of the font + Gfx::FontType m_fontType; // type of font + Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif + std::string m_name; // name of the button + std::string m_tooltip; // name of tooltip + bool m_bFocus; + bool m_bCapture; + + bool m_bGlint; + Math::Point m_glintCorner1; + Math::Point m_glintCorner2; + float m_glintProgress; + Math::Point m_glintMouse; +}; + +} // namespace Ui diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index 29499bd..a9e754f 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -15,17 +15,10 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// displayinfo.cpp - #include "ui/displayinfo.h" -#include "ui/interface.h" -#include "ui/button.h" -#include "ui/slider.h" -#include "ui/edit.h" -#include "ui/group.h" -#include "ui/window.h" +#include "app/app.h" #include "common/iman.h" #include "common/misc.h" @@ -43,25 +36,28 @@ #include "script/cbottoken.h" +#include "ui/interface.h" +#include "ui/button.h" +#include "ui/slider.h" +#include "ui/edit.h" +#include "ui/group.h" +#include "ui/window.h" + #include <string.h> namespace Ui { // Object's constructor. -//CDisplayInfo::CDisplayInfo(CInstanceManager* iMan) CDisplayInfo::CDisplayInfo() { - m_iMan = CInstanceManager::GetInstancePointer(); - m_iMan->AddInstance(CLASS_STUDIO, this); - - m_engine = static_cast <Gfx::CEngine*> (m_iMan->SearchInstance(CLASS_ENGINE)); - m_event = static_cast <CEventQueue*> (m_iMan->SearchInstance(CLASS_EVENT)); - m_interface = static_cast <CInterface*> (m_iMan->SearchInstance(CLASS_INTERFACE)); - m_main = static_cast <CRobotMain*> (m_iMan->SearchInstance(CLASS_MAIN)); - m_camera = static_cast <Gfx::CCamera*> (m_iMan->SearchInstance(CLASS_CAMERA)); - m_particle = static_cast <Gfx::CParticle*> (m_iMan->SearchInstance(CLASS_PARTICULE)); - m_light = static_cast <Gfx::CLightManager*> (m_iMan->SearchInstance(CLASS_LIGHT)); + m_event = CApplication::GetInstancePointer()->GetEventQueue(); + m_engine = Gfx::CEngine::GetInstancePointer(); + m_particle = m_engine->GetParticle(); + m_light = m_engine->GetLightManager(); + m_main = CRobotMain::GetInstancePointer(); + m_interface = m_main->GetInterface(); + m_camera = m_main->GetCamera(); m_bInfoMaximized = true; m_bInfoMinimized = false; @@ -77,7 +73,6 @@ CDisplayInfo::CDisplayInfo() CDisplayInfo::~CDisplayInfo() { - m_iMan->DeleteInstance(CLASS_STUDIO, this); } @@ -927,9 +922,11 @@ CObject* CDisplayInfo::SearchToto() CObject* pObj; int i; + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + for ( i=0 ; i<1000000 ; i++ ) { - pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); + pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; type = pObj->GetType(); @@ -1012,6 +1009,8 @@ void CDisplayInfo::CreateObjectsFile() int i; bool bRadar, bAtLeast; + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + file = fopen("help\\objects.txt", "w"); if ( file == 0 ) return; @@ -1019,7 +1018,7 @@ void CDisplayInfo::CreateObjectsFile() bRadar = false; for ( i=0 ; i<1000000 ; i++ ) { - pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); + pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( !pObj->GetActif() ) continue; diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h index 2eabbf2..ab42d62 100644 --- a/src/ui/displayinfo.h +++ b/src/ui/displayinfo.h @@ -25,7 +25,6 @@ #include "graphics/engine/camera.h" -class CInstanceManager; class CRobotMain; class CObject; class CEventQueue; @@ -33,67 +32,66 @@ class CEventQueue; struct Event; namespace Gfx { - class CEngine; - class CParticle; - class CLightManager; +class CEngine; +class CParticle; +class CLightManager; } namespace Ui { - class CInterface; - - class CDisplayInfo - { - public: - // CDisplayInfo(CInstanceManager* iMan); - CDisplayInfo(); - ~CDisplayInfo(); - - bool EventProcess(const Event &event); - - void StartDisplayInfo(std::string filename, int index, bool bSoluce); - void StopDisplayInfo(); - - void SetPosition(int pos); - int GetPosition(); - - protected: - bool EventFrame(const Event &event); - void HyperUpdate(); - void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim); - void ChangeIndexButton(int index); - void UpdateIndexButton(); - void UpdateCopyButton(); - void ViewDisplayInfo(); - CObject* SearchToto(); - void CreateObjectsFile(); - - protected: - CInstanceManager* m_iMan; - Gfx::CEngine* m_engine; - CEventQueue* m_event; - CRobotMain* m_main; - Gfx::CCamera* m_camera; - CInterface* m_interface; - Gfx::CParticle* m_particle; - Gfx::CLightManager* m_light; - - bool m_bInfoMaximized; - bool m_bInfoMinimized; - - int m_index; - Gfx::CameraType m_infoCamera; - Math::Point m_infoNormalPos; - Math::Point m_infoNormalDim; - Math::Point m_infoActualPos; - Math::Point m_infoActualDim; - Math::Point m_infoFinalPos; - Math::Point m_infoFinalDim; - int m_lightSuppl; - bool m_bEditLock; - bool m_bInitPause; - bool m_bSoluce; - CObject* m_toto; - }; - -} +class CInterface; + +class CDisplayInfo +{ +public: + CDisplayInfo(); + ~CDisplayInfo(); + + bool EventProcess(const Event &event); + + void StartDisplayInfo(std::string filename, int index, bool bSoluce); + void StopDisplayInfo(); + + void SetPosition(int pos); + int GetPosition(); + +protected: + bool EventFrame(const Event &event); + void HyperUpdate(); + void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim); + void ChangeIndexButton(int index); + void UpdateIndexButton(); + void UpdateCopyButton(); + void ViewDisplayInfo(); + CObject* SearchToto(); + void CreateObjectsFile(); + +protected: + Gfx::CEngine* m_engine; + CEventQueue* m_event; + CRobotMain* m_main; + Gfx::CCamera* m_camera; + CInterface* m_interface; + Gfx::CParticle* m_particle; + Gfx::CLightManager* m_light; + + bool m_bInfoMaximized; + bool m_bInfoMinimized; + + int m_index; + Gfx::CameraType m_infoCamera; + Math::Point m_infoNormalPos; + Math::Point m_infoNormalDim; + Math::Point m_infoActualPos; + Math::Point m_infoActualDim; + Math::Point m_infoFinalPos; + Math::Point m_infoFinalDim; + int m_lightSuppl; + bool m_bEditLock; + bool m_bInitPause; + bool m_bSoluce; + CObject* m_toto; +}; + + +} // namespace Ui diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp index 7c60f8b..630b385 100644 --- a/src/ui/displaytext.cpp +++ b/src/ui/displaytext.cpp @@ -15,16 +15,10 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// displaytext.cpp - #include "ui/displaytext.h" -#include "ui/interface.h" -#include "ui/button.h" -#include "ui/label.h" -#include "ui/window.h" -#include "ui/group.h" +#include "app/app.h" #include "common/event.h" #include "common/iman.h" @@ -36,6 +30,11 @@ #include "object/motion/motion.h" #include "object/motion/motiontoto.h" +#include "ui/interface.h" +#include "ui/button.h" +#include "ui/label.h" +#include "ui/window.h" +#include "ui/group.h" @@ -46,20 +45,13 @@ const float FONTSIZE = 12.0f; // Object's constructor. -//CDisplayText::CDisplayText(CInstanceManager* iMan) CDisplayText::CDisplayText() { - int i; + m_engine = Gfx::CEngine::GetInstancePointer(); + m_interface = CRobotMain::GetInstancePointer()->GetInterface(); + m_sound = CApplication::GetInstancePointer()->GetSound(); -// m_iMan = iMan; - m_iMan = CInstanceManager::GetInstancePointer(); - m_iMan->AddInstance(CLASS_DISPLAYTEXT, this); - - m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); - m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); - m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); - - for ( i=0 ; i<MAXDTLINE ; i++ ) + for (int i=0 ; i<MAXDTLINE ; i++ ) { m_bExist[i] = false; m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f); @@ -77,7 +69,6 @@ CDisplayText::CDisplayText() CDisplayText::~CDisplayText() { - m_iMan->DeleteInstance(CLASS_DISPLAYTEXT, this); } @@ -598,9 +589,11 @@ CObject* CDisplayText::SearchToto() CObject* pObj; int i; + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + for ( i=0 ; i<1000000 ; i++ ) { - pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); + pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; type = pObj->GetType(); diff --git a/src/ui/displaytext.h b/src/ui/displaytext.h index 5714cc5..94572a8 100644 --- a/src/ui/displaytext.h +++ b/src/ui/displaytext.h @@ -27,16 +27,14 @@ -class CInstanceManager; -//class CD3DEngine class CObject; class CSound; namespace Gfx { - class CEngine; +class CEngine; } -namespace Ui {; +namespace Ui { class CInterface; @@ -54,7 +52,6 @@ const int MAXDTLINE = 4; class CDisplayText { public: -// CDisplayText(CInstanceManager* iMan); CDisplayText(); ~CDisplayText(); @@ -87,7 +84,6 @@ protected: CObject* SearchToto(); protected: - CInstanceManager* m_iMan; Gfx::CEngine* m_engine; Ui::CInterface* m_interface; CSoundInterface* m_sound; @@ -104,4 +100,5 @@ protected: }; -} +} // namespace Ui + diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index 0e50852..64004bb 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -15,11 +15,11 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// edit.cpp -#include "app/app.h" #include "ui/edit.h" +#include "app/app.h" + #include <string.h> namespace Ui { diff --git a/src/ui/edit.h b/src/ui/edit.h index 75572c7..8f46445 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -32,7 +32,6 @@ #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" #include "common/restext.h" #include <set> diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 3cc856d..6397a73 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -15,22 +15,21 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// editvalue.cpp +#include "ui/editvalue.h" #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" + #include "ui/edit.h" #include "ui/button.h" -#include "ui/editvalue.h" + namespace Ui { // Object's constructor. -//CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan) CEditValue::CEditValue() : CControl () { m_edit = 0; diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h index 1469b69..5d6e643 100644 --- a/src/ui/editvalue.h +++ b/src/ui/editvalue.h @@ -44,7 +44,6 @@ class CButton; class CEditValue : public CControl { public: -// CEditValue(CInstanceManager* iMan); CEditValue(); virtual ~CEditValue(); diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index b1fa057..c98e3b6 100644 --- a/src/ui/gauge.cpp +++ b/src/ui/gauge.cpp @@ -15,8 +15,6 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// gauge.cpp - #include "ui/gauge.h" @@ -24,7 +22,6 @@ namespace Ui { // Object's constructor. -//CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan) CGauge::CGauge() : CControl() { m_level = 0.0f; diff --git a/src/ui/gauge.h b/src/ui/gauge.h index f4a008f..a2b689a 100644 --- a/src/ui/gauge.h +++ b/src/ui/gauge.h @@ -32,7 +32,6 @@ namespace Ui { class CGauge : public CControl { public: - // CGauge(CInstanceManager* iMan); CGauge(); virtual ~CGauge(); diff --git a/src/ui/group.cpp b/src/ui/group.cpp index 67369d9..c3c7028 100644 --- a/src/ui/group.cpp +++ b/src/ui/group.cpp @@ -14,14 +14,13 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// group.cpp #include "ui/group.h" #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" #include "common/restext.h" + #include "graphics/engine/engine.h" @@ -32,7 +31,6 @@ namespace Ui { // Object's constructor. -//CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan) CGroup::CGroup() : CControl() { } diff --git a/src/ui/group.h b/src/ui/group.h index bfeef74..fd31716 100644 --- a/src/ui/group.h +++ b/src/ui/group.h @@ -30,7 +30,6 @@ namespace Ui { class CGroup : public CControl { public: -// CGroup(CInstanceManager* iMan); CGroup(); virtual ~CGroup(); diff --git a/src/ui/image.cpp b/src/ui/image.cpp index ad838fa..94b9586 100644 --- a/src/ui/image.cpp +++ b/src/ui/image.cpp @@ -15,16 +15,15 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// image.cpp - +#include "ui/image.h" -#include "graphics/engine/engine.h" #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" #include "common/restext.h" -#include "ui/image.h" + +#include "graphics/engine/engine.h" + #include <string.h> #include <stdio.h> @@ -33,7 +32,6 @@ namespace Ui { // Object's constructor. -//CImage::CImage(CInstanceManager* iMan) : CControl(iMan) CImage::CImage() : CControl() { m_filename[0] = 0; diff --git a/src/ui/image.h b/src/ui/image.h index b73a5ae..c40828c 100644 --- a/src/ui/image.h +++ b/src/ui/image.h @@ -32,7 +32,6 @@ namespace Ui { class CImage : public CControl { public: -// CImage(CInstanceManager* iMan); CImage (); virtual ~CImage(); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 885cef4..24d2626 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -15,20 +15,18 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// interface.cpp - #include "ui/interface.h" +#include "app/app.h" + namespace Ui { CInterface::CInterface() { - m_iMan = CInstanceManager::GetInstancePointer(); - m_iMan->AddInstance(CLASS_INTERFACE, this); - m_event = static_cast<CEventQueue *>( m_iMan->SearchInstance(CLASS_EVENT) ); - m_engine = static_cast<Gfx::CEngine *>( m_iMan->SearchInstance(CLASS_ENGINE) ); + m_event = CApplication::GetInstancePointer()->GetEventQueue(); + m_engine = Gfx::CEngine::GetInstancePointer(); m_camera = nullptr; for (int i = 0; i < MAXCONTROL; i++ ) @@ -42,7 +40,6 @@ CInterface::CInterface() CInterface::~CInterface() { Flush(); - m_iMan->DeleteInstance(CLASS_INTERFACE, this); } @@ -278,15 +275,18 @@ CControl* CInterface::SearchControl(EventType eventMsg) bool CInterface::EventProcess(const Event &event) { - if (event.type == EVENT_MOUSE_MOVE) { - if (m_camera == nullptr) { - m_camera = static_cast<Gfx::CCamera *>(m_iMan->SearchInstance(CLASS_CAMERA)); - } + if (event.type == EVENT_MOUSE_MOVE) + { + if (m_camera == nullptr) + m_camera = CRobotMain::GetInstancePointer()->GetCamera(); + m_engine->SetMouseType(m_camera->GetMouseDef(event.mousePos)); } - for (int i = MAXCONTROL-1; i >= 0; i--) { - if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE)) { + for (int i = MAXCONTROL-1; i >= 0; i--) + { + if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE)) + { if ( !m_table[i]->EventProcess(event) ) return false; } @@ -300,8 +300,10 @@ bool CInterface::EventProcess(const Event &event) bool CInterface::GetTooltip(Math::Point pos, std::string &name) { - for (int i = MAXCONTROL-1; i >= 0; i--) { - if (m_table[i] != nullptr) { + for (int i = MAXCONTROL-1; i >= 0; i--) + { + if (m_table[i] != nullptr) + { if (m_table[i]->GetTooltip(pos, name)) return true; } @@ -314,16 +316,8 @@ bool CInterface::GetTooltip(Math::Point pos, std::string &name) void CInterface::Draw() { - /*ZeroMemory( &material, sizeof(D3DMATERIAL7) ); - material.diffuse.r = 1.0f; - material.diffuse.g = 1.0f; - material.diffuse.b = 1.0f; - material.ambient.r = 0.5f; - material.ambient.g = 0.5f; - material.ambient.b = 0.5f; - m_engine->SetMaterial(material);*/ - - for (int i = 0; i < MAXCONTROL; i++) { + for (int i = 0; i < MAXCONTROL; i++) + { if ( m_table[i] != nullptr ) m_table[i]->Draw(); } diff --git a/src/ui/interface.h b/src/ui/interface.h index 1496541..ebc80e7 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -19,11 +19,8 @@ #pragma once -#include <string> - #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" #include "math/point.h" @@ -49,6 +46,8 @@ #include "ui/map.h" #include "ui/window.h" +#include <string> + namespace Ui { const int MAXCONTROL = 100; @@ -92,7 +91,6 @@ class CInterface int GetNextFreeControl(); template <typename T> inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CInstanceManager* m_iMan; CEventQueue* m_event; Gfx::CEngine* m_engine; Gfx::CCamera* m_camera; diff --git a/src/ui/key.cpp b/src/ui/key.cpp index 9a76127..b181f70 100644 --- a/src/ui/key.cpp +++ b/src/ui/key.cpp @@ -15,6 +15,7 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. + #include "ui/key.h" #include "common/global.h" diff --git a/src/ui/key.h b/src/ui/key.h index 2332c9b..d8e935c 100644 --- a/src/ui/key.h +++ b/src/ui/key.h @@ -24,7 +24,6 @@ #include "ui/control.h" -#include "common/iman.h" #include "common/event.h" #include "common/restext.h" #include "common/key.h" diff --git a/src/ui/label.cpp b/src/ui/label.cpp index af65ab2..b5195b5 100644 --- a/src/ui/label.cpp +++ b/src/ui/label.cpp @@ -15,8 +15,6 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// label.cpp - #include "ui/label.h" diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 4356ea4..84aa8ca 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -15,8 +15,6 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// list.cpp - #include "ui/list.h" diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index cf451e5..920d958 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -14,22 +14,24 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// maindialog.cpp #include "ui/maindialog.h" #include "app/app.h" + #include "common/global.h" #include "common/event.h" #include "common/logger.h" #include "common/misc.h" #include "common/profile.h" -#include "common/iman.h" #include "common/restext.h" #include "common/logger.h" + #include "object/robotmain.h" + #include "script/cmdtoken.h" #include "sound/sound.h" + #include "ui/interface.h" #include "ui/button.h" #include "ui/color.h" @@ -54,8 +56,7 @@ //TODO Get rid of all sprintf's -namespace Ui -{ +namespace Ui { const int KEY_VISIBLE = 6; // number of visible keys redefinable @@ -106,20 +107,16 @@ namespace fs = boost::filesystem; // Constructor of robot application. -CMainDialog::CMainDialog(CInstanceManager* iMan) +CMainDialog::CMainDialog() { - m_iMan = iMan; - m_iMan->AddInstance(CLASS_DIALOG, this); - - m_app = CApplication::GetInstancePointer(); - - m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN)); - m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); - m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); - m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); - m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE)); - m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA)); - m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); + m_app = CApplication::GetInstancePointer(); + m_eventQueue = m_app->GetEventQueue(); + m_sound = m_app->GetSound(); + m_main = CRobotMain::GetInstancePointer(); + m_interface = m_main->GetInterface(); + m_camera = m_main->GetCamera(); + m_engine = Gfx::CEngine::GetInstancePointer(); + m_particle = m_engine->GetParticle(); m_phase = PHASE_NAME; m_phaseSetup = PHASE_SETUPg; diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index 51c6f2e..be61299 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -20,20 +20,18 @@ #include "graphics/core/color.h" + #include "object/robotmain.h" -class CInstanceManager; class CEventQueue; class CSoundInterface; -namespace Gfx -{ +namespace Gfx { class CEngine; class CParticle; -}; +} -namespace Ui -{ +namespace Ui { class CInterface; class CWindow; @@ -64,7 +62,7 @@ struct GamerPerso class CMainDialog { public: - CMainDialog(CInstanceManager* iMan); + CMainDialog(); ~CMainDialog(); bool EventProcess(const Event &event); @@ -172,7 +170,6 @@ protected: void ChangeKey(EventType event); protected: - CInstanceManager* m_iMan; CApplication* m_app; CRobotMain* m_main; CEventQueue* m_eventQueue; @@ -260,3 +257,4 @@ protected: }; } // namespace Ui + diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp index b70bad9..1143a77 100644 --- a/src/ui/mainmap.cpp +++ b/src/ui/mainmap.cpp @@ -15,11 +15,11 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// mainmap.cpp - #include "ui/mainmap.h" +#include "app/app.h" + namespace Ui { @@ -32,12 +32,9 @@ const float ZOOM_MAX = 16.0f; CMainMap::CMainMap() { - m_iMan = CInstanceManager::GetInstancePointer(); - m_iMan->AddInstance(CLASS_MAP, this); - - m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); - m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); - m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); + m_interface = CRobotMain::GetInstancePointer()->GetInterface(); + m_event = CApplication::GetInstancePointer()->GetEventQueue(); + m_engine = Gfx::CEngine::GetInstancePointer(); m_mapMode = 1; m_bFixImage = false; diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h index 35aae4c..9d0d72f 100644 --- a/src/ui/mainmap.h +++ b/src/ui/mainmap.h @@ -20,9 +20,13 @@ #pragma once #include "common/event.h" + #include "graphics/core/color.h" + #include "math/point.h" + #include "object/object.h" + #include "ui/interface.h" @@ -55,7 +59,6 @@ class CMainMap void CenterMap(); protected: - CInstanceManager* m_iMan; CEventQueue* m_event; Gfx::CEngine* m_engine; CInterface* m_interface; diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index 55b9612..d33482c 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.cpp @@ -15,24 +15,24 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// mainshort.cpp - #include "ui/mainshort.h" +#include "app/app.h" + +#include "common/iman.h" + + namespace Ui { // Constructor of the application card. CMainShort::CMainShort() { - m_iMan = CInstanceManager::GetInstancePointer(); - m_iMan->AddInstance(CLASS_SHORT, this); - - m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); - m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); - m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); - m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN)); + m_event = CApplication::GetInstancePointer()->GetEventQueue(); + m_engine = Gfx::CEngine::GetInstancePointer(); + m_main = CRobotMain::GetInstancePointer(); + m_interface = m_main->GetInterface(); FlushShortcuts(); } @@ -137,9 +137,11 @@ bool CMainShort::CreateShortcuts() m_shortcuts[rank] = 0; rank ++; + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + for ( i=0 ; i<1000000 ; i++ ) { - pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); + pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == nullptr ) break; if ( !pObj->GetActif() ) continue; diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h index 0912e68..d679eb0 100644 --- a/src/ui/mainshort.h +++ b/src/ui/mainshort.h @@ -19,12 +19,16 @@ #pragma once -#include "ui/interface.h" #include "common/event.h" + #include "math/point.h" + #include "object/object.h" + #include "graphics/engine/engine.h" +#include "ui/interface.h" + namespace Ui { @@ -46,7 +50,6 @@ class CMainShort protected: protected: - CInstanceManager* m_iMan; CEventQueue* m_event; Gfx::CEngine* m_engine; CInterface* m_interface; diff --git a/src/ui/map.cpp b/src/ui/map.cpp index b852976..33d0fb1 100644 --- a/src/ui/map.cpp +++ b/src/ui/map.cpp @@ -15,8 +15,6 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// map.cpp - #include "ui/map.h" @@ -31,9 +29,9 @@ namespace Ui { CMap::CMap() : CControl() { - m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN)); - m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN)); - m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER)); + m_main = CRobotMain::GetInstancePointer(); + m_terrain = m_main->GetTerrain(); + m_water = Gfx::CEngine::GetInstancePointer()->GetWater(); m_bEnable = true; m_time = 0.0f; diff --git a/src/ui/map.h b/src/ui/map.h index 9e1767c..258dcdf 100644 --- a/src/ui/map.h +++ b/src/ui/map.h @@ -22,11 +22,7 @@ #include "ui/control.h" -#include "object/object.h" -#include "object/robotmain.h" - #include "common/event.h" -#include "common/iman.h" #include "graphics/engine/terrain.h" #include "graphics/engine/water.h" @@ -36,6 +32,9 @@ #include "math/geometry.h" +#include "object/object.h" +#include "object/robotmain.h" + namespace Ui { diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 17f210e..ff7451d 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -15,14 +15,14 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// scroll.cpp #include "ui/scroll.h" #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" + #include "graphics/engine/engine.h" + #include "ui/button.h" diff --git a/src/ui/scroll.h b/src/ui/scroll.h index 52b60bc..57d6f8f 100644 --- a/src/ui/scroll.h +++ b/src/ui/scroll.h @@ -20,9 +20,10 @@ #pragma once -#include "ui/control.h" #include "common/event.h" +#include "ui/control.h" + namespace Ui { class CButton; diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index 18b8f31..4462140 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -15,13 +15,12 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// shortcut.cpp #include "ui/shortcut.h" #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" + #include "graphics/engine/engine.h" #include "graphics/core/device.h" @@ -31,7 +30,6 @@ namespace Ui { // Object's constructor. -//CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan) CShortcut::CShortcut() : CControl() { m_time = 0.0f; diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index ca907fe..f516e70 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -15,15 +15,15 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// slider.cpp #include "ui/slider.h" #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" + #include "graphics/engine/engine.h" #include "graphics/engine/text.h" + #include "ui/button.h" #include <stdio.h> diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 7aa2d22..bf2ff33 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -15,23 +15,26 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// studio.cpp - -#include "studio.h" +#include "ui/studio.h" #include "CBot/CBotDll.h" #include "app/app.h" + #include "common/event.h" -#include "common/iman.h" #include "common/misc.h" + #include "graphics/engine/camera.h" #include "graphics/engine/engine.h" + #include "object/object.h" + #include "script/cbottoken.h" #include "script/script.h" + #include "sound/sound.h" + #include "ui/check.h" #include "ui/control.h" #include "ui/color.h" @@ -61,16 +64,13 @@ namespace Ui { CStudio::CStudio() { - m_iMan = CInstanceManager::GetInstancePointer(); - m_iMan->AddInstance(CLASS_STUDIO, this); - - m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); - m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT)); - m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); - m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN)); - m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA)); - m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND)); - m_app = CApplication::GetInstancePointer(); + m_app = CApplication::GetInstancePointer(); + m_sound = m_app->GetSound(); + m_event = m_app->GetEventQueue(); + m_engine = Gfx::CEngine::GetInstancePointer(); + m_main = CRobotMain::GetInstancePointer(); + m_interface = m_main->GetInterface(); + m_camera = m_main->GetCamera(); m_bEditMaximized = false; m_bEditMinimized = false; @@ -87,7 +87,6 @@ CStudio::CStudio() CStudio::~CStudio() { - m_iMan->DeleteInstance(CLASS_STUDIO, this); } diff --git a/src/ui/studio.h b/src/ui/studio.h index 905baa6..7c2f652 100644 --- a/src/ui/studio.h +++ b/src/ui/studio.h @@ -26,7 +26,6 @@ #include <string> class CEventQueue; -class CInstanceManager; class CRobotMain; class CScript; class CSoundInterface; @@ -54,70 +53,69 @@ enum StudioDialog class CStudio { - public: - CStudio(); - ~CStudio(); - - bool EventProcess(const Event &event); - - void StartEditScript(CScript *script, std::string name, int rank); - bool StopEditScript(bool bCancel); - - protected: - bool EventFrame(const Event &event); - void SearchToken(CEdit* edit); - void ColorizeScript(CEdit* edit); - void AdjustEditScript(); - void SetInfoText(std::string text, bool bClickable); - void ViewEditScript(); - void UpdateFlux(); - void UpdateButtons(); - - void StartDialog(StudioDialog type); - void StopDialog(); - void AdjustDialog(); - bool EventDialog(const Event &event); - void UpdateChangeList(); - void UpdateChangeEdit(); - void UpdateDialogAction(); - void UpdateDialogPublic(); - void UpdateDialogList(); - void SearchDirectory(char* dir, bool bCreate); - bool ReadProgram(); - bool WriteProgram(); - - protected: - CInstanceManager* m_iMan; - Gfx::CEngine* m_engine; - CEventQueue* m_event; - CRobotMain* m_main; - Gfx::CCamera* m_camera; - CSoundInterface* m_sound; - CInterface* m_interface; - CApplication *m_app; - - int m_rank; - CScript* m_script; - Gfx::CameraType m_editCamera; - - bool m_bEditMaximized; - bool m_bEditMinimized; - - Math::Point m_editActualPos; - Math::Point m_editActualDim; - Math::Point m_editFinalPos; - Math::Point m_editFinalDim; - - float m_time; - float m_fixInfoTextTime; - bool m_bRunning; - bool m_bRealTime; - bool m_bInitPause; - std::string m_helpFilename; +public: + CStudio(); + ~CStudio(); + + bool EventProcess(const Event &event); + + void StartEditScript(CScript *script, std::string name, int rank); + bool StopEditScript(bool bCancel); + +protected: + bool EventFrame(const Event &event); + void SearchToken(CEdit* edit); + void ColorizeScript(CEdit* edit); + void AdjustEditScript(); + void SetInfoText(std::string text, bool bClickable); + void ViewEditScript(); + void UpdateFlux(); + void UpdateButtons(); + + void StartDialog(StudioDialog type); + void StopDialog(); + void AdjustDialog(); + bool EventDialog(const Event &event); + void UpdateChangeList(); + void UpdateChangeEdit(); + void UpdateDialogAction(); + void UpdateDialogPublic(); + void UpdateDialogList(); + void SearchDirectory(char* dir, bool bCreate); + bool ReadProgram(); + bool WriteProgram(); + +protected: + Gfx::CEngine* m_engine; + CEventQueue* m_event; + CRobotMain* m_main; + Gfx::CCamera* m_camera; + CSoundInterface* m_sound; + CInterface* m_interface; + CApplication* m_app; + + int m_rank; + CScript* m_script; + Gfx::CameraType m_editCamera; + + bool m_bEditMaximized; + bool m_bEditMinimized; + + Math::Point m_editActualPos; + Math::Point m_editActualDim; + Math::Point m_editFinalPos; + Math::Point m_editFinalDim; + + float m_time; + float m_fixInfoTextTime; + bool m_bRunning; + bool m_bRealTime; + bool m_bInitPause; + std::string m_helpFilename; StudioDialog m_dialog; }; -} +} // namespace Ui diff --git a/src/ui/target.cpp b/src/ui/target.cpp index b47ba16..cc74750 100644 --- a/src/ui/target.cpp +++ b/src/ui/target.cpp @@ -14,11 +14,10 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// target.cpp - #include "ui/target.h" +#include "common/iman.h" namespace Ui { @@ -189,9 +188,11 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) objRank = m_engine->DetectObject(pos); + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + for ( i=0 ; i<1000000 ; i++ ) { - pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); + pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( !pObj->GetActif() ) continue; diff --git a/src/ui/target.h b/src/ui/target.h index 05a3651..054524b 100644 --- a/src/ui/target.h +++ b/src/ui/target.h @@ -18,20 +18,19 @@ #pragma once -#include <string> - -#include "ui/control.h" - +#include "common/event.h" #include "common/misc.h" -#include "common/iman.h" #include "common/restext.h" -#include "common/event.h" #include "graphics/engine/engine.h" #include "object/robotmain.h" #include "object/object.h" +#include "ui/control.h" + +#include <string> + namespace Ui { diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 97daf94..6013d37 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -15,8 +15,6 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// window.cpp - #include "ui/window.h" @@ -25,7 +23,6 @@ namespace Ui { // Object's constructor. -//CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan) CWindow::CWindow() : CControl() { int i; @@ -122,7 +119,6 @@ CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, Event { if ( m_table[i] == 0 ) { -// m_table[i] = new CButton(m_iMan); m_table[i] = new CButton(); pc = static_cast<CButton*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -145,7 +141,6 @@ CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventTy { if ( m_table[i] == 0 ) { -// m_table[i] = new CColor(m_iMan); m_table[i] = new CColor(); pc = static_cast<CColor*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -168,7 +163,6 @@ CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventTy { if ( m_table[i] == 0 ) { -// m_table[i] = new CCheck(m_iMan); m_table[i] = new CCheck(); pc = static_cast<CCheck*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -191,7 +185,6 @@ CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType e { if ( m_table[i] == 0 ) { -// m_table[i] = new CKey(m_iMan); m_table[i] = new CKey(); pc = static_cast<CKey*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -214,7 +207,6 @@ CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventTy { if ( m_table[i] == 0 ) { -// m_table[i] = new CGroup(m_iMan); m_table[i] = new CGroup(); pc = static_cast<CGroup*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -237,7 +229,6 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventTy { if ( m_table[i] == 0 ) { -// m_table[i] = new CImage(m_iMan); m_table[i] = new CImage(); pc = static_cast<CImage*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -260,7 +251,6 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventTy { if ( m_table[i] == 0 ) { -// m_table[i] = new CLabel(m_iMan); m_table[i] = new CLabel(); pc = static_cast<CLabel*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -289,7 +279,6 @@ CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType { if ( m_table[i] == 0 ) { -// m_table[i] = new CEdit(m_iMan); m_table[i] = new CEdit(); pc = static_cast<CEdit*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -312,7 +301,6 @@ CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, { if ( m_table[i] == 0 ) { -// m_table[i] = new CEditValue(m_iMan); m_table[i] = new CEditValue(); pc = static_cast<CEditValue*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -335,7 +323,6 @@ CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, Event { if ( m_table[i] == 0 ) { -// m_table[i] = new CScroll(m_iMan); m_table[i] = new CScroll(); pc = static_cast<CScroll*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -358,7 +345,6 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event { if ( m_table[i] == 0 ) { -// m_table[i] = new CSlider(m_iMan); m_table[i] = new CSlider(); pc = static_cast<CSlider*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); @@ -382,7 +368,6 @@ CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType { if ( m_table[i] == 0 ) { -// m_table[i] = new CList(m_iMan); m_table[i] = new CList(); pc = static_cast<CList*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg, expand); diff --git a/src/ui/window.h b/src/ui/window.h index 8d7090c..e39b8a9 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -19,12 +19,12 @@ #pragma once -#include <string> - #include "common/event.h" #include "common/misc.h" #include "common/restext.h" +#include "graphics/engine/text.h" + #include "ui/button.h" #include "ui/color.h" #include "ui/check.h" @@ -44,7 +44,7 @@ #include "ui/target.h" #include "ui/control.h" -#include "graphics/engine/text.h" +#include <string> namespace Ui { |