summaryrefslogtreecommitdiffstats
path: root/src/ui/color.cpp
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-06-26 22:23:05 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-06-26 22:23:05 +0200
commitebed57aa22b772211387a5561f995eee8f5faed1 (patch)
tree9a0b08371df54c125957e63c7ecff81c001d4eaf /src/ui/color.cpp
parentfc5389d18816799ba2698914384cd099ba8a7a6c (diff)
downloadcolobot-ebed57aa22b772211387a5561f995eee8f5faed1.tar.gz
colobot-ebed57aa22b772211387a5561f995eee8f5faed1.tar.bz2
colobot-ebed57aa22b772211387a5561f995eee8f5faed1.zip
Whitespace and language change
- changed tabs to spaces and DOS line endings to Unix (except in CBot and metafile) - changed language to English - fixed #include <d3d.h> in d3dengine.h
Diffstat (limited to 'src/ui/color.cpp')
-rw-r--r--src/ui/color.cpp448
1 files changed, 224 insertions, 224 deletions
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index 69513af..1038343 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.cpp
@@ -1,224 +1,224 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * 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
-// * (at your option) any later version.
-// *
-// * 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
-// * GNU General Public License for more details.
-// *
-// * 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 <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/iman.h"
-#include "common/restext.h"
-#include "ui/color.h"
-
-
-
-const float DELAY1 = 0.4f;
-const float DELAY2 = 0.1f;
-
-
-
-// Object's constructor.
-
-CColor::CColor(CInstanceManager* iMan) : CControl(iMan)
-{
- m_bRepeat = false;
- m_repeat = 0.0f;
-
- m_color.r = 0.0f;
- m_color.g = 0.0f;
- m_color.b = 0.0f;
- m_color.a = 0.0f;
-}
-
-// Object's destructor.
-
-CColor::~CColor()
-{
-}
-
-
-// Creates a new button.
-
-bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
-{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- CControl::Create(pos, dim, icon, eventMsg);
-
- if ( icon == -1 )
- {
- char name[100];
- char* p;
-
- GetResource(RES_EVENT, eventMsg, name);
- p = strchr(name, '\\');
- if ( p != 0 ) *p = 0;
- SetName(name);
- }
-
- return true;
-}
-
-
-// Management of an event.
-
-bool CColor::EventProcess(const Event &event)
-{
- if ( m_state & STATE_DEAD ) return true;
-
- CControl::EventProcess(event);
-
- if ( event.event == EVENT_FRAME && m_bRepeat )
- {
- if ( m_repeat != 0.0f )
- {
- m_repeat -= event.rTime;
- if ( m_repeat <= 0.0f )
- {
- m_repeat = DELAY2;
-
- Event newEvent = event;
- newEvent.event = m_eventMsg;
- m_event->AddEvent(newEvent);
- return false;
- }
- }
- }
-
- if ( event.event == EVENT_LBUTTONDOWN &&
- (m_state & STATE_VISIBLE) &&
- (m_state & STATE_ENABLE) )
- {
- if ( CControl::Detect(event.pos) )
- {
- m_repeat = DELAY1;
-
- Event newEvent = event;
- newEvent.event = m_eventMsg;
- m_event->AddEvent(newEvent);
- return false;
- }
- }
-
- if ( event.event == EVENT_LBUTTONUP )
- {
- m_repeat = 0.0f;
- }
-
- return true;
-}
-
-
-// Dessine le bouton.
-
-void CColor::Draw()
-{
- LPDIRECT3DDEVICE7 device;
- D3DLVERTEX vertex[4]; // 2 triangles
- D3DCOLOR color;
- Math::Point p1, p2;
-
- if ( (m_state & STATE_VISIBLE) == 0 ) return;
-
- if ( m_state & STATE_SHADOW )
- {
- DrawShadow(m_pos, m_dim);
- }
-
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
- 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);
-
- 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);
-
- color = ::RetColor(m_color);
-
- m_engine->SetTexture("xxx.tga"); // no texture
- m_engine->SetState(D3DSTATENORMAL);
-
- 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 = m_engine->RetD3DDevice();
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL);
- m_engine->AddStatisticTriangle(2);
-#endif
-}
-
-
-void CColor::SetRepeat(bool bRepeat)
-{
- m_bRepeat = bRepeat;
-}
-
-bool CColor::RetRepeat()
-{
- return m_bRepeat;
-}
-
-
-void CColor::SetColor(D3DCOLORVALUE color)
-{
- m_color = color;
-}
-
-D3DCOLORVALUE CColor::RetColor()
-{
- return m_color;
-}
-
-
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// *
+// * 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
+// * (at your option) any later version.
+// *
+// * 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
+// * GNU General Public License for more details.
+// *
+// * 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 <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/iman.h"
+#include "common/restext.h"
+#include "ui/color.h"
+
+
+
+const float DELAY1 = 0.4f;
+const float DELAY2 = 0.1f;
+
+
+
+// Object's constructor.
+
+CColor::CColor(CInstanceManager* iMan) : CControl(iMan)
+{
+ m_bRepeat = false;
+ m_repeat = 0.0f;
+
+ m_color.r = 0.0f;
+ m_color.g = 0.0f;
+ m_color.b = 0.0f;
+ m_color.a = 0.0f;
+}
+
+// Object's destructor.
+
+CColor::~CColor()
+{
+}
+
+
+// Creates a new button.
+
+bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+{
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+
+ CControl::Create(pos, dim, icon, eventMsg);
+
+ if ( icon == -1 )
+ {
+ char name[100];
+ char* p;
+
+ GetResource(RES_EVENT, eventMsg, name);
+ p = strchr(name, '\\');
+ if ( p != 0 ) *p = 0;
+ SetName(name);
+ }
+
+ return true;
+}
+
+
+// Management of an event.
+
+bool CColor::EventProcess(const Event &event)
+{
+ if ( m_state & STATE_DEAD ) return true;
+
+ CControl::EventProcess(event);
+
+ if ( event.event == EVENT_FRAME && m_bRepeat )
+ {
+ if ( m_repeat != 0.0f )
+ {
+ m_repeat -= event.rTime;
+ if ( m_repeat <= 0.0f )
+ {
+ m_repeat = DELAY2;
+
+ Event newEvent = event;
+ newEvent.event = m_eventMsg;
+ m_event->AddEvent(newEvent);
+ return false;
+ }
+ }
+ }
+
+ if ( event.event == EVENT_LBUTTONDOWN &&
+ (m_state & STATE_VISIBLE) &&
+ (m_state & STATE_ENABLE) )
+ {
+ if ( CControl::Detect(event.pos) )
+ {
+ m_repeat = DELAY1;
+
+ Event newEvent = event;
+ newEvent.event = m_eventMsg;
+ m_event->AddEvent(newEvent);
+ return false;
+ }
+ }
+
+ if ( event.event == EVENT_LBUTTONUP )
+ {
+ m_repeat = 0.0f;
+ }
+
+ return true;
+}
+
+
+// Dessine le bouton.
+
+void CColor::Draw()
+{
+ LPDIRECT3DDEVICE7 device;
+ D3DLVERTEX vertex[4]; // 2 triangles
+ D3DCOLOR color;
+ Math::Point p1, p2;
+
+ if ( (m_state & STATE_VISIBLE) == 0 ) return;
+
+ if ( m_state & STATE_SHADOW )
+ {
+ DrawShadow(m_pos, m_dim);
+ }
+
+ m_engine->SetTexture("button1.tga");
+ m_engine->SetState(D3DSTATENORMAL);
+ 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);
+
+ 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);
+
+ color = ::RetColor(m_color);
+
+ m_engine->SetTexture("xxx.tga"); // no texture
+ m_engine->SetState(D3DSTATENORMAL);
+
+ 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 = m_engine->RetD3DDevice();
+ device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL);
+ m_engine->AddStatisticTriangle(2);
+#endif
+}
+
+
+void CColor::SetRepeat(bool bRepeat)
+{
+ m_bRepeat = bRepeat;
+}
+
+bool CColor::RetRepeat()
+{
+ return m_bRepeat;
+}
+
+
+void CColor::SetColor(D3DCOLORVALUE color)
+{
+ m_color = color;
+}
+
+D3DCOLORVALUE CColor::RetColor()
+{
+ return m_color;
+}
+
+