diff options
Diffstat (limited to 'src/ui')
56 files changed, 755 insertions, 1373 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..fcc77db 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); } @@ -386,7 +381,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc edit->ReadText(filename.c_str()); edit->HyperHome(filename.c_str()); edit->SetEditCap(false); // just to see! - edit->SetHiliteCap(false); + edit->SetHighlightCap(false); edit->SetFocus(true); ViewDisplayInfo(); @@ -460,6 +455,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc } light.type = Gfx::LIGHT_DIRECTIONAL; + light.ambient = Gfx::Color(0.0f, 0.0f, 0.0f); light.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f); light.direction = Math::Vector(1.0f, 0.0f, 1.0f); @@ -675,7 +671,7 @@ void CDisplayInfo::ChangeIndexButton(int index) { filename = m_main->GetDisplayInfoName(m_index); edit->ReadText(filename); - edit->HyperHome(filename); + edit->HyperHome(std::string(filename)); SetPosition(m_main->GetDisplayInfoPosition(m_index)); } @@ -789,7 +785,7 @@ void CDisplayInfo::UpdateIndexButton() if ( edit != 0 ) { //? edit->SetHiliteCap(m_index==SATCOM_LOADING); - edit->SetHiliteCap(true); + edit->SetHighlightCap(true); } UpdateCopyButton(); @@ -927,9 +923,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(); @@ -991,9 +989,9 @@ void ObjectWrite(FILE* file, ObjectList list[], int i) strcat(line, res); strcat(line, "\\u "); - p = const_cast<char*>(GetHelpFilename(list[i].type)); + p = const_cast<char*>(GetHelpFilename(list[i].type).c_str()); if ( p[0] == 0 ) return; - strcat(line, p+5); // skip "help\" + strcat(line, p+7); // skip "help\?\" p = strstr(line, ".txt"); if ( p != 0 ) *p = 0; strcat(line, ";\n"); @@ -1012,14 +1010,16 @@ void CDisplayInfo::CreateObjectsFile() int i; bool bRadar, bAtLeast; - file = fopen("help\\objects.txt", "w"); + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + + file = fopen((std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("objects.txt")).c_str(), "w"); if ( file == 0 ) return; list[0].total = 0; // empty list 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 639215a..e60a040 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 { @@ -261,7 +261,7 @@ bool CEdit::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_MOVE ) { - if ( Detect(event.mousePos) && + if ( Detect(event.mousePos) && event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) { if ( m_bEdit ) @@ -560,7 +560,7 @@ bool CEdit::IsLinkPos(Math::Point pos) if ( i == -1 ) return false; if ( i >= m_len ) return false; - if ( (m_format[i]& Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) return true; // TODO + if ( m_format.size() > static_cast<unsigned int>(i) && ((m_format[i] & Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK)) return true; // TODO return false; } @@ -735,7 +735,8 @@ int CEdit::MouseDetect(Math::Point mouse) // len, offset, size, // m_fontStretch); c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]).substr(0, len), - m_format, + m_format.begin() + m_lineOffset[i], + m_format.end(), size, offset); // TODO check if good } @@ -759,7 +760,7 @@ void CEdit::HyperFlush() // Indicates which is the home page. -void CEdit::HyperHome(const char *filename) +void CEdit::HyperHome(std::string filename) { HyperFlush(); HyperAdd(filename, 0); @@ -767,10 +768,10 @@ void CEdit::HyperHome(const char *filename) // Performs a hyper jump through a link. -void CEdit::HyperJump(const char *name, const char *marker) +void CEdit::HyperJump(std::string name, std::string marker) { - char filename[100]; - char sMarker[100]; + std::string filename; + std:: string sMarker; int i, line, pos; if ( m_historyCurrent >= 0 ) @@ -778,18 +779,16 @@ void CEdit::HyperJump(const char *name, const char *marker) m_history[m_historyCurrent].firstLine = m_lineFirst; } - strcpy(sMarker, marker); + sMarker = marker; //? sprintf(filename, "help\\%s.txt", name); - if ( name[0] == '%' ) - { - UserDir(filename, name, ""); - strcat(filename, ".txt"); - } - else - { - sprintf(filename, "help\\%s.txt", name); + + if ( name[0] == '%' ) { + filename = GetProfile().GetUserBasedPath(name, "") + ".txt"; + } else { + filename = std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + "/" + name + std::string(".txt"); } + if ( ReadText(filename) ) { Justif(); @@ -797,7 +796,7 @@ void CEdit::HyperJump(const char *name, const char *marker) line = 0; for ( i=0 ; i<m_markerTotal ; i++ ) { - if ( strcmp(sMarker, m_marker[i].name) == 0 ) + if (sMarker == m_marker[i].name) { pos = m_marker[i].pos; for ( i=0 ; i<m_lineTotal ; i++ ) @@ -818,12 +817,12 @@ void CEdit::HyperJump(const char *name, const char *marker) // Adds text to the history of visited. -bool CEdit::HyperAdd(const char *filename, int firstLine) +bool CEdit::HyperAdd(std::string filename, int firstLine) { if ( m_historyCurrent >= EDITHISTORYMAX-1 ) return false; m_historyCurrent ++; - strcpy(m_history[m_historyCurrent].filename, filename); + m_history[m_historyCurrent].filename = filename; m_history[m_historyCurrent].firstLine = firstLine; m_historyTotal = m_historyCurrent+1; @@ -935,10 +934,10 @@ void CEdit::Draw() pos.x = m_pos.x+(10.0f/640.0f); if ( m_bAutoIndent ) { + const char *s = "\t"; // line | dotted for ( j=0 ; j<m_lineIndent[i] ; j++ ) { - char s = '\t'; // line | dotted - m_engine->GetText()->DrawText(&s, m_fontType, m_fontSize, pos, 1.0f, Gfx::TEXT_ALIGN_LEFT, 0); + m_engine->GetText()->DrawText(s, m_fontType, m_fontSize, pos, 1.0f, Gfx::TEXT_ALIGN_LEFT, 0); pos.x += indentLength; } } @@ -950,7 +949,7 @@ void CEdit::Draw() size = m_fontSize; // Headline \b;? - if ( beg+len < m_len && m_format.count(beg) && + if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) { start.x = ppos.x-MARGX; @@ -964,7 +963,7 @@ void CEdit::Draw() } // As \t;? - if ( beg+len < m_len && m_format.count(beg) && + if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_NORM ) { start.x = ppos.x-MARGX; @@ -975,7 +974,7 @@ void CEdit::Draw() } // Subtitle \s;? - if ( beg+len < m_len && m_format.count(beg) && + if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_LITTLE ) { start.x = ppos.x-MARGX; @@ -986,7 +985,7 @@ void CEdit::Draw() } // Table \tab;? - if ( beg+len < m_len && m_format.count(beg) && + if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) && (m_format[beg]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE ) { start.x = ppos.x-MARGX; @@ -997,7 +996,7 @@ void CEdit::Draw() } // Image \image; ? - if ( beg+len < m_len && m_format.count(beg) && + if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) && (m_format[beg]&Gfx::FONT_MASK_IMAGE) != 0 ) { line = 1; @@ -1005,7 +1004,7 @@ void CEdit::Draw() { if ( i+line >= m_lineTotal || i+line >= m_lineFirst+m_lineVisible || - (m_format.count(beg+line) && m_format[beg+line]&Gfx::FONT_MASK_IMAGE) == 0 ) break; + (m_format.size() > static_cast<unsigned int>(beg+line) && m_format[beg+line]&Gfx::FONT_MASK_IMAGE) == 0 ) break; line ++; } @@ -1034,16 +1033,18 @@ void CEdit::Draw() else { start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg).substr(0, o1-beg), - m_format, + m_format.begin() + beg, + m_format.end(), size); end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1).substr(0, o2-o1), - m_format, + m_format.begin() + o1, + m_format.end(), size); } start.y = ppos.y-(m_bMulti?0.0f:MARGY1); end.y = m_lineHeight; - if ( m_format.count(beg) && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT; + if ( m_format.size() > static_cast<unsigned int>(beg) && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT; DrawPart(start, end, 1); // plain yellow background } @@ -1065,7 +1066,8 @@ void CEdit::Draw() else { m_engine->GetText()->DrawText(std::string(m_text+beg).substr(0, len), - m_format, + m_format.begin() + beg, + m_format.end(), size, ppos, m_dim.x, @@ -1107,7 +1109,8 @@ void CEdit::Draw() else { m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]).substr(0, len), - m_format, + m_format.begin() + m_lineOffset[i], + m_format.end(), size, pos, Gfx::TEXT_ALIGN_LEFT, start, end); } @@ -1131,16 +1134,14 @@ void CEdit::Draw() // Draw an image part. -void CEdit::DrawImage(Math::Point pos, const char *name, float width, +void CEdit::DrawImage(Math::Point pos, std::string name, float width, float offset, float height, int nbLine) { - Math::Point uv1, uv2, dim; - float dp; - char filename[100]; + Math::Point uv1, uv2, dim; + float dp; + std::string filename; -//? sprintf(filename, "diagram\\%s.png", name); - UserDir(filename, name, "diagram"); - strcat(filename, ".png"); + filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png"; m_engine->SetTexture(filename); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); @@ -1384,77 +1385,58 @@ int CEdit::GetTextLength() // Returns a name in a command. // \x nom1 nom2 nom3; -void GetNameParam(const char *cmd, int rank, char *buffer) +std::string GetNameParam(std::string cmd, int rank) { - int i; - - for ( i=0 ; i<rank ; i++ ) - { - while ( *cmd != ' ' && *cmd != ';' ) - { - cmd ++; - } - if ( *cmd != ';' ) cmd ++; + std::vector<std::string> results; + boost::split(results, cmd, boost::is_any_of(" ;")); + + if (results.size() > static_cast<unsigned int>(rank)) { + return results.at(rank); } - while ( *cmd != ' ' && *cmd != ';' ) - { - *buffer++ = *cmd++; - } - *buffer = 0; + return ""; } // Returns a number of a command. // \x nom n1 n2; -int GetValueParam(const char *cmd, int rank) +int GetValueParam(std::string cmd, int rank) { - int n, i; - - for ( i=0 ; i<rank ; i++ ) - { - while ( *cmd != ' ' && *cmd != ';' ) - { - cmd ++; - } - if ( *cmd != ';' ) cmd ++; + std::vector<std::string> results; + boost::split(results, cmd, boost::is_any_of(" ;")); + int return_value = 0; + + if (results.size() > static_cast<unsigned int>(rank)) { + return_value = atoi(results.at(rank).c_str()); } - sscanf(cmd, "%d", &n); - return n; + return return_value; } // Frees all images. void CEdit::FreeImage() { - char filename[100]; - int i; + std::string filename; - for ( i=0 ; i<m_imageTotal ; i++ ) - { -//? sprintf(filename, "diagram\\%s.png", m_image[i].name); - UserDir(filename, m_image[i].name, "diagram"); - strcat(filename, ".png"); + for (int i = 0 ; i < m_imageTotal; i++ ) { + filename = GetProfile().GetUserBasedPath(m_image[i].name, "diagram") + ".png"; m_engine->DeleteTexture(filename); } } // Reads the texture of an image. -void CEdit::LoadImage(const char *name) +void CEdit::LoadImage(std::string name) { - char filename[100]; - -//? sprintf(filename, "diagram\\%s.png", name); - UserDir(filename, name, "diagram"); - strcat(filename, ".png"); + std::string filename; + filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png"; m_engine->LoadTexture(filename); } // Read from a text file. -bool CEdit::ReadText(const char *filename, int addSize) +bool CEdit::ReadText(std::string filename, int addSize) { FILE *file = NULL; char *buffer; @@ -1466,7 +1448,16 @@ bool CEdit::ReadText(const char *filename, int addSize) bool bInSoluce, bBOL; if ( filename[0] == 0 ) return false; - file = fopen(filename, "rb"); + boost::replace_all(filename, "\\", "/"); + + /* This is ugly but doesn't require many changes in code. If file doesn't + exists it's posible filename is absolute not full path */ + std::string path = filename; + if (!fs::exists(path)) { + path = CApplication::GetInstancePointer()->GetDataDirPath() + "/" + filename; + } + + file = fopen(fs::path(path).make_preferred().string().c_str(), "rb"); if ( file == NULL ) return false; fseek(file, 0, SEEK_END); @@ -1491,8 +1482,11 @@ bool CEdit::ReadText(const char *filename, int addSize) fread(buffer, 1, len, file); - if ( m_format.size() > 0 ) - m_format.clear(); + m_format.clear(); + m_format.reserve(m_maxChar+1); + for (i = 0; i <= m_maxChar+1; i++) { + m_format.push_back(0); + } fclose(file); @@ -1597,8 +1591,8 @@ bool CEdit::ReadText(const char *filename, int addSize) { if ( iLink < EDITLINKMAX ) { - GetNameParam(buffer+i+3, 0, m_link[iLink].name); - GetNameParam(buffer+i+3, 1, m_link[iLink].marker); + m_link[iLink].name = GetNameParam(buffer+i+3, 0); + m_link[iLink].marker = GetNameParam(buffer+i+3, 1); iLink ++; } font &= ~Gfx::FONT_MASK_HIGHLIGHT; @@ -1614,7 +1608,7 @@ bool CEdit::ReadText(const char *filename, int addSize) { if ( m_markerTotal < EDITLINKMAX ) { - GetNameParam(buffer+i+3, 0, m_marker[m_markerTotal].name); + m_marker[m_markerTotal].name = GetNameParam(buffer+i+3, 0); m_marker[m_markerTotal].pos = j; m_markerTotal ++; } @@ -1632,21 +1626,19 @@ bool CEdit::ReadText(const char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { -#if _DEMO - strcpy(iName, "demo"); -#else - GetNameParam(buffer+i+7, 0, iName); -#endif + + strcpy(iName, GetNameParam(buffer+i+7, 0).c_str()); + //? iWidth = m_lineHeight*RetValueParam(buffer+i+7, 1); iWidth = static_cast<float>(GetValueParam(buffer+i+7, 1)); iWidth *= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL); iLines = GetValueParam(buffer+i+7, 2); - LoadImage(iName); + LoadImage(std::string(iName)); // A part of image per line of text. for ( iCount=0 ; iCount<iLines ; iCount++ ) { - strcpy(m_image[iIndex].name, iName); + m_image[iIndex].name = iName; m_image[iIndex].offset = static_cast<float>(iCount/iLines); m_image[iIndex].height = 1.0f/iLines; m_image[iIndex].width = iWidth*0.75f; @@ -1880,7 +1872,7 @@ bool CEdit::ReadText(const char *filename, int addSize) // Writes all the text in a file. -bool CEdit::WriteText(const char *filename) +bool CEdit::WriteText(std::string filename) { FILE* file; char buffer[1000+20]; @@ -1888,7 +1880,7 @@ bool CEdit::WriteText(const char *filename) float iDim; if ( filename[0] == 0 ) return false; - file = fopen(filename, "wb"); + file = fopen(filename.c_str(), "wb"); if ( file == NULL ) return false; if ( m_bAutoIndent ) @@ -1957,8 +1949,11 @@ void CEdit::SetMaxChar(int max) m_text = new char[m_maxChar+1]; memset(m_text, 0, m_maxChar+1); - if (m_format.size() > 0) - m_format.clear(); + m_format.clear(); + m_format.reserve(m_maxChar+1); + for (int i = 0; i <= m_maxChar+1; i++) { + m_format.push_back(0); + } m_len = 0; m_cursor1 = 0; @@ -1987,12 +1982,12 @@ bool CEdit::GetEditCap() // Mode management "hilitable" (that's the franch). -void CEdit::SetHiliteCap(bool bEnable) +void CEdit::SetHighlightCap(bool bEnable) { m_bHilite = bEnable; } -bool CEdit::GetHiliteCap() +bool CEdit::GetHighlightCap() { return m_bHilite; } @@ -2147,6 +2142,13 @@ bool CEdit::GetDisplaySpec() void CEdit::SetMultiFont(bool bMulti) { m_format.clear(); + + if (bMulti) { + m_format.reserve(m_maxChar+1); + for (int i = 0; i <= m_maxChar+1; i++) { + m_format.push_back(0); + } + } } // TODO check if it works correctly; was checking if variable is null @@ -2450,7 +2452,8 @@ void CEdit::MoveLine(int move, bool bWord, bool bSelect) else { c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]), - m_format, + m_format.begin() + m_lineOffset[line], + m_format.end(), m_fontSize, m_lineOffset[line+1]-m_lineOffset[line]); } @@ -2481,7 +2484,8 @@ void CEdit::ColumnFix() { m_column = m_engine->GetText()->GetStringWidth( std::string(m_text+m_lineOffset[line]), - m_format, + m_format.begin() + m_lineOffset[line], + m_format.end(), m_fontSize ); } @@ -2823,20 +2827,20 @@ void CEdit::InsertOne(char character) { m_text[i] = m_text[i-1]; // shoot - //if ( m_format.size() > 0 ) - //{ + if ( m_format.size() > static_cast<unsigned int>(i) ) + { m_format[i] = m_format[i-1]; // shoot - //} + } } m_len ++; m_text[m_cursor1] = character; - //if ( m_format.size() > 0 ) - //{ + if ( m_format.size() > static_cast<unsigned int>(m_cursor1) ) + { m_format[m_cursor1] = 0; - //} + } m_cursor1++; m_cursor2 = m_cursor1; @@ -2884,7 +2888,7 @@ void CEdit::DeleteOne(int dir) { m_text[i] = m_text[i+hole]; - if ( m_format.count(i+hole) ) + if ( m_format.size() > static_cast<unsigned int>(i + hole) ) { m_format[i] = m_format[i+hole]; } @@ -3087,13 +3091,13 @@ void CEdit::Justif() { size = m_fontSize; - if ( m_format.count(i) && (m_format[i]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) // headline? + if ( m_format.size() > static_cast<unsigned int>(i) && (m_format[i]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) // headline? { size *= BIG_FONT; bDual = true; } - if ( m_format.count(i) && (m_format[i]&Gfx::FONT_MASK_IMAGE) != 0 ) // image part? + if ( m_format.size() > static_cast<unsigned int>(i) && (m_format[i]&Gfx::FONT_MASK_IMAGE) != 0 ) // image part? { i ++; // jumps just a character (index in m_image) } @@ -3101,7 +3105,8 @@ void CEdit::Justif() { // TODO check if good i += m_engine->GetText()->Justify(std::string(m_text+i), - m_format, + m_format.begin() + i, + m_format.end(), size, width); } @@ -3296,12 +3301,12 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format) { int i; - //if ( m_format.size() == 0 ) return false; + if ( m_format.size() < static_cast<unsigned int>(cursor2) ) + SetMultiFont(true); for ( i=cursor1 ; i<cursor2 ; i++ ) { - if (m_format.count(i)) - m_format[i] |= format; + m_format.at(i) |= format; } return true; diff --git a/src/ui/edit.h b/src/ui/edit.h index 7247181..1cfec80 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -32,11 +32,16 @@ #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" #include "common/restext.h" #include <set> +#include <string> +#include <cstdlib> +#include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp> + +namespace fs = boost::filesystem; namespace Ui { @@ -85,7 +90,7 @@ enum OperUndo struct ImageLine { //! name of the image (without diagram \) - char name[40]; + std::string name; //! vertical offset (v texture) float offset; //! height of the part (dv texture) @@ -97,15 +102,15 @@ struct ImageLine struct HyperLink { //! text file name (without help \) - char name[40]; + std::string name; //! name of the marker - char marker[20]; + std::string marker; }; struct HyperMarker { //! name of the marker - char name[20]; + std::string name; //! position in the text int pos; }; @@ -113,7 +118,7 @@ struct HyperMarker struct HyperHistory { //! full file name text - char filename[50]; + std::string filename; //! rank of the first displayed line int firstLine; }; @@ -141,8 +146,8 @@ public: char* GetText(); int GetTextLength(); - bool ReadText(const char *filename, int addSize=0); - bool WriteText(const char *filename); + bool ReadText(std::string filename, int addSize=0); + bool WriteText(std::string filename); void SetMaxChar(int max); int GetMaxChar(); @@ -150,8 +155,8 @@ public: void SetEditCap(bool bMode); bool GetEditCap(); - void SetHiliteCap(bool bEnable); - bool GetHiliteCap(); + void SetHighlightCap(bool bEnable); + bool GetHighlightCap(); void SetInsideScroll(bool bInside); bool GetInsideScroll(); @@ -184,7 +189,7 @@ public: bool Undo(); void HyperFlush(); - void HyperHome(const char *filename); + void HyperHome(std::string filename); bool HyperTest(EventType event); bool HyperGo(EventType event); @@ -203,15 +208,15 @@ protected: int MouseDetect(Math::Point mouse); void MoveAdjust(); - void HyperJump(const char *name, const char *marker); - bool HyperAdd(const char *filename, int firstLine); + void HyperJump(std::string name, std::string marker); + bool HyperAdd(std::string filename, int firstLine); - void DrawImage(Math::Point pos, const char *name, float width, float offset, float height, int nbLine); + void DrawImage(Math::Point pos, std::string name, float width, float offset, float height, int nbLine); void DrawBack(Math::Point pos, Math::Point dim); void DrawPart(Math::Point pos, Math::Point dim, int icon); void FreeImage(); - void LoadImage(const char *name); + void LoadImage(std::string name); void Scroll(int pos, bool bAdjustCursor); void Scroll(); void MoveChar(int move, bool bWord, bool bSelect); @@ -242,7 +247,7 @@ protected: int m_maxChar; // max length of the buffer m_text char* m_text; // text (without zero terminator) - std::map<unsigned int, Gfx::FontMetaChar> m_format; // format characters + std::vector<Gfx::FontMetaChar> m_format; // format characters int m_len; // length used in m_text int m_cursor1; // offset cursor int m_cursor2; // offset cursor 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 68e7854..9060e8b 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -14,22 +14,25 @@ // * 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 "app/system.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 +57,7 @@ //TODO Get rid of all sprintf's -namespace Ui -{ +namespace Ui { const int KEY_VISIBLE = 6; // number of visible keys redefinable @@ -106,20 +108,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; @@ -176,7 +174,7 @@ CMainDialog::CMainDialog(CInstanceManager* iMan) m_sceneDir = "levels"; - m_savegameDir = "savegame"; + m_savegameDir = GetSystemUtils()->savegameDirectoryLocation(); m_publicDir = "program"; m_userDir = "user"; m_filesDir = "files"; @@ -378,7 +376,7 @@ pb->SetState(STATE_SHADOW); pos.y -= 5.0f/480.0f; pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "PPC Team"); pl->SetFontType(Gfx::FONT_COURIER); - pl->SetFontSize(8.0f); + pl->SetFontSize(Gfx::FONT_SIZE_SMALL); m_engine->SetBackground("interface.png", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), @@ -748,6 +746,10 @@ pb->SetState(STATE_SHADOW); m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { + if (!m_sound->IsPlayingMusic()) { + m_sound->PlayMusic(11, true); + } + if ( m_phase == PHASE_TRAINER ) m_index = 0; if ( m_phase == PHASE_DEFI ) m_index = 1; if ( m_phase == PHASE_MISSION ) m_index = 2; @@ -890,7 +892,7 @@ pb->SetState(STATE_SHADOW); pe->SetState(STATE_SHADOW); pe->SetMaxChar(500); pe->SetEditCap(false); // just to see - pe->SetHiliteCap(false); + pe->SetHighlightCap(false); // Button displays the "soluce": if ( m_phase != PHASE_TRAINER && @@ -1761,9 +1763,6 @@ pos.y -= 0.048f; } if ( m_phase == PHASE_WELCOME2 ) { - m_sound->StopMusic(); - m_sound->PlayMusic(11, false); - pos.x = 0.0f; pos.y = 0.0f; ddim.x = 0.0f; @@ -1817,10 +1816,10 @@ pos.y -= 0.048f; pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1); pe->SetGenericMode(true); pe->SetEditCap(false); - pe->SetHiliteCap(false); + pe->SetHighlightCap(false); pe->SetFontType(Gfx::FONT_COURIER); - pe->SetFontSize(8.0f); - pe->ReadText("help/authors.txt"); + pe->SetFontSize(Gfx::FONT_SIZE_SMALL); + pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt")); pos.x = 80.0f/640.0f; pos.y = 140.0f/480.0f; @@ -1829,30 +1828,30 @@ pos.y -= 0.048f; pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT2); pe->SetGenericMode(true); pe->SetEditCap(false); - pe->SetHiliteCap(false); + pe->SetHighlightCap(false); pe->SetFontType(Gfx::FONT_COURIER); - pe->SetFontSize(6.5f); - pe->ReadText("help/licences.txt"); + pe->SetFontSize(Gfx::FONT_SIZE_SMALL); + pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/licences.txt")); // #endif /* TODO: #if _SCHOOL -#if _CEEBOTDEMO -pos.x = 80.0f/640.0f; -pos.y = 210.0f/480.0f; -ddim.x = 490.0f/640.0f; -ddim.y = 150.0f/480.0f; -#else -pos.x = 80.0f/640.0f; -pos.y = 200.0f/480.0f; -ddim.x = 490.0f/640.0f; -ddim.y = 150.0f/480.0f; -#endif*/ + #if _CEEBOTDEMO + pos.x = 80.0f/640.0f; + pos.y = 210.0f/480.0f; + ddim.x = 490.0f/640.0f; + ddim.y = 150.0f/480.0f; + #else + pos.x = 80.0f/640.0f; + pos.y = 200.0f/480.0f; + ddim.x = 490.0f/640.0f; + ddim.y = 150.0f/480.0f; + #endif pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1); pe->SetGenericMode(true); pe->SetEditCap(false); - pe->SetHiliteCap(false); + pe->SetHighlightCap(false); pe->SetFontType(Gfx::FONT_COURIER); - pe->SetFontSize(8.0f); - pe->ReadText("help/authors.txt"); + pe->SetFontSize(Gfx::FONT_SIZE_SMALL); + pe->ReadText("help/authors.txt");*/ /* #if _DEMO //? pos.x = 80.0f/640.0f; @@ -1864,7 +1863,7 @@ ddim.y = 150.0f/480.0f; //? pe->SetEditCap(false); //? pe->SetHiliteCap(false); //? pe->SetFontType(Gfx::FONT_COURIER); - //? pe->SetFontSize(8.0f); + //? pe->SetFontSize(Gfx::FONT_SIZE_SMALL); //? pe->ReadText("help/demo.txt"); //? pos.x = 80.0f/640.0f; @@ -1876,7 +1875,7 @@ ddim.y = 150.0f/480.0f; //? pe->SetEditCap(false); //? pe->SetHiliteCap(false); //? pe->SetFontType(Gfx::FONT_COURIER); - //? pe->SetFontSize(8.0f); + //? pe->SetFontSize(Gfx::FONT_SIZE_SMALL); //? pe->ReadText("help/authors.txt"); #endif */ @@ -1888,13 +1887,13 @@ ddim.y = 150.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_DEV1, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); pl->SetFontType(Gfx::FONT_COURIER); - pl->SetFontSize(8.0f); + pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pos.y = 13.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_DEV2, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name); pl->SetFontType(Gfx::FONT_COURIER); - pl->SetFontSize(8.0f); + pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pos.x = 355.0f/640.0f; pos.y = 83.0f/480.0f; @@ -1903,13 +1902,13 @@ ddim.y = 150.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_EDIT1, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name); pl->SetFontType(Gfx::FONT_COURIER); - pl->SetFontSize(8.0f); + pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pos.y = 13.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_EDIT2, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name); pl->SetFontType(Gfx::FONT_COURIER); - pl->SetFontSize(8.0f); + pl->SetFontSize(Gfx::FONT_SIZE_SMALL); // #endif /* TODO: #if _DEMO @@ -1928,7 +1927,7 @@ ddim.y = 150.0f/480.0f; pb->SetState(STATE_SHADOW); // #endif - m_engine->SetBackground("generic.png", + m_engine->SetBackground("generico.png", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), @@ -1972,8 +1971,8 @@ ddim.y = 9.0f/480.0f; ddim.x = 90.0f/640.0f; ddim.y = 10.0f/480.0f; //#endif - GetResource(RES_TEXT, RT_VERSION_ID, name); - pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); + //GetResource(RES_TEXT, RT_VERSION_ID, name); + pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, __DATE__); pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontSize(9.0f); } @@ -3561,11 +3560,11 @@ void CMainDialog::SetUserDir(char *base, int rank) if ( strcmp(base, "user") == 0 && rank >= 100 ) { dir = m_userDir + "/" + m_userList.at(rank/100-1); - UserDir(true, dir.c_str()); + GetProfile().SetUserDir(dir); } else { - UserDir(false, ""); + GetProfile().SetUserDir(""); } } @@ -4260,7 +4259,6 @@ bool CMainDialog::IsIOReadScene() FILE* file; std::string filename; - //TODO: Change this to point user dir acocrding to operating system filename = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + "000/data.sav"; file = fopen(filename.c_str(), "r"); if ( file == NULL ) return false; @@ -4277,6 +4275,7 @@ void CMainDialog::IOReadName() CEdit* pe; std::string filename; char op[100]; + char op_i18n[100]; char line[500]; char resume[100]; char name[100]; @@ -4290,6 +4289,9 @@ void CMainDialog::IOReadName() sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1); BuildSceneName(filename, m_sceneName, (m_chap[m_index]+1)*100); + sprintf(op, "Title.E"); + sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar() ); + file = fopen(filename.c_str(), "r"); if ( file != NULL ) { @@ -4305,11 +4307,13 @@ void CMainDialog::IOReadName() } } - // TODO: Fallback to an non-localized entry - sprintf(op, "Title.%c", m_app->GetLanguageChar() ); if ( Cmd(line, op) ) { OpString(line, "resume", resume); + } + if ( Cmd(line, op_i18n) ) + { + OpString(line, "resume", resume); break; } } @@ -4350,7 +4354,7 @@ void CMainDialog::IOReadList() filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/data.sav"; // sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j); - file = fopen(filename.c_str(), "r"); + file = fopen(fs::path(filename).make_preferred().string().c_str(), "r"); if ( file == NULL ) break; while ( fgets(line, 500, file) != NULL ) @@ -4648,12 +4652,14 @@ void CMainDialog::UpdateSceneChap(int &chap) //struct _finddata_t fileBuffer; std::string fileName; char op[100]; + char op_i18n[100]; char line[500]; char name[100]; int i, j; bool bPassed; memset(op, 0, 100); + memset(op_i18n, 0, 100); memset(line, 0, 500); memset(name, 0, 100); @@ -4668,6 +4674,7 @@ void CMainDialog::UpdateSceneChap(int &chap) { j = 0; fs::directory_iterator dirIt(m_savegameDir), dirEndIt; + m_userList.clear(); BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt)) { @@ -4689,6 +4696,9 @@ void CMainDialog::UpdateSceneChap(int &chap) else { BuildResumeName(name, m_sceneName, j+1); // default name + sprintf(op, "Title.E"); + sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar()); + while ( fgets(line, 500, file) != NULL ) { for ( i=0 ; i<500 ; i++ ) @@ -4701,11 +4711,13 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - // TODO: Fallback to an non-localized entry - sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); + } + if ( Cmd(line, op_i18n) ) + { + OpString(line, "text", name); break; } } @@ -4736,6 +4748,9 @@ void CMainDialog::UpdateSceneChap(int &chap) if ( file == NULL ) break; BuildResumeName(name, m_sceneName, j+1); // default name + sprintf(op, "Title.E"); + sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar()); + while ( fgets(line, 500, file) != NULL ) { for ( i=0 ; i<500 ; i++ ) @@ -4748,11 +4763,13 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - // TODO: Fallback to an non-localized entry - sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); + } + if ( Cmd(line, op_i18n) ) + { + OpString(line, "text", name); break; } } @@ -4801,12 +4818,14 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) CList* pl; std::string fileName; char op[100]; + char op_i18n[100]; char line[500]; char name[100]; int i, j; bool bPassed; memset(op, 0, 100); + memset(op_i18n, 0, 100); memset(line, 0, 500); memset(name, 0, 100); @@ -4839,6 +4858,9 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) if ( file == NULL ) break; BuildResumeName(name, m_sceneName, j+1); // default name + sprintf(op, "Title.E"); + sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar()); + while ( fgets(line, 500, file) != NULL ) { for ( i=0 ; i<500 ; i++ ) @@ -4851,11 +4873,13 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) } } - // TODO: Fallback to an non-localized entry - sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); + } + if ( Cmd(line, op_i18n) ) + { + OpString(line, "text", name); break; } } @@ -4950,6 +4974,7 @@ void CMainDialog::UpdateSceneResume(int rank) CCheck* pc; std::string fileName; char op[100]; + char op_i18n[100]; char line[500]; char name[500]; int i, numTry; @@ -4980,6 +5005,9 @@ void CMainDialog::UpdateSceneResume(int rank) } BuildSceneName(fileName, m_sceneName, rank); + sprintf(op, "Resume.E"); + sprintf(op_i18n, "Resume.%c", m_app->GetLanguageChar()); + file = fopen(fileName.c_str(), "r"); if ( file == NULL ) return; @@ -4996,11 +5024,13 @@ void CMainDialog::UpdateSceneResume(int rank) } } - // TODO: Fallback to an non-localized entry - sprintf(op, "Resume.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); + } + if ( Cmd(line, op_i18n) ) + { + OpString(line, "text", name); break; } } @@ -5016,8 +5046,8 @@ void CMainDialog::UpdateDisplayDevice() CWindow* pw; CList* pl; char bufDevices[1000]; - char bufModes[5000]; - int i, j, totalDevices, selectDevices, totalModes, selectModes; + //char bufModes[5000]; + int i, j; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; @@ -5025,7 +5055,7 @@ void CMainDialog::UpdateDisplayDevice() if ( pl == 0 ) return; pl->Flush(); - bufModes[0] = 0; + //bufModes[0] = 0; /* TODO: remove device choice m_engine->EnumDevices(bufDevices, 1000, bufModes, 5000, @@ -5040,10 +5070,10 @@ void CMainDialog::UpdateDisplayDevice() while ( bufDevices[i++] != 0 ); } - pl->SetSelect(selectDevices); + pl->SetSelect(0); pl->ShowSelect(false); - m_setupSelDevice = selectDevices; + m_setupSelDevice = 0; } // Updates the list of modes. @@ -5080,8 +5110,8 @@ void CMainDialog::ChangeDisplay() CWindow* pw; CList* pl; CCheck* pc; - char* device; - char* mode; + //char* device; + //char* mode; bool bFull; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); @@ -5090,12 +5120,12 @@ void CMainDialog::ChangeDisplay() pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; m_setupSelDevice = pl->GetSelect(); - device = pl->GetName(m_setupSelDevice); + //device = pl->GetName(m_setupSelDevice); pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; m_setupSelMode = pl->GetSelect(); - mode = pl->GetName(m_setupSelMode); + //mode = pl->GetName(m_setupSelMode); pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL)); if ( pc == 0 ) return; @@ -5427,10 +5457,8 @@ void CMainDialog::ChangeSetupButtons() ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC)); if ( ps != 0 ) { - /* - TODO: midi volume value = ps->GetVisibleValue(); - m_sound->SetMidiVolume((int)value);*/ + m_sound->SetMusicVolume(static_cast<int>(value)); } } diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index 51c6f2e..a79b95e 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -20,20 +20,24 @@ #include "graphics/core/color.h" + #include "object/robotmain.h" -class CInstanceManager; +#include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp> + +namespace fs = boost::filesystem; + + class CEventQueue; class CSoundInterface; -namespace Gfx -{ +namespace Gfx { class CEngine; class CParticle; -}; +} -namespace Ui -{ +namespace Ui { class CInterface; class CWindow; @@ -64,7 +68,7 @@ struct GamerPerso class CMainDialog { public: - CMainDialog(CInstanceManager* iMan); + CMainDialog(); ~CMainDialog(); bool EventProcess(const Event &event); @@ -172,7 +176,6 @@ protected: void ChangeKey(EventType event); protected: - CInstanceManager* m_iMan; CApplication* m_app; CRobotMain* m_main; CEventQueue* m_eventQueue; @@ -260,3 +263,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 2f58c95..29dfebf 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); } @@ -114,7 +113,7 @@ bool CStudio::EventProcess(const Event &event) if ( pw == nullptr ) return false; edit = static_cast<CEdit*>(pw->SearchControl(EVENT_STUDIO_EDIT)); - if ( edit == 0 ) return false; + if ( edit == nullptr ) return false; if ( event.type == pw->GetEventTypeClose() ) { @@ -501,7 +500,7 @@ void CStudio::SearchToken(CEdit* edit) } token[i] = 0; - m_helpFilename = std::string(GetHelpFilename(token)); + m_helpFilename = GetHelpFilename(token); if ( m_helpFilename.length() == 0 ) { for ( i=0 ; i<OBJECT_MAX ; i++ ) @@ -692,7 +691,7 @@ void CStudio::AdjustEditScript() dim.x = wdim.x-0.02f; dim.y = wdim.y-0.22f-hList; edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); - if ( edit != 0 ) + if ( edit != nullptr ) { edit->SetPos(pos); edit->SetDim(dim); @@ -703,7 +702,7 @@ void CStudio::AdjustEditScript() dim.x = wdim.x-0.02f; dim.y = hList; list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST)); - if ( list != 0 ) + if ( list != nullptr ) { list->SetPos(pos); list->SetDim(dim); @@ -716,56 +715,56 @@ void CStudio::AdjustEditScript() pos.y = wpos.y+wdim.y-dim.y-0.06f; pos.x = wpos.x+0.01f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_NEW)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.05f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OPEN)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.09f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_SAVE)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.14f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_UNDO)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.19f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CUT)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.23f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COPY)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.27f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_PASTE)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.32f; slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) + if ( slider != nullptr ) { ppos = pos; ddim.x = dim.x*0.7f; @@ -777,21 +776,21 @@ void CStudio::AdjustEditScript() } pos.x = wpos.x+0.36f; group = static_cast< CGroup* >(pw->SearchControl(EVENT_LABEL1)); - if ( group != 0 ) + if ( group != nullptr ) { group->SetPos(pos); group->SetDim(dim); } pos.x = wpos.x+0.40f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_TOOL)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.44f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_HELP)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); @@ -802,14 +801,14 @@ void CStudio::AdjustEditScript() dim.x = 80.0f/640.0f; dim.y = 25.0f/480.0f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OK)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.14f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CANCEL)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); @@ -817,28 +816,28 @@ void CStudio::AdjustEditScript() pos.x = wpos.x+0.28f; dim.x = dim.y*0.75f; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*1; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*2; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*3; button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP)); - if ( button != 0 ) + if ( button != nullptr ) { button->SetPos(pos); button->SetDim(dim); @@ -991,13 +990,13 @@ void CStudio::UpdateButtons() { edit->SetIcon(1); // red background edit->SetEditCap(false); // just to see - edit->SetHiliteCap(true); + edit->SetHighlightCap(true); } else { edit->SetIcon(0); // standard background edit->SetEditCap(true); - edit->SetHiliteCap(true); + edit->SetHighlightCap(true); } button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE)); @@ -1478,8 +1477,7 @@ void CStudio::UpdateDialogPublic() CCheck* pc; CLabel* pl; char name[100]; - char dir[MAX_FNAME]; - char text[MAX_FNAME+100]; + //char text[MAX_FNAME+100]; pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; @@ -1500,9 +1498,7 @@ void CStudio::UpdateDialogPublic() if ( pl != 0 ) { GetResource(RES_TEXT, RT_IO_LIST, name); - SearchDirectory(dir, false); - sprintf(text, name, dir); - pl->SetName(text, false); + pl->SetName(SearchDirectory(false).c_str(), false); } } @@ -1510,84 +1506,52 @@ void CStudio::UpdateDialogPublic() void CStudio::UpdateDialogList() { - // TODO rewrite to multiplatform - /*CWindow* pw; - CList* pl; - long hFile; - struct _finddata_t fileBuffer; - struct _finddata_t* listBuffer; - bool bDo; - char dir[MAX_FNAME]; - char temp[MAX_FNAME]; - int nbFilenames, i; - - pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9); + CWindow* pw; + CList* pl; + fs::path path; + int i = 0; + char time[100]; + char temp[100]; + + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; - pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST); - if ( pl == 0 ) return; + pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); + if ( pl == nullptr ) return; pl->Flush(); - nbFilenames = 0; - listBuffer = (_finddata_t*)malloc(sizeof(_finddata_t)*1000); - - SearchDirectory(dir, false); - strcat(dir, "*"); // list all - hFile = _findfirst(dir, &fileBuffer); - if ( hFile != -1 ) - { - do - { - if ( (fileBuffer.attrib & _A_SUBDIR) == 0 ) - { - listBuffer[nbFilenames++] = fileBuffer; + path = fs::path(SearchDirectory(false)); + fs::directory_iterator end_iter; + if ( fs::exists(path) && fs::is_directory(path) ) { + for( fs::directory_iterator file(path); file != end_iter; file++) { + if (fs::is_regular_file(file->status()) ) { + TimeToAscii(fs::last_write_time(file->path()), time); + sprintf(temp, "%s\t%lu \t%s", file->path().filename().string().c_str(), fs::file_size(file->path()), time); + + pl->SetName(i++, temp); } } - while ( _findnext(hFile, &fileBuffer) == 0 && nbFilenames < 1000 ); } - do // sorts all names: - { - bDo = false; - for ( i=0 ; i<nbFilenames-1 ; i++ ) - { - if ( strcmp(listBuffer[i].name, listBuffer[i+1].name) > 0 ) - { - fileBuffer = listBuffer[i]; // exchange i and i +1 - listBuffer[i] = listBuffer[i+1]; - listBuffer[i+1] = fileBuffer; - bDo = true; - } - } - } - while ( bDo ); - - for ( i=0 ; i<nbFilenames ; i++ ) - { - TimeToAscii(listBuffer[i].time_write, dir); - sprintf(temp, "%s\t%d \t%s", listBuffer[i].name, listBuffer[i].size, dir); - pl->SetName(i, temp); - } - - free(listBuffer);*/ } // Constructs the name of the folder or open/save. // If the folder does not exist, it will be created. -void CStudio::SearchDirectory(char *dir, bool bCreate) +std::string CStudio::SearchDirectory(bool bCreate) { - if ( m_main->GetIOPublic() ) - { - sprintf(dir, "%s\\", m_main->GetPublicDir()); + char dir[MAX_FNAME]; + if ( m_main->GetIOPublic() ) { + sprintf(dir, "%s/", m_main->GetPublicDir()); + } else { + sprintf(dir, "%s/%s/Program/", m_main->GetSavegameDir(), m_main->GetGamerName()); } - else - { - sprintf(dir, "%s\\%s\\Program\\", m_main->GetSavegameDir(), m_main->GetGamerName()); + + fs::path path = fs::path(dir); + + if ( bCreate ) { + fs::create_directory(path); } - if ( bCreate ) - {// TODO -// mkdir(dir,0777); // if does not exist yet! - } + return path.make_preferred().string(); } // Reads a new program. @@ -1613,7 +1577,7 @@ bool CStudio::ReadProgram() { strcat(filename, ".txt"); } - SearchDirectory(dir, true); + strcpy(dir, SearchDirectory(true).c_str()); strcat(dir, filename); pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); @@ -1651,7 +1615,7 @@ bool CStudio::WriteProgram() { strcat(filename, ".txt"); } - SearchDirectory(dir, true); + strcpy(dir, SearchDirectory(true).c_str()); strcat(dir, filename); pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); @@ -1659,7 +1623,7 @@ bool CStudio::WriteProgram() pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( pe == nullptr ) return false; - if ( !pe->WriteText(dir) ) return false; + if ( !pe->WriteText(std::string(dir)) ) return false; m_script->SetFilename(filename); return true; diff --git a/src/ui/studio.h b/src/ui/studio.h index 905baa6..1c14124 100644 --- a/src/ui/studio.h +++ b/src/ui/studio.h @@ -22,11 +22,13 @@ #include "graphics/engine/camera.h" +#include <boost/filesystem.hpp> + +namespace fs = boost::filesystem; #include <string> class CEventQueue; -class CInstanceManager; class CRobotMain; class CScript; class CSoundInterface; @@ -54,70 +56,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(); + std::string SearchDirectory(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/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt deleted file mode 100644 index c38d2bb..0000000 --- a/src/ui/test/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE debug) -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - -include_directories( -. -../.. -../../.. -${GTEST_INCLUDE_DIR} -${GMOCK_INCLUDE_DIR} -) - - -add_executable(edit_test - ../../common/event.cpp - ../../common/logger.cpp - ../../common/misc.cpp - ../../common/iman.cpp - ../../common/stringutils.cpp - ../../graphics/engine/text.cpp - ../button.cpp - ../control.cpp - ../edit.cpp - ../scroll.cpp - stubs/app_stub.cpp - stubs/engine_stub.cpp - stubs/particle_stub.cpp - stubs/restext_stub.cpp - stubs/robotmain_stub.cpp - edit_test.cpp) -target_link_libraries(edit_test gtest gmock ${SDL_LIBRARY} ${SDLTTF_LIBRARY}) - -add_test(edit_test ./edit_test) diff --git a/src/ui/test/edit_test.cpp b/src/ui/test/edit_test.cpp deleted file mode 100644 index 489b873..0000000 --- a/src/ui/test/edit_test.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "../edit.h" -#include "../../app/app.h" -#include "mocks/text_mock.h" -#include <gtest/gtest.h> -#include <gmock/gmock.h> -#include <fstream> - -class CEditTest : public testing::Test -{ -public: - CEditTest(){}; - - virtual void SetUp() - { - m_engine = new Gfx::CEngine(&m_iMan, NULL); - - m_iMan.AddInstance(CLASS_ENGINE, m_engine); - m_edit = new Ui::CEdit; - } - - virtual void TearDown() - { - m_iMan.DeleteInstance(CLASS_ENGINE, m_engine); - delete m_engine; - m_engine = NULL; - delete m_edit; - m_edit = NULL; - - } - virtual ~CEditTest() - { - - }; - -protected: - CInstanceManager m_iMan; - CApplication m_app; - Gfx::CEngine * m_engine; - Ui::CEdit * m_edit; - CLogger m_logger; -}; - -using ::testing::_; -using ::testing::Return; - -TEST_F(CEditTest, WriteTest) -{ - ASSERT_TRUE(true); - CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText()); - EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f)); - EXPECT_CALL(*text, GetStringWidth(_, _, _)).WillOnce(Return(1.0f)); - std::string filename = "test.file"; - m_edit->SetMaxChar(Ui::EDITSTUDIOMAX); - m_edit->SetAutoIndent(true); - std::string inputScript = "{\ntext1\ntext2\n\ntext3\n{\ntext4\n}\n}"; - std::string expectedScript = "{\r\n\ttext1\r\n\ttext2\r\n\t\r\n\ttext3\r\n\t{\r\n\t\ttext4\r\n\t}\r\n}"; - m_edit->SetText(inputScript.c_str(), true); - GetLogger()->Info("Writing text \n"); - m_edit->WriteText("script.txt"); - - std::fstream scriptFile; - - scriptFile.open("script.txt", std::ios_base::binary | std::ios_base::in); - std::string outputScript((std::istreambuf_iterator<char>(scriptFile)), std::istreambuf_iterator<char>()); - ASSERT_STREQ(expectedScript.c_str(), outputScript.c_str()); -} - -int main(int argc, char *argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/src/ui/test/mocks/text_mock.h b/src/ui/test/mocks/text_mock.h deleted file mode 100644 index 59a6c48..0000000 --- a/src/ui/test/mocks/text_mock.h +++ /dev/null @@ -1,21 +0,0 @@ -#include "../../graphics/engine/text.h" -#include <gmock/gmock.h> -#include "../../common/logger.h" - - -class CTextMock : public Gfx::CText -{ -public: - CTextMock(CInstanceManager *iMan, Gfx::CEngine* engine) : CText(iMan, engine) - { - } - - virtual ~CTextMock() - { - }; - - MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float)); - MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float)); - -}; - diff --git a/src/ui/test/stubs/app_stub.cpp b/src/ui/test/stubs/app_stub.cpp deleted file mode 100644 index 5dd79e4..0000000 --- a/src/ui/test/stubs/app_stub.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "../../app/app.h" -#include "../../graphics/opengl/gldevice.h" - -template<> CApplication* CSingleton<CApplication>::mInstance = nullptr; - -namespace Gfx { - -GLDeviceConfig::GLDeviceConfig() -{ -} - -} /* Gfx */ -CApplication::CApplication() -{ -} - -CApplication::~CApplication() -{ -} - -std::string CApplication::GetDataFilePath(DataDir /* dataDir */, const std::string& subpath) -{ - return subpath; -} - - diff --git a/src/ui/test/stubs/engine_stub.cpp b/src/ui/test/stubs/engine_stub.cpp deleted file mode 100644 index 6ec6006..0000000 --- a/src/ui/test/stubs/engine_stub.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "../../graphics/engine/engine.h" -#include "../../graphics/engine/text.h" -#include "../mocks/text_mock.h" - -namespace Gfx { - -CEngine::CEngine(CInstanceManager* iMan, CApplication* app) : - m_iMan(iMan), m_app(app) -{ - m_text = new CTextMock(m_iMan, this); - m_text->Create(); -} - -CEngine::~CEngine() -{ - delete m_text; - m_text = NULL; -} - -Math::Point CEngine::WindowToInterfaceSize(Math::IntPoint size) -{ - return Math::Point(size.x, size.y); -} - -void CEngine::SetState(int state, const Color& color) -{ - if (state == m_lastState && color == m_lastColor) - return; - - m_lastState = state; - m_lastColor = color; -} - -Math::IntPoint CEngine::GetWindowSize() -{ - return m_size; -} - -void CEngine::AddStatisticTriangle(int count) -{ - m_statisticTriangle += count; -} - -void CEngine::SetMouseType(EngineMouseType type) -{ - m_mouseType = type; -} - -bool CEngine::SetTexture(const std::string& /* name */, int /* stage */) -{ - return true; -} - -CText* CEngine::GetText() -{ - return m_text; -} - -CDevice* CEngine::GetDevice() -{ - return m_device; -} - -int CEngine::GetEditIndentValue() -{ - return m_editIndentValue; -} - -void CEngine::DeleteTexture(const std::string& /* texName */) -{ -} -Texture CEngine::LoadTexture(const std::string& /* name */) -{ - Texture texture; - return texture; -} - -} /* Gfx */ - diff --git a/src/ui/test/stubs/particle_stub.cpp b/src/ui/test/stubs/particle_stub.cpp deleted file mode 100644 index 41f07cc..0000000 --- a/src/ui/test/stubs/particle_stub.cpp +++ /dev/null @@ -1,291 +0,0 @@ -#include "graphics/engine/particle.h" - -#include "common/logger.h" - - -// Graphics module namespace -namespace Gfx { - - -CParticle::CParticle(CInstanceManager* iMan, CEngine* engine) -{ - GetLogger()->Trace("CParticle::CParticle() stub!\n"); - // TODO! -} - -CParticle::~CParticle() -{ - GetLogger()->Trace("CParticle::~CParticle() stub!\n"); - // TODO! -} - -void CParticle::SetDevice(CDevice* device) -{ - GetLogger()->Trace("CParticle::SetDevice() stub!\n"); - // TODO! -} - -void CParticle::FlushParticle() -{ - GetLogger()->Trace("CParticle::FlushParticle() stub!\n"); - // TODO! -} - -void CParticle::FlushParticle(int sheet) -{ - GetLogger()->Trace("CParticle::FlushParticle() stub!\n"); - // TODO! -} - -int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point dim, - ParticleType type, float duration, float mass, - float windSensitivity, int sheet) -{ - GetLogger()->Trace("CParticle::CreateParticle() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreateFrag(Math::Vector pos, Math::Vector speed, EngineTriangle *triangle, - ParticleType type, float duration, float mass, - float windSensitivity, int sheet) -{ - GetLogger()->Trace("CParticle::CreateFrag() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreatePart(Math::Vector pos, Math::Vector speed, ParticleType type, - float duration, float mass, float weight, - float windSensitivity, int sheet) -{ - GetLogger()->Trace("CParticle::CreatePart() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreateRay(Math::Vector pos, Math::Vector goal, ParticleType type, Math::Point dim, - float duration, int sheet) -{ - GetLogger()->Trace("CParticle::CreateRay() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticleType type, - float duration, float mass, float length, float width) -{ - GetLogger()->Trace("CParticle::CreateTrack() stub!\n"); - // TODO! - return 0; -} - -void CParticle::CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3, - const Math::Vector &p4, ParticleType type) -{ - GetLogger()->Trace("CParticle::CreateWheelTrace() stub!\n"); - // TODO! -} - -void CParticle::DeleteParticle(ParticleType type) -{ - GetLogger()->Trace("CParticle::DeleteParticle() stub!\n"); - // TODO! -} - -void CParticle::DeleteParticle(int channel) -{ - GetLogger()->Trace("CParticle::DeleteParticle() stub!\n"); - // TODO! -} - -void CParticle::SetObjectLink(int channel, CObject *object) -{ - GetLogger()->Trace("CParticle::SetObjectLink() stub!\n"); - // TODO! -} - -void CParticle::SetObjectFather(int channel, CObject *object) -{ - GetLogger()->Trace("CParticle::SetObjectFather() stub!\n"); - // TODO! -} - -void CParticle::SetPosition(int channel, Math::Vector pos) -{ - GetLogger()->Trace("CParticle::SetPosition() stub!\n"); - // TODO! -} - -void CParticle::SetDimension(int channel, Math::Point dim) -{ - GetLogger()->Trace("CParticle::SetDimension() stub!\n"); - // TODO! -} - -void CParticle::SetZoom(int channel, float zoom) -{ - GetLogger()->Trace("CParticle::SetZoom() stub!\n"); - // TODO! -} - -void CParticle::SetAngle(int channel, float angle) -{ - GetLogger()->Trace("CParticle::SetAngle() stub!\n"); - // TODO! -} - -void CParticle::SetIntensity(int channel, float intensity) -{ - GetLogger()->Trace("CParticle::SetIntensity() stub!\n"); - // TODO! -} - -void CParticle::SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity) -{ - GetLogger()->Trace("CParticle::SetParam() stub!\n"); - // TODO! -} - -void CParticle::SetPhase(int channel, ParticlePhase phase, float duration) -{ - GetLogger()->Trace("CParticle::SetPhase() stub!\n"); - // TODO! -} - -bool CParticle::GetPosition(int channel, Math::Vector &pos) -{ - GetLogger()->Trace("CParticle::GetPosition() stub!\n"); - // TODO! - return true; -} - -Color CParticle::GetFogColor(Math::Vector pos) -{ - GetLogger()->Trace("CParticle::GetFogColor() stub!\n"); - // TODO! - return Color(); -} - -void CParticle::SetFrameUpdate(int sheet, bool update) -{ - GetLogger()->Trace("CParticle::SetFrameUpdate() stub!\n"); - // TODO! -} - -void CParticle::FrameParticle(float rTime) -{ - GetLogger()->Trace("CParticle::FrameParticle() stub!\n"); - // TODO! -} - -void CParticle::DrawParticle(int sheet) -{ - GetLogger()->Trace("CParticle::DrawParticle() stub!\n"); - // TODO! -} - -bool CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur) -{ - GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n"); - // TODO! - return true; -} - -void CParticle::DeleteRank(int rank) -{ - GetLogger()->Trace("CParticle::DeleteRank() stub!\n"); - // TODO! -} - -bool CParticle::CheckChannel(int &channel) -{ - GetLogger()->Trace("CParticle::CheckChannel() stub!\n"); - // TODO! - return true; -} - -void CParticle::DrawParticleTriangle(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleTriangle() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleNorm(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleNorm() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleFlat(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleFlat() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleFog(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleFog() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleRay(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleRay() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleSphere(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleSphere() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleCylinder(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleCylinder() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleWheel(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleWheel() stub!\n"); - // TODO! -} - -CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father) -{ - GetLogger()->Trace("CParticle::SearchObjectGun() stub!\n"); - // TODO! - return nullptr; -} - -CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father) -{ - GetLogger()->Trace("CParticle::SearchObjectRay() stub!\n"); - // TODO! - return nullptr; -} - -void CParticle::Play(Sound sound, Math::Vector pos, float amplitude) -{ - GetLogger()->Trace("CParticle::Play() stub!\n"); - // TODO! -} - -bool CParticle::TrackMove(int i, Math::Vector pos, float progress) -{ - GetLogger()->Trace("CParticle::TrackMove() stub!\n"); - // TODO! - return true; -} - -void CParticle::TrackDraw(int i, ParticleType type) -{ - GetLogger()->Trace("CParticle::TrackDraw() stub!\n"); - // TODO! -} - - -} // namespace Gfx - diff --git a/src/ui/test/stubs/restext_stub.cpp b/src/ui/test/stubs/restext_stub.cpp deleted file mode 100644 index c1986ca..0000000 --- a/src/ui/test/stubs/restext_stub.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "../../common/restext.h" -bool GetResource(ResType /* type */, int /* num */, char* /* text */) -{ - return true; -} - -bool SearchKey(const char * /* cmd */, InputSlot & /* key */) -{ - return true; -} - diff --git a/src/ui/test/stubs/robotmain_stub.cpp b/src/ui/test/stubs/robotmain_stub.cpp deleted file mode 100644 index 93e0e82..0000000 --- a/src/ui/test/stubs/robotmain_stub.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "../../object/robotmain.h" - - -template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr; - -bool CRobotMain::GetGlint() -{ - return false; -} - -const InputBinding& CRobotMain::GetInputBinding(InputSlot slot) -{ - unsigned int index = static_cast<unsigned int>(slot); - assert(index >= 0 && index < INPUT_SLOT_MAX); - return m_inputBindings[index]; -} - 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 { |