summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorerihel <erihel@gmail.com>2012-08-18 21:04:51 +0200
committererihel <erihel@gmail.com>2012-08-18 21:04:51 +0200
commit8d4a3ed57915af2acf8b3dcd9a8aec5a75806ca6 (patch)
treeffee78fc822604f9c5c3ab468c8da04862f31283 /src
parent48ad79a03c12b923dfdb3795a2138445859cf779 (diff)
downloadcolobot-8d4a3ed57915af2acf8b3dcd9a8aec5a75806ca6.tar.gz
colobot-8d4a3ed57915af2acf8b3dcd9a8aec5a75806ca6.tar.bz2
colobot-8d4a3ed57915af2acf8b3dcd9a8aec5a75806ca6.zip
* wrong enum used for text alignment
* wrong event function used
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt8
-rw-r--r--src/ui/interface.cpp24
-rw-r--r--src/ui/key.cpp8
-rw-r--r--src/ui/label.cpp12
-rw-r--r--src/ui/label.h1
-rw-r--r--src/ui/list.cpp18
-rw-r--r--src/ui/list.h1
7 files changed, 25 insertions, 47 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8870f21..a49d371 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -61,9 +61,9 @@ common/image.cpp
common/logger.cpp
common/iman.cpp
# common/metafile.cpp
-common/misc.cpp
+# common/misc.cpp
# common/modfile.cpp
-common/profile.cpp
+# common/profile.cpp
# common/restext.cpp
common/stringutils.cpp
graphics/core/color.cpp
@@ -149,7 +149,7 @@ graphics/opengl/gldevice.cpp
# ui/check.cpp
# ui/color.cpp
# ui/compass.cpp
-ui/control.cpp
+# ui/control.cpp
# ui/displayinfo.cpp
# ui/displaytext.cpp
# ui/edit.cpp
@@ -159,7 +159,7 @@ ui/control.cpp
# ui/image.cpp
# ui/interface.cpp
# ui/key.cpp
-ui/label.cpp
+# ui/label.cpp
# ui/list.cpp
# ui/maindialog.cpp
# ui/mainmap.cpp
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 0398e7f..6c96501 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -72,12 +72,8 @@ template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math:
{
T* pc;
int index;
- Event event;
-
- if (eventMsg == EVENT_NULL) {
- m_event->GetEvent(event);
- eventMsg = event.type;
- }
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
if ((index = GetNextFreeControl()) < 0)
return nullptr;
@@ -95,12 +91,8 @@ CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, E
{
CWindow* pc;
int index;
- Event event;
-
- if (eventMsg == EVENT_NULL) {
- m_event->GetEvent(event);
- eventMsg = event.type;
- }
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
switch (eventMsg) {
case EVENT_WINDOW0: index = 0; break;
@@ -212,12 +204,8 @@ CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventT
{
CList* pc;
int index;
- Event event;
-
- if (eventMsg == EVENT_NULL) {
- m_event->GetEvent(event);
- eventMsg = event.type;
- }
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
if ((index = GetNextFreeControl()) < 0)
return nullptr;
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index de668bc..0cf74bc 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -59,12 +59,8 @@ CKey::~CKey()
bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
char name[100];
- Event event;
-
- if (eventMsg == EVENT_NULL) {
- m_event->GetEvent(event);
- eventMsg = event.type;
- }
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
GetResource(RES_EVENT, eventMsg, name);
diff --git a/src/ui/label.cpp b/src/ui/label.cpp
index fb5f1d8..c5da211 100644
--- a/src/ui/label.cpp
+++ b/src/ui/label.cpp
@@ -40,12 +40,8 @@ CLabel::~CLabel()
bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- Event event;
-
- if (eventMsg == EVENT_NULL) {
- m_event->GetEvent(event);
- eventMsg = event.type;
- }
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
return true;
@@ -73,9 +69,9 @@ void CLabel::Draw()
pos.y = m_pos.y + m_dim.y / 2.0f;
switch (m_textAlign) {
- case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x; break;
+ case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x; break;
case Gfx::TEXT_ALIGN_CENTER: pos.x = m_pos.x + m_dim.x / 2.0f; break;
- case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x + m_dim.x; break;
+ case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x + m_dim.x; break;
}
m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
diff --git a/src/ui/label.h b/src/ui/label.h
index 303b698..6fe2e31 100644
--- a/src/ui/label.h
+++ b/src/ui/label.h
@@ -23,6 +23,7 @@
#include <ui/control.h>
#include <common/event.h>
+#include <common/misc.h>
namespace Ui {
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index 9f1d579..73a48e3 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -42,7 +42,7 @@ CList::CList() : CControl()
for (int i = 0; i < 10; i++) {
m_tabs[i] = 0.0f;
- m_justifs[i] = Gfx::TEXT_ALIGN_CENTER;
+ m_justifs[i] = Gfx::TEXT_ALIGN_RIGHT;
}
m_totalLine = 0;
@@ -72,14 +72,10 @@ CList::~CList()
bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand)
{
- Event event;
m_expand = expand;
- if (eventMsg == EVENT_NULL) {
- m_event->GetEvent(event);
- eventMsg = event.type;
- }
-
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
@@ -131,7 +127,7 @@ bool CList::MoveAdjust()
for (int i = 0; i < m_displayLine; i++) {
m_button[i] = new CButton();
m_button[i]->Create(ppos, ddim, -1, EVENT_NULL);
- m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_CENTER);
+ m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT);
m_button[i]->SetState(STATE_SIMPLY);
m_button[i]->SetFontType(m_fontType);
m_button[i]->SetFontSize(m_fontSize);
@@ -417,7 +413,7 @@ void CList::Draw()
ppos.y = pos.y + dim.y * 0.5f;
ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
ddim.x = dim.x-dim.y;
- DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_CENTER);
+ DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_RIGHT);
} else {
ppos.x = pos.x + dim.y * 0.5f;
ppos.y = pos.y + dim.y * 0.5f;
@@ -505,9 +501,9 @@ void CList::Draw()
void CList::DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif)
{
- if (justif == Gfx::TEXT_ALIGN_LEFT)
+ if (justif == Gfx::TEXT_ALIGN_CENTER)
pos.x += width / 2.0f;
- else
+ else if (justif == Gfx::TEXT_ALIGN_LEFT)
pos.x += width;
m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, width, justif, 0);
}
diff --git a/src/ui/list.h b/src/ui/list.h
index c963203..2fc5e4d 100644
--- a/src/ui/list.h
+++ b/src/ui/list.h
@@ -25,6 +25,7 @@
#include <ui/scroll.h>
#include <common/event.h>
+#include <common/misc.h>
#include <graphics/engine/text.h>