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/button.h | 2 +- src/ui/check.h | 2 +- src/ui/color.h | 2 +- src/ui/compass.h | 2 +- src/ui/control.h | 14 +- src/ui/displayinfo.h | 2 +- src/ui/displaytext.h | 2 +- src/ui/edit.h | 19 +- src/ui/editvalue.h | 5 +- src/ui/gauge.h | 2 +- src/ui/group.h | 2 +- src/ui/image.h | 7 +- src/ui/interface.cpp | 550 +++++++++++++-------------------------------------- src/ui/interface.h | 135 +++++++------ src/ui/key.cpp | 179 ++++++----------- src/ui/key.h | 37 ++-- src/ui/label.cpp | 51 ++--- src/ui/label.h | 24 +-- src/ui/list.h | 118 ++++++----- src/ui/map.h | 14 +- src/ui/scroll.h | 71 ++++--- src/ui/shortcut.h | 27 ++- src/ui/slider.h | 75 ++++--- src/ui/target.h | 27 ++- src/ui/window.h | 73 +++---- 25 files changed, 541 insertions(+), 901 deletions(-) (limited to 'src/ui') diff --git a/src/ui/button.h b/src/ui/button.h index 38b2dab..4f1740d 100644 --- a/src/ui/button.h +++ b/src/ui/button.h @@ -29,7 +29,7 @@ class CButton : public CControl { public: - CButton(CInstanceManager* iMan); + CButton(); virtual ~CButton(); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); diff --git a/src/ui/check.h b/src/ui/check.h index 3af6849..66375c0 100644 --- a/src/ui/check.h +++ b/src/ui/check.h @@ -29,7 +29,7 @@ class CD3DEngine; class CCheck : public CControl { public: - CCheck(CInstanceManager* iMan); + CCheck(); virtual ~CCheck(); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); diff --git a/src/ui/color.h b/src/ui/color.h index 151a4df..740b7e9 100644 --- a/src/ui/color.h +++ b/src/ui/color.h @@ -30,7 +30,7 @@ class CColor : public CControl { public: - CColor(CInstanceManager* iMan); + CColor(); virtual ~CColor(); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); diff --git a/src/ui/compass.h b/src/ui/compass.h index ac5f608..fcbf860 100644 --- a/src/ui/compass.h +++ b/src/ui/compass.h @@ -29,7 +29,7 @@ class CCompass : public CControl { public: - CCompass(CInstanceManager* iMan); + CCompass(); virtual ~CCompass(); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); 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(); diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h index 29677d4..dbc9bed 100644 --- a/src/ui/displayinfo.h +++ b/src/ui/displayinfo.h @@ -37,7 +37,7 @@ class CLight; class CDisplayInfo { public: - CDisplayInfo(CInstanceManager* iMan); + CDisplayInfo(); ~CDisplayInfo(); bool EventProcess(const Event &event); diff --git a/src/ui/displaytext.h b/src/ui/displaytext.h index c2eea98..93a3c8b 100644 --- a/src/ui/displaytext.h +++ b/src/ui/displaytext.h @@ -45,7 +45,7 @@ const int MAXDTLINE = 4; class CDisplayText { public: - CDisplayText(CInstanceManager* iMan); + CDisplayText(); ~CDisplayText(); void DeleteObject(); diff --git a/src/ui/edit.h b/src/ui/edit.h index dbd94d1..73bd062 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -19,14 +19,11 @@ #pragma once -#include "common/struct.h" -#include "ui/control.h" - - -class CD3DEngine; -class CScroll; - +#include +#include +#include +#include const int EDITSTUDIOMAX = 20000; // maximum number of characters in CBOT edit const int EDITLINEMAX = 1000; // maximum total number of lines @@ -85,10 +82,10 @@ struct HyperHistory class CEdit : public CControl { public: - CEdit(CInstanceManager* iMan); + CEdit(); virtual ~CEdit(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); void SetPos(Math::Point pos); void SetDim(Math::Point dim); @@ -145,8 +142,8 @@ public: void HyperFlush(); void HyperHome(char *filename); - bool HyperTest(EventMsg event); - bool HyperGo(EventMsg event); + bool HyperTest(EventType event); + bool HyperGo(EventType event); void SetFontSize(float size); diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h index dbb7812..758450a 100644 --- a/src/ui/editvalue.h +++ b/src/ui/editvalue.h @@ -21,6 +21,7 @@ #include "ui/control.h" +#include "common/event.h" enum EditValueType { @@ -39,10 +40,10 @@ class CButton; class CEditValue : public CControl { public: - CEditValue(CInstanceManager* iMan); + CEditValue(); virtual ~CEditValue(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); void SetPos(Math::Point pos); void SetDim(Math::Point dim); diff --git a/src/ui/gauge.h b/src/ui/gauge.h index 1686c56..26ce8e9 100644 --- a/src/ui/gauge.h +++ b/src/ui/gauge.h @@ -29,7 +29,7 @@ class CGauge : public CControl { public: - CGauge(CInstanceManager* iMan); + CGauge(); virtual ~CGauge(); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); diff --git a/src/ui/group.h b/src/ui/group.h index b54829d..12c4003 100644 --- a/src/ui/group.h +++ b/src/ui/group.h @@ -29,7 +29,7 @@ class CD3DEngine; class CGroup : public CControl { public: - CGroup(CInstanceManager* iMan); + CGroup(); virtual ~CGroup(); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); diff --git a/src/ui/image.h b/src/ui/image.h index 85c5962..b6b88c3 100644 --- a/src/ui/image.h +++ b/src/ui/image.h @@ -19,8 +19,9 @@ #pragma once -#include "ui/control.h" +#include +#include class CD3DEngine; @@ -29,10 +30,10 @@ class CD3DEngine; class CImage : public CControl { public: - CImage(CInstanceManager* iMan); + CImage(); virtual ~CImage(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); bool EventProcess(const Event &event); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 50d2352..afedfc9 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -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 @@ -17,55 +18,19 @@ // interface.cpp -#include -#include -#include - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/math3d.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/iman.h" -#include "ui/control.h" -#include "ui/button.h" -#include "ui/color.h" -#include "ui/check.h" -#include "ui/key.h" -#include "ui/group.h" -#include "ui/image.h" -#include "ui/label.h" -#include "ui/edit.h" -#include "ui/editvalue.h" -#include "ui/scroll.h" -#include "ui/slider.h" -#include "ui/list.h" -#include "ui/shortcut.h" -#include "ui/compass.h" -#include "ui/target.h" -#include "ui/map.h" -#include "ui/window.h" -#include "old/camera.h" -#include "ui/interface.h" - - - - -// Object's constructor. - -CInterface::CInterface(CInstanceManager* iMan) -{ - int i; +#include - m_iMan = iMan; - m_iMan->AddInstance(CLASS_INTERFACE, this); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_camera = 0; +CInterface::CInterface() +{ + m_iMan = CInstanceManager::GetInstancePointer(); + m_iMan->AddInstance(CLASS_INTERFACE, this); + m_event = static_cast( m_iMan->SearchInstance(CLASS_EVENT) ); + m_engine = static_cast( m_iMan->SearchInstance(CLASS_ENGINE) ); - for ( i=0 ; iDeleteInstance(CLASS_INTERFACE, this); } @@ -81,424 +47,222 @@ CInterface::~CInterface() void CInterface::Flush() { - int i; - - for ( i=0 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } + for (int i = 10; i < MAXCONTROL-1; i++) { + if (m_table[i] == nullptr) + return i; } - return 0; + return -1; } -// Creates a new button. -CButton* CInterface::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +template inline T* CInterface::CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CButton* pc; - int i; + T* pc; + int index; + Event event; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } + if (eventMsg == EVENT_NULL) { + m_event->GetEvent(event); + eventMsg = event.type; } - return 0; + + if ((index = GetNextFreeControl()) < 0) + return nullptr; + + m_table[index] = new T(); + pc = static_cast(m_table[index]); + pc->Create(pos, dim, icon, eventMsg); + return pc; } + // Creates a new button. -CColor* CInterface::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CColor* pc; - int i; + CWindow* pc; + int index; + Event event; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if (eventMsg == EVENT_NULL) { + m_event->GetEvent(event); + eventMsg = event.type; + } - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } + switch (eventMsg) { + case EVENT_WINDOW0: index = 0; break; + case EVENT_WINDOW1: index = 1; break; + case EVENT_WINDOW2: index = 2; break; + case EVENT_WINDOW3: index = 3; break; + case EVENT_WINDOW4: index = 4; break; + case EVENT_WINDOW5: index = 5; break; + case EVENT_WINDOW6: index = 6; break; + case EVENT_WINDOW7: index = 7; break; + case EVENT_WINDOW8: index = 8; break; + case EVENT_WINDOW9: index = 9; break; + case EVENT_TOOLTIP: index = MAXCONTROL-1; break; + default: index = GetNextFreeControl(); break; } - return 0; + + if (index < 0) + return nullptr; + + m_table[index] = new CWindow(); + pc = static_cast(m_table[index]); + pc->Create(pos, dim, icon, eventMsg); + return pc; } // Creates a new button. -CCheck* CInterface::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CButton* CInterface::CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CCheck* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new button. -CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CColor* CInterface::CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CKey* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new button. -CGroup* CInterface::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CCheck* CInterface::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CGroup* pc; - int i; + return CreateControl(pos, dim, icon, eventMsg); +} - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); +// Creates a new button. - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; +CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) +{ + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new button. -CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CGroup* CInterface::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CImage* pc; - int i; + return CreateControl(pos, dim, icon, eventMsg); +} - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); +// Creates a new button. - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; +CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) +{ + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new label. -CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, - char *name) +CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, const char *name) { - CLabel* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - pc->SetName(name); - return pc; - } - } - return 0; + CLabel* pc = CreateControl(pos, dim, icon, eventMsg); + if (pc != nullptr) + pc->SetName(name); + return pc; } // Creates a new pave editable. -CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CEdit* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new pave editable. -CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CEditValue* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new lift. -CScroll* CInterface::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CScroll* CInterface::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CScroll* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new cursor. -CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CSlider* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new list. -CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, - float expand) +CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { - CList* pc; - int i; + CList* pc; + int index; + Event event; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg, expand); - return pc; - } + if (eventMsg == EVENT_NULL) { + m_event->GetEvent(event); + eventMsg = event.type; } - return 0; + + if ((index = GetNextFreeControl()) < 0) + return nullptr; + + m_table[index] = new CList(); + pc = static_cast(m_table[index]); + pc->Create(pos, dim, icon, eventMsg, expand); + return pc; } // Creates a new shortcut. -CShortcut* CInterface::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CShortcut* CInterface::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CShortcut* ps; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return ps; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new compass. -CCompass* CInterface::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CCompass* CInterface::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CCompass* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new target. -CTarget* CInterface::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CTarget* CInterface::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CTarget* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Creates a new map. -CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CMap* pm; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; iCreate(pos, dim, icon, eventMsg); - return pm; - } - } - return 0; + return CreateControl(pos, dim, icon, eventMsg); } // Removes a control. -bool CInterface::DeleteControl(EventMsg eventMsg) +bool CInterface::DeleteControl(EventType eventMsg) { - int i; - - for ( i=0 ; iRetEventMsg() ) - { + for (int i = 0; i < MAXCONTROL; i++) { + if ( m_table[i] != nullptr ) { + if (eventMsg == m_table[i]->GetEventType()) { delete m_table[i]; - m_table[i] = 0; + m_table[i] = nullptr; return true; } } @@ -508,47 +272,32 @@ bool CInterface::DeleteControl(EventMsg eventMsg) // Gives a control. -CControl* CInterface::SearchControl(EventMsg eventMsg) +CControl* CInterface::SearchControl(EventType eventMsg) { - int i; - - for ( i=0 ; iRetEventMsg() ) - { + for (int i = 0; i < MAXCONTROL; i++) { + if (m_table[i] != nullptr) { + if (eventMsg == m_table[i]->GetEventType()) return m_table[i]; - } } } - return 0; + return nullptr; } // Management of an event. bool CInterface::EventProcess(const Event &event) { - int i; - - if ( event.event == EVENT_MOUSEMOVE ) - { - if ( m_camera == 0 ) - { - m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); + if (event.type == EVENT_MOUSE_MOVE) { + if (m_camera == nullptr) { + m_camera = static_cast(m_iMan->SearchInstance(CLASS_CAMERA)); } - m_engine->SetMouseType(m_camera->RetMouseDef(event.pos)); + m_engine->SetMouseType(m_camera->GetMouseDef(event.pos)); } - for ( i=MAXCONTROL-1 ; i>=0 ; i-- ) - { - if ( m_table[i] != 0 && - 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; - } } } @@ -558,18 +307,12 @@ bool CInterface::EventProcess(const Event &event) // Gives the tooltip binding to the window. -bool CInterface::GetTooltip(Math::Point pos, char* name) +bool CInterface::GetTooltip(Math::Point pos, const char* name) { - int i; - - for ( i=MAXCONTROL-1 ; i>=0 ; i-- ) - { - if ( m_table[i] != 0 ) - { - if ( m_table[i]->GetTooltip(pos, name) ) - { + for (int i = MAXCONTROL-1; i >= 0; i--) { + if (m_table[i] != nullptr) { + if (m_table[i]->GetTooltip(pos, name)) return true; - } } } return false; @@ -580,26 +323,17 @@ bool CInterface::GetTooltip(Math::Point pos, char* name) void CInterface::Draw() { - D3DMATERIAL7 material; - int i; - - ZeroMemory( &material, sizeof(D3DMATERIAL7) ); + /*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); + m_engine->SetMaterial(material);*/ - for ( i=0 ; i=0 ; i-- ) - { - if ( m_table[i] != 0 ) - { + 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 8aa7f44..d8f4d62 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.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 @@ -19,32 +20,34 @@ #pragma once -#include "common/event.h" -#include "math/point.h" - - -class CInstanceManager; -class CD3DEngine; -class CControl; -class CWindow; -class CButton; -class CColor; -class CCheck; -class CKey; -class CGroup; -class CImage; -class CLabel; -class CEdit; -class CEditValue; -class CScroll; -class CSlider; -class CList; -class CShortcut; -class CMap; -class CGauge; -class CCompass; -class CTarget; -class CCamera; +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include const int MAXCONTROL = 100; @@ -52,44 +55,48 @@ const int MAXCONTROL = 100; class CInterface { -public: - CInterface(CInstanceManager* iMan); - ~CInterface(); - - bool EventProcess(const Event &event); - bool GetTooltip(Math::Point pos, char* name); - - void Flush(); - CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name); - CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f); - CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - bool DeleteControl(EventMsg eventMsg); - CControl* SearchControl(EventMsg eventMsg); - - void Draw(); - -protected: - -protected: - CInstanceManager* m_iMan; - CD3DEngine* m_engine; - CCamera* m_camera; - - CControl* m_table[MAXCONTROL]; + public: + CInterface(); + ~CInterface(); + + bool EventProcess(const Event &event); + bool GetTooltip(Math::Point pos, const char* name); + + void Flush(); + CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + + CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f); + CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, const char *name); + + bool DeleteControl(EventType eventMsg); + CControl* SearchControl(EventType eventMsg); + + void Draw(); + + protected: + int GetNextFreeControl(); + template 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; + + CControl* m_table[MAXCONTROL]; }; diff --git a/src/ui/key.cpp b/src/ui/key.cpp index a1eebb3..0d73ed0 100644 --- a/src/ui/key.cpp +++ b/src/ui/key.cpp @@ -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 @@ -17,54 +18,32 @@ // key.cpp -#include -#include -#include +#include -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/math3d.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/iman.h" -#include "common/restext.h" -#include "old/sound.h" -#include "old/text.h" -#include "ui/key.h" - - - - -// Constructs the name of a button. void GetKeyName(char *name, int key) { - if ( !GetResource(RES_KEY, key, name) ) - { - if ( (key >= '0' && key <= '9') || - (key >= 'A' && key <= 'Z') || - (key >= 'a' && key <= 'z') ) - { + if ( !GetResource(RES_KEY, key, name) ) { + if (isalnum(key)) { name[0] = key; name[1] = 0; } - else - { + else { sprintf(name, "Code %d", key); } } } - - // Object's constructor. -CKey::CKey(CInstanceManager* iMan) : CControl(iMan) +CKey::CKey() : CControl() { m_key[0] = 0; m_key[1] = 0; m_bCatch = false; + + m_app = CApplication::GetInstancePointer(); } // Object's destructor. @@ -76,18 +55,18 @@ CKey::~CKey() // Creates a new button. -bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - char name[100]; - char* p; + char name[100]; + Event event; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if (eventMsg == EVENT_NULL) { + m_event->GetEvent(event); + eventMsg = event.type; + } CControl::Create(pos, dim, icon, eventMsg); - GetResource(RES_EVENT, eventMsg, name); - p = strchr(name, '\\'); - if ( p != 0 ) *p = 0; SetName(name); return true; @@ -98,24 +77,17 @@ bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CKey::EventProcess(const Event &event) { - if ( m_state & STATE_DEAD ) return true; + if (m_state & STATE_DEAD) + return true; CControl::EventProcess(event); - if ( event.event == EVENT_LBUTTONDOWN ) - { - if ( Detect(event.pos) ) - { - m_bCatch = true; - } - else - { - m_bCatch = false; - } + if (event.type == EVENT_MOUSE_BUTTON_DOWN) { + if (event.mouseButton.button == 1) // left + m_bCatch = Detect(event.pos); } - if ( event.event == EVENT_KEYDOWN && m_bCatch ) - { + if (event.type == EVENT_MOUSE_BUTTON_DOWN && m_bCatch) { m_bCatch = false; if ( TestKey(event.param) ) // impossible ? @@ -124,21 +96,17 @@ bool CKey::EventProcess(const Event &event) } else { - if ( event.param == m_key[0] || - event.param == m_key[1] ) - { + if ( event.param == m_key[0] || event.param == m_key[1] ) { m_key[0] = event.param; m_key[1] = 0; - } - else - { + } else { m_key[1] = m_key[0]; m_key[0] = event.param; } m_sound->Play(SOUND_CLICK); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } return false; @@ -152,25 +120,17 @@ bool CKey::EventProcess(const Event &event) bool CKey::TestKey(int key) { - int i, j; + if ( key == VK_PAUSE || key == VK_SNAPSHOT ) return true; // blocked key - if ( key == VK_PAUSE || - key == VK_SNAPSHOT ) return true; // blocked key - - for ( i=0 ; i<20 ; i++ ) - { - for ( j=0 ; j<2 ; j++ ) - { - if ( key == m_engine->RetKey(i, j) ) // key used? - { - m_engine->SetKey(i, j, 0); // nothing! - } + for (int i = 0; i < 20; i++) { + for (int j = 0; j < 2; j++) { + if (key == m_app->GetKey(i, j) ) // key used? + m_app->SetKey(i, j, 0); // nothing! } - if ( m_engine->RetKey(i, 0) == 0 ) // first free option? - { - m_engine->SetKey(i, 0, m_engine->RetKey(i, 1)); // shift - m_engine->SetKey(i, 1, 0); + if ( m_app->GetKey(i, 0) == 0 ) { // first free option? + m_app->SetKey(i, 0, m_app->GetKey(i, 1)); // shift + m_app->SetKey(i, 1, 0); } } @@ -182,106 +142,97 @@ bool CKey::TestKey(int key) void CKey::Draw() { - Math::Point iDim, pos; - float zoomExt, zoomInt, h; - int icon; - char text[100]; + Math::Point iDim, pos; + float zoomExt, zoomInt, h; + int icon; + char text[100]; - if ( (m_state & STATE_VISIBLE) == 0 ) return; + if ( (m_state & STATE_VISIBLE) == 0 ) + return; iDim = m_dim; m_dim.x = 200.0f/640.0f; if ( m_state & STATE_SHADOW ) - { DrawShadow(m_pos, m_dim); - } + m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL zoomExt = 1.00f; zoomInt = 0.95f; icon = 2; - if ( m_key[0] == 0 && - m_key[1] == 0 ) // no shortcut? - { + if ( m_key[0] == 0 && m_key[1] == 0 ) // no shortcut? icon = 3; - } - if ( m_state & STATE_DEFAULT ) - { + + if ( m_state & STATE_DEFAULT ) { DrawPart(23, 1.3f, 0.0f); zoomExt *= 1.15f; zoomInt *= 1.15f; } + if ( m_state & STATE_HILIGHT ) - { icon = 1; - } + if ( m_state & STATE_CHECK ) - { icon = 0; - } - if ( m_state & STATE_PRESS ) - { + + if ( m_state & STATE_PRESS ) { icon = 3; zoomInt *= 0.9f; } + if ( (m_state & STATE_ENABLE) == 0 ) - { icon = 7; - } + if ( m_state & STATE_DEAD ) - { icon = 17; - } + if ( m_bCatch ) - { icon = 23; - } - DrawPart(icon, zoomExt, 8.0f/256.0f); // draws the button - h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; + DrawPart(icon, zoomExt, 8.0f / 256.0f); // draws the button + + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; GetKeyName(text, m_key[0]); - if ( m_key[1] != 0 ) - { + if ( m_key[1] != 0 ) { GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text)); GetKeyName(text+strlen(text), m_key[1]); } - pos.x = m_pos.x+m_dim.x*0.5f; - pos.y = m_pos.y+m_dim.y*0.5f; + pos.x = m_pos.x + m_dim.x * 0.5f; + pos.y = m_pos.y + m_dim.y * 0.5f; pos.y -= h; - m_engine->RetText()->DrawText(text, pos, m_dim.x, 0, m_fontSize, m_fontStretch, m_fontType, 0); + m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_CENTER, 0); m_dim = iDim; - if ( m_state & STATE_DEAD ) return; + if ( m_state & STATE_DEAD ) + return; // Draws the name. - pos.x = m_pos.x+(214.0f/640.0f); - pos.y = m_pos.y+m_dim.y*0.5f; + pos.x = m_pos.x + (214.0f / 640.0f); + pos.y = m_pos.y + m_dim.y * 0.5f; pos.y -= h; - m_engine->RetText()->DrawText(m_name, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); + m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, 0); } void CKey::SetKey(int option, int key) { - if ( option < 0 || - option > 1 ) return; + if ( option < 0 || option > 1 ) return; m_key[option] = key; } -int CKey::RetKey(int option) +int CKey::GetKey(int option) { - if ( option < 0 || - option > 1 ) return 0; + if ( option < 0 || option > 1 ) return 0; return m_key[option]; } diff --git a/src/ui/key.h b/src/ui/key.h index 314f39b..db7d856 100644 --- a/src/ui/key.h +++ b/src/ui/key.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,35 +19,39 @@ #pragma once +#include +#include -#include "ui/control.h" +#include +#include +#include +#include -class CD3DEngine; - +#include class CKey : public CControl { -public: - CKey(CInstanceManager* iMan); - virtual ~CKey(); + public: + CKey(); + virtual ~CKey(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool EventProcess(const Event &event); - bool EventProcess(const Event &event); + void Draw(); - void Draw(); + void SetKey(int option, int key); + int GetKey(int option); - void SetKey(int option, int key); - int RetKey(int option); + protected: + bool TestKey(int key); -protected: - bool TestKey(int key); + int m_key[2]; + bool m_bCatch; -protected: - int m_key[2]; - bool m_bCatch; + CApplication *m_app; }; diff --git a/src/ui/label.cpp b/src/ui/label.cpp index cd96493..261f3fc 100644 --- a/src/ui/label.cpp +++ b/src/ui/label.cpp @@ -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 @@ -17,25 +18,12 @@ // label.cpp -#include -#include -#include - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/math3d.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/iman.h" -#include "old/text.h" -#include "ui/label.h" - - +#include // Object's constructor. -CLabel::CLabel(CInstanceManager* iMan) : CControl(iMan) +CLabel::CLabel() : CControl() { } @@ -48,9 +36,14 @@ CLabel::~CLabel() // Creates a new button. -bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + Event event; + + if (eventMsg == EVENT_NULL) { + m_event->GetEvent(event); + eventMsg = event.type; + } CControl::Create(pos, dim, icon, eventMsg); return true; @@ -72,22 +65,16 @@ void CLabel::Draw() { Math::Point pos; - if ( (m_state & STATE_VISIBLE) == 0 ) return; + if ( (m_state & STATE_VISIBLE) == 0 ) + return; - pos.y = m_pos.y+m_dim.y/2.0f; + pos.y = m_pos.y + m_dim.y / 2.0f; - if ( m_justif > 0 ) - { - pos.x = m_pos.x; + switch (m_justif) { + case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x; break; + case Gfx::TEXT_ALIGN_CENTER: pos.x = m_pos.x + m_dim.x / 2.0f; break; + case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x + m_dim.x; break; } - if ( m_justif == 0 ) - { - pos.x = m_pos.x+m_dim.x/2.0f; - } - if ( m_justif < 0 ) - { - pos.x = m_pos.x+m_dim.x; - } - m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0); -} + m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, m_justif, 0); +} diff --git a/src/ui/label.h b/src/ui/label.h index d3cb915..f65e1dd 100644 --- a/src/ui/label.h +++ b/src/ui/label.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 @@ -19,28 +20,21 @@ #pragma once -#include "ui/control.h" - - -class CD3DEngine; +#include +#include class CLabel : public CControl { -public: - CLabel(CInstanceManager* iMan); - virtual ~CLabel(); - - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - - bool EventProcess(const Event &event); - - void Draw(); + public: + CLabel(); + virtual ~CLabel(); -protected: + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool EventProcess(const Event &event); -protected: + void Draw(); }; diff --git a/src/ui/list.h b/src/ui/list.h index cc9e646..c7c278d 100644 --- a/src/ui/list.h +++ b/src/ui/list.h @@ -19,13 +19,9 @@ #pragma once -#include "ui/control.h" -#include "common/event.h" +#include - -class CD3DEngine; -class CButton; -class CScroll; +#include const int LISTMAXDISPLAY = 20; // maximum number of visible lines @@ -35,81 +31,81 @@ const int LISTMAXTOTAL = 100; // maximum total number of lines class CList : public CControl { -public: - CList(CInstanceManager* iMan); - ~CList(); + public: + CList(); + ~CList(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand); - void SetPos(Math::Point pos); - void SetDim(Math::Point dim); + void SetPos(Math::Point pos); + void SetDim(Math::Point dim); - bool SetState(int state, bool bState); - bool SetState(int state); - bool ClearState(int state); + bool SetState(int state, bool bState); + bool SetState(int state); + bool ClearState(int state); - bool EventProcess(const Event &event); - void Draw(); + bool EventProcess(const Event &event); + void Draw(); - void Flush(); + void Flush(); - void SetTotal(int i); - int RetTotal(); + void SetTotal(int i); + int RetTotal(); - void SetSelect(int i); - int RetSelect(); + void SetSelect(int i); + int RetSelect(); - void SetSelectCap(bool bEnable); - bool RetSelectCap(); + void SetSelectCap(bool bEnable); + bool RetSelectCap(); - void SetBlink(bool bEnable); - bool RetBlink(); + void SetBlink(bool bEnable); + bool RetBlink(); - void SetName(int i, char* name); - char* RetName(int i); + void SetName(int i, char* name); + char* RetName(int i); - void SetCheck(int i, bool bMode); - bool RetCheck(int i); + void SetCheck(int i, bool bMode); + bool RetCheck(int i); - void SetEnable(int i, bool bEnable); - bool RetEnable(int i); + void SetEnable(int i, bool bEnable); + bool RetEnable(int i); - void SetTabs(int i, float pos, int justif=1); - float RetTabs(int i); + void SetTabs(int i, float pos, int justif=1); + float RetTabs(int i); - void ShowSelect(bool bFixed); + void ShowSelect(bool bFixed); - EventMsg RetEventMsgButton(int i); - EventMsg RetEventMsgScroll(); + EventType RetEventMsgButton(int i); + EventType RetEventMsgScroll(); -protected: - bool MoveAdjust(); - void UpdateButton(); - void UpdateScroll(); - void MoveScroll(); - void DrawCase(char *text, Math::Point pos, float width, int justif); + protected: + bool MoveAdjust(); + void UpdateButton(); + void UpdateScroll(); + void MoveScroll(); + void DrawCase(char *text, Math::Point pos, float width, int justif); -protected: - CButton* m_button[LISTMAXDISPLAY]; - CScroll* m_scroll; + protected: + CButton* m_button[LISTMAXDISPLAY]; + CScroll* m_scroll; - EventMsg m_eventButton[LISTMAXDISPLAY]; - EventMsg m_eventScroll; + EventType m_eventButton[LISTMAXDISPLAY]; + EventType m_eventScroll; - float m_expand; - int m_totalLine; // total number of lines - int m_displayLine; // number of visible lines - int m_selectLine; // selected line - int m_firstLine; // first visible line - bool m_bBlink; - bool m_bSelectCap; - float m_blinkTime; - float m_tabs[10]; - int m_justifs[10]; + float m_expand; + int m_totalLine; // total number of lines + int m_displayLine; // number of visible lines + int m_selectLine; // selected line + int m_firstLine; // first visible line + bool m_bBlink; + bool m_bSelectCap; + float m_blinkTime; + float m_tabs[10]; + int m_justifs[10]; - char m_text[LISTMAXTOTAL][100]; - char m_check[LISTMAXTOTAL]; - char m_enable[LISTMAXTOTAL]; + char m_text[LISTMAXTOTAL][100]; + char m_check[LISTMAXTOTAL]; + char m_enable[LISTMAXTOTAL]; }; diff --git a/src/ui/map.h b/src/ui/map.h index efdf54b..693398c 100644 --- a/src/ui/map.h +++ b/src/ui/map.h @@ -19,16 +19,14 @@ #pragma once -#include "ui/control.h" -#include "object/object.h" +#include +#include + +#include -class CD3DEngine; class CTerrain; class CWater; -class CRobotMain; - - const int MAPMAXOBJECT = 100; @@ -62,10 +60,10 @@ struct MapObject class CMap : public CControl { public: - CMap(CInstanceManager* iMan); + CMap(); ~CMap(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); bool EventProcess(const Event &event); void Draw(); diff --git a/src/ui/scroll.h b/src/ui/scroll.h index 6854e61..a82fea0 100644 --- a/src/ui/scroll.h +++ b/src/ui/scroll.h @@ -19,12 +19,9 @@ #pragma once -#include "ui/control.h" - - -class CD3DEngine; -class CButton; +#include +#include const float SCROLL_WIDTH = (15.0f/640.0f); @@ -32,50 +29,50 @@ const float SCROLL_WIDTH = (15.0f/640.0f); class CScroll : public CControl { -public: - CScroll(CInstanceManager* iMan); - ~CScroll(); + public: + CScroll(); + ~CScroll(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - void SetPos(Math::Point pos); - void SetDim(Math::Point dim); + void SetPos(Math::Point pos); + void SetDim(Math::Point dim); - bool SetState(int state, bool bState); - bool SetState(int state); - bool ClearState(int state); + bool SetState(int state, bool bState); + bool SetState(int state); + bool ClearState(int state); - bool EventProcess(const Event &event); - void Draw(); + bool EventProcess(const Event &event); + void Draw(); - void SetVisibleValue(float value); - float RetVisibleValue(); + void SetVisibleValue(float value); + float RetVisibleValue(); - void SetVisibleRatio(float value); - float RetVisibleRatio(); + void SetVisibleRatio(float value); + float RetVisibleRatio(); - void SetArrowStep(float step); - float RetArrowStep(); + void SetArrowStep(float step); + float RetArrowStep(); -protected: - void MoveAdjust(); - void AdjustGlint(); - void DrawVertex(Math::Point pos, Math::Point dim, int icon); + protected: + void MoveAdjust(); + void AdjustGlint(); + void DrawVertex(Math::Point pos, Math::Point dim, int icon); -protected: - CButton* m_buttonUp; - CButton* m_buttonDown; + protected: + CButton* m_buttonUp; + CButton* m_buttonDown; - float m_visibleValue; - float m_visibleRatio; - float m_step; + float m_visibleValue; + float m_visibleRatio; + float m_step; - bool m_bCapture; - Math::Point m_pressPos; - float m_pressValue; + bool m_bCapture; + Math::Point m_pressPos; + float m_pressValue; - EventMsg m_eventUp; - EventMsg m_eventDown; + EventType m_eventUp; + EventType m_eventDown; }; diff --git a/src/ui/shortcut.h b/src/ui/shortcut.h index b918ccc..d819bf2 100644 --- a/src/ui/shortcut.h +++ b/src/ui/shortcut.h @@ -18,31 +18,28 @@ #pragma once +#include -#include "ui/control.h" - - -class CD3DEngine; - +#include class CShortcut : public CControl { -public: - CShortcut(CInstanceManager* iMan); - ~CShortcut(); + public: + CShortcut(); + ~CShortcut(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - bool EventProcess(const Event &event); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); -protected: - void DrawVertex(int icon, float zoom); + protected: + void DrawVertex(int icon, float zoom); -protected: - float m_time; + protected: + float m_time; }; diff --git a/src/ui/slider.h b/src/ui/slider.h index 1ec9ea5..e79b348 100644 --- a/src/ui/slider.h +++ b/src/ui/slider.h @@ -19,63 +19,60 @@ #pragma once -#include "ui/control.h" - - -class CD3DEngine; -class CButton; +#include +#include class CSlider : public CControl { -public: - CSlider(CInstanceManager* iMan); - ~CSlider(); + public: + CSlider(); + ~CSlider(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - void SetPos(Math::Point pos); - void SetDim(Math::Point dim); + void SetPos(Math::Point pos); + void SetDim(Math::Point dim); - bool SetState(int state, bool bState); - bool SetState(int state); - bool ClearState(int state); + bool SetState(int state, bool bState); + bool SetState(int state); + bool ClearState(int state); - bool EventProcess(const Event &event); - void Draw(); + bool EventProcess(const Event &event); + void Draw(); - void SetLimit(float min, float max); + void SetLimit(float min, float max); - void SetVisibleValue(float value); - float RetVisibleValue(); + void SetVisibleValue(float value); + float RetVisibleValue(); - void SetArrowStep(float step); - float RetArrowStep(); + void SetArrowStep(float step); + float RetArrowStep(); -protected: - void MoveAdjust(); - void AdjustGlint(); - void DrawVertex(Math::Point pos, Math::Point dim, int icon); + protected: + void MoveAdjust(); + void AdjustGlint(); + void DrawVertex(Math::Point pos, Math::Point dim, int icon); -protected: - CButton* m_buttonLeft; - CButton* m_buttonRight; + protected: + CButton* m_buttonLeft; + CButton* m_buttonRight; - float m_min; - float m_max; - float m_visibleValue; - float m_step; + float m_min; + float m_max; + float m_visibleValue; + float m_step; - bool m_bHoriz; - float m_marginButton; + bool m_bHoriz; + float m_marginButton; - bool m_bCapture; - Math::Point m_pressPos; - float m_pressValue; + bool m_bCapture; + Math::Point m_pressPos; + float m_pressValue; - EventMsg m_eventUp; - EventMsg m_eventDown; + EventType m_eventUp; + EventType m_eventDown; }; diff --git a/src/ui/target.h b/src/ui/target.h index ae0c7af..a2615b4 100644 --- a/src/ui/target.h +++ b/src/ui/target.h @@ -19,30 +19,25 @@ #pragma once -#include "ui/control.h" - - -class CD3DEngine; -class CObject; +#include +#include class CTarget : public CControl { -public: - CTarget(CInstanceManager* iMan); - ~CTarget(); - - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + public: + CTarget(); + ~CTarget(); - bool EventProcess(const Event &event); - void Draw(); - bool GetTooltip(Math::Point pos, char* name); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); -protected: - CObject* DetectFriendObject(Math::Point pos); + bool EventProcess(const Event &event); + void Draw(); + bool GetTooltip(Math::Point pos, char* name); -protected: + protected: + CObject* DetectFriendObject(Math::Point pos); }; diff --git a/src/ui/window.h b/src/ui/window.h index 3acf3b4..8884c6f 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -19,27 +19,8 @@ #pragma once -#include "ui/control.h" - - -class CD3DEngine; -class CButton; -class CColor; -class CCheck; -class CKey; -class CGroup; -class CImage; -class CLabel; -class CEdit; -class CEditValue; -class CScroll; -class CSlider; -class CList; -class CShortcut; -class CMap; -class CGauge; -class CCompass; -class CTarget; +#include +#include const int MAXWINDOW = 100; @@ -48,34 +29,34 @@ const int MAXWINDOW = 100; class CWindow : public CControl { public: - CWindow(CInstanceManager* iMan); + CWindow(); ~CWindow(); void Flush(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name); - CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f); - CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - bool DeleteControl(EventMsg eventMsg); - CControl* SearchControl(EventMsg eventMsg); - - EventMsg RetEventMsgReduce(); - EventMsg RetEventMsgFull(); - EventMsg RetEventMsgClose(); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, char *name); + CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f); + CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool DeleteControl(EventType eventMsg); + CControl* SearchControl(EventType eventMsg); + + EventType RetEventTypeReduce(); + EventType RetEventTypeFull(); + EventType RetEventTypeClose(); void SetName(char* name); -- cgit v1.2.3-1-g7c22