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/button.cpp | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'src/ui/button.cpp') diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 0147f63..ab2c644 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -15,15 +15,16 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include -#include -#include - -#include "common/struct.h" -#include "old/d3dengine.h" -#include "common/language.h" -#include "old/math3d.h" -#include "common/event.h" +//#include +//#include +//#include + +//#include "common/struct.h" +//#include "old/d3dengine.h" +#include "graphics/engine/engine.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" @@ -55,18 +56,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 +86,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,14 +96,15 @@ 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) ) { @@ -114,25 +116,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 ( !m_bImmediat && !m_bRepeat ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } } @@ -182,7 +186,7 @@ void CButton::Draw() (m_state & STATE_SIMPLY) == 0 ) { m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); dp = 0.5f/256.0f; @@ -225,7 +229,7 @@ void CButton::SetImmediat(bool bImmediat) m_bImmediat = bImmediat; } -bool CButton::RetImmediat() +bool CButton::GetImmediat() { return m_bImmediat; } @@ -239,7 +243,7 @@ void CButton::SetRepeat(bool bRepeat) m_bRepeat = bRepeat; } -bool CButton::RetRepeat() +bool CButton::GetRepeat() { return m_bRepeat; } -- 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/button.cpp | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'src/ui/button.cpp') diff --git a/src/ui/button.cpp b/src/ui/button.cpp index ab2c644..1f11a0c 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 @@ -24,22 +25,22 @@ #include "graphics/engine/engine.h" //#include "common/language.h" //#include "old/math3d.h" -//#include "common/event.h" +#include "common/event.h" #include "common/misc.h" #include "common/iman.h" #include "common/restext.h" #include "ui/button.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; @@ -162,10 +163,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); @@ -188,17 +189,17 @@ void CButton::Draw() m_engine->SetTexture("button2.tga"); 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; @@ -206,15 +207,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 @@ -248,3 +249,4 @@ bool CButton::GetRepeat() return m_bRepeat; } +} -- cgit v1.2.3-1-g7c22 From 6ba0f42f22a170625f15879e01b4653a4ac153a1 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 31 Aug 2012 22:28:07 +0200 Subject: latest changes; few more classes should compile now --- src/ui/button.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/ui/button.cpp') diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 1f11a0c..60c76b3 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -16,20 +16,8 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -//#include -//#include -//#include - -//#include "common/struct.h" -//#include "old/d3dengine.h" -#include "graphics/engine/engine.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/button.h" + +#include namespace Ui { -- 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/button.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ui/button.cpp') diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 60c76b3..b8934c4 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -17,7 +17,13 @@ -#include +#include "button.h" + +#include +#include +#include + +#include namespace Ui { -- cgit v1.2.3-1-g7c22