diff options
Diffstat (limited to 'src/ui')
52 files changed, 5045 insertions, 5379 deletions
diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 0147f63..d98e676 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.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 @@ -15,30 +16,27 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include <windows.h> -#include <stdio.h> -#include <d3d.h> -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/language.h" -#include "old/math3d.h" +#include "ui/button.h" + #include "common/event.h" #include "common/misc.h" -#include "common/iman.h" #include "common/restext.h" -#include "ui/button.h" +#include "graphics/engine/engine.h" + +#include <string.h> +namespace Ui { + const float DELAY1 = 0.4f; const float DELAY2 = 0.1f; - // Object's constructor. -CButton::CButton(CInstanceManager* iMan) : CControl(iMan) +CButton::CButton() : CControl() { m_bCapture = false; m_bImmediat = false; @@ -55,18 +53,18 @@ CButton::~CButton() // Creates a new button. -bool CButton::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CButton::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); if ( icon == -1 ) { char name[100]; char* p; - GetResource(RES_EVENT, eventMsg, name); + GetResource(RES_EVENT, eventType, name); p = strchr(name, '\\'); if ( p != 0 ) *p = 0; SetName(name); @@ -85,7 +83,7 @@ bool CButton::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.event == EVENT_FRAME ) + if ( event.type == EVENT_FRAME ) { if ( m_bRepeat && m_repeat != 0.0f ) { @@ -95,18 +93,19 @@ bool CButton::EventProcess(const Event &event) m_repeat = DELAY2; Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } } } - if ( event.event == EVENT_LBUTTONDOWN && + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1 && (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { m_bCapture = true; m_repeat = DELAY1; @@ -114,25 +113,27 @@ bool CButton::EventProcess(const Event &event) if ( m_bImmediat || m_bRepeat ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } return false; } } - if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) + if ( event.type == EVENT_MOUSE_MOVE && m_bCapture ) { } - if ( event.event == EVENT_LBUTTONUP && m_bCapture ) + if ( event.type == EVENT_MOUSE_BUTTON_UP && //left + event.mouseButton.button == 1 && + m_bCapture ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { if ( !m_bImmediat && !m_bRepeat ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } } @@ -158,10 +159,10 @@ void CButton::Draw() if ( m_state & STATE_WARNING ) // shading yellow-black? { - pos.x = m_pos.x-( 8.0f/640.0f); - pos.y = m_pos.y-( 4.0f/480.0f); - dim.x = m_dim.x+(16.0f/640.0f); - dim.y = m_dim.y+( 8.0f/480.0f); + pos.x = m_pos.x - ( 8.0f / 640.0f); + pos.y = m_pos.y - ( 4.0f / 480.0f); + dim.x = m_dim.x + (16.0f / 640.0f); + dim.y = m_dim.y + ( 8.0f / 480.0f); if ( m_state & STATE_SHADOW ) { DrawShadow(pos, dim); @@ -181,20 +182,20 @@ void CButton::Draw() (m_state & STATE_CARD ) == 0 && (m_state & STATE_SIMPLY) == 0 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); - dp = 0.5f/256.0f; + dp = 0.5f / 256.0f; - uv1.x = 128.0f/256.0f; - uv1.y = 96.0f/256.0f; - uv2.x = 136.0f/256.0f; - uv2.y = 128.0f/256.0f; + uv1.x = 128.0f / 256.0f; + uv1.y = 96.0f / 256.0f; + uv2.x = 136.0f / 256.0f; + uv2.y = 128.0f / 256.0f; if ( (m_state & STATE_ENABLE) == 0 ) { - uv1.x += 16.0f/256.0f; - uv2.x += 16.0f/256.0f; + uv1.x += 16.0f / 256.0f; + uv2.x += 16.0f / 256.0f; } uv1.x += dp; @@ -202,15 +203,15 @@ void CButton::Draw() uv2.x -= dp; uv2.y -= dp; - pos.y = m_pos.y+5.0f/480.0f; - dim.y = m_dim.y-10.0f/480.0f; - pos.x = m_pos.x+5.0f/640.0f; - dim.x = 3.0f/640.0f; + pos.y = m_pos.y + 5.0f / 480.0f; + dim.y = m_dim.y - 10.0f / 480.0f; + pos.x = m_pos.x + 5.0f / 640.0f; + dim.x = 3.0f / 640.0f; DrawIcon(pos, dim, uv1, uv2, 0.0f); - uv1.x += 8.0f/256.0f; - uv2.x += 8.0f/256.0f; - pos.x = m_pos.x+m_dim.x-5.0f/640.0f-3.0f/640.0f; + uv1.x += 8.0f / 256.0f; + uv2.x += 8.0f / 256.0f; + pos.x = m_pos.x + m_dim.x - 5.0f / 640.0f - 3.0f / 640.0f; DrawIcon(pos, dim, uv1, uv2, 0.0f); } #endif @@ -225,7 +226,7 @@ void CButton::SetImmediat(bool bImmediat) m_bImmediat = bImmediat; } -bool CButton::RetImmediat() +bool CButton::GetImmediat() { return m_bImmediat; } @@ -239,8 +240,9 @@ void CButton::SetRepeat(bool bRepeat) m_bRepeat = bRepeat; } -bool CButton::RetRepeat() +bool CButton::GetRepeat() { return m_bRepeat; } +} diff --git a/src/ui/button.h b/src/ui/button.h index 0a05b11..33a48ee 100644 --- a/src/ui/button.h +++ b/src/ui/button.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,39 +19,37 @@ #pragma once - #include "ui/control.h" -class CD3DEngine; - - +namespace Ui { -class CButton : public CControl -{ -public: - CButton(CInstanceManager* iMan); - virtual ~CButton(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + class CButton : public CControl + { + public: + CButton(); + virtual ~CButton(); - 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 SetImmediat(bool bRepeat); - bool RetImmediat(); + void Draw(); - void SetRepeat(bool bRepeat); - bool RetRepeat(); + void SetImmediat(bool bRepeat); + bool GetImmediat(); -protected: + void SetRepeat(bool bRepeat); + bool GetRepeat(); -protected: - bool m_bCapture; - bool m_bImmediat; - bool m_bRepeat; - float m_repeat; -}; + protected: + 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 18c7633..a64fb5f 100644 --- a/src/ui/check.cpp +++ b/src/ui/check.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 @@ -15,26 +16,24 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include <windows.h> -#include <stdio.h> -#include <d3d.h> +#include "ui/check.h" -#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/misc.h" #include "common/restext.h" -#include "old/text.h" -#include "ui/check.h" +#include "graphics/engine/engine.h" +#include "graphics/engine/text.h" +#include <string.h> +namespace Ui { + // Object's constructor. -CCheck::CCheck(CInstanceManager* iMan) : CControl(iMan) +CCheck::CCheck() : CControl() { } @@ -47,16 +46,16 @@ CCheck::~CCheck() // Creates a new button. -bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { char name[100]; char* p; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); - GetResource(RES_EVENT, eventMsg, name); + GetResource(RES_EVENT, eventType, name); p = strchr(name, '\\'); if ( p != 0 ) *p = 0; SetName(name); @@ -73,14 +72,15 @@ bool CCheck::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.event == EVENT_LBUTTONDOWN && - (m_state & STATE_VISIBLE) && + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1 && + (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } @@ -101,15 +101,15 @@ void CCheck::Draw() if ( (m_state & STATE_VISIBLE) == 0 ) return; iDim = m_dim; - m_dim.x = m_dim.y*0.75f; // square + m_dim.x = m_dim.y * 0.75f; // square if ( m_state & STATE_SHADOW ) { DrawShadow(m_pos, m_dim); } - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); zoomExt = 1.00f; zoomInt = 0.95f; @@ -143,7 +143,7 @@ void CCheck::Draw() if ( (m_state & STATE_DEAD) == 0 ) { - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); if ( m_state & STATE_CHECK ) { @@ -157,10 +157,10 @@ void CCheck::Draw() if ( m_state & STATE_DEAD ) return; // Draw the name. - pos.x = m_pos.x+m_dim.y/0.9f; - pos.y = m_pos.y+m_dim.y*0.50f; - pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; - m_engine->RetText()->DrawText(m_name, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); + pos.x = m_pos.x + m_dim.y / 0.9f; + pos.y = m_pos.y + m_dim.y * 0.50f; + pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f; + m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0); } - +} diff --git a/src/ui/check.h b/src/ui/check.h index 24c58f3..af26add 100644 --- a/src/ui/check.h +++ b/src/ui/check.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,29 +19,30 @@ #pragma once - #include "ui/control.h" -class CD3DEngine; - - +namespace Gfx{ + class CEngine; +} -class CCheck : public CControl -{ -public: - CCheck(CInstanceManager* iMan); - virtual ~CCheck(); +namespace Ui { + class CCheck : public CControl + { + public: + CCheck(); + virtual ~CCheck(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + 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(); -protected: + protected: -protected: -}; + protected: + }; +} diff --git a/src/ui/color.cpp b/src/ui/color.cpp index 1038343..200ed0c 100644 --- a/src/ui/color.cpp +++ b/src/ui/color.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 @@ -15,22 +16,20 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include <windows.h> -#include <stdio.h> -#include <d3d.h> +#include "ui/color.h" -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/language.h" -#include "old/math3d.h" #include "common/event.h" -#include "common/misc.h" #include "common/iman.h" +#include "common/misc.h" #include "common/restext.h" -#include "ui/color.h" +#include "graphics/core/device.h" +#include "graphics/engine/engine.h" + +#include <string.h> +namespace Ui { const float DELAY1 = 0.4f; const float DELAY2 = 0.1f; @@ -38,7 +37,8 @@ const float DELAY2 = 0.1f; // Object's constructor. -CColor::CColor(CInstanceManager* iMan) : CControl(iMan) +//CColor::CColor(CInstanceManager* iMan) : CControl(iMan) +CColor::CColor() : CControl() { m_bRepeat = false; m_repeat = 0.0f; @@ -58,18 +58,18 @@ CColor::~CColor() // Creates a new button. -bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); if ( icon == -1 ) { char name[100]; char* p; - GetResource(RES_EVENT, eventMsg, name); + GetResource(RES_EVENT, eventType, name); p = strchr(name, '\\'); if ( p != 0 ) *p = 0; SetName(name); @@ -87,7 +87,7 @@ bool CColor::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.event == EVENT_FRAME && m_bRepeat ) + if ( event.type == EVENT_FRAME && m_bRepeat ) { if ( m_repeat != 0.0f ) { @@ -97,29 +97,30 @@ bool CColor::EventProcess(const Event &event) m_repeat = DELAY2; Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } } } - if ( event.event == EVENT_LBUTTONDOWN && + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1 && (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { m_repeat = DELAY1; Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } } - if ( event.event == EVENT_LBUTTONUP ) + if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1) { m_repeat = 0.0f; } @@ -132,9 +133,9 @@ bool CColor::EventProcess(const Event &event) void CColor::Draw() { - LPDIRECT3DDEVICE7 device; - D3DLVERTEX vertex[4]; // 2 triangles - D3DCOLOR color; + Gfx::CDevice* device; + Gfx::VertexCol vertex[4]; // 2 triangles + Gfx::Color color; Math::Point p1, p2; if ( (m_state & STATE_VISIBLE) == 0 ) return; @@ -144,57 +145,58 @@ void CColor::Draw() DrawShadow(m_pos, m_dim); } - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); CControl::Draw(); #if _TEEN - color = ::RetColor(m_color); - - m_engine->SetTexture("xxx.tga"); // no texture - m_engine->SetState(D3DSTATENORMAL); - - device = m_engine->RetD3DDevice(); - - p1.x = m_pos.x+(4.0f/640.0f); - p1.y = m_pos.y+(4.0f/480.0f); - p2.x = m_pos.x+m_dim.x-(4.0f/640.0f); - p2.y = m_pos.y+m_dim.y-(4.0f/480.0f); - vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); - vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); - vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); - vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL); - - p1.x = m_pos.x+(5.0f/640.0f); - p1.y = m_pos.y+(5.0f/480.0f); - p2.x = m_pos.x+m_dim.x-(5.0f/640.0f); - p2.y = m_pos.y+m_dim.y-(5.0f/480.0f); - vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL); +// color = GetColor(m_color); + color = GetColor(); + + m_engine->SetTexture("xxx.png"); // no texture + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + + device = m_engine->GetDevice(); + + p1.x = m_pos.x + (4.0f / 640.0f); + p1.y = m_pos.y + (4.0f / 480.0f); + p2.x = m_pos.x + m_dim.x - (4.0f / 640.0f); + p2.y = m_pos.y + m_dim.y - (4.0f / 480.0f); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f)); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f)); + vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f)); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); + + p1.x = m_pos.x + (5.0f / 640.0f); + p1.y = m_pos.y + (5.0f / 480.0f); + p2.x = m_pos.x + m_dim.x - (5.0f / 640.0f); + p2.y = m_pos.y + m_dim.y - (5.0f / 480.0f); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f)); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f)); + vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f)); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); m_engine->AddStatisticTriangle(4); #else - p1.x = m_pos.x+(3.0f/640.0f); - p1.y = m_pos.y+(3.0f/480.0f); - p2.x = m_pos.x+m_dim.x-(3.0f/640.0f); - p2.y = m_pos.y+m_dim.y-(3.0f/480.0f); + p1.x = m_pos.x + (3.0f / 640.0f); + p1.y = m_pos.y + (3.0f / 480.0f); + p2.x = m_pos.x + m_dim.x - (3.0f / 640.0f); + p2.y = m_pos.y + m_dim.y - (3.0f / 480.0f); - color = ::RetColor(m_color); + color = GetColor(); - m_engine->SetTexture("xxx.tga"); // no texture - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("xxx.png"); // no texture + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); - vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); + vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f)); + vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f)); + vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f)); + vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f)); - device = m_engine->RetD3DDevice(); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL); + device = m_engine->GetDevice(); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); m_engine->AddStatisticTriangle(2); #endif } @@ -205,20 +207,21 @@ void CColor::SetRepeat(bool bRepeat) m_bRepeat = bRepeat; } -bool CColor::RetRepeat() +bool CColor::GetRepeat() { return m_bRepeat; } -void CColor::SetColor(D3DCOLORVALUE color) +void CColor::SetColor(Gfx::Color color) { m_color = color; } -D3DCOLORVALUE CColor::RetColor() +Gfx::Color CColor::GetColor() { return m_color; } +} diff --git a/src/ui/color.h b/src/ui/color.h index 41052a7..ad99ddd 100644 --- a/src/ui/color.h +++ b/src/ui/color.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,39 +19,41 @@ #pragma once - #include "ui/control.h" -#include "old/d3dengine.h" - - -class CD3DEngine; +namespace Gfx{ + class CEngine; + struct Color; +} -class CColor : public CControl -{ -public: - CColor(CInstanceManager* iMan); - virtual ~CColor(); +namespace Ui { + class CColor : public CControl + { + public: + // CColor(CInstanceManager* iMan); + CColor(); + virtual ~CColor(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + 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 SetRepeat(bool bRepeat); - bool RetRepeat(); + void SetRepeat(bool bRepeat); + bool GetRepeat(); - void SetColor(D3DCOLORVALUE color); - D3DCOLORVALUE RetColor(); + void SetColor(Gfx::Color color); + Gfx::Color GetColor(); -protected: + protected: -protected: - bool m_bRepeat; - float m_repeat; - D3DCOLORVALUE m_color; -}; + protected: + bool m_bRepeat; + float m_repeat; + Gfx::Color m_color; + }; +} diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp index 7ea6e9d..c7d0068 100644 --- a/src/ui/compass.cpp +++ b/src/ui/compass.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 @@ -14,26 +15,22 @@ // * 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 <windows.h> -#include <stdio.h> -#include <d3d.h> - -#include "common/struct.h" -#include "math/geometry.h" -#include "old/d3dengine.h" -#include "old/math3d.h" #include "common/event.h" -#include "common/misc.h" #include "common/iman.h" -#include "ui/compass.h" - +#include "common/misc.h" +#include "graphics/core/device.h" +#include "graphics/engine/engine.h" +#include "math/geometry.h" +namespace Ui { // Object's constructor. -CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan) +//CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan) +CCompass::CCompass() : CControl() { m_dir = 0.0f; } @@ -47,11 +44,11 @@ CCompass::~CCompass() // Creates a new button. -bool CCompass::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CCompass::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); return true; } @@ -62,12 +59,13 @@ bool CCompass::EventProcess(const Event &event) { CControl::EventProcess(event); - if ( event.event == EVENT_LBUTTONDOWN ) + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } @@ -81,33 +79,33 @@ bool CCompass::EventProcess(const Event &event) void CCompass::Draw() { - LPDIRECT3DDEVICE7 device; - D3DVERTEX2 vertex[4]; // 2 triangles - Math::Point p1, p2, p3, c, uv1, uv2; - Math::Vector n; - float dp; + Gfx::CDevice* device; + Gfx::Vertex vertex[4]; // 2 triangles + Math::Point p1, p2, p3, c, uv1, uv2; + Math::Vector n; + float dp; if ( (m_state & STATE_VISIBLE) == 0 ) return; - device = m_engine->RetD3DDevice(); + device = m_engine->GetDevice(); - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); p1.x = m_pos.x; p1.y = m_pos.y; p2.x = m_pos.x + m_dim.x; p2.y = m_pos.y + m_dim.y; - c.x = (p1.x+p2.x)/2.0f; - c.y = (p1.y+p2.y)/2.0f; // center + c.x = (p1.x + p2.x) / 2.0f; + c.y = (p1.y + p2.y) / 2.0f; // center - uv1.x = 64.0f/256.0f; - uv1.y = 32.0f/256.0f; - uv2.x = 96.0f/256.0f; - uv2.y = 64.0f/256.0f; + uv1.x = 64.0f / 256.0f; + uv1.y = 32.0f / 256.0f; + uv2.x = 96.0f / 256.0f; + uv2.y = 64.0f / 256.0f; - dp = 0.5f/256.0f; + dp = 0.5f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -115,46 +113,46 @@ void CCompass::Draw() n = Math::Vector(0.0f, 0.0f, -1.0f); // normal - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y); - vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y); - vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y)); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y)); + vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y)); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); m_engine->AddStatisticTriangle(2); if ( m_state & STATE_ENABLE ) { p1.x = c.x; - p1.y = c.y+m_dim.x*0.40f; + p1.y = c.y + m_dim.x * 0.40f; p1 = Math::RotatePoint(c, m_dir, p1); - p1.x = c.x+(p1.x-c.x)*(m_dim.x/m_dim.y); + p1.x = c.x + (p1.x - c.x) * (m_dim.x / m_dim.y); - p2.x = c.x+m_dim.x*0.20f; - p2.y = c.y-m_dim.x*0.40f; + p2.x = c.x + m_dim.x * 0.20f; + p2.y = c.y - m_dim.x * 0.40f; p2 = Math::RotatePoint(c, m_dir, p2); - p2.x = c.x+(p2.x-c.x)*(m_dim.x/m_dim.y); + p2.x = c.x + (p2.x - c.x) * (m_dim.x / m_dim.y); - p3.x = c.x-m_dim.x*0.20f; - p3.y = c.y-m_dim.x*0.40f; + p3.x = c.x - m_dim.x * 0.20f; + p3.y = c.y - m_dim.x * 0.40f; p3 = Math::RotatePoint(c, m_dir, p3); - p3.x = c.x+(p3.x-c.x)*(m_dim.x/m_dim.y); + p3.x = c.x + (p3.x - c.x) * (m_dim.x / m_dim.y); - uv1.x = 96.0f/256.0f; - uv1.y = 32.0f/256.0f; - uv2.x = 104.0f/256.0f; - uv2.y = 64.0f/256.0f; + uv1.x = 96.0f / 256.0f; + uv1.y = 32.0f / 256.0f; + uv2.x = 104.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y); - vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y); - vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv1.y)); + vertex[1] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv2.y)); + vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y)); - device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3); m_engine->AddStatisticTriangle(1); } } @@ -167,9 +165,10 @@ void CCompass::SetDirection(float dir) m_dir = dir; } -float CCompass::RetDirection() +float CCompass::GetDirection() { return m_dir; } +} diff --git a/src/ui/compass.h b/src/ui/compass.h index 0014f3d..09eec9d 100644 --- a/src/ui/compass.h +++ b/src/ui/compass.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,33 +19,36 @@ #pragma once - #include "ui/control.h" -class CD3DEngine; - +namespace Gfx { + class CEngine; +} +namespace Ui { -class CCompass : public CControl -{ -public: - CCompass(CInstanceManager* iMan); - virtual ~CCompass(); + class CCompass : public CControl + { + public: + // CCompass(CInstanceManager* iMan); + CCompass(); + virtual ~CCompass(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + 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 RetDirection(); + void SetDirection(float dir); + float GetDirection(); -protected: + protected: -protected: - float m_dir; -}; + protected: + float m_dir; + }; +} diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 6ff7c2f..6ac82bc 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -1,6 +1,7 @@ // * 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 // * the Free Software Foundation, either version 3 of the License, or @@ -15,47 +16,28 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/language.h" -#include "common/restext.h" -#include "old/math3d.h" -#include "common/event.h" -#include "common/misc.h" -#include "object/robotmain.h" -#include "old/particule.h" -#include "common/misc.h" -#include "common/iman.h" -#include "old/text.h" -#include "old/sound.h" #include "ui/control.h" - - +namespace Ui { // Object's constructor. -CControl::CControl(CInstanceManager* iMan) +CControl::CControl() { - m_iMan = iMan; + m_iMan = CInstanceManager::GetInstancePointer(); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); - m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); - m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); - m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); - m_eventMsg = EVENT_NULL; + 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_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT; - m_fontSize = SMALLFONT; - m_fontStretch = NORMSTRETCH; - m_fontType = FONT_COLOBOT; - m_justif = 0; - m_name[0] = 0; - m_tooltip[0] = 0; + 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; @@ -76,34 +58,31 @@ CControl::~CControl() // Creates a new button. // pos: [0..1] -bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - char text[100]; - char* p; + char text[100]; + std::string str_text; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) + eventType = GetUniqueEventType(); m_pos = pos; m_dim = dim; m_icon = icon; - m_eventMsg = eventMsg; + m_eventType = eventType; pos.x = m_pos.x; - pos.y = m_pos.y+m_dim.y; + pos.y = m_pos.y + m_dim.y; GlintCreate(pos); - GetResource(RES_EVENT, m_eventMsg, text); - p = strchr(text, '\\'); - if ( p == 0 ) - { + GetResource(RES_EVENT, m_eventType, text); + str_text = std::string(text); + auto p = str_text.find("\\"); + if ( p == std::string::npos ) { if ( icon != -1 ) - { - strcpy(m_tooltip, text); - } - } - else - { - strcpy(m_tooltip, p+1); // text after "\\" + m_tooltip = str_text; + } else { + m_tooltip = str_text.substr(p + 1); } return true; @@ -115,11 +94,11 @@ void CControl::SetPos(Math::Point pos) m_pos = pos; pos.x = m_pos.x; - pos.y = m_pos.y+m_dim.y; + pos.y = m_pos.y + m_dim.y; GlintCreate(pos); } -Math::Point CControl::RetPos() +Math::Point CControl::GetPos() { return m_pos; } @@ -131,11 +110,11 @@ void CControl::SetDim(Math::Point dim) m_dim = dim; pos.x = m_pos.x; - pos.y = m_pos.y+m_dim.y; + pos.y = m_pos.y + m_dim.y; GlintCreate(pos); } -Math::Point CControl::RetDim() +Math::Point CControl::GetDim() { return m_dim; } @@ -175,7 +154,7 @@ bool CControl::TestState(int state) // Returns all attributes of state. -int CControl::RetState() +int CControl::GetState() { return m_state; } @@ -188,7 +167,7 @@ void CControl::SetIcon(int icon) m_icon = icon; } -int CControl::RetIcon() +int CControl::GetIcon() { return m_icon; } @@ -196,41 +175,21 @@ int CControl::RetIcon() // Management of the button name. -void CControl::SetName(char* name, bool bTooltip) +void CControl::SetName(std::string name, bool bTooltip) { - char* p; - - if ( bTooltip ) - { - p = strchr(name, '\\'); - if ( p == 0 ) - { - strncpy(m_name, name, 100); - m_name[100-1] = 0; + if ( bTooltip ) { + auto p = name.find("\\"); + if ( p == std::string::npos ) + m_name = name; + else { + m_tooltip = name.substr(p + 1); + m_name = name.substr(0, p); } - else - { - char buffer[100]; - - strncpy(m_tooltip, p+1, 100); // text after "\\" - m_tooltip[100-1] = 0; - - strncpy(buffer, name, 100); - buffer[100-1] = 0; - p = strchr(buffer, '\\'); - if ( p != 0 ) *p = 0; - strncpy(m_name, buffer, 100); - m_name[100-1] = 0; - } - } - else - { - strncpy(m_name, name, 100); - m_name[100-1] = 0; - } + } else + m_name = name; } -char* CControl::RetName() +std::string CControl::GetName() { return m_name; } @@ -238,14 +197,16 @@ char* CControl::RetName() // Management of the mode of justification (-1,0,1). -void CControl::SetJustif(int mode) +void CControl::SetTextAlign(Gfx::TextAlign mode) { - m_justif = mode; + m_textAlign = mode; +// m_justif = mode; } -int CControl::RetJustif() +int CControl::GetTextAlign() { - return m_justif; + return m_textAlign; +// return m_justif; } @@ -256,7 +217,7 @@ void CControl::SetFontSize(float size) m_fontSize = size; } -float CControl::RetFontSize() +float CControl::GetFontSize() { return m_fontSize; } @@ -269,7 +230,7 @@ void CControl::SetFontStretch(float stretch) m_fontStretch = stretch; } -float CControl::RetFontStretch() +float CControl::GetFontStretch() { return m_fontStretch; } @@ -277,12 +238,12 @@ float CControl::RetFontStretch() // Choice of the font. -void CControl::SetFontType(FontType font) +void CControl::SetFontType(Gfx::FontType font) { m_fontType = font; } -FontType CControl::RetFontType() +Gfx::FontType CControl::GetFontType() { return m_fontType; } @@ -290,21 +251,21 @@ FontType CControl::RetFontType() // Specifies the tooltip. -bool CControl::SetTooltip(char* name) +bool CControl::SetTooltip(std::string name) { - strcpy(m_tooltip, name); + m_tooltip = name; return true; } -bool CControl::GetTooltip(Math::Point pos, char* name) +bool CControl::GetTooltip(Math::Point pos, std::string &name) { - if ( m_tooltip[0] == 0 ) return false; - if ( (m_state & STATE_VISIBLE) == 0 ) return false; + if ( m_tooltip.length() == 0 ) return false; + if ( (m_state & STATE_VISIBLE) == 0 ) return false; if ( (m_state & STATE_ENABLE) == 0 ) return false; if ( m_state & STATE_DEAD ) return false; if ( !Detect(pos) ) return false; - strcpy(name, m_tooltip); + name = m_tooltip; return true; } @@ -316,7 +277,7 @@ void CControl::SetFocus(bool bFocus) m_bFocus = bFocus; } -bool CControl::RetFocus() +bool CControl::GetFocus() { return m_bFocus; } @@ -324,9 +285,9 @@ bool CControl::RetFocus() // Returns the event associated with the control. -EventMsg CControl::RetEventMsg() +EventType CControl::GetEventType() { - return m_eventMsg; + return m_eventType; } @@ -336,21 +297,21 @@ bool CControl::EventProcess(const Event &event) { if ( m_state & STATE_DEAD ) return true; - if ( event.event == EVENT_FRAME && m_bGlint ) + if ( event.type == EVENT_FRAME && m_bGlint ) { GlintFrame(event); } - if ( event.event == EVENT_MOUSEMOVE ) + if ( event.type == EVENT_MOUSE_MOVE ) { - m_glintMouse = event.pos; + m_glintMouse = event.mouseMove.pos; - if ( Detect(event.pos) ) + if ( Detect(event.mouseMove.pos) ) { if ( (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE ) ) { - m_engine->SetMouseType(D3DMOUSEHAND); + m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); } SetState(STATE_HILIGHT); } @@ -360,18 +321,18 @@ bool CControl::EventProcess(const Event &event) } } - if ( event.event == EVENT_LBUTTONDOWN ) + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1) { - if ( Detect(event.pos) ) + if ( Detect(event.mouseButton.pos) ) { m_bCapture = true; SetState(STATE_PRESS); } } - if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) + if ( event.type == EVENT_MOUSE_MOVE && m_bCapture ) { - if ( Detect(event.pos) ) + if ( Detect(event.mouseMove.pos) ) { SetState(STATE_PRESS); } @@ -381,7 +342,7 @@ bool CControl::EventProcess(const Event &event) } } - if ( event.event == EVENT_LBUTTONUP && m_bCapture ) + if ( event.type == EVENT_MOUSE_BUTTON_UP && m_bCapture && event.mouseButton.button == 1) { m_bCapture = false; ClearState(STATE_PRESS); @@ -404,8 +365,8 @@ void CControl::GlintCreate(Math::Point ref, bool bLeft, bool bUp) { float offset; - offset = 8.0f/640.0f; - if ( offset > m_dim.x/4.0f) offset = m_dim.x/4.0f; + offset = 8.0f / 640.0f; + if ( offset > m_dim.x / 4.0f) offset = m_dim.x / 4.0f; if ( bLeft ) { @@ -419,17 +380,17 @@ void CControl::GlintCreate(Math::Point ref, bool bLeft, bool bUp) } offset = 8.0f/480.0f; - if ( offset > m_dim.y/4.0f) offset = m_dim.y/4.0f; + if ( offset > m_dim.y / 4.0f) offset = m_dim.y / 4.0f; if ( bUp ) { - m_glintCorner1.y = ref.y-offset; + m_glintCorner1.y = ref.y - offset; m_glintCorner2.y = ref.y; } else { m_glintCorner1.y = ref.y; - m_glintCorner2.y = ref.y+offset; + m_glintCorner2.y = ref.y + offset; } m_bGlint = true; @@ -446,20 +407,20 @@ void CControl::GlintFrame(const Event &event) (m_state & STATE_ENABLE ) == 0 || (m_state & STATE_VISIBLE) == 0 ) return; - if ( !m_main->RetGlint() ) return; + if ( !m_main->GetGlint() ) return; m_glintProgress += event.rTime; if ( m_glintProgress >= 2.0f && Detect(m_glintMouse) ) { - pos.x = m_glintCorner1.x + (m_glintCorner2.x-m_glintCorner1.x)*Math::Rand(); - pos.y = m_glintCorner1.y + (m_glintCorner2.y-m_glintCorner1.y)*Math::Rand(); + pos.x = m_glintCorner1.x + (m_glintCorner2.x - m_glintCorner1.x) * Math::Rand(); + pos.y = m_glintCorner1.y + (m_glintCorner2.y - m_glintCorner1.y) * Math::Rand(); pos.z = 0.0f; speed = Math::Vector(0.0f, 0.0f, 0.0f); - dim.x = ((15.0f+Math::Rand()*15.0f)/640.0f); - dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, PARTICONTROL, - 1.0f, 0.0f, 0.0f, SH_INTERFACE); + dim.x = ((15.0f + Math::Rand() * 15.0f) / 640.0f); + dim.y = dim.x / 0.75f; + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICONTROL, + 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE ); m_glintProgress = 0.0f; } @@ -476,8 +437,8 @@ void CControl::Draw() if ( (m_state & STATE_VISIBLE) == 0 ) return; - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); zoomExt = 1.00f; zoomInt = 0.95f; @@ -530,14 +491,14 @@ void CControl::Draw() if ( m_state & STATE_OKAY ) { - m_engine->SetTexture("button3.tga"); + m_engine->SetTexture("button3.png"); icon = 3; // yellow with green point pressed } if ( m_name[0] == 0 ) // button without name? { //? DrawPart(icon, zoomExt, 0.0f); - DrawPart(icon, zoomExt, 8.0f/256.0f); + DrawPart(icon, zoomExt, 8.0f / 256.0f); if ( m_state & STATE_DEAD ) return; @@ -546,27 +507,27 @@ void CControl::Draw() { icon -= 192; #if _POLISH - m_engine->SetTexture("textp.tga"); + m_engine->SetTexture("textp.png"); #else - m_engine->SetTexture("text.tga"); + m_engine->SetTexture("text.png"); #endif - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); } else if ( icon >= 128 ) { icon -= 128; - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); } else if ( icon >= 64 ) { icon -= 64; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); } else { - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); } if ( icon != -1 ) { @@ -579,26 +540,28 @@ void CControl::Draw() if ( m_state & STATE_DEAD ) return; - if ( m_justif < 0 ) +// if ( m_justif < 0 ) + if ( m_textAlign == Gfx::TEXT_ALIGN_LEFT ) { - pos.x = m_pos.x+m_dim.x-m_dim.y*0.5f; - pos.y = m_pos.y+m_dim.y*0.5f; - pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2; - m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0); + pos.x = m_pos.x + m_dim.x - m_dim.y * 0.5f; + pos.y = m_pos.y + m_dim.y * 0.5f; + pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f; + m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0); } - else if ( m_justif > 0 ) + else if ( m_textAlign == Gfx::TEXT_ALIGN_RIGHT ) +// else if ( m_justif > 0 ) { - pos.x = m_pos.x+m_dim.y*0.5f; - pos.y = m_pos.y+m_dim.y*0.5f; - pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; - m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0); + pos.x = m_pos.x + m_dim.y * 0.5f; + pos.y = m_pos.y + m_dim.y * 0.5f; + pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f; + m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0); } else { - pos.x = m_pos.x+m_dim.x*0.5f; - pos.y = m_pos.y+m_dim.y*0.5f; - pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; - m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0); + pos.x = m_pos.x + m_dim.x * 0.5f; + pos.y = m_pos.y + m_dim.y * 0.5f; + pos.y -= m_engine->GetText()->GetHeight( m_fontType, m_fontSize)/2.0f; + m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0); } } } @@ -618,26 +581,26 @@ void CControl::DrawPart(int icon, float zoom, float ex) if ( (m_state & STATE_CARD ) && (m_state & STATE_CHECK) ) { - p2.y += (2.0f/480.0f); // a bit above + p2.y += (2.0f / 480.0f); // a bit above } - c.x = (p1.x+p2.x)/2.0f; - c.y = (p1.y+p2.y)/2.0f; // center + c.x = (p1.x + p2.x)/2.0f; + c.y = (p1.y + p2.y)/2.0f; // center - p1.x = (p1.x-c.x)*zoom + c.x; - p1.y = (p1.y-c.y)*zoom + c.y; - p2.x = (p2.x-c.x)*zoom + c.x; - p2.y = (p2.y-c.y)*zoom + c.y; + p1.x = (p1.x - c.x) * zoom + c.x; + p1.y = (p1.y - c.y) * zoom + c.y; + p2.x = (p2.x - c.x) * zoom + c.x; + p2.y = (p2.y - c.y) * zoom + c.y; p2.x -= p1.x; p2.y -= p1.y; - uv1.x = (32.0f/256.0f)*(icon%8); - uv1.y = (32.0f/256.0f)*(icon/8); // uv texture - uv2.x = (32.0f/256.0f)+uv1.x; - uv2.y = (32.0f/256.0f)+uv1.y; + uv1.x = (32.0f / 256.0f) * (icon%8); + uv1.y = (32.0f / 256.0f) * (icon/8); // uv texture + uv2.x = (32.0f / 256.0f) + uv1.x; + uv2.y = (32.0f / 256.0f) + uv1.y; - dp = 0.5f/256.0f; + dp = 0.5f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -652,12 +615,12 @@ void CControl::DrawPart(int icon, float zoom, float ex) void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex) { - LPDIRECT3DDEVICE7 device; - D3DVERTEX2 vertex[8]; // 6 triangles + Gfx::CDevice* device; + Gfx::Vertex vertex[8]; // 6 triangles Math::Point p1, p2, p3, p4; Math::Vector n; - device = m_engine->RetD3DDevice(); + device = m_engine->GetDevice(); p1.x = pos.x; p1.y = pos.y; @@ -668,48 +631,48 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math: if ( ex == 0.0f ) // one piece? { - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y); - vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y); - vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv2.y)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y)); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x,uv2.y)); + vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x,uv1.y)); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); m_engine->AddStatisticTriangle(2); } else // 3 pieces? { if ( dim.x >= dim.y ) { - p3.x = p1.x + ex*dim.y/(uv2.y-uv1.y); - p4.x = p2.x - ex*dim.y/(uv2.y-uv1.y); - - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x, uv2.y); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x, uv1.y); - vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p1.y, 0.0f), n, uv1.x+ex,uv2.y); - vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p2.y, 0.0f), n, uv1.x+ex,uv1.y); - vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p1.y, 0.0f), n, uv2.x-ex,uv2.y); - vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p2.y, 0.0f), n, uv2.x-ex,uv1.y); - vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x, uv2.y); - vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x, uv1.y); - - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); + p3.x = p1.x + ex*dim.y / (uv2.y - uv1.y); + p4.x = p2.x - ex*dim.y / (uv2.y - uv1.y); + + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y)); + vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p1.y, 0.0f), n, Math::Point(uv1.x+ex,uv2.y)); + vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p2.y, 0.0f), n, Math::Point(uv1.x+ex,uv1.y)); + vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p1.y, 0.0f), n, Math::Point(uv2.x-ex,uv2.y)); + vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p2.y, 0.0f), n, Math::Point(uv2.x-ex,uv1.y)); + vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y)); + vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y)); + + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8); m_engine->AddStatisticTriangle(6); } else { - p3.y = p1.y + ex*dim.x/(uv2.x-uv1.x); - p4.y = p2.y - ex*dim.x/(uv2.x-uv1.x); - - vertex[0] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y ); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y ); - vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x,uv2.y-ex); - vertex[3] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x,uv2.y-ex); - vertex[4] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x,uv1.y+ex); - vertex[5] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x,uv1.y+ex); - vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y ); - vertex[7] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y ); - - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); + p3.y = p1.y + ex*dim.x / (uv2.x - uv1.x); + p4.y = p2.y - ex*dim.x / (uv2.x - uv1.x); + + vertex[0] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y )); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y )); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex)); + vertex[3] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex)); + vertex[4] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex)); + vertex[5] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex)); + vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y )); + vertex[7] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y )); + + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8); m_engine->AddStatisticTriangle(6); } } @@ -720,12 +683,12 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math: void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex) { - LPDIRECT3DDEVICE7 device; - D3DVERTEX2 vertex[8]; // 6 triangles + Gfx::CDevice* device; + Gfx::Vertex vertex[8]; // 6 triangles Math::Point p1, p2, p3, p4; Math::Vector n; - device = m_engine->RetD3DDevice(); + device = m_engine->GetDevice(); p1.x = pos.x; p1.y = pos.y; @@ -734,8 +697,8 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math: n = Math::Vector(0.0f, 0.0f, -1.0f); // normal - if ( corner.x > dim.x/2.0f ) corner.x = dim.x/2.0f; - if ( corner.y > dim.y/2.0f ) corner.y = dim.y/2.0f; + if ( corner.x > dim.x / 2.0f ) corner.x = dim.x / 2.0f; + if ( corner.y > dim.y / 2.0f ) corner.y = dim.y / 2.0f; p1.x = pos.x; p1.y = pos.y; @@ -747,39 +710,39 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math: p4.y = p2.y - corner.y; // Bottom horizontal band. - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x, uv2.y ); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x, uv2.y-ex); - vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p1.y, 0.0f), n, uv1.x+ex,uv2.y ); - vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x+ex,uv2.y-ex); - vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p1.y, 0.0f), n, uv2.x-ex,uv2.y ); - vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p3.y, 0.0f), n, uv2.x-ex,uv2.y-ex); - vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x, uv2.y ); - vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x, uv2.y-ex); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y )); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex)); + vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p1.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y )); + vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y - ex)); + vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p1.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y )); + vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p3.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y - ex)); + vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y )); + vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex)); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8); m_engine->AddStatisticTriangle(6); // Central horizontal band. - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x, uv2.y-ex); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x, uv1.y+ex); - vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x+ex,uv2.y-ex); - vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p4.y, 0.0f), n, uv1.x+ex,uv1.y+ex); - vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p3.y, 0.0f), n, uv2.x-ex,uv2.y-ex); - vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x-ex,uv1.y+ex); - vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x, uv2.y-ex); - vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x, uv1.y+ex); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex)); + vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y - ex)); + vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p4.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y + ex)); + vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p3.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y - ex)); + vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y + ex)); + vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex)); + vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex)); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8); m_engine->AddStatisticTriangle(6); // Top horizontal band. - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x, uv1.y+ex); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x, uv1.y ); - vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p4.y, 0.0f), n, uv1.x+ex,uv1.y+ex); - vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p2.y, 0.0f), n, uv1.x+ex,uv1.y ); - vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x-ex,uv1.y+ex); - vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p2.y, 0.0f), n, uv2.x-ex,uv1.y ); - vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x, uv1.y+ex); - vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x, uv1.y ); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y )); + vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p4.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y + ex)); + vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p2.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y )); + vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y + ex)); + vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p2.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y )); + vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex)); + vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y )); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8); m_engine->AddStatisticTriangle(6); } @@ -790,15 +753,15 @@ void CControl::DrawWarning(Math::Point pos, Math::Point dim) Math::Point uv1, uv2; float dp; - dp = 0.5f/256.0f; + dp = 0.5f / 256.0f; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); - uv1.x = 64.0f/256.0f; - uv1.y = 208.0f/256.0f; - uv2.x = 160.0f/256.0f; - uv2.y = 224.0f/256.0f; + uv1.x = 64.0f / 256.0f; + uv1.y = 208.0f / 256.0f; + uv2.x = 160.0f / 256.0f; + uv2.y = 224.0f / 256.0f; uv1.x += dp; uv1.y += dp; @@ -836,28 +799,28 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep) dp = 0.5f/256.0f; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button2.png"); + m_engine->SetState( Gfx::ENG_RSTATE_TTEXTURE_WHITE); - pos.x += deep*0.010f*0.75f; - pos.y -= deep*0.015f; - dim.x += deep*0.005f*0.75f; - dim.y += deep*0.005f; + pos.x += deep * 0.010f * 0.75f; + pos.y -= deep * 0.015f; + dim.x += deep * 0.005f * 0.75f; + dim.y += deep * 0.005f; - uv1.x = 192.0f/256.0f; - uv1.y = 32.0f/256.0f; - uv2.x = 224.0f/256.0f; - uv2.y = 64.0f/256.0f; + uv1.x = 192.0f / 256.0f; + uv1.y = 32.0f / 256.0f; + uv2.x = 224.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 10.0f/640.0f; - corner.y = 10.0f/480.0f; + corner.x = 10.0f / 640.0f; + corner.y = 10.0f / 480.0f; - DrawIcon(pos, dim, uv1, uv2, corner, 6.0f/256.0f); + DrawIcon(pos, dim, uv1, uv2, corner, 6.0f / 256.0f); } @@ -865,10 +828,10 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep) bool CControl::Detect(Math::Point pos) { - return ( pos.x >= m_pos.x && - pos.x <= m_pos.x+m_dim.x && - pos.y >= m_pos.y && - pos.y <= m_pos.y+m_dim.y ); + return ( pos.x >= m_pos.x && + pos.x <= m_pos.x + m_dim.x && + pos.y >= m_pos.y && + pos.y <= m_pos.y + m_dim.y ); } - +} diff --git a/src/ui/control.h b/src/ui/control.h index 0a12ff1..e08c34d 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,121 +19,129 @@ #pragma once +#include <string> -#include "old/text.h" -#include "common/struct.h" #include "common/event.h" - - -class CInstanceManager; -class CEvent; -class CD3DEngine; -class CRobotMain; -class CParticule; -class CSound; - - -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); - 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(); - -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; - 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; -}; - - +#include "common/iman.h" +#include "common/misc.h" +#include "common/restext.h" + +#include "graphics/core/device.h" +#include "graphics/engine/engine.h" +#include "graphics/engine/particle.h" +#include "graphics/engine/text.h" + +#include "object/robotmain.h" + +#include "sound/sound.h" + + + +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; + }; + +} diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index 39a4a14..173c100 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.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,53 +18,50 @@ // displayinfo.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> +#include "ui/displayinfo.h" -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/d3dmath.h" -#include "common/language.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/iman.h" -#include "common/restext.h" -#include "old/math3d.h" -#include "object/robotmain.h" -#include "old/camera.h" -#include "object/object.h" -#include "object/motion/motion.h" -#include "object/motion/motiontoto.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 "old/particule.h" -#include "old/light.h" -#include "old/text.h" -#include "script/cbottoken.h" -#include "ui/displayinfo.h" +#include "common/iman.h" +#include "common/misc.h" +#include "common/restext.h" + +#include "graphics/core/light.h" +#include "graphics/engine/engine.h" +#include "graphics/engine/lightman.h" +#include "graphics/engine/particle.h" + +#include "object/object.h" +#include "object/robotmain.h" +#include "object/motion/motion.h" +#include "object/motion/motiontoto.h" +#include "script/cbottoken.h" +#include <string.h> + +namespace Ui { // Object's constructor. -CDisplayInfo::CDisplayInfo(CInstanceManager* iMan) +//CDisplayInfo::CDisplayInfo(CInstanceManager* iMan) +CDisplayInfo::CDisplayInfo() { - m_iMan = iMan; + m_iMan = CInstanceManager::GetInstancePointer(); m_iMan->AddInstance(CLASS_STUDIO, this); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); - m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); - m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); - m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT); + 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_bInfoMaximized = true; m_bInfoMinimized = false; @@ -87,44 +85,44 @@ CDisplayInfo::~CDisplayInfo() bool CDisplayInfo::EventProcess(const Event &event) { - CWindow* pw; - CEdit* edit; - CSlider* slider; + Ui::CWindow* pw; + Ui::CEdit* edit; + Ui::CSlider* slider; CMotionToto* toto; - if ( event.event == EVENT_FRAME ) + if ( event.type == EVENT_FRAME ) { EventFrame(event); HyperUpdate(); } - if ( event.event == EVENT_MOUSEMOVE ) + if ( event.type == EVENT_MOUSE_MOVE ) { if ( m_toto != 0 ) { - toto = (CMotionToto*)m_toto->RetMotion(); + toto = static_cast<CMotionToto*>(m_toto->GetMotion()); if ( toto != 0 ) { - toto->SetMousePos(event.pos); + toto->SetMousePos(event.mouseMove.pos); } } } - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) { - if ( event.event == pw->RetEventMsgClose() ) + if ( event.type == pw->GetEventTypeClose() ) { Event newEvent = event; - newEvent.event = EVENT_OBJECT_INFOOK; + newEvent.type = EVENT_OBJECT_INFOOK; m_event->AddEvent(newEvent); } - if ( event.event == EVENT_SATCOM_HUSTON ) + if ( event.type == EVENT_SATCOM_HUSTON ) { ChangeIndexButton(SATCOM_HUSTON); } - if ( event.event == EVENT_SATCOM_SAT ) + if ( event.type == EVENT_SATCOM_SAT ) { ChangeIndexButton(SATCOM_SAT); } @@ -132,90 +130,90 @@ bool CDisplayInfo::EventProcess(const Event &event) //? { //? ChangeIndexButton(SATCOM_OBJECT); //? } - if ( event.event == EVENT_SATCOM_LOADING ) + if ( event.type == EVENT_SATCOM_LOADING ) { ChangeIndexButton(SATCOM_LOADING); } - if ( event.event == EVENT_SATCOM_PROG ) + if ( event.type == EVENT_SATCOM_PROG ) { ChangeIndexButton(SATCOM_PROG); } - if ( event.event == EVENT_SATCOM_SOLUCE ) + if ( event.type == EVENT_SATCOM_SOLUCE ) { ChangeIndexButton(SATCOM_SOLUCE); } - if ( event.event == EVENT_HYPER_HOME || - event.event == EVENT_HYPER_PREV || - event.event == EVENT_HYPER_NEXT ) + if ( event.type == EVENT_HYPER_HOME || + event.type == EVENT_HYPER_PREV || + event.type == EVENT_HYPER_NEXT ) { - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit != 0 ) { - edit->HyperGo(event.event); + edit->HyperGo(event.type); HyperUpdate(); } } - if ( event.event == EVENT_HYPER_SIZE1 ) // size 1? + if ( event.type == EVENT_HYPER_SIZE1 ) // size 1? { m_main->SetFontSize(9.0f); - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); - if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); + slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE)); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); ViewDisplayInfo(); } - if ( event.event == EVENT_HYPER_SIZE2 ) // size 2? + if ( event.type == EVENT_HYPER_SIZE2 ) // size 2? { m_main->SetFontSize(10.0f); - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); - if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); + slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE)); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); ViewDisplayInfo(); } - if ( event.event == EVENT_HYPER_SIZE3 ) // size 3? + if ( event.type == EVENT_HYPER_SIZE3 ) // size 3? { m_main->SetFontSize(12.0f); - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); - if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); + slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE)); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); ViewDisplayInfo(); } - if ( event.event == EVENT_HYPER_SIZE4 ) // size 4? + if ( event.type == EVENT_HYPER_SIZE4 ) // size 4? { m_main->SetFontSize(15.0f); - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); - if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); + slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE)); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); ViewDisplayInfo(); } - if ( event.event == EVENT_STUDIO_SIZE ) // size? + if ( event.type == EVENT_STUDIO_SIZE ) // size? { - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); + slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider == 0 ) return false; - m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f); + m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f); ViewDisplayInfo(); } - if ( event.event == EVENT_HYPER_COPY ) // copy ? + if ( event.type == EVENT_HYPER_COPY ) // copy ? { - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit != 0 ) { edit->Copy(); } } - if ( event.event == EVENT_LBUTTONDOWN || - event.event == EVENT_LBUTTONUP ) + if ( ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 )|| + ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 )) { UpdateCopyButton(); } - if ( event.event == EVENT_WINDOW4 ) // window moved? + if ( event.type == EVENT_WINDOW4 ) // window moved? { - m_infoNormalPos = m_infoActualPos = m_infoFinalPos = pw->RetPos(); - m_infoNormalDim = m_infoActualDim = m_infoFinalDim = pw->RetDim(); + m_infoNormalPos = m_infoActualPos = m_infoFinalPos = pw->GetPos(); + m_infoNormalDim = m_infoActualDim = m_infoFinalDim = pw->GetDim(); AdjustDisplayInfo(m_infoActualPos, m_infoActualDim); } - if ( event.event == pw->RetEventMsgReduce() ) + if ( event.type == pw->GetEventTypeReduce() ) { if ( m_bInfoMinimized ) { @@ -234,14 +232,14 @@ bool CDisplayInfo::EventProcess(const Event &event) m_bInfoMaximized = false; } //? m_main->SetEditFull(m_bInfoMaximized); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) { pw->SetMaximized(m_bInfoMaximized); pw->SetMinimized(m_bInfoMinimized); } } - if ( event.event == pw->RetEventMsgFull() ) + if ( event.type == pw->GetEventTypeFull() ) { if ( m_bInfoMaximized ) { @@ -260,7 +258,7 @@ bool CDisplayInfo::EventProcess(const Event &event) m_bInfoMaximized = true; } //? m_main->SetEditFull(m_bInfoMaximized); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) { pw->SetMaximized(m_bInfoMaximized); @@ -299,31 +297,31 @@ bool CDisplayInfo::EventFrame(const Event &event) void CDisplayInfo::HyperUpdate() { - CWindow* pw; - CEdit* edit; - CButton* button; - bool bEnable; + Ui::CWindow* pw; + Ui::CEdit* edit; + Ui::CButton* button; + bool bEnable; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return; - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit == 0 ) return; - button = (CButton*)pw->SearchControl(EVENT_HYPER_HOME); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_HOME)); if ( button != 0 ) { bEnable = edit->HyperTest(EVENT_HYPER_HOME); button->SetState(STATE_ENABLE, bEnable); } - button = (CButton*)pw->SearchControl(EVENT_HYPER_PREV); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_PREV)); if ( button != 0 ) { bEnable = edit->HyperTest(EVENT_HYPER_PREV); button->SetState(STATE_ENABLE, bEnable); } - button = (CButton*)pw->SearchControl(EVENT_HYPER_NEXT); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_NEXT)); if ( button != 0 ) { bEnable = edit->HyperTest(EVENT_HYPER_NEXT); @@ -334,14 +332,14 @@ void CDisplayInfo::HyperUpdate() // Beginning of the display of information. -void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce) +void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluce) { - D3DLIGHT7 light; + Gfx::Light light; Math::Point pos, dim; - CWindow* pw; - CEdit* edit; - CButton* button; - CSlider* slider; + Ui::CWindow* pw; + Ui::CEdit* edit; + Ui::CButton* button; + Ui::CSlider* slider; CMotionToto* toto; m_index = index; @@ -349,10 +347,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce) //? CreateObjectsFile(); - m_bEditLock = m_main->RetEditLock(); + m_bEditLock = m_main->GetEditLock(); if ( m_bEditLock ) // edition running program? { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != 0 ) { pw->ClearState(STATE_ENABLE); // CStudio inactive @@ -361,10 +359,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce) m_main->SetEditLock(true, false); m_main->SetEditFull(false); - m_bInitPause = m_engine->RetPause(); + m_bInitPause = m_engine->GetPause(); m_engine->SetPause(true); - m_infoCamera = m_camera->RetType(); - m_camera->SetType(CAMERA_INFO); + m_infoCamera = m_camera->GetType(); + m_camera->SetType(Gfx::CAM_TYPE_INFO); pos = m_infoActualPos = m_infoFinalPos; dim = m_infoActualDim = m_infoFinalDim; @@ -383,10 +381,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce) edit->SetState(STATE_SHADOW); edit->SetMultiFont(true); edit->SetMaxChar(10000); - edit->SetFontType(FONT_COLOBOT); + edit->SetFontType(Gfx::FONT_COLOBOT); edit->SetSoluceMode(bSoluce); - edit->ReadText(filename); - edit->HyperHome(filename); + edit->ReadText(filename.c_str()); + edit->HyperHome(filename.c_str()); edit->SetEditCap(false); // just to see! edit->SetHiliteCap(false); edit->SetFocus(true); @@ -431,7 +429,7 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce) button->SetState(STATE_SHADOW); slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE); slider->SetState(STATE_SHADOW); - slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); + slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); button = pw->CreateButton(pos, dim, 61, EVENT_HYPER_COPY); button->SetState(STATE_SHADOW); HyperUpdate(); @@ -447,29 +445,27 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce) m_engine->SetDrawWorld(false); // doesn't draw anything in the interface m_engine->SetDrawFront(true); // toto draws on the interface - m_particule->SetFrameUpdate(SH_WORLD, false); // particles break into world + m_particle->SetFrameUpdate(Gfx::SH_WORLD, false); // particles break into world m_toto = SearchToto(); if ( m_toto != 0 ) { m_toto->SetDrawFront(true); - toto = (CMotionToto*)m_toto->RetMotion(); + toto = static_cast<CMotionToto*>(m_toto->GetMotion()); if ( toto != 0 ) { toto->StartDisplayInfo(); } } - ZeroMemory(&light, sizeof(light)); - light.dltType = D3DLIGHT_DIRECTIONAL; - light.dcvDiffuse.r = 1.0f; - light.dcvDiffuse.g = 1.0f; - light.dcvDiffuse.b = 1.0f; - light.dvDirection = D3DVECTOR(1.0f, 0.0f, 1.0f); + light.type = Gfx::LIGHT_DIRECTIONAL; + light.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f); + light.direction = Math::Vector(1.0f, 0.0f, 1.0f); + m_lightSuppl = m_light->CreateLight(); m_light->SetLight(m_lightSuppl, light); - m_light->SetLightExcluType(m_lightSuppl, TYPETERRAIN); + m_light->SetLightExcludeType(m_lightSuppl, Gfx::ENG_OBJTYPE_TERRAIN); } // Repositions all controls editing. @@ -483,31 +479,31 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim) CGroup* group; Math::Point pos, dim; - wpos.x = 50.0f/640.0f; - wpos.y = 30.0f/480.0f; - wdim.x = 540.0f/640.0f; - wdim.y = 420.0f/480.0f; + wpos.x = 50.0f / 640.0f; + wpos.y = 30.0f / 480.0f; + wdim.x = 540.0f / 640.0f; + wdim.y = 420.0f / 480.0f; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) { pw->SetPos(wpos); pw->SetDim(wdim); - wdim = pw->RetDim(); + wdim = pw->GetDim(); } - pos.x = (50.0f+10.0f)/640.0f; - pos.y = (30.0f+10.0f+24.0f+10.0f+324.0f-48.0f)/480.0f; - dim.x = 48.0f/640.0f; - dim.y = 48.0f/480.0f; - button = (CButton*)pw->SearchControl(EVENT_SATCOM_HUSTON); + pos.x = (50.0f + 10.0f) / 640.0f; + pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f - 48.0f) / 480.0f; + dim.x = 48.0f / 640.0f; + dim.y = 48.0f / 480.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_HUSTON)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.y -= (48.0f+4.0f)/480.0f; - button = (CButton*)pw->SearchControl(EVENT_SATCOM_SAT); + pos.y -= (48.0f + 4.0f) / 480.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SAT)); if ( button != 0 ) { button->SetPos(pos); @@ -520,136 +516,136 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim) //? button->SetPos(pos); //? button->SetDim(dim); //? } - pos.y -= (48.0f+4.0f)/480.0f; - button = (CButton*)pw->SearchControl(EVENT_SATCOM_LOADING); + pos.y -= (48.0f + 4.0f) / 480.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_LOADING)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.y -= (48.0f+4.0f)/480.0f; - button = (CButton*)pw->SearchControl(EVENT_SATCOM_PROG); + pos.y -= (48.0f + 4.0f) / 480.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_PROG)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.y -= (48.0f+4.0f)/480.0f; - button = (CButton*)pw->SearchControl(EVENT_SATCOM_SOLUCE); + pos.y -= (48.0f + 4.0f) / 480.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SOLUCE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x = (50.0f+10.0f+5.0f)/640.0f; - pos.y = (30.0f+10.0f+4.0f)/480.0f; - dim.x = (48.0f-10.0f)/640.0f; - dim.y = 24.0f/480.0f; - button = (CButton*)pw->SearchControl(EVENT_OBJECT_INFOOK); + pos.x = (50.0f + 10.0f + 5.0f) / 640.0f; + pos.y = (30.0f + 10.0f + 4.0f) / 480.0f; + dim.x = (48.0f - 10.0f) / 640.0f; + dim.y = 24.0f / 480.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_OBJECT_INFOOK)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x = (50.0f+10.0f+48.0f+10.0f)/640.0f; - pos.y = (30.0f+10.0f)/480.0f; - dim.x = 462.0f/640.0f; - dim.y = 358.0f/480.0f; - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f; + pos.y = (30.0f + 10.0f) / 480.0f; + dim.x = 462.0f / 640.0f; + dim.y = 358.0f / 480.0f; + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit != 0 ) { edit->SetPos(pos); edit->SetDim(dim); } - pos.x = (50.0f+10.0f+48.0f+10.0f)/640.0f; - pos.y = (30.0f+10.0f+358.0f+10.0f)/480.0f; - dim.x = 32.0f/640.0f; - dim.y = 32.0f/480.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_PREV); + pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f; + pos.y = (30.0f + 10.0f + 358.0f + 10.0f) / 480.0f; + dim.x = 32.0f / 640.0f; + dim.y = 32.0f / 480.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_PREV)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x += 35.0f/640.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_NEXT); + pos.x += 35.0f / 640.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_NEXT)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x += 35.0f/640.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_HOME); + pos.x += 35.0f / 640.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_HOME)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x += 50.0f/640.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE1); + pos.x += 50.0f / 640.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE1)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x += 35.0f/640.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE2); + pos.x += 35.0f / 640.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE2)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x += 35.0f/640.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE3); + pos.x += 35.0f / 640.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE3)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x += 35.0f/640.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE4); + pos.x += 35.0f / 640.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE4)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x += 35.0f/640.0f; - dim.x = 18.0f/640.0f; - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); + pos.x += 35.0f / 640.0f; + dim.x = 18.0f / 640.0f; + slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider != 0 ) { slider->SetPos(pos); slider->SetDim(dim); } - pos.x += 50.0f/640.0f; - dim.x = 32.0f/640.0f; - button = (CButton*)pw->SearchControl(EVENT_HYPER_COPY); + pos.x += 50.0f / 640.0f; + dim.x = 32.0f / 640.0f; + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_COPY)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } - pos.x = (50.0f+10.0f)/640.0f; - pos.y = (30.0f+10.0f+24.0f+10.0f+324.0f+6.0f)/480.0f; - dim.x = 48.0f/640.0f; - dim.y = 40.0f/480.0f; - group = (CGroup*)pw->SearchControl(EVENT_LABEL2); // symbol SatCom + pos.x = (50.0f + 10.0f) / 640.0f; + pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f + 6.0f) / 480.0f; + dim.x = 48.0f / 640.0f; + dim.y = 40.0f / 480.0f; + group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL2)); // symbol SatCom if ( group != 0 ) { group->SetPos(pos); group->SetDim(dim); } - pos.x = (50.0f+10.0f+14.0f)/640.0f; - pos.y = (30.0f+10.0f+6.0f)/480.0f; - dim.x = 20.0f/640.0f; - dim.y = 20.0f/480.0f; - group = (CGroup*)pw->SearchControl(EVENT_LABEL3); // symbol stand-by + pos.x = (50.0f + 10.0f + 14.0f) / 640.0f; + pos.y = (30.0f + 10.0f + 6.0f) / 480.0f; + dim.x = 20.0f / 640.0f; + dim.y = 20.0f / 480.0f; + group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL3)); // symbol stand-by if ( group != 0 ) { group->SetPos(pos); @@ -661,26 +657,26 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim) void CDisplayInfo::ChangeIndexButton(int index) { - CWindow* pw; - CEdit* edit; + Ui::CWindow* pw; + Ui::CEdit* edit; char* filename; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return; if ( m_index != -1 ) { - m_main->SetDisplayInfoPosition(m_index, RetPosition()); + m_main->SetDisplayInfoPosition(m_index, GetPosition()); } m_index = index; - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit != 0 ) { - filename = m_main->RetDisplayInfoName(m_index); + filename = m_main->GetDisplayInfoName(m_index); edit->ReadText(filename); edit->HyperHome(filename); - SetPosition(m_main->RetDisplayInfoPosition(m_index)); + SetPosition(m_main->GetDisplayInfoPosition(m_index)); } UpdateIndexButton(); @@ -690,10 +686,10 @@ void CDisplayInfo::ChangeIndexButton(int index) void CDisplayInfo::UpdateIndexButton() { - CWindow* pw; - CButton* button; - CGroup* group; - CEdit* edit; + Ui::CWindow* pw; + Ui::CButton* button; + Ui::CGroup* group; + Ui::CEdit* edit; Math::Point pos, dim; char* filename; char* loading; @@ -708,22 +704,22 @@ void CDisplayInfo::UpdateIndexButton() 4, // SATCOM_SOLUCE }; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return; - button = (CButton*)pw->SearchControl(EVENT_SATCOM_HUSTON); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_HUSTON)); if ( button != 0 ) { button->SetState(STATE_CHECK, m_index==SATCOM_HUSTON); - filename = m_main->RetDisplayInfoName(SATCOM_HUSTON); + filename = m_main->GetDisplayInfoName(SATCOM_HUSTON); button->SetState(STATE_VISIBLE, filename[0]!=0); } - button = (CButton*)pw->SearchControl(EVENT_SATCOM_SAT); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SAT)); if ( button != 0 ) { button->SetState(STATE_CHECK, m_index==SATCOM_SAT); - filename = m_main->RetDisplayInfoName(SATCOM_SAT); + filename = m_main->GetDisplayInfoName(SATCOM_SAT); button->SetState(STATE_VISIBLE, filename[0]!=0); } @@ -731,36 +727,36 @@ void CDisplayInfo::UpdateIndexButton() //? if ( button != 0 ) //? { //? button->SetState(STATE_CHECK, m_index==SATCOM_OBJECT); -//? filename = m_main->RetDisplayInfoName(SATCOM_OBJECT); +//? filename = m_main->GetDisplayInfoName(SATCOM_OBJECT); //? button->SetState(STATE_VISIBLE, filename[0]!=0); //? } loading = 0; - button = (CButton*)pw->SearchControl(EVENT_SATCOM_LOADING); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_LOADING)); if ( button != 0 ) { button->SetState(STATE_CHECK, m_index==SATCOM_LOADING); - loading = m_main->RetDisplayInfoName(SATCOM_LOADING); + loading = m_main->GetDisplayInfoName(SATCOM_LOADING); button->SetState(STATE_VISIBLE, loading[0]!=0); } - button = (CButton*)pw->SearchControl(EVENT_SATCOM_PROG); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_PROG)); if ( button != 0 ) { button->SetState(STATE_CHECK, m_index==SATCOM_PROG); - filename = m_main->RetDisplayInfoName(SATCOM_PROG); + filename = m_main->GetDisplayInfoName(SATCOM_PROG); button->SetState(STATE_VISIBLE, filename[0]!=0 && (m_index==SATCOM_LOADING||m_index==SATCOM_PROG||(loading!=0&&loading[0]==0))); } - button = (CButton*)pw->SearchControl(EVENT_SATCOM_SOLUCE); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SOLUCE)); if ( button != 0 ) { button->SetState(STATE_CHECK, m_index==SATCOM_SOLUCE); - filename = m_main->RetDisplayInfoName(SATCOM_SOLUCE); + filename = m_main->GetDisplayInfoName(SATCOM_SOLUCE); button->SetState(STATE_VISIBLE, filename[0]!=0 && m_bSoluce); } - group = (CGroup*)pw->SearchControl(EVENT_LABEL1); + group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL1)); if ( group != 0 ) { if ( m_index == -1 ) @@ -789,7 +785,7 @@ void CDisplayInfo::UpdateIndexButton() } #endif - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit != 0 ) { //? edit->SetHiliteCap(m_index==SATCOM_LOADING); @@ -803,20 +799,20 @@ void CDisplayInfo::UpdateIndexButton() void CDisplayInfo::UpdateCopyButton() { - CWindow* pw; - CButton* button; - CEdit* edit; + Ui::CWindow* pw; + Ui::CButton* button; + Ui::CEdit* edit; int c1, c2; //? if ( m_index != SATCOM_LOADING ) return; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return; - button = (CButton*)pw->SearchControl(EVENT_HYPER_COPY); + button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_COPY)); if ( button == 0 ) return; - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit == 0 ) return; edit->GetCursor(c1, c2); @@ -828,17 +824,17 @@ void CDisplayInfo::UpdateCopyButton() void CDisplayInfo::StopDisplayInfo() { - CWindow* pw; + Ui::CWindow* pw; CMotionToto* toto; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return; m_interface->DeleteControl(EVENT_WINDOW4); if ( m_bEditLock ) // editing running program? { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != 0 ) { pw->SetState(STATE_ENABLE); // CStudio operating @@ -853,13 +849,13 @@ void CDisplayInfo::StopDisplayInfo() m_engine->SetDrawWorld(true); // draws all on the interface m_engine->SetDrawFront(false); // draws nothing on the interface - m_particule->SetFrameUpdate(SH_WORLD, true); - m_particule->FlushParticule(SH_FRONT); - m_particule->FlushParticule(SH_INTERFACE); + m_particle->SetFrameUpdate(Gfx::SH_WORLD, true); + m_particle->FlushParticle(Gfx::SH_FRONT); + m_particle->FlushParticle(Gfx::SH_INTERFACE); if ( m_toto != 0 ) { - toto = (CMotionToto*)m_toto->RetMotion(); + toto = static_cast<CMotionToto*>(m_toto->GetMotion()); if ( toto != 0 ) { toto->StopDisplayInfo(); @@ -875,13 +871,13 @@ void CDisplayInfo::StopDisplayInfo() void CDisplayInfo::SetPosition(int pos) { - CWindow* pw; - CEdit* edit; + Ui::CWindow* pw; + Ui::CEdit* edit; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return; - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit == 0 ) return; edit->SetFirstLine(pos); @@ -889,18 +885,18 @@ void CDisplayInfo::SetPosition(int pos) // Returns the position. -int CDisplayInfo::RetPosition() +int CDisplayInfo::GetPosition() { - CWindow* pw; - CEdit* edit; + Ui::CWindow* pw; + Ui::CEdit* edit; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return 0; - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit == 0 ) return 0; - return edit->RetFirstLine(); + return edit->GetFirstLine(); } @@ -909,18 +905,18 @@ int CDisplayInfo::RetPosition() void CDisplayInfo::ViewDisplayInfo() { - CWindow* pw; - CEdit* edit; - POINT dim; + Ui::CWindow* pw; + Ui::CEdit* edit; + Math::IntPoint dim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == 0 ) return; - edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); + edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit == 0 ) return; - dim = m_engine->RetDim(); - edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f)); + dim = m_engine->GetWindowSize(); + edit->SetFontSize(m_main->GetFontSize()/(dim.x / 640.0f)); } // Returns the object human. @@ -933,10 +929,10 @@ CObject* CDisplayInfo::SearchToto() for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_TOTO ) { return pObj; @@ -995,7 +991,7 @@ void ObjectWrite(FILE* file, ObjectList list[], int i) strcat(line, res); strcat(line, "\\u "); - p = RetHelpFilename(list[i].type); + p = const_cast<char*>(GetHelpFilename(list[i].type)); if ( p[0] == 0 ) return; strcat(line, p+5); // skip "help\" p = strstr(line, ".txt"); @@ -1023,14 +1019,14 @@ void CDisplayInfo::CreateObjectsFile() bRadar = false; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetActif() ) continue; - if ( !pObj->RetSelectable() ) continue; - if ( pObj->RetProxyActivate() ) continue; + if ( !pObj->GetActif() ) continue; + if ( !pObj->GetSelectable() ) continue; + if ( pObj->GetProxyActivate() ) continue; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_NULL ) continue; if ( type == OBJECT_FIX ) continue; @@ -1217,3 +1213,4 @@ void CDisplayInfo::CreateObjectsFile() } +} diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h index 29677d4..2eabbf2 100644 --- a/src/ui/displayinfo.h +++ b/src/ui/displayinfo.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,73 +19,81 @@ #pragma once +#include <string> -#include "common/struct.h" -#include "old/camera.h" +#include "common/event.h" +#include "graphics/engine/camera.h" class CInstanceManager; -class CD3DEngine; -class CEvent; class CRobotMain; -class CCamera; -class CInterface; class CObject; -class CParticule; -class CLight; - - -class CDisplayInfo -{ -public: - CDisplayInfo(CInstanceManager* iMan); - ~CDisplayInfo(); - - bool EventProcess(const Event &event); - - void StartDisplayInfo(char *filename, int index, bool bSoluce); - void StopDisplayInfo(); - - void SetPosition(int pos); - int RetPosition(); - -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; - CD3DEngine* m_engine; - CEvent* m_event; - CRobotMain* m_main; - CCamera* m_camera; - CInterface* m_interface; - CParticule* m_particule; - CLight* m_light; - - bool m_bInfoMaximized; - bool m_bInfoMinimized; - - int m_index; - 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 CEventQueue; + +struct Event; + +namespace Gfx { + 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; + }; + + +} diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp index 9be81f4..7c60f8b 100644 --- a/src/ui/displaytext.cpp +++ b/src/ui/displaytext.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,46 +18,46 @@ // displaytext.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> +#include "ui/displaytext.h" -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/restext.h" -#include "common/iman.h" -#include "object/object.h" -#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" -#include "old/text.h" -#include "old/sound.h" -#include "ui/displaytext.h" +#include "common/event.h" +#include "common/iman.h" +#include "common/restext.h" + +#include "graphics/engine/engine.h" +#include "object/object.h" +#include "object/motion/motion.h" +#include "object/motion/motiontoto.h" + + + +namespace Ui { const float FONTSIZE = 12.0f; // Object's constructor. -CDisplayText::CDisplayText(CInstanceManager* iMan) +//CDisplayText::CDisplayText(CInstanceManager* iMan) +CDisplayText::CDisplayText() { int i; - m_iMan = iMan; +// m_iMan = iMan; + m_iMan = CInstanceManager::GetInstancePointer(); m_iMan->AddInstance(CLASS_DISPLAYTEXT, this); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); + 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++ ) { @@ -94,9 +95,9 @@ bool CDisplayText::EventProcess(const Event &event) { int i; - if ( m_engine->RetPause() ) return true; + if ( m_engine->GetPause() ) return true; - if ( event.event == EVENT_FRAME ) + if ( event.type == EVENT_FRAME ) { for ( i=0 ; i<MAXDTLINE ; i++ ) { @@ -124,9 +125,9 @@ void CDisplayText::DisplayError(Error err, CObject* pObj, float time) if ( pObj == 0 ) return; - pos = pObj->RetPosition(0); - h = RetIdealHeight(pObj); - d = RetIdealDist(pObj); + pos = pObj->GetPosition(0); + h = GetIdealHeight(pObj); + d = GetIdealDist(pObj); DisplayError(err, pos, h, d, time); } @@ -178,7 +179,7 @@ void CDisplayText::DisplayError(Error err, Math::Vector goal, float height, // Displays text. -void CDisplayText::DisplayText(char *text, CObject* pObj, +void CDisplayText::DisplayText(const char *text, CObject* pObj, float time, TextType type) { Math::Vector pos; @@ -186,23 +187,23 @@ void CDisplayText::DisplayText(char *text, CObject* pObj, if ( pObj == 0 ) return; - pos = pObj->RetPosition(0); - h = RetIdealHeight(pObj); - d = RetIdealDist(pObj); + pos = pObj->GetPosition(0); + h = GetIdealHeight(pObj); + d = GetIdealDist(pObj); DisplayText(text, pos, h, d, time, type); } // Displays text. -void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, +void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height, float dist, float time, TextType type) { CObject* toto; CMotion* motion; - CWindow* pw; - CButton* button; - CGroup* group; - CLabel* label; + Ui::CWindow* pw; + Ui::CButton* button; + Ui::CGroup* group; + Ui::CLabel* label; Math::Point pos, ppos, dim; Sound sound; float hLine, hBox; @@ -210,7 +211,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, if ( !m_bEnable ) return; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) { pos.x = 0.0f; @@ -221,12 +222,12 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, } hBox = 0.045f; - hLine = m_engine->RetText()->RetHeight(FONTSIZE, FONT_COLOBOT); + hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, FONTSIZE); nLine = 0; for ( i=0 ; i<MAXDTLINE ; i++ ) { - group = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i)); + group = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i))); if ( group == 0 ) break; nLine ++; } @@ -247,13 +248,13 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, if ( type == TT_WARNING ) icon = 10; // blue if ( type == TT_INFO ) icon = 8; // green if ( type == TT_MESSAGE ) icon = 11; // yellow - pw->CreateGroup(pos, dim, icon, EventMsg(EVENT_DT_GROUP0+nLine)); + pw->CreateGroup(pos, dim, icon, EventType(EVENT_DT_GROUP0+nLine)); pw->SetTrashEvent(false); ppos = pos; ppos.y -= hLine/2.0f; - label = pw->CreateLabel(ppos, dim, -1, EventMsg(EVENT_DT_LABEL0+nLine), text); + label = pw->CreateLabel(ppos, dim, -1, EventType(EVENT_DT_LABEL0+nLine), text); if ( label != 0 ) { label->SetFontSize(FONTSIZE); @@ -261,7 +262,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, dim.x = dim.y*0.75f; pos.x -= dim.x; - button = pw->CreateButton(pos, dim, 14, EventMsg(EVENT_DT_VISIT0+nLine)); + button = pw->CreateButton(pos, dim, 14, EventType(EVENT_DT_VISIT0+nLine)); if ( goal.x == 0.0f && goal.y == 0.0f && @@ -279,7 +280,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, toto = SearchToto(); if ( toto != 0 ) { - motion = toto->RetMotion(); + motion = toto->GetMotion(); if ( motion != 0 ) { if ( type == TT_ERROR ) @@ -324,18 +325,18 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, void CDisplayText::ClearText() { - CWindow* pw; + Ui::CWindow* pw; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); for ( i=0 ; i<MAXDTLINE ; i++ ) { if ( pw != 0 ) { - pw->DeleteControl(EventMsg(EVENT_DT_GROUP0+i)); - pw->DeleteControl(EventMsg(EVENT_DT_LABEL0+i)); - pw->DeleteControl(EventMsg(EVENT_DT_VISIT0+i)); + pw->DeleteControl(EventType(EVENT_DT_GROUP0+i)); + pw->DeleteControl(EventType(EVENT_DT_LABEL0+i)); + pw->DeleteControl(EventType(EVENT_DT_VISIT0+i)); } m_bExist[i] = false; m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f); @@ -349,32 +350,32 @@ void CDisplayText::ClearText() void CDisplayText::HideText(bool bHide) { - CWindow* pw; - CGroup* pg; - CLabel* pl; - CButton* pb; + Ui::CWindow* pw; + Ui::CGroup* pg; + Ui::CLabel* pl; + Ui::CButton* pb; int i; m_bHide = bHide; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return; for ( i=0 ; i<MAXDTLINE ; i++ ) { - pg = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i)); + pg = static_cast<Ui::CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i))); if ( pg != 0 ) { pg->SetState(STATE_VISIBLE, !bHide); } - pl = (CLabel* )pw->SearchControl(EventMsg(EVENT_DT_LABEL0+i)); + pl = static_cast<Ui::CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i))); if ( pl != 0 ) { pl->SetState(STATE_VISIBLE, !bHide); } - pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); + pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb != 0 ) { pb->SetState(STATE_VISIBLE, !bHide); @@ -386,20 +387,20 @@ void CDisplayText::HideText(bool bHide) bool CDisplayText::ClearLastText() { - CWindow *pw; - CButton *pb1, *pb2; - CGroup *pg1, *pg2; - CLabel *pl1, *pl2; + Ui::CWindow *pw; + Ui::CButton *pb1, *pb2; + Ui::CGroup *pg1, *pg2; + Ui::CLabel *pl1, *pl2; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return false; - pb2 = (CButton*)pw->SearchControl(EVENT_DT_VISIT0); + pb2 = static_cast<CButton*>(pw->SearchControl(EVENT_DT_VISIT0)); if ( pb2 == 0 ) return false; // same not of first-line - pg2 = (CGroup*)pw->SearchControl(EVENT_DT_GROUP0); + pg2 = static_cast<CGroup*>(pw->SearchControl(EVENT_DT_GROUP0)); if ( pg2 == 0 ) return false; - pl2 = (CLabel*)pw->SearchControl(EVENT_DT_LABEL0); + pl2 = static_cast<CLabel*>(pw->SearchControl(EVENT_DT_LABEL0)); if ( pl2 == 0 ) return false; for ( i=0 ; i<MAXDTLINE-1 ; i++ ) @@ -408,18 +409,18 @@ bool CDisplayText::ClearLastText() pg1 = pg2; pl1 = pl2; - pb2 = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i+1)); + pb2 = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i+1))); if ( pb2 == 0 ) break; - pg2 = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i+1)); + pg2 = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i+1))); if ( pg2 == 0 ) break; - pl2 = (CLabel*)pw->SearchControl(EventMsg(EVENT_DT_LABEL0+i+1)); + pl2 = static_cast<CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i+1))); if ( pl2 == 0 ) break; pb1->SetState(STATE_ENABLE, pb2->TestState(STATE_ENABLE)); - pg1->SetIcon(pg2->RetIcon()); - pl1->SetName(pl2->RetName()); + pg1->SetIcon(pg2->GetIcon()); + pl1->SetName(pl2->GetName()); m_time[i] = m_time[i+1]; m_visitGoal[i] = m_visitGoal[i+1]; @@ -427,9 +428,9 @@ bool CDisplayText::ClearLastText() m_visitHeight[i] = m_visitHeight[i+1]; // shift } - pw->DeleteControl(EventMsg(EVENT_DT_VISIT0+i)); - pw->DeleteControl(EventMsg(EVENT_DT_GROUP0+i)); - pw->DeleteControl(EventMsg(EVENT_DT_LABEL0+i)); + pw->DeleteControl(EventType(EVENT_DT_VISIT0+i)); + pw->DeleteControl(EventType(EVENT_DT_GROUP0+i)); + pw->DeleteControl(EventType(EVENT_DT_LABEL0+i)); m_bExist[i] = false; return true; } @@ -453,7 +454,7 @@ void CDisplayText::SetEnable(bool bEnable) // Returns the goal during a visit. -Math::Vector CDisplayText::RetVisitGoal(EventMsg event) +Math::Vector CDisplayText::GetVisitGoal(EventType event) { int i; @@ -464,7 +465,7 @@ Math::Vector CDisplayText::RetVisitGoal(EventMsg event) // Returns the distance during a visit. -float CDisplayText::RetVisitDist(EventMsg event) +float CDisplayText::GetVisitDist(EventType event) { int i; @@ -475,7 +476,7 @@ float CDisplayText::RetVisitDist(EventMsg event) // Returns the height on a visit. -float CDisplayText::RetVisitHeight(EventMsg event) +float CDisplayText::GetVisitHeight(EventType event) { int i; @@ -487,13 +488,13 @@ float CDisplayText::RetVisitHeight(EventMsg event) // Ranges from ideal visit for a given object. -float CDisplayText::RetIdealDist(CObject* pObj) +float CDisplayText::GetIdealDist(CObject* pObj) { ObjectType type; if ( pObj == 0 ) return 40.0f; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_PORTICO ) return 200.0f; if ( type == OBJECT_BASE ) return 200.0f; if ( type == OBJECT_NUCLEAR ) return 100.0f; @@ -506,13 +507,13 @@ float CDisplayText::RetIdealDist(CObject* pObj) // Returns the height of ideal visit for a given object. -float CDisplayText::RetIdealHeight(CObject* pObj) +float CDisplayText::GetIdealHeight(CObject* pObj) { ObjectType type; if ( pObj == 0 ) return 5.0f; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_DERRICK ) return 35.0f; if ( type == OBJECT_FACTORY ) return 22.0f; if ( type == OBJECT_REPAIR ) return 30.0f; @@ -537,16 +538,16 @@ float CDisplayText::RetIdealHeight(CObject* pObj) void CDisplayText::ClearVisit() { - CWindow* pw; - CButton* pb; + Ui::CWindow* pw; + Ui::CButton* pb; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return; for ( i=0 ; i<MAXDTLINE ; i++ ) { - pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); + pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb == 0 ) break; pb->SetIcon(14); // eyes } @@ -554,38 +555,38 @@ void CDisplayText::ClearVisit() // Puts a button in "visit". -void CDisplayText::SetVisit(EventMsg event) +void CDisplayText::SetVisit(EventType event) { - CWindow* pw; - CButton* pb; + Ui::CWindow* pw; + Ui::CButton* pb; int i; i = event-EVENT_DT_VISIT0; if ( i < 0 || i >= MAXDTLINE ) return; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return; - pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); + pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb == 0 ) return; pb->SetIcon(48); // > } // Indicates whether a button is set to "visit". -bool CDisplayText::IsVisit(EventMsg event) +bool CDisplayText::IsVisit(EventType event) { - CWindow* pw; - CButton* pb; + Ui::CWindow* pw; + Ui::CButton* pb; int i; i = event-EVENT_DT_VISIT0; if ( i < 0 || i >= MAXDTLINE ) return false; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return false; - pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); + pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb == 0 ) return false; - return (pb->RetIcon() == 48); // > ? + return (pb->GetIcon() == 48); // > ? } @@ -599,10 +600,10 @@ CObject* CDisplayText::SearchToto() for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_TOTO ) { return pObj; @@ -611,3 +612,4 @@ CObject* CDisplayText::SearchToto() return 0; } +} diff --git a/src/ui/displaytext.h b/src/ui/displaytext.h index c2eea98..5714cc5 100644 --- a/src/ui/displaytext.h +++ b/src/ui/displaytext.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 @@ -20,16 +21,24 @@ #include "common/event.h" -#include "common/misc.h" -#include "old/d3dengine.h" +#include "common/global.h" + +#include "sound/sound.h" + class CInstanceManager; -class CD3DEngine; -class CInterface; +//class CD3DEngine class CObject; class CSound; +namespace Gfx { + class CEngine; +} + +namespace Ui {; + +class CInterface; enum TextType { @@ -45,7 +54,8 @@ const int MAXDTLINE = 4; class CDisplayText { public: - CDisplayText(CInstanceManager* iMan); +// CDisplayText(CInstanceManager* iMan); + CDisplayText(); ~CDisplayText(); void DeleteObject(); @@ -54,33 +64,33 @@ public: void DisplayError(Error err, CObject* pObj, float time=10.0f); void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f); - void DisplayText(char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO); - void DisplayText(char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO); + void DisplayText(const char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO); + void DisplayText(const char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO); void HideText(bool bHide); void ClearText(); bool ClearLastText(); void SetDelay(float factor); void SetEnable(bool bEnable); - Math::Vector RetVisitGoal(EventMsg event); - float RetVisitDist(EventMsg event); - float RetVisitHeight(EventMsg event); + Math::Vector GetVisitGoal(EventType event); + float GetVisitDist(EventType event); + float GetVisitHeight(EventType event); - float RetIdealDist(CObject* pObj); - float RetIdealHeight(CObject* pObj); + float GetIdealDist(CObject* pObj); + float GetIdealHeight(CObject* pObj); void ClearVisit(); - void SetVisit(EventMsg event); - bool IsVisit(EventMsg event); + void SetVisit(EventType event); + bool IsVisit(EventType event); protected: CObject* SearchToto(); protected: CInstanceManager* m_iMan; - CD3DEngine* m_engine; - CInterface* m_interface; - CSound* m_sound; + Gfx::CEngine* m_engine; + Ui::CInterface* m_interface; + CSoundInterface* m_sound; bool m_bExist[MAXDTLINE]; float m_time[MAXDTLINE]; @@ -94,3 +104,4 @@ protected: }; +} diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index 58a8b7d..e2baae9 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.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 @@ -16,38 +17,28 @@ // edit.cpp - -#include <stdlib.h> -#include <stdio.h> -#include <ctype.h> -#include <windows.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/language.h" -#include "old/math3d.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/iman.h" -#include "common/restext.h" -#include "ui/scroll.h" -#include "old/text.h" +#include "app/app.h" #include "ui/edit.h" +#include <string.h> + +namespace Ui { const float MARGX = (5.0f/640.0f); const float MARGY = (5.0f/480.0f); const float MARGYS = (4.0f/480.0f); const float MARGY1 = (1.0f/480.0f); -const float DELAY_DBCLICK = 0.3f; // time limit for double-click -const float DELAY_SCROLL = 0.1f; // time limit for scroll -const float BIG_FONT = 1.6f; // expansion for \b; +//! time limit for double-click +const float DELAY_DBCLICK = 0.3f; +//! time limit for scroll +const float DELAY_SCROLL = 0.1f; +//! expansion for \b; +const float BIG_FONT = 1.6f; -// Indicates whether a character is a space. +//! Indicates whether a character is a space. bool IsSpace(int character) { @@ -56,20 +47,20 @@ bool IsSpace(int character) character == '\n' ); } -// Indicates whether a character is part of a word. +//! Indicates whether a character is part of a word. bool IsWord(int character) { char c; - c = tolower(RetNoAccent(character)); + c = tolower(GetNoAccent(character)); return ( (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '_' ); } -// Indicates whether a character is a word separator. +//! Indicates whether a character is a word separator. bool IsSep(int character) { @@ -79,19 +70,22 @@ bool IsSep(int character) -// Object's constructor. +//! Object's constructor. -CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan) +//CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan) +CEdit::CEdit () : CControl () { Math::Point pos; int i; m_maxChar = 100; - m_text = (char*)malloc(sizeof(char)*(m_maxChar+1)); - m_format = 0; + m_text = new char[m_maxChar+1]; + memset(m_text, 0, m_maxChar+1); m_len = 0; - m_fontType = FONT_COURIER; + memset(m_lineOffset, 0, sizeof(int) * EDITLINEMAX); + + m_fontType = Gfx::FONT_COURIER; m_scroll = 0; m_bEdit = true; m_bHilite = true; @@ -110,7 +104,7 @@ CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan) for ( i=0 ; i<EDITUNDOMAX ; i++ ) { - m_undo[i].text = 0; + m_undo[i].text = nullptr; } m_bUndoForce = true; m_undoOper = OPERUNDO_SPEC; @@ -127,23 +121,29 @@ CEdit::~CEdit() for ( i=0 ; i<EDITUNDOMAX ; i++ ) { delete m_undo[i].text; + m_undo[i].text = nullptr; + } + + if (m_text != nullptr) + { + delete[] m_text; + m_text = nullptr; } - delete m_text; - delete m_format; delete m_scroll; + m_scroll = nullptr; } // Creates a new editable line. -bool CEdit::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CEdit::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { CScroll* pc; Math::Point start, end; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - CControl::Create(pos, dim, icon, eventMsg); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); + CControl::Create(pos, dim, icon, eventType); m_len = 0; m_lineFirst = 0; @@ -162,8 +162,8 @@ bool CEdit::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg { m_bMulti = true; MoveAdjust(); // readjusts multi-line mode - m_scroll = new CScroll(m_iMan); - pc = (CScroll*)m_scroll; + m_scroll = new Ui::CScroll(); + pc = static_cast<CScroll*>(m_scroll); pc->Create(pos, dim, -1, EVENT_NULL); MoveAdjust(); } @@ -189,25 +189,25 @@ void CEdit::MoveAdjust() Math::Point pos, dim; float height; - m_lineDescent = m_engine->RetText()->RetDescent(m_fontSize, m_fontType); - m_lineAscent = m_engine->RetText()->RetAscent(m_fontSize, m_fontType); - m_lineHeight = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); + m_lineDescent = m_engine->GetText()->GetDescent(m_fontType, m_fontSize); + m_lineAscent = m_engine->GetText()->GetAscent(m_fontType, m_fontSize); + m_lineHeight = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); height = m_dim.y-(m_bMulti?MARGY*2.0f:MARGY1); - m_lineVisible = (int)(height/m_lineHeight); + m_lineVisible = static_cast<int>((height/m_lineHeight)); if ( m_scroll != 0 ) { if ( m_bInsideScroll ) { - pos.x = m_pos.x+m_dim.x-MARGX-SCROLL_WIDTH; - pos.y = m_pos.y+MARGYS; + pos.x = m_pos.x + m_dim.x - MARGX-SCROLL_WIDTH; + pos.y = m_pos.y + MARGYS; dim.x = SCROLL_WIDTH; - dim.y = m_dim.y-MARGYS*2.0f; + dim.y = m_dim.y - MARGYS*2.0f; } else { - pos.x = m_pos.x+m_dim.x-SCROLL_WIDTH; + pos.x = m_pos.x + m_dim.x - SCROLL_WIDTH; pos.y = m_pos.y; dim.x = SCROLL_WIDTH; dim.y = m_dim.y; @@ -238,16 +238,16 @@ bool CEdit::EventProcess(const Event &event) if ( (m_state & STATE_VISIBLE) == 0 ) return true; - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELUP && + if (event.type == EVENT_MOUSE_WHEEL && + event.mouseWheel.dir == WHEEL_UP && Detect(event.pos) ) { Scroll(m_lineFirst-3, true); return true; } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELDOWN && - Detect(event.pos) ) + if (event.type == EVENT_KEY_DOWN && + event.mouseWheel.dir == WHEEL_DOWN && + Detect(event.mouseWheel.pos) ) { Scroll(m_lineFirst+3, true); return true; @@ -255,30 +255,30 @@ bool CEdit::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.event == EVENT_FRAME ) + if ( event.type == EVENT_FRAME ) { m_time += event.rTime; m_timeBlink += event.rTime; } - if ( event.event == EVENT_MOUSEMOVE ) + if ( event.type == EVENT_MOUSE_MOVE ) { - if ( Detect(event.pos) && - event.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) + if ( Detect(event.mouseMove.pos) && + event.mouseMove.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) { if ( m_bEdit ) { - m_engine->SetMouseType(D3DMOUSEEDIT); + m_engine->SetMouseType(Gfx::ENG_MOUSE_EDIT); } else { - if ( IsLinkPos(event.pos) ) + if ( IsLinkPos(event.mouseMove.pos) ) { - m_engine->SetMouseType(D3DMOUSEHAND); + m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); } else { - m_engine->SetMouseType(D3DMOUSENORM); + m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); } } } @@ -288,109 +288,109 @@ bool CEdit::EventProcess(const Event &event) { m_scroll->EventProcess(event); - if ( event.event == m_scroll->RetEventMsg() ) + if ( event.type == m_scroll->GetEventType() ) { Scroll(); return true; } } - if ( event.event == EVENT_KEYDOWN && m_bFocus ) + if ( event.type == EVENT_KEY_DOWN && m_bFocus ) { - bShift = (event.keyState&KS_SHIFT); - bControl = (event.keyState&KS_CONTROL); + bShift = ( (event.trackedKeys & TRKEY_SHIFT) != 0 ); + bControl = ( (event.trackedKeys & TRKEY_CONTROL) != 0); - if ( (event.param == 'X' && !bShift && bControl) || - (event.param == VK_DELETE && bShift && !bControl) ) + if ( (event.key.unicode == 'X' && !bShift && bControl) || + (event.key.key == KEY(DELETE) && bShift && !bControl) ) { Cut(); return true; } - if ( (event.param == 'C' && !bShift && bControl) || - (event.param == VK_INSERT && !bShift && bControl) ) + if ( (event.key.unicode == 'C' && !bShift && bControl) || + (event.key.key == KEY(INSERT) && !bShift && bControl) ) { Copy(); return true; } - if ( (event.param == 'V' && !bShift && bControl) || - (event.param == VK_INSERT && bShift && !bControl) ) + if ( (event.key.unicode == 'V' && !bShift && bControl) || + (event.param == KEY(INSERT) && bShift && !bControl) ) { Paste(); return true; } - if ( event.param == 'A' && !bShift && bControl ) + if ( event.key.unicode == 'A' && !bShift && bControl ) { SetCursor(999999, 0); return true; } - if ( event.param == 'O' && !bShift && bControl ) + if ( event.key.unicode == 'O' && !bShift && bControl ) { - Event newEvent; - m_event->MakeEvent(newEvent, EVENT_STUDIO_OPEN); + Event newEvent(EVENT_STUDIO_OPEN); +// m_event->NewEvent(newEvent, EVENT_STUDIO_OPEN); m_event->AddEvent(newEvent); } - if ( event.param == 'S' && !bShift && bControl ) + if ( event.key.unicode == 'S' && !bShift && bControl ) { - Event newEvent; - m_event->MakeEvent(newEvent, EVENT_STUDIO_SAVE); + Event newEvent( EVENT_STUDIO_SAVE ); +// m_event->MakeEvent(newEvent, EVENT_STUDIO_SAVE); m_event->AddEvent(newEvent); } - if ( event.param == 'Z' && !bShift && bControl ) + if ( event.key.unicode == 'Z' && !bShift && bControl ) { Undo(); return true; } - if ( event.param == 'U' && !bShift && bControl ) + if ( event.key.unicode == 'U' && !bShift && bControl ) { if ( MinMaj(false) ) return true; } - if ( event.param == 'U' && bShift && bControl ) + if ( event.key.unicode == 'U' && bShift && bControl ) { if ( MinMaj(true) ) return true; } - if ( event.param == VK_TAB && !bShift && !bControl && !m_bAutoIndent ) + if ( event.key.key == KEY(TAB) && !bShift && !bControl && !m_bAutoIndent ) { if ( Shift(false) ) return true; } - if ( event.param == VK_TAB && bShift && !bControl && !m_bAutoIndent ) + if ( event.key.key == KEY(TAB) && bShift && !bControl && !m_bAutoIndent ) { if ( Shift(true) ) return true; } if ( m_bEdit ) { - if ( event.param == VK_LEFT ) + if ( event.key.key == KEY(LEFT) ) { MoveChar(-1, bControl, bShift); return true; } - if ( event.param == VK_RIGHT ) + if ( event.key.key == KEY(RIGHT) ) { MoveChar(1, bControl, bShift); return true; } - if ( event.param == VK_UP ) + if ( event.key.key == KEY(UP) ) { MoveLine(-1, bControl, bShift); return true; } - if ( event.param == VK_DOWN ) + if ( event.key.key == KEY(DOWN) ) { MoveLine(1, bControl, bShift); return true; } - if ( event.param == VK_PRIOR ) // PageUp ? + if ( event.key.key == KEY(PAGEUP) ) // PageUp ? { MoveLine(-(m_lineVisible-1), bControl, bShift); return true; } - if ( event.param == VK_NEXT ) // PageDown ? + if ( event.key.key == KEY(PAGEDOWN) ) // PageDown ? { MoveLine(m_lineVisible-1, bControl, bShift); return true; @@ -398,62 +398,62 @@ bool CEdit::EventProcess(const Event &event) } else { - if ( event.param == VK_LEFT || - event.param == VK_UP ) + if ( event.key.key == KEY(LEFT) || + event.key.key == KEY(UP) ) { Scroll(m_lineFirst-1, true); return true; } - if ( event.param == VK_RIGHT || - event.param == VK_DOWN ) + if ( event.key.key == KEY(RIGHT) || + event.key.key == KEY(DOWN) ) { Scroll(m_lineFirst+1, true); return true; } - if ( event.param == VK_PRIOR ) // PageUp ? + if ( event.key.key == KEY(PAGEUP) ) // PageUp ? { Scroll(m_lineFirst-(m_lineVisible-1), true); return true; } - if ( event.param == VK_NEXT ) // PageDown ? + if ( event.key.key == KEY(PAGEDOWN) ) // PageDown ? { Scroll(m_lineFirst+(m_lineVisible-1), true); return true; } } - if ( event.param == VK_HOME ) + if ( event.key.key == KEY(HOME) ) { MoveHome(bControl, bShift); return true; } - if ( event.param == VK_END ) + if ( event.key.key == KEY(END) ) { MoveEnd(bControl, bShift); return true; } - if ( event.param == VK_BACK ) // backspace ( <- ) ? + if ( event.key.key == KEY(BACKSPACE) ) // backspace ( <- ) ? { Delete(-1); SendModifEvent(); return true; } - if ( event.param == VK_DELETE ) + if ( event.key.key == KEY(DELETE) ) { Delete(1); SendModifEvent(); return true; } - if ( event.param == VK_RETURN ) + if ( event.key.key == KEY(RETURN) ) { Insert('\n'); SendModifEvent(); return true; } - if ( event.param == VK_TAB ) + if ( event.key.key == KEY(TAB) ) { Insert('\t'); SendModifEvent(); @@ -461,19 +461,19 @@ bool CEdit::EventProcess(const Event &event) } } - if ( event.event == EVENT_CHAR && m_bFocus ) + if ( event.type == EVENT_ACTIVE && m_bFocus ) { - if ( event.param >= ' ' && event.param <= 255 ) + if ( event.key.key >= ' ' && event.key.key <= 255 ) { - Insert((char)event.param); + Insert(static_cast<char>(event.key.key)); SendModifEvent(); return true; } } - if ( event.event == EVENT_FOCUS ) + if ( event.type == EVENT_ACTIVE ) { - if ( event.param == m_eventMsg ) + if ( event.param == m_eventType ) { m_bFocus = true; } @@ -483,7 +483,8 @@ bool CEdit::EventProcess(const Event &event) } } - if ( event.event == EVENT_LBUTTONDOWN ) + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1) { m_mouseFirstPos = event.pos; m_mouseLastPos = event.pos; @@ -502,18 +503,19 @@ bool CEdit::EventProcess(const Event &event) } } - if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) + if ( event.type == EVENT_MOUSE_MOVE && m_bCapture ) { m_mouseLastPos = event.pos; MouseMove(event.pos); } - if ( event.event == EVENT_FRAME && m_bCapture ) + if ( event.type == EVENT_FRAME && m_bCapture ) { MouseMove(m_mouseLastPos); } - if ( event.event == EVENT_LBUTTONUP ) + if ( event.type == EVENT_MOUSE_BUTTON_UP && + event.mouseButton.button == 1) { if ( Detect(event.pos) ) { @@ -541,9 +543,9 @@ bool CEdit::EventProcess(const Event &event) void CEdit::SendModifEvent() { - Event newEvent; + Event newEvent (m_eventType); - m_event->MakeEvent(newEvent, m_eventMsg); +// m_event->MakeEvent(newEvent, m_eventType); m_event->AddEvent(newEvent); } @@ -554,13 +556,13 @@ bool CEdit::IsLinkPos(Math::Point pos) { int i; - if ( m_format == 0 ) return false; + if ( m_format.size() == 0 ) return false; i = MouseDetect(pos); if ( i == -1 ) return false; if ( i >= m_len ) return false; - if ( (m_format[i]&COLOR_MASK) == COLOR_LINK ) return true; + if ( (m_format[i]& Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) return true; // TODO return false; } @@ -578,7 +580,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse) while ( i > 0 ) { - character = (unsigned char)m_text[i-1]; + character = static_cast<unsigned char>(m_text[i-1]); if ( !IsWord(character) ) break; i --; } @@ -586,7 +588,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse) while ( i < m_len ) { - character = (unsigned char)m_text[i]; + character = static_cast<unsigned char>(m_text[i]); if ( !IsWord(character) ) break; i ++; } @@ -634,14 +636,14 @@ void CEdit::MouseRelease(Math::Point mouse) if ( !m_bEdit ) { - if ( m_format != 0 && i < m_len && m_cursor1 == m_cursor2 && - (m_format[i]&COLOR_MASK) == COLOR_LINK ) + if ( m_format.size() > 0 && i < m_len && m_cursor1 == m_cursor2 && + (m_format[i]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) //TODO { rank = -1; for ( j=0 ; j<=i ; j++ ) { - if ( (j == 0 || (m_format[j-1]&COLOR_MASK) != COLOR_LINK) && - (m_format[j+0]&COLOR_MASK) == COLOR_LINK ) + if ( (j == 0 || (m_format[j-1]&Gfx::FONT_MASK_HIGHLIGHT) != Gfx::FONT_HIGHLIGHT_LINK) && // TODO check if good + (m_format[j+0]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) // TODO { rank ++; } @@ -694,14 +696,14 @@ int CEdit::MouseDetect(Math::Point mouse) if ( m_bAutoIndent ) { - indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType) - * m_engine->RetEditIndentValue(); + indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f) + * m_engine->GetEditIndentValue(); } pos.y = m_pos.y+m_dim.y-m_lineHeight-(m_bMulti?MARGY:MARGY1); for ( i=m_lineFirst ; i<m_lineTotal ; i++ ) { - bTitle = ( m_format != 0 && (m_format[m_lineOffset[i]]&TITLE_MASK) == TITLE_BIG ); + bTitle = ( m_format.size() > 0 && (m_format[m_lineOffset[i]]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ); if ( i >= m_lineFirst+m_lineVisible ) break; @@ -718,21 +720,26 @@ int CEdit::MouseDetect(Math::Point mouse) { len = m_lineOffset[i+1] - m_lineOffset[i]; - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { - c = m_engine->RetText()->Detect(m_text+m_lineOffset[i], - len, offset, m_fontSize, - m_fontStretch, m_fontType); +// c = m_engine->GetText()->Detect(m_text+m_lineOffset[i], +// len, offset, m_fontSize, +// m_fontStretch, m_fontType); + c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]), m_fontType, m_fontSize, offset); // TODO check if good } else { size = m_fontSize; - if ( bTitle ) size *= BIG_FONT; + if ( bTitle ) size *= Gfx::FONT_SIZE_BIG; - c = m_engine->RetText()->Detect(m_text+m_lineOffset[i], - m_format+m_lineOffset[i], - len, offset, size, - m_fontStretch); +// c = m_engine->GetText()->Detect(m_text+m_lineOffset[i], +// m_format+m_lineOffset[i], +// len, offset, size, +// m_fontStretch); + c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]), + std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()), + size, + offset); // TODO check if good } return m_lineOffset[i]+c; } @@ -754,7 +761,7 @@ void CEdit::HyperFlush() // Indicates which is the home page. -void CEdit::HyperHome(char *filename) +void CEdit::HyperHome(const char *filename) { HyperFlush(); HyperAdd(filename, 0); @@ -762,7 +769,7 @@ void CEdit::HyperHome(char *filename) // Performs a hyper jump through a link. -void CEdit::HyperJump(char *name, char *marker) +void CEdit::HyperJump(const char *name, const char *marker) { char filename[100]; char sMarker[100]; @@ -813,7 +820,7 @@ void CEdit::HyperJump(char *name, char *marker) // Adds text to the history of visited. -bool CEdit::HyperAdd(char *filename, int firstLine) +bool CEdit::HyperAdd(const char *filename, int firstLine) { if ( m_historyCurrent >= EDITHISTORYMAX-1 ) return false; @@ -827,7 +834,7 @@ bool CEdit::HyperAdd(char *filename, int firstLine) // Indicates whether a button EVENT_HYPER_ * is active or not. -bool CEdit::HyperTest(EventMsg event) +bool CEdit::HyperTest(EventType event) { if ( event == EVENT_HYPER_HOME ) { @@ -849,7 +856,7 @@ bool CEdit::HyperTest(EventMsg event) // Performs the action corresponding to a button EVENT_HYPER_ *. -bool CEdit::HyperGo(EventMsg event) +bool CEdit::HyperGo(EventType event) { if ( !HyperTest(event) ) return false; @@ -911,8 +918,8 @@ void CEdit::Draw() if ( m_bAutoIndent ) { - indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType) - * m_engine->RetEditIndentValue(); + indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f) + * m_engine->GetEditIndentValue(); } pos.y = m_pos.y+m_dim.y-m_lineHeight-(m_bMulti?MARGY:MARGY1); @@ -933,7 +940,7 @@ void CEdit::Draw() for ( j=0 ; j<m_lineIndent[i] ; j++ ) { char s = '\t'; // line | dotted - m_engine->RetText()->DrawText(&s, 1, pos, 1.0f, 1, m_fontSize, m_fontStretch, m_fontType, 0); + m_engine->GetText()->DrawText(&s, m_fontType, m_fontSize, pos, 1.0f, Gfx::TEXT_ALIGN_LEFT, 0); pos.x += indentLength; } } @@ -945,8 +952,8 @@ void CEdit::Draw() size = m_fontSize; // Headline \b;? - if ( beg+len < m_len && m_format != 0 && - (m_format[beg]&TITLE_MASK) == TITLE_BIG ) + if ( beg+len < m_len && m_format.size() > 0 && + (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) { start.x = ppos.x-MARGX; end.x = dim.x-MARGX*2.0f; @@ -959,8 +966,8 @@ void CEdit::Draw() } // As \t;? - if ( beg+len < m_len && m_format != 0 && - (m_format[beg]&TITLE_MASK) == TITLE_NORM ) + if ( beg+len < m_len && m_format.size() > 0 && + (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_NORM ) { start.x = ppos.x-MARGX; end.x = dim.x-MARGX*2.0f; @@ -970,8 +977,8 @@ void CEdit::Draw() } // Subtitle \s;? - if ( beg+len < m_len && m_format != 0 && - (m_format[beg]&TITLE_MASK) == TITLE_LITTLE ) + if ( beg+len < m_len && m_format.size() > 0 && + (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_LITTLE ) { start.x = ppos.x-MARGX; end.x = dim.x-MARGX*2.0f; @@ -981,8 +988,8 @@ void CEdit::Draw() } // Table \tab;? - if ( beg+len < m_len && m_format != 0 && - (m_format[beg]&COLOR_MASK) == COLOR_TABLE ) + if ( beg+len < m_len && m_format.size() > 0 && + (m_format[beg]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE ) { start.x = ppos.x-MARGX; end.x = dim.x-MARGX*2.0f; @@ -992,22 +999,22 @@ void CEdit::Draw() } // Image \image; ? - if ( beg+len < m_len && m_format != 0 && - (m_format[beg]&IMAGE_MASK) != 0 ) + if ( beg+len < m_len && m_format.size() > 0 && + (m_format[beg]&Gfx::FONT_MASK_IMAGE) != 0 ) { line = 1; while ( true ) // includes the image slices { if ( i+line >= m_lineTotal || i+line >= m_lineFirst+m_lineVisible || - (m_format[beg+line]&IMAGE_MASK) == 0 ) break; + (m_format[beg+line]&Gfx::FONT_MASK_IMAGE) == 0 ) break; line ++; } iIndex = m_text[beg]; // character = index in m_image pos.y -= m_lineHeight*(line-1); DrawImage(pos, m_image[iIndex].name, - m_image[iIndex].width*(m_fontSize/SMALLFONT), + m_image[iIndex].width*(m_fontSize/Gfx::FONT_SIZE_SMALL), m_image[iIndex].offset, m_image[iIndex].height*line, line); pos.y -= m_lineHeight; i += line-1; @@ -1021,20 +1028,24 @@ void CEdit::Draw() o1 = c1; if ( o1 < beg ) o1 = beg; o2 = c2; if ( o2 > beg+len ) o2 = beg+len; - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { - start.x = ppos.x+m_engine->RetText()->RetStringWidth(m_text+beg, o1-beg, size, m_fontStretch, m_fontType); - end.x = m_engine->RetText()->RetStringWidth(m_text+o1, o2-o1, size, m_fontStretch, m_fontType); + start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg), m_fontType, size); + end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1), m_fontType, size); } else { - start.x = ppos.x+m_engine->RetText()->RetStringWidth(m_text+beg, m_format+beg, o1-beg, size, m_fontStretch); - end.x = m_engine->RetText()->RetStringWidth(m_text+o1, m_format+o1, o2-o1, size, m_fontStretch); + start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg), + std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()), + size); + end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1), + std::vector<Gfx::FontMetaChar>(m_format.begin()+o1, m_format.end()), + size); } start.y = ppos.y-(m_bMulti?0.0f:MARGY1); end.y = m_lineHeight; - if ( m_format != 0 && (m_format[beg]&TITLE_MASK) == TITLE_BIG ) end.y *= BIG_FONT; + if ( m_format.size() > 0 && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT; DrawPart(start, end, 1); // plain yellow background } @@ -1049,13 +1060,19 @@ void CEdit::Draw() eol = 2; // square (eot) } if ( !m_bMulti || !m_bDisplaySpec ) eol = 0; - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { - m_engine->RetText()->DrawText(m_text+beg, len, ppos, m_dim.x, 1, size, m_fontStretch, m_fontType, eol); + m_engine->GetText()->DrawText(std::string(m_text+beg), m_fontType, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, eol); } else { - m_engine->RetText()->DrawText(m_text+beg, m_format+beg, len, ppos, m_dim.x, 1, size, m_fontStretch, eol); + m_engine->GetText()->DrawText(std::string(m_text+beg), + std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()), + size, + ppos, + m_dim.x, + Gfx::TEXT_ALIGN_LEFT, + eol); } pos.y -= m_lineHeight; @@ -1083,19 +1100,17 @@ void CEdit::Draw() len = m_cursor1 - m_lineOffset[i]; - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { - m_engine->RetText()->DimText(m_text+m_lineOffset[i], len, - pos, 1, size, - m_fontStretch, m_fontType, + m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]), m_fontType, + size, pos, Gfx::TEXT_ALIGN_LEFT, start, end); } else { - m_engine->RetText()->DimText(m_text+m_lineOffset[i], - m_format+m_lineOffset[i], - len, pos, 1, size, - m_fontStretch, + m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]), + std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()), + size, pos, Gfx::TEXT_ALIGN_LEFT, start, end); } @@ -1104,8 +1119,8 @@ void CEdit::Draw() } pos.y -= m_lineHeight; } - pos.x -= 1.0f/640.0f; - dim.x = 2.0f/640.0f; + pos.x -= 1.0f / 640.0f; + dim.x = 2.0f / 640.0f; dim.y = m_lineHeight; DrawPart(pos, dim, 0); // red } @@ -1118,19 +1133,19 @@ void CEdit::Draw() // Draw an image part. -void CEdit::DrawImage(Math::Point pos, char *name, float width, +void CEdit::DrawImage(Math::Point pos, const char *name, float width, float offset, float height, int nbLine) { Math::Point uv1, uv2, dim; float dp; char filename[100]; -//? sprintf(filename, "diagram\\%s.bmp", name); +//? sprintf(filename, "diagram\\%s.png", name); UserDir(filename, name, "diagram"); - strcat(filename, ".bmp"); + strcat(filename, ".png"); m_engine->SetTexture(filename); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 0.0f; uv2.x = 1.0f; @@ -1157,8 +1172,8 @@ void CEdit::DrawBack(Math::Point pos, Math::Point dim) if ( m_bGeneric ) return; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); if ( m_bMulti ) { @@ -1208,11 +1223,11 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon) float dp; #if _POLISH - m_engine->SetTexture("textp.tga"); + m_engine->SetTexture("textp.png"); #else - m_engine->SetTexture("text.tga"); + m_engine->SetTexture("text.png"); #endif - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = (16.0f/256.0f)*(icon%16); uv1.y = (240.0f/256.0f); @@ -1231,7 +1246,7 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon) // Give the text to edit. -void CEdit::SetText(char *text, bool bNew) +void CEdit::SetText(const char *text, bool bNew) { int i, j, font; bool bBOL; @@ -1241,7 +1256,7 @@ void CEdit::SetText(char *text, bool bNew) m_len = strlen(text); if ( m_len > m_maxChar ) m_len = m_maxChar; - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { if ( m_bAutoIndent ) { @@ -1291,32 +1306,32 @@ void CEdit::SetText(char *text, bool bNew) { if ( text[i+1] == 'n' ) // normal ? { - font &= ~FONT_MASK; - font |= FONT_COLOBOT; + font &= ~Gfx::FONT_MASK_FONT; + font |= Gfx::FONT_COLOBOT; i += 2; } else if ( text[i+1] == 'c' ) // cbot ? { - font &= ~FONT_MASK; - font |= FONT_COURIER; + font &= ~Gfx::FONT_MASK_FONT; + font |= Gfx::FONT_COURIER; i += 2; } else if ( text[i+1] == 'b' ) // big title ? { - font &= ~TITLE_MASK; - font |= TITLE_BIG; + font &= ~Gfx::FONT_MASK_TITLE; + font |= Gfx::FONT_TITLE_BIG; i += 2; } else if ( text[i+1] == 't' ) // title ? { - font &= ~TITLE_MASK; - font |= TITLE_NORM; + font &= ~Gfx::FONT_MASK_TITLE; + font |= Gfx::FONT_TITLE_NORM; i += 2; } else if ( text[i+1] == 's' ) // subtitle ? { - font &= ~TITLE_MASK; - font |= TITLE_LITTLE; + font &= ~Gfx::FONT_MASK_TITLE; + font |= Gfx::FONT_TITLE_LITTLE; i += 2; } } @@ -1326,7 +1341,7 @@ void CEdit::SetText(char *text, bool bNew) m_format[j] = font; j ++; - font &= ~TITLE_MASK; // reset title + font &= ~Gfx::FONT_MASK_TITLE; // reset title } } m_len = j; @@ -1342,7 +1357,7 @@ void CEdit::SetText(char *text, bool bNew) // Returns a pointer to the edited text. -char* CEdit::RetText() +char* CEdit::GetText() { m_text[m_len] = 0; return m_text; @@ -1361,7 +1376,7 @@ void CEdit::GetText(char *buffer, int max) // Returns the length of the text. -int CEdit::RetTextLength() +int CEdit::GetTextLength() { return m_len; } @@ -1371,7 +1386,7 @@ int CEdit::RetTextLength() // Returns a name in a command. // \x nom1 nom2 nom3; -void GetNameParam(char *cmd, int rank, char *buffer) +void GetNameParam(const char *cmd, int rank, char *buffer) { int i; @@ -1394,7 +1409,7 @@ void GetNameParam(char *cmd, int rank, char *buffer) // Returns a number of a command. // \x nom n1 n2; -int RetValueParam(char *cmd, int rank) +int GetValueParam(const char *cmd, int rank) { int n, i; @@ -1420,28 +1435,28 @@ void CEdit::FreeImage() for ( i=0 ; i<m_imageTotal ; i++ ) { -//? sprintf(filename, "diagram\\%s.bmp", m_image[i].name); +//? sprintf(filename, "diagram\\%s.png", m_image[i].name); UserDir(filename, m_image[i].name, "diagram"); - strcat(filename, ".bmp"); - m_engine->FreeTexture(filename); + strcat(filename, ".png"); + m_engine->DeleteTexture(filename); } } // Reads the texture of an image. -void CEdit::LoadImage(char *name) +void CEdit::LoadImage(const char *name) { char filename[100]; -//? sprintf(filename, "diagram\\%s.bmp", name); +//? sprintf(filename, "diagram\\%s.png", name); UserDir(filename, name, "diagram"); - strcat(filename, ".bmp"); + strcat(filename, ".png"); m_engine->LoadTexture(filename); } // Read from a text file. -bool CEdit::ReadText(char *filename, int addSize) +bool CEdit::ReadText(const char *filename, int addSize) { FILE *file = NULL; char *buffer; @@ -1449,7 +1464,7 @@ bool CEdit::ReadText(char *filename, int addSize) char iName[50]; char text[50]; float iWidth; - KeyRank key; + InputSlot slot; bool bInSoluce, bBOL; if ( filename[0] == 0 ) return false; @@ -1466,15 +1481,21 @@ bool CEdit::ReadText(char *filename, int addSize) m_cursor2 = 0; FreeImage(); - delete m_text; - m_text = (char*)malloc(sizeof(char)*(m_maxChar+1)); - buffer = (char*)malloc(sizeof(char)*(m_maxChar+1)); + + if (m_text != nullptr) + delete m_text; + + m_text = new char[m_maxChar+1]; + memset(m_text, 0, m_maxChar+1); + + buffer = new char[m_maxChar+1]; + memset(buffer, 0, m_maxChar+1); + fread(buffer, 1, len, file); - if ( m_format != 0 ) + if ( m_format.size() > 0 ) { - delete m_format; - m_format = (char*)malloc(sizeof(char)*m_maxChar); + m_format.clear(); } fclose(file); @@ -1496,7 +1517,7 @@ bool CEdit::ReadText(char *filename, int addSize) if ( !bBOL ) { m_text[j] = buffer[i]; - if ( m_format != 0 ) m_format[j] = font; + if ( m_format.size() > 0 ) m_format[j] = font; j ++; } i ++; @@ -1509,14 +1530,14 @@ bool CEdit::ReadText(char *filename, int addSize) { i ++; } - else if ( m_format != 0 && buffer[i] == '\\' && buffer[i+2] == ';' ) + else if ( m_format.size() > 0 && buffer[i] == '\\' && buffer[i+2] == ';' ) { if ( buffer[i+1] == 'n' ) // normal ? { if ( m_bSoluce || !bInSoluce ) { - font &= ~FONT_MASK; - font |= FONT_COLOBOT; + font &= ~Gfx::FONT_MASK_FONT; + font |= Gfx::FONT_COLOBOT; } i += 3; } @@ -1524,8 +1545,8 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~FONT_MASK; - font |= FONT_COURIER; + font &= ~Gfx::FONT_MASK_FONT; + font |= Gfx::FONT_COURIER; } i += 3; } @@ -1533,8 +1554,8 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~TITLE_MASK; - font |= TITLE_BIG; + font &= ~Gfx::FONT_MASK_TITLE; + font |= Gfx::FONT_TITLE_BIG; } i += 3; } @@ -1542,8 +1563,8 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~TITLE_MASK; - font |= TITLE_NORM; + font &= ~Gfx::FONT_MASK_TITLE; + font |= Gfx::FONT_TITLE_NORM; } i += 3; } @@ -1551,8 +1572,8 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~TITLE_MASK; - font |= TITLE_LITTLE; + font &= ~Gfx::FONT_MASK_TITLE; + font |= Gfx::FONT_TITLE_LITTLE; } i += 3; } @@ -1560,8 +1581,8 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~COLOR_MASK; - font |= COLOR_LINK; + font &= ~Gfx::FONT_MASK_HIGHLIGHT; + font |= Gfx::FONT_HIGHLIGHT_LINK; } i += 3; } @@ -1570,7 +1591,7 @@ bool CEdit::ReadText(char *filename, int addSize) i += 3; } } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \u marker name; ? buffer[i+1] == 'u' && buffer[i+2] == ' ' ) @@ -1583,11 +1604,11 @@ bool CEdit::ReadText(char *filename, int addSize) GetNameParam(buffer+i+3, 1, m_link[iLink].marker); iLink ++; } - font &= ~COLOR_MASK; + font &= ~Gfx::FONT_MASK_HIGHLIGHT; } i += strchr(buffer+i, ';')-(buffer+i)+1; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \m marker; ? buffer[i+1] == 'm' && buffer[i+2] == ' ' ) @@ -1603,7 +1624,7 @@ bool CEdit::ReadText(char *filename, int addSize) } i += strchr(buffer+i, ';')-(buffer+i)+1; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \image name lx ly; ? buffer[i+1] == 'i' && buffer[i+2] == 'm' && @@ -1620,27 +1641,27 @@ bool CEdit::ReadText(char *filename, int addSize) GetNameParam(buffer+i+7, 0, iName); #endif //? iWidth = m_lineHeight*RetValueParam(buffer+i+7, 1); - iWidth = (float)RetValueParam(buffer+i+7, 1); - iWidth *= m_engine->RetText()->RetHeight(SMALLFONT, FONT_COLOBOT); - iLines = RetValueParam(buffer+i+7, 2); + 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); // A part of image per line of text. for ( iCount=0 ; iCount<iLines ; iCount++ ) { strcpy(m_image[iIndex].name, iName); - m_image[iIndex].offset = (float)iCount/iLines; + m_image[iIndex].offset = static_cast<float>(iCount/iLines); m_image[iIndex].height = 1.0f/iLines; m_image[iIndex].width = iWidth*0.75f; - m_text[j] = (char)(iIndex++); // as an index into m_image - m_format[j] = (unsigned char)IMAGE_MASK; + m_text[j] = static_cast<char>(iIndex++); // as an index into m_image + m_format[j] = static_cast<unsigned char>(Gfx::FONT_MASK_IMAGE); j ++; } } i += strchr(buffer+i, ';')-(buffer+i)+1; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \button; ? buffer[i+1] == 'b' && buffer[i+2] == 'u' && @@ -1652,13 +1673,13 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - m_text[j] = RetValueParam(buffer+i+8, 0); - m_format[j] = font|FONT_BUTTON; + m_text[j] = GetValueParam(buffer+i+8, 0); + m_format[j] = font|Gfx::FONT_BUTTON; j ++; } i += strchr(buffer+i, ';')-(buffer+i)+1; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \token; ? buffer[i+1] == 't' && buffer[i+2] == 'o' && @@ -1669,12 +1690,12 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~COLOR_MASK; - font |= COLOR_TOKEN; + font &= ~Gfx::FONT_MASK_HIGHLIGHT; + font |= Gfx::FONT_HIGHLIGHT_TOKEN; } i += 7; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \type; ? buffer[i+1] == 't' && buffer[i+2] == 'y' && @@ -1684,12 +1705,12 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~COLOR_MASK; - font |= COLOR_TYPE; + font &= ~Gfx::FONT_MASK_HIGHLIGHT; + font |= Gfx::FONT_HIGHLIGHT_TYPE; } i += 6; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \const; ? buffer[i+1] == 'c' && buffer[i+2] == 'o' && @@ -1700,12 +1721,12 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~COLOR_MASK; - font |= COLOR_CONST; + font &= ~Gfx::FONT_MASK_HIGHLIGHT; + font |= Gfx::FONT_HIGHLIGHT_CONST; } i += 7; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \key; ? buffer[i+1] == 'k' && buffer[i+2] == 'e' && @@ -1714,12 +1735,12 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~COLOR_MASK; - font |= COLOR_KEY; + font &= ~Gfx::FONT_MASK_HIGHLIGHT; + font |= Gfx::FONT_HIGHLIGHT_KEY; } i += 5; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \tab; ? buffer[i+1] == 't' && buffer[i+2] == 'a' && @@ -1728,11 +1749,11 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font |= COLOR_TABLE; + font |= Gfx::FONT_HIGHLIGHT_TABLE; } i += 5; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \norm; ? buffer[i+1] == 'n' && buffer[i+2] == 'o' && @@ -1742,11 +1763,11 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - font &= ~COLOR_MASK; + font &= ~Gfx::FONT_MASK_HIGHLIGHT; } i += 6; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \begin soluce; ? buffer[i+1] == 'b' && buffer[i+2] == 's' && @@ -1755,7 +1776,7 @@ bool CEdit::ReadText(char *filename, int addSize) bInSoluce = true; i += 4; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \end soluce; ? buffer[i+1] == 'e' && buffer[i+2] == 's' && @@ -1764,7 +1785,7 @@ bool CEdit::ReadText(char *filename, int addSize) bInSoluce = false; i += 4; } - else if ( m_format != 0 && + else if ( m_format.size() > 0 && buffer[i+0] == '\\' && // \key name; ? buffer[i+1] == 'k' && buffer[i+2] == 'e' && @@ -1773,9 +1794,10 @@ bool CEdit::ReadText(char *filename, int addSize) { if ( m_bSoluce || !bInSoluce ) { - if ( SearchKey(buffer+i+5, key) ) + if ( SearchKey(buffer+i+5, slot) ) { - res = m_engine->RetKey(key, 0); + CRobotMain* main = CRobotMain::GetInstancePointer(); + res = main->GetInputBinding(slot).key; if ( res != 0 ) { if ( GetResource(RES_KEY, res, iName) ) @@ -1794,7 +1816,7 @@ bool CEdit::ReadText(char *filename, int addSize) m_format[j] = font; j ++; - res = m_engine->RetKey(key, 1); + res = main->GetInputBinding(slot).joy; if ( res != 0 ) { if ( GetResource(RES_KEY, res, iName) ) @@ -1804,7 +1826,7 @@ bool CEdit::ReadText(char *filename, int addSize) while ( text[n] != 0 ) { m_text[j] = text[n++]; - m_format[j] = font&~COLOR_MASK; + m_format[j] = font&~Gfx::FONT_MASK_HIGHLIGHT; j ++; } n = 0; @@ -1835,16 +1857,16 @@ bool CEdit::ReadText(char *filename, int addSize) if ( m_bSoluce || !bInSoluce ) { m_text[j] = buffer[i]; - if ( m_format != 0 ) m_format[j] = font; + if ( m_format.size() > 0 ) m_format[j] = font; j ++; } i ++; - font &= ~TITLE_MASK; // reset title + font &= ~Gfx::FONT_MASK_TITLE; // reset title - if ( (font&COLOR_MASK) == COLOR_TABLE ) + if ( (font&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE ) { - font &= ~COLOR_TABLE; + font &= ~Gfx::FONT_HIGHLIGHT_TABLE; } } } @@ -1860,7 +1882,7 @@ bool CEdit::ReadText(char *filename, int addSize) // Writes all the text in a file. -bool CEdit::WriteText(char *filename) +bool CEdit::WriteText(const char *filename) { FILE* file; char buffer[1000+20]; @@ -1927,16 +1949,18 @@ bool CEdit::WriteText(char *filename) void CEdit::SetMaxChar(int max) { - m_maxChar = max; FreeImage(); - delete m_text; - m_text = (char*)malloc(sizeof(char)*(m_maxChar+1)); - if ( m_format != 0 ) - { - delete m_format; - m_format = (char*)malloc(sizeof(char)*m_maxChar); - } + if (m_text != nullptr) + delete[] m_text; + + m_maxChar = max; + + m_text = new char[m_maxChar+1]; + memset(m_text, 0, m_maxChar+1); + + if (m_format.size() > 0) + m_format.clear(); m_len = 0; m_cursor1 = 0; @@ -1945,7 +1969,7 @@ void CEdit::SetMaxChar(int max) UndoFlush(); } -int CEdit::RetMaxChar() +int CEdit::GetMaxChar() { return m_maxChar; } @@ -1958,7 +1982,7 @@ void CEdit::SetEditCap(bool bMode) m_bEdit = bMode; } -bool CEdit::RetEditCap() +bool CEdit::GetEditCap() { return m_bEdit; } @@ -1970,7 +1994,7 @@ void CEdit::SetHiliteCap(bool bEnable) m_bHilite = bEnable; } -bool CEdit::RetHiliteCap() +bool CEdit::GetHiliteCap() { return m_bHilite; } @@ -1982,7 +2006,7 @@ void CEdit::SetInsideScroll(bool bInside) m_bInsideScroll = bInside; } -bool CEdit::RetInsideScroll() +bool CEdit::GetInsideScroll() { return m_bInsideScroll; } @@ -1994,7 +2018,7 @@ void CEdit::SetSoluceMode(bool bSoluce) m_bSoluce = bSoluce; } -bool CEdit::RetSoluceMode() +bool CEdit::GetSoluceMode() { return m_bSoluce; } @@ -2006,7 +2030,7 @@ void CEdit::SetGenericMode(bool bGeneric) m_bGeneric = bGeneric; } -bool CEdit::RetGenericMode() +bool CEdit::GetGenericMode() { return m_bGeneric; } @@ -2019,7 +2043,7 @@ void CEdit::SetAutoIndent(bool bMode) m_bAutoIndent = bMode; } -bool CEdit::RetAutoIndent() +bool CEdit::GetAutoIndent() { return m_bAutoIndent; } @@ -2057,7 +2081,7 @@ void CEdit::SetFirstLine(int rank) // Returns the first displayed line. -int CEdit::RetFirstLine() +int CEdit::GetFirstLine() { if ( m_historyTotal > 0 ) { @@ -2091,7 +2115,7 @@ void CEdit::ShowSelect() cursor2 = m_cursor1; } - line = RetCursorLine(cursor2); + line = GetCursorLine(cursor2); if ( line >= m_lineFirst+m_lineVisible ) { line -= m_lineVisible-1; @@ -2099,7 +2123,7 @@ void CEdit::ShowSelect() Scroll(line, false); } - line = RetCursorLine(cursor1); + line = GetCursorLine(cursor1); if ( line < m_lineFirst ) { Scroll(line, false); @@ -2114,7 +2138,7 @@ void CEdit::SetDisplaySpec(bool bDisplay) m_bDisplaySpec = bDisplay; } -bool CEdit::RetDisplaySpec() +bool CEdit::GetDisplaySpec() { return m_bDisplaySpec; } @@ -2124,22 +2148,12 @@ bool CEdit::RetDisplaySpec() void CEdit::SetMultiFont(bool bMulti) { - if ( bMulti ) - { - delete m_format; - m_format = (char*)malloc(sizeof(char)*m_maxChar); - memset(m_format, 0, m_maxChar); - } - else - { - delete m_format; - m_format = 0; - } + m_format.clear(); } -bool CEdit::RetMultiFont() +bool CEdit::GetMultiFont() { - return ( m_format != 0 ); + return ( m_format.size() > 0 ); } @@ -2161,9 +2175,9 @@ void CEdit::Scroll() if ( m_scroll != 0 ) { - value = m_scroll->RetVisibleValue(); + value = m_scroll->GetVisibleValue(); value *= m_lineTotal-m_lineVisible; - Scroll((int)(value+0.5f), true); + Scroll(static_cast<int>(value+0.5f), true); } } @@ -2181,7 +2195,7 @@ void CEdit::Scroll(int pos, bool bAdjustCursor) if ( max < 0 ) max = 0; if ( m_lineFirst > max ) m_lineFirst = max; - line = RetCursorLine(m_cursor1); + line = GetCursorLine(m_cursor1); if ( bAdjustCursor && m_bEdit ) { @@ -2277,19 +2291,19 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsSpace(character) ) break; m_cursor1 --; } if ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( IsSpace(character) ) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsSpace(character) ) break; m_cursor1 --; } @@ -2298,7 +2312,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsWord(character) ) break; m_cursor1 --; } @@ -2307,7 +2321,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 > 0 ) { - character = (unsigned char)m_text[m_cursor1-1]; + character = static_cast<unsigned char>(m_text[m_cursor1-1]); if ( !IsSep(character) ) break; m_cursor1 --; } @@ -2327,12 +2341,12 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { if ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( IsSpace(character) ) { while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsSpace(character) ) break; m_cursor1 ++; } @@ -2341,7 +2355,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsWord(character) ) break; m_cursor1 ++; } @@ -2350,7 +2364,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) { while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsSep(character) ) break; m_cursor1 ++; } @@ -2359,7 +2373,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) while ( m_cursor1 < m_len ) { - character = (unsigned char)m_text[m_cursor1]; + character = static_cast<unsigned char>(m_text[m_cursor1]); if ( !IsSpace(character) ) break; m_cursor1 ++; } @@ -2418,29 +2432,28 @@ void CEdit::MoveLine(int move, bool bWord, bool bSelect) } } - line = RetCursorLine(m_cursor1); + line = GetCursorLine(m_cursor1); column = m_column; if ( m_bAutoIndent ) { - indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType) - * m_engine->RetEditIndentValue(); + indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f) + * m_engine->GetEditIndentValue(); column -= indentLength*m_lineIndent[line]; } - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { - c = m_engine->RetText()->Detect(m_text+m_lineOffset[line], - m_lineOffset[line+1]-m_lineOffset[line], - column, m_fontSize, - m_fontStretch, m_fontType); + c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]), + m_fontType, m_fontSize, + m_lineOffset[line+1]-m_lineOffset[line]); } else { - c = m_engine->RetText()->Detect(m_text+m_lineOffset[line], - m_format+m_lineOffset[line], - m_lineOffset[line+1]-m_lineOffset[line], - column, m_fontSize, m_fontStretch); + c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]), + std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()), + m_fontSize, + m_lineOffset[line+1]-m_lineOffset[line]); } m_cursor1 = m_lineOffset[line]+c; @@ -2457,32 +2470,27 @@ void CEdit::ColumnFix() float indentLength; int line; - line = RetCursorLine(m_cursor1); + line = GetCursorLine(m_cursor1); - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { - m_column = m_engine->RetText()->RetStringWidth - ( - m_text+m_lineOffset[line], - m_cursor1-m_lineOffset[line], - m_fontSize, m_fontStretch, m_fontType - ); + m_column = m_engine->GetText()->GetStringWidth( + std::string(m_text+m_lineOffset[line]), + m_fontType, m_fontSize); } else { - m_column = m_engine->RetText()->RetStringWidth - ( - m_text+m_lineOffset[line], - m_format+m_lineOffset[line], - m_cursor1-m_lineOffset[line], - m_fontSize, m_fontStretch + m_column = m_engine->GetText()->GetStringWidth( + std::string(m_text+m_lineOffset[line]), + std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()), + m_fontSize ); } if ( m_bAutoIndent ) { - indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType) - * m_engine->RetEditIndentValue(); + indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f) + * m_engine->GetEditIndentValue(); m_column += indentLength*m_lineIndent[line]; } } @@ -2490,9 +2498,9 @@ void CEdit::ColumnFix() // Cut the selected characters or entire line. -bool CEdit::Cut() +bool CEdit::Cut() // TODO MS Windows allocations { - HGLOBAL hg; + /* HGLOBAL hg; char* text; char c; int c1, c2, start, len, i, j; @@ -2565,15 +2573,15 @@ bool CEdit::Cut() DeleteOne(0); // deletes the selected characters Justif(); ColumnFix(); - SendModifEvent(); + SendModifEvent();*/ return true; } // Copy the selected characters or entire line. -bool CEdit::Copy() +bool CEdit::Copy() // TODO { - HGLOBAL hg; + /* HGLOBAL hg; char* text; char c; int c1, c2, start, len, i, j; @@ -2637,15 +2645,15 @@ bool CEdit::Copy() return false; } CloseClipboard(); - +*/ return true; } // Paste the contents of the notebook. -bool CEdit::Paste() +bool CEdit::Paste() // TODO { - HANDLE h; + /*HANDLE h; char c; char* p; @@ -2683,7 +2691,7 @@ bool CEdit::Paste() Justif(); ColumnFix(); - SendModifEvent(); + SendModifEvent();*/ return true; } @@ -2777,7 +2785,7 @@ void CEdit::Insert(char character) #endif else if ( character == '\t' ) { - for ( i=0 ; i<m_engine->RetEditIndentValue() ; i++ ) + for ( i=0 ; i<m_engine->GetEditIndentValue() ; i++ ) { InsertOne(' '); } @@ -2816,7 +2824,7 @@ void CEdit::InsertOne(char character) { m_text[i] = m_text[i-1]; // shoot - if ( m_format != 0 ) + if ( m_format.size() > 0 ) { m_format[i] = m_format[i-1]; // shoot } @@ -2826,7 +2834,7 @@ void CEdit::InsertOne(char character) m_text[m_cursor1] = character; - if ( m_format != 0 ) + if ( m_format.size() > 0 ) { m_format[m_cursor1] = 0; } @@ -2877,7 +2885,7 @@ void CEdit::DeleteOne(int dir) { m_text[i] = m_text[i+hole]; - if ( m_format != 0 ) + if ( m_format.size() > 0 ) { m_format[i] = m_format[i+hole]; } @@ -3024,9 +3032,9 @@ bool CEdit::MinMaj(bool bMaj) for ( i=c1 ; i<c2 ; i++ ) { - character = (unsigned char)m_text[i]; - if ( bMaj ) character = RetToUpper(character); - else character = RetToLower(character); + character = static_cast<unsigned char>(m_text[i]); + if ( bMaj ) character = GetToUpper(character); + else character = GetToLower(character); m_text[i] = character; } @@ -3053,8 +3061,8 @@ void CEdit::Justif() if ( m_bAutoIndent ) { - indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType) - * m_engine->RetEditIndentValue(); + indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f) + * m_engine->GetEditIndentValue(); } bString = bRem = false; @@ -3069,31 +3077,34 @@ void CEdit::Justif() width -= indentLength*m_lineIndent[m_lineTotal-1]; } - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { - i += m_engine->RetText()->Justif(m_text+i, m_len-i, width, - m_fontSize, m_fontStretch, - m_fontType); + // TODO check if good + + i += m_engine->GetText()->Justify(m_text+i, m_fontType, + m_fontSize, width); } else { size = m_fontSize; - if ( (m_format[i]&TITLE_MASK) == TITLE_BIG ) // headline? + if ( (m_format[i]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) // headline? { size *= BIG_FONT; bDual = true; } - if ( (m_format[i]&IMAGE_MASK) != 0 ) // image part? + if ( (m_format[i]&Gfx::FONT_MASK_IMAGE) != 0 ) // image part? { i ++; // jumps just a character (index in m_image) } else { - i += m_engine->RetText()->Justif(m_text+i, m_format+i, - m_len-i, width, - size, m_fontStretch); + // TODO check if good + i += m_engine->GetText()->Justify(std::string(m_text+i), + std::vector<Gfx::FontMetaChar>(m_format.begin()+i, m_format.end()), + size, + width); } } @@ -3149,7 +3160,7 @@ void CEdit::Justif() { if ( m_bEdit ) { - line = RetCursorLine(m_cursor1); + line = GetCursorLine(m_cursor1); if ( line < m_lineFirst ) { m_lineFirst = line; @@ -3175,13 +3186,13 @@ void CEdit::Justif() } else { - value = (float)m_lineVisible/m_lineTotal; + value = static_cast<float>(m_lineVisible/m_lineTotal); m_scroll->SetVisibleRatio(value); - value = (float)m_lineFirst/(m_lineTotal-m_lineVisible); + value = static_cast<float>(m_lineFirst/(m_lineTotal-m_lineVisible)); m_scroll->SetVisibleValue(value); - value = (float)1.0f/(m_lineTotal-m_lineVisible); + value = static_cast<float>(1.0f/(m_lineTotal-m_lineVisible)); m_scroll->SetArrowStep(value); } } @@ -3191,7 +3202,7 @@ void CEdit::Justif() // Returns the rank of the line where the cursor is located. -int CEdit::RetCursorLine(int cursor) +int CEdit::GetCursorLine(int cursor) { int line, i; @@ -3216,7 +3227,7 @@ void CEdit::UndoFlush() for ( i=0 ; i<EDITUNDOMAX ; i++ ) { delete m_undo[i].text; - m_undo[i].text = 0; + m_undo[i].text = nullptr; } m_bUndoForce = true; @@ -3238,6 +3249,7 @@ void CEdit::UndoMemorize(OperUndo oper) m_undoOper = oper; delete m_undo[EDITUNDOMAX-1].text; + m_undo[EDITUNDOMAX-1].text = nullptr; for ( i=EDITUNDOMAX-1 ; i>=1 ; i-- ) { @@ -3246,7 +3258,7 @@ void CEdit::UndoMemorize(OperUndo oper) len = m_len; if ( len == 0 ) len ++; - m_undo[0].text = (char*)malloc(sizeof(char)*(len+1)); + m_undo[0].text = new char[len+1]; memcpy(m_undo[0].text, m_text, m_len); m_undo[0].len = m_len; @@ -3261,7 +3273,7 @@ bool CEdit::UndoRecall() { int i; - if ( m_undo[0].text == 0 ) return false; + if ( m_undo[0].text == nullptr ) return false; m_len = m_undo[0].len; memcpy(m_text, m_undo[0].text, m_len); @@ -3274,7 +3286,7 @@ bool CEdit::UndoRecall() { m_undo[i] = m_undo[i+1]; } - m_undo[EDITUNDOMAX-1].text = 0; + m_undo[EDITUNDOMAX-1].text = nullptr; m_bUndoForce = true; Justif(); @@ -3288,11 +3300,11 @@ bool CEdit::UndoRecall() bool CEdit::ClearFormat() { - if ( m_format == 0 ) + if ( m_format.size() == 0 ) { SetMultiFont(true); } - memset(m_format, m_fontType, m_len); + m_format.clear(); return true; } @@ -3303,7 +3315,7 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format) { int i; - if ( m_format == 0 ) return false; + if ( m_format.size() == 0 ) return false; for ( i=cursor1 ; i<cursor2 ; i++ ) { @@ -3314,3 +3326,4 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format) } +} diff --git a/src/ui/edit.h b/src/ui/edit.h index dbd94d1..c5c6cf6 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.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 @@ -14,69 +15,107 @@ // * 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.h + +/** + * \file ui/edit.h + * \brief CEdit class + */ #pragma once -#include "common/struct.h" #include "ui/control.h" +#include "ui/scroll.h" + +#include "graphics/engine/engine.h" +#include "graphics/engine/text.h" + +#include "common/event.h" +#include "common/misc.h" +#include "common/iman.h" +#include "common/restext.h" + +#include <vector> + -class CD3DEngine; -class CScroll; +namespace Ui { -const int EDITSTUDIOMAX = 20000; // maximum number of characters in CBOT edit -const int EDITLINEMAX = 1000; // maximum total number of lines -const int EDITIMAGEMAX = 50; // maximum total number of lines with images -const int EDITLINKMAX = 100; // maximum number of links -const int EDITHISTORYMAX = 50; // max number of levels preserves +//! maximum number of characters in CBOT edit +const int EDITSTUDIOMAX = 20000; +//! maximum total number of lines +const int EDITLINEMAX = 1000; +//! maximum total number of lines with images +const int EDITIMAGEMAX = 50; +//! maximum number of links +const int EDITLINKMAX = 100; +//! max number of levels preserves +const int EDITHISTORYMAX = 50; -const int EDITUNDOMAX = 20; // max number of successive undo +//! max number of successive undo +const int EDITUNDOMAX = 20; struct EditUndo { - char* text; // original text - int len; // length of the text - int cursor1; // offset cursor - int cursor2; // offset cursor - int lineFirst; // the first line displayed. + //! original text + char* text; + //! length of the text + int len; + //! offset cursor + int cursor1; + //! offset cursor + int cursor2; + //! the first line displayed. + int lineFirst; }; enum OperUndo { - OPERUNDO_SPEC = 0, // special operation - OPERUNDO_INSERT = 1, // inserting characters - OPERUNDO_DELETE = 2, // deleting characters + //! special operation + OPERUNDO_SPEC = 0, + //! inserting characters + OPERUNDO_INSERT = 1, + //! deleting characters + OPERUNDO_DELETE = 2, }; struct ImageLine { - char name[40]; // name of the image (without diagram \) - float offset; // vertical offset (v texture) - float height; // height of the part (dv texture) - float width; // width + //! name of the image (without diagram \) + char name[40]; + //! vertical offset (v texture) + float offset; + //! height of the part (dv texture) + float height; + //! width + float width; }; struct HyperLink { - char name[40]; // text file name (without help \) - char marker[20]; // name of the marker + //! text file name (without help \) + char name[40]; + //! name of the marker + char marker[20]; }; struct HyperMarker { - char name[20]; // name of the marker - int pos; // position in the text + //! name of the marker + char name[20]; + //! position in the text + int pos; }; struct HyperHistory { - char filename[50]; // full file name text - int firstLine; // rank of the first displayed line + //! full file name text + char filename[50]; + //! rank of the first displayed line + int firstLine; }; @@ -85,10 +124,11 @@ struct HyperHistory class CEdit : public CControl { public: - CEdit(CInstanceManager* iMan); +// 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 eventType); void SetPos(Math::Point pos); void SetDim(Math::Point dim); @@ -96,47 +136,47 @@ public: bool EventProcess(const Event &event); void Draw(); - void SetText(char *text, bool bNew=true); + void SetText(const char *text, bool bNew=true); void GetText(char *buffer, int max); - char* RetText(); - int RetTextLength(); + char* GetText(); + int GetTextLength(); - bool ReadText(char *filename, int addSize=0); - bool WriteText(char *filename); + bool ReadText(const char *filename, int addSize=0); + bool WriteText(const char *filename); void SetMaxChar(int max); - int RetMaxChar(); + int GetMaxChar(); void SetEditCap(bool bMode); - bool RetEditCap(); + bool GetEditCap(); void SetHiliteCap(bool bEnable); - bool RetHiliteCap(); + bool GetHiliteCap(); void SetInsideScroll(bool bInside); - bool RetInsideScroll(); + bool GetInsideScroll(); void SetSoluceMode(bool bSoluce); - bool RetSoluceMode(); + bool GetSoluceMode(); void SetGenericMode(bool bGeneric); - bool RetGenericMode(); + bool GetGenericMode(); void SetAutoIndent(bool bMode); - bool RetAutoIndent(); + bool GetAutoIndent(); void SetCursor(int cursor1, int cursor2); void GetCursor(int &cursor1, int &cursor2); void SetFirstLine(int rank); - int RetFirstLine(); + int GetFirstLine(); void ShowSelect(); void SetDisplaySpec(bool bDisplay); - bool RetDisplaySpec(); + bool GetDisplaySpec(); void SetMultiFont(bool bMulti); - bool RetMultiFont(); + bool GetMultiFont(); bool Cut(); bool Copy(); @@ -144,9 +184,9 @@ public: bool Undo(); void HyperFlush(); - void HyperHome(char *filename); - bool HyperTest(EventMsg event); - bool HyperGo(EventMsg event); + void HyperHome(const char *filename); + bool HyperTest(EventType event); + bool HyperGo(EventType event); void SetFontSize(float size); @@ -163,15 +203,15 @@ protected: int MouseDetect(Math::Point mouse); void MoveAdjust(); - void HyperJump(char *name, char *marker); - bool HyperAdd(char *filename, int firstLine); + void HyperJump(const char *name, const char *marker); + bool HyperAdd(const char *filename, int firstLine); - void DrawImage(Math::Point pos, char *name, float width, float offset, float height, int nbLine); + void DrawImage(Math::Point pos, const char *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(char *name); + void LoadImage(const char *name); void Scroll(int pos, bool bAdjustCursor); void Scroll(); void MoveChar(int move, bool bWord, bool bSelect); @@ -189,7 +229,7 @@ protected: bool Shift(bool bLeft); bool MinMaj(bool bMaj); void Justif(); - int RetCursorLine(int cursor); + int GetCursorLine(int cursor); void UndoFlush(); void UndoMemorize(OperUndo oper); @@ -200,7 +240,7 @@ protected: int m_maxChar; // max length of the buffer m_text char* m_text; // text (without zero terminator) - char* 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 @@ -246,3 +286,4 @@ protected: }; +} diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 71e06f2..3b819b3 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.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,13 +18,6 @@ // editvalue.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/math3d.h" #include "common/event.h" #include "common/misc.h" #include "common/iman.h" @@ -33,10 +27,11 @@ - +namespace Ui { // Object's constructor. -CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan) +//CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan) +CEditValue::CEditValue() : CControl () { m_edit = 0; m_buttonUp = 0; @@ -60,28 +55,28 @@ CEditValue::~CEditValue() // Creates a new button. -bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - CEdit* pe; - CButton* pc; + Ui::CEdit* pe; + Ui::CButton* pc; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - CControl::Create(pos, dim, icon, eventMsg); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); + CControl::Create(pos, dim, icon, eventType); GlintDelete(); - m_edit = new CEdit(m_iMan); - pe = (CEdit*)m_edit; + m_edit = new Ui::CEdit(); + pe = static_cast<Ui::CEdit*>(m_edit); pe->Create(pos, dim, 0, EVENT_NULL); pe->SetMaxChar(4); - m_buttonUp = new CButton(m_iMan); - pc = (CButton*)m_buttonUp; + m_buttonUp = new Ui::CButton(); + pc = static_cast<Ui::CButton*>(m_buttonUp); pc->Create(pos, dim, 49, EVENT_NULL); // ^ pc->SetRepeat(true); - m_buttonDown = new CButton(m_iMan); - pc = (CButton*)m_buttonDown; + m_buttonDown = new Ui::CButton(); + pc = static_cast<Ui::CButton*>(m_buttonDown); pc->Create(pos, dim, 50, EVENT_NULL); // v pc->SetRepeat(true); @@ -151,11 +146,11 @@ bool CEditValue::EventProcess(const Event &event) if ( m_edit != 0 ) { - if ( m_edit->RetFocus() && - event.event == EVENT_KEYDOWN && - event.param == VK_RETURN ) + if ( m_edit->GetFocus() && + event.type == EVENT_KEY_DOWN && + event.key.key == KEY(RETURN) ) { - value = RetValue(); + value = GetValue(); if ( value > m_maxValue ) value = m_maxValue; if ( value < m_minValue ) value = m_minValue; SetValue(value, true); @@ -163,19 +158,18 @@ bool CEditValue::EventProcess(const Event &event) } if ( !m_edit->EventProcess(event) ) return false; - if ( event.event == m_edit->RetEventMsg() ) + if ( event.type == m_edit->GetEventType() ) { - Event newEvent; - m_event->MakeEvent(newEvent, m_eventMsg); + Event newEvent(m_eventType); m_event->AddEvent(newEvent); } } if ( m_buttonUp != 0 ) { - if ( event.event == m_buttonUp->RetEventMsg() ) + if ( event.type == m_buttonUp->GetEventType() ) { - value = RetValue()+m_stepValue; + value = GetValue()+m_stepValue; if ( value > m_maxValue ) value = m_maxValue; SetValue(value, true); HiliteValue(event); @@ -185,9 +179,9 @@ bool CEditValue::EventProcess(const Event &event) if ( m_buttonDown != 0 ) { - if ( event.event == m_buttonDown->RetEventMsg() ) + if ( event.type == m_buttonDown->GetEventType() ) { - value = RetValue()-m_stepValue; + value = GetValue()-m_stepValue; if ( value < m_minValue ) value = m_minValue; SetValue(value, true); HiliteValue(event); @@ -195,20 +189,20 @@ bool CEditValue::EventProcess(const Event &event) if ( !m_buttonDown->EventProcess(event) ) return false; } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELUP && - Detect(event.pos) ) + if (event.type == EVENT_MOUSE_WHEEL && + event.mouseWheel.dir == WHEEL_UP && + Detect(event.mouseWheel.pos)) { - value = RetValue()+m_stepValue; + value = GetValue()+m_stepValue; if ( value > m_maxValue ) value = m_maxValue; SetValue(value, true); HiliteValue(event); } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELDOWN && - Detect(event.pos) ) + if ( event.type == EVENT_KEY_DOWN && + event.mouseWheel.dir == WHEEL_DOWN && + Detect(event.mouseWheel.pos)) { - value = RetValue()-m_stepValue; + value = GetValue()-m_stepValue; if ( value < m_minValue ) value = m_minValue; SetValue(value, true); HiliteValue(event); @@ -226,7 +220,7 @@ void CEditValue::HiliteValue(const Event &event) if ( m_edit == 0 ) return; - pos = m_edit->RetTextLength(); + pos = m_edit->GetTextLength(); if ( m_type == EVT_100 && pos > 0 ) { pos --; // not only selects the "%" @@ -236,8 +230,9 @@ void CEditValue::HiliteValue(const Event &event) m_edit->SetFocus(true); Event newEvent = event; - newEvent.event = EVENT_FOCUS; - newEvent.param = m_edit->RetEventMsg(); + newEvent.type = EVENT_ACTIVE; + newEvent.active.gain = true; // TODO not much pretty sure about it + newEvent.param = m_edit->GetEventType(); m_event->AddEvent(newEvent); // defocus the other objects } @@ -275,7 +270,7 @@ void CEditValue::SetType(EditValueType type) m_type = type; } -EditValueType CEditValue::RetType() +EditValueType CEditValue::GetType() { return m_type; } @@ -293,7 +288,7 @@ void CEditValue::SetValue(float value, bool bSendMessage) if ( m_type == EVT_INT ) { - sprintf(text, "%d", (int)value); + sprintf(text, "%d", static_cast<int>(value)); } if ( m_type == EVT_FLOAT ) @@ -303,37 +298,36 @@ void CEditValue::SetValue(float value, bool bSendMessage) if ( m_type == EVT_100 ) { - sprintf(text, "%d%%", (int)(value*100.0f)); + sprintf(text, "%d%%", static_cast<int>(value*100.0f)); } m_edit->SetText(text); if ( bSendMessage ) { - Event newEvent; - m_event->MakeEvent(newEvent, m_eventMsg); + Event newEvent(m_eventType); m_event->AddEvent(newEvent); } } // Return the edited value. -float CEditValue::RetValue() +float CEditValue::GetValue() { char text[100]; - float value; + float value = 0.0f; - if ( m_edit == 0 ) 0.0f; - - m_edit->GetText(text, 100); - sscanf(text, "%f", &value); - - if ( m_type == EVT_100 ) + if ( m_edit != 0 ) { - value = (value+0.5f)/100.0f; - if ( value < 0.01f ) value = 0.0f; // less than 1%? - } + m_edit->GetText(text, 100); + sscanf(text, "%f", &value); + if ( m_type == EVT_100 ) + { + value = (value+0.5f)/100.0f; + if ( value < 0.01f ) value = 0.0f; // less than 1%? + } + } return value; } @@ -345,7 +339,7 @@ void CEditValue::SetStepValue(float value) m_stepValue = value; } -float CEditValue::RetStepValue() +float CEditValue::GetStepValue() { return m_stepValue; } @@ -358,7 +352,7 @@ void CEditValue::SetMinValue(float value) m_minValue = value; } -float CEditValue::RetMinValue() +float CEditValue::GetMinValue() { return m_minValue; } @@ -371,8 +365,9 @@ void CEditValue::SetMaxValue(float value) m_maxValue = value; } -float CEditValue::RetMaxValue() +float CEditValue::GetMaxValue() { return m_maxValue; } +} diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h index dbb7812..1469b69 100644 --- a/src/ui/editvalue.h +++ b/src/ui/editvalue.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 @@ -22,6 +23,12 @@ #include "ui/control.h" +namespace Gfx{ +class CEngine; +} + +namespace Ui { + enum EditValueType { EVT_INT = 1, // integer @@ -29,8 +36,6 @@ enum EditValueType EVT_100 = 3, // percent (0 .. 1) }; - -class CD3DEngine; class CEdit; class CButton; @@ -39,10 +44,11 @@ class CButton; class CEditValue : public CControl { public: - CEditValue(CInstanceManager* iMan); +// 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 eventType); void SetPos(Math::Point pos); void SetDim(Math::Point dim); @@ -51,33 +57,32 @@ public: void Draw(); void SetType(EditValueType type); - EditValueType RetType(); + EditValueType GetType(); void SetValue(float value, bool bSendMessage=false); - float RetValue(); + float GetValue(); void SetStepValue(float value); - float RetStepValue(); + float GetStepValue(); void SetMinValue(float value); - float RetMinValue(); + float GetMinValue(); void SetMaxValue(float value); - float RetMaxValue(); + float GetMaxValue(); protected: void MoveAdjust(); void HiliteValue(const Event &event); -protected: - CEdit* m_edit; - CButton* m_buttonUp; - CButton* m_buttonDown; - - EditValueType m_type; - float m_stepValue; - float m_minValue; - float m_maxValue; + Ui::CEdit* m_edit; + Ui::CButton* m_buttonUp; + Ui::CButton* m_buttonDown; + EditValueType m_type; + float m_stepValue; + float m_minValue; + float m_maxValue; }; +} diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index 13cd4f7..b1ce31d 100644 --- a/src/ui/gauge.cpp +++ b/src/ui/gauge.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,24 +18,14 @@ // gauge.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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/gauge.h" - - +namespace Ui { // Object's constructor. -CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan) +//CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan) +CGauge::CGauge() : CControl() { m_level = 0.0f; } @@ -48,11 +39,11 @@ CGauge::~CGauge() // Creates a new button. -bool CGauge::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CGauge::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); return true; } @@ -63,12 +54,12 @@ bool CGauge::EventProcess(const Event &event) { CControl::EventProcess(event); - if ( event.event == EVENT_LBUTTONDOWN ) + if ( event.type == EVENT_MOUSE_BUTTON_DOWN ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } @@ -87,48 +78,48 @@ void CGauge::Draw() if ( (m_state & STATE_VISIBLE) == 0 ) return; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); dp = 0.5f/256.0f; pos = m_pos; dim = m_dim; - uv1.x = 32.0f/256.0f; - uv1.y = 32.0f/256.0f; - uv2.x = 64.0f/256.0f; - uv2.y = 64.0f/256.0f; + uv1.x = 32.0f / 256.0f; + uv1.y = 32.0f / 256.0f; + uv2.x = 64.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 10.0f/640.0f; - corner.y = 10.0f/480.0f; + corner.x = 10.0f / 640.0f; + corner.y = 10.0f / 480.0f; DrawIcon(pos, dim, uv1, uv2, corner, 8.0f/256.0f); - pos.x += 3.0f/640.0f; - pos.y += 3.0f/480.0f; - dim.x -= 6.0f/640.0f; - dim.y -= 6.0f/480.0f; + pos.x += 3.0f / 640.0f; + pos.y += 3.0f / 480.0f; + dim.x -= 6.0f / 640.0f; + dim.y -= 6.0f / 480.0f; if ( m_dim.x < m_dim.y ) // vertical gauge? { - uv1.x = (0.0f+m_icon*16.0f)/256.0f; - uv2.x = uv1.x+16.0f/256.0f; - uv1.y = 128.0f/256.0f+m_level*(64.0f/256.0f); - uv2.y = uv1.y+64.0f/256.0f; + uv1.x = (0.0f + m_icon * 16.0f) / 256.0f; + uv2.x = uv1.x + 16.0f / 256.0f; + uv1.y = 128.0f/256.0f + m_level * (64.0f/256.0f); + uv2.y = uv1.y + 64.0f/256.0f; } else // horizontal gauge? { - uv1.x = 64.0f/256.0f+(1.0f-m_level)*(64.0f/256.0f); - uv2.x = uv1.x+64.0f/256.0f; - uv1.y = (128.0f+m_icon*16.0f)/256.0f; - uv2.y = uv1.y+16.0f/256.0f; + uv1.x = 64.0f/256.0f + (1.0f - m_level) * (64.0f/256.0f); + uv2.x = uv1.x + 64.0f/256.0f; + uv1.y = (128.0f + m_icon*16.0f) / 256.0f; + uv2.y = uv1.y + 16.0f/256.0f; } uv1.x += dp; @@ -149,9 +140,10 @@ void CGauge::SetLevel(float level) m_level = level; } -float CGauge::RetLevel() +float CGauge::GetLevel() { return m_level; } +} diff --git a/src/ui/gauge.h b/src/ui/gauge.h index bdc85ff..f4a008f 100644 --- a/src/ui/gauge.h +++ b/src/ui/gauge.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,33 +19,37 @@ #pragma once +#include "graphics/engine/engine.h" -#include "ui/control.h" - +#include "common/event.h" +#include "common/misc.h" -class CD3DEngine; +#include "ui/control.h" +namespace Ui { class CGauge : public CControl { -public: - CGauge(CInstanceManager* iMan); - virtual ~CGauge(); + public: + // CGauge(CInstanceManager* iMan); + CGauge(); + virtual ~CGauge(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + 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 SetLevel(float level); - float RetLevel(); + void SetLevel(float level); + float GetLevel(); -protected: + protected: -protected: - float m_level; + protected: + float m_level; }; +} diff --git a/src/ui/group.cpp b/src/ui/group.cpp index 06290e4..67369d9 100644 --- a/src/ui/group.cpp +++ b/src/ui/group.cpp @@ -16,26 +16,24 @@ // group.cpp +#include "ui/group.h" -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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 "ui/group.h" +#include "graphics/engine/engine.h" +#include <stdio.h> +#include <string.h> +namespace Ui { // Object's constructor. -CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan) +//CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan) +CGroup::CGroup() : CControl() { } @@ -48,18 +46,18 @@ CGroup::~CGroup() // Creates a new button. -bool CGroup::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CGroup::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); if ( icon == -1 ) { char name[100]; char* p; - GetResource(RES_EVENT, eventMsg, name); + GetResource(RES_EVENT, eventType, name); p = strchr(name, '\\'); if ( p != 0 ) *p = 0; SetName(name); @@ -92,16 +90,16 @@ void CGroup::Draw() DrawShadow(m_pos, m_dim); } - dp = 0.5f/256.0f; + dp = 0.5f / 256.0f; if ( m_icon == 0 ) // hollow frame? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 160.0f/256.0f; - uv1.y = 192.0f/256.0f; // u-v texture - uv2.x = 192.0f/256.0f; - uv2.y = 224.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 160.0f / 256.0f; + uv1.y = 192.0f / 256.0f; // u-v texture + uv2.x = 192.0f / 256.0f; + uv2.y = 224.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -112,12 +110,12 @@ void CGroup::Draw() } if ( m_icon == 1 ) // orange solid opaque? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 104.0f/256.0f; - uv1.y = 48.0f/256.0f; - uv2.x = 112.0f/256.0f; - uv2.y = 64.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 104.0f / 256.0f; + uv1.y = 48.0f / 256.0f; + uv2.x = 112.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -126,12 +124,12 @@ void CGroup::Draw() } if ( m_icon == 2 ) // orange degrade -> transparent? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 112.0f/256.0f; - uv1.y = 48.0f/256.0f; - uv2.x = 120.0f/256.0f; - uv2.y = 64.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 112.0f / 256.0f; + uv1.y = 48.0f / 256.0f; + uv2.x = 120.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -140,12 +138,12 @@ void CGroup::Draw() } if ( m_icon == 3 ) // transparent gradient -> gray? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 120.0f/256.0f; - uv1.y = 48.0f/256.0f; - uv2.x = 128.0f/256.0f; - uv2.y = 64.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 120.0f / 256.0f; + uv1.y = 48.0f / 256.0f; + uv2.x = 128.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -154,12 +152,12 @@ void CGroup::Draw() } if ( m_icon == 4 ) // degrade blue corner? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 192.0f/256.0f; - uv1.y = 128.0f/256.0f; - uv2.x = 224.0f/256.0f; - uv2.y = 160.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 192.0f / 256.0f; + uv1.y = 128.0f / 256.0f; + uv2.x = 224.0f / 256.0f; + uv2.y = 160.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -168,12 +166,12 @@ void CGroup::Draw() } if ( m_icon == 5 ) // degrade orange corner? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 224.0f/256.0f; - uv1.y = 128.0f/256.0f; - uv2.x = 256.0f/256.0f; - uv2.y = 160.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 224.0f / 256.0f; + uv1.y = 128.0f / 256.0f; + uv2.x = 256.0f / 256.0f; + uv2.y = 160.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -182,28 +180,28 @@ void CGroup::Draw() } if ( m_icon == 6 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); - uv1.x = 0.0f/256.0f; // brown transparent - uv1.y = 75.0f/256.0f; - uv2.x = 64.0f/256.0f; - uv2.y = 128.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); + uv1.x = 0.0f / 256.0f; // brown transparent + uv1.y = 75.0f / 256.0f; + uv2.x = 64.0f / 256.0f; + uv2.y = 128.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 4.0f/640.0f; - corner.y = 4.0f/480.0f; + corner.x = 4.0f / 640.0f; + corner.y = 4.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f); } if ( m_icon == 7 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 64.0f/256.0f; - uv1.y = 0.0f/256.0f; - uv2.x = 96.0f/256.0f; - uv2.y = 32.0f/256.0f; + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 64.0f / 256.0f; + uv1.y = 0.0f / 256.0f; + uv2.x = 96.0f / 256.0f; + uv2.y = 32.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -212,12 +210,12 @@ void CGroup::Draw() } if ( m_icon == 8 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); - uv1.x = 64.0f/256.0f; // green transparent - uv1.y = 160.0f/256.0f; - uv2.x = 160.0f/256.0f; - uv2.y = 176.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); + uv1.x = 64.0f / 256.0f; // green transparent + uv1.y = 160.0f / 256.0f; + uv2.x = 160.0f / 256.0f; + uv2.y = 176.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -226,9 +224,9 @@ void CGroup::Draw() } if ( m_icon == 9 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); - uv1.x = 64.0f/256.0f; // red transparent + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); + uv1.x = 64.0f / 256.0f; // red transparent uv1.y = 176.0f/256.0f; uv2.x = 160.0f/256.0f; uv2.y = 192.0f/256.0f; @@ -240,12 +238,12 @@ void CGroup::Draw() } if ( m_icon == 10 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); - uv1.x = 64.0f/256.0f; // blue transparent - uv1.y = 192.0f/256.0f; - uv2.x = 160.0f/256.0f; - uv2.y = 208.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); + uv1.x = 64.0f / 256.0f; // blue transparent + uv1.y = 192.0f / 256.0f; + uv2.x = 160.0f / 256.0f; + uv2.y = 208.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -254,12 +252,12 @@ void CGroup::Draw() } if ( m_icon == 11 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); - uv1.x = 64.0f/256.0f; // yellow transparent - uv1.y = 224.0f/256.0f; - uv2.x = 160.0f/256.0f; - uv2.y = 240.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); + uv1.x = 64.0f / 256.0f; // yellow transparent + uv1.y = 224.0f / 256.0f; + uv2.x = 160.0f / 256.0f; + uv2.y = 240.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -268,17 +266,17 @@ void CGroup::Draw() } if ( m_icon == 12 ) // viewfinder cross? { - dim.x = m_dim.x/2.0f; - dim.y = m_dim.y/2.0f; + dim.x = m_dim.x / 2.0f; + dim.y = m_dim.y / 2.0f; - m_engine->SetTexture("mouse.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("mouse.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); pos.x = m_pos.x-m_dim.x/300.0f; pos.y = m_pos.y+m_dim.y/300.0f+dim.y; - uv1.x = 0.5f/256.0f; - uv1.y = 192.5f/256.0f; - uv2.x = 63.5f/256.0f; - uv2.y = 255.5f/256.0f; + uv1.x = 0.5f / 256.0f; + uv1.y = 192.5f / 256.0f; + uv2.x = 63.5f / 256.0f; + uv2.y = 255.5f / 256.0f; DrawIcon(pos, dim, uv1, uv2); // ul pos.x += dim.x; Math::Swap(uv1.x, uv2.x); @@ -290,13 +288,13 @@ void CGroup::Draw() Math::Swap(uv1.x, uv2.x); DrawIcon(pos, dim, uv1, uv2); // dl - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); pos.x = m_pos.x+m_dim.x/300.0f; pos.y = m_pos.y-m_dim.y/300.0f+dim.y; - uv1.x = 64.5f/256.0f; - uv1.y = 192.5f/256.0f; - uv2.x = 127.5f/256.0f; - uv2.y = 255.5f/256.0f; + uv1.x = 64.5f / 256.0f; + uv1.y = 192.5f / 256.0f; + uv2.x = 127.5f / 256.0f; + uv2.y = 255.5f / 256.0f; DrawIcon(pos, dim, uv1, uv2); // ul pos.x += dim.x; Math::Swap(uv1.x, uv2.x); @@ -310,112 +308,112 @@ void CGroup::Draw() } if ( m_icon == 13 ) // corner upper / left? { - m_engine->SetTexture("mouse.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("mouse.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); pos.x = m_pos.x-m_dim.x/150.0f; pos.y = m_pos.y+m_dim.y/150.0f; - uv1.x = 128.5f/256.0f; - uv1.y = 192.5f/256.0f; - uv2.x = 191.5f/256.0f; - uv2.y = 255.5f/256.0f; + uv1.x = 128.5f / 256.0f; + uv1.y = 192.5f / 256.0f; + uv2.x = 191.5f / 256.0f; + uv2.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); pos.x = m_pos.x+m_dim.x/150.0f; pos.y = m_pos.y-m_dim.y/150.0f; - uv1.x = 192.5f/256.0f; - uv1.y = 192.5f/256.0f; - uv2.x = 255.5f/256.0f; - uv2.y = 255.5f/256.0f; + uv1.x = 192.5f / 256.0f; + uv1.y = 192.5f / 256.0f; + uv2.x = 255.5f / 256.0f; + uv2.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); } if ( m_icon == 14 ) // corner upper / right? { - m_engine->SetTexture("mouse.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("mouse.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); pos.x = m_pos.x-m_dim.x/150.0f; pos.y = m_pos.y+m_dim.y/150.0f; - uv2.x = 128.5f/256.0f; - uv1.y = 192.5f/256.0f; - uv1.x = 191.5f/256.0f; - uv2.y = 255.5f/256.0f; + uv2.x = 128.5f / 256.0f; + uv1.y = 192.5f / 256.0f; + uv1.x = 191.5f / 256.0f; + uv2.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); pos.x = m_pos.x+m_dim.x/150.0f; pos.y = m_pos.y-m_dim.y/150.0f; - uv2.x = 192.5f/256.0f; - uv1.y = 192.5f/256.0f; - uv1.x = 255.5f/256.0f; - uv2.y = 255.5f/256.0f; + uv2.x = 192.5f / 256.0f; + uv1.y = 192.5f / 256.0f; + uv1.x = 255.5f / 256.0f; + uv2.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); } if ( m_icon == 15 ) // corner lower / left? { - m_engine->SetTexture("mouse.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("mouse.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); pos.x = m_pos.x-m_dim.x/150.0f; pos.y = m_pos.y+m_dim.y/150.0f; - uv1.x = 128.5f/256.0f; - uv2.y = 192.5f/256.0f; - uv2.x = 191.5f/256.0f; - uv1.y = 255.5f/256.0f; + uv1.x = 128.5f / 256.0f; + uv2.y = 192.5f / 256.0f; + uv2.x = 191.5f / 256.0f; + uv1.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); pos.x = m_pos.x+m_dim.x/150.0f; pos.y = m_pos.y-m_dim.y/150.0f; - uv1.x = 192.5f/256.0f; - uv2.y = 192.5f/256.0f; - uv2.x = 255.5f/256.0f; - uv1.y = 255.5f/256.0f; + uv1.x = 192.5f / 256.0f; + uv2.y = 192.5f / 256.0f; + uv2.x = 255.5f / 256.0f; + uv1.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); } if ( m_icon == 16 ) // corner lower / left? { - m_engine->SetTexture("mouse.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("mouse.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); pos.x = m_pos.x-m_dim.x/150.0f; pos.y = m_pos.y+m_dim.y/150.0f; - uv2.x = 128.5f/256.0f; - uv2.y = 192.5f/256.0f; - uv1.x = 191.5f/256.0f; - uv1.y = 255.5f/256.0f; + uv2.x = 128.5f / 256.0f; + uv2.y = 192.5f / 256.0f; + uv1.x = 191.5f / 256.0f; + uv1.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); pos.x = m_pos.x+m_dim.x/150.0f; pos.y = m_pos.y-m_dim.y/150.0f; - uv2.x = 192.5f/256.0f; - uv2.y = 192.5f/256.0f; - uv1.x = 255.5f/256.0f; - uv1.y = 255.5f/256.0f; + uv2.x = 192.5f / 256.0f; + uv2.y = 192.5f / 256.0f; + uv1.x = 255.5f / 256.0f; + uv1.y = 255.5f / 256.0f; DrawIcon(pos, m_dim, uv1, uv2); } if ( m_icon == 17 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 0.0f/256.0f; // blue frame - uv1.y = 75.0f/256.0f; - uv2.x = 64.0f/256.0f; - uv2.y = 128.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 0.0f / 256.0f; // blue frame + uv1.y = 75.0f / 256.0f; + uv2.x = 64.0f / 256.0f; + uv2.y = 128.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 6.0f/640.0f; - corner.y = 6.0f/480.0f; + corner.x = 6.0f / 640.0f; + corner.y = 6.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); } if ( m_icon == 18 ) // arrow> for SatCom? { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 0.0f/256.0f; // > - uv1.y = 192.0f/256.0f; - uv2.x = 32.0f/256.0f; - uv2.y = 224.0f/256.0f; + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 0.0f / 256.0f; // > + uv1.y = 192.0f / 256.0f; + uv2.x = 32.0f / 256.0f; + uv2.y = 224.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -424,12 +422,12 @@ void CGroup::Draw() } if ( m_icon == 19 ) // SatCom symbol? { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 224.0f/256.0f; // SatCom symbol - uv1.y = 224.0f/256.0f; - uv2.x = 256.0f/256.0f; - uv2.y = 256.0f/256.0f; + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 224.0f / 256.0f; // SatCom symbol + uv1.y = 224.0f / 256.0f; + uv2.x = 256.0f / 256.0f; + uv2.y = 256.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -438,12 +436,12 @@ void CGroup::Draw() } if ( m_icon == 20 ) // solid blue background? { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 224.0f/256.0f; - uv1.y = 32.0f/256.0f; - uv2.x = 256.0f/256.0f; - uv2.y = 64.0f/256.0f; + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 224.0f / 256.0f; + uv1.y = 32.0f / 256.0f; + uv2.x = 256.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -452,12 +450,12 @@ void CGroup::Draw() } if ( m_icon == 21 ) // stand-by symbol? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 160.0f/256.0f; - uv1.y = 32.0f/256.0f; - uv2.x = 192.0f/256.0f; - uv2.y = 64.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); + uv1.x = 160.0f / 256.0f; + uv1.y = 32.0f / 256.0f; + uv2.x = 192.0f / 256.0f; + uv2.y = 64.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -466,93 +464,93 @@ void CGroup::Draw() } if ( m_icon == 22 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 64.0f/256.0f; // opaque yellow - uv1.y = 224.0f/256.0f; - uv2.x = 160.0f/256.0f; - uv2.y = 240.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 64.0f / 256.0f; // opaque yellow + uv1.y = 224.0f / 256.0f; + uv2.x = 160.0f / 256.0f; + uv2.y = 240.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 5.0f/640.0f; - corner.y = 5.0f/480.0f; + corner.x = 5.0f / 640.0f; + corner.y = 5.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 3.0f/256.0f); } if ( m_icon == 23 ) { - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 64.0f/256.0f; // yellow - uv1.y = 192.0f/256.0f; - uv2.x = 80.0f/256.0f; - uv2.y = 208.0f/256.0f; + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 64.0f / 256.0f; // yellow + uv1.y = 192.0f / 256.0f; + uv2.x = 80.0f / 256.0f; + uv2.y = 208.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 4.0f/640.0f; - corner.y = 4.0f/480.0f; + corner.x = 4.0f / 640.0f; + corner.y = 4.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); } if ( m_icon == 24 ) { - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 80.0f/256.0f; // orange - uv1.y = 192.0f/256.0f; - uv2.x = 96.0f/256.0f; - uv2.y = 208.0f/256.0f; + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 80.0f / 256.0f; // orange + uv1.y = 192.0f / 256.0f; + uv2.x = 96.0f / 256.0f; + uv2.y = 208.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 4.0f/640.0f; - corner.y = 4.0f/480.0f; + corner.x = 4.0f / 640.0f; + corner.y = 4.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); } if ( m_icon == 25 ) { - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 64.0f/256.0f; // orange - uv1.y = 208.0f/256.0f; - uv2.x = 80.0f/256.0f; - uv2.y = 224.0f/256.0f; + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 64.0f / 256.0f; // orange + uv1.y = 208.0f / 256.0f; + uv2.x = 80.0f / 256.0f; + uv2.y = 224.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 4.0f/640.0f; - corner.y = 4.0f/480.0f; + corner.x = 4.0f / 640.0f; + corner.y = 4.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); } if ( m_icon == 26 ) { - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 80.0f/256.0f; // red - uv1.y = 208.0f/256.0f; - uv2.x = 96.0f/256.0f; - uv2.y = 224.0f/256.0f; + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 80.0f / 256.0f; // red + uv1.y = 208.0f / 256.0f; + uv2.x = 96.0f / 256.0f; + uv2.y = 224.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 4.0f/640.0f; - corner.y = 4.0f/480.0f; + corner.x = 4.0f / 640.0f; + corner.y = 4.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); } if ( m_icon == 27 ) { - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 32.0f/256.0f; - uv1.y = 0.0f/256.0f; - uv2.x = 64.0f/256.0f; - uv2.y = 32.0f/256.0f; + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 32.0f / 256.0f; + uv1.y = 0.0f / 256.0f; + uv2.x = 64.0f / 256.0f; + uv2.y = 32.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; @@ -565,10 +563,10 @@ void CGroup::Draw() pos = m_pos; dim = m_dim; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 32.0f/256.0f; - uv1.y = 32.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 32.0f / 256.0f; + uv1.y = 32.0f / 256.0f; uv2.x = uv1.x+32.0f/256.0f; uv2.y = uv1.y+32.0f/256.0f; uv1.x += dp; @@ -577,14 +575,14 @@ void CGroup::Draw() uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATENORMAL); - pos.x += 8.0f/640.0f; - pos.y += 8.0f/480.0f; - dim.x -= 16.0f/640.0f; - dim.y -= 16.0f/480.0f; - uv1.x = 32.0f/256.0f; - uv1.y = 0.0f/256.0f; + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + pos.x += 8.0f / 640.0f; + pos.y += 8.0f / 480.0f; + dim.x -= 16.0f / 640.0f; + dim.y -= 16.0f / 480.0f; + uv1.x = 32.0f / 256.0f; + uv1.y = 0.0f / 256.0f; uv2.x = uv1.x+32.0f/256.0f; uv2.y = uv1.y+32.0f/256.0f; uv1.x += dp; @@ -593,13 +591,13 @@ void CGroup::Draw() uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); - m_engine->SetState(D3DSTATENORMAL); - pos.x += 2.0f/640.0f; - pos.y += 2.0f/480.0f; - dim.x -= 4.0f/640.0f; - dim.y -= 4.0f/480.0f; - uv1.x = 0.0f/256.0f; - uv1.y = 0.0f/256.0f; + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + pos.x += 2.0f / 640.0f; + pos.y += 2.0f / 480.0f; + dim.x -= 4.0f / 640.0f; + dim.y -= 4.0f / 480.0f; + uv1.x = 0.0f / 256.0f; + uv1.y = 0.0f / 256.0f; uv2.x = uv1.x+32.0f/256.0f; uv2.y = uv1.y+32.0f/256.0f; uv1.x += dp; @@ -608,11 +606,11 @@ void CGroup::Draw() uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); - m_engine->SetState(D3DSTATETTb); - pos.x += 8.0f/640.0f; - pos.y += 8.0f/480.0f; - dim.x -= 16.0f/640.0f; - dim.y -= 16.0f/480.0f; + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); + pos.x += 8.0f / 640.0f; + pos.y += 8.0f / 480.0f; + dim.x -= 16.0f / 640.0f; + dim.y -= 16.0f / 480.0f; if ( m_icon == 100 ) icon = 43; // base ? if ( m_icon == 101 ) icon = 32; // factory ? if ( m_icon == 102 ) icon = 35; // research ? @@ -642,3 +640,4 @@ void CGroup::Draw() } +} diff --git a/src/ui/group.h b/src/ui/group.h index baf609f..bfeef74 100644 --- a/src/ui/group.h +++ b/src/ui/group.h @@ -21,18 +21,20 @@ #include "ui/control.h" +namespace Gfx{ +class CEngine; +}; -class CD3DEngine; - - +namespace Ui { class CGroup : public CControl { public: - CGroup(CInstanceManager* iMan); +// CGroup(CInstanceManager* iMan); + CGroup(); virtual ~CGroup(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); bool EventProcess(const Event &event); @@ -44,3 +46,4 @@ protected: }; +} diff --git a/src/ui/image.cpp b/src/ui/image.cpp index 8bf46fb..ad838fa 100644 --- a/src/ui/image.cpp +++ b/src/ui/image.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,23 @@ // image.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/math3d.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 <string.h> +#include <stdio.h> - +namespace Ui { // Object's constructor. -CImage::CImage(CInstanceManager* iMan) : CControl(iMan) +//CImage::CImage(CInstanceManager* iMan) : CControl(iMan) +CImage::CImage() : CControl() { m_filename[0] = 0; } @@ -46,25 +45,25 @@ CImage::~CImage() { if ( m_filename[0] != 0 ) { - m_engine->FreeTexture(m_filename); + m_engine->DeleteTexture(m_filename); } } // Creates a new button. -bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); if ( icon == -1 ) { char name[100]; char* p; - GetResource(RES_EVENT, eventMsg, name); + GetResource(RES_EVENT, eventType, name); p = strchr(name, '\\'); if ( p != 0 ) *p = 0; SetName(name); @@ -76,17 +75,17 @@ bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMs // Specifies the name of the image display. -void CImage::SetFilenameImage(char *name) +void CImage::SetFilenameImage(const char *name) { if ( m_filename[0] != 0 ) { - m_engine->FreeTexture(m_filename); + m_engine->DeleteTexture(m_filename); } strcpy(m_filename, name); } -char* CImage::RetFilenameImage() +char* CImage::GetFilenameImage() { return m_filename; } @@ -118,18 +117,18 @@ void CImage::Draw() if ( m_icon == 0 ) // hollow frame? { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 160.0f/256.0f; - uv1.y = 192.0f/256.0f; // u-v texture - uv2.x = 192.0f/256.0f; - uv2.y = 224.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 160.0f / 256.0f; + uv1.y = 192.0f / 256.0f; // u-v texture + uv2.x = 192.0f / 256.0f; + uv2.y = 224.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; - corner.x = 10.0f/640.0f; - corner.y = 10.0f/480.0f; + corner.x = 10.0f / 640.0f; + corner.y = 10.0f / 480.0f; DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f); } @@ -137,13 +136,13 @@ void CImage::Draw() { m_engine->LoadTexture(m_filename); m_engine->SetTexture(m_filename); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); pos = m_pos; dim = m_dim; - pos.x += 5.0f/640.0f; - pos.y += 5.0f/480.0f; - dim.x -= 10.0f/640.0f; - dim.y -= 10.0f/480.0f; + pos.x += 5.0f / 640.0f; + pos.y += 5.0f / 480.0f; + dim.x -= 10.0f / 640.0f; + dim.y -= 10.0f / 480.0f; uv1.x = 0.0f; uv1.y = 0.0f; uv2.x = 1.0f; @@ -153,3 +152,4 @@ void CImage::Draw() } +} diff --git a/src/ui/image.h b/src/ui/image.h index 85c5962..b73a5ae 100644 --- a/src/ui/image.h +++ b/src/ui/image.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 @@ -21,25 +22,28 @@ #include "ui/control.h" - -class CD3DEngine; +namespace Gfx{ +class CEngine; +}; +namespace Ui { class CImage : public CControl { public: - CImage(CInstanceManager* iMan); +// 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 eventType); bool EventProcess(const Event &event); void Draw(); - void SetFilenameImage(char *name); - char* RetFilenameImage(); + void SetFilenameImage(const char *name); + char* GetFilenameImage(); protected: @@ -48,3 +52,4 @@ protected: }; +} diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 50d2352..0745c9b 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,22 @@ // interface.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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" +namespace Ui { - -// Object's constructor. - -CInterface::CInterface(CInstanceManager* iMan) +CInterface::CInterface() { - int i; - - m_iMan = iMan; + 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_camera = nullptr; - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_camera = 0; - - for ( i=0 ; i<MAXCONTROL ; i++ ) + for (int i = 0; i < MAXCONTROL; i++ ) { - m_table[i] = 0; + m_table[i] = nullptr; } } @@ -74,6 +42,7 @@ CInterface::CInterface(CInstanceManager* iMan) CInterface::~CInterface() { Flush(); + m_iMan->DeleteInstance(CLASS_INTERFACE, this); } @@ -81,424 +50,210 @@ CInterface::~CInterface() void CInterface::Flush() { - int i; - - for ( i=0 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] != 0 ) - { + for (int i = 0; i < MAXCONTROL; i++ ) { + if ( m_table[i] != nullptr ) { delete m_table[i]; - m_table[i] = 0; + m_table[i] = nullptr; } } } -// Creates a new button. - -CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +int CInterface::GetNextFreeControl() { - CWindow* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - if ( eventMsg == EVENT_WINDOW0 ) {i=0; goto create;} - if ( eventMsg == EVENT_WINDOW1 ) {i=1; goto create;} - if ( eventMsg == EVENT_WINDOW2 ) {i=2; goto create;} - if ( eventMsg == EVENT_WINDOW3 ) {i=3; goto create;} - if ( eventMsg == EVENT_WINDOW4 ) {i=4; goto create;} - if ( eventMsg == EVENT_WINDOW5 ) {i=5; goto create;} - if ( eventMsg == EVENT_WINDOW6 ) {i=6; goto create;} - if ( eventMsg == EVENT_WINDOW7 ) {i=7; goto create;} - if ( eventMsg == EVENT_WINDOW8 ) {i=8; goto create;} - if ( eventMsg == EVENT_WINDOW9 ) {i=9; goto create;} - - if ( eventMsg == EVENT_TOOLTIP ) {i=MAXCONTROL-1; goto create;} - - for ( i=10 ; i<MAXCONTROL-1 ; i++ ) - { - if ( m_table[i] == 0 ) - { - create: - m_table[i] = new CWindow(m_iMan); - pc = (CWindow*)m_table[i]; - pc->Create(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 <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - CButton* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CButton(m_iMan); - pc = (CButton*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + T* pc; + int index; + if (eventMsg == EVENT_NULL) + eventMsg = GetUniqueEventType(); + + if ((index = GetNextFreeControl()) < 0) + return nullptr; + + m_table[index] = new T(); + pc = static_cast<T *>(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; + if (eventMsg == EVENT_NULL) + eventMsg = GetUniqueEventType(); + + 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; + } - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if (index < 0) + return nullptr; - for ( i=10 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CColor(m_iMan); - pc = (CColor*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + m_table[index] = new CWindow(); + pc = static_cast<CWindow *>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CCheck(m_iMan); - pc = (CCheck*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CButton>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CKey(m_iMan); - pc = (CKey*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CColor>(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<CCheck>(pos, dim, icon, eventMsg); +} - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); +// Creates a new button. - for ( i=10 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CGroup(m_iMan); - pc = (CGroup*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; +CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) +{ + return CreateControl<CKey>(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<CGroup>(pos, dim, icon, eventMsg); +} - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); +// Creates a new button. - for ( i=10 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CImage(m_iMan); - pc = (CImage*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; +CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) +{ + return CreateControl<CImage>(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, std::string name) { - CLabel* pc; - int i; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CLabel(m_iMan); - pc = (CLabel*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - pc->SetName(name); - return pc; - } - } - return 0; + CLabel* pc = CreateControl<CLabel>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CEdit(m_iMan); - pc = (CEdit*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CEdit>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CEditValue(m_iMan); - pc = (CEditValue*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CEditValue>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CScroll(m_iMan); - pc = (CScroll*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CScroll>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CSlider(m_iMan); - pc = (CSlider*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CSlider>(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; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - - for ( i=10 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CList(m_iMan); - pc = (CList*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg, expand); - return pc; - } - } - return 0; + CList* pc; + int index; + if (eventMsg == EVENT_NULL) + eventMsg = GetUniqueEventType(); + + if ((index = GetNextFreeControl()) < 0) + return nullptr; + + m_table[index] = new CList(); + pc = static_cast<CList *>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CShortcut(m_iMan); - ps = (CShortcut*)m_table[i]; - ps->Create(pos, dim, icon, eventMsg); - return ps; - } - } - return 0; + return CreateControl<CShortcut>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CCompass(m_iMan); - pc = (CCompass*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CCompass>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CTarget(m_iMan); - pc = (CTarget*)m_table[i]; - pc->Create(pos, dim, icon, eventMsg); - return pc; - } - } - return 0; + return CreateControl<CTarget>(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 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] == 0 ) - { - m_table[i] = new CMap(m_iMan); - pm = (CMap*)m_table[i]; - pm->Create(pos, dim, icon, eventMsg); - return pm; - } - } - return 0; + return CreateControl<CMap>(pos, dim, icon, eventMsg); } // Removes a control. -bool CInterface::DeleteControl(EventMsg eventMsg) +bool CInterface::DeleteControl(EventType eventMsg) { - int i; - - for ( i=0 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] != 0 ) - { - if ( eventMsg == m_table[i]->RetEventMsg() ) - { + 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 +263,32 @@ bool CInterface::DeleteControl(EventMsg eventMsg) // Gives a control. -CControl* CInterface::SearchControl(EventMsg eventMsg) +CControl* CInterface::SearchControl(EventType eventMsg) { - int i; - - for ( i=0 ; i<MAXCONTROL ; i++ ) - { - if ( m_table[i] != 0 ) - { - if ( eventMsg == m_table[i]->RetEventMsg() ) - { + 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<Gfx::CCamera *>(m_iMan->SearchInstance(CLASS_CAMERA)); } - m_engine->SetMouseType(m_camera->RetMouseDef(event.pos)); + m_engine->SetMouseType(m_camera->GetMouseDef(event.mouseMove.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 +298,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, std::string &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 +314,19 @@ 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<MAXCONTROL ; i++ ) -//? for ( i=MAXCONTROL-1 ; 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..1496541 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 @@ -18,78 +19,86 @@ #pragma once +#include <string> #include "common/event.h" -#include "math/point.h" - +#include "common/misc.h" +#include "common/iman.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 "math/point.h" +#include "graphics/engine/camera.h" +#include "graphics/engine/engine.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" + +namespace Ui { 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, std::string &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, std::string name); + + bool DeleteControl(EventType eventMsg); + CControl* SearchControl(EventType eventMsg); + + void Draw(); + + protected: + 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; + + CControl* m_table[MAXCONTROL]; }; +} diff --git a/src/ui/key.cpp b/src/ui/key.cpp index a1eebb3..2e627bd 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,35 @@ // key.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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" +#include <string.h> - - -// Constructs the name of a button. +namespace Ui { 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,19 +58,15 @@ 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; - - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + char name[100]; + if (eventMsg == EVENT_NULL) + eventMsg = GetUniqueEventType(); CControl::Create(pos, dim, icon, eventMsg); - GetResource(RES_EVENT, eventMsg, name); - p = strchr(name, '\\'); - if ( p != 0 ) *p = 0; - SetName(name); + SetName(std::string(name)); return true; } @@ -98,47 +76,33 @@ 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.mouseButton.pos); } - if ( event.event == EVENT_KEYDOWN && m_bCatch ) - { + if (event.type == EVENT_KEY_DOWN && m_bCatch) { m_bCatch = false; - if ( TestKey(event.param) ) // impossible ? - { + if ( TestKey(event.key.key) ) { // impossible ? m_sound->Play(SOUND_TZOING); - } - else - { - if ( event.param == m_key[0] || - event.param == m_key[1] ) - { - m_key[0] = event.param; + } else { + if ( event.key.key == m_key[0] || event.key.key == m_key[1] ) { + m_key[0] = event.key.key; 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,27 +116,20 @@ 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 - - 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! - } + if ( key == KEY(PAUSE) || key == KEY(PRINT) ) return true; // blocked key + + /* TODO: input bindings + 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); } - } + } */ return false; // not used } @@ -182,107 +139,99 @@ 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->SetTexture("button1.png"); + 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_LEFT, 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..be28b6e 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,43 @@ #pragma once +#include <cctype> +#include <string> #include "ui/control.h" +#include "common/iman.h" +#include "common/event.h" +#include "common/restext.h" +#include "common/key.h" -class CD3DEngine; - +#include "app/app.h" +namespace Ui { 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..af65ab2 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,14 @@ // label.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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" - +namespace Ui { // Object's constructor. -CLabel::CLabel(CInstanceManager* iMan) : CControl(iMan) +CLabel::CLabel() : CControl() { } @@ -48,9 +38,10 @@ 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(); + if (eventMsg == EVENT_NULL) + eventMsg = GetUniqueEventType(); CControl::Create(pos, dim, icon, eventMsg); return true; @@ -72,22 +63,18 @@ 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; - } - if ( m_justif == 0 ) - { - pos.x = m_pos.x+m_dim.x/2.0f; + switch (m_textAlign) { + 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; - } - 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_textAlign, 0); } +} diff --git a/src/ui/label.h b/src/ui/label.h index d3cb915..c9e1050 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 @@ -21,26 +22,22 @@ #include "ui/control.h" +#include "common/event.h" +#include "common/misc.h" -class CD3DEngine; - - +namespace Ui { 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.cpp b/src/ui/list.cpp index 9fbc5d9..f62d0ea 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.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,50 +18,32 @@ // list.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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/button.h" -#include "ui/scroll.h" -#include "old/text.h" #include "ui/list.h" +#include <string.h> +namespace Ui { const float MARGING = 4.0f; - // Object's constructor. -CList::CList(CInstanceManager* iMan) : CControl(iMan) +CList::CList() : CControl() { - int i; - - for ( i=0 ; i<LISTMAXDISPLAY ; i++ ) - { - m_button[i] = 0; - } - m_scroll = 0; + for (int i = 0; i < LISTMAXDISPLAY; i++) + m_button[i] = nullptr; - for ( i=0 ; i<LISTMAXTOTAL ; i++ ) - { + m_scroll = nullptr; + for (int i = 0; i < LISTMAXTOTAL; i++) { m_text[i][0] = 0; m_check[i] = false; m_enable[i] = true; } - for ( i=0 ; i<10 ; i++ ) - { + for (int i = 0; i < 10; i++) { m_tabs[i] = 0.0f; - m_justifs[i] = 1; + m_justifs[i] = Gfx::TEXT_ALIGN_LEFT; } m_totalLine = 0; @@ -76,29 +59,30 @@ CList::CList(CInstanceManager* iMan) : CControl(iMan) CList::~CList() { - int i; - - for ( i=0 ; i<LISTMAXDISPLAY ; i++ ) - { - delete m_button[i]; + for (int i = 0; i < LISTMAXDISPLAY; i++) { + if (m_button[i] != nullptr) + delete m_button[i]; } - delete m_scroll; + + if (m_scroll != nullptr) + delete m_scroll; } // Creates a new list. -bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, - float expand) +bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { m_expand = expand; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if (eventMsg == EVENT_NULL) + eventMsg = GetUniqueEventType(); + CControl::Create(pos, dim, icon, eventMsg); - m_scroll = new CScroll(m_iMan); + m_scroll = new CScroll(); m_scroll->Create(pos, dim, 0, EVENT_NULL); - m_eventScroll = m_scroll->RetEventMsg(); + m_eventScroll = m_scroll->GetEventType(); return MoveAdjust(); } @@ -107,52 +91,54 @@ bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg bool CList::MoveAdjust() { - Math::Point ipos, idim, ppos, ddim; - float marging, h; - int i; + Math::Point ipos, idim, ppos, ddim; + float marging, h; - for ( i=0 ; i<LISTMAXDISPLAY ; i++ ) - { - delete m_button[i]; - m_button[i] = 0; + for (int i = 0; i < LISTMAXDISPLAY; i++) { + if (m_button[i] != nullptr) { + delete m_button[i]; + m_button[i] = nullptr; + } } - if ( m_icon == 0 ) marging = MARGING; - else marging = 0.0f; + if (m_icon == 0) + marging = MARGING; + else + marging = 0.0f; - ipos.x = m_pos.x+marging/640.f; - ipos.y = m_pos.y+marging/480.f; - idim.x = m_dim.x-marging*2.0f/640.f; - idim.y = m_dim.y-marging*2.0f/480.f; + ipos.x = m_pos.x + marging / 640.f; + ipos.y = m_pos.y + marging / 480.f; + idim.x = m_dim.x - marging * 2.0f / 640.f; + idim.y = m_dim.y - marging * 2.0f / 480.f; - h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType)*m_expand; + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * m_expand; - m_displayLine = (int)(idim.y/h); - if ( m_displayLine == 0 ) return false; - if ( m_displayLine > LISTMAXDISPLAY ) m_displayLine = LISTMAXDISPLAY; - idim.y = h*m_displayLine; - m_dim.y = idim.y+marging*2.0f/480.f; + m_displayLine = static_cast<int>(idim.y / h); + if (m_displayLine == 0) + return false; + if (m_displayLine > LISTMAXDISPLAY) + m_displayLine = LISTMAXDISPLAY; + idim.y = h * m_displayLine; + m_dim.y = idim.y + marging * 2.0f / 480.f; ppos.x = ipos.x; - ppos.y = ipos.y+idim.y-h; - ddim.x = idim.x-SCROLL_WIDTH; + ppos.y = ipos.y + idim.y - h; + ddim.x = idim.x - SCROLL_WIDTH; ddim.y = h; - for ( i=0 ; i<m_displayLine ; i++ ) - { - m_button[i] = new CButton(m_iMan); + for (int i = 0; i < m_displayLine; i++) { + m_button[i] = new CButton(); m_button[i]->Create(ppos, ddim, -1, EVENT_NULL); - m_button[i]->SetJustif(1); + m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); m_button[i]->SetState(STATE_SIMPLY); m_button[i]->SetFontType(m_fontType); m_button[i]->SetFontSize(m_fontSize); ppos.y -= h; - m_eventButton[i] = m_button[i]->RetEventMsg(); + m_eventButton[i] = m_button[i]->GetEventType(); } - if ( m_scroll != 0 ) - { - ppos.x = ipos.x+idim.x-SCROLL_WIDTH; + if ( m_scroll != nullptr ) { + ppos.x = ipos.x + idim.x - SCROLL_WIDTH; ppos.y = ipos.y; ddim.x = SCROLL_WIDTH; ddim.y = idim.y; @@ -168,19 +154,22 @@ bool CList::MoveAdjust() // Returns the message of a button. -EventMsg CList::RetEventMsgButton(int i) +EventType CList::GetEventMsgButton(int i) { - if ( i < 0 || i >= m_displayLine ) return EVENT_NULL; - if ( m_button[i] == 0 ) return EVENT_NULL; - return m_button[i]->RetEventMsg(); + if (i < 0 || i >= m_displayLine) + return EVENT_NULL; + if (m_button[i] == nullptr) + return EVENT_NULL; + return m_button[i]->GetEventType(); } // Returns the message from the elevator. -EventMsg CList::RetEventMsgScroll() +EventType CList::GetEventMsgScroll() { - if ( m_scroll == 0 ) return EVENT_NULL; - return m_scroll->RetEventMsg(); + if (m_scroll == nullptr) + return EVENT_NULL; + return m_scroll->GetEventType(); } @@ -189,6 +178,7 @@ void CList::SetPos(Math::Point pos) CControl::SetPos(pos); } + void CList::SetDim(Math::Point dim) { m_dim = dim; @@ -199,47 +189,43 @@ void CList::SetDim(Math::Point dim) bool CList::SetState(int state, bool bState) { - int i; - - if ( state & STATE_ENABLE ) - { - for ( i=0 ; i<m_displayLine ; i++ ) - { - if ( m_button[i] != 0 ) m_button[i]->SetState(state, bState); + if (state & STATE_ENABLE) { + for (int i = 0; i < m_displayLine; i++) { + if (m_button[i] != nullptr) + m_button[i]->SetState(state, bState); } - if ( m_scroll != 0 ) m_scroll->SetState(state, bState); + if (m_scroll != nullptr) + m_scroll->SetState(state, bState); } return CControl::SetState(state, bState); } + bool CList::SetState(int state) { - int i; - - if ( state & STATE_ENABLE ) - { - for ( i=0 ; i<m_displayLine ; i++ ) - { - if ( m_button[i] != 0 ) m_button[i]->SetState(state); + if (state & STATE_ENABLE) { + for (int i = 0; i < m_displayLine; i++) { + if (m_button[i] != nullptr) + m_button[i]->SetState(state); } - if ( m_scroll != 0 ) m_scroll->SetState(state); + if (m_scroll != nullptr) + m_scroll->SetState(state); } return CControl::SetState(state); } + bool CList::ClearState(int state) { - int i; - - if ( state & STATE_ENABLE ) - { - for ( i=0 ; i<m_displayLine ; i++ ) - { - if ( m_button[i] != 0 ) m_button[i]->ClearState(state); + if (state & STATE_ENABLE) { + for (int i = 0; i < m_displayLine; i++) { + if (m_button[i] != nullptr) + m_button[i]->ClearState(state); } - if ( m_scroll != 0 ) m_scroll->ClearState(state); + if (m_scroll != nullptr) + m_scroll->ClearState(state); } return CControl::ClearState(state); @@ -250,47 +236,38 @@ bool CList::ClearState(int state) bool CList::EventProcess(const Event &event) { - int i; - - if ( m_bBlink && // blinks? - event.event == EVENT_FRAME ) - { + int i; + if (m_bBlink && event.type == EVENT_FRAME) { i = m_selectLine-m_firstLine; - if ( i >= 0 && i < 4 && - m_button[i] != 0 ) - { + if (i >= 0 && i < 4 && m_button[i] != nullptr) { m_blinkTime += event.rTime; - if ( Math::Mod(m_blinkTime, 0.7f) < 0.3f ) - { + if (Math::Mod(m_blinkTime, 0.7f) < 0.3f) { m_button[i]->ClearState(STATE_ENABLE); m_button[i]->ClearState(STATE_CHECK); - } - else - { + } else { m_button[i]->SetState(STATE_ENABLE); m_button[i]->SetState(STATE_CHECK); } } } - if ( (m_state & STATE_VISIBLE) == 0 ) return true; - if ( (m_state & STATE_ENABLE) == 0 ) return true; + if ((m_state & STATE_VISIBLE) == 0) + return true; + if ((m_state & STATE_ENABLE) == 0) + return true; - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELUP && - Detect(event.pos) ) - { - if ( m_firstLine > 0 ) m_firstLine --; + if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mouseWheel.pos)) { + if (m_firstLine > 0) + m_firstLine--; UpdateScroll(); UpdateButton(); return true; } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELDOWN && - Detect(event.pos) ) - { - if ( m_firstLine < m_totalLine-m_displayLine ) m_firstLine ++; + + if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mouseWheel.pos)) { + if (m_firstLine < m_totalLine - m_displayLine) + m_firstLine++; UpdateScroll(); UpdateButton(); return true; @@ -298,46 +275,41 @@ bool CList::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.event == EVENT_MOUSEMOVE && Detect(event.pos) ) - { - m_engine->SetMouseType(D3DMOUSENORM); - for ( i=0 ; i<m_displayLine ; i++ ) - { - if ( i+m_firstLine >= m_totalLine ) break; - if ( m_button[i] != 0 ) - { + if (event.type == EVENT_MOUSE_MOVE && Detect(event.mouseMove.pos)) { + m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); + for (i = 0; i < m_displayLine; i++) { + if (i + m_firstLine >= m_totalLine) + break; + if (m_button[i] != nullptr) m_button[i]->EventProcess(event); - } } } - if ( m_bSelectCap ) - { - for ( i=0 ; i<m_displayLine ; i++ ) - { - if ( i+m_firstLine >= m_totalLine ) break; - if ( m_button[i] != 0 ) - { - if ( !m_button[i]->EventProcess(event) ) return false; - - if ( event.event == m_eventButton[i] ) - { - SetSelect(m_firstLine+i); + if (m_bSelectCap) { + for (i = 0; i < m_displayLine; i++) { + if (i + m_firstLine >= m_totalLine) + break; + + if (m_button[i] != nullptr) { + if (!m_button[i]->EventProcess(event)) + return false; + + if (event.type == m_eventButton[i]) { + SetSelect(m_firstLine + i); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); // selected line changes } } } } - if ( m_scroll != 0 ) - { - if ( !m_scroll->EventProcess(event) ) return false; + if (m_scroll != nullptr) { + if (!m_scroll->EventProcess(event)) + return false; - if ( event.event == m_eventScroll ) - { + if (event.type == m_eventScroll) { MoveScroll(); UpdateButton(); } @@ -353,46 +325,40 @@ void CList::Draw() { Math::Point uv1, uv2, corner, pos, dim, ppos, ddim; float dp; - int i, j; + int i; char text[100]; char *pb, *pe; - if ( (m_state & STATE_VISIBLE) == 0 ) return; + if ((m_state & STATE_VISIBLE) == 0) + return; - if ( m_state & STATE_SHADOW ) - { + if (m_state & STATE_SHADOW) DrawShadow(m_pos, m_dim); - } - dp = 0.5f/256.0f; + dp = 0.5f / 256.0f; - if ( m_icon != -1 ) - { + if (m_icon != -1) { dim = m_dim; - if ( m_icon == 0 ) - { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - - uv1.x = 128.0f/256.0f; - uv1.y = 64.0f/256.0f; // u-v texture - uv2.x = 160.0f/256.0f; - uv2.y = 96.0f/256.0f; - } - else - { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); - - uv1.x = 132.0f/256.0f; - uv1.y = 68.0f/256.0f; // u-v texture - uv2.x = 156.0f/256.0f; - uv2.y = 92.0f/256.0f; - - if ( m_button[0] != 0 ) - { - dim = m_button[0]->RetDim(); + if (m_icon == 0) { + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + + uv1.x = 128.0f / 256.0f; + uv1.y = 64.0f / 256.0f; // u-v texture + uv2.x = 160.0f / 256.0f; + uv2.y = 96.0f / 256.0f; + } else { + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + + uv1.x = 132.0f / 256.0f; + uv1.y = 68.0f / 256.0f; // u-v texture + uv2.x = 156.0f / 256.0f; + uv2.y = 92.0f / 256.0f; + + if (m_button[0] != nullptr) { + dim = m_button[0]->GetDim(); dim.y *= m_displayLine; // background sounds spot behind } } @@ -402,28 +368,26 @@ void CList::Draw() uv2.x -= dp; uv2.y -= dp; - corner.x = 10.0f/640.0f; - corner.y = 10.0f/480.0f; - DrawIcon(m_pos, dim, uv1, uv2, corner, 8.0f/256.0f); + corner.x = 10.0f / 640.0f; + corner.y = 10.0f / 480.0f; + DrawIcon(m_pos, dim, uv1, uv2, corner, 8.0f / 256.0f); } - if ( m_totalLine < m_displayLine ) // no buttons to the bottom? - { + if ( m_totalLine < m_displayLine ) { // no buttons to the bottom? i = m_totalLine; - if ( m_button[i] != 0 ) - { - pos = m_button[i]->RetPos(); - dim = m_button[i]->RetDim(); - pos.y += dim.y*1.1f; + if ( m_button[i] != 0 ) { + pos = m_button[i]->GetPos(); + dim = m_button[i]->GetDim(); + pos.y += dim.y * 1.1f; dim.y *= 0.4f; pos.y -= dim.y; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); - uv1.x = 120.0f/256.0f; - uv1.y = 64.0f/256.0f; - uv2.x = 128.0f/256.0f; - uv2.y = 48.0f/256.0f; + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw + uv1.x = 120.0f / 256.0f; + uv1.y = 64.0f / 256.0f; + uv2.x = 128.0f / 256.0f; + uv2.y = 48.0f / 256.0f; uv1.x += dp; uv1.y -= dp; uv2.x -= dp; @@ -432,108 +396,93 @@ void CList::Draw() } } - for ( i=0 ; i<m_displayLine ; i++ ) - { - if ( i+m_firstLine >= m_totalLine ) break; + for (i = 0; i < m_displayLine; i++) { + if ( i + m_firstLine >= m_totalLine ) + break; - if ( m_button[i] != 0 ) - { - if ( !m_bBlink && i+m_firstLine < m_totalLine ) - { + if ( m_button[i] != nullptr ) { + if ( !m_bBlink && i + m_firstLine < m_totalLine ) m_button[i]->SetState(STATE_ENABLE, m_enable[i+m_firstLine] && (m_state & STATE_ENABLE) ); - } + m_button[i]->Draw(); // draws a box without text // draws text in the box - pos = m_button[i]->RetPos(); - dim = m_button[i]->RetDim(); - if ( m_tabs[0] == 0.0f ) - { - ppos.x = pos.x+dim.y*0.5f; - ppos.y = pos.y+dim.y*0.5f; - ppos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; + pos = m_button[i]->GetPos(); + dim = m_button[i]->GetDim(); + if ( m_tabs[0] == 0.0f ) { + ppos.x = pos.x + dim.y * 0.5f; + ppos.y = pos.y + dim.y * 0.5f; + ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; ddim.x = dim.x-dim.y; - DrawCase(m_text[i+m_firstLine], ppos, ddim.x, 1); - } - else - { - ppos.x = pos.x+dim.y*0.5f; - ppos.y = pos.y+dim.y*0.5f; - ppos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; - pb = m_text[i+m_firstLine]; - for ( j=0 ; j<10 ; j++ ) - { + DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_LEFT); + } else { + ppos.x = pos.x + dim.y * 0.5f; + ppos.y = pos.y + dim.y * 0.5f; + ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; + pb = m_text[i + m_firstLine]; + for (int j = 0; j < 10; j++) { pe = strchr(pb, '\t'); if ( pe == 0 ) - { strcpy(text, pb); - } - else - { - strncpy(text, pb, pe-pb); - text[pe-pb] = 0; + else { + strncpy(text, pb, pe - pb); + text[pe - pb] = 0; } DrawCase(text, ppos, m_tabs[j], m_justifs[j]); - if ( pe == 0 ) break; + if ( pe == 0 ) + break; ppos.x += m_tabs[j]; - pb = pe+1; + pb = pe + 1; } } - if ( (m_state & STATE_EXTEND) && i < m_totalLine ) - { - pos = m_button[i]->RetPos(); - dim = m_button[i]->RetDim(); - pos.x += dim.x-dim.y*0.75f; - dim.x = dim.y*0.75f; - pos.x += 2.0f/640.0f; - pos.y += 2.0f/480.0f; - dim.x -= 4.0f/640.0f; - dim.y -= 4.0f/480.0f; - - if ( m_check[i+m_firstLine] ) - { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 64.0f/256.0f; - uv1.y = 0.0f/256.0f; - uv2.x = 96.0f/256.0f; - uv2.y = 32.0f/256.0f; + if ( (m_state & STATE_EXTEND) && i < m_totalLine) { + pos = m_button[i]->GetPos(); + dim = m_button[i]->GetDim(); + pos.x += dim.x - dim.y * 0.75f; + dim.x = dim.y * 0.75f; + pos.x += 2.0f / 640.0f; + pos.y += 2.0f / 480.0f; + dim.x -= 4.0f / 640.0f; + dim.y -= 4.0f / 480.0f; + + if ( m_check[i + m_firstLine] ) { + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 64.0f / 256.0f; + uv1.y = 0.0f / 256.0f; + uv2.x = 96.0f / 256.0f; + uv2.y = 32.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); // square shape - m_engine->SetState(D3DSTATETTw); - uv1.x = 0.0f/256.0f; // v - uv1.y = 64.0f/256.0f; - uv2.x = 32.0f/256.0f; - uv2.y = 96.0f/256.0f; + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw + uv1.x = 0.0f / 256.0f; // v + uv1.y = 64.0f / 256.0f; + uv2.x = 32.0f / 256.0f; + uv2.y = 96.0f / 256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); // draws v - } - else - { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATETTw); - if ( i+m_firstLine == m_selectLine ) - { - uv1.x =224.0f/256.0f; // < - uv1.y =192.0f/256.0f; - uv2.x =256.0f/256.0f; - uv2.y =224.0f/256.0f; - } - else - { - uv1.x = 96.0f/256.0f; // x - uv1.y = 32.0f/256.0f; - uv2.x =128.0f/256.0f; - uv2.y = 64.0f/256.0f; + } else { + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw + if ( i + m_firstLine == m_selectLine ) { + uv1.x =224.0f / 256.0f; // < + uv1.y =192.0f / 256.0f; + uv2.x =256.0f / 256.0f; + uv2.y =224.0f / 256.0f; + } else { + uv1.x = 96.0f / 256.0f; // x + uv1.y = 32.0f / 256.0f; + uv2.x =128.0f / 256.0f; + uv2.y = 64.0f / 256.0f; } uv1.x += dp; uv1.y += dp; @@ -546,29 +495,18 @@ void CList::Draw() } if ( m_scroll != 0 ) - { m_scroll->Draw(); // draws the lift - } } // Displays text in a box. -void CList::DrawCase(char *text, Math::Point pos, float width, int justif) +void CList::DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif) { - if ( justif == 1 ) - { - m_engine->RetText()->DrawText(text, pos, width, 1, m_fontSize, m_fontStretch, m_fontType, 0); - } - else if ( justif == 0 ) - { - pos.x += width/2.0f; - m_engine->RetText()->DrawText(text, pos, width, 0, m_fontSize, m_fontStretch, m_fontType, 0); - } - else - { + if (justif == Gfx::TEXT_ALIGN_CENTER) + pos.x += width / 2.0f; + else if (justif == Gfx::TEXT_ALIGN_RIGHT) pos.x += width; - m_engine->RetText()->DrawText(text, pos, width, -1, m_fontSize, m_fontStretch, m_fontType, 0); - } + m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, width, justif, 0); } @@ -593,7 +531,7 @@ void CList::SetTotal(int i) // Returns the total number of lines. -int CList::RetTotal() +int CList::GetTotal() { return m_totalLine; } @@ -604,11 +542,8 @@ int CList::RetTotal() void CList::SetSelect(int i) { if ( m_bSelectCap ) - { m_selectLine = i; - } - else - { + else { m_firstLine = i; UpdateScroll(); } @@ -618,16 +553,12 @@ void CList::SetSelect(int i) // Returns the selected line. -int CList::RetSelect() +int CList::GetSelect() { if ( m_bSelectCap ) - { return m_selectLine; - } else - { return m_firstLine; - } } @@ -638,7 +569,7 @@ void CList::SetSelectCap(bool bEnable) m_bSelectCap = bEnable; } -bool CList::RetSelectCap() +bool CList::GetSelectCap() { return m_bSelectCap; } @@ -648,25 +579,22 @@ bool CList::RetSelectCap() void CList::SetBlink(bool bEnable) { - int i; + int i; m_bBlink = bEnable; m_blinkTime = 0.0f; i = m_selectLine-m_firstLine; - if ( i >= 0 && i < 4 && - m_button[i] != 0 ) - { - if ( !bEnable ) - { + if (i >= 0 && i < 4 && m_button[i] != nullptr) { + if ( !bEnable ) { m_button[i]->SetState(STATE_CHECK); m_button[i]->ClearState(STATE_ENABLE); } } } -bool CList::RetBlink() +bool CList::GetBlink() { return m_bBlink; } @@ -674,32 +602,29 @@ bool CList::RetBlink() // Specifies the text of a line. -void CList::SetName(int i, char* name) +void CList::SetName(int i, const char* name) { - if ( i < 0 || i >= LISTMAXTOTAL ) return; + if ( i < 0 || i >= LISTMAXTOTAL ) + return; if ( i >= m_totalLine ) - { m_totalLine = i+1; // expands the list - } if ( name[0] == 0 ) - { strcpy(m_text[i], " "); - } else - { strcpy(m_text[i], name); - } + UpdateButton(); UpdateScroll(); } // Returns the text of a line. -char* CList::RetName(int i) +char* CList::GetName(int i) { - if ( i < 0 || i >= m_totalLine ) return 0; + if ( i < 0 || i >= m_totalLine ) + return 0; return m_text[i]; } @@ -709,16 +634,18 @@ char* CList::RetName(int i) void CList::SetCheck(int i, bool bMode) { - if ( i < 0 || i >= m_totalLine ) return; + if ( i < 0 || i >= m_totalLine ) + return; m_check[i] = bMode; } // Returns the bit "check" for a box. -bool CList::RetCheck(int i) +bool CList::GetCheck(int i) { - if ( i < 0 || i >= m_totalLine ) return false; + if ( i < 0 || i >= m_totalLine ) + return false; return m_check[i]; } @@ -728,16 +655,18 @@ bool CList::RetCheck(int i) void CList::SetEnable(int i, bool bMode) { - if ( i < 0 || i >= m_totalLine ) return; + if ( i < 0 || i >= m_totalLine ) + return; m_enable[i] = bMode; } // Returns the bit "enable" for a box. -bool CList::RetEnable(int i) +bool CList::GetEnable(int i) { - if ( i < 0 || i >= m_totalLine ) return false; + if ( i < 0 || i >= m_totalLine ) + return false; return m_enable[i]; } @@ -745,16 +674,18 @@ bool CList::RetEnable(int i) // Management of the position of the tabs. -void CList::SetTabs(int i, float pos, int justif) +void CList::SetTabs(int i, float pos, Gfx::TextAlign justif) { - if ( i < 0 || i >= 10 ) return; + if ( i < 0 || i >= 10 ) + return; m_tabs[i] = pos; m_justifs[i] = justif; } -float CList::RetTabs(int i) +float CList::GetTabs(int i) { - if ( i < 0 || i >= 10 ) return 0.0f; + if ( i < 0 || i >= 10 ) + return 0.0f; return m_tabs[i]; } @@ -765,19 +696,20 @@ void CList::ShowSelect(bool bFixed) { int sel; - if ( bFixed && - m_selectLine >= m_firstLine && - m_selectLine < m_firstLine+m_displayLine ) return; // all good + if ( bFixed && m_selectLine >= m_firstLine && m_selectLine < m_firstLine+m_displayLine ) + return; // all good sel = m_selectLine; // Down from 1/2 * h. - sel += m_displayLine/2; - if ( sel > m_totalLine-1 ) sel = m_totalLine-1; + sel += m_displayLine / 2; + if ( sel > m_totalLine - 1 ) + sel = m_totalLine - 1; // Back to h-1. - sel -= m_displayLine-1; - if ( sel < 0 ) sel = 0; + sel -= m_displayLine - 1; + if ( sel < 0 ) + sel = 0; m_firstLine = sel; @@ -790,25 +722,22 @@ void CList::ShowSelect(bool bFixed) void CList::UpdateButton() { - int state, i, j; + int state, i, j; - state = CControl::RetState(); + state = CControl::GetState(); j = m_firstLine; - for ( i=0 ; i<m_displayLine ; i++ ) - { - if ( m_button[i] == 0 ) continue; + for (i = 0; i < m_displayLine; i++) { + if (m_button[i] == nullptr) + continue; m_button[i]->SetState(STATE_CHECK, (j == m_selectLine)); - if ( j < m_totalLine ) - { + if ( j < m_totalLine ) { //? m_button[i]->SetName(m_text[j]); m_button[i]->SetName(" "); // blank button m_button[i]->SetState(STATE_ENABLE, (state & STATE_ENABLE)); - } - else - { + } else { m_button[i]->SetName(" "); // blank button m_button[i]->ClearState(STATE_ENABLE); } @@ -820,27 +749,28 @@ void CList::UpdateButton() void CList::UpdateScroll() { - float ratio, value, step; + float ratio, value, step; - if ( m_scroll == 0 ) return; + if (m_scroll == nullptr) + return; - if ( m_totalLine <= m_displayLine ) - { + if (m_totalLine <= m_displayLine) { ratio = 1.0f; value = 0.0f; step = 0.0f; - } - else - { - ratio = (float)m_displayLine/m_totalLine; + } else { + ratio = static_cast<float>(m_displayLine) / m_totalLine; if ( ratio > 1.0f ) ratio = 1.0f; - value = (float)m_firstLine/(m_totalLine-m_displayLine); - if ( value < 0.0f ) value = 0.0f; - if ( value > 1.0f ) value = 1.0f; + value = static_cast<float>(m_firstLine) / (m_totalLine - m_displayLine); + if ( value < 0.0f ) + value = 0.0f; + if ( value > 1.0f ) + value = 1.0f; - step = (float)1.0f/(m_totalLine-m_displayLine); - if ( step < 0.0f ) step = 0.0f; + step = static_cast<float>(1.0f)/ (m_totalLine - m_displayLine); + if ( step < 0.0f ) + step = 0.0f; } m_scroll->SetVisibleRatio(ratio); @@ -852,17 +782,21 @@ void CList::UpdateScroll() void CList::MoveScroll() { - float pos; - int n; + float pos; + int n; - if ( m_scroll == 0 ) return; + if ( m_scroll == 0 ) + return; - n = m_totalLine-m_displayLine; - pos = m_scroll->RetVisibleValue(); - pos += m_scroll->RetArrowStep()/2.0f; // it's magic! - m_firstLine = (int)(pos*n); - if ( m_firstLine < 0 ) m_firstLine = 0; - if ( m_firstLine > n ) m_firstLine = n; + n = m_totalLine - m_displayLine; + pos = m_scroll->GetVisibleValue(); + pos += m_scroll->GetArrowStep() / 2.0f; // it's magic! + m_firstLine = static_cast<int>(pos * n); + if ( m_firstLine < 0 ) + m_firstLine = 0; + if ( m_firstLine > n ) + m_firstLine = n; } +} diff --git a/src/ui/list.h b/src/ui/list.h index cc9e646..97bd48c 100644 --- a/src/ui/list.h +++ b/src/ui/list.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 @@ -20,13 +21,16 @@ #include "ui/control.h" +#include "ui/button.h" +#include "ui/scroll.h" + #include "common/event.h" +#include "common/misc.h" +#include "graphics/engine/text.h" -class CD3DEngine; -class CButton; -class CScroll; +namespace Ui { const int LISTMAXDISPLAY = 20; // maximum number of visible lines const int LISTMAXTOTAL = 100; // maximum total number of lines @@ -35,81 +39,83 @@ 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 GetTotal(); - void SetSelect(int i); - int RetSelect(); + void SetSelect(int i); + int GetSelect(); - void SetSelectCap(bool bEnable); - bool RetSelectCap(); + void SetSelectCap(bool bEnable); + bool GetSelectCap(); - void SetBlink(bool bEnable); - bool RetBlink(); + void SetBlink(bool bEnable); + bool GetBlink(); - void SetName(int i, char* name); - char* RetName(int i); + void SetName(int i, const char* name); + char* GetName(int i); - void SetCheck(int i, bool bMode); - bool RetCheck(int i); + void SetCheck(int i, bool bMode); + bool GetCheck(int i); - void SetEnable(int i, bool bEnable); - bool RetEnable(int i); + void SetEnable(int i, bool bEnable); + bool GetEnable(int i); - void SetTabs(int i, float pos, int justif=1); - float RetTabs(int i); + void SetTabs(int i, float pos, Gfx::TextAlign justif=Gfx::TEXT_ALIGN_LEFT); + float GetTabs(int i); - void ShowSelect(bool bFixed); + void ShowSelect(bool bFixed); - EventMsg RetEventMsgButton(int i); - EventMsg RetEventMsgScroll(); + EventType GetEventMsgButton(int i); + EventType GetEventMsgScroll(); -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, Gfx::TextAlign 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]; + Gfx::TextAlign 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/maindialog.cpp b/src/ui/maindialog.cpp index c8759e0..a40cc27 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -8,7 +8,7 @@ // * // * This program is distributed in the hope that it will be useful, // * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * MERCHANTABILITY or FITNESS FOR A Gfx::PARTICULAR PURPOSE. See the // * GNU General Public License for more details. // * // * You should have received a copy of the GNU General Public License @@ -16,26 +16,17 @@ // maindialog.cpp +#include "ui/maindialog.h" -#include <windows.h> -#include <stdio.h> -#include <time.h> -#include <direct.h> -#include <io.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/d3dmath.h" #include "common/global.h" -#include "common/language.h" #include "common/event.h" #include "common/misc.h" #include "common/profile.h" #include "common/iman.h" #include "common/restext.h" -#include "old/math3d.h" -#include "old/particule.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" @@ -50,24 +41,22 @@ #include "ui/window.h" #include "ui/edit.h" #include "ui/editvalue.h" -#include "old/text.h" -#include "old/camera.h" -#include "old/sound.h" -#include "script/cmdtoken.h" -#include "object/robotmain.h" -#include "ui/maindialog.h" +#include <stdio.h> +#include <string.h> +namespace Ui +{ + const int KEY_VISIBLE = 6; // number of visible keys redefinable -#if _SCHOOL & _TEEN +/*TODO: #if _SCHOOL & _TEEN const int KEY_TOTAL = 13; // total number of keys redefinable -#else +#else*/ const int KEY_TOTAL = 21; // total number of keys redefinable -#endif -const int WELCOME_LENGTH = 6.0f; +const float WELCOME_LENGTH = 2.0f; @@ -109,7 +98,7 @@ static int perso_color[3*10*3] = }; -#if _NET +/* TODO: ? #if _NET // Check if the key "school" is present in the registry. bool SchoolCheck() @@ -138,24 +127,24 @@ bool SchoolCheck() return true; } #endif - +*/ // Constructor of robot application. CMainDialog::CMainDialog(CInstanceManager* iMan) { - int i; - m_iMan = iMan; m_iMan->AddInstance(CLASS_DIALOG, this); - m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); - m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); - m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); + 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_phase = PHASE_NAME; m_phaseSetup = PHASE_SETUPg; @@ -166,18 +155,18 @@ CMainDialog::CMainDialog(CInstanceManager* iMan) m_sceneRank = 0; m_bSceneSoluce = false; m_bSimulSetup = false; -#if _NET +/* TODO: ? #if _NET m_accessEnable = SchoolCheck(); m_accessMission= false; m_accessUser = false; -#else +#else*/ m_accessEnable = true; m_accessMission= true; m_accessUser = true; -#endif + m_bDeleteGamer = true; - for ( i=0 ; i<10 ; i++ ) + for (int i = 0; i < 10; i++) { m_chap[i] = 0; m_sel[i] = 0; @@ -185,7 +174,7 @@ CMainDialog::CMainDialog(CInstanceManager* iMan) m_index = 0; m_maxList = 0; - ZeroMemory(&m_perso, sizeof(GamerPerso)); + memset(&m_perso, 0, sizeof(GamerPerso)); DefPerso(); m_bTooltip = true; @@ -195,11 +184,11 @@ CMainDialog::CMainDialog(CInstanceManager* iMan) m_bMovies = true; m_bNiceReset = true; m_bHimselfDamage = true; -#if _TEEN +/* TODO: #if _TEEN m_bCameraScroll = false; -#else +#else*/ m_bCameraScroll = true; -#endif + m_bCameraInvertX = false; m_bCameraInvertY = false; m_bEffect = true; @@ -208,7 +197,7 @@ CMainDialog::CMainDialog(CInstanceManager* iMan) m_glintMouse = Math::Point(0.0f, 0.0f); m_glintTime = 1000.0f; - for ( i=0 ; i<10 ; i++ ) + for (int i = 0; i < 10; i++) { m_partiPhase[i] = 0; m_partiTime[i] = 0.0f; @@ -252,9 +241,9 @@ void CMainDialog::ChangePhase(Phase phase) char* gamer; int res, i, j; - m_camera->SetType(CAMERA_DIALOG); + m_camera->SetType(Gfx::CAM_TYPE_DIALOG); m_engine->SetOverFront(false); - m_engine->SetOverColor(RetColor(0.0f), D3DSTATETCb); + m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok? if ( phase == PHASE_TERM ) { @@ -276,11 +265,11 @@ void CMainDialog::ChangePhase(Phase phase) pos.y = 0.10f; ddim.x = 0.30f; ddim.y = 0.80f; -#if _TEEN +/* TODO: #if _TEEN pw = m_interface->CreateWindows(pos, ddim, 12, EVENT_WINDOW5); -#else +#else*/ pw = m_interface->CreateWindows(pos, ddim, 10, EVENT_WINDOW5); -#endif + GetResource(RES_TEXT, RT_TITLE_INIT, name); pw->SetName(name); @@ -295,7 +284,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.30f; pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner -#if _SCHOOL +/* TODO: #if _SCHOOL ddim.x = 0.20f; ddim.y = dim.y*2.4f; pos.x = 0.40f; @@ -309,7 +298,7 @@ void CMainDialog::ChangePhase(Phase phase) pos.y = oy+sy*1.9f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // red pg->SetState(STATE_SHADOW); -#else +#else */ ddim.x = 0.20f; ddim.y = dim.y*2.4f; pos.x = 0.40f; @@ -329,9 +318,8 @@ void CMainDialog::ChangePhase(Phase phase) pos.y = oy+sy*1.9f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // red pg->SetState(STATE_SHADOW); -#endif -#if _SCHOOL +/* TODO: #if _SCHOOL ddim.x = 0.18f; ddim.y = dim.y*1; pos.x = 0.41f; @@ -349,7 +337,7 @@ void CMainDialog::ChangePhase(Phase phase) pb->ClearState(STATE_ENABLE); #endif pb->SetState(STATE_SHADOW); -#else +#else */ ddim.x = 0.18f; ddim.y = dim.y*1; pos.x = 0.41f; @@ -372,14 +360,15 @@ void CMainDialog::ChangePhase(Phase phase) pos.y = oy+sy*6.9f; pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_DEFI); pb->SetState(STATE_SHADOW); -#endif - if ( m_engine->RetSetupMode() ) + + /* TODO: setup mode? + if ( m_engine->GetSetupMode() ) { pos.y = oy+sy*5.1f; pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_SETUP); pb->SetState(STATE_SHADOW); - } + } */ pos.y = oy+sy*4.0f; pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NAME); @@ -389,22 +378,22 @@ void CMainDialog::ChangePhase(Phase phase) pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_QUIT); pb->SetState(STATE_SHADOW); -#if !_DEMO & !_SCHOOL +// TODO: #if !_DEMO & !_SCHOOL if ( m_accessEnable && m_accessUser ) { pos.x = 447.0f/640.0f; pos.y = 313.0f/480.0f; ddim.x = 0.09f; -#if _POLISH +/*#if _POLISH pos.x -= 5.0f/640.0f; ddim.x += 10.0f/640.0f; -#endif +#endif*/ pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_USER); pb->SetState(STATE_SHADOW); } -#endif +// #endif - if ( m_engine->RetDebugMode() ) + if ( m_app->GetDebugMode() ) { pos.x = 139.0f/640.0f; pos.y = 313.0f/480.0f; @@ -420,19 +409,16 @@ void CMainDialog::ChangePhase(Phase phase) pg = pw->CreateGroup(pos, ddim, 1, EVENT_LABEL1); pg->SetState(STATE_SHADOW); pos.y -= 5.0f/480.0f; -#if _WG - pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, " "); -#else -#if _NEWLOOK - pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "www.epsitec.ch"); -#else - pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "www.ceebot.com"); -#endif -#endif - pl->SetFontType(FONT_COURIER); + pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "PPC Team"); + pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontSize(8.0f); - m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true); + m_engine->SetBackground("interface.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(1.0f, 768.0f / 1024.0f)); m_engine->SetBackForce(true); } @@ -446,7 +432,7 @@ void CMainDialog::ChangePhase(Phase phase) GetResource(RES_TEXT, RT_TITLE_NAME, name); pw->SetName(name); -#if _NEWLOOK +/* TODO: #if _NEWLOOK pos.x = 80.0f/640.0f; pos.y = 93.0f/480.0f; ddim.x = 285.0f/640.0f; @@ -457,7 +443,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 188.0f/640.0f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet pg->SetState(STATE_SHADOW); -#endif +#endif*/ pos.x = 0.10f; pos.y = 0.40f; @@ -476,7 +462,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 32.0f/480.0f; GetResource(RES_EVENT, EVENT_INTERFACE_NLABEL, name); pl = pw->CreateLabel(pos, ddim, -1, EVENT_INTERFACE_NLABEL, name); - pl->SetJustif(-1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT); pos.x = 200.0f/640.0f; pos.y = 320.0f/480.0f; @@ -491,7 +477,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_NEDIT); pe->SetMaxChar(15); - gamer = m_main->RetGamerName(); + gamer = m_main->GetGamerName(); if ( gamer[0] == 0 ) { GetResource(RES_TEXT, RT_NAME_DEFAULT, name); @@ -511,14 +497,14 @@ void CMainDialog::ChangePhase(Phase phase) pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NOK); pb->SetState(STATE_SHADOW); -#if !_TEEN +/* TODO: #if !_TEEN pos.x = 380.0f/640.0f; pos.y = 250.0f/480.0f; ddim.x =100.0f/640.0f; ddim.y = 52.0f/480.0f; pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_PERSO); pb->SetState(STATE_SHADOW); -#endif +#endif*/ pos.x = 200.0f/640.0f; pos.y = 150.0f/480.0f; @@ -549,7 +535,12 @@ void CMainDialog::ChangePhase(Phase phase) UpdateNameControl(); UpdateNameFace(); - m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true); + m_engine->SetBackground("interface.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(1.0f, 768.0f / 1024.0f)); m_engine->SetBackForce(true); } @@ -563,14 +554,14 @@ void CMainDialog::ChangePhase(Phase phase) GetResource(RES_TEXT, RT_TITLE_PERSO, name); pw->SetName(name); -#if _NEWLOOK +/* TODO: #if _NEWLOOK pos.x = 95.0f/640.0f; pos.y = 66.0f/480.0f; ddim.x = 443.0f/640.0f; ddim.y = 42.0f/480.0f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet pg->SetState(STATE_SHADOW); -#endif +#endif*/ pos.x = 0.10f; pos.y = 0.40f; @@ -628,7 +619,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 200.0f/640.0f; ddim.y = 16.0f/480.0f; pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, ""); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.x = 340.0f/640.0f; pos.y = 312.0f/480.0f; @@ -652,7 +643,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 200.0f/640.0f; ddim.y = 16.0f/480.0f; pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, ""); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.x = 340.0f/640.0f; pos.y = 240.0f/480.0f; @@ -661,7 +652,7 @@ void CMainDialog::ChangePhase(Phase phase) for ( i=0 ; i<6 ; i++ ) { int ti[6] = {11, 179, 180, 181, 182, 183}; - pb = pw->CreateButton(pos, ddim, ti[i], (EventMsg)(EVENT_INTERFACE_PGLASS0+i)); + pb = pw->CreateButton(pos, ddim, ti[i], static_cast<EventType>(EVENT_INTERFACE_PGLASS0+i)); pb->SetState(STATE_SHADOW); pos.x += (30.0f+2.8f)/640.0f; } @@ -672,7 +663,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 200.0f/640.0f; ddim.y = 16.0f/480.0f; pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL14, ""); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.y = 282.0f/480.0f; ddim.x = 18.0f/640.0f; @@ -682,7 +673,7 @@ void CMainDialog::ChangePhase(Phase phase) pos.x = 340.0f/640.0f; for ( i=0 ; i<3 ; i++ ) { - pco = pw->CreateColor(pos, ddim, -1, (EventMsg)(EVENT_INTERFACE_PC0a+j*3+i)); + pco = pw->CreateColor(pos, ddim, -1, static_cast<EventType>(EVENT_INTERFACE_PC0a+j*3+i)); pco->SetState(STATE_SHADOW); pos.x += 20.0f/640.0f; } @@ -695,7 +686,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; for ( i=0 ; i<3 ; i++ ) { - psl = pw->CreateSlider(pos, ddim, 0, (EventMsg)(EVENT_INTERFACE_PCRa+i)); + psl = pw->CreateSlider(pos, ddim, 0, static_cast<EventType>(EVENT_INTERFACE_PCRa+i)); psl->SetState(STATE_SHADOW); psl->SetLimit(0.0f, 255.0f); psl->SetArrowStep(16.0f); @@ -708,7 +699,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 200.0f/640.0f; ddim.y = 16.0f/480.0f; pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL13, ""); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.y = 174.0f/480.0f; ddim.x = 18.0f/640.0f; @@ -718,7 +709,7 @@ void CMainDialog::ChangePhase(Phase phase) pos.x = 340.0f/640.0f; for ( i=0 ; i<3 ; i++ ) { - pco = pw->CreateColor(pos, ddim, -1, (EventMsg)(EVENT_INTERFACE_PC0b+j*3+i)); + pco = pw->CreateColor(pos, ddim, -1, static_cast<EventType>(EVENT_INTERFACE_PC0b+j*3+i)); pco->SetState(STATE_SHADOW); pos.x += 20.0f/640.0f; } @@ -731,7 +722,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; for ( i=0 ; i<3 ; i++ ) { - psl = pw->CreateSlider(pos, ddim, 0, (EventMsg)(EVENT_INTERFACE_PCRb+i)); + psl = pw->CreateSlider(pos, ddim, 0, static_cast<EventType>(EVENT_INTERFACE_PCRb+i)); psl->SetState(STATE_SHADOW); psl->SetLimit(0.0f, 255.0f); psl->SetArrowStep(16.0f); @@ -804,7 +795,7 @@ void CMainDialog::ChangePhase(Phase phase) { strcpy(m_sceneName, "scene"); ReadGamerInfo(); - m_accessChap = RetChapPassed(); + m_accessChap = GetChapPassed(); } if ( m_phase == PHASE_TRAINER ) strcpy(m_sceneName, "train"); @@ -833,7 +824,7 @@ void CMainDialog::ChangePhase(Phase phase) GetResource(RES_TEXT, res, name); pw->SetName(name); -#if _NEWLOOK +/* TODO: #if _NEWLOOK pos.x = 100.0f/640.0f; pos.y = 226.0f/480.0f; ddim.x = 216.0f/640.0f; @@ -854,7 +845,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 42.0f/480.0f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet pg->SetState(STATE_SHADOW); -#endif +#endif */ pos.x = 0.10f; pos.y = 0.40f; @@ -881,7 +872,7 @@ void CMainDialog::ChangePhase(Phase phase) if ( m_phase == PHASE_PROTO ) res = RT_PLAY_CHAPp; GetResource(RES_TEXT, res, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.y = oy+sy*6.7f; ddim.y = dim.y*4.5f; @@ -905,7 +896,7 @@ void CMainDialog::ChangePhase(Phase phase) if ( m_phase == PHASE_PROTO ) res = RT_PLAY_LISTp; GetResource(RES_TEXT, res, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.y = oy+sy*6.7f; ddim.y = dim.y*4.5f; @@ -914,8 +905,8 @@ void CMainDialog::ChangePhase(Phase phase) pli->SetState(STATE_SHADOW); UpdateSceneList(m_chap[m_index], m_sel[m_index]); if ( m_phase != PHASE_USER ) pli->SetState(STATE_EXTEND); - pos = pli->RetPos(); - ddim = pli->RetDim(); + pos = pli->GetPos(); + ddim = pli->GetDim(); // Displays the summary: pos.x = ox+sx*3; @@ -924,7 +915,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = dim.y*0.6f; GetResource(RES_TEXT, RT_PLAY_RESUME, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL13, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.x = ox+sx*3; pos.y = oy+sy*3.6f; @@ -996,7 +987,12 @@ void CMainDialog::ChangePhase(Phase phase) pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_BACK); pb->SetState(STATE_SHADOW); - m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true); + m_engine->SetBackground("interface.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(1.0f, 768.0f / 1024.0f)); m_engine->SetBackForce(true); } @@ -1063,7 +1059,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.05f; pw->CreateGroup(pos, ddim, 3, EVENT_NULL); // transparent -> gray -#if _NEWLOOK +/* TODO: #if _NEWLOOK if ( m_phase == PHASE_SETUPd || // setup/display ? m_phase == PHASE_SETUPds ) { @@ -1135,7 +1131,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 42.0f/480.0f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet pg->SetState(STATE_SHADOW); -#endif +#endif */ ddim.x = 0.78f/5-0.01f; ddim.y = 0.06f; @@ -1190,7 +1186,12 @@ void CMainDialog::ChangePhase(Phase phase) if ( !m_bSimulSetup ) { - m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true); + m_engine->SetBackground("interface.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(1.0f, 768.0f / 1024.0f)); m_engine->SetBackForce(true); } } @@ -1204,7 +1205,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = dim.y*1; GetResource(RES_TEXT, RT_SETUP_DEVICE, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.x = ox+sx*3; pos.y = oy+sy*5.2f; @@ -1220,9 +1221,9 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = dim.y*1; GetResource(RES_TEXT, RT_SETUP_MODE, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); - m_setupFull = m_engine->RetFullScreen(); + m_setupFull = m_app->GetVideoConfig().fullScreen; pos.x = ox+sx*10; pos.y = oy+sy*5.2f; ddim.x = dim.x*6; @@ -1263,7 +1264,8 @@ void CMainDialog::ChangePhase(Phase phase) { pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_GROUND); pc->SetState(STATE_SHADOW); - if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE); + // TODO: video 8 MB? + //if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE); } pos.y -= 0.048f; pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_DIRTY); @@ -1271,7 +1273,8 @@ void CMainDialog::ChangePhase(Phase phase) pos.y -= 0.048f; pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SKY); pc->SetState(STATE_SHADOW); - if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE); + // TODO: video 8 MB? + //if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE); pos.y -= 0.048f; pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_LENS); pc->SetState(STATE_SHADOW); @@ -1301,7 +1304,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 0.40f; GetResource(RES_EVENT, EVENT_INTERFACE_PARTI, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL10, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.x = ox+sx*8.5f; pos.y = 0.59f; @@ -1316,7 +1319,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 0.40f; GetResource(RES_EVENT, EVENT_INTERFACE_CLIP, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.x = ox+sx*8.5f; pos.y = 0.53f; @@ -1331,7 +1334,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 0.40f; GetResource(RES_EVENT, EVENT_INTERFACE_DETAIL, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); if ( !m_bSimulSetup ) { @@ -1348,7 +1351,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 0.40f; GetResource(RES_EVENT, EVENT_INTERFACE_GADGET, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL13, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); } #if 0 @@ -1369,7 +1372,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 0.40f; GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL14, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); } #endif @@ -1377,10 +1380,10 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = dim.y*1; pos.x = ox+sx*10; pos.y = oy+sy*2; -#if _POLISH +/* TODO: #if _POLISH ddim.x += 20.0f/640.0f; pos.x -= 20.0f/640.0f*3.0f; -#endif +#endif*/ pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_MIN); pb->SetState(STATE_SHADOW); pos.x += ddim.x; @@ -1403,17 +1406,17 @@ void CMainDialog::ChangePhase(Phase phase) //? pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_TOTO); //? pc->SetState(STATE_SHADOW); //? pos.y -= 0.048f; -#if _SCHOOL +/*TODO: #if _SCHOOL #if _EDU pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SOLUCE4); pc->SetState(STATE_SHADOW); pos.y -= 0.048f; #endif -#else +#else*/ pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOVIES); pc->SetState(STATE_SHADOW); pos.y -= 0.048f; -#endif +//#endif pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SCROLL); pc->SetState(STATE_SHADOW); pos.y -= 0.048f; @@ -1470,7 +1473,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; GetResource(RES_TEXT, RT_SETUP_KEY1, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_KINFO1, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.x = ox+sx*3; pos.y = 302.0f/480.0f; @@ -1478,7 +1481,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; GetResource(RES_TEXT, RT_SETUP_KEY2, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_KINFO2, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); ddim.x = 428.0f/640.0f; ddim.y = 128.0f/480.0f; @@ -1494,8 +1497,8 @@ void CMainDialog::ChangePhase(Phase phase) pos.x = 510.0f/640.0f; pos.y = 168.0f/480.0f; ps = pw->CreateScroll(pos, ddim, -1, EVENT_INTERFACE_KSCROLL); - ps->SetVisibleRatio((float)KEY_VISIBLE/KEY_TOTAL); - ps->SetArrowStep(1.0f/((float)KEY_TOTAL-KEY_VISIBLE)); + ps->SetVisibleRatio(static_cast<float>(KEY_VISIBLE/KEY_TOTAL)); + ps->SetArrowStep(1.0f/(static_cast<float>(KEY_TOTAL-KEY_VISIBLE))); UpdateKey(); ddim.x = dim.x*6; @@ -1529,9 +1532,9 @@ void CMainDialog::ChangePhase(Phase phase) pos.y += ddim.y; GetResource(RES_EVENT, EVENT_INTERFACE_VOLSOUND, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); -#if (_FULL | _NET) & _SOUNDTRACKS +// TODO: #if (_FULL | _NET) & _SOUNDTRACKS pos.x = ox+sx*3; pos.y = 0.40f; ddim.x = dim.x*4.0f; @@ -1543,8 +1546,8 @@ void CMainDialog::ChangePhase(Phase phase) pos.y += ddim.y; GetResource(RES_EVENT, EVENT_INTERFACE_VOLMUSIC, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name); - pl->SetJustif(1); -#endif + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); +// #endif ddim.x = dim.x*6; ddim.y = dim.y*0.5f; @@ -1589,14 +1592,14 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.50f; pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner -#if _NEWLOOK +/* TODO: #if _NEWLOOK pos.x = 100.0f/640.0f; pos.y = 66.0f/480.0f; ddim.x = 438.0f/640.0f; ddim.y = 42.0f/480.0f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet pg->SetState(STATE_SHADOW); -#endif +#endif */ pos.x = 290.0f/640.0f; ddim.x = 245.0f/640.0f; @@ -1605,13 +1608,13 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 18.0f/480.0f; GetResource(RES_EVENT, EVENT_INTERFACE_IOLABEL, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_IOLABEL, name); - pl->SetJustif(1); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pos.y = 130.0f/480.0f; ddim.y = 18.0f/480.0f; pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_IONAME); pe->SetState(STATE_SHADOW); - pe->SetFontType(FONT_COLOBOT); + pe->SetFontType(Gfx::FONT_COLOBOT); pe->SetMaxChar(35); IOReadName(); @@ -1673,14 +1676,14 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.50f; pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner -#if _NEWLOOK +/* TODO: #if _NEWLOOK pos.x = 100.0f/640.0f; pos.y = 66.0f/480.0f; ddim.x = 438.0f/640.0f; ddim.y = 42.0f/480.0f; pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet pg->SetState(STATE_SHADOW); -#endif +#endif*/ pos.x = 290.0f/640.0f; ddim.x = 245.0f/640.0f; @@ -1725,7 +1728,12 @@ void CMainDialog::ChangePhase(Phase phase) if ( m_phase == PHASE_READ ) { - m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true); + m_engine->SetBackground("interface.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(1.0f, 768.0f / 1024.0f)); m_engine->SetBackForce(true); } } @@ -1736,11 +1744,11 @@ void CMainDialog::ChangePhase(Phase phase) pos.y = 0.10f; ddim.x = 0.30f; ddim.y = 0.80f; -#if _TEEN +/*TODO: #if _TEEN pw = m_interface->CreateWindows(pos, ddim, 12, EVENT_WINDOW5); -#else +#else*/ pw = m_interface->CreateWindows(pos, ddim, 10, EVENT_WINDOW5); -#endif + pw->SetName(" "); pos.x = 0.35f; @@ -1768,9 +1776,14 @@ void CMainDialog::ChangePhase(Phase phase) GetResource(RES_TEXT, RT_DIALOG_LOADING, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); pl->SetFontSize(12.0f); - pl->SetJustif(0); - - m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true); + pl->SetTextAlign(Gfx::TEXT_ALIGN_CENTER); + + m_engine->SetBackground("interface.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(1.0f, 768.0f / 1024.0f)); m_engine->SetBackForce(true); m_loadingCounter = 1; // enough time to display! @@ -1787,30 +1800,21 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.0f; pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5); - m_engine->SetOverColor(RetColor(1.0f), D3DSTATETCb); + m_engine->SetOverColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok? m_engine->SetOverFront(true); -#if _FRENCH - m_engine->SetBackground("alsyd.tga", 0,0, 0,0, true, false); -#endif -#if _POLISH - m_engine->SetBackground("manta.tga", 0,0, 0,0, true, false); -#endif -#if _WG - m_engine->SetBackground("wg.tga", 0,0, 0,0, true, false); -#endif + m_engine->SetBackground("ppc.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(861.0f / 1024.0f, 646.0f / 1024.0f)); m_engine->SetBackForce(true); } if ( m_phase == PHASE_WELCOME2 ) { -#if _ENGLISH m_sound->StopMusic(); m_sound->PlayMusic(11, false); -#endif -#if _POLISH - m_sound->StopMusic(); - m_sound->PlayMusic(11, false); -#endif pos.x = 0.0f; pos.y = 0.0f; @@ -1818,10 +1822,15 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.0f; pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5); - m_engine->SetOverColor(RetColor(1.0f), D3DSTATETCb); + m_engine->SetOverColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok? m_engine->SetOverFront(true); - m_engine->SetBackground("colobot.tga", 0,0, 0,0, true, false); + m_engine->SetBackground("colobot.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f)); m_engine->SetBackForce(true); } if ( m_phase == PHASE_WELCOME3 ) @@ -1832,21 +1841,15 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.0f; pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5); - m_engine->SetOverColor(RetColor(0.0f), D3DSTATETCw); + m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_WHITE); // TODO: color ok? m_engine->SetOverFront(true); -#if _FRENCH - m_engine->SetBackground("epsitecf.tga", 0,0, 0,0, true, false); -#endif -#if _ENGLISH - m_engine->SetBackground("epsitece.tga", 0,0, 0,0, true, false); -#endif -#if _GERMAN | _WG - m_engine->SetBackground("epsitecd.tga", 0,0, 0,0, true, false); -#endif -#if _POLISH - m_engine->SetBackground("epsitecp.tga", 0,0, 0,0, true, false); -#endif + m_engine->SetBackground("epsitec.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f)); m_engine->SetBackForce(true); } @@ -1858,7 +1861,7 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 0.0f; pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5); -#if _FULL | _NET +// TODO: #if _FULL | _NET pos.x = 80.0f/640.0f; pos.y = 240.0f/480.0f; ddim.x = 490.0f/640.0f; @@ -1867,7 +1870,7 @@ void CMainDialog::ChangePhase(Phase phase) pe->SetGenericMode(true); pe->SetEditCap(false); pe->SetHiliteCap(false); - pe->SetFontType(FONT_COURIER); + pe->SetFontType(Gfx::FONT_COURIER); pe->SetFontSize(8.0f); pe->ReadText("help\\authors.txt"); @@ -1879,11 +1882,11 @@ void CMainDialog::ChangePhase(Phase phase) pe->SetGenericMode(true); pe->SetEditCap(false); pe->SetHiliteCap(false); - pe->SetFontType(FONT_COURIER); + pe->SetFontType(Gfx::FONT_COURIER); pe->SetFontSize(6.5f); pe->ReadText("help\\licences.txt"); -#endif -#if _SCHOOL +// #endif +/* TODO: #if _SCHOOL #if _CEEBOTDEMO pos.x = 80.0f/640.0f; pos.y = 210.0f/480.0f; @@ -1894,16 +1897,16 @@ void CMainDialog::ChangePhase(Phase phase) pos.y = 200.0f/480.0f; ddim.x = 490.0f/640.0f; ddim.y = 150.0f/480.0f; -#endif +#endif*/ pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1); pe->SetGenericMode(true); pe->SetEditCap(false); pe->SetHiliteCap(false); - pe->SetFontType(FONT_COURIER); + pe->SetFontType(Gfx::FONT_COURIER); pe->SetFontSize(8.0f); pe->ReadText("help\\authors.txt"); -#endif -#if _DEMO + +/* #if _DEMO //? pos.x = 80.0f/640.0f; //? pos.y = 240.0f/480.0f; //? ddim.x = 490.0f/640.0f; @@ -1912,7 +1915,7 @@ void CMainDialog::ChangePhase(Phase phase) //? pe->SetGenericMode(true); //? pe->SetEditCap(false); //? pe->SetHiliteCap(false); -//? pe->SetFontType(FONT_COURIER); +//? pe->SetFontType(Gfx::FONT_COURIER); //? pe->SetFontSize(8.0f); //? pe->ReadText("help\\demo.txt"); @@ -1924,25 +1927,25 @@ void CMainDialog::ChangePhase(Phase phase) //? pe->SetGenericMode(true); //? pe->SetEditCap(false); //? pe->SetHiliteCap(false); -//? pe->SetFontType(FONT_COURIER); +//? pe->SetFontType(Gfx::FONT_COURIER); //? pe->SetFontSize(8.0f); //? pe->ReadText("help\\authors.txt"); -#endif +#endif */ -#if !_DEMO +// TODO: #if !_DEMO pos.x = 40.0f/640.0f; pos.y = 83.0f/480.0f; ddim.x = 246.0f/640.0f; ddim.y = 16.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_DEV1, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); - pl->SetFontType(FONT_COURIER); + pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontSize(8.0f); pos.y = 13.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_DEV2, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name); - pl->SetFontType(FONT_COURIER); + pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontSize(8.0f); pos.x = 355.0f/640.0f; @@ -1951,79 +1954,38 @@ void CMainDialog::ChangePhase(Phase phase) ddim.y = 16.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_EDIT1, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name); - pl->SetFontType(FONT_COURIER); + pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontSize(8.0f); pos.y = 13.0f/480.0f; GetResource(RES_TEXT, RT_GENERIC_EDIT2, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name); - pl->SetFontType(FONT_COURIER); + pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontSize(8.0f); -#endif +// #endif -#if _DEMO +/* TODO: #if _DEMO pos.x = 481.0f/640.0f; pos.y = 51.0f/480.0f; ddim.x = 30.0f/640.0f; ddim.y = 30.0f/480.0f; pb = pw->CreateButton(pos, ddim, 49, EVENT_INTERFACE_ABORT); pb->SetState(STATE_SHADOW); -#else +#else */ pos.x = 306.0f/640.0f; pos.y = 17.0f/480.0f; ddim.x = 30.0f/640.0f; ddim.y = 30.0f/480.0f; pb = pw->CreateButton(pos, ddim, 49, EVENT_INTERFACE_ABORT); pb->SetState(STATE_SHADOW); -#endif - -#if _NEWLOOK -#if _CEEBOTDEMO -#if _TEEN - m_engine->SetBackground("genedt.tga", 0,0, 0,0, true, true); -#else - m_engine->SetBackground("geneda.tga", 0,0, 0,0, true, true); -#endif -#else - m_engine->SetBackground("genern.tga", 0,0, 0,0, true, true); -#endif -#else -#if _FRENCH -#if _DEMO - m_engine->SetBackground("genedf.tga", 0,0, 0,0, true, true); -#else - m_engine->SetBackground("generf.tga", 0,0, 0,0, true, true); -#endif -#endif -#if _ENGLISH -#if _DEMO - m_engine->SetBackground("genede.tga", 0,0, 0,0, true, true); -#else - m_engine->SetBackground("genere.tga", 0,0, 0,0, true, true); -#endif -#endif -#if _GERMAN -#if _DEMO - m_engine->SetBackground("genedd.tga", 0,0, 0,0, true, true); -#else - m_engine->SetBackground("genere.tga", 0,0, 0,0, true, true); -#endif -#endif -#if _WG -#if _DEMO - m_engine->SetBackground("genedd.tga", 0,0, 0,0, true, true); -#else - m_engine->SetBackground("generd.tga", 0,0, 0,0, true, true); -#endif -#endif -#if _POLISH -#if _DEMO - m_engine->SetBackground("genedp.tga", 0,0, 0,0, true, true); -#else - m_engine->SetBackground("generp.tga", 0,0, 0,0, true, true); -#endif -#endif -#endif +// #endif + + m_engine->SetBackground("generic.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), + Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), + true, Math::Point(1.0f, 768.0f / 1024.0f)); m_engine->SetBackForce(true); } @@ -2044,7 +2006,7 @@ void CMainDialog::ChangePhase(Phase phase) m_phase == PHASE_READ || m_phase == PHASE_LOADING ) { -#if _SCHOOL +/*TODO: #if _SCHOOL #if _TEEN pos.x = 50.0f/640.0f; pos.y = 430.0f/480.0f; @@ -2056,24 +2018,24 @@ void CMainDialog::ChangePhase(Phase phase) ddim.x = 170.0f/640.0f; ddim.y = 9.0f/480.0f; #endif -#else +#else */ pos.x = 540.0f/640.0f; pos.y = 9.0f/480.0f; ddim.x = 90.0f/640.0f; ddim.y = 10.0f/480.0f; -#endif +//#endif GetResource(RES_TEXT, RT_VERSION_ID, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); - pl->SetFontType(FONT_COURIER); + pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontSize(9.0f); } - m_engine->LoadAllTexture(); + m_engine->LoadAllTextures(); } // Processing an event. -// Returns false if the event has been processed completely. +// Geturns false if the event has been processed completely. bool CMainDialog::EventProcess(const Event &event) { @@ -2084,7 +2046,7 @@ bool CMainDialog::EventProcess(const Event &event) Event newEvent; float welcomeLength; - if ( event.event == EVENT_FRAME ) + if ( event.type == EVENT_FRAME ) { m_phaseTime += event.rTime; @@ -2097,7 +2059,7 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_WELCOME3 ) { float intensity; - int mode = D3DSTATETCb; + int mode = Gfx::ENG_RSTATE_TCOLOR_BLACK; if ( m_phaseTime < 1.5f ) { @@ -2118,10 +2080,10 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_WELCOME3 ) { intensity = 1.0f-intensity; - mode = D3DSTATETCw; + mode = Gfx::ENG_RSTATE_TCOLOR_WHITE; } - m_engine->SetOverColor(RetColor(intensity), mode); + m_engine->SetOverColor(Gfx::Color(intensity, intensity, intensity, intensity), mode); // TODO: color ok? } if ( m_phase == PHASE_WELCOME1 && m_phaseTime >= welcomeLength ) @@ -2163,7 +2125,7 @@ bool CMainDialog::EventProcess(const Event &event) m_glintTime += event.rTime; GlintMove(); // moves reflections - FrameParticule(event.rTime); + FrameParticle(event.rTime); if ( m_bDialog ) // this dialogue? { @@ -2173,18 +2135,18 @@ bool CMainDialog::EventProcess(const Event &event) return true; } - if ( event.event == EVENT_MOUSEMOVE ) + if ( event.type == EVENT_MOUSE_MOVE ) { m_glintMouse = event.pos; - NiceParticule(event.pos, event.keyState&KS_MLEFT); + NiceParticle(event.pos, event.keyState&KS_MLEFT); } if ( m_bDialog ) // this dialogue? { m_interface->EventProcess(event); - if ( event.event == EVENT_DIALOG_OK || - (event.event == EVENT_KEYDOWN && event.param == VK_RETURN ) ) + if ( event.type == EVENT_DIALOG_OK || + (event.type == EVENT_KEY_DOWN && event.param == KEY(RETURN) ) ) { StopDialog(); if ( m_phase == PHASE_NAME ) @@ -2193,8 +2155,8 @@ bool CMainDialog::EventProcess(const Event &event) } if ( m_phase == PHASE_INIT ) { -//? m_event->MakeEvent(newEvent, EVENT_QUIT); -//? m_event->AddEvent(newEvent); +//? m_eventQueue->MakeEvent(newEvent, EVENT_QUIT); +//? m_eventQueue->AddEvent(newEvent); m_main->ChangePhase(PHASE_GENERIC); } if ( m_phase == PHASE_SIMUL ) @@ -2209,12 +2171,12 @@ bool CMainDialog::EventProcess(const Event &event) } } } - if ( event.event == EVENT_DIALOG_CANCEL || - (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE ) ) + if ( event.type == EVENT_DIALOG_CANCEL || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE) ) ) { StopDialog(); } - if ( event.event == EVENT_INTERFACE_SETUP ) + if ( event.type == EVENT_INTERFACE_SETUP ) { StopDialog(); StartSuspend(); @@ -2224,18 +2186,18 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phaseSetup == PHASE_SETUPc ) ChangePhase(PHASE_SETUPcs); if ( m_phaseSetup == PHASE_SETUPs ) ChangePhase(PHASE_SETUPss); } - if ( event.event == EVENT_INTERFACE_AGAIN ) + if ( event.type == EVENT_INTERFACE_AGAIN ) { StopDialog(); m_main->ChangePhase(PHASE_LOADING); } - if ( event.event == EVENT_INTERFACE_WRITE ) + if ( event.type == EVENT_INTERFACE_WRITE ) { StopDialog(); StartSuspend(); ChangePhase(PHASE_WRITEs); } - if ( event.event == EVENT_INTERFACE_READ ) + if ( event.type == EVENT_INTERFACE_READ ) { StopDialog(); StartSuspend(); @@ -2245,7 +2207,7 @@ bool CMainDialog::EventProcess(const Event &event) return false; } - if ( !m_engine->RetMouseHide() && + if ( /*TODO: m_engine->GetMouseVisible() &&*/ !m_interface->EventProcess(event) ) { return false; @@ -2253,10 +2215,10 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_INIT ) { - switch( event.event ) + switch( event.type ) { - case EVENT_KEYDOWN: - if ( event.param == VK_ESCAPE ) + case EVENT_KEY_DOWN: + if ( event.param == KEY(ESCAPE) ) { //? StartQuit(); // would you leave? m_sound->Play(SOUND_TZOING); @@ -2305,24 +2267,27 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_NAME: m_main->ChangePhase(PHASE_NAME); break; + + default: + break; } return false; } if ( m_phase == PHASE_NAME ) { - switch( event.event ) + switch( event.type ) { - case EVENT_KEYDOWN: - if ( event.param == VK_RETURN ) + case EVENT_KEY_DOWN: + if ( event.param == KEY(RETURN) ) { NameSelect(); } - if ( event.param == VK_ESCAPE ) + if ( event.param == KEY(ESCAPE) ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NCANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NCANCEL)); if ( pb == 0 ) break; if ( pb->TestState(STATE_ENABLE) ) { @@ -2354,25 +2319,28 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_NDELETE: - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) break; - StartDeleteGame(pl->RetName(pl->RetSelect())); + StartDeleteGame(pl->GetName(pl->GetSelect())); + break; + + default: break; } } if ( m_phase == PHASE_PERSO ) { - switch( event.event ) + switch( event.type ) { - case EVENT_KEYDOWN: - if ( event.param == VK_RETURN ) + case EVENT_KEY_DOWN: + if ( event.param == KEY(RETURN) ) { m_main->ChangePhase(PHASE_INIT); } - if ( event.param == VK_ESCAPE ) + if ( event.param == KEY(ESCAPE) ) { m_main->ChangePhase(PHASE_NAME); } @@ -2395,8 +2363,8 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_PFACE2: case EVENT_INTERFACE_PFACE3: case EVENT_INTERFACE_PFACE4: - m_perso.face = event.event-EVENT_INTERFACE_PFACE1; - WriteGamerPerso(m_main->RetGamerName()); + m_perso.face = event.type-EVENT_INTERFACE_PFACE1; + WriteGamerPerso(m_main->GetGamerName()); UpdatePerso(); m_main->ScenePerso(); break; @@ -2411,8 +2379,8 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_PGLASS7: case EVENT_INTERFACE_PGLASS8: case EVENT_INTERFACE_PGLASS9: - m_perso.glasses = event.event-EVENT_INTERFACE_PGLASS0; - WriteGamerPerso(m_main->RetGamerName()); + m_perso.glasses = event.type-EVENT_INTERFACE_PGLASS0; + WriteGamerPerso(m_main->GetGamerName()); UpdatePerso(); m_main->ScenePerso(); break; @@ -2427,8 +2395,8 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_PC7a: case EVENT_INTERFACE_PC8a: case EVENT_INTERFACE_PC9a: - FixPerso(event.event-EVENT_INTERFACE_PC0a, 0); - WriteGamerPerso(m_main->RetGamerName()); + FixPerso(event.type-EVENT_INTERFACE_PC0a, 0); + WriteGamerPerso(m_main->GetGamerName()); UpdatePerso(); m_main->ScenePerso(); break; @@ -2443,8 +2411,8 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_PC7b: case EVENT_INTERFACE_PC8b: case EVENT_INTERFACE_PC9b: - FixPerso(event.event-EVENT_INTERFACE_PC0b, 1); - WriteGamerPerso(m_main->RetGamerName()); + FixPerso(event.type-EVENT_INTERFACE_PC0b, 1); + WriteGamerPerso(m_main->GetGamerName()); UpdatePerso(); m_main->ScenePerso(); break; @@ -2456,14 +2424,14 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_PCGb: case EVENT_INTERFACE_PCBb: ColorPerso(); - WriteGamerPerso(m_main->RetGamerName()); + WriteGamerPerso(m_main->GetGamerName()); UpdatePerso(); m_main->ScenePerso(); break; case EVENT_INTERFACE_PDEF: DefPerso(); - WriteGamerPerso(m_main->RetGamerName()); + WriteGamerPerso(m_main->GetGamerName()); UpdatePerso(); m_main->ScenePerso(); break; @@ -2481,9 +2449,12 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_PCANCEL: m_perso = m_persoCopy; - WriteGamerPerso(m_main->RetGamerName()); + WriteGamerPerso(m_main->GetGamerName()); m_main->ChangePhase(PHASE_NAME); break; + + default: + break; } } @@ -2495,12 +2466,12 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - if ( event.event == pw->RetEventMsgClose() || - event.event == EVENT_INTERFACE_BACK || - (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ) + if ( event.type == pw->GetEventTypeClose() || + event.type == EVENT_INTERFACE_BACK || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) ) { m_main->ChangePhase(PHASE_INIT); return false; @@ -2515,25 +2486,25 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { - switch( event.event ) + switch( event.type ) { case EVENT_INTERFACE_CHAP: - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_CHAP); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP)); if ( pl == 0 ) break; - m_chap[m_index] = pl->RetSelect(); + m_chap[m_index] = pl->GetSelect(); UpdateSceneList(m_chap[m_index], m_sel[m_index]); UpdateSceneResume((m_chap[m_index]+1)*100+(m_sel[m_index]+1)); break; case EVENT_INTERFACE_LIST: - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_LIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST)); if ( pl == 0 ) break; - m_sel[m_index] = pl->RetSelect(); + m_sel[m_index] = pl->GetSelect(); UpdateSceneResume((m_chap[m_index]+1)*100+(m_sel[m_index]+1)); break; case EVENT_INTERFACE_SOLUCE: - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_SOLUCE); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE)); if ( pb == 0 ) break; m_bSceneSoluce = !m_bSceneSoluce; pb->SetState(STATE_CHECK, m_bSceneSoluce); @@ -2554,6 +2525,9 @@ bool CMainDialog::EventProcess(const Event &event) m_phaseTerm = m_phase; m_main->ChangePhase(PHASE_READ); break; + + default: + break; } return false; } @@ -2564,12 +2538,12 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_SETUPc || m_phase == PHASE_SETUPs ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - if ( event.event == pw->RetEventMsgClose() || - event.event == EVENT_INTERFACE_BACK || - (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ) + if ( event.type == pw->GetEventTypeClose() || + event.type == EVENT_INTERFACE_BACK || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) ) { SetupMemorize(); m_engine->ApplyChange(); @@ -2577,7 +2551,7 @@ bool CMainDialog::EventProcess(const Event &event) return false; } - switch( event.event ) + switch( event.type ) { case EVENT_INTERFACE_SETUPd: m_main->ChangePhase(PHASE_SETUPd); @@ -2598,6 +2572,9 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_SETUPs: m_main->ChangePhase(PHASE_SETUPs); break; + + default: + break; } } @@ -2607,12 +2584,12 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_SETUPcs || m_phase == PHASE_SETUPss ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - if ( event.event == pw->RetEventMsgClose() || - event.event == EVENT_INTERFACE_BACK || - (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ) + if ( event.type == pw->GetEventTypeClose() || + event.type == EVENT_INTERFACE_BACK || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) ) { SetupMemorize(); m_engine->ApplyChange(); @@ -2622,7 +2599,7 @@ bool CMainDialog::EventProcess(const Event &event) return false; } - switch( event.event ) + switch( event.type ) { case EVENT_INTERFACE_SETUPd: ChangePhase(PHASE_SETUPds); @@ -2643,13 +2620,16 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_SETUPs: ChangePhase(PHASE_SETUPss); break; + + default: + break; } } if ( m_phase == PHASE_SETUPd || // setup/display ? m_phase == PHASE_SETUPds ) { - switch( event.event ) + switch( event.type ) { case EVENT_LIST1: case EVENT_LIST2: @@ -2657,11 +2637,11 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_FULL: - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL)); if ( pc == 0 ) break; - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) break; if ( pc->TestState(STATE_CHECK) ) { @@ -2677,15 +2657,18 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_APPLY: - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_APPLY); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY)); if ( pb == 0 ) break; pb->ClearState(STATE_PRESS); pb->ClearState(STATE_HILIGHT); ChangeDisplay(); UpdateApply(); break; + + default: + break; } return false; } @@ -2693,53 +2676,53 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_SETUPg || // setup/graphic ? m_phase == PHASE_SETUPgs ) { - switch( event.event ) + switch( event.type ) { case EVENT_INTERFACE_SHADOW: - m_engine->SetShadow(!m_engine->RetShadow()); + m_engine->SetShadow(!m_engine->GetShadow()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_GROUND: - m_engine->SetGroundSpot(!m_engine->RetGroundSpot()); + m_engine->SetGroundSpot(!m_engine->GetGroundSpot()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_DIRTY: - m_engine->SetDirty(!m_engine->RetDirty()); + m_engine->SetDirty(!m_engine->GetDirty()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_FOG: - m_engine->SetFog(!m_engine->RetFog()); - m_camera->SetOverBaseColor(RetColor(RetColor(0.0f))); + m_engine->SetFog(!m_engine->GetFog()); + m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok? ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_LENS: - m_engine->SetLensMode(!m_engine->RetLensMode()); + m_engine->SetLensMode(!m_engine->GetLensMode()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_SKY: - m_engine->SetSkyMode(!m_engine->RetSkyMode()); + m_engine->SetSkyMode(!m_engine->GetSkyMode()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_PLANET: - m_engine->SetPlanetMode(!m_engine->RetPlanetMode()); + m_engine->SetPlanetMode(!m_engine->GetPlanetMode()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_LIGHT: - m_engine->SetLightMode(!m_engine->RetLightMode()); + m_engine->SetLightMode(!m_engine->GetLightMode()); ChangeSetupButtons(); UpdateSetupButtons(); break; @@ -2764,6 +2747,9 @@ bool CMainDialog::EventProcess(const Event &event) ChangeSetupQuality(1); UpdateSetupButtons(); break; + + default: + break; } return false; } @@ -2771,10 +2757,10 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_SETUPp || // setup/game ? m_phase == PHASE_SETUPps ) { - switch( event.event ) + switch( event.type ) { case EVENT_INTERFACE_TOTO: - m_engine->SetTotoMode(!m_engine->RetTotoMode()); + m_engine->SetTotoMode(!m_engine->GetTotoMode()); ChangeSetupButtons(); UpdateSetupButtons(); break; @@ -2798,19 +2784,20 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_MOUSE: - m_engine->SetNiceMouse(!m_engine->RetNiceMouse()); + m_engine->SetMouseVisible(!m_engine->GetMouseVisible()); + // TODO: system mouse visible ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_EDITMODE: - m_engine->SetEditIndentMode(!m_engine->RetEditIndentMode()); + m_engine->SetEditIndentMode(!m_engine->GetEditIndentMode()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_EDITVALUE: - if ( m_engine->RetEditIndentValue() == 2 ) + if ( m_engine->GetEditIndentValue() == 2 ) { m_engine->SetEditIndentValue(4); } @@ -2873,6 +2860,9 @@ bool CMainDialog::EventProcess(const Event &event) ChangeSetupButtons(); UpdateSetupButtons(); break; + + default: + break; } return false; } @@ -2880,7 +2870,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_SETUPc || // setup/commands ? m_phase == PHASE_SETUPcs ) { - switch( event.event ) + switch( event.type ) { case EVENT_INTERFACE_KSCROLL: UpdateKey(); @@ -2908,19 +2898,22 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_KSPEED20: case EVENT_INTERFACE_KSPEED30: case EVENT_INTERFACE_KVISIT: - ChangeKey(event.event); + ChangeKey(event.type); UpdateKey(); break; case EVENT_INTERFACE_KDEF: - m_engine->ResetKey(); + m_app->ResetKeyStates(); UpdateKey(); break; case EVENT_INTERFACE_JOYSTICK: - m_engine->SetJoystick(!m_engine->RetJoystick()); + m_app->SetJoystickEnabled(!m_app->GetJoystickEnabled()); UpdateSetupButtons(); break; + + default: + break; } return false; } @@ -2928,7 +2921,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_SETUPs || // setup/sound ? m_phase == PHASE_SETUPss ) { - switch( event.event ) + switch( event.type ) { case EVENT_INTERFACE_VOLSOUND: case EVENT_INTERFACE_VOLMUSIC: @@ -2936,47 +2929,50 @@ bool CMainDialog::EventProcess(const Event &event) break; case EVENT_INTERFACE_SOUND3D: - m_sound->SetSound3D(!m_sound->RetSound3D()); + m_sound->SetSound3D(!m_sound->GetSound3D()); ChangeSetupButtons(); UpdateSetupButtons(); break; case EVENT_INTERFACE_SILENT: m_sound->SetAudioVolume(0); - m_sound->SetMidiVolume(0); + //TODO: m_sound->SetMidiVolume(0); UpdateSetupButtons(); break; case EVENT_INTERFACE_NOISY: m_sound->SetAudioVolume(MAXVOLUME); - m_sound->SetMidiVolume(MAXVOLUME*3/4); + //TODO: m_sound->SetMidiVolume(MAXVOLUME*3/4); UpdateSetupButtons(); break; + + default: + break; } return false; } if ( m_phase == PHASE_READ ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - if ( event.event == pw->RetEventMsgClose() || - event.event == EVENT_INTERFACE_BACK || - (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ) + if ( event.type == pw->GetEventTypeClose() || + event.type == EVENT_INTERFACE_BACK || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) ) { ChangePhase(m_phaseTerm); } - if ( event.event == EVENT_INTERFACE_IOLIST ) + if ( event.type == EVENT_INTERFACE_IOLIST ) { IOUpdateList(); } - if ( event.event == EVENT_INTERFACE_IODELETE ) + if ( event.type == EVENT_INTERFACE_IODELETE ) { IODeleteScene(); IOUpdateList(); } - if ( event.event == EVENT_INTERFACE_IOREAD ) + if ( event.type == EVENT_INTERFACE_IOREAD ) { if ( IOReadScene() ) { @@ -2990,35 +2986,35 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_WRITEs || m_phase == PHASE_READs ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - if ( event.event == pw->RetEventMsgClose() || - event.event == EVENT_INTERFACE_BACK || - (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ) + if ( event.type == pw->GetEventTypeClose() || + event.type == EVENT_INTERFACE_BACK || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) ) { m_interface->DeleteControl(EVENT_WINDOW5); ChangePhase(PHASE_SIMUL); StopSuspend(); } - if ( event.event == EVENT_INTERFACE_IOLIST ) + if ( event.type == EVENT_INTERFACE_IOLIST ) { IOUpdateList(); } - if ( event.event == EVENT_INTERFACE_IODELETE ) + if ( event.type == EVENT_INTERFACE_IODELETE ) { IODeleteScene(); IOUpdateList(); } - if ( event.event == EVENT_INTERFACE_IOWRITE ) + if ( event.type == EVENT_INTERFACE_IOWRITE ) { IOWriteScene(); m_interface->DeleteControl(EVENT_WINDOW5); ChangePhase(PHASE_SIMUL); StopSuspend(); } - if ( event.event == EVENT_INTERFACE_IOREAD ) + if ( event.type == EVENT_INTERFACE_IOREAD ) { if ( IOReadScene() ) { @@ -3034,9 +3030,8 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_WELCOME1 ) { - if ( event.event == EVENT_KEYDOWN || - event.event == EVENT_LBUTTONDOWN || - event.event == EVENT_RBUTTONDOWN ) + if ( event.type == EVENT_KEY_DOWN || + event.type == EVENT_MOUSE_BUTTON_DOWN ) { ChangePhase(PHASE_WELCOME2); return true; @@ -3044,9 +3039,8 @@ bool CMainDialog::EventProcess(const Event &event) } if ( m_phase == PHASE_WELCOME2 ) { - if ( event.event == EVENT_KEYDOWN || - event.event == EVENT_LBUTTONDOWN || - event.event == EVENT_RBUTTONDOWN ) + if ( event.type == EVENT_KEY_DOWN || + event.type == EVENT_MOUSE_BUTTON_DOWN ) { ChangePhase(PHASE_WELCOME3); return true; @@ -3054,9 +3048,8 @@ bool CMainDialog::EventProcess(const Event &event) } if ( m_phase == PHASE_WELCOME3 ) { - if ( event.event == EVENT_KEYDOWN || - event.event == EVENT_LBUTTONDOWN || - event.event == EVENT_RBUTTONDOWN ) + if ( event.type == EVENT_KEY_DOWN || + event.type == EVENT_MOUSE_BUTTON_DOWN ) { ChangePhase(PHASE_NAME); return true; @@ -3065,29 +3058,26 @@ bool CMainDialog::EventProcess(const Event &event) if ( m_phase == PHASE_GENERIC ) { - if ( event.event == EVENT_INTERFACE_ABORT ) + if ( event.type == EVENT_INTERFACE_ABORT ) { ChangePhase(PHASE_INIT); } - if ( event.event == EVENT_KEYDOWN ) + if ( event.type == EVENT_KEY_DOWN ) { - if ( event.param == VK_ESCAPE ) + if ( event.param == KEY(ESCAPE) ) { ChangePhase(PHASE_INIT); } else { - m_event->MakeEvent(newEvent, EVENT_QUIT); - m_event->AddEvent(newEvent); + m_eventQueue->AddEvent(Event(EVENT_QUIT)); } } - if ( event.event == EVENT_LBUTTONDOWN || - event.event == EVENT_RBUTTONDOWN ) + if ( event.type == EVENT_MOUSE_BUTTON_DOWN ) { - m_event->MakeEvent(newEvent, EVENT_QUIT); - m_event->AddEvent(newEvent); + m_eventQueue->AddEvent(Event(EVENT_QUIT)); } } @@ -3105,12 +3095,12 @@ void CMainDialog::GlintMove() if ( m_phase == PHASE_SIMUL ) return; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; if ( m_phase == PHASE_INIT ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.23f); @@ -3124,7 +3114,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.21f); @@ -3147,7 +3137,7 @@ void CMainDialog::GlintMove() m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.22f); @@ -3161,7 +3151,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.19f); @@ -3187,7 +3177,7 @@ void CMainDialog::GlintMove() m_phase == PHASE_SETUPcs || m_phase == PHASE_SETUPss ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTu); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTu)); if ( pg != 0 ) { zoom.y = sinf(m_glintTime*0.27f); @@ -3200,7 +3190,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.29f); @@ -3220,7 +3210,7 @@ void CMainDialog::GlintMove() m_phase == PHASE_WRITEs || m_phase == PHASE_READs ) { - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.22f); @@ -3234,7 +3224,7 @@ void CMainDialog::GlintMove() pg->SetDim(dim); } - pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr); + pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr)); if ( pg != 0 ) { zoom.x = sinf(m_glintTime*0.19f); @@ -3251,7 +3241,7 @@ void CMainDialog::GlintMove() } -// Returns the position for a sound. +// Geturns the position for a sound. Math::Vector SoundPos(Math::Point pos) { @@ -3264,7 +3254,7 @@ Math::Vector SoundPos(Math::Point pos) return s; } -// Returns a random position for a sound. +// Geturns a random position for a sound. Math::Vector SoundRand() { @@ -3279,10 +3269,10 @@ Math::Vector SoundRand() // Makes pretty qq particles evolve. -void CMainDialog::FrameParticule(float rTime) +void CMainDialog::FrameParticle(float rTime) { -#if _NEWLOOK -#else +/* TODO: #if _NEWLOOK +#else */ Math::Vector pos, speed; Math::Point dim; float *pParti, *pGlint; @@ -3390,8 +3380,8 @@ void CMainDialog::FrameParticule(float rTime) return; } - nParti = (int)(*pParti++); - nGlint = (int)(*pGlint++); + nParti = static_cast<int>(*pParti++); + nGlint = static_cast<int>(*pGlint++); for ( i=0 ; i<10 ; i++ ) { @@ -3408,7 +3398,7 @@ void CMainDialog::FrameParticule(float rTime) m_partiPos[i].x = pParti[ii*5+0]/640.0f; m_partiPos[i].y = (480.0f-pParti[ii*5+1])/480.0f; m_partiTime[i] = pParti[ii*5+2]+Math::Rand()*pParti[ii*5+3]; - m_partiPhase[i] = (int)pParti[ii*5+4]; + m_partiPhase[i] = static_cast<int>(pParti[ii*5+4]); if ( m_partiPhase[i] == 3 ) { m_sound->Play(SOUND_PSHHH, SoundPos(m_partiPos[i]), 0.3f+Math::Rand()*0.3f); @@ -3430,10 +3420,10 @@ void CMainDialog::FrameParticule(float rTime) speed.z = 0.0f; dim.x = 0.04f+Math::Rand()*0.04f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, - rand()%2?PARTIGLINT:PARTICONTROL, + m_particle->CreateParticle(pos, speed, dim, + rand()%2?Gfx::PARTIGLINT:Gfx::PARTICONTROL, Math::Rand()*0.4f+0.4f, 0.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); m_partiTime[i] = 0.5f+Math::Rand()*0.5f; } @@ -3496,9 +3486,9 @@ void CMainDialog::FrameParticule(float rTime) speed.z = 0.0f; dim.x = 0.005f+Math::Rand()*0.005f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ, Math::Rand()*0.2f+0.2f, 0.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); pos.x = m_partiPos[i].x; pos.y = m_partiPos[i].y; pos.z = 0.0f; @@ -3507,10 +3497,10 @@ void CMainDialog::FrameParticule(float rTime) speed.z = 0.0f; dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, - (ParticuleType)(PARTILENS1+rand()%3), + m_particle->CreateParticle(pos, speed, dim, + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), Math::Rand()*0.5f+0.5f, 2.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); } if ( m_partiPhase[i] == 2 ) // sparks? { @@ -3524,9 +3514,9 @@ void CMainDialog::FrameParticule(float rTime) speed.z = 0.0f; dim.x = 0.005f+Math::Rand()*0.005f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ, Math::Rand()*0.2f+0.2f, 0.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); pos.x = m_partiPos[i].x; pos.y = m_partiPos[i].y; pos.z = 0.0f; @@ -3535,9 +3525,9 @@ void CMainDialog::FrameParticule(float rTime) speed.z = 0.0f; dim.x = 0.005f+Math::Rand()*0.005f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS, + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISCRAPS, Math::Rand()*0.5f+0.5f, 2.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); } if ( m_partiPhase[i] == 3 ) // smoke? { @@ -3551,9 +3541,9 @@ void CMainDialog::FrameParticule(float rTime) speed.z = 0.0f; dim.x = 0.03f+Math::Rand()*0.07f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, PARTICRASH, + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, Math::Rand()*0.4f+0.4f, 0.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); } } else @@ -3563,12 +3553,12 @@ void CMainDialog::FrameParticule(float rTime) } } } -#endif +// #endif } // Some nice particles following the mouse. -void CMainDialog::NiceParticule(Math::Point mouse, bool bPress) +void CMainDialog::NiceParticle(Math::Point mouse, bool bPress) { Math::Vector pos, speed; Math::Point dim; @@ -3590,9 +3580,9 @@ void CMainDialog::NiceParticule(Math::Point mouse, bool bPress) speed.z = 0.0f; dim.x = 0.005f+Math::Rand()*0.005f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS, + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISCRAPS, Math::Rand()*0.5f+0.5f, 2.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); } else { @@ -3604,10 +3594,10 @@ void CMainDialog::NiceParticule(Math::Point mouse, bool bPress) speed.z = 0.0f; dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, - (ParticuleType)(PARTILENS1+rand()%3), + m_particle->CreateParticle(pos, speed, dim, + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), Math::Rand()*0.5f+0.5f, 2.0f, 0.0f, - SH_INTERFACE); + Gfx::SH_INTERFACE); } } @@ -3651,9 +3641,9 @@ void CMainDialog::BuildResumeName(char *filename, char *base, int rank) sprintf(filename, "Scene %s %d", base, rank); } -// Returns the name of the file or save the files. +// Geturns the name of the file or save the files. -char* CMainDialog::RetFilesDir() +char* CMainDialog::GetFilesDir() { return m_filesDir; } @@ -3666,20 +3656,21 @@ void CMainDialog::ReadNameList() CWindow* pw; CList* pl; long hFile; - struct _finddata_t fBuffer; + //struct _finddata_t fBuffer; bool bDo; - char dir[_MAX_FNAME]; - char temp[_MAX_FNAME]; - char filenames[_MAX_FNAME][100]; + char dir[MAX_FNAME]; + char temp[MAX_FNAME]; + char filenames[MAX_FNAME][100]; int nbFilenames, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; pl->Flush(); nbFilenames = 0; + /* TODO: list dir sprintf(dir, "%s\\*", m_savegameDir); hFile = _findfirst(dir, &fBuffer); if ( hFile != -1 ) @@ -3707,7 +3698,9 @@ void CMainDialog::ReadNameList() } } } - while ( bDo ); + while ( bDo );*/ + + strcpy(filenames[nbFilenames++], "Test"); for ( i=0 ; i<nbFilenames ; i++ ) { @@ -3727,37 +3720,37 @@ void CMainDialog::UpdateNameControl() char* gamer; int total, sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; - gamer = m_main->RetGamerName(); - total = pl->RetTotal(); - sel = pl->RetSelect(); + gamer = m_main->GetGamerName(); + total = pl->GetTotal(); + sel = pl->GetSelect(); pe->GetText(name, 100); - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NCANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NCANCEL)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, gamer[0]!=0); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NDELETE); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NDELETE)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, total>0 && sel!=-1); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NOK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NOK)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, name[0]!=0 || sel!=-1); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PERSO); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PERSO)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, name[0]!=0 || sel!=-1); @@ -3772,22 +3765,22 @@ void CMainDialog::UpdateNameList() CList* pl; CEdit* pe; char name[100]; - int total, sel, i; + int total, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; pe->GetText(name, 100); - total = pl->RetTotal(); - sel = pl->RetSelect(); + total = pl->GetTotal(); for ( i=0 ; i<total ; i++ ) { - if ( stricmp(name, pl->RetName(i)) == 0 ) + // TODO: stricmp? + if ( strcmp(name, pl->GetName(i)) == 0 ) { pl->SetSelect(i); pl->ShowSelect(false); @@ -3808,14 +3801,14 @@ void CMainDialog::UpdateNameEdit() char* name; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; - sel = pl->RetSelect(); + sel = pl->GetSelect(); if ( sel == -1 ) { pe->SetText(""); @@ -3823,7 +3816,7 @@ void CMainDialog::UpdateNameEdit() } else { - name = pl->RetName(sel); + name = pl->GetName(sel); pe->SetText(name); pe->SetCursor(strlen(name), 0); } @@ -3840,14 +3833,14 @@ void CMainDialog::UpdateNameFace() char* name; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - sel = pl->RetSelect(); + sel = pl->GetSelect(); if ( sel == -1 ) return; - name = pl->RetName(sel); + name = pl->GetName(sel); ReadGamerPerso(name); } @@ -3862,15 +3855,15 @@ void CMainDialog::NameSelect() char name[100]; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; pe->GetText(name, 100); - sel = pl->RetSelect(); + sel = pl->GetSelect(); if ( sel == -1 ) { @@ -3878,13 +3871,13 @@ void CMainDialog::NameSelect() } else { - m_main->SetGamerName(pl->RetName(sel)); + m_main->SetGamerName(pl->GetName(sel)); m_main->ChangePhase(PHASE_INIT); } - RetGamerFace(m_main->RetGamerName()); + GetGamerFace(m_main->GetGamerName()); - SetLocalProfileString("Gamer", "LastName", m_main->RetGamerName()); + // TODO: SetLocalProfileString("Gamer", "LastName", m_main->GetGamerName()); } // Creates a new player. @@ -3898,9 +3891,9 @@ void CMainDialog::NameCreate() char c; int len, i, j; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT)); if ( pe == 0 ) return; pe->GetText(name, 100); @@ -3914,7 +3907,7 @@ void CMainDialog::NameCreate() j = 0; for ( i=0 ; i<len ; i++ ) { - c = RetNoAccent(RetToLower(name[i])); + c = GetNoAccent(GetToLower(name[i])); if ( (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || c == ' ' || @@ -3934,10 +3927,10 @@ void CMainDialog::NameCreate() return; } - _mkdir(m_savegameDir); // if does not exist yet! + // TODO: _mkdir(m_savegameDir); // if does not exist yet! sprintf(dir, "%s\\%s", m_savegameDir, name); - if ( _mkdir(dir) != 0 ) + // TODO: if ( _mkdir(dir) != 0 ) { m_sound->Play(SOUND_TZOING); pe->SetText(name); @@ -3956,6 +3949,7 @@ void CMainDialog::NameCreate() bool RemoveDir(char *dirname) { + /* TODO: remove dir long hFile; struct _finddata_t fBuffer; char filename[100]; @@ -3986,7 +3980,7 @@ bool RemoveDir(char *dirname) if ( _rmdir(dirname) != 0 ) { return false; - } + }*/ return true; } @@ -4000,18 +3994,18 @@ void CMainDialog::NameDelete() char* gamer; char dir[100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) return; - sel = pl->RetSelect(); + sel = pl->GetSelect(); if ( sel == -1 ) { m_sound->Play(SOUND_TZOING); return; } - gamer = pl->RetName(sel); + gamer = pl->GetName(sel); // Deletes all the contents of the file. sprintf(dir, "%s\\%s", m_savegameDir, gamer); @@ -4033,7 +4027,7 @@ void CMainDialog::NameDelete() // ests whether two colors are equal or nearly are. -bool EqColor(const D3DCOLORVALUE &c1, const D3DCOLORVALUE &c2) +bool EqColor(const Gfx::Color &c1, const Gfx::Color &c2) { return (fabs(c1.r-c2.r) < 0.01f && fabs(c1.g-c2.g) < 0.01f && @@ -4049,25 +4043,25 @@ void CMainDialog::UpdatePerso() CButton* pb; CColor* pc; CSlider* ps; - D3DCOLORVALUE color; + Gfx::Color color; char name[100]; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PHEAD); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PHEAD)); if ( pb != 0 ) { pb->SetState(STATE_CHECK, m_persoTab==0); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PBODY); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PBODY)); if ( pb != 0 ) { pb->SetState(STATE_CHECK, m_persoTab==1); } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL11); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL11)); if ( pl != 0 ) { if ( m_persoTab == 0 ) @@ -4082,7 +4076,7 @@ void CMainDialog::UpdatePerso() } } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL12); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL12)); if ( pl != 0 ) { if ( m_persoTab == 0 ) @@ -4097,7 +4091,7 @@ void CMainDialog::UpdatePerso() } } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL13); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL13)); if ( pl != 0 ) { if ( m_persoTab == 0 ) GetResource(RES_TEXT, RT_PERSO_HAIR, name); @@ -4105,7 +4099,7 @@ void CMainDialog::UpdatePerso() pl->SetName(name); } - pl = (CLabel*)pw->SearchControl(EVENT_LABEL14); + pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL14)); if ( pl != 0 ) { if ( m_persoTab == 0 ) @@ -4122,7 +4116,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<4 ; i++ ) { - pb = (CButton*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PFACE1+i)); + pb = static_cast<CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PFACE1+i))); if ( pb == 0 ) break; pb->SetState(STATE_VISIBLE, m_persoTab==0); pb->SetState(STATE_CHECK, i==m_perso.face); @@ -4130,7 +4124,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<10 ; i++ ) { - pb = (CButton*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PGLASS0+i)); + pb = static_cast<CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PGLASS0+i))); if ( pb == 0 ) break; pb->SetState(STATE_VISIBLE, m_persoTab==0); pb->SetState(STATE_CHECK, i==m_perso.glasses); @@ -4138,7 +4132,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<3*3 ; i++ ) { - pc = (CColor*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PC0a+i)); + pc = static_cast<CColor*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PC0a+i))); if ( pc == 0 ) break; if ( m_persoTab == 0 ) { @@ -4155,7 +4149,7 @@ void CMainDialog::UpdatePerso() pc->SetState(STATE_CHECK, EqColor(color, m_perso.colorCombi)); } - pc = (CColor*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PC0b+i)); + pc = static_cast<CColor*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PC0b+i))); if ( pc == 0 ) break; color.r = perso_color[3*10*2*m_persoTab+3*i+0]/255.0f; color.g = perso_color[3*10*2*m_persoTab+3*i+1]/255.0f; @@ -4167,7 +4161,7 @@ void CMainDialog::UpdatePerso() for ( i=0 ; i<3 ; i++ ) { - ps = (CSlider*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PCRa+i)); + ps = static_cast<CSlider*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PCRa+i))); if ( ps == 0 ) break; ps->SetState(STATE_VISIBLE, m_persoTab==1); } @@ -4175,21 +4169,21 @@ void CMainDialog::UpdatePerso() if ( m_persoTab == 1 ) { color = m_perso.colorCombi; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRa)); if ( ps != 0 ) ps->SetVisibleValue(color.r*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGa)); if ( ps != 0 ) ps->SetVisibleValue(color.g*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBa); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBa)); if ( ps != 0 ) ps->SetVisibleValue(color.b*255.0f); } if ( m_persoTab == 0 ) color = m_perso.colorHair; else color = m_perso.colorBand; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRb)); if ( ps != 0 ) ps->SetVisibleValue(color.r*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGb)); if ( ps != 0 ) ps->SetVisibleValue(color.g*255.0f); - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBb); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBb)); if ( ps != 0 ) ps->SetVisibleValue(color.b*255.0f); } @@ -4210,7 +4204,7 @@ void CMainDialog::CameraPerso() Math::Vector(0.0f, 1.6f, 4.5f), 0.0f); } - m_camera->SetType(CAMERA_SCRIPT); + m_camera->SetType(Gfx::CAM_TYPE_SCRIPT); m_camera->FixCamera(); } @@ -4250,27 +4244,27 @@ void CMainDialog::ColorPerso() { CWindow* pw; CSlider* ps; - D3DCOLORVALUE color; + Gfx::Color color; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; color.a = 0.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRa); - if ( ps != 0 ) color.r = ps->RetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGa); - if ( ps != 0 ) color.g = ps->RetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBa); - if ( ps != 0 ) color.b = ps->RetVisibleValue()/255.0f; + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRa)); + if ( ps != 0 ) color.r = ps->GetVisibleValue()/255.0f; + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGa)); + if ( ps != 0 ) color.g = ps->GetVisibleValue()/255.0f; + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBa)); + if ( ps != 0 ) color.b = ps->GetVisibleValue()/255.0f; if ( m_persoTab == 1 ) m_perso.colorCombi = color; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRb); - if ( ps != 0 ) color.r = ps->RetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGb); - if ( ps != 0 ) color.g = ps->RetVisibleValue()/255.0f; - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBb); - if ( ps != 0 ) color.b = ps->RetVisibleValue()/255.0f; + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRb)); + if ( ps != 0 ) color.r = ps->GetVisibleValue()/255.0f; + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGb)); + if ( ps != 0 ) color.g = ps->GetVisibleValue()/255.0f; + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBb)); + if ( ps != 0 ) color.b = ps->GetVisibleValue()/255.0f; if ( m_persoTab == 0 ) m_perso.colorHair = color; else m_perso.colorBand = color; } @@ -4328,7 +4322,7 @@ bool CMainDialog::IsIOReadScene() FILE* file; char filename[100]; - sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], 0); + sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], 0); file = fopen(filename, "r"); if ( file == NULL ) return false; fclose(file); @@ -4342,7 +4336,7 @@ void CMainDialog::IOReadName() FILE* file; CWindow* pw; CEdit* pe; - char filename[_MAX_FNAME]; + char filename[MAX_FNAME]; char op[100]; char line[500]; char resume[100]; @@ -4350,9 +4344,9 @@ void CMainDialog::IOReadName() time_t now; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_IONAME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME)); if ( pe == 0 ) return; sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1); @@ -4372,7 +4366,8 @@ void CMainDialog::IOReadName() } } - sprintf(op, "Title.%c", RetLanguageLetter()); + // TODO: language letters + sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/ ); if ( Cmd(line, op) ) { OpString(line, "resume", resume); @@ -4402,20 +4397,19 @@ void CMainDialog::IOReadList() char name[100]; int i, j; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return; pl->Flush(); for ( j=0 ; j<999 ; j++ ) { - sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], j); + sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j); file = fopen(filename, "r"); if ( file == NULL ) break; - strcmp(name, filename); // default name while ( fgets(line, 500, file) != NULL ) { for ( i=0 ; i<500 ; i++ ) @@ -4463,17 +4457,17 @@ void CMainDialog::IOUpdateList() char filename[100]; int sel, max; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return; - pi = (CImage*)pw->SearchControl(EVENT_INTERFACE_IOIMAGE); + pi = static_cast<CImage*>(pw->SearchControl(EVENT_INTERFACE_IOIMAGE)); if ( pi == 0 ) return; - sel = pl->RetSelect(); - max = pl->RetTotal(); + sel = pl->GetSelect(); + max = pl->GetTotal(); - sprintf(filename, "%s\\%s\\save%c%.3d\\screen.bmp", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); + sprintf(filename, "%s\\%s\\save%c%.3d\\screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) @@ -4487,7 +4481,7 @@ void CMainDialog::IOUpdateList() pi->SetFilenameImage(""); } - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_IODELETE); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_IODELETE)); if ( pb != 0 ) { pb->SetState(STATE_ENABLE, sel < max-1); @@ -4508,23 +4502,24 @@ void CMainDialog::IODeleteScene() char dir[100]; char old[100]; long hFile; - struct _finddata_t fBuffer; + //struct _finddata_t fBuffer; int sel, max, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return; - sel = pl->RetSelect(); + sel = pl->GetSelect(); if ( sel == -1 ) { m_sound->Play(SOUND_TZOING); return; } + /* TODO: remove files // Deletes all the contents of the file. - sprintf(dir, "%s\\%s\\save%c%.3d\\*", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); + sprintf(dir, "%s\\%s\\save%c%.3d\\*", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); hFile = _findfirst(dir, &fBuffer); if ( hFile != -1 ) { @@ -4532,27 +4527,28 @@ void CMainDialog::IODeleteScene() { if ( fBuffer.name[0] != '.' ) { - sprintf(dir, "%s\\%s\\save%c%.3d\\%s", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel, fBuffer.name); + sprintf(dir, "%s\\%s\\save%c%.3d\\%s", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel, fBuffer.name); remove(dir); } } while ( _findnext(hFile, &fBuffer) == 0 ); } - sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); + sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); if ( _rmdir(dir) != 0 ) { m_sound->Play(SOUND_TZOING); return; - } + }*/ - max = pl->RetTotal(); + /* TODO: rename + max = pl->GetTotal(); for ( i=sel+1 ; i<max ; i++ ) { - sprintf(old, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], i); - sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], i-1); + sprintf(old, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i); + sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i-1); rename(old, dir); - } + }*/ IOReadList(); } @@ -4568,29 +4564,29 @@ bool CMainDialog::IOWriteScene() char info[100]; int sel; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_IONAME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME)); if ( pe == 0 ) return false; - sel = pl->RetSelect(); + sel = pl->GetSelect(); if ( sel == -1 ) return false; - _mkdir("Savegame"); // if doesn't exist yet! - sprintf(filename, "%s\\%s", m_savegameDir, m_main->RetGamerName()); - _mkdir(filename); - sprintf(filename, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); - _mkdir(filename); + // TODO: _mkdir("Savegame"); // if doesn't exist yet! + sprintf(filename, "%s\\%s", m_savegameDir, m_main->GetGamerName()); + // TODO: _mkdir(filename); + sprintf(filename, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); + // TODO: _mkdir(filename); - sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); - sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); + sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); + sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); pe->GetText(info, 100); m_main->IOWriteScene(filename, filecbot, info); m_shotDelay = 3; - sprintf(m_shotName, "%s\\%s\\save%c%.3d\\screen.bmp", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); + sprintf(m_shotName, "%s\\%s\\save%c%.3d\\screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); return true; } @@ -4608,16 +4604,16 @@ bool CMainDialog::IOReadScene() char dir[100]; int sel, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return false; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST)); if ( pl == 0 ) return false; - sel = pl->RetSelect(); + sel = pl->GetSelect(); if ( sel == -1 ) return false; - sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); - sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel); + sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); + sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel); file = fopen(filename, "r"); if ( file == NULL ) return false; @@ -4670,17 +4666,17 @@ bool CMainDialog::IOReadScene() } -// Returns the number of accessible chapters. +// Geturns the number of accessible chapters. -int CMainDialog::RetChapPassed() +int CMainDialog::GetChapPassed() { int j; - if ( m_main->RetShowAll() ) return 9; + if ( m_main->GetShowAll() ) return 9; for ( j=0 ; j<9 ; j++ ) { - if ( !RetGamerInfoPassed((j+1)*100) ) + if ( !GetGamerInfoPassed((j+1)*100) ) { return j; } @@ -4713,17 +4709,17 @@ void CMainDialog::UpdateSceneChap(int &chap) CWindow* pw; CList* pl; long hFile; - struct _finddata_t fileBuffer; - char filename[_MAX_FNAME]; + //struct _finddata_t fileBuffer; + char filename[MAX_FNAME]; char op[100]; char line[500]; char name[100]; int i, j; bool bPassed, bDo; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_CHAP); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP)); if ( pl == 0 ) return; pl->Flush(); @@ -4731,6 +4727,7 @@ void CMainDialog::UpdateSceneChap(int &chap) if ( m_phase == PHASE_USER ) { j = 0; + /* TODO: list files hFile = _findfirst("user\\*", &fileBuffer); if ( hFile != -1 ) { @@ -4743,7 +4740,7 @@ void CMainDialog::UpdateSceneChap(int &chap) } } while ( _findnext(hFile, &fileBuffer) == 0 && j < 100 ); - } + }*/ m_userTotal = j; do // sorts all names: @@ -4785,7 +4782,8 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - sprintf(op, "Title.%c", RetLanguageLetter()); + /* TODO: language letters */ + sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4803,7 +4801,7 @@ void CMainDialog::UpdateSceneChap(int &chap) { for ( j=0 ; j<9 ; j++ ) { -#if _SCHOOL +/* TODO: #if _SCHOOL if ( m_phase == PHASE_MISSION ) break; if ( m_phase == PHASE_FREE ) break; #if _CEEBOTDEMO @@ -4813,7 +4811,7 @@ void CMainDialog::UpdateSceneChap(int &chap) #if _DEMO if ( m_phase == PHASE_MISSION && j >= 4 ) break; if ( m_phase == PHASE_TRAINER && j >= 1 ) break; -#endif +#endif */ BuildSceneName(filename, m_sceneName, (j+1)*100); file = fopen(filename, "r"); if ( file == NULL ) break; @@ -4831,7 +4829,8 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - sprintf(op, "Title.%c", RetLanguageLetter()); + // TODO: language letters + sprintf(op, "Title.%c", 'E'/*GetLanguageLetter()*/); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4840,25 +4839,25 @@ void CMainDialog::UpdateSceneChap(int &chap) } fclose(file); - bPassed = RetGamerInfoPassed((j+1)*100); + bPassed = GetGamerInfoPassed((j+1)*100); sprintf(line, "%d: %s", j+1, name); pl->SetName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); - if ( m_phase == PHASE_MISSION && !m_main->RetShowAll() && !bPassed ) + if ( m_phase == PHASE_MISSION && !m_main->GetShowAll() && !bPassed ) { j ++; break; } -#if _TEEN - if ( m_phase == PHASE_TRAINER && !m_main->RetShowAll() && !bPassed ) +/* TODO: #if _TEEN + if ( m_phase == PHASE_TRAINER && !m_main->GetShowAll() && !bPassed ) { j ++; break; } -#endif +#endif*/ if ( m_phase == PHASE_FREE && j == m_accessChap ) { @@ -4881,23 +4880,23 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) FILE* file = NULL; CWindow* pw; CList* pl; - char filename[_MAX_FNAME]; + char filename[MAX_FNAME]; char op[100]; char line[500]; char name[100]; int i, j; bool bPassed; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_INTERFACE_LIST); + pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST)); if ( pl == 0 ) return; pl->Flush(); for ( j=0 ; j<99 ; j++ ) { -#if _SCHOOL +/* TODO: #if _SCHOOL if ( m_phase == PHASE_MISSION ) break; if ( m_phase == PHASE_FREE ) break; #if _CEEBOTDEMO @@ -4911,7 +4910,7 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) #if _DEMO if ( m_phase == PHASE_MISSION && j >= 3 ) break; if ( m_phase == PHASE_TRAINER && j >= 5 ) break; -#endif +#endif */ BuildSceneName(filename, m_sceneName, (chap+1)*100+(j+1)); file = fopen(filename, "r"); if ( file == NULL ) break; @@ -4929,7 +4928,8 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) } } - sprintf(op, "Title.%c", RetLanguageLetter()); + // TODO: language letters + sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4938,25 +4938,25 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) } fclose(file); - bPassed = RetGamerInfoPassed((chap+1)*100+(j+1)); + bPassed = GetGamerInfoPassed((chap+1)*100+(j+1)); sprintf(line, "%d: %s", j+1, name); pl->SetName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); - if ( m_phase == PHASE_MISSION && !m_main->RetShowAll() && !bPassed ) + if ( m_phase == PHASE_MISSION && !m_main->GetShowAll() && !bPassed ) { j ++; break; } -#if _TEEN - if ( m_phase == PHASE_TRAINER && !m_main->RetShowAll() && !bPassed ) +/* TODO: #if _TEEN + if ( m_phase == PHASE_TRAINER && !m_main->GetShowAll() && !bPassed ) { j ++; break; } -#endif +#endif*/ } BuildSceneName(filename, m_sceneName, (chap+1)*100+(j+1)); @@ -4995,14 +4995,14 @@ void CMainDialog::ShowSoluceUpdate() { m_bSceneSoluce = false; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_RESUME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_RESUME)); if ( pe == 0 ) return; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE)); if ( pc == 0 ) return; - if ( m_main->RetShowSoluce() ) + if ( m_main->GetShowSoluce() ) { pc->SetState(STATE_VISIBLE); pc->SetState(STATE_CHECK); @@ -5025,18 +5025,18 @@ void CMainDialog::UpdateSceneResume(int rank) CWindow* pw; CEdit* pe; CCheck* pc; - char filename[_MAX_FNAME]; + char filename[MAX_FNAME]; char op[100]; char line[500]; char name[500]; int i, numTry; bool bPassed, bVisible; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_RESUME); + pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_RESUME)); if ( pe == 0 ) return; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE)); if ( pc == 0 ) { @@ -5044,10 +5044,10 @@ void CMainDialog::UpdateSceneResume(int rank) } else { - numTry = RetGamerInfoTry(rank); - bPassed = RetGamerInfoPassed(rank); - bVisible = ( numTry > 2 || bPassed || m_main->RetShowSoluce() ); - if ( !RetSoluce4() ) bVisible = false; + numTry = GetGamerInfoTry(rank); + bPassed = GetGamerInfoPassed(rank); + bVisible = ( numTry > 2 || bPassed || m_main->GetShowSoluce() ); + if ( !GetSoluce4() ) bVisible = false; pc->SetState(STATE_VISIBLE, bVisible); if ( !bVisible ) { @@ -5073,7 +5073,8 @@ void CMainDialog::UpdateSceneResume(int rank) } } - sprintf(op, "Resume.%c", RetLanguageLetter()); + // TODO: language letters + sprintf(op, "Resume.%c", 'E' /*MAX_FNAME()*/); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -5095,16 +5096,18 @@ void CMainDialog::UpdateDisplayDevice() char bufModes[5000]; int i, j, totalDevices, selectDevices, totalModes, selectModes; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST1); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; pl->Flush(); + bufModes[0] = 0; + /* TODO: remove device choice m_engine->EnumDevices(bufDevices, 1000, bufModes, 5000, totalDevices, selectDevices, - totalModes, selectModes); + totalModes, selectModes);*/ i = 0; j = 0; @@ -5130,16 +5133,18 @@ void CMainDialog::UpdateDisplayMode() char bufModes[5000]; int i, j, totalDevices, selectDevices, totalModes, selectModes; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; pl->Flush(); + bufModes[0] = 0; + /* TODO: remove device choice m_engine->EnumDevices(bufDevices, 1000, bufModes, 5000, totalDevices, selectDevices, - totalModes, selectModes); + totalModes, selectModes);*/ i = 0; j = 0; @@ -5166,25 +5171,26 @@ void CMainDialog::ChangeDisplay() char* mode; bool bFull; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST1); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; - m_setupSelDevice = pl->RetSelect(); - device = pl->RetName(m_setupSelDevice); + m_setupSelDevice = pl->GetSelect(); + device = pl->GetName(m_setupSelDevice); - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; - m_setupSelMode = pl->RetSelect(); - mode = pl->RetName(m_setupSelMode); + m_setupSelMode = pl->GetSelect(); + mode = pl->GetName(m_setupSelMode); - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL)); if ( pc == 0 ) return; bFull = pc->TestState(STATE_CHECK); m_setupFull = bFull; - m_engine->ChangeDevice(device, mode, bFull); + // TODO: remove device choice + // m_engine->ChangeDevice(device, mode, bFull); if ( m_bSimulSetup ) { @@ -5206,21 +5212,21 @@ void CMainDialog::UpdateApply() int sel1, sel2; bool bFull; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_APPLY); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY)); if ( pb == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_LIST1); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; - sel1 = pl->RetSelect(); + sel1 = pl->GetSelect(); - pl = (CList*)pw->SearchControl(EVENT_LIST2); + pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; - sel2 = pl->RetSelect(); + sel2 = pl->GetSelect(); - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL)); bFull = pc->TestState(STATE_CHECK); if ( sel1 == m_setupSelDevice && @@ -5245,208 +5251,210 @@ void CMainDialog::UpdateSetupButtons() CSlider* ps; float value; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_TOTO); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOTO)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetTotoMode()); + pc->SetState(STATE_CHECK, m_engine->GetTotoMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_TOOLTIP); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOOLTIP)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bTooltip); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_GLINT); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GLINT)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bGlint); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_RAIN); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_RAIN)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bRain); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_MOUSE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOUSE)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetNiceMouse()); - pc->SetState(STATE_ENABLE, m_engine->RetNiceMouseCap()); + /* TODO: nice mouse? + pc->SetState(STATE_CHECK, m_engine->GetNiceMouse()); + pc->SetState(STATE_ENABLE, m_engine->GetNiceMouseCap());*/ } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EDITMODE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITMODE)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetEditIndentMode()); + pc->SetState(STATE_CHECK, m_engine->GetEditIndentMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EDITVALUE); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITVALUE)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetEditIndentValue()>2); + pc->SetState(STATE_CHECK, m_engine->GetEditIndentValue()>2); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE4); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE4)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bSoluce4); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_MOVIES); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOVIES)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bMovies); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_NICERST); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_NICERST)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bNiceReset); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_HIMSELF); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_HIMSELF)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bHimselfDamage); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SCROLL); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SCROLL)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bCameraScroll); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_INVERTX); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTX)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bCameraInvertX); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_INVERTY); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTY)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bCameraInvertY); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EFFECT); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EFFECT)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_bEffect); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SHADOW); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SHADOW)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetShadow()); + pc->SetState(STATE_CHECK, m_engine->GetShadow()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_GROUND); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GROUND)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetGroundSpot()); + pc->SetState(STATE_CHECK, m_engine->GetGroundSpot()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_DIRTY); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_DIRTY)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetDirty()); + pc->SetState(STATE_CHECK, m_engine->GetDirty()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FOG); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FOG)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetFog()); + pc->SetState(STATE_CHECK, m_engine->GetFog()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_LENS); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LENS)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetLensMode()); + pc->SetState(STATE_CHECK, m_engine->GetLensMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SKY); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SKY)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetSkyMode()); + pc->SetState(STATE_CHECK, m_engine->GetSkyMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_PLANET); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_PLANET)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetPlanetMode()); + pc->SetState(STATE_CHECK, m_engine->GetPlanetMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_LIGHT); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LIGHT)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetLightMode()); + pc->SetState(STATE_CHECK, m_engine->GetLightMode()); } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_JOYSTICK); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_JOYSTICK)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_engine->RetJoystick()); + pc->SetState(STATE_CHECK, m_app->GetJoystickEnabled()); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_PARTI); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI)); if ( pv != 0 ) { - value = m_engine->RetParticuleDensity(); + value = m_engine->GetParticleDensity(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_CLIP); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP)); if ( pv != 0 ) { - value = m_engine->RetClippingDistance(); + value = m_engine->GetClippingDistance(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_DETAIL); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL)); if ( pv != 0 ) { - value = m_engine->RetObjectDetail(); + value = m_engine->GetObjectDetail(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_GADGET); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET)); if ( pv != 0 ) { - value = m_engine->RetGadgetQuantity(); + value = m_engine->GetGadgetQuantity(); pv->SetValue(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_TEXTURE); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE)); if ( pv != 0 ) { - value = (float)m_engine->RetTextureQuality(); + value = static_cast<float>(m_engine->GetTextureQuality()); pv->SetValue(value); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLSOUND); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND)); if ( ps != 0 ) { - value = (float)m_sound->RetAudioVolume(); + value = static_cast<float>(m_sound->GetAudioVolume()); ps->SetVisibleValue(value); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLMUSIC); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC)); if ( ps != 0 ) { - value = (float)m_sound->RetMidiVolume(); - ps->SetVisibleValue(value); + /* TODO: midi volume + value = (float)m_sound->GetMidiVolume(); + ps->SetVisibleValue(value);*/ } - pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOUND3D); + pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOUND3D)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_sound->RetSound3D()); - pc->SetState(STATE_ENABLE, m_sound->RetSound3DCap()); + pc->SetState(STATE_CHECK, m_sound->GetSound3D()); + pc->SetState(STATE_ENABLE, m_sound->GetSound3DCap()); } } @@ -5459,56 +5467,58 @@ void CMainDialog::ChangeSetupButtons() CSlider* ps; float value; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_PARTI); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI)); if ( pv != 0 ) { - value = pv->RetValue(); - m_engine->SetParticuleDensity(value); + value = pv->GetValue(); + m_engine->SetParticleDensity(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_CLIP); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP)); if ( pv != 0 ) { - value = pv->RetValue(); + value = pv->GetValue(); m_engine->SetClippingDistance(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_DETAIL); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL)); if ( pv != 0 ) { - value = pv->RetValue(); + value = pv->GetValue(); m_engine->SetObjectDetail(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_GADGET); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET)); if ( pv != 0 ) { - value = pv->RetValue(); + value = pv->GetValue(); m_engine->SetGadgetQuantity(value); } - pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_TEXTURE); + pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE)); if ( pv != 0 ) { - value = pv->RetValue(); - m_engine->SetTextureQuality((int)value); + value = pv->GetValue(); + m_engine->SetTextureQuality(static_cast<int>(value)); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLSOUND); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND)); if ( ps != 0 ) { - value = ps->RetVisibleValue(); - m_sound->SetAudioVolume((int)value); + value = ps->GetVisibleValue(); + m_sound->SetAudioVolume(static_cast<int>(value)); } - ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLMUSIC); + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC)); if ( ps != 0 ) { - value = ps->RetVisibleValue(); - m_sound->SetMidiVolume((int)value); + /* + TODO: midi volume + value = ps->GetVisibleValue(); + m_sound->SetMidiVolume((int)value);*/ } } @@ -5522,13 +5532,14 @@ void CMainDialog::SetupMemorize() char key[500]; char num[10]; + /* TODO: profile SetLocalProfileString("Directory", "scene", m_sceneDir); SetLocalProfileString("Directory", "savegame", m_savegameDir); SetLocalProfileString("Directory", "public", m_publicDir); SetLocalProfileString("Directory", "user", m_userDir); SetLocalProfileString("Directory", "files", m_filesDir); - iValue = m_engine->RetTotoMode(); + iValue = m_engine->GetTotoMode(); SetLocalProfileInt("Setup", "TotoMode", iValue); iValue = m_bTooltip; @@ -5540,7 +5551,7 @@ void CMainDialog::SetupMemorize() iValue = m_bRain; SetLocalProfileInt("Setup", "InterfaceGlint", iValue); - iValue = m_engine->RetNiceMouse(); + iValue = m_engine->GetNiceMouse(); SetLocalProfileInt("Setup", "NiceMouse", iValue); iValue = m_bSoluce4; @@ -5564,78 +5575,80 @@ void CMainDialog::SetupMemorize() iValue = m_bEffect; SetLocalProfileInt("Setup", "InterfaceEffect", iValue); - iValue = m_engine->RetShadow(); + iValue = m_engine->GetShadow(); SetLocalProfileInt("Setup", "GroundShadow", iValue); - iValue = m_engine->RetGroundSpot(); + iValue = m_engine->GetGroundSpot(); SetLocalProfileInt("Setup", "GroundSpot", iValue); - iValue = m_engine->RetDirty(); + iValue = m_engine->GetDirty(); SetLocalProfileInt("Setup", "ObjectDirty", iValue); - iValue = m_engine->RetFog(); + iValue = m_engine->GetFog(); SetLocalProfileInt("Setup", "FogMode", iValue); - iValue = m_engine->RetLensMode(); + iValue = m_engine->GetLensMode(); SetLocalProfileInt("Setup", "LensMode", iValue); - iValue = m_engine->RetSkyMode(); + iValue = m_engine->GetSkyMode(); SetLocalProfileInt("Setup", "SkyMode", iValue); - iValue = m_engine->RetPlanetMode(); + iValue = m_engine->GetPlanetMode(); SetLocalProfileInt("Setup", "PlanetMode", iValue); - iValue = m_engine->RetLightMode(); + iValue = m_engine->GetLightMode(); SetLocalProfileInt("Setup", "LightMode", iValue); - iValue = m_engine->RetJoystick(); + iValue = m_engine->GetJoystick(); SetLocalProfileInt("Setup", "UseJoystick", iValue); - fValue = m_engine->RetParticuleDensity(); - SetLocalProfileFloat("Setup", "ParticuleDensity", fValue); + fValue = m_engine->GetParticleDensity(); + SetLocalProfileFloat("Setup", "ParticleDensity", fValue); - fValue = m_engine->RetClippingDistance(); + fValue = m_engine->GetClippingDistance(); SetLocalProfileFloat("Setup", "ClippingDistance", fValue); - fValue = m_engine->RetObjectDetail(); + fValue = m_engine->GetObjectDetail(); SetLocalProfileFloat("Setup", "ObjectDetail", fValue); - fValue = m_engine->RetGadgetQuantity(); + fValue = m_engine->GetGadgetQuantity(); SetLocalProfileFloat("Setup", "GadgetQuantity", fValue); - iValue = m_engine->RetTextureQuality(); + iValue = m_engine->GetTextureQuality(); SetLocalProfileInt("Setup", "TextureQuality", iValue); - iValue = m_sound->RetAudioVolume(); + iValue = m_sound->GetAudioVolume(); SetLocalProfileInt("Setup", "AudioVolume", iValue); - iValue = m_sound->RetMidiVolume(); + iValue = m_sound->GetMidiVolume(); SetLocalProfileInt("Setup", "MidiVolume", iValue); - iValue = m_sound->RetSound3D(); + iValue = m_sound->GetSound3D(); SetLocalProfileInt("Setup", "Sound3D", iValue); - iValue = m_engine->RetEditIndentMode(); + iValue = m_engine->GetEditIndentMode(); SetLocalProfileInt("Setup", "EditIndentMode", iValue); - iValue = m_engine->RetEditIndentValue(); - SetLocalProfileInt("Setup", "EditIndentValue", iValue); + iValue = m_engine->GetEditIndentValue(); + SetLocalProfileInt("Setup", "EditIndentValue", iValue);*/ - key[0] = 0; + /* key[0] = 0; for ( i=0 ; i<100 ; i++ ) { - if ( m_engine->RetKey(i, 0) == 0 ) break; + if ( m_engine->GetKey(i, 0) == 0 ) break; for ( j=0 ; j<2 ; j++ ) { - iValue = m_engine->RetKey(i, j); + iValue = m_engine->GetKey(i, j); sprintf(num, "%d%c", iValue, j==0?'+':' '); strcat(key, num); } - } - SetLocalProfileString("Setup", "KeyMap", key); + }*/ + + /* TODO: profile + SetLocalProfileString("Setup", "KeyMap", key); */ -#if _NET +/* TODO: #if _NET if ( m_accessEnable ) { iValue = m_accessMission; @@ -5644,12 +5657,14 @@ void CMainDialog::SetupMemorize() iValue = m_accessUser; SetLocalProfileInt("Setup", "AccessUser", iValue); } -#endif +#endif */ + /* TODO: profile iValue = m_bDeleteGamer; - SetLocalProfileInt("Setup", "DeleteGamer", iValue); + SetLocalProfileInt("Setup", "DeleteGamer", iValue); */ - m_engine->WriteProfile(); + // TODO: write profile + //m_engine->WriteProfile(); } // Remember all the settings. @@ -5661,27 +5676,28 @@ void CMainDialog::SetupRecall() char key[500]; char* p; - if ( GetLocalProfileString("Directory", "scene", key, _MAX_FNAME) ) + /* TODO: profile + if ( GetLocalProfileString("Directory", "scene", key, MAX_FNAME) ) { strcpy(m_sceneDir, key); } - if ( GetLocalProfileString("Directory", "savegame", key, _MAX_FNAME) ) + if ( GetLocalProfileString("Directory", "savegame", key, MAX_FNAME) ) { strcpy(m_savegameDir, key); } - if ( GetLocalProfileString("Directory", "public", key, _MAX_FNAME) ) + if ( GetLocalProfileString("Directory", "public", key, MAX_FNAME) ) { strcpy(m_publicDir, key); } - if ( GetLocalProfileString("Directory", "user", key, _MAX_FNAME) ) + if ( GetLocalProfileString("Directory", "user", key, MAX_FNAME) ) { strcpy(m_userDir, key); } - if ( GetLocalProfileString("Directory", "files", key, _MAX_FNAME) ) + if ( GetLocalProfileString("Directory", "files", key, MAX_FNAME) ) { strcpy(m_filesDir, key); } @@ -5773,7 +5789,7 @@ void CMainDialog::SetupRecall() if ( GetLocalProfileInt("Setup", "FogMode", iValue) ) { m_engine->SetFog(iValue); - m_camera->SetOverBaseColor(RetColor(RetColor(0.0f))); + m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f))); // TODO: color ok? } if ( GetLocalProfileInt("Setup", "LensMode", iValue) ) @@ -5801,9 +5817,9 @@ void CMainDialog::SetupRecall() m_engine->SetJoystick(iValue); } - if ( GetLocalProfileFloat("Setup", "ParticuleDensity", fValue) ) + if ( GetLocalProfileFloat("Setup", "ParticleDensity", fValue) ) { - m_engine->SetParticuleDensity(fValue); + m_engine->SetParticleDensity(fValue); } if ( GetLocalProfileFloat("Setup", "ClippingDistance", fValue) ) @@ -5861,9 +5877,9 @@ void CMainDialog::SetupRecall() while ( *p == ' ' || *p == '+' ) p++; } } - } + } */ -#if _NET +/* TODO: #if _NET if ( m_accessEnable ) { if ( GetLocalProfileInt("Setup", "AccessMission", iValue) ) @@ -5876,12 +5892,13 @@ void CMainDialog::SetupRecall() m_accessUser = iValue; } } -#endif +#endif */ + /* TODO: profile if ( GetLocalProfileInt("Setup", "DeleteGamer", iValue) ) { m_bDeleteGamer = iValue; - } + } */ } @@ -5902,12 +5919,12 @@ void CMainDialog::ChangeSetupQuality(int quality) m_engine->SetSkyMode(bEnable); m_engine->SetPlanetMode(bEnable); m_engine->SetLightMode(bEnable); - m_camera->SetOverBaseColor(RetColor(RetColor(0.0f))); + m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok? if ( quality < 0 ) value = 0.0f; if ( quality == 0 ) value = 1.0f; if ( quality > 0 ) value = 2.0f; - m_engine->SetParticuleDensity(value); + m_engine->SetParticleDensity(value); if ( quality < 0 ) value = 0.5f; if ( quality == 0 ) value = 1.0f; @@ -5929,7 +5946,8 @@ void CMainDialog::ChangeSetupQuality(int quality) if ( quality > 0 ) iValue = 2; m_engine->SetTextureQuality(iValue); - m_engine->FirstExecuteAdapt(false); + // TODO: first execute adapt? + //m_engine->FirstExecuteAdapt(false); } @@ -5937,48 +5955,48 @@ void CMainDialog::ChangeSetupQuality(int quality) static int key_table[KEY_TOTAL] = { -#if _SCHOOL & _TEEN - KEYRANK_LEFT, - KEYRANK_RIGHT, - KEYRANK_UP, - KEYRANK_DOWN, - KEYRANK_CAMERA, - KEYRANK_NEAR, - KEYRANK_AWAY, - KEYRANK_HELP, - KEYRANK_PROG, - KEYRANK_SPEED10, - KEYRANK_SPEED15, - KEYRANK_SPEED20, - KEYRANK_QUIT, -#else - KEYRANK_LEFT, - KEYRANK_RIGHT, - KEYRANK_UP, - KEYRANK_DOWN, - KEYRANK_GUP, - KEYRANK_GDOWN, - KEYRANK_ACTION, - KEYRANK_CAMERA, - KEYRANK_VISIT, - KEYRANK_NEXT, - KEYRANK_HUMAN, - KEYRANK_DESEL, - KEYRANK_NEAR, - KEYRANK_AWAY, - KEYRANK_HELP, - KEYRANK_PROG, - KEYRANK_CBOT, - KEYRANK_SPEED10, - KEYRANK_SPEED15, - KEYRANK_SPEED20, - KEYRANK_QUIT, -#endif +/* TODO: #if _SCHOOL & _TEEN + INPUT_SLOT_LEFT, + INPUT_SLOT_RIGHT, + INPUT_SLOT_UP, + INPUT_SLOT_DOWN, + INPUT_SLOT_CAMERA, + INPUT_SLOT_NEAR, + INPUT_SLOT_AWAY, + INPUT_SLOT_HELP, + INPUT_SLOT_PROG, + INPUT_SLOT_SPEED10, + INPUT_SLOT_SPEED15, + INPUT_SLOT_SPEED20, + INPUT_SLOT_QUIT, +#else */ + INPUT_SLOT_LEFT, + INPUT_SLOT_RIGHT, + INPUT_SLOT_UP, + INPUT_SLOT_DOWN, + INPUT_SLOT_GUP, + INPUT_SLOT_GDOWN, + INPUT_SLOT_ACTION, + INPUT_SLOT_CAMERA, + INPUT_SLOT_VISIT, + INPUT_SLOT_NEXT, + INPUT_SLOT_HUMAN, + INPUT_SLOT_DESEL, + INPUT_SLOT_NEAR, + INPUT_SLOT_AWAY, + INPUT_SLOT_HELP, + INPUT_SLOT_PROG, + INPUT_SLOT_CBOT, + INPUT_SLOT_SPEED10, + INPUT_SLOT_SPEED15, + INPUT_SLOT_SPEED20, + INPUT_SLOT_QUIT, +// #endif }; -static EventMsg key_event[KEY_TOTAL] = +static EventType key_event[KEY_TOTAL] = { -#if _SCHOOL & _TEEN +/* TODO: #if _SCHOOL & _TEEN EVENT_INTERFACE_KLEFT, EVENT_INTERFACE_KRIGHT, EVENT_INTERFACE_KUP, @@ -5992,7 +6010,7 @@ static EventMsg key_event[KEY_TOTAL] = EVENT_INTERFACE_KSPEED15, EVENT_INTERFACE_KSPEED20, EVENT_INTERFACE_KQUIT, -#else +#else */ EVENT_INTERFACE_KLEFT, EVENT_INTERFACE_KRIGHT, EVENT_INTERFACE_KUP, @@ -6014,7 +6032,7 @@ static EventMsg key_event[KEY_TOTAL] = EVENT_INTERFACE_KSPEED15, EVENT_INTERFACE_KSPEED20, EVENT_INTERFACE_KQUIT, -#endif +//#endif }; // Updates the list of keys. @@ -6027,13 +6045,13 @@ void CMainDialog::UpdateKey() Math::Point pos, dim; int first, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - ps = (CScroll*)pw->SearchControl(EVENT_INTERFACE_KSCROLL); + ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL)); if ( ps == 0 ) return; - first = (int)(ps->RetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE)); + first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE)); for ( i=0 ; i<KEY_TOTAL ; i++ ) { @@ -6047,37 +6065,39 @@ void CMainDialog::UpdateKey() for ( i=0 ; i<KEY_VISIBLE ; i++ ) { pw->CreateKey(pos, dim, -1, key_event[first+i]); - pk = (CKey*)pw->SearchControl(key_event[first+i]); + pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i])); if ( pk == 0 ) break; - pk->SetKey(0, m_engine->RetKey(key_table[first+i], 0)); - pk->SetKey(1, m_engine->RetKey(key_table[first+i], 1)); + /* TODO: set input bindings + pk->SetKey(0, m_engine->GetKey(key_table[first+i], 0)); + pk->SetKey(1, m_engine->GetKey(key_table[first+i], 1)); */ pos.y -= dim.y; } } // Change a key. -void CMainDialog::ChangeKey(EventMsg event) +void CMainDialog::ChangeKey(EventType event) { CWindow* pw; CScroll* ps; CKey* pk; int i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; - ps = (CScroll*)pw->SearchControl(EVENT_INTERFACE_KSCROLL); + ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL)); if ( ps == 0 ) return; for ( i=0 ; i<KEY_TOTAL ; i++ ) { if ( key_event[i] == event ) { - pk = (CKey*)pw->SearchControl(key_event[i]); + pk = static_cast<CKey*>(pw->SearchControl(key_event[i])); if ( pk == 0 ) break; - m_engine->SetKey(key_table[i], 0, pk->RetKey(0)); - m_engine->SetKey(key_table[i], 1, pk->RetKey(1)); + /* TODO: set key binding + m_engine->SetKey(key_table[i], 0, pk->GetKey(0)); + m_engine->SetKey(key_table[i], 1, pk->GetKey(1)); */ } } } @@ -6096,7 +6116,7 @@ void CMainDialog::StartAbort() StartDialog(Math::Point(0.3f, 0.8f), true, false, false); m_bDialogDelete = false; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.35f; @@ -6112,10 +6132,10 @@ void CMainDialog::StartAbort() pos.x = 0.40f; dim.x = 0.20f; -#if _POLISH +/* TODO: #if _POLISH pos.x -= 7.0f/640.0f; dim.x += 14.0f/640.0f; -#endif +#endif*/ dim.y = 32.0f/480.0f; pos.y = 0.74f; @@ -6146,12 +6166,13 @@ void CMainDialog::StartAbort() pb->SetState(STATE_WARNING); } - if ( m_engine->RetSetupMode() ) + /* TODO: setup mode? + if ( m_engine->GetSetupMode() ) { pos.y = 0.39f; pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_SETUP); pb->SetState(STATE_SHADOW); - } + }*/ pos.y = 0.25f; pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_AGAIN); @@ -6178,7 +6199,7 @@ void CMainDialog::StartDeleteObject() StartDialog(Math::Point(0.7f, 0.3f), false, true, true); m_bDialogDelete = true; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.00f; @@ -6188,13 +6209,13 @@ void CMainDialog::StartDeleteObject() GetResource(RES_TEXT, RT_DIALOG_DELOBJ, name); pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_YESDEL, name); pb->SetName(name); pb->SetState(STATE_WARNING); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_NODEL, name); pb->SetName(name); @@ -6213,7 +6234,7 @@ void CMainDialog::StartDeleteGame(char *gamer) StartDialog(Math::Point(0.7f, 0.3f), false, true, true); m_bDialogDelete = true; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.00f; @@ -6224,13 +6245,13 @@ void CMainDialog::StartDeleteGame(char *gamer) sprintf(text, name, gamer); pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, text); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_YESDEL, name); pb->SetName(name); pb->SetState(STATE_WARNING); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_NODEL, name); pb->SetName(name); @@ -6247,7 +6268,7 @@ void CMainDialog::StartQuit() StartDialog(Math::Point(0.6f, 0.3f), false, true, true); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == 0 ) return; pos.x = 0.00f; @@ -6257,13 +6278,13 @@ void CMainDialog::StartQuit() GetResource(RES_TEXT, RT_DIALOG_QUIT, name); pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_YESQUIT, name); pb->SetName(name); pb->SetState(STATE_WARNING); - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb == 0 ) return; GetResource(RES_TEXT, RT_DIALOG_NOQUIT, name); pb->SetName(name); @@ -6280,34 +6301,34 @@ void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCance StartSuspend(); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW8)); if ( pw != 0 ) pw->ClearState(STATE_ENABLE); - pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + pb = static_cast<CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( pb != 0 ) { pb->ClearState(STATE_VISIBLE); @@ -6371,7 +6392,7 @@ void CMainDialog::FrameDialog(float rTime) m_dialogTime += rTime; if ( m_dialogTime < 1.0f ) { - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw != 0 ) { if ( m_dialogTime < 0.50f ) @@ -6400,7 +6421,7 @@ void CMainDialog::FrameDialog(float rTime) if ( !m_bGlint ) return; m_dialogParti += rTime; - if ( m_dialogParti < m_engine->ParticuleAdapt(0.05f) ) return; + if ( m_dialogParti < m_engine->ParticleAdapt(0.05f) ) return; m_dialogParti = 0.0f; if ( !m_bDialogFire ) return; @@ -6420,9 +6441,9 @@ void CMainDialog::FrameDialog(float rTime) pos.y += Math::Rand()*(16.0f/480.0f)-(10.0f/480.0f); dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, - (ParticuleType)(PARTILENS1+rand()%3), - 1.0f, 0.0f, 0.0f, SH_INTERFACE); + m_particle->CreateParticle(pos, speed, dim, + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), + 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); // Top. pos.x = dpos.x + ddim.x*Math::Rand(); @@ -6431,9 +6452,9 @@ void CMainDialog::FrameDialog(float rTime) pos.y -= Math::Rand()*(16.0f/480.0f)-(10.0f/480.0f); dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, - (ParticuleType)(PARTILENS1+rand()%3), - 1.0f, 0.0f, 0.0f, SH_INTERFACE); + m_particle->CreateParticle(pos, speed, dim, + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), + 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); // Left. pos.y = dpos.y + ddim.y*Math::Rand(); @@ -6442,9 +6463,9 @@ void CMainDialog::FrameDialog(float rTime) pos.y += (Math::Rand()-0.5f)*(6.0f/480.0f); dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, - (ParticuleType)(PARTILENS1+rand()%3), - 1.0f, 0.0f, 0.0f, SH_INTERFACE); + m_particle->CreateParticle(pos, speed, dim, + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), + 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); // Right. pos.y = dpos.y + ddim.y*Math::Rand(); @@ -6453,9 +6474,9 @@ void CMainDialog::FrameDialog(float rTime) pos.y += (Math::Rand()-0.5f)*(6.0f/480.0f); dim.x = 0.01f+Math::Rand()*0.01f; dim.y = dim.x/0.75f; - m_particule->CreateParticule(pos, speed, dim, - (ParticuleType)(PARTILENS1+rand()%3), - 1.0f, 0.0f, 0.0f, SH_INTERFACE); + m_particle->CreateParticle(pos, speed, dim, + static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3), + 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE); } } @@ -6466,34 +6487,34 @@ void CMainDialog::StopDialog() CWindow* pw; CButton* pb; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW8)); if ( pw != 0 ) pw->SetState(STATE_ENABLE); - pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + pb = static_cast<CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( pb != 0 ) { pb->SetState(STATE_VISIBLE); @@ -6510,13 +6531,13 @@ void CMainDialog::StartSuspend() { m_sound->MuteAll(true); m_main->ClearInterface(); - m_bInitPause = m_engine->RetPause(); + m_bInitPause = m_engine->GetPause(); m_engine->SetPause(true); m_engine->SetOverFront(false); // over flat behind m_main->CreateShortcuts(); m_main->StartSuspend(); - m_initCamera = m_camera->RetType(); - m_camera->SetType(CAMERA_DIALOG); + m_initCamera = m_camera->GetType(); + m_camera->SetType(Gfx::CAM_TYPE_DIALOG); } // Resume the simulation after a period of dialog. @@ -6535,7 +6556,7 @@ void CMainDialog::StopSuspend() // Whether to use tooltips. -bool CMainDialog::RetTooltip() +bool CMainDialog::GetTooltip() { return m_bTooltip; } @@ -6552,42 +6573,42 @@ bool CMainDialog::IsDialog() // Specifies the name of the scene to read. -void CMainDialog::SetSceneRead(char* name) +void CMainDialog::SetSceneRead(const char* name) { strcpy(m_sceneRead, name); } -// Returns the name of the scene to read. +// Geturns the name of the scene to read. -char* CMainDialog::RetSceneRead() +char* CMainDialog::GetSceneRead() { return m_sceneRead; } // Specifies the name of the scene to read. -void CMainDialog::SetStackRead(char* name) +void CMainDialog::SetStackRead(const char* name) { strcpy(m_stackRead, name); } -// Returns the name of the scene to read. +// Geturns the name of the scene to read. -char* CMainDialog::RetStackRead() +char* CMainDialog::GetStackRead() { return m_stackRead; } // Specifies the name of the chosen to play scene. -void CMainDialog::SetSceneName(char* name) +void CMainDialog::SetSceneName(const char* name) { strcpy(m_sceneName, name); } -// Returns the name of the chosen to play scene. +// Geturns the name of the chosen to play scene. -char* CMainDialog::RetSceneName() +char* CMainDialog::GetSceneName() { return m_sceneName; } @@ -6599,16 +6620,16 @@ void CMainDialog::SetSceneRank(int rank) m_sceneRank = rank; } -// Returns the rank of the chosen to play scene. +// Geturns the rank of the chosen to play scene. -int CMainDialog::RetSceneRank() +int CMainDialog::GetSceneRank() { return m_sceneRank; } -// Returns folder name of the scene that user selected to play. +// Geturns folder name of the scene that user selected to play. -char* CMainDialog::RetSceneDir() +char* CMainDialog::GetSceneDir() { int i; @@ -6620,21 +6641,21 @@ char* CMainDialog::RetSceneDir() // Whether to show the solution. -bool CMainDialog::RetSceneSoluce() +bool CMainDialog::GetSceneSoluce() { return m_bSceneSoluce; } -// Returns the name of the folder to save. +// Geturns the name of the folder to save. -char* CMainDialog::RetSavegameDir() +char* CMainDialog::GetSavegameDir() { return m_savegameDir; } -// Returns the name of public folder. +// Geturns the name of public folder. -char* CMainDialog::RetPublicDir() +char* CMainDialog::GetPublicDir() { return m_publicDir; } @@ -6642,35 +6663,35 @@ char* CMainDialog::RetPublicDir() // Indicates if there are reflections on the buttons. -bool CMainDialog::RetGlint() +bool CMainDialog::GetGlint() { return m_bGlint; } // Whether to show 4:solutions. -bool CMainDialog::RetSoluce4() +bool CMainDialog::GetSoluce4() { return m_bSoluce4; } // Whether to show the cinematics. -bool CMainDialog::RetMovies() +bool CMainDialog::GetMovies() { return m_bMovies; } // IWhether to make an animation in CTaskReset. -bool CMainDialog::RetNiceReset() +bool CMainDialog::GetNiceReset() { return m_bNiceReset; } // Indicates whether the fire causes damage to its own units. -bool CMainDialog::RetHimselfDamage() +bool CMainDialog::GetHimselfDamage() { return m_bHimselfDamage; } @@ -6709,7 +6730,7 @@ void CMainDialog::ReadGamerPerso(char *gamer) FILE* file; char filename[100]; char line[100]; - D3DCOLORVALUE color; + Gfx::Color color; m_perso.face = 0; DefPerso(); @@ -6729,7 +6750,7 @@ void CMainDialog::ReadGamerPerso(char *gamer) color.g = 0.0f; color.b = 0.0f; color.a = 0.0f; - m_perso.colorHair = OpColorValue(line, "hair", color); + m_perso.colorHair = OpColor(line, "hair", color); } if ( Cmd(line, "Body") ) @@ -6738,13 +6759,13 @@ void CMainDialog::ReadGamerPerso(char *gamer) color.g = 0.0f; color.b = 0.0f; color.a = 0.0f; - m_perso.colorCombi = OpColorValue(line, "combi", color); + m_perso.colorCombi = OpColor(line, "combi", color); color.r = 0.0f; color.g = 0.0f; color.b = 0.0f; color.a = 0.0f; - m_perso.colorBand = OpColorValue(line, "band", color); + m_perso.colorBand = OpColor(line, "band", color); } } @@ -6761,7 +6782,7 @@ void CMainDialog::SetGamerFace(char *gamer, int face) // Gives the face of the player. -int CMainDialog::RetGamerFace(char *gamer) +int CMainDialog::GetGamerFace(char *gamer) { ReadGamerPerso(gamer); return m_perso.face; @@ -6769,37 +6790,37 @@ int CMainDialog::RetGamerFace(char *gamer) // Gives the face of the player. -int CMainDialog::RetGamerFace() +int CMainDialog::GetGamerFace() { return m_perso.face; } -int CMainDialog::RetGamerGlasses() +int CMainDialog::GetGamerGlasses() { return m_perso.glasses; } -bool CMainDialog::RetGamerOnlyHead() +bool CMainDialog::GetGamerOnlyHead() { return (m_phase == PHASE_PERSO && m_persoTab == 0); } -float CMainDialog::RetPersoAngle() +float CMainDialog::GetPersoAngle() { return m_persoAngle; } -D3DCOLORVALUE CMainDialog::RetGamerColorHair() +Gfx::Color CMainDialog::GetGamerColorHair() { return m_perso.colorHair; } -D3DCOLORVALUE CMainDialog::RetGamerColorCombi() +Gfx::Color CMainDialog::GetGamerColorCombi() { return m_perso.colorCombi; } -D3DCOLORVALUE CMainDialog::RetGamerColorBand() +Gfx::Color CMainDialog::GetGamerColorBand() { return m_perso.colorBand; } @@ -6819,7 +6840,7 @@ bool CMainDialog::ReadGamerInfo() m_sceneInfo[i].bPassed = false; } - sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->RetGamerName(), m_sceneName); + sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName); file = fopen(line, "r"); if ( file == NULL ) return false; @@ -6855,7 +6876,7 @@ bool CMainDialog::WriteGamerInfo() char line[100]; int i; - sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->RetGamerName(), m_sceneName); + sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName); file = fopen(line, "w"); if ( file == NULL ) return false; @@ -6883,7 +6904,7 @@ void CMainDialog::SetGamerInfoTry(int rank, int numTry) m_sceneInfo[rank].numTry = numTry; } -int CMainDialog::RetGamerInfoTry(int rank) +int CMainDialog::GetGamerInfoTry(int rank) { if ( rank < 0 || rank >= MAXSCENE ) return 0; return m_sceneInfo[rank].numTry; @@ -6910,7 +6931,7 @@ void CMainDialog::SetGamerInfoPassed(int rank, bool bPassed) } } -bool CMainDialog::RetGamerInfoPassed(int rank) +bool CMainDialog::GetGamerInfoPassed(int rank) { if ( rank < 0 || rank >= MAXSCENE ) return false; return m_sceneInfo[rank].bPassed; @@ -6932,4 +6953,5 @@ bool CMainDialog::NextMission() return true; } +} // namespace Ui diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index cfd9564..8b0ef81 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -19,24 +19,32 @@ #pragma once -#include "common/struct.h" -#include "old/camera.h" +#include "graphics/core/color.h" #include "object/robotmain.h" - class CInstanceManager; -class CEvent; -class CD3DEngine; +class CEventQueue; +class CSoundInterface; + +namespace Gfx +{ +class CEngine; +class CParticle; +}; + +namespace Ui +{ + class CInterface; class CWindow; class CControl; -class CParticule; -class CSound; const int USERLISTMAX = 100; const int MAXSCENE = 1000; +const int MAX_FNAME = 255; // TODO: remove after rewrite to std::string + struct SceneInfo { char numTry; @@ -47,9 +55,9 @@ struct GamerPerso { int face; // face int glasses; // glasses - D3DCOLORVALUE colorHair; // hair color - D3DCOLORVALUE colorCombi; // spacesuit volor - D3DCOLORVALUE colorBand; // strips color + Gfx::Color colorHair; // hair color + Gfx::Color colorCombi; // spacesuit volor + Gfx::Color colorBand; // strips color }; @@ -63,30 +71,30 @@ public: bool EventProcess(const Event &event); void ChangePhase(Phase phase); - void SetSceneRead(char* name); - void SetStackRead(char* name); - void SetSceneName(char* name); + void SetSceneRead(const char* name); + void SetStackRead(const char* name); + void SetSceneName(const char* name); void SetSceneRank(int rank); - char* RetSceneRead(); - char* RetStackRead(); - char* RetSceneName(); - int RetSceneRank(); - char* RetSceneDir(); - bool RetSceneSoluce(); - char* RetSavegameDir(); - char* RetPublicDir(); - - bool RetTooltip(); - bool RetGlint(); - bool RetSoluce4(); - bool RetMovies(); - bool RetNiceReset(); - bool RetHimselfDamage(); + char* GetSceneRead(); + char* GetStackRead(); + char* GetSceneName(); + int GetSceneRank(); + char* GetSceneDir(); + bool GetSceneSoluce(); + char* GetSavegameDir(); + char* GetPublicDir(); + + bool GetTooltip(); + bool GetGlint(); + bool GetSoluce4(); + bool GetMovies(); + bool GetNiceReset(); + bool GetHimselfDamage(); void SetUserDir(char *base, int rank); void BuildSceneName(char *filename, char *base, int rank); void BuildResumeName(char *filename, char *base, int rank); - char* RetFilesDir(); + char* GetFilesDir(); void StartAbort(); void StartDeleteObject(); @@ -106,30 +114,30 @@ public: bool ReadGamerInfo(); bool WriteGamerInfo(); void SetGamerInfoTry(int rank, int numTry); - int RetGamerInfoTry(int rank); + int GetGamerInfoTry(int rank); void SetGamerInfoPassed(int rank, bool bPassed); - bool RetGamerInfoPassed(int rank); + bool GetGamerInfoPassed(int rank); bool NextMission(); void WriteGamerPerso(char *gamer); void ReadGamerPerso(char *gamer); void SetGamerFace(char *gamer, int face); - int RetGamerFace(char *gamer); - int RetGamerFace(); - int RetGamerGlasses(); - bool RetGamerOnlyHead(); - float RetPersoAngle(); - D3DCOLORVALUE RetGamerColorHair(); - D3DCOLORVALUE RetGamerColorCombi(); - D3DCOLORVALUE RetGamerColorBand(); + int GetGamerFace(char *gamer); + int GetGamerFace(); + int GetGamerGlasses(); + bool GetGamerOnlyHead(); + float GetPersoAngle(); + Gfx::Color GetGamerColorHair(); + Gfx::Color GetGamerColorCombi(); + Gfx::Color GetGamerColorBand(); void AllMissionUpdate(); void ShowSoluceUpdate(); protected: void GlintMove(); - void FrameParticule(float rTime); - void NiceParticule(Math::Point mouse, bool bPress); + void FrameParticle(float rTime); + void NiceParticle(Math::Point mouse, bool bPress); void ReadNameList(); void UpdateNameList(); void UpdateNameEdit(); @@ -150,7 +158,7 @@ protected: void IODeleteScene(); bool IOWriteScene(); bool IOReadScene(); - int RetChapPassed(); + int GetChapPassed(); void UpdateSceneChap(int &chap); void UpdateSceneList(int chap, int &sel); void UpdateSceneResume(int rank); @@ -162,17 +170,18 @@ protected: void ChangeSetupButtons(); void ChangeSetupQuality(int quality); void UpdateKey(); - void ChangeKey(EventMsg event); + void ChangeKey(EventType event); protected: CInstanceManager* m_iMan; - CRobotMain* m_main; - CEvent* m_event; - CD3DEngine* m_engine; - CInterface* m_interface; - CParticule* m_particule; - CCamera* m_camera; - CSound* m_sound; + CApplication* m_app; + CRobotMain* m_main; + CEventQueue* m_eventQueue; + Gfx::CEngine* m_engine; + CInterface* m_interface; + Gfx::CParticle* m_particle; + Gfx::CCamera* m_camera; + CSoundInterface* m_sound; Phase m_phase; // copy of CRobotMain Phase m_phaseSetup; // tab selected @@ -184,11 +193,11 @@ protected: int m_persoTab; // perso: tab selected float m_persoAngle; // perso: angle of presentation - char m_sceneDir[_MAX_FNAME]; // scene folder - char m_savegameDir[_MAX_FNAME]; // savegame folder - char m_publicDir[_MAX_FNAME]; // program folder - char m_userDir[_MAX_FNAME]; // user folder - char m_filesDir[_MAX_FNAME]; // case files + char m_sceneDir[MAX_FNAME]; // scene folder + char m_savegameDir[MAX_FNAME]; // savegame folder + char m_publicDir[MAX_FNAME]; // program folder + char m_userDir[MAX_FNAME]; // user folder + char m_filesDir[MAX_FNAME]; // case files int m_index; // 0..4 int m_chap[10]; // selected chapter (0..8) @@ -241,7 +250,7 @@ protected: float m_dialogParti; float m_dialogTime; bool m_bInitPause; - CameraType m_initCamera; + Gfx::CameraType m_initCamera; int m_partiPhase[10]; float m_partiTime[10]; @@ -250,4 +259,4 @@ protected: SceneInfo m_sceneInfo[MAXSCENE]; }; - +} // namespace Ui diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp index 76e3627..b70bad9 100644 --- a/src/ui/mainmap.cpp +++ b/src/ui/mainmap.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,42 +18,26 @@ // mainmap.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/d3dmath.h" -#include "common/global.h" -#include "common/event.h" -#include "common/iman.h" -#include "ui/interface.h" -#include "ui/map.h" -#include "ui/image.h" -#include "ui/group.h" -#include "ui/slider.h" -#include "ui/scroll.h" -#include "ui/window.h" #include "ui/mainmap.h" +namespace Ui { + const float ZOOM_MIN = 1.0f; const float ZOOM_MAX = 16.0f; - // Constructor of the application card. -CMainMap::CMainMap(CInstanceManager* iMan) +CMainMap::CMainMap() { - m_iMan = iMan; + m_iMan = CInstanceManager::GetInstancePointer(); m_iMan->AddInstance(CLASS_MAP, this); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); + 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_mapMode = 1; m_bFixImage = false; @@ -72,9 +57,8 @@ void CMainMap::CreateMap() CWindow* pw; Math::Point pos, dim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) - { + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) { pos.x = 0.0f; pos.y = 0.0f; dim.x = 0.0f; @@ -82,10 +66,10 @@ void CMainMap::CreateMap() pw = m_interface->CreateWindows(pos, dim, 10, EVENT_WINDOW1); } - dim.x = 10.0f/640.0f; - dim.y = 10.0f/480.0f; - pos.x = 10.0f/640.0f; - pos.y = 10.0f/480.0f; + dim.x = 10.0f / 640.0f; + dim.y = 10.0f / 480.0f; + pos.x = 10.0f / 640.0f; + pos.y = 10.0f / 480.0f; pw->CreateMap (pos, dim, 2, EVENT_OBJECT_MAP); pw->CreateSlider(pos, dim, 0, EVENT_OBJECT_MAPZOOM); @@ -94,16 +78,18 @@ void CMainMap::CreateMap() // Indicates whether the mini-map should display a still image. -void CMainMap::SetFixImage(char *filename) +void CMainMap::SetFixImage(const char *filename) { CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return; pw->DeleteControl(EVENT_OBJECT_MAPZOOM); m_bFixImage = true; @@ -113,17 +99,17 @@ void CMainMap::SetFixImage(char *filename) // Choosing colors of soil and water for the mini-map. -void CMainMap::FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water) +void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water) { CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm != 0 ) - { + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm != nullptr) { pm->SetFloorColor(floor); pm->SetWaterColor(water); } @@ -137,26 +123,20 @@ void CMainMap::ShowMap(bool bShow) CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - if ( bShow ) - { + if (bShow) { DimMap(); - } - else - { - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm != 0 ) - { + } else { + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm != nullptr) pm->ClearState(STATE_VISIBLE); - } - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); - if ( ps != 0 ) - { + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); + if (ps != nullptr) ps->ClearState(STATE_VISIBLE); - } } } @@ -170,10 +150,12 @@ void CMainMap::DimMap() Math::Point pos, dim; float value; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return; pm->SetState(STATE_VISIBLE, (m_mapMode != 0)); @@ -184,20 +166,19 @@ void CMainMap::DimMap() pm->SetPos(pos); pm->SetDim(dim); - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); - if ( ps != 0 ) - { + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); + if (ps != nullptr) { ps->SetState(STATE_VISIBLE, (m_mapMode != 0)); dim.x = SCROLL_WIDTH; - dim.y = 66.0f/480.0f; - pos.x = 523.0f/640.0f; - pos.y = 3.0f/480.0f; + dim.y = 66.0f / 480.0f; + pos.x = 523.0f / 640.0f; + pos.y = 3.0f / 480.0f; ps->SetPos(pos); ps->SetDim(dim); - value = pm->RetZoom(); - value = (value-ZOOM_MIN)/(ZOOM_MAX-ZOOM_MIN); + value = pm->GetZoom(); + value = (value-ZOOM_MIN) / (ZOOM_MAX-ZOOM_MIN); value = powf(value, 0.5f); ps->SetVisibleValue(value); ps->SetArrowStep(0.2f); @@ -206,22 +187,25 @@ void CMainMap::DimMap() // Returns the current zoom of the minimap. -float CMainMap::RetZoomMap() +float CMainMap::GetZoomMap() { CWindow* pw; CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return ZOOM_MIN; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return ZOOM_MIN; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return ZOOM_MIN; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return ZOOM_MIN; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); - if ( ps == 0 ) return ZOOM_MIN; + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); + if (ps == nullptr) + return ZOOM_MIN; - return pm->RetZoom(); + return pm->GetZoom(); } // Zoom the mini-map of any factor. @@ -232,16 +216,21 @@ void CMainMap::ZoomMap(float zoom) CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return; - - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); - if ( ps == 0 ) return; - - if ( zoom < ZOOM_MIN ) zoom = ZOOM_MIN; - if ( zoom > ZOOM_MAX ) zoom = ZOOM_MAX; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return; + + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); + if (ps == nullptr) + return; + + if (zoom < ZOOM_MIN) + zoom = ZOOM_MIN; + if (zoom > ZOOM_MAX) + zoom = ZOOM_MAX; pm->SetZoom(zoom); DimMap(); @@ -256,17 +245,21 @@ void CMainMap::ZoomMap() CSlider* ps; float zoom; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return; + + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); + if (ps == nullptr) + return; - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); - if ( ps == 0 ) return; - zoom = ps->RetVisibleValue(); + zoom = ps->GetVisibleValue(); zoom = powf(zoom, 2.0f); - zoom = ZOOM_MIN+zoom*(ZOOM_MAX-ZOOM_MIN); + zoom = ZOOM_MIN+zoom*(ZOOM_MAX - ZOOM_MIN); pm->SetZoom(zoom); DimMap(); @@ -280,20 +273,17 @@ void CMainMap::MapEnable(bool bEnable) CMap* pm; CSlider* ps; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm != 0 ) - { + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm != nullptr) pm->SetEnable(bEnable); - } - ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM); - if ( ps != 0 ) - { + ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); + if (ps != nullptr) ps->SetState(STATE_ENABLE, bEnable); - } } // Specifies the type of icon for the selected object. @@ -303,11 +293,13 @@ void CMainMap::SetToy(bool bToy) CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return; pm->SetToy(bToy); } @@ -320,11 +312,13 @@ void CMainMap::SetFixParam(float zoom, float ox, float oy, float angle, CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return; pm->SetZoom(zoom); pm->SetOffset(ox, oy); @@ -340,26 +334,25 @@ void CMainMap::UpdateMap() CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm != 0 ) - { + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm != nullptr) pm->UpdateTerrain(); - } } // Indicates if the mini-map is visible. -bool CMainMap::RetShowMap() +bool CMainMap::GetShowMap() { return ( m_mapMode != 0 ); } // Indicates whether the mini-map displays a still image. -bool CMainMap::RetFixImage() +bool CMainMap::GetFixImage() { return m_bFixImage; } @@ -372,31 +365,33 @@ CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap) CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return 0; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return 0; bInMap = false; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm == 0 ) return 0; + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm == nullptr) + return 0; return pm->DetectObject(pos, bInMap); } // Indicates the object with the mouse hovers over. -void CMainMap::SetHilite(CObject* pObj) +void CMainMap::SetHighlight(CObject* pObj) { - CWindow* pw; + CWindow* pw; CMap* pm; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw == 0 ) return; + pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1)); + if (pw == nullptr) + return; - pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP); - if ( pm != 0 ) - { - pm->SetHilite(pObj); - } + pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP)); + if (pm != nullptr) + pm->SetHighlight(pObj); } +} diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h index dba87fc..35aae4c 100644 --- a/src/ui/mainmap.h +++ b/src/ui/mainmap.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,53 +19,50 @@ #pragma once - -#include "common/struct.h" +#include "common/event.h" +#include "graphics/core/color.h" #include "math/point.h" +#include "object/object.h" +#include "ui/interface.h" -class CInstanceManager; -class CEvent; -class CD3DEngine; -class CInterface; -class CObject; - - +namespace Ui { class CMainMap { -public: - CMainMap(CInstanceManager* iMan); - ~CMainMap(); + public: + CMainMap(); + ~CMainMap(); - void UpdateMap(); - void CreateMap(); - void SetFixImage(char *filename); - void FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water); - void ShowMap(bool bShow); - void DimMap(); - float RetZoomMap(); - void ZoomMap(float zoom); - void ZoomMap(); - void MapEnable(bool bEnable); - bool RetShowMap(); - bool RetFixImage(); - CObject* DetectMap(Math::Point pos, bool &bInMap); - void SetHilite(CObject* pObj); - void SetToy(bool bToy); - void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug); + void UpdateMap(); + void CreateMap(); + void SetFixImage(const char *filename); + void FloorColorMap(Gfx::Color floor, Gfx::Color water); + void ShowMap(bool bShow); + void DimMap(); + float GetZoomMap(); + void ZoomMap(float zoom); + void ZoomMap(); + void MapEnable(bool bEnable); + bool GetShowMap(); + bool GetFixImage(); + CObject* DetectMap(Math::Point pos, bool &bInMap); + void SetHighlight(CObject* pObj); + void SetToy(bool bToy); + void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug); -protected: - void CenterMap(); + protected: + void CenterMap(); -protected: - CInstanceManager* m_iMan; - CEvent* m_event; - CD3DEngine* m_engine; - CInterface* m_interface; + protected: + CInstanceManager* m_iMan; + CEventQueue* m_event; + Gfx::CEngine* m_engine; + CInterface* m_interface; - int m_mapMode; - bool m_bFixImage; + int m_mapMode; + bool m_bFixImage; }; +} diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index f23354b..ac6d7fc 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.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,36 +18,21 @@ // mainshort.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/global.h" -#include "common/event.h" -#include "common/iman.h" -#include "object/object.h" -#include "ui/interface.h" -#include "ui/map.h" -#include "ui/button.h" -#include "object/robotmain.h" #include "ui/mainshort.h" - - +namespace Ui { // Constructor of the application card. -CMainShort::CMainShort(CInstanceManager* iMan) +CMainShort::CMainShort() { - m_iMan = iMan; + m_iMan = CInstanceManager::GetInstancePointer(); m_iMan->AddInstance(CLASS_SHORT, this); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); + m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); + m_event = static_cast<CEvent*>(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)); FlushShortcuts(); } @@ -78,7 +64,7 @@ void CMainShort::FlushShortcuts() } } -static EventMsg table_sc_em[20] = +static EventType table_sc_em[20] = { EVENT_OBJECT_SHORTCUT00, EVENT_OBJECT_SHORTCUT01, @@ -113,13 +99,13 @@ bool CMainShort::CreateShortcuts() int i, rank, icon; char name[100]; - if ( m_main->RetFixScene() ) return false; + if ( m_main->GetFixScene() ) return false; m_interface->DeleteControl(EVENT_OBJECT_MOVIELOCK); m_interface->DeleteControl(EVENT_OBJECT_EDITLOCK); for ( i=0 ; i<20 ; i++ ) { - if ( i != 0 && m_shortcuts[i] == 0 ) continue; + if ( i != 0 && m_shortcuts[i] == nullptr ) continue; m_interface->DeleteControl(table_sc_em[i]); m_shortcuts[i] = 0; @@ -130,15 +116,15 @@ bool CMainShort::CreateShortcuts() pos.x = 4.0f/640.0f; pos.y = (480.0f-32.0f)/480.0f; - if ( m_main->RetMovieLock() && - !m_main->RetEditLock() ) // hangs during film? + if ( m_main->GetMovieLock() && + !m_main->GetEditLock() ) // hangs during film? { m_interface->CreateShortcut(pos, dim, 7, EVENT_OBJECT_MOVIELOCK); return true; } - if ( !m_main->RetFreePhoto() && - (m_main->RetEditLock() || - m_engine->RetPause()) ) // hangs during edition? + if ( !m_main->GetFreePhoto() && + (m_main->GetEditLock() || + m_engine->GetPause()) ) // hangs during edition? { m_interface->CreateShortcut(pos, dim, 6, EVENT_OBJECT_EDITLOCK); return true; @@ -153,14 +139,14 @@ bool CMainShort::CreateShortcuts() for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); - if ( pObj == 0 ) break; + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); + if ( pObj == nullptr ) break; - if ( !pObj->RetActif() ) continue; - if ( !pObj->RetSelectable() ) continue; - if ( pObj->RetProxyActivate() ) continue; + if ( !pObj->GetActif() ) continue; + if ( !pObj->GetSelectable() ) continue; + if ( pObj->GetProxyActivate() ) continue; - type = pObj->RetType(); + type = pObj->GetType(); icon = -1; if ( m_bBuilding ) { @@ -243,12 +229,12 @@ bool CMainShort::UpdateShortcuts() for ( i=0 ; i<20 ; i++ ) { - if ( m_shortcuts[i] == 0 ) continue; + if ( m_shortcuts[i] == nullptr ) continue; pc = m_interface->SearchControl(table_sc_em[i]); - if ( pc != 0 ) + if ( pc != nullptr ) { - pc->SetState(STATE_CHECK, m_shortcuts[i]->RetSelect()); + pc->SetState(STATE_CHECK, m_shortcuts[i]->GetSelect()); pc->SetState(STATE_RUN, m_shortcuts[i]->IsProgram()); } } @@ -257,7 +243,7 @@ bool CMainShort::UpdateShortcuts() // Selects an object through a shortcut. -void CMainShort::SelectShortcut(EventMsg event) +void CMainShort::SelectShortcut(EventType event) { int i; @@ -265,7 +251,7 @@ void CMainShort::SelectShortcut(EventMsg event) { if ( event == table_sc_em[i] ) { - if ( i != 0 && m_shortcuts[i] == 0 ) continue; + if ( i != 0 && m_shortcuts[i] == nullptr ) continue; if ( i == 0 ) // buildings <-> vehicles? { @@ -289,9 +275,9 @@ void CMainShort::SelectNext() CObject* pPrev; int i; - if ( m_main->RetMovieLock() || - m_main->RetEditLock() || - m_engine->RetPause() ) return; + if ( m_main->GetMovieLock() || + m_main->GetEditLock() || + m_engine->GetPause() ) return; pPrev = m_main->DeselectAll(); @@ -299,12 +285,12 @@ void CMainShort::SelectNext() { if ( m_shortcuts[i] == pPrev ) { - if ( m_shortcuts[++i] == 0 ) i = 1; + if ( m_shortcuts[++i] == nullptr ) i = 1; break; } } - if ( i == 20 || m_shortcuts[i] == 0 ) + if ( i == 20 || m_shortcuts[i] == nullptr ) { m_main->SelectHuman(); } @@ -325,13 +311,13 @@ CObject* CMainShort::DetectShort(Math::Point pos) for ( i=0 ; i<20 ; i++ ) { - if ( m_shortcuts[i] == 0 ) continue; + if ( m_shortcuts[i] == nullptr ) continue; pc = m_interface->SearchControl(table_sc_em[i]); if ( pc != 0 ) { - cpos = pc->RetPos(); - cdim = pc->RetDim(); + cpos = pc->GetPos(); + cdim = pc->GetDim(); if ( pos.x >= cpos.x && pos.x <= cpos.x+cdim.x && @@ -347,17 +333,17 @@ CObject* CMainShort::DetectShort(Math::Point pos) // Reports the object with the mouse hovers over. -void CMainShort::SetHilite(CObject* pObj) +void CMainShort::SetHighlight(CObject* pObj) { CControl* pc; int i; for ( i=0 ; i<20 ; i++ ) { - if ( m_shortcuts[i] == 0 ) continue; + if ( m_shortcuts[i] == nullptr ) continue; pc = m_interface->SearchControl(table_sc_em[i]); - if ( pc == 0 ) continue; + if ( pc == nullptr ) continue; if ( m_shortcuts[i] == pObj ) { @@ -372,3 +358,5 @@ void CMainShort::SetHilite(CObject* pObj) } } +} + diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h index f260f0e..e97bdcc 100644 --- a/src/ui/mainshort.h +++ b/src/ui/mainshort.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,45 +19,41 @@ #pragma once - +#include "ui/interface.h" #include "common/event.h" #include "math/point.h" +#include "object/object.h" +#include "graphics/engine/engine.h" - -class CInstanceManager; -class CD3DEngine; -class CInterface; -class CRobotMain; -class CObject; - +namespace Ui { class CMainShort { -public: - CMainShort(CInstanceManager* iMan); - ~CMainShort(); - - void SetMode(bool bBuilding); - void FlushShortcuts(); - bool CreateShortcuts(); - bool UpdateShortcuts(); - void SelectShortcut(EventMsg event); - void SelectNext(); - CObject* DetectShort(Math::Point pos); - void SetHilite(CObject* pObj); - -protected: - -protected: - CInstanceManager* m_iMan; - CEvent* m_event; - CD3DEngine* m_engine; - CInterface* m_interface; - CRobotMain* m_main; - - CObject* m_shortcuts[20]; - bool m_bBuilding; + public: + CMainShort(); + ~CMainShort(); + + void SetMode(bool bBuilding); + void FlushShortcuts(); + bool CreateShortcuts(); + bool UpdateShortcuts(); + void SelectShortcut(EventType event); + void SelectNext(); + CObject* DetectShort(Math::Point pos); + void SetHighlight(CObject* pObj); + + protected: + + protected: + CInstanceManager* m_iMan; + CEvent* m_event; + Gfx::CEngine* m_engine; + CInterface* m_interface; + CRobotMain* m_main; + + CObject* m_shortcuts[20]; + bool m_bBuilding; }; - +} diff --git a/src/ui/map.cpp b/src/ui/map.cpp index a74e557..3a3d30f 100644 --- a/src/ui/map.cpp +++ b/src/ui/map.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,34 +18,20 @@ // map.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#include "common/struct.h" -#include "math/geometry.h" -#include "old/d3dengine.h" -#include "common/event.h" -#include "old/math3d.h" -#include "old/terrain.h" -#include "old/water.h" -#include "object/object.h" -#include "common/event.h" -#include "common/misc.h" -#include "object/robotmain.h" -#include "common/iman.h" #include "ui/map.h" +#include <string.h> +namespace Ui { // Object's constructor. -CMap::CMap(CInstanceManager* iMan) : CControl(iMan) +CMap::CMap() : CControl() { - m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); - m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN); - m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER); + 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_bEnable = true; m_time = 0.0f; @@ -61,9 +48,9 @@ CMap::CMap(CInstanceManager* iMan) : CControl(iMan) m_waterColor.g = 0.80f; m_waterColor.b = 1.00f; // blue - m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f; + m_half = m_terrain->GetMosaicCount() * m_terrain->GetBrickCount() * m_terrain->GetBrickSize() / 2.0f; - m_hiliteRank = -1; + m_highlightRank = -1; FlushObject(); m_fixImage[0] = 0; @@ -81,9 +68,10 @@ CMap::~CMap() // Creates a new button. -bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if (eventMsg == EVENT_NULL) + eventMsg = GetUniqueEventType(); CControl::Create(pos, dim, icon, eventMsg); return true; @@ -96,7 +84,7 @@ void CMap::SetOffset(float ox, float oy) { m_offset.x = ox; m_offset.y = oy; - m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f; + m_half = m_terrain->GetMosaicCount() * m_terrain->GetBrickCount() * m_terrain->GetBrickSize() / 2.0f; } // Choice of the global angle of rotation. @@ -131,10 +119,10 @@ void CMap::SetDebug(bool bDebug) void CMap::SetZoom(float value) { m_zoom = value; - m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f; + m_half = m_terrain->GetMosaicCount() * m_terrain->GetBrickCount() * m_terrain->GetBrickSize() / 2.0f; } -float CMap::RetZoom() +float CMap::GetZoom() { return m_zoom; } @@ -149,7 +137,7 @@ void CMap::SetEnable(bool bEnable) SetState(STATE_DEAD, !bEnable); } -bool CMap::RetEnable() +bool CMap::GetEnable() { return m_bEnable; } @@ -157,14 +145,14 @@ bool CMap::RetEnable() // Choosing the color of the soil. -void CMap::SetFloorColor(D3DCOLORVALUE color) +void CMap::SetFloorColor(Gfx::Color color) { m_floorColor = color; } // Choosing the color of the water. -void CMap::SetWaterColor(D3DCOLORVALUE color) +void CMap::SetWaterColor(Gfx::Color color) { m_waterColor = color; } @@ -172,14 +160,14 @@ void CMap::SetWaterColor(D3DCOLORVALUE color) // Specifies a fixed image in place of the drawing of the relief. -void CMap::SetFixImage(char *filename) +void CMap::SetFixImage(const char *filename) { strcpy(m_fixImage, filename); } // Whether to use a still image. -bool CMap::RetFixImage() +bool CMap::GetFixImage() { return (m_fixImage[0] != 0); } @@ -189,31 +177,25 @@ bool CMap::RetFixImage() bool CMap::EventProcess(const Event &event) { - bool bInMap; + bool bInMap; - if ( (m_state & STATE_VISIBLE) == 0 ) return true; + if ( (m_state & STATE_VISIBLE) == 0 ) + return true; CControl::EventProcess(event); - if ( event.event == EVENT_FRAME ) - { + if ( event.type == EVENT_FRAME ) m_time += event.rTime; - } - if ( event.event == EVENT_MOUSEMOVE && Detect(event.pos) ) - { - m_engine->SetMouseType(D3DMOUSENORM); - if ( DetectObject(event.pos, bInMap) != 0 ) - { - m_engine->SetMouseType(D3DMOUSEHAND); - } + if ( event.type == EVENT_MOUSE_MOVE && Detect(event.pos) ) { + m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); + if ( DetectObject(event.mouseMove.pos, bInMap) != 0 ) + m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); } - if ( event.event == EVENT_LBUTTONDOWN ) - { - if ( CControl::Detect(event.pos) ) - { - SelectObject(event.pos); + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 ) { + if ( CControl::Detect(event.mouseButton.pos) ) { + SelectObject(event.mouseButton.pos); return false; } } @@ -227,7 +209,7 @@ Math::Point CMap::AdjustOffset(Math::Point offset) { float limit; - limit = m_half - m_half/m_zoom; + limit = m_half - m_half / m_zoom; if ( offset.x < -limit ) offset.x = -limit; if ( offset.x > limit ) offset.x = limit; if ( offset.y < -limit ) offset.y = -limit; @@ -238,21 +220,20 @@ Math::Point CMap::AdjustOffset(Math::Point offset) // Indicates the object with the mouse hovers over. -void CMap::SetHilite(CObject* pObj) +void CMap::SetHighlight(CObject* pObj) { - int i; - - m_hiliteRank = -1; - if ( m_bToy || m_fixImage[0] != 0 ) return; // card with still image? - if ( pObj == 0 ) return; + m_highlightRank = -1; + if ( m_bToy || m_fixImage[0] != 0 ) + return; // card with still image? + if ( pObj == nullptr ) + return; - for ( i=0 ; i<MAPMAXOBJECT ; i++ ) - { - if ( !m_map[i].bUsed ) continue; + for (int i = 0; i < MAPMAXOBJECT; i++) { + if ( !m_map[i].bUsed ) + continue; - if ( m_map[i].object == pObj ) - { - m_hiliteRank = i; + if ( m_map[i].object == pObj ) { + m_highlightRank = i; break; } } @@ -262,39 +243,43 @@ void CMap::SetHilite(CObject* pObj) CObject* CMap::DetectObject(Math::Point pos, bool &bInMap) { - float dist, min; - int i, best; + float dist, min; + int best; bInMap = false; - if ( pos.x < m_pos.x || - pos.y < m_pos.y || - pos.x > m_pos.x+m_dim.x || - pos.y > m_pos.y+m_dim.y ) return 0; + if ( pos.x < m_pos.x || + pos.y < m_pos.y || + pos.x > m_pos.x + m_dim.x || + pos.y > m_pos.y + m_dim.y ) + return 0; bInMap = true; - pos.x = (pos.x-m_pos.x)/m_dim.x*256.0f; - pos.y = (pos.y-m_pos.y)/m_dim.y*256.0f; // 0..256 - pos.x = (pos.x-128.0f)*m_half/(m_zoom*128.0f)+m_offset.x; - pos.y = (pos.y-128.0f)*m_half/(m_zoom*128.0f)+m_offset.y; + pos.x = (pos.x - m_pos.x) / m_dim.x * 256.0f; + pos.y = (pos.y - m_pos.y) / m_dim.y * 256.0f; // 0..256 + pos.x = (pos.x - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.x; + pos.y = (pos.y - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.y; min = 10000.0f; best = -1; - for ( i=MAPMAXOBJECT-1 ; i>=0 ; i-- ) - { - if ( !m_map[i].bUsed ) continue; - if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar ) continue; - if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar ) continue; - - dist = Math::Point(m_map[i].pos.x-pos.x, m_map[i].pos.y-pos.y).Length(); - if ( dist > m_half/m_zoom*8.0f/100.0f ) continue; // too far? - if ( dist < min ) - { + for (int i = MAPMAXOBJECT - 1; i >= 0; i--) { + if ( !m_map[i].bUsed ) + continue; + if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar ) + continue; + if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar ) + continue; + + dist = Math::Point(m_map[i].pos.x - pos.x, m_map[i].pos.y - pos.y).Length(); + if ( dist > m_half / m_zoom * 8.0f / 100.0f ) + continue; // too far? + if ( dist < min ) { min = dist; best = i; } } - if ( best == -1 ) return 0; + if ( best == -1 ) + return 0; return m_map[best].object; } @@ -302,14 +287,12 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap) void CMap::SelectObject(Math::Point pos) { - CObject *pObj; - bool bInMap; + CObject *pObj; + bool bInMap; pObj = DetectObject(pos, bInMap); if ( pObj != 0 ) - { m_main->SelectObject(pObj); - } } @@ -318,34 +301,31 @@ void CMap::SelectObject(Math::Point pos) void CMap::Draw() { Math::Point uv1, uv2; - int i; + int i; - if ( (m_state & STATE_VISIBLE) == 0 ) return; + if ( (m_state & STATE_VISIBLE) == 0 ) + return; CControl::Draw(); // draws the bottom (button) - if ( !m_bEnable ) return; + if ( !m_bEnable ) + return; - if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT-1].bUsed ) - { - m_offset = AdjustOffset(m_map[MAPMAXOBJECT-1].pos); - } + if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT - 1].bUsed ) + m_offset = AdjustOffset(m_map[MAPMAXOBJECT - 1].pos); - if ( m_fixImage[0] == 0 ) // drawing of the relief? - { - m_engine->SetTexture("map.tga"); - m_engine->SetState(D3DSTATENORMAL); - uv1.x = 0.5f+(m_offset.x-(m_half/m_zoom))/(m_half*2.0f); - uv1.y = 0.5f-(m_offset.y+(m_half/m_zoom))/(m_half*2.0f); - uv2.x = 0.5f+(m_offset.x+(m_half/m_zoom))/(m_half*2.0f); - uv2.y = 0.5f-(m_offset.y-(m_half/m_zoom))/(m_half*2.0f); + if ( m_fixImage[0] == 0 ) { // drawing of the relief? + m_engine->SetTexture("map.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); + uv1.x = 0.5f + (m_offset.x - (m_half / m_zoom)) / (m_half * 2.0f); + uv1.y = 0.5f - (m_offset.y + (m_half / m_zoom)) / (m_half * 2.0f); + uv2.x = 0.5f + (m_offset.x + (m_half / m_zoom)) / (m_half * 2.0f); + uv2.y = 0.5f - (m_offset.y - (m_half / m_zoom)) / (m_half * 2.0f); DrawVertex(uv1, uv2, 0.97f); // drawing the map - } - else // still image? - { + } else { // still image? m_engine->LoadTexture(m_fixImage); m_engine->SetTexture(m_fixImage); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 0.0f; uv1.y = 0.0f; uv2.x = 1.0f; @@ -355,33 +335,28 @@ void CMap::Draw() i = MAPMAXOBJECT-1; if ( m_map[i].bUsed ) // selection: - { DrawFocus(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color); - } - for ( i=0 ; i<m_totalFix ; i++ ) // fixed objects: - { - if ( i == m_hiliteRank ) continue; + for ( i=0 ; i<m_totalFix ; i++ ) { // fixed objects: + if ( i == m_highlightRank ) + continue; DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false); } - for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) // moving objects: - { - if ( i == m_hiliteRank ) continue; + for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) { // moving objects: + if ( i == m_highlightRank ) + continue; DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false); } i = MAPMAXOBJECT-1; - if ( m_map[i].bUsed && i != m_hiliteRank ) // selection: - { + if ( m_map[i].bUsed && i != m_highlightRank ) // selection: DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, true, false); - } - if ( m_hiliteRank != -1 && m_map[m_hiliteRank].bUsed ) - { - i = m_hiliteRank; + if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) { + i = m_highlightRank; DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, true); - DrawHilite(m_map[i].pos); + DrawHighlight(m_map[i].pos); } } @@ -392,35 +367,32 @@ Math::Point CMap::MapInter(Math::Point pos, float dir) Math::Point p1; float limit; - p1.x = pos.x+1.0f; + p1.x = pos.x + 1.0f; p1.y = pos.y; p1 = Math::RotatePoint(pos, dir, p1); p1.x -= pos.x; p1.y -= pos.y; - limit = m_mapPos.x+m_mapDim.x-pos.x; - if ( p1.x > limit ) // exceeds the right? - { + limit = m_mapPos.x + m_mapDim.x - pos.x; + if ( p1.x > limit ) { // exceeds the right? p1.y = limit*p1.y/p1.x; p1.x = limit; } - limit = m_mapPos.y*0.75f+m_mapDim.y*0.75f-pos.y; - if ( p1.y > limit ) // exceeds the top? - { - p1.x = limit*p1.x/p1.y; + limit = m_mapPos.y * 0.75f + m_mapDim.y * 0.75f - pos.y; + if ( p1.y > limit ) { // exceeds the top? + p1.x = limit * p1.x / p1.y; p1.y = limit; } - limit = m_mapPos.x-pos.x; - if ( p1.x < limit ) // exceeds the left? - { - p1.y = limit*p1.y/p1.x; + limit = m_mapPos.x - pos.x; + if ( p1.x < limit ) { // exceeds the left? + p1.y = limit * p1.y / p1.x; p1.x = limit; } - limit = m_mapPos.y*0.75f-pos.y; - if ( p1.y < limit ) // exceeds the bottom? - { - p1.x = limit*p1.x/p1.y; + + limit = m_mapPos.y * 0.75f - pos.y; + if ( p1.y < limit ) { // exceeds the bottom? + p1.x = limit * p1.x / p1.y; p1.y = limit; } @@ -454,7 +426,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color pos.x = m_mapPos.x+m_mapDim.x*pos.x; pos.y = m_mapPos.y*0.75f+m_mapDim.y*pos.y*0.75f; - focus = m_engine->RetFocus(); + focus = m_engine->GetFocus(); dir += Math::PI/2.0f; aMin = Math::NormAngle(dir-Math::PI/4.0f*focus); aMax = Math::NormAngle(dir+Math::PI/4.0f*focus); @@ -483,8 +455,8 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color uv2.x = 126.0f/256.0f; uv2.y = 255.0f/256.0f; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); bEnding = false; do @@ -492,7 +464,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color quart ++; aOct = limit[quart%4]; if ( quart >= 4 ) aOct += Math::PI*2.0f; - if ( aOct >= aMax-Math::VERY_SMALL ) + if ( aOct >= aMax - Math::VERY_SMALL_NUM ) { aOct = aMax; bEnding = true; @@ -543,8 +515,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo return; // flashes } - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); if ( bUp ) { uv1.x = 160.5f/256.0f; // yellow triangle ^ @@ -686,8 +658,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo { if ( bSelect ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); if ( m_bToy ) { uv1.x = 164.5f/256.0f; // black pentagon @@ -712,8 +684,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo { if ( m_bRadar ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = 64.5f/256.0f; // blue triangle uv1.y = 240.5f/256.0f; uv2.x = 79.0f/256.0f; @@ -732,8 +704,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo if ( color == MAPCOLOR_WAYPOINTb ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 192.5f/256.0f; // blue cross uv1.y = 240.5f/256.0f; uv2.x = 207.0f/256.0f; @@ -742,8 +714,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo } if ( color == MAPCOLOR_WAYPOINTr ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 208.5f/256.0f; // red cross uv1.y = 240.5f/256.0f; uv2.x = 223.0f/256.0f; @@ -752,8 +724,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo } if ( color == MAPCOLOR_WAYPOINTg ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 224.5f/256.0f; // green cross uv1.y = 240.5f/256.0f; uv2.x = 239.0f/256.0f; @@ -762,8 +734,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo } if ( color == MAPCOLOR_WAYPOINTy ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 240.5f/256.0f; // yellow cross uv1.y = 240.5f/256.0f; uv2.x = 255.0f/256.0f; @@ -772,8 +744,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo } if ( color == MAPCOLOR_WAYPOINTv ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 192.5f/256.0f; // violet cross uv1.y = 224.5f/256.0f; uv2.x = 207.0f/256.0f; @@ -793,8 +765,8 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, dp = 0.5f/256.0f; - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); if ( color == MAPCOLOR_MOVE ) { uv1.x = 160.0f/256.0f; // blue @@ -877,7 +849,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, if ( type == OBJECT_TEEN34 ) icon = 48; // stone if ( icon == -1 ) return; - m_engine->SetState(D3DSTATETTw); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = (32.0f/256.0f)*(icon%8); uv1.y = (32.0f/256.0f)*(icon/8); uv2.x = uv1.x+32.0f/256.0f; @@ -892,22 +864,15 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, // Draw the object with the mouse hovers over. -void CMap::DrawHilite(Math::Point pos) +void CMap::DrawHighlight(Math::Point pos) { - Math::Point dim, uv1, uv2; - bool bOut, bUp, bDown, bLeft, bRight; + Math::Point dim, uv1, uv2; if ( m_bToy || m_fixImage[0] != 0 ) return; // map with still image? pos.x = (pos.x-m_offset.x)*(m_zoom*0.5f)/m_half+0.5f; pos.y = (pos.y-m_offset.y)*(m_zoom*0.5f)/m_half+0.5f; - bOut = bUp = bDown = bLeft = bRight = false; - if ( pos.x < 0.06f ) { pos.x = 0.02f; bOut = bLeft = true; } - if ( pos.y < 0.06f ) { pos.y = 0.02f; bOut = bDown = true; } - if ( pos.x > 0.94f ) { pos.x = 0.98f; bOut = bRight = true; } - if ( pos.y > 0.94f ) { pos.y = 0.98f; bOut = bUp = true; } - pos.x = m_mapPos.x+m_mapDim.x*pos.x; pos.y = m_mapPos.y+m_mapDim.y*pos.y; dim.x = 2.0f/128.0f*0.75f; @@ -915,8 +880,8 @@ void CMap::DrawHilite(Math::Point pos) dim.x *= 2.0f+cosf(m_time*8.0f)*0.5f; dim.y *= 2.0f+cosf(m_time*8.0f)*0.5f; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 160.5f/256.0f; // hilite uv1.y = 224.5f/256.0f; uv2.x = 175.0f/256.0f; @@ -930,19 +895,19 @@ void CMap::DrawHilite(Math::Point pos) void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2) { - LPDIRECT3DDEVICE7 device; - D3DVERTEX2 vertex[3]; // 1 triangle + Gfx::CDevice* device; + Gfx::VertexTex2 vertex[3]; // 1 triangle Math::Vector n; - device = m_engine->RetD3DDevice(); + device = m_engine->GetDevice(); n = Math::Vector(0.0f, 0.0f, -1.0f); // normal - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y); - vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y); - vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y); + vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y)); + vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y)); + vertex[2] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y)); - device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3); m_engine->AddStatisticTriangle(1); } @@ -950,28 +915,28 @@ void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Po void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2) { - LPDIRECT3DDEVICE7 device; - D3DVERTEX2 vertex[5]; // 1 pentagon + Gfx::CDevice* device; + Gfx::VertexTex2 vertex[5]; // 1 pentagon Math::Vector n; - device = m_engine->RetD3DDevice(); + device = m_engine->GetDevice(); n = Math::Vector(0.0f, 0.0f, -1.0f); // normal #if 1 - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y); - vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y); - vertex[2] = D3DVERTEX2(Math::Vector(p5.x, p5.y, 0.0f), n, uv2.x,uv2.y); - vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y); - vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y); + vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y)); + vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y)); + vertex[2] = Gfx::VertexTex2(Math::Vector(p5.x, p5.y, 0.0f), n, Math::Point(uv2.x,uv2.y)); + vertex[3] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y)); + vertex[4] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y)); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 5, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 5); #else - vertex[0] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv1.y); - vertex[1] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x,uv2.y); - vertex[2] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y); + vertex[0] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y)); + vertex[1] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x,uv2.y)); + vertex[2] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y)); - device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3); #endif m_engine->AddStatisticTriangle(3); } @@ -980,12 +945,12 @@ void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom) { - LPDIRECT3DDEVICE7 device; - D3DVERTEX2 vertex[4]; // 2 triangles + Gfx::CDevice* device; + Gfx::VertexTex2 vertex[4]; // 2 triangles Math::Point p1, p2, c; Math::Vector n; - device = m_engine->RetD3DDevice(); + device = m_engine->GetDevice(); p1.x = m_pos.x; p1.y = m_pos.y; @@ -1007,12 +972,12 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom) n = Math::Vector(0.0f, 0.0f, -1.0f); // normal - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y); - vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y); - vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y); + vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv2.y)); + vertex[1] = Gfx::VertexTex2(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y)); + vertex[2] = Gfx::VertexTex2(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x,uv2.y)); + vertex[3] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x,uv1.y)); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); m_engine->AddStatisticTriangle(2); } @@ -1021,30 +986,34 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom) void CMap::UpdateTerrain() { - D3DCOLORVALUE color; + Gfx::Color color; Math::Vector pos; float scale, water, level, intensity; int x, y; if ( m_fixImage[0] != 0 ) return; // still image? - if ( !m_engine->OpenImage("map.tga") ) return; - scale = m_terrain->RetScaleRelief(); - water = m_water->RetLevel(); + // TODO: map texture manipulation + return; + + // if ( !m_engine->OpenImage("map.png") ) return; + + scale = m_terrain->GetReliefScale(); + water = m_water->GetLevel(); color.a = 0.0f; for ( y=0 ; y<256 ; y++ ) { for ( x=0 ; x<256 ; x++ ) { - pos.x = ((float)x-128.0f)*m_half/128.0f; - pos.z = -((float)y-128.0f)*m_half/128.0f; + pos.x = (static_cast<float>(x)-128.0f)*m_half/128.0f; + pos.z = -(static_cast<float>(y)-128.0f)*m_half/128.0f; pos.y = 0.0f; if ( pos.x >= -m_half && pos.x <= m_half && pos.z >= -m_half && pos.z <= m_half ) { - level = m_terrain->RetFloorLevel(pos, true)/scale; + level = m_terrain->GetFloorLevel(pos, true)/scale; } else { @@ -1068,43 +1037,47 @@ void CMap::UpdateTerrain() color.b = m_waterColor.b + (intensity-0.5f); } - m_engine->SetDot(x, y, color); + //m_engine->SetDot(x, y, color); } } - m_engine->CopyImage(); // copy the ground drawing - m_engine->CloseImage(); + //m_engine->CopyImage(); // copy the ground drawing + //m_engine->CloseImage(); } // Updates the field in the map. void CMap::UpdateTerrain(int bx, int by, int ex, int ey) { - D3DCOLORVALUE color; + Gfx::Color color; Math::Vector pos; float scale, water, level, intensity; int x, y; if ( m_fixImage[0] != 0 ) return; // still image? - if ( !m_engine->OpenImage("map.tga") ) return; - m_engine->LoadImage(); - scale = m_terrain->RetScaleRelief(); - water = m_water->RetLevel(); + // TODO: map texture manipulation + return; + + //if ( !m_engine->OpenImage("map.png") ) return; + //m_engine->LoadImage(); + + scale = m_terrain->GetReliefScale(); + water = m_water->GetLevel(); color.a = 0.0f; for ( y=by ; y<ey ; y++ ) { for ( x=bx ; x<ex ; x++ ) { - pos.x = ((float)x-128.0f)*m_half/128.0f; - pos.z = -((float)y-128.0f)*m_half/128.0f; + pos.x = (static_cast<float>(x)-128.0f)*m_half/128.0f; + pos.z = -(static_cast<float>(y)-128.0f)*m_half/128.0f; pos.y = 0.0f; if ( pos.x >= -m_half && pos.x <= m_half && pos.z >= -m_half && pos.z <= m_half ) { - level = m_terrain->RetFloorLevel(pos, true)/scale; + level = m_terrain->GetFloorLevel(pos, true)/scale; } else { @@ -1128,12 +1101,12 @@ void CMap::UpdateTerrain(int bx, int by, int ex, int ey) color.b = m_waterColor.b + (intensity-0.5f); } - m_engine->SetDot(x, y, color); + //m_engine->SetDot(x, y, color); } } - m_engine->CopyImage(); // copy the ground drawing - m_engine->CloseImage(); + //m_engine->CopyImage(); // copy the ground drawing + //m_engine->CloseImage(); } @@ -1145,7 +1118,7 @@ void CMap::FlushObject() m_totalFix = 0; // object index fixed m_totalMove = MAPMAXOBJECT-2; // moving vehicles index - m_bRadar = m_main->RetCheatRadar(); // no radar + //m_bRadar = m_main->GetCheatRadar(); // no radar for ( i=0 ; i<MAPMAXOBJECT ; i++ ) { @@ -1166,14 +1139,14 @@ void CMap::UpdateObject(CObject* pObj) if ( !m_bEnable ) return; if ( m_totalFix >= m_totalMove ) return; // full table? - if ( !pObj->RetActif() ) return; - if ( !pObj->RetSelectable() ) return; - if ( pObj->RetProxyActivate() ) return; - if ( pObj->RetTruck() != 0 ) return; + if ( !pObj->GetActif() ) return; + if ( !pObj->GetSelectable() ) return; + if ( pObj->GetProxyActivate() ) return; + if ( pObj->GetTruck() != 0 ) return; - type = pObj->RetType(); - pos = pObj->RetPosition(0); - dir = -(pObj->RetAngleY(0)+Math::PI/2.0f); + type = pObj->GetType(); + pos = pObj->GetPosition(0); + dir = -(pObj->GetAngleY(0)+Math::PI/2.0f); if ( m_angle != 0.0f ) { @@ -1299,7 +1272,7 @@ void CMap::UpdateObject(CObject* pObj) color != MAPCOLOR_MOVE ) return; } - if ( pObj->RetSelect() ) + if ( pObj->GetSelect() ) { m_map[MAPMAXOBJECT-1].type = type; m_map[MAPMAXOBJECT-1].object = pObj; @@ -1337,3 +1310,4 @@ void CMap::UpdateObject(CObject* pObj) } } +} diff --git a/src/ui/map.h b/src/ui/map.h index efdf54b..9e1767c 100644 --- a/src/ui/map.h +++ b/src/ui/map.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 @@ -20,15 +21,23 @@ #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" +#include "graphics/engine/engine.h" +#include "graphics/core/device.h" +#include "graphics/core/vertex.h" -class CD3DEngine; -class CTerrain; -class CWater; -class CRobotMain; +#include "math/geometry.h" +namespace Ui { const int MAPMAXOBJECT = 100; @@ -61,77 +70,78 @@ struct MapObject class CMap : public CControl { -public: - CMap(CInstanceManager* iMan); - ~CMap(); - - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); - bool EventProcess(const Event &event); - void Draw(); - - void UpdateTerrain(); - void UpdateTerrain(int bx, int by, int ex, int ey); - - void SetFixImage(char *filename); - bool RetFixImage(); - - void SetOffset(float ox, float oy); - void SetAngle(float angle); - void SetMode(int mode); - void SetToy(bool bToy); - void SetDebug(bool bDebug); - - void SetZoom(float value); - float RetZoom(); - - void SetEnable(bool bEnable); - bool RetEnable(); - - void SetFloorColor(D3DCOLORVALUE color); - void SetWaterColor(D3DCOLORVALUE color); - - void FlushObject(); - void UpdateObject(CObject* pObj); - - CObject* DetectObject(Math::Point pos, bool &bInMap); - void SetHilite(CObject* pObj); - -protected: - Math::Point AdjustOffset(Math::Point offset); - void SelectObject(Math::Point pos); - Math::Point MapInter(Math::Point pos, float dir); - void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color); - void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite); - void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite); - void DrawHilite(Math::Point pos); - void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2); - void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2); - void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom); - -protected: - CTerrain* m_terrain; - CWater* m_water; - CRobotMain* m_main; - - bool m_bEnable; - float m_time; - float m_half; - float m_zoom; - Math::Point m_offset; - float m_angle; - D3DCOLORVALUE m_floorColor; - D3DCOLORVALUE m_waterColor; - MapObject m_map[MAPMAXOBJECT]; - int m_totalFix; - int m_totalMove; - int m_hiliteRank; - Math::Point m_mapPos; - Math::Point m_mapDim; - bool m_bRadar; - char m_fixImage[100]; - int m_mode; - bool m_bToy; - bool m_bDebug; + public: + CMap(); + ~CMap(); + + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool EventProcess(const Event &event); + void Draw(); + + void UpdateTerrain(); + void UpdateTerrain(int bx, int by, int ex, int ey); + + void SetFixImage(const char *filename); + bool GetFixImage(); + + void SetOffset(float ox, float oy); + void SetAngle(float angle); + void SetMode(int mode); + void SetToy(bool bToy); + void SetDebug(bool bDebug); + + void SetZoom(float value); + float GetZoom(); + + void SetEnable(bool bEnable); + bool GetEnable(); + + void SetFloorColor(Gfx::Color color); + void SetWaterColor(Gfx::Color color); + + void FlushObject(); + void UpdateObject(CObject* pObj); + + CObject* DetectObject(Math::Point pos, bool &bInMap); + void SetHighlight(CObject* pObj); + + protected: + Math::Point AdjustOffset(Math::Point offset); + void SelectObject(Math::Point pos); + Math::Point MapInter(Math::Point pos, float dir); + void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color); + void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite); + void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite); + void DrawHighlight(Math::Point pos); + void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2); + void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2); + void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom); + + protected: + Gfx::CTerrain* m_terrain; + Gfx::CWater* m_water; + CRobotMain* m_main; + + bool m_bEnable; + float m_time; + float m_half; + float m_zoom; + Math::Point m_offset; + float m_angle; + Gfx::Color m_floorColor; + Gfx::Color m_waterColor; + MapObject m_map[MAPMAXOBJECT]; + int m_totalFix; + int m_totalMove; + int m_highlightRank; + Math::Point m_mapPos; + Math::Point m_mapDim; + bool m_bRadar; + char m_fixImage[100]; + int m_mode; + bool m_bToy; + bool m_bDebug; }; +} diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 051de8d..d3d0ed2 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.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 @@ -16,26 +17,21 @@ // scroll.cpp +#include "ui/scroll.h" -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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 "graphics/engine/engine.h" #include "ui/button.h" -#include "ui/scroll.h" +namespace Ui { // Object's constructor. -CScroll::CScroll(CInstanceManager* iMan) : CControl(iMan) +CScroll::CScroll() : CControl() { m_buttonUp = 0; m_buttonDown = 0; @@ -61,9 +57,9 @@ CScroll::~CScroll() // Creates a new button. -bool CScroll::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CScroll::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); CControl::Create(pos, dim, icon, eventMsg); MoveAdjust(); @@ -102,20 +98,20 @@ void CScroll::MoveAdjust() { if ( m_buttonUp == 0 ) { - m_buttonUp = new CButton(m_iMan); - pc = (CButton*)m_buttonUp; + m_buttonUp = new CButton(); + pc = m_buttonUp; pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL); pc->SetRepeat(true); - m_eventUp = pc->RetEventMsg(); + m_eventUp = pc->GetEventType(); } if ( m_buttonDown == 0 ) { - m_buttonDown = new CButton(m_iMan); - pc = (CButton*)m_buttonDown; + m_buttonDown = new CButton(); + pc = m_buttonDown; pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL); pc->SetRepeat(true); - m_eventDown = pc->RetEventMsg(); + m_eventDown = pc->GetEventType(); } } @@ -213,66 +209,67 @@ bool CScroll::EventProcess(const Event &event) if ( !m_buttonDown->EventProcess(event) ) return false; } - if ( event.event == m_eventUp && m_step > 0.0f ) + if ( event.type == m_eventUp && m_step > 0.0f ) { m_visibleValue -= m_step; if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f; AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } - if ( event.event == m_eventDown && m_step > 0.0f ) + if ( event.type == m_eventDown && m_step > 0.0f ) { m_visibleValue += m_step; if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f; AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } hButton = m_buttonUp?m_dim.x/0.75f:0.0f; - if ( event.event == EVENT_LBUTTONDOWN && + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1 && (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { pos.y = m_pos.y+hButton; dim.y = m_dim.y-hButton*2.0f; pos.y += dim.y*(1.0f-m_visibleRatio)*(1.0f-m_visibleValue); dim.y *= m_visibleRatio; - if ( event.pos.y < pos.y || - event.pos.y > pos.y+dim.y ) // click outside cabin? + if ( event.mouseButton.pos.y < pos.y || + event.mouseButton.pos.y > pos.y+dim.y ) // click outside cabin? { h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio); - value = 1.0f-(event.pos.y-(m_pos.y+hButton+dim.y*0.5f))/h; + value = 1.0f-(event.mouseButton.pos.y-(m_pos.y+hButton+dim.y*0.5f))/h; if ( value < 0.0f ) value = 0.0f; if ( value > 1.0f ) value = 1.0f; m_visibleValue = value; AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } m_bCapture = true; - m_pressPos = event.pos; + m_pressPos = event.mouseButton.pos; m_pressValue = m_visibleValue; } } - if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) + if ( event.type == EVENT_MOUSE_MOVE && m_bCapture ) { h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio); if ( h != 0 ) { - value = m_pressValue - (event.pos.y-m_pressPos.y)/h; + value = m_pressValue - (event.mouseMove.pos.y-m_pressPos.y)/h; if ( value < 0.0f ) value = 0.0f; if ( value > 1.0f ) value = 1.0f; @@ -282,33 +279,35 @@ bool CScroll::EventProcess(const Event &event) AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } } } - if ( event.event == EVENT_LBUTTONUP && m_bCapture ) + if ( event.type == EVENT_MOUSE_BUTTON_UP && + event.mouseButton.button == 1 && + m_bCapture ) { m_bCapture = false; } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELUP && - Detect(event.pos) && - m_buttonUp != 0 ) + if (event.type == EVENT_MOUSE_WHEEL && + event.mouseWheel.dir == WHEEL_UP && + Detect(event.mouseWheel.pos) && + m_buttonUp != 0) { Event newEvent = event; - newEvent.event = m_buttonUp->RetEventMsg(); + newEvent.type = m_buttonUp->GetEventType(); m_event->AddEvent(newEvent); } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELDOWN && - Detect(event.pos) && - m_buttonDown != 0 ) + if (event.type == EVENT_MOUSE_WHEEL && + event.mouseWheel.dir == WHEEL_DOWN && + Detect(event.mouseWheel.pos) && + m_buttonDown != 0) { Event newEvent = event; - newEvent.event = m_buttonDown->RetEventMsg(); + newEvent.type = m_buttonDown->GetEventType(); m_event->AddEvent(newEvent); } @@ -346,7 +345,7 @@ void CScroll::Draw() dim.y *= m_visibleRatio; DrawVertex(pos, dim, 2); - n = (int)(dim.y*0.8f/0.012f); + n = static_cast<int>(dim.y*0.8f/0.012f); if ( n < 1 ) n = 1; if ( n > 5 ) n = 5; @@ -380,8 +379,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) if ( icon == 0 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 0.0f/256.0f; // yellow rectangle uv1.y = 32.0f/256.0f; uv2.x = 32.0f/256.0f; @@ -390,8 +389,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 1 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 128.0f/256.0f; // gray rectangle uv1.y = 32.0f/256.0f; uv2.x = 160.0f/256.0f; @@ -400,8 +399,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 2 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 64.0f/256.0f; // blue rectangle uv1.y = 0.0f/256.0f; uv2.x = 96.0f/256.0f; @@ -410,8 +409,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 104.0f/256.0f; // blue line - uv1.y = 32.0f/256.0f; uv2.x = 128.0f/256.0f; @@ -437,7 +436,7 @@ void CScroll::SetVisibleValue(float value) AdjustGlint(); } -float CScroll::RetVisibleValue() +float CScroll::GetVisibleValue() { return m_visibleValue; } @@ -451,7 +450,7 @@ void CScroll::SetVisibleRatio(float value) AdjustGlint(); } -float CScroll::RetVisibleRatio() +float CScroll::GetVisibleRatio() { return m_visibleRatio; } @@ -462,8 +461,9 @@ void CScroll::SetArrowStep(float step) m_step = step; } -float CScroll::RetArrowStep() +float CScroll::GetArrowStep() { return m_step; } +} diff --git a/src/ui/scroll.h b/src/ui/scroll.h index 6854e61..52b60bc 100644 --- a/src/ui/scroll.h +++ b/src/ui/scroll.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 @@ -20,62 +21,63 @@ #include "ui/control.h" +#include "common/event.h" +namespace Ui { -class CD3DEngine; class CButton; - 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 GetVisibleValue(); - void SetVisibleRatio(float value); - float RetVisibleRatio(); + void SetVisibleRatio(float value); + float GetVisibleRatio(); - void SetArrowStep(float step); - float RetArrowStep(); + void SetArrowStep(float step); + float GetArrowStep(); -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.cpp b/src/ui/shortcut.cpp index fe9ca9b..c8d3890 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.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 @@ -16,25 +17,22 @@ // shortcut.cpp +#include "ui/shortcut.h" -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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/shortcut.h" - +#include "graphics/engine/engine.h" +#include "graphics/core/device.h" +#include <math.h> +namespace Ui { // Object's constructor. -CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan) +//CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan) +CShortcut::CShortcut() : CControl() { m_time = 0.0f; } @@ -48,11 +46,11 @@ CShortcut::~CShortcut() // Creates a new button. -bool CShortcut::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CShortcut::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); return true; } @@ -63,17 +61,18 @@ bool CShortcut::EventProcess(const Event &event) { CControl::EventProcess(event); - if ( event.event == EVENT_FRAME ) + if ( event.type == EVENT_FRAME ) { m_time += event.rTime; } - if ( event.event == EVENT_LBUTTONDOWN ) + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } @@ -92,24 +91,24 @@ void CShortcut::Draw() icon = 0; zoom = 0.8f; - mode = D3DSTATETTw; + mode = Gfx::ENG_RSTATE_TTEXTURE_WHITE; if ( m_state & STATE_HILIGHT ) { icon = 4; zoom = 0.9f; - mode = D3DSTATENORMAL; + mode = Gfx::ENG_RSTATE_NORMAL; } if ( m_state & STATE_CHECK ) { icon = 1; zoom = 0.8f; - mode = D3DSTATENORMAL; + mode = Gfx::ENG_RSTATE_NORMAL; } if ( m_state & STATE_PRESS ) { icon = 1; zoom = 1.0f; - mode = D3DSTATENORMAL; + mode = Gfx::ENG_RSTATE_NORMAL; } if ( m_icon == 6 || m_icon == 7 ) // pause or film? { @@ -117,7 +116,7 @@ void CShortcut::Draw() zoom = 1.0f; } - m_engine->SetTexture("button3.tga"); + m_engine->SetTexture("button3.png"); if ( icon != -1 ) { @@ -125,7 +124,7 @@ void CShortcut::Draw() DrawVertex(icon, 0.95f); } - m_engine->SetState(D3DSTATETTb); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); DrawVertex(m_icon, zoom); if ( m_state & STATE_FRAME ) @@ -133,8 +132,8 @@ void CShortcut::Draw() Math::Point p1, p2, c, uv1, uv2; float zoom, dp; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); zoom = 0.9f+sinf(m_time*8.0f)*0.1f; @@ -173,8 +172,8 @@ void CShortcut::Draw() Math::Point uv1, uv2; float dp; - m_engine->SetTexture("button3.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button3.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = 160.0f/256.0f; uv1.y = 0.0f/256.0f; @@ -195,13 +194,13 @@ void CShortcut::Draw() void CShortcut::DrawVertex(int icon, float zoom) { - LPDIRECT3DDEVICE7 device; - D3DVERTEX2 vertex[4]; // 2 triangles + Gfx::CDevice* device; + Gfx::Vertex vertex[4]; // 2 triangles Math::Point p1, p2, c; Math::Vector n; float u1, u2, v1, v2, dp; - device = m_engine->RetD3DDevice(); + device = m_engine->GetDevice(); p1.x = m_pos.x; p1.y = m_pos.y; @@ -230,12 +229,13 @@ void CShortcut::DrawVertex(int icon, float zoom) n = Math::Vector(0.0f, 0.0f, -1.0f); // normal - vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, u1,v2); - vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, u1,v1); - vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, u2,v2); - vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, u2,v1); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(u1, v2)); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(u1, v1)); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(u2, v2)); + vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1)); - device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); m_engine->AddStatisticTriangle(2); } +} diff --git a/src/ui/shortcut.h b/src/ui/shortcut.h index b918ccc..7e7899e 100644 --- a/src/ui/shortcut.h +++ b/src/ui/shortcut.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,31 +19,30 @@ #pragma once - #include "ui/control.h" +#include "common/event.h" -class CD3DEngine; - - +namespace Ui { 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 eventType); - 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.cpp b/src/ui/slider.cpp index be8af18..70dd2cc 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.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 @@ -16,22 +17,19 @@ // slider.cpp +#include "ui/slider.h" -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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 "graphics/engine/engine.h" +#include "graphics/engine/text.h" #include "ui/button.h" -#include "ui/slider.h" + +#include <stdio.h> +namespace Ui { const float CURSOR_WIDTH = (10.0f/640.0f); const float HOLE_WIDTH = (5.0f/480.0f); @@ -41,7 +39,7 @@ const float HOLE_WIDTH = (5.0f/480.0f); // Object's constructor. -CSlider::CSlider(CInstanceManager* iMan) : CControl(iMan) +CSlider::CSlider() : CControl() { m_buttonLeft = 0; m_buttonRight = 0; @@ -71,10 +69,10 @@ CSlider::~CSlider() // Creates a new button. -bool CSlider::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CSlider::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - CControl::Create(pos, dim, icon, eventMsg); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); + CControl::Create(pos, dim, icon, eventType); MoveAdjust(); return true; @@ -115,20 +113,20 @@ void CSlider::MoveAdjust() #if 1 if ( m_buttonLeft == 0 ) { - m_buttonLeft = new CButton(m_iMan); + m_buttonLeft = new CButton(); m_buttonLeft->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?55:49, EVENT_NULL); // </^ m_buttonLeft->SetRepeat(true); if ( m_state & STATE_SHADOW ) m_buttonLeft->SetState(STATE_SHADOW); - m_eventUp = m_buttonLeft->RetEventMsg(); + m_eventUp = m_buttonLeft->GetEventType(); } if ( m_buttonRight == 0 ) { - m_buttonRight = new CButton(m_iMan); + m_buttonRight = new CButton(); m_buttonRight->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?48:50, EVENT_NULL); // >/v m_buttonRight->SetRepeat(true); if ( m_state & STATE_SHADOW ) m_buttonRight->SetState(STATE_SHADOW); - m_eventDown = m_buttonRight->RetEventMsg(); + m_eventDown = m_buttonRight->GetEventType(); } m_marginButton = m_bHoriz?(m_dim.y*0.75f):(m_dim.x/0.75f); @@ -261,7 +259,7 @@ bool CSlider::EventProcess(const Event &event) if ( !m_buttonRight->EventProcess(event) ) return false; } - if ( event.event == m_eventUp && m_step > 0.0f ) + if ( event.type == m_eventUp && m_step > 0.0f ) { m_visibleValue -= m_bHoriz?m_step:-m_step; if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f; @@ -269,11 +267,11 @@ bool CSlider::EventProcess(const Event &event) AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } - if ( event.event == m_eventDown && m_step > 0.0f ) + if ( event.type == m_eventDown && m_step > 0.0f ) { m_visibleValue += m_bHoriz?m_step:-m_step; if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f; @@ -281,28 +279,29 @@ bool CSlider::EventProcess(const Event &event) AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } - if ( event.event == EVENT_LBUTTONDOWN && - (m_state & STATE_VISIBLE) && + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + (event.mouseButton.button == 1 ) && + (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { if ( m_bHoriz ) { pos.x = m_pos.x+m_marginButton; dim.x = m_dim.x-m_marginButton*2.0f; - value = (event.pos.x-pos.x-CURSOR_WIDTH/2.0f); + value = (event.mouseButton.pos.x-pos.x-CURSOR_WIDTH/2.0f); value /= (dim.x-CURSOR_WIDTH); } else { pos.y = m_pos.y+m_marginButton; dim.y = m_dim.y-m_marginButton*2.0f; - value = (event.pos.y-pos.y-CURSOR_WIDTH/2.0f); + value = (event.mouseButton.pos.y-pos.y-CURSOR_WIDTH/2.0f); value /= (dim.y-CURSOR_WIDTH); } if ( value < 0.0f ) value = 0.0f; @@ -311,29 +310,29 @@ bool CSlider::EventProcess(const Event &event) AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); m_bCapture = true; - m_pressPos = event.pos; + m_pressPos = event.mouseButton.pos; m_pressValue = m_visibleValue; } } - if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) + if ( event.type == EVENT_MOUSE_MOVE && m_bCapture ) { if ( m_bHoriz ) { pos.x = m_pos.x+m_marginButton; dim.x = m_dim.x-m_marginButton*2.0f; - value = (event.pos.x-pos.x-CURSOR_WIDTH/2.0f); + value = (event.mouseMove.pos.x-pos.x-CURSOR_WIDTH/2.0f); value /= (dim.x-CURSOR_WIDTH); } else { pos.y = m_pos.y+m_marginButton; dim.y = m_dim.y-m_marginButton*2.0f; - value = (event.pos.y-pos.y-CURSOR_WIDTH/2.0f); + value = (event.mouseMove.pos.y-pos.y-CURSOR_WIDTH/2.0f); value /= (dim.y-CURSOR_WIDTH); } if ( value < 0.0f ) value = 0.0f; @@ -345,32 +344,35 @@ bool CSlider::EventProcess(const Event &event) AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } } - if ( event.event == EVENT_LBUTTONUP && m_bCapture ) + if ( ( event.type == EVENT_MOUSE_BUTTON_UP ) && + ( event.mouseButton.button == 1 ) && + m_bCapture ) { m_bCapture = false; } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELUP && - Detect(event.pos) && - m_buttonLeft != 0 ) + if (event.type == EVENT_MOUSE_WHEEL && + event.mouseWheel.dir == WHEEL_UP && + Detect(event.mouseWheel.pos) && + m_buttonLeft != 0) { Event newEvent = event; - newEvent.event = m_buttonLeft->RetEventMsg(); + newEvent.type = m_buttonLeft->GetEventType(); m_event->AddEvent(newEvent); } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELDOWN && - Detect(event.pos) && - m_buttonRight != 0 ) + + if (event.type == EVENT_MOUSE_WHEEL && + event.mouseButton.button == WHEEL_DOWN && + Detect(event.mouseWheel.pos) && + m_buttonRight != 0) { Event newEvent = event; - newEvent.event = m_buttonRight->RetEventMsg(); + newEvent.type = m_buttonRight->GetEventType(); m_event->AddEvent(newEvent); } @@ -465,11 +467,11 @@ void CSlider::Draw() if ( m_bHoriz ) { - sprintf(text, "%d", (int)(m_min+m_visibleValue*(m_max-m_min))); - h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); + sprintf(text, "%d", static_cast<int>(m_min+m_visibleValue*(m_max-m_min))); + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); pos.x = m_pos.x+m_dim.x+(10.0f/640.0f); pos.y = m_pos.y+(m_dim.y-h)/2.0f; - m_engine->RetText()->DrawText(text, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); + m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0); } else { @@ -481,8 +483,8 @@ void CSlider::Draw() pos.y += (h-CURSOR_WIDTH)*m_visibleValue; dim.x = 50.0f/640.0f; dim.y = 16.0f/480.0f; - sprintf(text, "%d", (int)(m_min+(m_visibleValue*(m_max-m_min)))); - m_engine->RetText()->DrawText(text, pos, dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); + sprintf(text, "%d", static_cast<int>(m_min+(m_visibleValue*(m_max-m_min)))); + m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0); } } } @@ -496,8 +498,8 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon) if ( icon == 0 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 0.0f/256.0f; // yellow rectangle uv1.y = 32.0f/256.0f; uv2.x = 32.0f/256.0f; @@ -508,8 +510,8 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 1 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 128.0f/256.0f; // gray rectangle uv1.y = 32.0f/256.0f; uv2.x = 160.0f/256.0f; @@ -520,8 +522,8 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 224.0f/256.0f; // cursor uv1.y = 32.0f/256.0f; uv2.x = 256.0f/256.0f; @@ -561,7 +563,7 @@ void CSlider::SetVisibleValue(float value) AdjustGlint(); } -float CSlider::RetVisibleValue() +float CSlider::GetVisibleValue() { return m_min+m_visibleValue*(m_max-m_min); } @@ -572,9 +574,10 @@ void CSlider::SetArrowStep(float step) m_step = step/(m_max-m_min); } -float CSlider::RetArrowStep() +float CSlider::GetArrowStep() { return m_step*(m_max-m_min); } +} diff --git a/src/ui/slider.h b/src/ui/slider.h index 1ec9ea5..4912453 100644 --- a/src/ui/slider.h +++ b/src/ui/slider.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 @@ -20,62 +21,62 @@ #include "ui/control.h" +#include "common/event.h" +namespace Ui { -class CD3DEngine; class CButton; - - 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 GetVisibleValue(); - void SetArrowStep(float step); - float RetArrowStep(); + void SetArrowStep(float step); + float GetArrowStep(); -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/studio.cpp b/src/ui/studio.cpp index cba19d6..c546c57 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.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,58 +18,59 @@ // studio.cpp -#include <stdlib.h> -#include <stdio.h> -#include <ctype.h> -#include <windows.h> -#include <direct.h> -#include <io.h> -#include <time.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/d3dmath.h" -#include "common/language.h" +#include "studio.h" + +#include "CBot/CBotDll.h" + +#include "app/app.h" #include "common/event.h" -#include "common/misc.h" #include "common/iman.h" -#include "common/restext.h" -#include "old/math3d.h" -#include "object/robotmain.h" +#include "common/misc.h" +#include "graphics/engine/camera.h" +#include "graphics/engine/engine.h" #include "object/object.h" -#include "old/camera.h" -#include "old/sound.h" +#include "script/cbottoken.h" #include "script/script.h" -#include "ui/interface.h" -#include "ui/button.h" +#include "sound/sound.h" #include "ui/check.h" -#include "ui/slider.h" +#include "ui/control.h" +#include "ui/color.h" +#include "ui/compass.h" #include "ui/edit.h" -#include "ui/list.h" -#include "ui/label.h" #include "ui/group.h" +#include "ui/image.h" +#include "ui/interface.h" +#include "ui/key.h" +#include "ui/label.h" +#include "ui/list.h" +#include "ui/map.h" +#include "ui/shortcut.h" +#include "ui/target.h" #include "ui/window.h" -#include "old/text.h" -#include "script/cbottoken.h" -#include "ui/studio.h" + +#include <stdio.h> + + +const int MAX_FNAME = 255; +namespace Ui { // Object's constructor. -CStudio::CStudio(CInstanceManager* iMan) +CStudio::CStudio() { - m_iMan = iMan; + m_iMan = CInstanceManager::GetInstancePointer(); m_iMan->AddInstance(CLASS_STUDIO, this); - m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); - m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); - m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); - m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); - m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); - m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); + 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_bEditMaximized = false; m_bEditMinimized = false; @@ -103,85 +105,85 @@ bool CStudio::EventProcess(const Event &event) return EventDialog(event); } - if ( event.event == EVENT_FRAME ) + if ( event.type == EVENT_FRAME ) { EventFrame(event); } - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return false; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast<CEdit*>(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == 0 ) return false; - if ( event.event == pw->RetEventMsgClose() ) + if ( event.type == pw->GetEventTypeClose() ) { Event newEvent = event; - newEvent.event = EVENT_STUDIO_OK; + newEvent.type = EVENT_STUDIO_OK; m_event->AddEvent(newEvent); } - if ( event.event == EVENT_STUDIO_EDIT ) // text modifief? + if ( event.type == EVENT_STUDIO_EDIT ) // text modifief? { ColorizeScript(edit); } - if ( event.event == EVENT_STUDIO_LIST ) // list clicked? + if ( event.type == EVENT_STUDIO_LIST ) // list clicked? { - m_main->StartDisplayInfo(m_helpFilename, -1); + m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes } - if ( event.event == EVENT_STUDIO_NEW ) // new? + if ( event.type == EVENT_STUDIO_NEW ) // new? { m_script->New(edit, ""); } - if ( event.event == EVENT_STUDIO_OPEN ) // open? + if ( event.type == EVENT_STUDIO_OPEN ) // open? { StartDialog(SD_OPEN); } - if ( event.event == EVENT_STUDIO_SAVE ) // save? + if ( event.type == EVENT_STUDIO_SAVE ) // save? { StartDialog(SD_SAVE); } - if ( event.event == EVENT_STUDIO_UNDO ) // undo? + if ( event.type == EVENT_STUDIO_UNDO ) // undo? { edit->Undo(); } - if ( event.event == EVENT_STUDIO_CUT ) // cut? + if ( event.type == EVENT_STUDIO_CUT ) // cut? { edit->Cut(); } - if ( event.event == EVENT_STUDIO_COPY ) // copy? + if ( event.type == EVENT_STUDIO_COPY ) // copy? { edit->Copy(); } - if ( event.event == EVENT_STUDIO_PASTE ) // paste? + if ( event.type == EVENT_STUDIO_PASTE ) // paste? { edit->Paste(); } - if ( event.event == EVENT_STUDIO_SIZE ) // size? + if ( event.type == EVENT_STUDIO_SIZE ) // size? { - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); - if ( slider == 0 ) return false; - m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f); + slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); + if ( slider == nullptr ) return false; + m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f); ViewEditScript(); } - if ( event.event == EVENT_STUDIO_TOOL && // instructions? + if ( event.type == EVENT_STUDIO_TOOL && // instructions? m_dialog == SD_NULL ) { m_main->StartDisplayInfo(SATCOM_HUSTON, false); } - if ( event.event == EVENT_STUDIO_HELP && // help? + if ( event.type == EVENT_STUDIO_HELP && // help? m_dialog == SD_NULL ) { m_main->StartDisplayInfo(SATCOM_PROG, false); } - if ( event.event == EVENT_STUDIO_COMPILE ) // compile? + if ( event.type == EVENT_STUDIO_COMPILE ) // compile? { char buffer[100]; @@ -197,12 +199,12 @@ bool CStudio::EventProcess(const Event &event) } } - if ( event.event == EVENT_STUDIO_RUN ) // run/stop? + if ( event.type == EVENT_STUDIO_RUN ) // run/stop? { if ( m_script->IsRunning() ) { Event newEvent = event; - newEvent.event = EVENT_OBJECT_PROGSTOP; + newEvent.type = EVENT_OBJECT_PROGSTOP; m_event->AddEvent(newEvent); // stop } else @@ -212,7 +214,7 @@ bool CStudio::EventProcess(const Event &event) SetInfoText("", false); Event newEvent = event; - newEvent.event = EVENT_OBJECT_PROGSTART; + newEvent.type = EVENT_OBJECT_PROGSTART; m_event->AddEvent(newEvent); // start } else @@ -224,7 +226,7 @@ bool CStudio::EventProcess(const Event &event) } } - if ( event.event == EVENT_STUDIO_REALTIME ) // real time? + if ( event.type == EVENT_STUDIO_REALTIME ) // real time? { m_bRealTime = !m_bRealTime; m_script->SetStepMode(!m_bRealTime); @@ -232,37 +234,37 @@ bool CStudio::EventProcess(const Event &event) UpdateButtons(); } - if ( event.event == EVENT_STUDIO_STEP ) // step? + if ( event.type == EVENT_STUDIO_STEP ) // step? { m_script->Step(event); } - if ( event.event == EVENT_KEYDOWN ) + if ( event.type == EVENT_KEY_DOWN ) { - if ( event.param == m_engine->RetKey(KEYRANK_CBOT, 0) || - event.param == m_engine->RetKey(KEYRANK_CBOT, 1) ) + if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).key || + event.param == m_main->GetInputBinding(INPUT_SLOT_CBOT).joy ) { - if ( m_helpFilename[0] != 0 ) + if ( m_helpFilename.length() > 0 ) { - m_main->StartDisplayInfo(m_helpFilename, -1); + m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes } } } - if ( event.event == EVENT_WINDOW3 ) // window is moved? + if ( event.type == EVENT_WINDOW3 ) // window is moved? { - m_editActualPos = m_editFinalPos = pw->RetPos(); - m_editActualDim = m_editFinalDim = pw->RetDim(); + m_editActualPos = m_editFinalPos = pw->GetPos(); + m_editActualDim = m_editFinalDim = pw->GetDim(); m_main->SetWindowPos(m_editActualPos); m_main->SetWindowDim(m_editActualDim); AdjustEditScript(); } - if ( event.event == pw->RetEventMsgReduce() ) + if ( event.type == pw->GetEventTypeReduce() ) { if ( m_bEditMinimized ) { - m_editFinalPos = m_main->RetWindowPos(); - m_editFinalDim = m_main->RetWindowDim(); + m_editFinalPos = m_main->GetWindowPos(); + m_editFinalDim = m_main->GetWindowDim(); m_bEditMinimized = false; m_bEditMaximized = false; } @@ -276,19 +278,19 @@ bool CStudio::EventProcess(const Event &event) m_bEditMaximized = false; } m_main->SetEditFull(m_bEditMaximized); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw != 0 ) + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw != nullptr ) { pw->SetMaximized(m_bEditMaximized); pw->SetMinimized(m_bEditMinimized); } } - if ( event.event == pw->RetEventMsgFull() ) + if ( event.type == pw->GetEventTypeFull() ) { if ( m_bEditMaximized ) { - m_editFinalPos = m_main->RetWindowPos(); - m_editFinalDim = m_main->RetWindowDim(); + m_editFinalPos = m_main->GetWindowPos(); + m_editFinalDim = m_main->GetWindowDim(); m_bEditMinimized = false; m_bEditMaximized = false; } @@ -302,8 +304,8 @@ bool CStudio::EventProcess(const Event &event) m_bEditMaximized = true; } m_main->SetEditFull(m_bEditMaximized); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw != 0 ) + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw != nullptr ) { pw->SetMaximized(m_bEditMaximized); pw->SetMinimized(m_bEditMinimized); @@ -348,13 +350,13 @@ bool CStudio::EventFrame(const Event &event) m_time += event.rTime; m_fixInfoTextTime -= event.rTime; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return false; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == 0 ) return false; - list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST); + list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST)); if ( list == 0 ) return false; if ( !m_script->IsRunning() && m_bRunning ) // stop? @@ -366,7 +368,7 @@ bool CStudio::EventFrame(const Event &event) SetInfoText(res, false); Event newEvent = event; - newEvent.event = EVENT_OBJECT_PROGSTOP; + newEvent.type = EVENT_OBJECT_PROGSTOP; m_event->AddEvent(newEvent); // stop } @@ -419,7 +421,7 @@ bool IsToken(int character) { char c; - c = tolower(RetNoAccent(character)); + c = tolower(GetNoAccent(character)); return ( (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || @@ -435,20 +437,20 @@ void CStudio::SearchToken(CEdit* edit) char* text; char token[100]; - text = edit->RetText(); - len = edit->RetTextLength(); + text = edit->GetText(); + len = edit->GetTextLength(); edit->GetCursor(cursor1, cursor2); i = cursor1; if ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( !IsToken(character) ) { level = 1; while ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( character == ')' ) { level ++; @@ -468,7 +470,7 @@ void CStudio::SearchToken(CEdit* edit) } while ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( IsToken(character) ) break; i --; } @@ -477,7 +479,7 @@ void CStudio::SearchToken(CEdit* edit) while ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( !IsToken(character) ) break; i --; } @@ -485,7 +487,7 @@ void CStudio::SearchToken(CEdit* edit) while ( i < len ) { - character = (unsigned char)text[i]; + character = static_cast< unsigned char > (text[i]); if ( !IsToken(character) ) break; i ++; } @@ -499,39 +501,39 @@ void CStudio::SearchToken(CEdit* edit) } token[i] = 0; - strcpy(m_helpFilename, RetHelpFilename(token)); - if ( m_helpFilename[0] == 0 ) + m_helpFilename = std::string(GetHelpFilename(token)); + if ( m_helpFilename.length() == 0 ) { for ( i=0 ; i<OBJECT_MAX ; i++ ) { - type = (ObjectType)i; - text = RetObjectName(type); + type = static_cast< ObjectType >(i); + text = const_cast<char *>(GetObjectName(type)); if ( text[0] != 0 ) { if ( strcmp(token, text) == 0 ) { - strcpy(m_helpFilename, RetHelpFilename(type)); - SetInfoText(token, true); + m_helpFilename = GetHelpFilename(type); + SetInfoText(std::string(token), true); return; } } - text = RetObjectAlias(type); + text = const_cast<char *>(GetObjectAlias(type)); if ( text[0] != 0 ) { if ( strcmp(token, text) == 0 ) { - strcpy(m_helpFilename, RetHelpFilename(type)); - SetInfoText(token, true); + m_helpFilename = GetHelpFilename(type); + SetInfoText(std::string(token), true); return; } } } } - text = RetHelpText(token); - if ( text[0] == 0 && m_helpFilename[0] != 0 ) + text = const_cast<char *>(GetHelpText(token)); + if ( text[0] == 0 && m_helpFilename.length() > 0 ) { - SetInfoText(token, true); + SetInfoText(std::string(token), true); } else { @@ -549,7 +551,7 @@ void CStudio::ColorizeScript(CEdit* edit) // Starts editing a program. -void CStudio::StartEditScript(CScript *script, char* name, int rank) +void CStudio::StartEditScript(CScript *script, std::string name, int rank) { Math::Point pos, dim; CWindow* pw; @@ -564,25 +566,25 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank) m_main->SetEditLock(true, true); m_main->SetEditFull(false); - m_bInitPause = m_engine->RetPause(); + m_bInitPause = m_engine->GetPause(); m_main->SetSpeed(1.0f); - m_editCamera = m_camera->RetType(); - m_camera->SetType(CAMERA_EDIT); + m_editCamera = m_camera->GetType(); + m_camera->SetType(Gfx::CAM_TYPE_EDIT); m_bRunning = m_script->IsRunning(); m_bRealTime = m_bRunning; m_script->SetStepMode(!m_bRealTime); - button = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + button = static_cast< CButton* >(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( button != 0 ) { button->ClearState(STATE_VISIBLE); } - pos = m_editFinalPos = m_editActualPos = m_main->RetWindowPos(); - dim = m_editFinalDim = m_editActualDim = m_main->RetWindowDim(); + pos = m_editFinalPos = m_editActualPos = m_main->GetWindowPos(); + dim = m_editFinalDim = m_editActualDim = m_main->GetWindowDim(); pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW3); - if ( pw == 0 ) return; + if ( pw == nullptr ) return; pw->SetState(STATE_SHADOW); pw->SetRedim(true); // before SetName! pw->SetMovable(true); @@ -600,20 +602,21 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank) edit->SetInsideScroll(false); //? if ( m_bRunning ) edit->SetEdit(false); edit->SetMaxChar(EDITSTUDIOMAX); - edit->SetFontType(FONT_COURIER); + edit->SetFontType(Gfx::FONT_COURIER); edit->SetFontStretch(0.7f); edit->SetDisplaySpec(true); - edit->SetAutoIndent(m_engine->RetEditIndentMode()); - m_script->PutScript(edit, name); + edit->SetAutoIndent(m_engine->GetEditIndentMode()); + + m_script->PutScript(edit, name.c_str()); ColorizeScript(edit); ViewEditScript(); list = pw->CreateList(pos, dim, 1, EVENT_STUDIO_LIST, 1.2f); list->SetState(STATE_SHADOW); - list->SetFontType(FONT_COURIER); + list->SetFontType(Gfx::FONT_COURIER); list->SetSelectCap(false); - list->SetFontSize(SMALLFONT*0.85f); + list->SetFontSize(Gfx::FONT_SIZE_SMALL*0.85f); //? list->SetFontStretch(1.0f); button = pw->CreateButton(pos, dim, 56, EVENT_STUDIO_NEW); @@ -632,7 +635,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank) button->SetState(STATE_SHADOW); slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE); slider->SetState(STATE_SHADOW); - slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); + slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); pw->CreateGroup(pos, dim, 19, EVENT_LABEL1); // SatCom logo button = pw->CreateButton(pos, dim, 128+57, EVENT_STUDIO_TOOL); button->SetState(STATE_SHADOW); @@ -673,12 +676,12 @@ void CStudio::AdjustEditScript() wpos = m_editActualPos; wdim = m_editActualDim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw != 0 ) + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw != nullptr ) { pw->SetPos(wpos); pw->SetDim(wdim); - wdim = pw->RetDim(); + wdim = pw->GetDim(); } if ( m_bRunning ) hList = 80.0f/480.0f; @@ -688,7 +691,7 @@ void CStudio::AdjustEditScript() pos.y = wpos.y+0.09f+hList; dim.x = wdim.x-0.02f; dim.y = wdim.y-0.22f-hList; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit != 0 ) { edit->SetPos(pos); @@ -699,7 +702,7 @@ void CStudio::AdjustEditScript() pos.y = wpos.y+0.09f; dim.x = wdim.x-0.02f; dim.y = hList; - list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST); + list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST)); if ( list != 0 ) { list->SetPos(pos); @@ -712,56 +715,56 @@ void CStudio::AdjustEditScript() pos.y = wpos.y+wdim.y-dim.y-0.06f; pos.x = wpos.x+0.01f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_NEW); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_NEW)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.05f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_OPEN); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OPEN)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.09f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_SAVE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_SAVE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.14f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_UNDO); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_UNDO)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.19f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_CUT); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CUT)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.23f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_COPY); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COPY)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.27f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_PASTE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_PASTE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.32f; - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); + slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider != 0 ) { ppos = pos; @@ -773,21 +776,21 @@ void CStudio::AdjustEditScript() slider->SetDim(ddim); } pos.x = wpos.x+0.36f; - group = (CGroup*)pw->SearchControl(EVENT_LABEL1); + group = static_cast< CGroup* >(pw->SearchControl(EVENT_LABEL1)); if ( group != 0 ) { group->SetPos(pos); group->SetDim(dim); } pos.x = wpos.x+0.40f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_TOOL); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_TOOL)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.44f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_HELP); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_HELP)); if ( button != 0 ) { button->SetPos(pos); @@ -798,14 +801,14 @@ void CStudio::AdjustEditScript() pos.x = wpos.x+0.01f; dim.x = 80.0f/640.0f; dim.y = 25.0f/480.0f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_OK); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OK)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.14f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_CANCEL); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CANCEL)); if ( button != 0 ) { button->SetPos(pos); @@ -813,28 +816,28 @@ void CStudio::AdjustEditScript() } pos.x = wpos.x+0.28f; dim.x = dim.y*0.75f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_COMPILE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*1; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_RUN); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*2; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_REALTIME); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*3; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_STEP); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP)); if ( button != 0 ) { button->SetPos(pos); @@ -851,12 +854,12 @@ bool CStudio::StopEditScript(bool bCancel) CButton* button; char buffer[100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return false; if ( !bCancel && !m_script->IsRunning() ) { - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit != 0 ) { if ( !m_script->GetScript(edit) ) // compile @@ -871,7 +874,7 @@ bool CStudio::StopEditScript(bool bCancel) m_interface->DeleteControl(EVENT_WINDOW3); - button = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + button = static_cast< CButton* >(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( button != 0 ) { button->SetState(STATE_VISIBLE); @@ -888,23 +891,21 @@ bool CStudio::StopEditScript(bool bCancel) // The messages are not clickable 8 seconds, // even if a message was clickable poster before. -void CStudio::SetInfoText(char *text, bool bClickable) +void CStudio::SetInfoText(std::string text, bool bClickable) { - CWindow* pw; - CList* list; char res[100]; if ( bClickable && m_fixInfoTextTime > 0.0f ) return; if ( !bClickable ) m_fixInfoTextTime = 8.0f; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return; + CWindow* pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return; - list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST); + CList* list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST)); if ( list == 0 ) return; list->Flush(); // just text - list->SetName(0, text); + list->SetName(0, text.c_str()); if ( text[0] == 0 ) bClickable = false; list->SetSelectCap(bClickable); @@ -930,16 +931,16 @@ void CStudio::ViewEditScript() { CWindow* pw; CEdit* edit; - POINT dim; + Math::IntPoint dim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == 0 ) return; - dim = m_engine->RetDim(); - edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f)); + dim = m_engine->GetWindowSize(); + edit->SetFontSize(m_main->GetFontSize()/(dim.x/640.0f)); } @@ -980,10 +981,10 @@ void CStudio::UpdateButtons() CEdit* edit; CButton* button; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == 0 ) return; if ( m_bRunning ) @@ -999,20 +1000,20 @@ void CStudio::UpdateButtons() edit->SetHiliteCap(true); } - button = (CButton*)pw->SearchControl(EVENT_STUDIO_COMPILE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE)); if ( button == 0 ) return; button->SetState(STATE_ENABLE, !m_bRunning); - button = (CButton*)pw->SearchControl(EVENT_STUDIO_RUN); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN)); if ( button == 0 ) return; button->SetIcon(m_bRunning?8:21); // stop/run - button = (CButton*)pw->SearchControl(EVENT_STUDIO_REALTIME); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME)); if ( button == 0 ) return; button->SetIcon(m_bRealTime?64+22:64+21); button->SetState(STATE_ENABLE, (!m_bRunning || !m_script->IsContinue())); - button = (CButton*)pw->SearchControl(EVENT_STUDIO_STEP); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP)); if ( button == 0 ) return; button->SetState(STATE_ENABLE, (m_bRunning && !m_bRealTime && !m_script->IsContinue())); } @@ -1033,38 +1034,38 @@ void CStudio::StartDialog(StudioDialog type) m_dialog = type; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW1)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW4)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW5)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); - if ( pw != 0 ) pw->ClearState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW8)); + if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); if ( m_dialog == SD_OPEN || m_dialog == SD_SAVE ) { - pos = m_main->RetIOPos(); - dim = m_main->RetIODim(); + pos = m_main->GetIOPos(); + dim = m_main->GetIODim(); } //? pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW9); pw = m_interface->CreateWindows(pos, dim, m_dialog==SD_OPEN?14:13, EVENT_WINDOW9); @@ -1084,25 +1085,25 @@ void CStudio::StartDialog(StudioDialog type) { GetResource(RES_TEXT, RT_IO_LIST, name); pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL1, name); - pla->SetJustif(1); + pla->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pli = pw->CreateList(pos, dim, 0, EVENT_DIALOG_LIST); pli->SetState(STATE_SHADOW); GetResource(RES_TEXT, RT_IO_NAME, name); pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL2, name); - pla->SetJustif(1); + pla->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pe = pw->CreateEdit(pos, dim, 0, EVENT_DIALOG_EDIT); pe->SetState(STATE_SHADOW); if ( m_dialog == SD_SAVE ) { - pe->SetText(m_script->RetFilename()); + pe->SetText(m_script->GetFilename()); } GetResource(RES_TEXT, RT_IO_DIR, name); pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL3, name); - pla->SetJustif(1); + pla->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pc = pw->CreateCheck(pos, dim, 0, EVENT_DIALOG_CHECK1); GetResource(RES_TEXT, RT_IO_PRIVATE, name); @@ -1152,32 +1153,32 @@ void CStudio::StopDialog() if ( m_dialog == SD_NULL ) return; m_dialog = SD_NULL; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW1)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW2)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW4)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW5)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); - if ( pw != 0 ) pw->SetState(STATE_ENABLE); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW8)); + if ( pw != nullptr ) pw->SetState(STATE_ENABLE); m_interface->DeleteControl(EVENT_WINDOW9); m_main->SetSatComLock(false); // possible to use the SatCom @@ -1197,11 +1198,11 @@ void CStudio::AdjustDialog() int nli, nch; char name[100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); + if ( pw == nullptr ) return; - wpos = pw->RetPos(); - wdim = pw->RetDim(); + wpos = pw->GetPos(); + wdim = pw->GetDim(); pw->SetPos(wpos); // to move the buttons on the titlebar if ( m_dialog == SD_OPEN || @@ -1211,23 +1212,23 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+wdim.y-55.0f/480.0f; ddim.x = wdim.x-20.0f/640.0f; ddim.y = 20.0f/480.0f; - pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1); + pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1)); if ( pla != 0 ) { pla->SetPos(ppos); pla->SetDim(ddim); } - nli = (int)((wdim.y-120.0f/480.0f)/(18.0f/480.0f)); + nli = static_cast<int>((wdim.y-120.0f/480.0f)/(18.0f/480.0f)); ddim.y = nli*18.0f/480.0f+9.0f/480.0f; ppos.y = wpos.y+wdim.y-48.0f/480.0f-ddim.y; - pli = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + pli = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); if ( pli != 0 ) { pli->SetPos(ppos); pli->SetDim(ddim); pli->SetTabs(0, ddim.x-(50.0f+130.0f+16.0f)/640.0f); - pli->SetTabs(1, 50.0f/640.0f, -1); + pli->SetTabs(1, 50.0f/640.0f, Gfx::TEXT_ALIGN_RIGHT); pli->SetTabs(2, 130.0f/640.0f); //? pli->ShowSelect(); } @@ -1235,7 +1236,7 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+30.0f/480.0f; ddim.x = 50.0f/640.0f; ddim.y = 20.0f/480.0f; - pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL2); + pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL2)); if ( pla != 0 ) { pla->SetPos(ppos); @@ -1245,13 +1246,13 @@ void CStudio::AdjustDialog() ppos.x += 50.0f/640.0f; ppos.y = wpos.y+36.0f/480.0f; ddim.x = wdim.x-170.0f/640.0f; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe != 0 ) { pe->SetPos(ppos); pe->SetDim(ddim); - nch = (int)((ddim.x*640.0f-22.0f)/8.0f); + nch = static_cast< int >((ddim.x*640.0f-22.0f)/8.0f); pe->GetText(name, 100); pe->SetMaxChar(nch); name[nch] = 0; // truncates the text according to max @@ -1262,7 +1263,7 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+5.0f/480.0f; ddim.x = 50.0f/640.0f; ddim.y = 16.0f/480.0f; - pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL3); + pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL3)); if ( pla != 0 ) { pla->SetPos(ppos); @@ -1272,7 +1273,7 @@ void CStudio::AdjustDialog() ppos.x += 50.0f/640.0f; ppos.y = wpos.y+12.0f/480.0f; ddim.x = 70.0f/640.0f; - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK1)); if ( pc != 0 ) { pc->SetPos(ppos); @@ -1280,7 +1281,7 @@ void CStudio::AdjustDialog() } ppos.x += 80.0f/640.0f; - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK2)); if ( pc != 0 ) { pc->SetPos(ppos); @@ -1291,7 +1292,7 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+34.0f/480.0f; ddim.x = 90.0f/640.0f; ddim.y = 23.0f/480.0f; - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb != 0 ) { pb->SetPos(ppos); @@ -1299,7 +1300,7 @@ void CStudio::AdjustDialog() } ppos.y -= 26.0f/480.0f; - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb != 0 ) { pb->SetPos(ppos); @@ -1315,13 +1316,13 @@ bool CStudio::EventDialog(const Event &event) CWindow* pw; Math::Point wpos, wdim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); + if ( pw == nullptr ) return false; - if ( event.event == EVENT_WINDOW9 ) // window is moved? + if ( event.type == EVENT_WINDOW9 ) // window is moved? { - wpos = pw->RetPos(); - wdim = pw->RetDim(); + wpos = pw->GetPos(); + wdim = pw->GetDim(); m_main->SetIOPos(wpos); m_main->SetIODim(wdim); AdjustDialog(); @@ -1330,22 +1331,22 @@ bool CStudio::EventDialog(const Event &event) if ( m_dialog == SD_OPEN || m_dialog == SD_SAVE ) { - if ( event.event == EVENT_DIALOG_LIST ) + if ( event.type == EVENT_DIALOG_LIST ) { UpdateChangeList(); } - if ( event.event == EVENT_DIALOG_EDIT ) + if ( event.type == EVENT_DIALOG_EDIT ) { UpdateChangeEdit(); } - if ( event.event == EVENT_DIALOG_CHECK1 ) // private? + if ( event.type == EVENT_DIALOG_CHECK1 ) // private? { m_main->SetIOPublic(false); UpdateDialogPublic(); UpdateDialogList(); } - if ( event.event == EVENT_DIALOG_CHECK2 ) // public? + if ( event.type == EVENT_DIALOG_CHECK2 ) // public? { m_main->SetIOPublic(true); UpdateDialogPublic(); @@ -1353,8 +1354,8 @@ bool CStudio::EventDialog(const Event &event) } } - if ( event.event == EVENT_DIALOG_OK || - (event.event == EVENT_KEYDOWN && event.param == VK_RETURN) ) + if ( event.type == EVENT_DIALOG_OK || + (event.type == EVENT_KEY_DOWN && event.param == KEY(RETURN)) ) { if ( m_dialog == SD_OPEN ) { @@ -1369,9 +1370,9 @@ bool CStudio::EventDialog(const Event &event) return true; } - if ( event.event == EVENT_DIALOG_CANCEL || - (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) || - event.event == pw->RetEventMsgClose() ) + if ( event.type == EVENT_DIALOG_CANCEL || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) || + event.type == pw->GetEventTypeClose() ) { StopDialog(); return true; @@ -1390,15 +1391,15 @@ void CStudio::UpdateChangeList() char name[100]; char* p; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + 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; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); - if ( pe == 0 ) return; + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); + if ( pe == nullptr ) return; - strcpy(name, pl->RetName(pl->RetSelect())); - name[pe->RetMaxChar()] = 0; // truncates according lg max editable + strcpy(name, pl->GetName(pl->GetSelect())); + name[pe->GetMaxChar()] = 0; // truncates according lg max editable p = strchr(name, '\t'); // seeks first tab if ( p != 0 ) *p = 0; pe->SetText(name); @@ -1415,9 +1416,9 @@ void CStudio::UpdateChangeEdit() CWindow* pw; CList* pl; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + 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->SetSelect(-1); @@ -1436,12 +1437,12 @@ void CStudio::UpdateDialogAction() int len, i; bool bError; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); - if ( pe == 0 ) return; - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); - if ( pb == 0 ) return; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); + if ( pw == nullptr ) return; + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); + if ( pe == nullptr ) return; + pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_OK)); + if ( pb == nullptr ) return; pe->GetText(name, 100); len = strlen(name); @@ -1477,25 +1478,25 @@ void CStudio::UpdateDialogPublic() CCheck* pc; CLabel* pl; char name[100]; - char dir[_MAX_FNAME]; - char text[_MAX_FNAME+100]; + char dir[MAX_FNAME]; + char text[MAX_FNAME+100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); + if ( pw == nullptr ) return; - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK1)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, !m_main->RetIOPublic()); + pc->SetState(STATE_CHECK, !m_main->GetIOPublic()); } - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK2)); if ( pc != 0 ) { - pc->SetState(STATE_CHECK, m_main->RetIOPublic()); + pc->SetState(STATE_CHECK, m_main->GetIOPublic()); } - pl = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1); + pl = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1)); if ( pl != 0 ) { GetResource(RES_TEXT, RT_IO_LIST, name); @@ -1509,19 +1510,20 @@ void CStudio::UpdateDialogPublic() void CStudio::UpdateDialogList() { - CWindow* pw; + // 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]; + char dir[MAX_FNAME]; + char temp[MAX_FNAME]; int nbFilenames, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return; - pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + 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->Flush(); @@ -1565,7 +1567,7 @@ void CStudio::UpdateDialogList() pl->SetName(i, temp); } - free(listBuffer); + free(listBuffer);*/ } // Constructs the name of the folder or open/save. @@ -1573,18 +1575,18 @@ void CStudio::UpdateDialogList() void CStudio::SearchDirectory(char *dir, bool bCreate) { - if ( m_main->RetIOPublic() ) + if ( m_main->GetIOPublic() ) { - sprintf(dir, "%s\\", m_main->RetPublicDir()); + sprintf(dir, "%s\\", m_main->GetPublicDir()); } else { - sprintf(dir, "%s\\%s\\Program\\", m_main->RetSavegameDir(), m_main->RetGamerName()); + sprintf(dir, "%s\\%s\\Program\\", m_main->GetSavegameDir(), m_main->GetGamerName()); } if ( bCreate ) - { - _mkdir(dir); // if does not exist yet! + {// TODO +// mkdir(dir,0777); // if does not exist yet! } } @@ -1598,11 +1600,11 @@ bool CStudio::ReadProgram() char dir[100]; char* p; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); + if ( pw == nullptr ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); - if ( pe == 0 ) return false; + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); + if ( pe == nullptr ) return false; pe->GetText(filename, 100); if ( filename[0] == 0 ) return false; @@ -1614,10 +1616,10 @@ bool CStudio::ReadProgram() SearchDirectory(dir, true); strcat(dir, filename); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); - if ( pe == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return false; + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); + if ( pe == nullptr ) return false; if ( !pe->ReadText(dir) ) return false; @@ -1636,11 +1638,11 @@ bool CStudio::WriteProgram() char dir[100]; char* p; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); - if ( pw == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); + if ( pw == nullptr ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); - if ( pe == 0 ) return false; + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); + if ( pe == nullptr ) return false; pe->GetText(filename, 100); if ( filename[0] == 0 ) return false; @@ -1652,10 +1654,10 @@ bool CStudio::WriteProgram() SearchDirectory(dir, true); strcat(dir, filename); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); - if ( pw == 0 ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); - if ( pe == 0 ) return false; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); + if ( pw == nullptr ) return false; + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); + if ( pe == nullptr ) return false; if ( !pe->WriteText(dir) ) return false; @@ -1663,3 +1665,4 @@ bool CStudio::WriteProgram() return true; } +} diff --git a/src/ui/studio.h b/src/ui/studio.h index 687ab22..905baa6 100644 --- a/src/ui/studio.h +++ b/src/ui/studio.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 @@ -17,24 +18,28 @@ // studio.h #pragma once +#include "common/event.h" +#include "graphics/engine/camera.h" -#include "object/object.h" -#include "script/script.h" +#include <string> +class CEventQueue; class CInstanceManager; -class CD3DEngine; -class CEvent; class CRobotMain; -class CCamera; -class CSound; -class CInterface; class CScript; -class CList; -class CEdit; +class CSoundInterface; +namespace Gfx { +class CEngine; +class CCamera; +}; +namespace Ui { + +class CEdit; +class CInterface; enum StudioDialog { @@ -49,67 +54,70 @@ enum StudioDialog class CStudio { -public: - CStudio(CInstanceManager* iMan); - ~CStudio(); - - bool EventProcess(const Event &event); - - void StartEditScript(CScript *script, char* 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(char *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; - CD3DEngine* m_engine; - CEvent* m_event; - CRobotMain* m_main; - CCamera* m_camera; - CSound* m_sound; - CInterface* m_interface; - - int m_rank; - CScript* m_script; - - bool m_bEditMaximized; - bool m_bEditMinimized; - - CameraType m_editCamera; - 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; - char m_helpFilename[100]; + 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; StudioDialog m_dialog; }; +} + diff --git a/src/ui/target.cpp b/src/ui/target.cpp index f94ae02..f398e58 100644 --- a/src/ui/target.cpp +++ b/src/ui/target.cpp @@ -17,27 +17,14 @@ // target.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#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 "object/robotmain.h" -#include "object/object.h" -#include "common/restext.h" #include "ui/target.h" - +namespace Ui { // Object's constructor. -CTarget::CTarget(CInstanceManager* iMan) : CControl(iMan) +CTarget::CTarget() : CControl() { } @@ -50,11 +37,11 @@ CTarget::~CTarget() // Creates a new button. -bool CTarget::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CTarget::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); - CControl::Create(pos, dim, icon, eventMsg); + CControl::Create(pos, dim, icon, eventType); return true; } @@ -70,26 +57,27 @@ bool CTarget::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.event == EVENT_MOUSEMOVE ) + if ( event.type == EVENT_MOUSE_MOVE ) { if ( CControl::Detect(event.pos) ) { - m_engine->SetMouseType(D3DMOUSETARGET); + m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } } - if ( event.event == EVENT_LBUTTONDOWN && + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1 && (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { if ( CControl::Detect(event.pos) ) { Event newEvent = event; - newEvent.event = EVENT_OBJECT_FIRE; + newEvent.type = EVENT_OBJECT_FIRE; m_event->AddEvent(newEvent); return false; } @@ -104,40 +92,41 @@ bool CTarget::EventProcess(const Event &event) CControl::EventProcess(event); - if ( event.event == EVENT_MOUSEMOVE ) + if ( event.type == EVENT_MOUSE_MOVE ) { m_main->SetFriendAim(false); - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseMove.pos) ) { - pObj = DetectFriendObject(event.pos); + pObj = DetectFriendObject(event.mouseMove.pos); if ( pObj == 0 ) { - m_engine->SetMouseType(D3DMOUSETARGET); + m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } else { m_main->SetFriendAim(true); - m_engine->SetMouseType(D3DMOUSENORM); + m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); } } } - if ( event.event == EVENT_LBUTTONDOWN && + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1 && (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { - if ( !m_main->RetFriendAim() ) + if ( !m_main->GetFriendAim() ) { Event newEvent = event; - newEvent.event = EVENT_OBJECT_FIRE; + newEvent.type = EVENT_OBJECT_FIRE; m_event->AddEvent(newEvent); return false; } @@ -159,7 +148,7 @@ void CTarget::Draw() // Returns the tooltip. -bool CTarget::GetTooltip(Math::Point pos, char* name) +bool CTarget::GetTooltip(Math::Point pos, std::string &name) { #if 0 if ( (m_state&STATE_VISIBLE) && Detect(pos) ) // in the window? @@ -178,9 +167,9 @@ bool CTarget::GetTooltip(Math::Point pos, char* name) { //? pObj = DetectFriendObject(pos); //? if ( pObj == 0 ) - if ( !m_main->RetFriendAim() ) + if ( !m_main->GetFriendAim() ) { - strcpy(name, m_tooltip); + m_tooltip = name; return true; // does not detect objects below! } } @@ -202,15 +191,15 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetActif() ) continue; - if ( pObj->RetProxyActivate() ) continue; - if ( pObj->RetSelect() ) continue; + if ( !pObj->GetActif() ) continue; + if ( pObj->GetProxyActivate() ) continue; + if ( pObj->GetSelect() ) continue; pTarget = 0; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_DERRICK || type == OBJECT_FACTORY || type == OBJECT_REPAIR || @@ -261,10 +250,10 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) } else if ( (type == OBJECT_POWER || type == OBJECT_ATOMIC ) && - pObj->RetTruck() != 0 ) // battery used? + pObj->GetTruck() != 0 ) // battery used? { - pTarget = pObj->RetTruck(); - if ( pTarget->RetType() == OBJECT_MOBILEtg ) + pTarget = pObj->GetTruck(); + if ( pTarget->GetType() == OBJECT_MOBILEtg ) { pTarget = 0; } @@ -272,7 +261,7 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) for ( j=0 ; j<OBJECTMAXPART ; j++ ) { - rank = pObj->RetObjectRank(j); + rank = pObj->GetObjectRank(j); if ( rank == -1 ) continue; if ( rank != objRank ) continue; return pTarget; @@ -281,3 +270,4 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) return 0; } +} diff --git a/src/ui/target.h b/src/ui/target.h index ae0c7af..05a3651 100644 --- a/src/ui/target.h +++ b/src/ui/target.h @@ -18,31 +18,38 @@ #pragma once +#include <string> #include "ui/control.h" +#include "common/misc.h" +#include "common/iman.h" +#include "common/restext.h" +#include "common/event.h" -class CD3DEngine; -class CObject; +#include "graphics/engine/engine.h" +#include "object/robotmain.h" +#include "object/object.h" +namespace Ui { + 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, std::string &name); -protected: + protected: + CObject* DetectFriendObject(Math::Point pos); }; +} diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 8866643..4967795 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.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,44 +18,15 @@ // window.cpp -#include <windows.h> -#include <stdio.h> -#include <d3d.h> - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/language.h" -#include "old/math3d.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/restext.h" -#include "common/iman.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/map.h" -#include "ui/gauge.h" -#include "ui/compass.h" -#include "ui/target.h" -#include "old/text.h" #include "ui/window.h" - +namespace Ui { // Object's constructor. -CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan) +//CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan) +CWindow::CWindow() : CControl() { int i; @@ -80,7 +52,7 @@ CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan) m_bClosable = false; m_bCapture = false; - m_fontStretch = NORMSTRETCH*1.2f; +// m_fontStretch = NORMSTRETCH*1.2f; } // Object's destructor. @@ -128,9 +100,9 @@ void CWindow::Flush() // Creates a new window. -bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); CControl::Create(pos, dim, icon, eventMsg); return true; @@ -139,19 +111,20 @@ bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventM // Creates a new button. -CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CButton* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CButton(m_iMan); - pc = (CButton*)m_table[i]; +// 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); return pc; } @@ -161,19 +134,20 @@ CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, Event // Creates a new button. -CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CColor* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CColor(m_iMan); - pc = (CColor*)m_table[i]; +// 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); return pc; } @@ -183,19 +157,20 @@ CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMs // Creates a new button. -CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CCheck* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CCheck(m_iMan); - pc = (CCheck*)m_table[i]; +// 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); return pc; } @@ -205,19 +180,20 @@ CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMs // Creates a new button. -CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CKey* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CKey(m_iMan); - pc = (CKey*)m_table[i]; +// 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); return pc; } @@ -227,19 +203,20 @@ CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg ev // Creates a new button. -CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CGroup* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CGroup(m_iMan); - pc = (CGroup*)m_table[i]; +// 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); return pc; } @@ -249,19 +226,20 @@ CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMs // Creates a new button. -CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CImage* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CImage(m_iMan); - pc = (CImage*)m_table[i]; +// 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); return pc; } @@ -271,39 +249,27 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMs // Creates a new label. -CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, - char *name) +CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name) { CLabel* pc; - char* p; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CLabel(m_iMan); - pc = (CLabel*)m_table[i]; +// 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); - p = strchr(name, '\\'); - if ( p == 0 ) - { + auto p = name.find("\\"); + if ( p == std::string::npos ) pc->SetName(name); - } else - { - char text[100]; - strncpy(text, name, 100); - text[100-1] = 0; - if ( p-name < 100 ) - { - text[p-name] = 0; // deletes text after "\\" (tooltip) - } - pc->SetName(text); - } + pc->SetName(name.substr(0, p)); return pc; } } @@ -312,19 +278,20 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMs // Creates a new editable pave. -CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CEdit* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CEdit(m_iMan); - pc = (CEdit*)m_table[i]; +// 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); return pc; } @@ -334,19 +301,20 @@ CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg // Creates a new editable pave. -CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CEditValue* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CEditValue(m_iMan); - pc = (CEditValue*)m_table[i]; +// 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); return pc; } @@ -356,19 +324,20 @@ CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, // Creates a new elevator. -CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CScroll* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CScroll(m_iMan); - pc = (CScroll*)m_table[i]; +// 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); return pc; } @@ -378,19 +347,20 @@ CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, Event // Creates a new cursor. -CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CSlider* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CSlider(m_iMan); - pc = (CSlider*)m_table[i]; +// 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); return pc; } @@ -400,20 +370,21 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event // Creates a new list. -CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, +CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { CList* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CList(m_iMan); - pc = (CList*)m_table[i]; +// 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); return pc; } @@ -423,19 +394,19 @@ CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg // Creates a new shortcut. -CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CShortcut* ps; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CShortcut(m_iMan); - ps = (CShortcut*)m_table[i]; + m_table[i] = new CShortcut(); + ps = static_cast<CShortcut*>(m_table[i]); ps->Create(pos, dim, icon, eventMsg); return ps; } @@ -445,19 +416,19 @@ CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, E // Creates a new card. -CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CMap* pm; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CMap(m_iMan); - pm = (CMap*)m_table[i]; + m_table[i] = new CMap(); + pm = static_cast<CMap*>(m_table[i]); pm->Create(pos, dim, icon, eventMsg); return pm; } @@ -467,19 +438,19 @@ CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg ev // Creates a new gauge. -CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CGauge* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CGauge(m_iMan); - pc = (CGauge*)m_table[i]; + m_table[i] = new CGauge(); + pc = static_cast<CGauge*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -489,19 +460,19 @@ CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMs // Creates a new compass. -CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CCompass* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CCompass(m_iMan); - pc = (CCompass*)m_table[i]; + m_table[i] = new CCompass(); + pc = static_cast<CCompass*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -511,19 +482,19 @@ CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, Eve // Creates a new target. -CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) { CTarget* pc; int i; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); + if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType(); for ( i=0 ; i<MAXWINDOW ; i++ ) { if ( m_table[i] == 0 ) { - m_table[i] = new CTarget(m_iMan); - pc = (CTarget*)m_table[i]; + m_table[i] = new CTarget(); + pc = static_cast<CTarget*>(m_table[i]); pc->Create(pos, dim, icon, eventMsg); return pc; } @@ -533,7 +504,7 @@ CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, Event // Removes a control. -bool CWindow::DeleteControl(EventMsg eventMsg) +bool CWindow::DeleteControl(EventType eventMsg) { int i; @@ -541,7 +512,7 @@ bool CWindow::DeleteControl(EventMsg eventMsg) { if ( m_table[i] != 0 ) { - if ( eventMsg == m_table[i]->RetEventMsg() ) + if ( eventMsg == m_table[i]->GetEventType() ) { delete m_table[i]; m_table[i] = 0; @@ -554,7 +525,7 @@ bool CWindow::DeleteControl(EventMsg eventMsg) // Gives a control. -CControl* CWindow::SearchControl(EventMsg eventMsg) +CControl* CWindow::SearchControl(EventType eventMsg) { int i; @@ -562,7 +533,7 @@ CControl* CWindow::SearchControl(EventMsg eventMsg) { if ( m_table[i] != 0 ) { - if ( eventMsg == m_table[i]->RetEventMsg() ) + if ( eventMsg == m_table[i]->GetEventType() ) { return m_table[i]; } @@ -574,7 +545,7 @@ CControl* CWindow::SearchControl(EventMsg eventMsg) // Makes the tooltip binds to the window. -bool CWindow::GetTooltip(Math::Point pos, char* name) +bool CWindow::GetTooltip(Math::Point pos, std::string &name) { int i; @@ -607,7 +578,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name) if ( Detect(pos) ) // in the window? { - strcpy(name, m_tooltip); + name = m_tooltip; return true; } @@ -617,7 +588,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name) // Specifies the name for the title bar. -void CWindow::SetName(char* name) +void CWindow::SetName(std::string name) { CButton* pc; bool bAdjust; @@ -644,23 +615,23 @@ void CWindow::SetName(char* name) bAdjust = false; - if ( m_name[0] != 0 && m_bRedim ) // title bar exists? + if ( m_name.length() > 0 && m_bRedim ) // title bar exists? { - m_buttonReduce = new CButton(m_iMan); - pc = (CButton*)m_buttonReduce; + m_buttonReduce = new CButton(); + pc = m_buttonReduce; pc->Create(m_pos, m_dim, 0, EVENT_NULL); - m_buttonFull = new CButton(m_iMan); - pc = (CButton*)m_buttonFull; + m_buttonFull = new CButton(); + pc = m_buttonFull; pc->Create(m_pos, m_dim, 0, EVENT_NULL); bAdjust = true; } - if ( m_name[0] != 0 && m_bClosable ) // title bar exists? + if ( m_name.length() > 0 && m_bClosable ) // title bar exists? { - m_buttonClose = new CButton(m_iMan); - pc = (CButton*)m_buttonClose; + m_buttonClose = new CButton(); + pc = m_buttonClose; pc->Create(m_pos, m_dim, 0, EVENT_NULL); bAdjust = true; @@ -697,7 +668,7 @@ void CWindow::MoveAdjust() Math::Point pos, dim; float h, offset; - h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); dim.y = h*1.2f; dim.x = dim.y*0.75f; @@ -742,12 +713,12 @@ void CWindow::SetMaxDim(Math::Point dim) m_maxDim = dim; } -Math::Point CWindow::RetMinDim() +Math::Point CWindow::GetMinDim() { return m_minDim; } -Math::Point CWindow::RetMaxDim() +Math::Point CWindow::GetMaxDim() { return m_maxDim; } @@ -760,7 +731,7 @@ void CWindow::SetMovable(bool bMode) m_bMovable = bMode; } -bool CWindow::RetMovable() +bool CWindow::GetMovable() { return m_bMovable; } @@ -773,7 +744,7 @@ void CWindow::SetRedim(bool bMode) m_bRedim = bMode; } -bool CWindow::RetRedim() +bool CWindow::GetRedim() { return m_bRedim; } @@ -786,7 +757,7 @@ void CWindow::SetClosable(bool bMode) m_bClosable = bMode; } -bool CWindow::RetClosable() +bool CWindow::GetClosable() { return m_bClosable; } @@ -798,7 +769,7 @@ void CWindow::SetMaximized(bool bMaxi) AdjustButtons(); } -bool CWindow::RetMaximized() +bool CWindow::GetMaximized() { return m_bMaximized; } @@ -809,7 +780,7 @@ void CWindow::SetMinimized(bool bMini) AdjustButtons(); } -bool CWindow::RetMinimized() +bool CWindow::GetMinimized() { return m_bMinimized; } @@ -819,7 +790,7 @@ void CWindow::SetFixed(bool bFix) m_bFixed = bFix; } -bool CWindow::RetFixed() +bool CWindow::GetFixed() { return m_bFixed; } @@ -837,13 +808,13 @@ void CWindow::AdjustButtons() { m_buttonFull->SetIcon(54); GetResource(RES_TEXT, RT_WINDOW_STANDARD, res); - m_buttonFull->SetTooltip(res); + m_buttonFull->SetTooltip(std::string(res)); } else { m_buttonFull->SetIcon(52); GetResource(RES_TEXT, RT_WINDOW_MAXIMIZED, res); - m_buttonFull->SetTooltip(res); + m_buttonFull->SetTooltip(std::string(res)); } } @@ -853,13 +824,13 @@ void CWindow::AdjustButtons() { m_buttonReduce->SetIcon(54); GetResource(RES_TEXT, RT_WINDOW_STANDARD, res); - m_buttonReduce->SetTooltip(res); + m_buttonReduce->SetTooltip(std::string(res)); } else { m_buttonReduce->SetIcon(51); GetResource(RES_TEXT, RT_WINDOW_MINIMIZED, res); - m_buttonReduce->SetTooltip(res); + m_buttonReduce->SetTooltip(std::string(res)); } } @@ -867,7 +838,7 @@ void CWindow::AdjustButtons() { m_buttonClose->SetIcon(11); // x GetResource(RES_TEXT, RT_WINDOW_CLOSE, res); - m_buttonClose->SetTooltip(res); + m_buttonClose->SetTooltip(std::string(res)); } } @@ -877,7 +848,7 @@ void CWindow::SetTrashEvent(bool bTrash) m_bTrashEvent = bTrash; } -bool CWindow::RetTrashEvent() +bool CWindow::GetTrashEvent() { return m_bTrashEvent; } @@ -885,26 +856,26 @@ bool CWindow::RetTrashEvent() // Returns the message from the button "reduce". -EventMsg CWindow::RetEventMsgReduce() +EventType CWindow::GetEventTypeReduce() { if ( m_buttonReduce == 0 ) return EVENT_NULL; - return m_buttonReduce->RetEventMsg(); + return m_buttonReduce->GetEventType(); } // Returns the message from the button "full". -EventMsg CWindow::RetEventMsgFull() +EventType CWindow::GetEventTypeFull() { if ( m_buttonFull == 0 ) return EVENT_NULL; - return m_buttonFull->RetEventMsg(); + return m_buttonFull->GetEventType(); } // Returns the message from the button "close". -EventMsg CWindow::RetEventMsgClose() +EventType CWindow::GetEventTypeClose() { if ( m_buttonClose == 0 ) return EVENT_NULL; - return m_buttonClose->RetEventMsg(); + return m_buttonClose->GetEventType(); } @@ -947,7 +918,7 @@ int CWindow::BorderDetect(Math::Point pos) if ( flags == 0 ) { - h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); dim.y = h*1.2f; dim.x = dim.y*0.75f; if ( pos.x < m_pos.x+m_dim.x-0.01f-dim.x*3.0f && @@ -967,7 +938,7 @@ bool CWindow::EventProcess(const Event &event) Math::Point pos; int i, flags; - if ( event.event == EVENT_MOUSEMOVE ) + if ( event.type == EVENT_MOUSE_MOVE ) { if ( m_bCapture ) { @@ -975,37 +946,37 @@ bool CWindow::EventProcess(const Event &event) } else { - m_pressMouse = D3DMOUSENORM; + m_pressMouse = Gfx::ENG_MOUSE_NORM; - if ( m_name[0] != 0 && m_bMovable && // title bar? + if ( m_name.length() > 0 && m_bMovable && // title bar? Detect(event.pos) ) { flags = BorderDetect(event.pos); if ( flags == -1 ) { - m_pressMouse = D3DMOUSEMOVE; // + + m_pressMouse = Gfx::ENG_MOUSE_MOVE; // + } else if ( ((flags & (1<<0)) && (flags & (1<<3))) || ((flags & (1<<1)) && (flags & (1<<2))) ) { - m_pressMouse = D3DMOUSEMOVEI; // \ // + m_pressMouse = Gfx::ENG_MOUSE_MOVEI; // \ // } else if ( ((flags & (1<<0)) && (flags & (1<<1))) || ((flags & (1<<2)) && (flags & (1<<3))) ) { - m_pressMouse = D3DMOUSEMOVED; // / + m_pressMouse = Gfx::ENG_MOUSE_MOVED; // / } else if ( (flags & (1<<0)) || (flags & (1<<2)) ) { - m_pressMouse = D3DMOUSEMOVEH; // - + m_pressMouse = Gfx::ENG_MOUSE_MOVEH; // - } else if ( (flags & (1<<1)) || (flags & (1<<3)) ) { - m_pressMouse = D3DMOUSEMOVEV; // | + m_pressMouse = Gfx::ENG_MOUSE_MOVEV; // | } } - if ( m_pressMouse != D3DMOUSENORM ) + if ( m_pressMouse != Gfx::ENG_MOUSE_NORM ) { m_engine->SetMouseType(m_pressMouse); } @@ -1039,11 +1010,12 @@ bool CWindow::EventProcess(const Event &event) } } - if ( m_bTrashEvent && event.event == EVENT_LBUTTONDOWN ) + if ( m_bTrashEvent && event.type == EVENT_MOUSE_BUTTON_DOWN && + event.mouseButton.button == 1) { if ( Detect(event.pos) ) { - if ( m_name[0] != 0 && m_bMovable ) // title bar? + if ( m_name.length() > 0 && m_bMovable ) // title bar? { m_pressFlags = BorderDetect(event.pos); if ( m_pressFlags != 0 ) @@ -1056,7 +1028,7 @@ bool CWindow::EventProcess(const Event &event) } } - if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) + if ( event.type == EVENT_MOUSE_MOVE && m_bCapture ) { pos = event.pos; if ( m_pressFlags == -1 ) // all moves? @@ -1105,11 +1077,11 @@ bool CWindow::EventProcess(const Event &event) AdjustButtons(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } - if ( event.event == EVENT_LBUTTONUP && m_bCapture ) + if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 && m_bCapture ) { m_bCapture = false; } @@ -1135,9 +1107,9 @@ void CWindow::Draw() DrawVertex(m_pos, m_dim, m_icon); // draws the background - if ( m_name[0] != 0 ) // title bar? + if ( m_name.length() > 0 ) // title bar? { - h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); // Draws the shadow under the title bar. { @@ -1160,7 +1132,7 @@ void CWindow::Draw() dim.y = h*1.2f; DrawVertex(pos, dim, (m_state&STATE_ENABLE)?2:9); - sw = m_engine->RetText()->RetStringWidth(m_name, strlen(m_name), m_fontSize, m_fontStretch, m_fontType); + sw = m_engine->GetText()->GetStringWidth(m_name, m_fontType, m_fontSize); if ( m_state&STATE_ENABLE ) { @@ -1175,7 +1147,7 @@ void CWindow::Draw() pos.x = m_pos.x+width/2.0f; pos.y = m_pos.y+m_dim.y-0.01f-h*1.10f; - m_engine->RetText()->DrawText(m_name, pos, width, 0, m_fontSize, m_fontStretch, m_fontType, 0); + m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, width, Gfx::TEXT_ALIGN_CENTER, 0); if ( m_buttonReduce != 0 ) { @@ -1214,8 +1186,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) if ( icon == 0 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = 64.0f/256.0f; // dark blue transparent uv1.y = 64.0f/256.0f; uv2.x = 128.0f/256.0f; @@ -1230,8 +1202,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 1 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = 128.0f/256.0f; // yellow tooltip uv1.y = 0.0f/256.0f; uv2.x = 224.0f/256.0f; @@ -1244,8 +1216,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 2 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 128.0f/256.0f; // yellow uv1.y = 16.0f/256.0f; uv2.x = 224.0f/256.0f; @@ -1258,8 +1230,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 3 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 0.0f/256.0f; // transparent blue bar with yellow upper uv1.y = 64.0f/256.0f; uv2.x = 64.0f/256.0f; @@ -1277,8 +1249,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) dim.x += 100.0f/640.0f; dim.y += 60.0f/480.0f; - m_engine->SetTexture("human.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("human.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 140.0f/256.0f; uv1.y = 32.0f/256.0f; uv2.x = 182.0f/256.0f; @@ -1294,8 +1266,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) dim.x -= 20.0f/640.0f; dim.y += 0.0f/480.0f; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTw); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = 192.0f/256.0f; uv1.y = 32.0f/256.0f; uv2.x = 224.0f/256.0f; @@ -1313,8 +1285,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) dim.x -= 20.0f/640.0f; dim.y -= 20.0f/480.0f; - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 64.0f/256.0f; uv1.y = 0.0f/256.0f; uv2.x = 96.0f/256.0f; @@ -1349,7 +1321,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) dim.x -= 20.0f/640.0f; dim.y -= 20.0f/480.0f; - m_engine->SetTexture("button3.tga"); + m_engine->SetTexture("button3.png"); uv1.x = 0.0f/256.0f; uv1.y = 224.0f/256.0f; uv2.x = 32.0f/256.0f; @@ -1360,7 +1332,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); // dark blue background - m_engine->SetTexture("button2.tga"); + m_engine->SetTexture("button2.png"); uv1.x = 224.0f/256.0f; uv1.y = 224.0f/256.0f; uv2.x = 249.0f/256.0f; @@ -1432,8 +1404,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 5 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 64.0f/256.0f; // transparent green uv1.y = 160.0f/256.0f; uv2.x = 160.0f/256.0f; @@ -1446,8 +1418,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 6 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 64.0f/256.0f; // transparent red uv1.y = 176.0f/256.0f; uv2.x = 160.0f/256.0f; @@ -1460,8 +1432,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 7 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 64.0f/256.0f; // transparent blue uv1.y = 192.0f/256.0f; uv2.x = 160.0f/256.0f; @@ -1474,8 +1446,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 8 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 0.0f/256.0f; // opaque orange uv1.y = 0.0f/256.0f; uv2.x = 32.0f/256.0f; @@ -1490,8 +1462,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 9 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 32.0f/256.0f; // opaque gray uv1.y = 32.0f/256.0f; uv2.x = 64.0f/256.0f; @@ -1510,8 +1482,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 11 ) { - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATETTb); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); uv1.x = 64.0f/256.0f; // transparent yellow uv1.y = 224.0f/256.0f; uv2.x = 160.0f/256.0f; @@ -1524,8 +1496,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 12 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 128.0f/256.0f; // dirty opaque gray uv1.y = 128.0f/256.0f; uv2.x = 160.0f/256.0f; @@ -1540,8 +1512,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 13 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 192.0f/256.0f; // dirty opaque blue uv1.y = 128.0f/256.0f; uv2.x = 224.0f/256.0f; @@ -1556,8 +1528,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 14 ) { - m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button1.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 160.0f/256.0f; // dirty opaque red uv1.y = 128.0f/256.0f; uv2.x = 192.0f/256.0f; @@ -1584,8 +1556,8 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim) dp = 0.5f/256.0f; - m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetTexture("button2.png"); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 64.0f/256.0f; // hatching uv1.y = 208.0f/256.0f; uv2.x = 145.0f/256.0f; @@ -1618,3 +1590,4 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim) #endif } +} diff --git a/src/ui/window.h b/src/ui/window.h index 3acf3b4..8d7090c 100644 --- a/src/ui/window.h +++ b/src/ui/window.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,29 +19,34 @@ #pragma once - +#include <string> + +#include "common/event.h" +#include "common/misc.h" +#include "common/restext.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/map.h" +#include "ui/gauge.h" +#include "ui/compass.h" +#include "ui/target.h" #include "ui/control.h" +#include "graphics/engine/text.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; - +namespace Ui { const int MAXWINDOW = 100; @@ -48,65 +54,65 @@ 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(); - - void SetName(char* name); + 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, std::string 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 GetEventTypeReduce(); + EventType GetEventTypeFull(); + EventType GetEventTypeClose(); + + void SetName(std::string name); void SetTrashEvent(bool bTrash); - bool RetTrashEvent(); + bool GetTrashEvent(); void SetPos(Math::Point pos); void SetDim(Math::Point dim); void SetMinDim(Math::Point dim); void SetMaxDim(Math::Point dim); - Math::Point RetMinDim(); - Math::Point RetMaxDim(); + Math::Point GetMinDim(); + Math::Point GetMaxDim(); void SetMovable(bool bMode); - bool RetMovable(); + bool GetMovable(); void SetRedim(bool bMode); - bool RetRedim(); + bool GetRedim(); void SetClosable(bool bMode); - bool RetClosable(); + bool GetClosable(); void SetMaximized(bool bMaxi); - bool RetMaximized(); + bool GetMaximized(); void SetMinimized(bool bMini); - bool RetMinimized(); + bool GetMinimized(); void SetFixed(bool bFix); - bool RetFixed(); + bool GetFixed(); - bool GetTooltip(Math::Point pos, char* name); + bool GetTooltip(Math::Point pos, std::string &name); bool EventProcess(const Event &event); @@ -140,7 +146,8 @@ protected: bool m_bCapture; Math::Point m_pressPos; int m_pressFlags; - D3DMouse m_pressMouse; + Gfx::EngineMouseType m_pressMouse; }; +} |