From 10b2c562fb7635f9850f1441f08ba8b1a71e31e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Wed, 15 Aug 2012 01:48:49 +0200 Subject: First approach to port 2D UI Interface - changes in src/ui ; be CAREFUL, not every file is changed in a proper way -> bugs - necessary changes in object/robotmain.h and common/misc.h/.cpp in order to compile --- src/ui/control.h | 127 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 62 deletions(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index 0a12ff1..b211ff6 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -19,16 +19,18 @@ #pragma once -#include "old/text.h" +//#include "old/text.h" #include "common/struct.h" #include "common/event.h" - +#include "graphics/engine/engine.h" +#include "graphics/engine/text.h" +#include "graphics/engine/particle.h" class CInstanceManager; class CEvent; -class CD3DEngine; +//class Gfx::CEngine; class CRobotMain; -class CParticule; +//class Gfx::CParticle; class CSound; @@ -61,39 +63,39 @@ public: CControl(CInstanceManager* iMan); virtual ~CControl(); - virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - - virtual bool EventProcess(const Event &event); - - virtual void SetPos(Math::Point pos); - virtual Math::Point RetPos(); - virtual void SetDim(Math::Point dim); - virtual Math::Point RetDim(); - virtual bool SetState(int state, bool bState); - virtual bool SetState(int state); - virtual bool ClearState(int state); - virtual bool TestState(int state); - virtual int RetState(); - virtual void SetIcon(int icon); - virtual int RetIcon(); - virtual void SetName(char* name, bool bTooltip=true); - virtual char* RetName(); - virtual void SetJustif(int mode); - virtual int RetJustif(); - virtual void SetFontSize(float size); - virtual float RetFontSize(); - virtual void SetFontStretch(float stretch); - virtual float RetFontStretch(); - virtual void SetFontType(FontType font); - virtual FontType RetFontType(); - virtual bool SetTooltip(char* name); - virtual bool GetTooltip(Math::Point pos, char* name); - virtual void SetFocus(bool bFocus); - virtual bool RetFocus(); - - virtual EventMsg RetEventMsg(); - - virtual void Draw(); + 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(char* name, bool bTooltip=true); + virtual char* 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(char* name); + virtual bool GetTooltip(Math::Point pos, char* name); + virtual void SetFocus(bool bFocus); + virtual bool GetFocus(); + + virtual EventType GetEventType(); + + virtual void Draw(); protected: void GlintDelete(); @@ -108,31 +110,32 @@ protected: protected: CInstanceManager* m_iMan; - CD3DEngine* m_engine; - CEvent* m_event; - CRobotMain* m_main; - CParticule* m_particule; - CSound* m_sound; - - Math::Point m_pos; // corner upper / left - Math::Point m_dim; // dimensions - int m_icon; - EventMsg m_eventMsg; // 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 - FontType m_fontType; // type of font - int m_justif; // type of justification (-1,0,1) - char m_name[100]; // name of the button - char m_tooltip[100]; // 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; + Gfx::CEngine* m_engine; + CEventQueue* m_event; + CRobotMain* m_main; + Gfx::CParticle* m_particle; + CSound* 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) + char m_name[100]; // name of the button + char m_tooltip[100]; // 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; }; -- cgit v1.2.3-1-g7c22 From c2464d4c71bbc0154287f0b0441aef05e27cf084 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 17 Aug 2012 22:43:07 +0200 Subject: * changes to ui classes --- src/ui/control.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index b211ff6..ef49b65 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -26,12 +26,14 @@ #include "graphics/engine/text.h" #include "graphics/engine/particle.h" +#include "sound/sound.h" + class CInstanceManager; class CEvent; //class Gfx::CEngine; class CRobotMain; //class Gfx::CParticle; -class CSound; +//class CSound; enum ControlState @@ -60,7 +62,7 @@ enum ControlState class CControl { public: - CControl(CInstanceManager* iMan); + CControl(); virtual ~CControl(); virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); @@ -78,8 +80,8 @@ public: virtual int GetState(); virtual void SetIcon(int icon); virtual int GetIcon(); - virtual void SetName(char* name, bool bTooltip=true); - virtual char* GetName(); + virtual void SetName(const char* name, bool bTooltip=true); + virtual const char* GetName(); virtual void SetTextAlign(Gfx::TextAlign mode); virtual int GetTextAlign(); virtual void SetFontSize(float size); @@ -88,8 +90,8 @@ public: virtual float GetFontStretch(); virtual void SetFontType(Gfx::FontType font); virtual Gfx::FontType GetFontType(); - virtual bool SetTooltip(char* name); - virtual bool GetTooltip(Math::Point pos, char* name); + virtual bool SetTooltip(const char* name); + virtual bool GetTooltip(Math::Point pos, const char* name); virtual void SetFocus(bool bFocus); virtual bool GetFocus(); -- cgit v1.2.3-1-g7c22 From ea6269c4110282a3e7c05bec9c7f17ffd1bd5191 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 17 Aug 2012 23:03:52 +0200 Subject: * ui/key.cpp compiles * csoundinterface to ccontrol --- src/ui/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index ef49b65..d336ede 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -116,7 +116,7 @@ protected: CEventQueue* m_event; CRobotMain* m_main; Gfx::CParticle* m_particle; - CSound* m_sound; + CSoundInterface* m_sound; Math::Point m_pos; // corner upper / left Math::Point m_dim; // dimensions -- cgit v1.2.3-1-g7c22 From 48ad79a03c12b923dfdb3795a2138445859cf779 Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 18 Aug 2012 11:30:29 +0200 Subject: * minor changes to control.cpp to compile it without errors --- src/ui/control.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index d336ede..dcae4f2 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -20,18 +20,18 @@ //#include "old/text.h" -#include "common/struct.h" -#include "common/event.h" -#include "graphics/engine/engine.h" -#include "graphics/engine/text.h" -#include "graphics/engine/particle.h" +#include +#include -#include "sound/sound.h" +#include +#include +#include -class CInstanceManager; -class CEvent; +#include + +// class CEvent; //class Gfx::CEngine; -class CRobotMain; +// class CRobotMain; //class Gfx::CParticle; //class CSound; @@ -80,8 +80,8 @@ public: virtual int GetState(); virtual void SetIcon(int icon); virtual int GetIcon(); - virtual void SetName(const char* name, bool bTooltip=true); - virtual const char* GetName(); + virtual void SetName(char* name, bool bTooltip=true); + virtual char* GetName(); virtual void SetTextAlign(Gfx::TextAlign mode); virtual int GetTextAlign(); virtual void SetFontSize(float size); @@ -90,8 +90,8 @@ public: virtual float GetFontStretch(); virtual void SetFontType(Gfx::FontType font); virtual Gfx::FontType GetFontType(); - virtual bool SetTooltip(const char* name); - virtual bool GetTooltip(Math::Point pos, const char* name); + virtual bool SetTooltip(char* name); + virtual bool GetTooltip(Math::Point pos, char* name); virtual void SetFocus(bool bFocus); virtual bool GetFocus(); -- cgit v1.2.3-1-g7c22 From 574c07e388dfd902b6565bc4a5ac9b915c73074e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Sat, 18 Aug 2012 22:56:42 +0200 Subject: Further improvements in UI porting --- src/ui/control.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index b211ff6..95d01f6 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -20,20 +20,23 @@ //#include "old/text.h" -#include "common/struct.h" -#include "common/event.h" -#include "graphics/engine/engine.h" #include "graphics/engine/text.h" -#include "graphics/engine/particle.h" +//#include "common/struct.h" +#include "common/event.h" + +namespace Gfx { +class CEngine; +class CParticle; +}; class CInstanceManager; class CEvent; //class Gfx::CEngine; class CRobotMain; //class Gfx::CParticle; -class CSound; - +class CSoundInterface; +namespace Ui { enum ControlState { STATE_ENABLE = (1<<0), // active @@ -60,7 +63,8 @@ enum ControlState class CControl { public: - CControl(CInstanceManager* iMan); +// CControl(CInstanceManager* iMan); + CControl (); virtual ~CControl(); virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); @@ -114,7 +118,7 @@ protected: CEventQueue* m_event; CRobotMain* m_main; Gfx::CParticle* m_particle; - CSound* m_sound; + CSoundInterface* m_sound; Math::Point m_pos; // corner upper / left Math::Point m_dim; // dimensions @@ -139,3 +143,4 @@ protected: }; +} -- cgit v1.2.3-1-g7c22 From 75a76e82529f9726772bff066748e764f88c6d85 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 21 Aug 2012 20:53:39 +0200 Subject: latest changes --- src/ui/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index dcae4f2..ca57207 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -80,7 +80,7 @@ public: virtual int GetState(); virtual void SetIcon(int icon); virtual int GetIcon(); - virtual void SetName(char* name, bool bTooltip=true); + virtual void SetName(const char* name, bool bTooltip=true); virtual char* GetName(); virtual void SetTextAlign(Gfx::TextAlign mode); virtual int GetTextAlign(); -- cgit v1.2.3-1-g7c22 From 6ba0f42f22a170625f15879e01b4653a4ac153a1 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 31 Aug 2012 22:28:07 +0200 Subject: latest changes; few more classes should compile now --- src/ui/control.h | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index 13cf998..b16a324 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -1,5 +1,6 @@ // * This file is part of the COLOBOT source code // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * Copyright (C) 2012 Polish Portal of Colobot (PPC) // * // * This program is free software: you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by @@ -18,25 +19,28 @@ #pragma once +#include -//#include "old/text.h" -#include "graphics/engine/text.h" -//#include "common/struct.h" -#include "common/event.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include -namespace Gfx { -class CEngine; -class CParticle; -}; -class CInstanceManager; -class CEvent; -//class Gfx::CEngine; -class CRobotMain; -//class Gfx::CParticle; -class CSoundInterface; namespace Ui { + + enum ControlState { STATE_ENABLE = (1<<0), // active @@ -82,8 +86,8 @@ public: virtual int GetState(); virtual void SetIcon(int icon); virtual int GetIcon(); - virtual void SetName(const char* name, bool bTooltip=true); - virtual char* GetName(); + 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); @@ -92,8 +96,8 @@ public: virtual float GetFontStretch(); virtual void SetFontType(Gfx::FontType font); virtual Gfx::FontType GetFontType(); - virtual bool SetTooltip(char* name); - virtual bool GetTooltip(Math::Point pos, char* name); + virtual bool SetTooltip(std::string name); + virtual bool GetTooltip(Math::Point pos, std::string &name); virtual void SetFocus(bool bFocus); virtual bool GetFocus(); @@ -130,8 +134,8 @@ protected: 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) - char m_name[100]; // name of the button - char m_tooltip[100]; // name of tooltip + std::string m_name; // name of the button + std::string m_tooltip; // name of tooltip bool m_bFocus; bool m_bCapture; -- cgit v1.2.3-1-g7c22 From 01cc0fbc49696a19a56dfdd8359d4bb77e868925 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 11 Sep 2012 12:49:41 +0200 Subject: * latest changes * all files except studio, map and maindialog should compile * did some code cleanup --- src/ui/control.h | 222 +++++++++++++++++++++++++++---------------------------- 1 file changed, 110 insertions(+), 112 deletions(-) (limited to 'src/ui/control.h') diff --git a/src/ui/control.h b/src/ui/control.h index b16a324..48c3ef9 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -21,17 +21,17 @@ #include +#include +#include +#include +#include +#include + #include #include #include #include -#include -#include -#include -#include -#include - #include #include @@ -40,111 +40,109 @@ 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(CInstanceManager* iMan); - 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; - CEventQueue* m_event; - CRobotMain* m_main; - Gfx::CParticle* m_particle; - 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(CInstanceManager* iMan); + 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; + CEventQueue* m_event; + CRobotMain* m_main; + Gfx::CParticle* m_particle; + 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; + }; } -- cgit v1.2.3-1-g7c22