From 10b2c562fb7635f9850f1441f08ba8b1a71e31e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Wed, 15 Aug 2012 01:48:49 +0200 Subject: First approach to port 2D UI Interface - changes in src/ui ; be CAREFUL, not every file is changed in a proper way -> bugs - necessary changes in object/robotmain.h and common/misc.h/.cpp in order to compile --- src/ui/color.cpp | 92 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 44 deletions(-) (limited to 'src/ui/color.cpp') diff --git a/src/ui/color.cpp b/src/ui/color.cpp index 1038343..3ba68b3 100644 --- a/src/ui/color.cpp +++ b/src/ui/color.cpp @@ -15,14 +15,16 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include +//#include #include -#include - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/language.h" -#include "old/math3d.h" +//#include + +//#include "common/struct.h" +//#include "old/d3dengine.h" +#include "graphics/engine/engine.h" +#include "graphics/core/device.h" +//#include "common/language.h" +//#include "old/math3d.h" #include "common/event.h" #include "common/misc.h" #include "common/iman.h" @@ -58,18 +60,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 +89,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,14 +99,15 @@ 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) ) { @@ -113,13 +116,13 @@ bool CColor::EventProcess(const Event &event) 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 +135,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; @@ -145,36 +148,37 @@ void CColor::Draw() } m_engine->SetTexture("button1.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); CControl::Draw(); #if _TEEN - color = ::RetColor(m_color); +// color = GetColor(m_color); + color = GetColor(); m_engine->SetTexture("xxx.tga"); // no texture - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); - device = m_engine->RetD3DDevice(); + 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] = 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); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); + vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, 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] = 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); + vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); + vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); + vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); + vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); + device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); m_engine->AddStatisticTriangle(4); #else @@ -183,18 +187,18 @@ void CColor::Draw() 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->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,0x00000000, Math::Point( 0.0f,0.0f)); + vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f,0.0f)); + vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point(0.0f,0.0f)); + vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, 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,18 +209,18 @@ 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; } -- cgit v1.2.3-1-g7c22 From 574c07e388dfd902b6565bc4a5ac9b915c73074e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Sat, 18 Aug 2012 22:56:42 +0200 Subject: Further improvements in UI porting --- src/ui/color.cpp | 57 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'src/ui/color.cpp') diff --git a/src/ui/color.cpp b/src/ui/color.cpp index 3ba68b3..2d463b5 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 @@ -16,7 +17,7 @@ //#include -#include +//#include //#include //#include "common/struct.h" @@ -32,7 +33,7 @@ #include "ui/color.h" - +namespace Ui { const float DELAY1 = 0.4f; const float DELAY2 = 0.1f; @@ -40,7 +41,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; @@ -160,42 +162,42 @@ void CColor::Draw() 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, 0.0f,0.0f); - vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); - vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); - vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); + 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, 0.0f,0.0f); - vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); - vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); + 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 = GetColor(); m_engine->SetTexture("xxx.tga"); // no texture m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); - vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f,0.0f)); - vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f,0.0f)); - vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point(0.0f,0.0f)); - vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f,0.0f)); + vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f)); + vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f)); + vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f)); + vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f)); device = m_engine->GetDevice(); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4); @@ -226,3 +228,4 @@ Gfx::Color CColor::GetColor() } +} -- cgit v1.2.3-1-g7c22 From 01cc0fbc49696a19a56dfdd8359d4bb77e868925 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 11 Sep 2012 12:49:41 +0200 Subject: * latest changes * all files except studio, map and maindialog should compile * did some code cleanup --- src/ui/color.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/ui/color.cpp') diff --git a/src/ui/color.cpp b/src/ui/color.cpp index 2d463b5..c8588b8 100644 --- a/src/ui/color.cpp +++ b/src/ui/color.cpp @@ -16,21 +16,15 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -//#include -//#include -//#include +#include "color.h" -//#include "common/struct.h" -//#include "old/d3dengine.h" -#include "graphics/engine/engine.h" -#include "graphics/core/device.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" namespace Ui { -- cgit v1.2.3-1-g7c22