From 479a67a731be5a5e8035ea7acce0344c7c605814 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Mon, 10 Sep 2012 23:29:38 +0200 Subject: Merge with changes from Zaba999 fork. --- src/ui/scroll.cpp | 82 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'src/ui/scroll.cpp') diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 051de8d..b54c868 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 @@ -17,13 +18,14 @@ // scroll.cpp -#include -#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 "graphics/engine/engine.h" #include "common/event.h" #include "common/misc.h" #include "common/iman.h" @@ -31,11 +33,11 @@ #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 +63,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 +104,20 @@ void CScroll::MoveAdjust() { if ( m_buttonUp == 0 ) { - m_buttonUp = new CButton(m_iMan); + m_buttonUp = new CButton(); pc = (CButton*)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); + m_buttonDown = new CButton(); pc = (CButton*)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,31 +215,32 @@ 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) ) { @@ -258,7 +261,7 @@ bool CScroll::EventProcess(const Event &event) AdjustGlint(); Event newEvent = event; - newEvent.event = m_eventMsg; + newEvent.type = m_eventType; m_event->AddEvent(newEvent); } m_bCapture = true; @@ -267,7 +270,7 @@ bool CScroll::EventProcess(const Event &event) } } - 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 ) @@ -282,33 +285,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) && + if ( event.type == EVENT_KEY_DOWN && + event.mouseButton.button == 4 && + Detect(event.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) && + if ( event.type == EVENT_KEY_DOWN && + event.mouseButton.button == 5 && + Detect(event.pos) && m_buttonDown != 0 ) { Event newEvent = event; - newEvent.event = m_buttonDown->RetEventMsg(); + newEvent.type = m_buttonDown->GetEventType(); m_event->AddEvent(newEvent); } @@ -381,7 +386,7 @@ 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->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; @@ -391,7 +396,7 @@ 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->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; @@ -401,7 +406,7 @@ 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->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; @@ -411,7 +416,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) else { m_engine->SetTexture("button2.tga"); - m_engine->SetState(D3DSTATENORMAL); + 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 +442,7 @@ void CScroll::SetVisibleValue(float value) AdjustGlint(); } -float CScroll::RetVisibleValue() +float CScroll::GetVisibleValue() { return m_visibleValue; } @@ -451,7 +456,7 @@ void CScroll::SetVisibleRatio(float value) AdjustGlint(); } -float CScroll::RetVisibleRatio() +float CScroll::GetVisibleRatio() { return m_visibleRatio; } @@ -462,8 +467,9 @@ void CScroll::SetArrowStep(float step) m_step = step; } -float CScroll::RetArrowStep() +float CScroll::GetArrowStep() { return m_step; } +} -- cgit v1.2.3-1-g7c22 From 6a0d150539897ec65ccc161305db48de10ea35ba Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Sep 2012 10:38:08 +0200 Subject: Interface works - removed mock of CInterface and fixed event passing to CRobotMain - changed texture names from tga and bmp to png - UI now works but interaction is still broken --- src/ui/scroll.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui/scroll.cpp') diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 86595f9..21f8158 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -379,7 +379,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) if ( icon == 0 ) { - m_engine->SetTexture("button2.tga"); + 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; @@ -389,7 +389,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 1 ) { - m_engine->SetTexture("button2.tga"); + 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; @@ -399,7 +399,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else if ( icon == 2 ) { - m_engine->SetTexture("button1.tga"); + 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; @@ -409,7 +409,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon) } else { - m_engine->SetTexture("button2.tga"); + 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; -- cgit v1.2.3-1-g7c22 From 36ae984ac77c5545d3d11dde7e37913a8eff0b0d Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Tue, 18 Sep 2012 22:33:28 +0200 Subject: Warnings cleaned, left only those connected to commented out code. --- src/ui/scroll.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui/scroll.cpp') diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 21f8158..41240ca 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -99,7 +99,7 @@ void CScroll::MoveAdjust() if ( m_buttonUp == 0 ) { m_buttonUp = new CButton(); - pc = (CButton*)m_buttonUp; + 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->GetEventType(); @@ -108,7 +108,7 @@ void CScroll::MoveAdjust() if ( m_buttonDown == 0 ) { m_buttonDown = new CButton(); - pc = (CButton*)m_buttonDown; + 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->GetEventType(); @@ -345,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(dim.y*0.8f/0.012f); if ( n < 1 ) n = 1; if ( n > 5 ) n = 5; -- cgit v1.2.3-1-g7c22 From 1a79137e904eb07c17df2596e6b8aa9310ff22bd Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 19 Sep 2012 21:45:41 +0200 Subject: Mouse wheel fixes --- src/ui/scroll.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ui/scroll.cpp') diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 41240ca..38379a5 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -292,19 +292,19 @@ bool CScroll::EventProcess(const Event &event) m_bCapture = false; } - if ( event.type == EVENT_KEY_DOWN && - event.mouseButton.button == 4 && - 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.type = m_buttonUp->GetEventType(); m_event->AddEvent(newEvent); } - if ( event.type == EVENT_KEY_DOWN && - event.mouseButton.button == 5 && - 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.type = m_buttonDown->GetEventType(); -- cgit v1.2.3-1-g7c22 From 57d33d79ea570773d84ad81d4a61f50e079979ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Wed, 19 Sep 2012 22:17:28 +0200 Subject: Changes in Ui, solves part of #47 --- src/ui/scroll.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ui/scroll.cpp') diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 38379a5..d3d0ed2 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -238,17 +238,17 @@ bool CScroll::EventProcess(const Event &event) (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; @@ -259,7 +259,7 @@ bool CScroll::EventProcess(const Event &event) m_event->AddEvent(newEvent); } m_bCapture = true; - m_pressPos = event.pos; + m_pressPos = event.mouseButton.pos; m_pressValue = m_visibleValue; } } @@ -269,7 +269,7 @@ bool CScroll::EventProcess(const Event &event) 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; -- cgit v1.2.3-1-g7c22