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/gauge.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/ui/gauge.cpp') diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index 13cd4f7..a4571da 100644 --- a/src/ui/gauge.cpp +++ b/src/ui/gauge.cpp @@ -17,13 +17,13 @@ // gauge.cpp -#include +//#include #include -#include +//#include -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/math3d.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" @@ -48,11 +48,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 +63,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) ) { Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); return false; } @@ -88,7 +88,7 @@ void CGauge::Draw() if ( (m_state & STATE_VISIBLE) == 0 ) return; m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); dp = 0.5f/256.0f; @@ -149,7 +149,7 @@ void CGauge::SetLevel(float level) m_level = level; } -float CGauge::RetLevel() +float CGauge::GetLevel() { return m_level; } -- 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/gauge.cpp | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/ui/gauge.cpp') diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index a4571da..cc4eca0 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 @@ -18,11 +19,12 @@ //#include -#include +//#include //#include //#include "common/struct.h" //#include "old/d3dengine.h" +#include "graphics/engine/engine.h" //#include "old/math3d.h" #include "common/event.h" #include "common/misc.h" @@ -31,10 +33,11 @@ - +namespace Ui { // Object's constructor. -CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan) +//CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan) +CGauge::CGauge() : CControl() { m_level = 0.0f; } @@ -95,40 +98,40 @@ void CGauge::Draw() 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; @@ -155,3 +158,4 @@ float CGauge::GetLevel() } +} -- 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/gauge.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src/ui/gauge.cpp') diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index cc4eca0..20904f7 100644 --- a/src/ui/gauge.cpp +++ b/src/ui/gauge.cpp @@ -18,19 +18,7 @@ // gauge.cpp -//#include -//#include -//#include - -//#include "common/struct.h" -//#include "old/d3dengine.h" -#include "graphics/engine/engine.h" -//#include "old/math3d.h" -#include "common/event.h" -#include "common/misc.h" -#include "common/iman.h" -#include "ui/gauge.h" - +#include namespace Ui { -- cgit v1.2.3-1-g7c22