From 8d4a3ed57915af2acf8b3dcd9a8aec5a75806ca6 Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 18 Aug 2012 21:04:51 +0200 Subject: [PATCH] * wrong enum used for text alignment * wrong event function used --- src/CMakeLists.txt | 8 ++++---- src/ui/interface.cpp | 24 ++++++------------------ src/ui/key.cpp | 8 ++------ src/ui/label.cpp | 12 ++++-------- src/ui/label.h | 1 + src/ui/list.cpp | 18 +++++++----------- src/ui/list.h | 1 + 7 files changed, 25 insertions(+), 47 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8870f21d..a49d371b 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 0398e7fc..6c96501f 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -72,12 +72,8 @@ template 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 de668bc9..0cf74bc7 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 fb5f1d89..c5da2114 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 303b698f..6fe2e311 100644 --- a/src/ui/label.h +++ b/src/ui/label.h @@ -23,6 +23,7 @@ #include #include +#include namespace Ui { diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 9f1d5795..73a48e3e 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 c963203a..2fc5e4d9 100644 --- a/src/ui/list.h +++ b/src/ui/list.h @@ -25,6 +25,7 @@ #include #include +#include #include