summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerihel <erihel@gmail.com>2012-08-31 22:28:07 +0200
committererihel <erihel@gmail.com>2012-08-31 22:28:07 +0200
commit6ba0f42f22a170625f15879e01b4653a4ac153a1 (patch)
tree129478ed8c5e4fd167c7c77c8ce00b88c5a4f83b
parent5408fe92527a4df01e4d66a2cdfdbbbea5738afc (diff)
downloadcolobot-6ba0f42f22a170625f15879e01b4653a4ac153a1.tar.gz
colobot-6ba0f42f22a170625f15879e01b4653a4ac153a1.tar.bz2
colobot-6ba0f42f22a170625f15879e01b4653a4ac153a1.zip
latest changes; few more classes should compile now
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/common/misc.cpp2
-rw-r--r--src/common/misc.h2
-rw-r--r--src/ui/button.cpp16
-rw-r--r--src/ui/button.h12
-rw-r--r--src/ui/control.cpp104
-rw-r--r--src/ui/control.h44
-rw-r--r--src/ui/edit.cpp217
-rw-r--r--src/ui/edit.h42
-rw-r--r--src/ui/gauge.cpp14
-rw-r--r--src/ui/gauge.h33
-rw-r--r--src/ui/interface.cpp4
-rw-r--r--src/ui/interface.h5
-rw-r--r--src/ui/key.cpp2
-rw-r--r--src/ui/studio.cpp196
-rw-r--r--src/ui/studio.h165
-rw-r--r--src/ui/target.cpp4
-rw-r--r--src/ui/target.h3
-rw-r--r--src/ui/window.cpp84
-rw-r--r--src/ui/window.h34
20 files changed, 446 insertions, 541 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a49d371..c3b460c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -149,10 +149,10 @@ 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
+ui/edit.cpp
# ui/editvalue.cpp
# ui/gauge.cpp
# ui/group.cpp
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index d4805e6..747c66d 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -381,7 +381,7 @@ void UserDir(bool bUser, char* dir)
// def = "abc\"
// out: buffer = "abc\toto.txt"
-void UserDir(char* buffer, char* dir, char* def)
+void UserDir(char* buffer, const char* dir, const char* def)
{
char ddir[100];
char* add;
diff --git a/src/common/misc.h b/src/common/misc.h
index bb4bf1f..0001332 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -231,7 +231,7 @@ extern bool CopyFileToTemp(char* filename);
extern bool CopyFileListToTemp(char* filename, int* list, int total);
extern void AddExt(char* filename, char* ext);
extern void UserDir(bool bUser, char* dir);
-extern void UserDir(char* buffer, char* dir, char* def);
+extern void UserDir(char* buffer, const char* dir, const char* def);
extern char GetLanguageLetter();
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index 1f11a0c..60c76b3 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.cpp
@@ -16,20 +16,8 @@
// * 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 "graphics/engine/engine.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/button.h"
+
+#include <ui/button.h>
namespace Ui {
diff --git a/src/ui/button.h b/src/ui/button.h
index 924a4d8..789b51c 100644
--- a/src/ui/button.h
+++ b/src/ui/button.h
@@ -20,13 +20,17 @@
#pragma once
-#include "ui/control.h"
+#include <ui/control.h>
+
+#include <graphics/engine/engine.h>
+
+#include <common/event.h>
+#include <common/misc.h>
+#include <common/restext.h>
-namespace Gfx{
-class CEngine;
-}
namespace Ui {
+
class CButton : public CControl
{
public:
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 37392d7..59e9f00 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -16,28 +16,7 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-//#include <windows.h>
-#include <stdio.h>
-//#include <d3d.h>
-
-#include "graphics/core/device.h"
-//#include "common/struct.h"
-//#include "old/d3dengine.h"
-#include "graphics/engine/engine.h"
-#include "common/language.h"
-#include "common/restext.h"
-//#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "object/robotmain.h"
-//#include "old/particule.h"
-#include "graphics/engine/particle.h"
-#include "common/iman.h"
-//#include "old/text.h"
-#include "graphics/engine/text.h"
-//#include "old/sound.h"
-#include "sound/sound.h"
-#include "ui/control.h"
+#include <ui/control.h>
@@ -60,8 +39,6 @@ CControl::CControl()
m_fontType = Gfx::FONT_COLOBOT;
m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
// m_justif = 0;
- m_name[0] = 0;
- m_tooltip[0] = 0;
m_bFocus = false;
m_bCapture = false;
@@ -84,10 +61,11 @@ CControl::~CControl()
bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- char text[100];
- char* p;
+ char text[100];
+ std::string str_text;
- if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
+ if ( eventType == EVENT_NULL )
+ eventType = GetUniqueEventType();
m_pos = pos;
m_dim = dim;
@@ -99,17 +77,13 @@ bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType even
GlintCreate(pos);
GetResource(RES_EVENT, m_eventType, text);
- p = strchr(text, '\\');
- if ( p == 0 )
- {
+ str_text = std::string(text);
+ auto p = str_text.find("\\");
+ if ( p == std::string::npos ) {
if ( icon != -1 )
- {
- strcpy(m_tooltip, text);
- }
- }
- else
- {
- strcpy(m_tooltip, p+1); // text after "\\"
+ m_tooltip = str_text;
+ } else {
+ m_tooltip = str_text.substr(p + 1);
}
return true;
@@ -202,41 +176,21 @@ int CControl::GetIcon()
// Management of the button name.
-void CControl::SetName(char* name, bool bTooltip)
+void CControl::SetName(std::string name, bool bTooltip)
{
- char* p;
-
- if ( bTooltip )
- {
- p = strchr(name, '\\');
- if ( p == 0 )
- {
- strncpy(m_name, name, 100);
- m_name[100-1] = 0;
+ if ( bTooltip ) {
+ auto p = name.find("\\");
+ if ( p == std::string::npos )
+ m_name = name;
+ else {
+ m_tooltip = name.substr(p + 1);
+ m_name = name.substr(0, p);
}
- else
- {
- char buffer[100];
-
- strncpy(m_tooltip, p+1, 100); // text after "\\"
- m_tooltip[100-1] = 0;
-
- strncpy(buffer, name, 100);
- buffer[100-1] = 0;
- p = strchr(buffer, '\\');
- if ( p != 0 ) *p = 0;
- strncpy(m_name, buffer, 100);
- m_name[100-1] = 0;
- }
- }
- else
- {
- strncpy(m_name, name, 100);
- m_name[100-1] = 0;
- }
+ } else
+ m_name = name;
}
-char* CControl::GetName()
+std::string CControl::GetName()
{
return m_name;
}
@@ -298,21 +252,21 @@ Gfx::FontType CControl::GetFontType()
// Specifies the tooltip.
-bool CControl::SetTooltip(char* name)
+bool CControl::SetTooltip(std::string name)
{
- strcpy(m_tooltip, name);
+ m_tooltip = name;
return true;
}
-bool CControl::GetTooltip(Math::Point pos, char* name)
+bool CControl::GetTooltip(Math::Point pos, std::string &name)
{
- if ( m_tooltip[0] == 0 ) return false;
- if ( (m_state & STATE_VISIBLE) == 0 ) return false;
+ if ( m_tooltip.length() == 0 ) return false;
+ if ( (m_state & STATE_VISIBLE) == 0 ) return false;
if ( (m_state & STATE_ENABLE) == 0 ) return false;
if ( m_state & STATE_DEAD ) return false;
if ( !Detect(pos) ) return false;
- strcpy(name, m_tooltip);
+ name = m_tooltip;
return true;
}
@@ -454,7 +408,7 @@ void CControl::GlintFrame(const Event &event)
(m_state & STATE_ENABLE ) == 0 ||
(m_state & STATE_VISIBLE) == 0 ) return;
- if ( !m_main->RetGlint() ) return;
+ if ( !m_main->GetGlint() ) return;
m_glintProgress += event.rTime;
diff --git a/src/ui/control.h b/src/ui/control.h
index 13cf998..b16a324 100644
--- a/src/ui/control.h
+++ b/src/ui/control.h
@@ -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,25 +19,28 @@
#pragma once
+#include <string>
-//#include "old/text.h"
-#include "graphics/engine/text.h"
-//#include "common/struct.h"
-#include "common/event.h"
+#include <graphics/core/device.h>
+#include <graphics/engine/engine.h>
+#include <graphics/engine/particle.h>
+#include <graphics/engine/text.h>
+
+#include <common/language.h>
+#include <common/restext.h>
+#include <common/event.h>
+#include <common/misc.h>
+#include <common/iman.h>
+
+#include <object/robotmain.h>
+
+#include <sound/sound.h>
-namespace Gfx {
-class CEngine;
-class CParticle;
-};
-class CInstanceManager;
-class CEvent;
-//class Gfx::CEngine;
-class CRobotMain;
-//class Gfx::CParticle;
-class CSoundInterface;
namespace Ui {
+
+
enum ControlState
{
STATE_ENABLE = (1<<0), // active
@@ -82,8 +86,8 @@ public:
virtual int GetState();
virtual void SetIcon(int icon);
virtual int GetIcon();
- virtual void SetName(const char* name, bool bTooltip=true);
- virtual char* GetName();
+ virtual void SetName(std::string name, bool bTooltip=true);
+ virtual std::string GetName();
virtual void SetTextAlign(Gfx::TextAlign mode);
virtual int GetTextAlign();
virtual void SetFontSize(float size);
@@ -92,8 +96,8 @@ public:
virtual float GetFontStretch();
virtual void SetFontType(Gfx::FontType font);
virtual Gfx::FontType GetFontType();
- virtual bool SetTooltip(char* name);
- virtual bool GetTooltip(Math::Point pos, char* name);
+ virtual bool SetTooltip(std::string name);
+ virtual bool GetTooltip(Math::Point pos, std::string &name);
virtual void SetFocus(bool bFocus);
virtual bool GetFocus();
@@ -130,8 +134,8 @@ protected:
Gfx::FontType m_fontType; // type of font
Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
// int m_justif; // type of justification (-1,0,1)
- char m_name[100]; // name of the button
- char m_tooltip[100]; // name of tooltip
+ std::string m_name; // name of the button
+ std::string m_tooltip; // name of tooltip
bool m_bFocus;
bool m_bCapture;
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 86f0011..2052356 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -18,26 +18,7 @@
// edit.cpp
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-//#include <windows.h>
-//#include <d3d.h>
-
-//#include "common/struct.h"
-//#include "old/d3dengine.h"
-#include "graphics/engine/engine.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/scroll.h"
-//#include "old/text.h"
-#include "graphics/engine/text.h"
-//#include "graphics/engine/color.h"
-#include "ui/edit.h"
+#include <ui/edit.h>
namespace Ui {
@@ -96,9 +77,9 @@ CEdit::CEdit () : CControl ()
int i;
m_maxChar = 100;
- m_text = new char* [sizeof(char)*(m_maxChar+1)]; // TODO
- m_format = 0;
+ m_text = new char[sizeof(char)*(m_maxChar+1)];
m_len = 0;
+ m_app = CApplication::GetInstancePointer();
m_fontType = Gfx::FONT_COURIER;
m_scroll = 0;
@@ -139,7 +120,6 @@ CEdit::~CEdit()
}
delete m_text;
- delete m_format;
delete m_scroll;
}
@@ -565,7 +545,7 @@ bool CEdit::IsLinkPos(Math::Point pos)
{
int i;
- if ( m_format == 0 ) return false;
+ if ( m_format.size() == 0 ) return false;
i = MouseDetect(pos);
if ( i == -1 ) return false;
@@ -645,7 +625,7 @@ void CEdit::MouseRelease(Math::Point mouse)
if ( !m_bEdit )
{
- if ( m_format != 0 && i < m_len && m_cursor1 == m_cursor2 &&
+ if ( m_format.size() > 0 && i < m_len && m_cursor1 == m_cursor2 &&
(m_format[i]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) //TODO
{
rank = -1;
@@ -712,7 +692,7 @@ int CEdit::MouseDetect(Math::Point mouse)
pos.y = m_pos.y+m_dim.y-m_lineHeight-(m_bMulti?MARGY:MARGY1);
for ( i=m_lineFirst ; i<m_lineTotal ; i++ )
{
- bTitle = ( m_format != 0 && (m_format[m_lineOffset[i]]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG );
+ bTitle = ( m_format.size() > 0 && (m_format[m_lineOffset[i]]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG );
if ( i >= m_lineFirst+m_lineVisible ) break;
@@ -729,12 +709,12 @@ int CEdit::MouseDetect(Math::Point mouse)
{
len = m_lineOffset[i+1] - m_lineOffset[i];
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
// c = m_engine->GetText()->Detect(m_text+m_lineOffset[i],
// len, offset, m_fontSize,
// m_fontStretch, m_fontType);
- c = m_engine->GetText()->Detect(m_text+m_lineOffset[i], m_fontType, m_fontSize, offset); // TODO check if good
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]), m_fontType, m_fontSize, offset); // TODO check if good
}
else
{
@@ -745,7 +725,10 @@ int CEdit::MouseDetect(Math::Point mouse)
// m_format+m_lineOffset[i],
// len, offset, size,
// m_fontStretch);
- c = m_engine->GetText()->Detect(m_text+m_lineOffset[i],m_format+m_lineOffset[i], size, offset); // TODO check if good
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()),
+ size,
+ offset); // TODO check if good
}
return m_lineOffset[i]+c;
}
@@ -767,7 +750,7 @@ void CEdit::HyperFlush()
// Indicates which is the home page.
-void CEdit::HyperHome(char *filename)
+void CEdit::HyperHome(const char *filename)
{
HyperFlush();
HyperAdd(filename, 0);
@@ -775,7 +758,7 @@ void CEdit::HyperHome(char *filename)
// Performs a hyper jump through a link.
-void CEdit::HyperJump(char *name, char *marker)
+void CEdit::HyperJump(const char *name, const char *marker)
{
char filename[100];
char sMarker[100];
@@ -826,7 +809,7 @@ void CEdit::HyperJump(char *name, char *marker)
// Adds text to the history of visited.
-bool CEdit::HyperAdd(char *filename, int firstLine)
+bool CEdit::HyperAdd(const char *filename, int firstLine)
{
if ( m_historyCurrent >= EDITHISTORYMAX-1 ) return false;
@@ -958,7 +941,7 @@ void CEdit::Draw()
size = m_fontSize;
// Headline \b;?
- if ( beg+len < m_len && m_format != 0 &&
+ if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG )
{
start.x = ppos.x-MARGX;
@@ -972,7 +955,7 @@ void CEdit::Draw()
}
// As \t;?
- if ( beg+len < m_len && m_format != 0 &&
+ if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_NORM )
{
start.x = ppos.x-MARGX;
@@ -983,7 +966,7 @@ void CEdit::Draw()
}
// Subtitle \s;?
- if ( beg+len < m_len && m_format != 0 &&
+ if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_LITTLE )
{
start.x = ppos.x-MARGX;
@@ -994,7 +977,7 @@ void CEdit::Draw()
}
// Table \tab;?
- if ( beg+len < m_len && m_format != 0 &&
+ if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE )
{
start.x = ppos.x-MARGX;
@@ -1005,7 +988,7 @@ void CEdit::Draw()
}
// Image \image; ?
- if ( beg+len < m_len && m_format != 0 &&
+ if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_IMAGE) != 0 )
{
line = 1;
@@ -1034,20 +1017,24 @@ void CEdit::Draw()
o1 = c1; if ( o1 < beg ) o1 = beg;
o2 = c2; if ( o2 > beg+len ) o2 = beg+len;
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- start.x = ppos.x+m_engine->GetText()->GetStringWidth(m_text+beg, m_fontType, size);
- end.x = m_engine->GetText()->GetStringWidth(m_text+o1, m_fontType, size);
+ start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg), m_fontType, size);
+ end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1), m_fontType, size);
}
else
{
- start.x = ppos.x+m_engine->GetText()->GetStringWidth(m_text+beg, m_format+beg, size);
- end.x = m_engine->GetText()->GetStringWidth(m_text+o1, m_format+o1, size);
+ start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()),
+ size);
+ end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+o1, m_format.end()),
+ size);
}
start.y = ppos.y-(m_bMulti?0.0f:MARGY1);
end.y = m_lineHeight;
- if ( m_format != 0 && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT;
+ if ( m_format.size() > 0 && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT;
DrawPart(start, end, 1); // plain yellow background
}
@@ -1062,13 +1049,19 @@ void CEdit::Draw()
eol = 2; // square (eot)
}
if ( !m_bMulti || !m_bDisplaySpec ) eol = 0;
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- m_engine->GetText()->DrawText(m_text+beg, m_fontType, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, eol);
+ m_engine->GetText()->DrawText(std::string(m_text+beg), m_fontType, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, eol);
}
else
{
- m_engine->GetText()->DrawText(m_text+beg, m_format+beg, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, eol);
+ m_engine->GetText()->DrawText(std::string(m_text+beg),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()),
+ size,
+ ppos,
+ m_dim.x,
+ Gfx::TEXT_ALIGN_RIGHT,
+ eol);
}
pos.y -= m_lineHeight;
@@ -1096,16 +1089,16 @@ void CEdit::Draw()
len = m_cursor1 - m_lineOffset[i];
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- m_engine->GetText()->SizeText(m_text+m_lineOffset[i], m_fontType,
+ m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]), m_fontType,
size, pos, Gfx::TEXT_ALIGN_RIGHT,
start, end);
}
else
{
- m_engine->GetText()->SizeText(m_text+m_lineOffset[i],
- m_format+m_lineOffset[i],
+ m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()),
size, pos, Gfx::TEXT_ALIGN_RIGHT,
start, end);
}
@@ -1129,7 +1122,7 @@ void CEdit::Draw()
// Draw an image part.
-void CEdit::DrawImage(Math::Point pos, char *name, float width,
+void CEdit::DrawImage(Math::Point pos, const char *name, float width,
float offset, float height, int nbLine)
{
Math::Point uv1, uv2, dim;
@@ -1242,7 +1235,7 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon)
// Give the text to edit.
-void CEdit::SetText(char *text, bool bNew)
+void CEdit::SetText(const char *text, bool bNew)
{
int i, j, font;
bool bBOL;
@@ -1252,7 +1245,7 @@ void CEdit::SetText(char *text, bool bNew)
m_len = strlen(text);
if ( m_len > m_maxChar ) m_len = m_maxChar;
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
if ( m_bAutoIndent )
{
@@ -1382,7 +1375,7 @@ int CEdit::GetTextLength()
// Returns a name in a command.
// \x nom1 nom2 nom3;
-void GetNameParam(char *cmd, int rank, char *buffer)
+void GetNameParam(const char *cmd, int rank, char *buffer)
{
int i;
@@ -1405,7 +1398,7 @@ void GetNameParam(char *cmd, int rank, char *buffer)
// Returns a number of a command.
// \x nom n1 n2;
-int GetValueParam(char *cmd, int rank)
+int GetValueParam(const char *cmd, int rank)
{
int n, i;
@@ -1440,7 +1433,7 @@ void CEdit::FreeImage()
// Reads the texture of an image.
-void CEdit::LoadImage(char *name)
+void CEdit::LoadImage(const char *name)
{
char filename[100];
@@ -1452,7 +1445,7 @@ void CEdit::LoadImage(char *name)
// Read from a text file.
-bool CEdit::ReadText(char *filename, int addSize)
+bool CEdit::ReadText(const char *filename, int addSize)
{
FILE *file = NULL;
char *buffer;
@@ -1482,10 +1475,9 @@ bool CEdit::ReadText(char *filename, int addSize)
buffer = new char[sizeof(char)*(m_maxChar+1)];
fread(buffer, 1, len, file);
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
- delete m_format;
- m_format = new char[sizeof(char)*m_maxChar];
+ m_format.clear();
}
fclose(file);
@@ -1507,7 +1499,7 @@ bool CEdit::ReadText(char *filename, int addSize)
if ( !bBOL )
{
m_text[j] = buffer[i];
- if ( m_format != 0 ) m_format[j] = font;
+ if ( m_format.size() > 0 ) m_format[j] = font;
j ++;
}
i ++;
@@ -1520,7 +1512,7 @@ bool CEdit::ReadText(char *filename, int addSize)
{
i ++;
}
- else if ( m_format != 0 && buffer[i] == '\\' && buffer[i+2] == ';' )
+ else if ( m_format.size() > 0 && buffer[i] == '\\' && buffer[i+2] == ';' )
{
if ( buffer[i+1] == 'n' ) // normal ?
{
@@ -1581,7 +1573,7 @@ bool CEdit::ReadText(char *filename, int addSize)
i += 3;
}
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \u marker name; ?
buffer[i+1] == 'u' &&
buffer[i+2] == ' ' )
@@ -1598,7 +1590,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \m marker; ?
buffer[i+1] == 'm' &&
buffer[i+2] == ' ' )
@@ -1614,7 +1606,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \image name lx ly; ?
buffer[i+1] == 'i' &&
buffer[i+2] == 'm' &&
@@ -1651,7 +1643,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \button; ?
buffer[i+1] == 'b' &&
buffer[i+2] == 'u' &&
@@ -1669,7 +1661,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \token; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'o' &&
@@ -1685,7 +1677,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 7;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \type; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'y' &&
@@ -1700,7 +1692,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 6;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \const; ?
buffer[i+1] == 'c' &&
buffer[i+2] == 'o' &&
@@ -1716,7 +1708,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 7;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \key; ?
buffer[i+1] == 'k' &&
buffer[i+2] == 'e' &&
@@ -1730,7 +1722,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 5;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \tab; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'a' &&
@@ -1743,7 +1735,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 5;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \norm; ?
buffer[i+1] == 'n' &&
buffer[i+2] == 'o' &&
@@ -1757,7 +1749,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 6;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \begin soluce; ?
buffer[i+1] == 'b' &&
buffer[i+2] == 's' &&
@@ -1766,7 +1758,7 @@ bool CEdit::ReadText(char *filename, int addSize)
bInSoluce = true;
i += 4;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \end soluce; ?
buffer[i+1] == 'e' &&
buffer[i+2] == 's' &&
@@ -1775,7 +1767,7 @@ bool CEdit::ReadText(char *filename, int addSize)
bInSoluce = false;
i += 4;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \key name; ?
buffer[i+1] == 'k' &&
buffer[i+2] == 'e' &&
@@ -1786,7 +1778,7 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( SearchKey(buffer+i+5, key) )
{
- res = m_engine->GetKey(key, 0); // TODO
+ res = m_app->GetKey(key, 0); // TODO
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@@ -1805,7 +1797,7 @@ bool CEdit::ReadText(char *filename, int addSize)
m_format[j] = font;
j ++;
- res = m_engine->GetKey(key, 1); // TODO
+ res = m_app->GetKey(key, 1); // TODO
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@@ -1846,7 +1838,7 @@ bool CEdit::ReadText(char *filename, int addSize)
if ( m_bSoluce || !bInSoluce )
{
m_text[j] = buffer[i];
- if ( m_format != 0 ) m_format[j] = font;
+ if ( m_format.size() > 0 ) m_format[j] = font;
j ++;
}
i ++;
@@ -1871,7 +1863,7 @@ bool CEdit::ReadText(char *filename, int addSize)
// Writes all the text in a file.
-bool CEdit::WriteText(char *filename)
+bool CEdit::WriteText(const char *filename)
{
FILE* file;
char buffer[1000+20];
@@ -1943,10 +1935,9 @@ void CEdit::SetMaxChar(int max)
delete m_text;
m_text = (char*)malloc(sizeof(char)*(m_maxChar+1));
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
- delete m_format;
- m_format = (char*)malloc(sizeof(char)*m_maxChar);
+ m_format.clear();
}
m_len = 0;
@@ -2135,22 +2126,12 @@ bool CEdit::GetDisplaySpec()
void CEdit::SetMultiFont(bool bMulti)
{
- if ( bMulti )
- {
- delete m_format;
- m_format = (char*)malloc(sizeof(char)*m_maxChar);
- memset(m_format, 0, m_maxChar);
- }
- else
- {
- delete m_format;
- m_format = 0;
- }
+ m_format.clear();
}
bool CEdit::GetMultiFont()
{
- return ( m_format != 0 );
+ return ( m_format.size() > 0 );
}
@@ -2439,16 +2420,16 @@ void CEdit::MoveLine(int move, bool bWord, bool bSelect)
column -= indentLength*m_lineIndent[line];
}
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- c = m_engine->GetText()->Detect(m_text+m_lineOffset[line],
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]),
m_fontType, m_fontSize,
m_lineOffset[line+1]-m_lineOffset[line]);
}
else
{
- c = m_engine->GetText()->Detect(m_text+m_lineOffset[line],
- m_format+m_lineOffset[line],
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()),
m_fontSize,
m_lineOffset[line+1]-m_lineOffset[line]);
}
@@ -2469,17 +2450,17 @@ void CEdit::ColumnFix()
line = GetCursorLine(m_cursor1);
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
m_column = m_engine->GetText()->GetStringWidth(
- m_text+m_lineOffset[line],
+ std::string(m_text+m_lineOffset[line]),
m_fontType, m_fontSize);
}
else
{
m_column = m_engine->GetText()->GetStringWidth(
- m_text+m_lineOffset[line],
- m_format+m_lineOffset[line],
+ std::string(m_text+m_lineOffset[line]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()),
m_fontSize
);
}
@@ -2497,7 +2478,7 @@ void CEdit::ColumnFix()
bool CEdit::Cut() // TODO MS Windows allocations
{
- HGLOBAL hg;
+ /* HGLOBAL hg;
char* text;
char c;
int c1, c2, start, len, i, j;
@@ -2570,7 +2551,7 @@ bool CEdit::Cut() // TODO MS Windows allocations
DeleteOne(0); // deletes the selected characters
Justif();
ColumnFix();
- SendModifEvent();
+ SendModifEvent();*/
return true;
}
@@ -2578,7 +2559,7 @@ bool CEdit::Cut() // TODO MS Windows allocations
bool CEdit::Copy() // TODO
{
- HGLOBAL hg;
+ /* HGLOBAL hg;
char* text;
char c;
int c1, c2, start, len, i, j;
@@ -2642,7 +2623,7 @@ bool CEdit::Copy() // TODO
return false;
}
CloseClipboard();
-
+*/
return true;
}
@@ -2650,7 +2631,7 @@ bool CEdit::Copy() // TODO
bool CEdit::Paste() // TODO
{
- HANDLE h;
+ /*HANDLE h;
char c;
char* p;
@@ -2688,7 +2669,7 @@ bool CEdit::Paste() // TODO
Justif();
ColumnFix();
- SendModifEvent();
+ SendModifEvent();*/
return true;
}
@@ -2821,7 +2802,7 @@ void CEdit::InsertOne(char character)
{
m_text[i] = m_text[i-1]; // shoot
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
m_format[i] = m_format[i-1]; // shoot
}
@@ -2831,7 +2812,7 @@ void CEdit::InsertOne(char character)
m_text[m_cursor1] = character;
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
m_format[m_cursor1] = 0;
}
@@ -2882,7 +2863,7 @@ void CEdit::DeleteOne(int dir)
{
m_text[i] = m_text[i+hole];
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
m_format[i] = m_format[i+hole];
}
@@ -3074,7 +3055,7 @@ void CEdit::Justif()
width -= indentLength*m_lineIndent[m_lineTotal-1];
}
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
// TODO check if good
i += m_engine->GetText()->Justify(m_text+i, m_fontType,
@@ -3097,8 +3078,10 @@ void CEdit::Justif()
else
{
// TODO check if good
- i += m_engine->GetText()->Justify(m_text+i, m_format+i,
- size, width);
+ i += m_engine->GetText()->Justify(std::string(m_text+i),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+i, m_format.end()),
+ size,
+ width);
}
}
@@ -3293,11 +3276,11 @@ bool CEdit::UndoRecall()
bool CEdit::ClearFormat()
{
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
SetMultiFont(true);
}
- memset(m_format, m_fontType, m_len);
+ m_format.clear();
return true;
}
@@ -3308,7 +3291,7 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format)
{
int i;
- if ( m_format == 0 ) return false;
+ if ( m_format.size() == 0 ) return false;
for ( i=cursor1 ; i<cursor2 ; i++ )
{
diff --git a/src/ui/edit.h b/src/ui/edit.h
index 99ec693..22ac577 100644
--- a/src/ui/edit.h
+++ b/src/ui/edit.h
@@ -24,15 +24,26 @@
#pragma once
-//#include "common/struct.h"
-#include "ui/control.h"
+#include <ui/control.h>
+#include <ui/scroll.h>
+
+#include <graphics/engine/engine.h>
+#include <graphics/engine/text.h>
+
+#include <common/language.h>
+#include <common/event.h>
+#include <common/misc.h>
+#include <common/iman.h>
+#include <common/restext.h>
+
+#include <app/app.h>
+
+#include <vector>
+
-namespace Gfx{
-class CEngine;
-};
namespace Ui {
-class CScroll;
+
//! maximum number of characters in CBOT edit
@@ -128,13 +139,13 @@ public:
bool EventProcess(const Event &event);
void Draw();
- void SetText(char *text, bool bNew=true);
+ void SetText(const char *text, bool bNew=true);
void GetText(char *buffer, int max);
char* GetText();
int GetTextLength();
- bool ReadText(char *filename, int addSize=0);
- bool WriteText(char *filename);
+ bool ReadText(const char *filename, int addSize=0);
+ bool WriteText(const char *filename);
void SetMaxChar(int max);
int GetMaxChar();
@@ -176,7 +187,7 @@ public:
bool Undo();
void HyperFlush();
- void HyperHome(char *filename);
+ void HyperHome(const char *filename);
bool HyperTest(EventType event);
bool HyperGo(EventType event);
@@ -195,15 +206,15 @@ protected:
int MouseDetect(Math::Point mouse);
void MoveAdjust();
- void HyperJump(char *name, char *marker);
- bool HyperAdd(char *filename, int firstLine);
+ void HyperJump(const char *name, const char *marker);
+ bool HyperAdd(const char *filename, int firstLine);
- void DrawImage(Math::Point pos, char *name, float width, float offset, float height, int nbLine);
+ void DrawImage(Math::Point pos, const char *name, float width, float offset, float height, int nbLine);
void DrawBack(Math::Point pos, Math::Point dim);
void DrawPart(Math::Point pos, Math::Point dim, int icon);
void FreeImage();
- void LoadImage(char *name);
+ void LoadImage(const char *name);
void Scroll(int pos, bool bAdjustCursor);
void Scroll();
void MoveChar(int move, bool bWord, bool bSelect);
@@ -232,10 +243,11 @@ protected:
int m_maxChar; // max length of the buffer m_text
char* m_text; // text (without zero terminator)
- char* m_format; // format characters
+ std::vector<Gfx::FontMetaChar> m_format; // format characters
int m_len; // length used in m_text
int m_cursor1; // offset cursor
int m_cursor2; // offset cursor
+ CApplication *m_app;
bool m_bMulti; // true -> multi-line
bool m_bEdit; // true -> editable
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 <windows.h>
-//#include <stdio.h>
-//#include <d3d.h>
-
-//#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 <ui/gauge.h>
namespace Ui {
diff --git a/src/ui/gauge.h b/src/ui/gauge.h
index b745834..8b7ef66 100644
--- a/src/ui/gauge.h
+++ b/src/ui/gauge.h
@@ -19,35 +19,36 @@
#pragma once
+#include <graphics/engine/engine.h>
-#include "ui/control.h"
+#include <common/event.h>
+#include <common/misc.h>
+
+#include <ui/control.h>
-namespace Gfx{
-class CEngine;
-};
namespace Ui {
class CGauge : public CControl
{
-public:
-// CGauge(CInstanceManager* iMan);
- CGauge();
- virtual ~CGauge();
+ public:
+ // CGauge(CInstanceManager* iMan);
+ CGauge();
+ virtual ~CGauge();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetLevel(float level);
- float GetLevel();
+ void SetLevel(float level);
+ float GetLevel();
-protected:
+ protected:
-protected:
- float m_level;
+ protected:
+ float m_level;
};
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 6c96501..a042899 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -162,7 +162,7 @@ CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, Even
// Creates a new label.
-CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, const char *name)
+CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name)
{
CLabel* pc = CreateControl<CLabel>(pos, dim, icon, eventMsg);
if (pc != nullptr)
@@ -297,7 +297,7 @@ bool CInterface::EventProcess(const Event &event)
// Gives the tooltip binding to the window.
-bool CInterface::GetTooltip(Math::Point pos, const char* name)
+bool CInterface::GetTooltip(Math::Point pos, std::string &name)
{
for (int i = MAXCONTROL-1; i >= 0; i--) {
if (m_table[i] != nullptr) {
diff --git a/src/ui/interface.h b/src/ui/interface.h
index 43f2698..7123c05 100644
--- a/src/ui/interface.h
+++ b/src/ui/interface.h
@@ -19,6 +19,7 @@
#pragma once
+#include <string>
#include <common/event.h>
#include <common/struct.h>
@@ -61,7 +62,7 @@ class CInterface
~CInterface();
bool EventProcess(const Event &event);
- bool GetTooltip(Math::Point pos, const char* name);
+ bool GetTooltip(Math::Point pos, std::string &name);
void Flush();
CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
@@ -81,7 +82,7 @@ class CInterface
CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
- CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, const char *name);
+ CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
bool DeleteControl(EventType eventMsg);
CControl* SearchControl(EventType eventMsg);
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index 0cf74bc..89473a8 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -64,7 +64,7 @@ bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg
CControl::Create(pos, dim, icon, eventMsg);
GetResource(RES_EVENT, eventMsg, name);
- SetName(name);
+ SetName(std::string(name));
return true;
}
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index cba19d6..928e129 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.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,58 +18,24 @@
// studio.cpp
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <windows.h>
-#include <direct.h>
-#include <io.h>
-#include <time.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "common/restext.h"
-#include "old/math3d.h"
-#include "object/robotmain.h"
-#include "object/object.h"
-#include "old/camera.h"
-#include "old/sound.h"
-#include "script/script.h"
-#include "ui/interface.h"
-#include "ui/button.h"
-#include "ui/check.h"
-#include "ui/slider.h"
-#include "ui/edit.h"
-#include "ui/list.h"
-#include "ui/label.h"
-#include "ui/group.h"
-#include "ui/window.h"
-#include "old/text.h"
-#include "script/cbottoken.h"
-#include "ui/studio.h"
-
+#include <ui/studio.h>
+namespace Ui {
// Object's constructor.
-CStudio::CStudio(CInstanceManager* iMan)
+CStudio::CStudio()
{
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_STUDIO, this);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_bEditMaximized = false;
m_bEditMinimized = false;
@@ -103,7 +70,7 @@ bool CStudio::EventProcess(const Event &event)
return EventDialog(event);
}
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
EventFrame(event);
}
@@ -114,74 +81,74 @@ bool CStudio::EventProcess(const Event &event)
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( edit == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() )
+ if ( event.type == pw->GetEventTypeClose() )
{
Event newEvent = event;
newEvent.event = EVENT_STUDIO_OK;
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_STUDIO_EDIT ) // text modifief?
+ if ( event.type == EVENT_STUDIO_EDIT ) // text modifief?
{
ColorizeScript(edit);
}
- if ( event.event == EVENT_STUDIO_LIST ) // list clicked?
+ if ( event.type == EVENT_STUDIO_LIST ) // list clicked?
{
m_main->StartDisplayInfo(m_helpFilename, -1);
}
- if ( event.event == EVENT_STUDIO_NEW ) // new?
+ if ( event.type == EVENT_STUDIO_NEW ) // new?
{
m_script->New(edit, "");
}
- if ( event.event == EVENT_STUDIO_OPEN ) // open?
+ if ( event.type == EVENT_STUDIO_OPEN ) // open?
{
StartDialog(SD_OPEN);
}
- if ( event.event == EVENT_STUDIO_SAVE ) // save?
+ if ( event.type == EVENT_STUDIO_SAVE ) // save?
{
StartDialog(SD_SAVE);
}
- if ( event.event == EVENT_STUDIO_UNDO ) // undo?
+ if ( event.type == EVENT_STUDIO_UNDO ) // undo?
{
edit->Undo();
}
- if ( event.event == EVENT_STUDIO_CUT ) // cut?
+ if ( event.type == EVENT_STUDIO_CUT ) // cut?
{
edit->Cut();
}
- if ( event.event == EVENT_STUDIO_COPY ) // copy?
+ if ( event.type == EVENT_STUDIO_COPY ) // copy?
{
edit->Copy();
}
- if ( event.event == EVENT_STUDIO_PASTE ) // paste?
+ if ( event.type == EVENT_STUDIO_PASTE ) // paste?
{
edit->Paste();
}
- if ( event.event == EVENT_STUDIO_SIZE ) // size?
+ if ( event.type == EVENT_STUDIO_SIZE ) // size?
{
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
if ( slider == 0 ) return false;
- m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f);
+ m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f);
ViewEditScript();
}
- if ( event.event == EVENT_STUDIO_TOOL && // instructions?
+ if ( event.type == EVENT_STUDIO_TOOL && // instructions?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_HUSTON, false);
}
- if ( event.event == EVENT_STUDIO_HELP && // help?
+ if ( event.type == EVENT_STUDIO_HELP && // help?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_PROG, false);
}
- if ( event.event == EVENT_STUDIO_COMPILE ) // compile?
+ if ( event.type == EVENT_STUDIO_COMPILE ) // compile?
{
char buffer[100];
@@ -197,7 +164,7 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_STUDIO_RUN ) // run/stop?
+ if ( event.type == EVENT_STUDIO_RUN ) // run/stop?
{
if ( m_script->IsRunning() )
{
@@ -224,7 +191,7 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_STUDIO_REALTIME ) // real time?
+ if ( event.type == EVENT_STUDIO_REALTIME ) // real time?
{
m_bRealTime = !m_bRealTime;
m_script->SetStepMode(!m_bRealTime);
@@ -232,15 +199,15 @@ bool CStudio::EventProcess(const Event &event)
UpdateButtons();
}
- if ( event.event == EVENT_STUDIO_STEP ) // step?
+ if ( event.type == EVENT_STUDIO_STEP ) // step?
{
m_script->Step(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEYDOWN )
{
- if ( event.param == m_engine->RetKey(KEYRANK_CBOT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_CBOT, 1) )
+ if ( event.param == m_engine->GetKey(KEYRANK_CBOT, 0) ||
+ event.param == m_engine->GetKey(KEYRANK_CBOT, 1) )
{
if ( m_helpFilename[0] != 0 )
{
@@ -249,20 +216,20 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_WINDOW3 ) // window is moved?
+ if ( event.type == EVENT_WINDOW3 ) // window is moved?
{
- m_editActualPos = m_editFinalPos = pw->RetPos();
- m_editActualDim = m_editFinalDim = pw->RetDim();
+ m_editActualPos = m_editFinalPos = pw->GetPos();
+ m_editActualDim = m_editFinalDim = pw->GetDim();
m_main->SetWindowPos(m_editActualPos);
m_main->SetWindowDim(m_editActualDim);
AdjustEditScript();
}
- if ( event.event == pw->RetEventMsgReduce() )
+ if ( event.type == pw->GetEventTypeReduce() )
{
if ( m_bEditMinimized )
{
- m_editFinalPos = m_main->RetWindowPos();
- m_editFinalDim = m_main->RetWindowDim();
+ m_editFinalPos = m_main->GetWindowPos();
+ m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@@ -283,12 +250,12 @@ bool CStudio::EventProcess(const Event &event)
pw->SetMinimized(m_bEditMinimized);
}
}
- if ( event.event == pw->RetEventMsgFull() )
+ if ( event.type == pw->GetEventTypeFull() )
{
if ( m_bEditMaximized )
{
- m_editFinalPos = m_main->RetWindowPos();
- m_editFinalDim = m_main->RetWindowDim();
+ m_editFinalPos = m_main->GetWindowPos();
+ m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@@ -435,8 +402,8 @@ void CStudio::SearchToken(CEdit* edit)
char* text;
char token[100];
- text = edit->RetText();
- len = edit->RetTextLength();
+ text = edit->GetText();
+ len = edit->GetTextLength();
edit->GetCursor(cursor1, cursor2);
i = cursor1;
@@ -499,18 +466,18 @@ void CStudio::SearchToken(CEdit* edit)
}
token[i] = 0;
- strcpy(m_helpFilename, RetHelpFilename(token));
+ strcpy(m_helpFilename, GetHelpFilename(token));
if ( m_helpFilename[0] == 0 )
{
for ( i=0 ; i<OBJECT_MAX ; i++ )
{
type = (ObjectType)i;
- text = RetObjectName(type);
+ text = GetObjectName(type);
if ( text[0] != 0 )
{
if ( strcmp(token, text) == 0 )
{
- strcpy(m_helpFilename, RetHelpFilename(type));
+ strcpy(m_helpFilename, GetHelpFilename(type));
SetInfoText(token, true);
return;
}
@@ -520,7 +487,7 @@ void CStudio::SearchToken(CEdit* edit)
{
if ( strcmp(token, text) == 0 )
{
- strcpy(m_helpFilename, RetHelpFilename(type));
+ strcpy(m_helpFilename, GetHelpFilename(type));
SetInfoText(token, true);
return;
}
@@ -564,9 +531,9 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
m_main->SetEditLock(true, true);
m_main->SetEditFull(false);
- m_bInitPause = m_engine->RetPause();
+ m_bInitPause = m_engine->GetPause();
m_main->SetSpeed(1.0f);
- m_editCamera = m_camera->RetType();
+ m_editCamera = m_camera->GetType();
m_camera->SetType(CAMERA_EDIT);
m_bRunning = m_script->IsRunning();
@@ -579,8 +546,8 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
button->ClearState(STATE_VISIBLE);
}
- pos = m_editFinalPos = m_editActualPos = m_main->RetWindowPos();
- dim = m_editFinalDim = m_editActualDim = m_main->RetWindowDim();
+ pos = m_editFinalPos = m_editActualPos = m_main->GetWindowPos();
+ dim = m_editFinalDim = m_editActualDim = m_main->GetWindowDim();
pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW3);
if ( pw == 0 ) return;
pw->SetState(STATE_SHADOW);
@@ -603,7 +570,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
edit->SetFontType(FONT_COURIER);
edit->SetFontStretch(0.7f);
edit->SetDisplaySpec(true);
- edit->SetAutoIndent(m_engine->RetEditIndentMode());
+ edit->SetAutoIndent(m_engine->GetEditIndentMode());
m_script->PutScript(edit, name);
ColorizeScript(edit);
@@ -632,7 +599,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
button->SetState(STATE_SHADOW);
slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE);
slider->SetState(STATE_SHADOW);
- slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
pw->CreateGroup(pos, dim, 19, EVENT_LABEL1); // SatCom logo
button = pw->CreateButton(pos, dim, 128+57, EVENT_STUDIO_TOOL);
button->SetState(STATE_SHADOW);
@@ -678,7 +645,7 @@ void CStudio::AdjustEditScript()
{
pw->SetPos(wpos);
pw->SetDim(wdim);
- wdim = pw->RetDim();
+ wdim = pw->GetDim();
}
if ( m_bRunning ) hList = 80.0f/480.0f;
@@ -938,8 +905,8 @@ void CStudio::ViewEditScript()
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( edit == 0 ) return;
- dim = m_engine->RetDim();
- edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f));
+ dim = m_engine->GetDim();
+ edit->SetFontSize(m_main->GetFontSize()/(dim.x/640.0f));
}
@@ -1063,8 +1030,8 @@ void CStudio::StartDialog(StudioDialog type)
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
- pos = m_main->RetIOPos();
- dim = m_main->RetIODim();
+ pos = m_main->GetIOPos();
+ dim = m_main->GetIODim();
}
//? pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW9);
pw = m_interface->CreateWindows(pos, dim, m_dialog==SD_OPEN?14:13, EVENT_WINDOW9);
@@ -1097,7 +1064,7 @@ void CStudio::StartDialog(StudioDialog type)
pe->SetState(STATE_SHADOW);
if ( m_dialog == SD_SAVE )
{
- pe->SetText(m_script->RetFilename());
+ pe->SetText(m_script->GetFilename());
}
GetResource(RES_TEXT, RT_IO_DIR, name);
@@ -1200,8 +1167,8 @@ void CStudio::AdjustDialog()
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
- wpos = pw->RetPos();
- wdim = pw->RetDim();
+ wpos = pw->GetPos();
+ wdim = pw->GetDim();
pw->SetPos(wpos); // to move the buttons on the titlebar
if ( m_dialog == SD_OPEN ||
@@ -1318,10 +1285,10 @@ bool CStudio::EventDialog(const Event &event)
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return false;
- if ( event.event == EVENT_WINDOW9 ) // window is moved?
+ if ( event.type == EVENT_WINDOW9 ) // window is moved?
{
- wpos = pw->RetPos();
- wdim = pw->RetDim();
+ wpos = pw->GetPos();
+ wdim = pw->GetDim();
m_main->SetIOPos(wpos);
m_main->SetIODim(wdim);
AdjustDialog();
@@ -1330,22 +1297,22 @@ bool CStudio::EventDialog(const Event &event)
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
- if ( event.event == EVENT_DIALOG_LIST )
+ if ( event.type == EVENT_DIALOG_LIST )
{
UpdateChangeList();
}
- if ( event.event == EVENT_DIALOG_EDIT )
+ if ( event.type == EVENT_DIALOG_EDIT )
{
UpdateChangeEdit();
}
- if ( event.event == EVENT_DIALOG_CHECK1 ) // private?
+ if ( event.type == EVENT_DIALOG_CHECK1 ) // private?
{
m_main->SetIOPublic(false);
UpdateDialogPublic();
UpdateDialogList();
}
- if ( event.event == EVENT_DIALOG_CHECK2 ) // public?
+ if ( event.type == EVENT_DIALOG_CHECK2 ) // public?
{
m_main->SetIOPublic(true);
UpdateDialogPublic();
@@ -1353,8 +1320,8 @@ bool CStudio::EventDialog(const Event &event)
}
}
- if ( event.event == EVENT_DIALOG_OK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_RETURN) )
+ if ( event.type == EVENT_DIALOG_OK ||
+ (event.type == EVENT_KEYDOWN && event.param == VK_RETURN) )
{
if ( m_dialog == SD_OPEN )
{
@@ -1369,9 +1336,9 @@ bool CStudio::EventDialog(const Event &event)
return true;
}
- if ( event.event == EVENT_DIALOG_CANCEL ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ||
- event.event == pw->RetEventMsgClose() )
+ if ( event.type == EVENT_DIALOG_CANCEL ||
+ (event.type == EVENT_KEYDOWN && event.param == VK_ESCAPE) ||
+ event.type == pw->GetEventTypeClose() )
{
StopDialog();
return true;
@@ -1397,8 +1364,8 @@ void CStudio::UpdateChangeList()
pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
if ( pe == 0 ) return;
- strcpy(name, pl->RetName(pl->RetSelect()));
- name[pe->RetMaxChar()] = 0; // truncates according lg max editable
+ strcpy(name, pl->GetName(pl->GetSelect()));
+ name[pe->GetMaxChar()] = 0; // truncates according lg max editable
p = strchr(name, '\t'); // seeks first tab
if ( p != 0 ) *p = 0;
pe->SetText(name);
@@ -1486,13 +1453,13 @@ void CStudio::UpdateDialogPublic()
pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1);
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, !m_main->RetIOPublic());
+ pc->SetState(STATE_CHECK, !m_main->GetIOPublic());
}
pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2);
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_main->RetIOPublic());
+ pc->SetState(STATE_CHECK, m_main->GetIOPublic());
}
pl = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1);
@@ -1573,13 +1540,13 @@ void CStudio::UpdateDialogList()
void CStudio::SearchDirectory(char *dir, bool bCreate)
{
- if ( m_main->RetIOPublic() )
+ if ( m_main->GetIOPublic() )
{
- sprintf(dir, "%s\\", m_main->RetPublicDir());
+ sprintf(dir, "%s\\", m_main->GetPublicDir());
}
else
{
- sprintf(dir, "%s\\%s\\Program\\", m_main->RetSavegameDir(), m_main->RetGamerName());
+ sprintf(dir, "%s\\%s\\Program\\", m_main->GetSavegameDir(), m_main->GetGamerName());
}
if ( bCreate )
@@ -1663,3 +1630,4 @@ bool CStudio::WriteProgram()
return true;
}
+}
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 687ab22..6af69ee 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -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
@@ -19,22 +20,42 @@
#pragma once
-#include "object/object.h"
-#include "script/script.h"
+#include <object/object.h>
+#include <script/script.h>
-class CInstanceManager;
-class CD3DEngine;
-class CEvent;
-class CRobotMain;
-class CCamera;
-class CSound;
-class CInterface;
-class CScript;
-class CList;
-class CEdit;
+#include <graphics/engine/engine.h>
+#include <graphics/engine/camera.h>
+#include <common/event.h>
+#include <common/struct.h>
+#include <common/misc.h>
+#include <common/iman.h>
+#include <sound/sound.h>
+
+#include <ui/control.h>
+#include <ui/button.h>
+#include <ui/color.h>
+#include <ui/check.h>
+#include <ui/key.h>
+#include <ui/group.h>
+#include <ui/image.h>
+#include <ui/label.h>
+#include <ui/edit.h>
+#include <ui/editvalue.h>
+#include <ui/scroll.h>
+#include <ui/slider.h>
+#include <ui/list.h>
+#include <ui/shortcut.h>
+#include <ui/compass.h>
+#include <ui/target.h>
+#include <ui/map.h>
+#include <ui/window.h>
+#include <ui/interface.h>
+
+
+namespace Ui {
enum StudioDialog
{
@@ -49,67 +70,69 @@ enum StudioDialog
class CStudio
{
-public:
- CStudio(CInstanceManager* iMan);
- ~CStudio();
-
- bool EventProcess(const Event &event);
-
- void StartEditScript(CScript *script, char* name, int rank);
- bool StopEditScript(bool bCancel);
-
-protected:
- bool EventFrame(const Event &event);
- void SearchToken(CEdit* edit);
- void ColorizeScript(CEdit* edit);
- void AdjustEditScript();
- void SetInfoText(char *text, bool bClickable);
- void ViewEditScript();
- void UpdateFlux();
- void UpdateButtons();
-
- void StartDialog(StudioDialog type);
- void StopDialog();
- void AdjustDialog();
- bool EventDialog(const Event &event);
- void UpdateChangeList();
- void UpdateChangeEdit();
- void UpdateDialogAction();
- void UpdateDialogPublic();
- void UpdateDialogList();
- void SearchDirectory(char *dir, bool bCreate);
- bool ReadProgram();
- bool WriteProgram();
-
-protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CEvent* m_event;
- CRobotMain* m_main;
- CCamera* m_camera;
- CSound* m_sound;
- CInterface* m_interface;
-
- int m_rank;
- CScript* m_script;
-
- bool m_bEditMaximized;
- bool m_bEditMinimized;
-
- CameraType m_editCamera;
- Math::Point m_editActualPos;
- Math::Point m_editActualDim;
- Math::Point m_editFinalPos;
- Math::Point m_editFinalDim;
-
- float m_time;
- float m_fixInfoTextTime;
- bool m_bRunning;
- bool m_bRealTime;
- bool m_bInitPause;
- char m_helpFilename[100];
+ public:
+ CStudio();
+ ~CStudio();
+
+ bool EventProcess(const Event &event);
+
+ void StartEditScript(CScript *script, char* name, int rank);
+ bool StopEditScript(bool bCancel);
+
+ protected:
+ bool EventFrame(const Event &event);
+ void SearchToken(CEdit* edit);
+ void ColorizeScript(CEdit* edit);
+ void AdjustEditScript();
+ void SetInfoText(char *text, bool bClickable);
+ void ViewEditScript();
+ void UpdateFlux();
+ void UpdateButtons();
+
+ void StartDialog(StudioDialog type);
+ void StopDialog();
+ void AdjustDialog();
+ bool EventDialog(const Event &event);
+ void UpdateChangeList();
+ void UpdateChangeEdit();
+ void UpdateDialogAction();
+ void UpdateDialogPublic();
+ void UpdateDialogList();
+ void SearchDirectory(char *dir, bool bCreate);
+ bool ReadProgram();
+ bool WriteProgram();
+
+ protected:
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ CCamera* m_camera;
+ CSoundInterface* m_sound;
+ CInterface* m_interface;
+
+ int m_rank;
+ CScript* m_script;
+
+ bool m_bEditMaximized;
+ bool m_bEditMinimized;
+
+ CameraType m_editCamera;
+ Math::Point m_editActualPos;
+ Math::Point m_editActualDim;
+ Math::Point m_editFinalPos;
+ Math::Point m_editFinalDim;
+
+ float m_time;
+ float m_fixInfoTextTime;
+ bool m_bRunning;
+ bool m_bRealTime;
+ bool m_bInitPause;
+ char m_helpFilename[100];
StudioDialog m_dialog;
};
+}
+
diff --git a/src/ui/target.cpp b/src/ui/target.cpp
index db478fe..9ffcfb9 100644
--- a/src/ui/target.cpp
+++ b/src/ui/target.cpp
@@ -137,7 +137,7 @@ bool CTarget::EventProcess(const Event &event)
{
if ( CControl::Detect(event.pos) )
{
- if ( !m_main->RetFriendAim() )
+ if ( !m_main->GetFriendAim() )
{
Event newEvent = event;
newEvent.type = EVENT_OBJECT_FIRE;
@@ -181,7 +181,7 @@ bool CTarget::GetTooltip(Math::Point pos, char* name)
{
//? pObj = DetectFriendObject(pos);
//? if ( pObj == 0 )
- if ( !m_main->RetFriendAim() )
+ if ( !m_main->GetFriendAim() )
{
strcpy(name, m_tooltip);
return true; // does not detect objects below!
diff --git a/src/ui/target.h b/src/ui/target.h
index 0b5b67d..47b9760 100644
--- a/src/ui/target.h
+++ b/src/ui/target.h
@@ -18,6 +18,7 @@
#pragma once
+#include <string>
#include <ui/control.h>
@@ -35,7 +36,7 @@ class CTarget : public CControl
bool EventProcess(const Event &event);
void Draw();
- bool GetTooltip(Math::Point pos, char* name);
+ bool GetTooltip(Math::Point pos, std::string &name);
protected:
CObject* DetectFriendObject(Math::Point pos);
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index fabd9c4..f922569 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -18,38 +18,7 @@
// window.cpp
-//#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/restext.h"
-#include "common/iman.h"
-#include "ui/button.h"
-#include "ui/color.h"
-#include "ui/check.h"
-#include "ui/key.h"
-#include "ui/group.h"
-#include "ui/image.h"
-#include "ui/label.h"
-#include "ui/edit.h"
-#include "ui/editvalue.h"
-#include "ui/scroll.h"
-#include "ui/slider.h"
-#include "ui/list.h"
-#include "ui/shortcut.h"
-#include "ui/map.h"
-#include "ui/gauge.h"
-#include "ui/compass.h"
-#include "ui/target.h"
-//#include "old/text.h"
-#include "graphics/engine/text.h"
-#include "ui/window.h"
+#include <ui/window.h>
@@ -280,11 +249,9 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventTy
// Creates a new label.
-CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg,
- char *name)
+CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name)
{
CLabel* pc;
- char* p;
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
@@ -298,22 +265,11 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventTy
pc = (CLabel*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
- p = strchr(name, '\\');
- if ( p == 0 )
- {
+ auto p = name.find("\\");
+ if ( p == std::string::npos )
pc->SetName(name);
- }
else
- {
- char text[100];
- strncpy(text, name, 100);
- text[100-1] = 0;
- if ( p-name < 100 )
- {
- text[p-name] = 0; // deletes text after "\\" (tooltip)
- }
- pc->SetName(text);
- }
+ pc->SetName(name.substr(0, p));
return pc;
}
}
@@ -589,7 +545,7 @@ CControl* CWindow::SearchControl(EventType eventMsg)
// Makes the tooltip binds to the window.
-bool CWindow::GetTooltip(Math::Point pos, char* name)
+bool CWindow::GetTooltip(Math::Point pos, std::string &name)
{
int i;
@@ -622,7 +578,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name)
if ( Detect(pos) ) // in the window?
{
- strcpy(name, m_tooltip);
+ name = m_tooltip;
return true;
}
@@ -632,7 +588,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name)
// Specifies the name for the title bar.
-void CWindow::SetName(char* name)
+void CWindow::SetName(std::string name)
{
CButton* pc;
bool bAdjust;
@@ -659,7 +615,7 @@ void CWindow::SetName(char* name)
bAdjust = false;
- if ( m_name[0] != 0 && m_bRedim ) // title bar exists?
+ if ( m_name.length() > 0 && m_bRedim ) // title bar exists?
{
m_buttonReduce = new CButton();
pc = (CButton*)m_buttonReduce;
@@ -672,7 +628,7 @@ void CWindow::SetName(char* name)
bAdjust = true;
}
- if ( m_name[0] != 0 && m_bClosable ) // title bar exists?
+ if ( m_name.length() > 0 && m_bClosable ) // title bar exists?
{
m_buttonClose = new CButton();
pc = (CButton*)m_buttonClose;
@@ -852,13 +808,13 @@ void CWindow::AdjustButtons()
{
m_buttonFull->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
- m_buttonFull->SetTooltip(res);
+ m_buttonFull->SetTooltip(std::string(res));
}
else
{
m_buttonFull->SetIcon(52);
GetResource(RES_TEXT, RT_WINDOW_MAXIMIZED, res);
- m_buttonFull->SetTooltip(res);
+ m_buttonFull->SetTooltip(std::string(res));
}
}
@@ -868,13 +824,13 @@ void CWindow::AdjustButtons()
{
m_buttonReduce->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
- m_buttonReduce->SetTooltip(res);
+ m_buttonReduce->SetTooltip(std::string(res));
}
else
{
m_buttonReduce->SetIcon(51);
GetResource(RES_TEXT, RT_WINDOW_MINIMIZED, res);
- m_buttonReduce->SetTooltip(res);
+ m_buttonReduce->SetTooltip(std::string(res));
}
}
@@ -882,7 +838,7 @@ void CWindow::AdjustButtons()
{
m_buttonClose->SetIcon(11); // x
GetResource(RES_TEXT, RT_WINDOW_CLOSE, res);
- m_buttonClose->SetTooltip(res);
+ m_buttonClose->SetTooltip(std::string(res));
}
}
@@ -992,7 +948,7 @@ bool CWindow::EventProcess(const Event &event)
{
m_pressMouse = Gfx::ENG_MOUSE_NORM;
- if ( m_name[0] != 0 && m_bMovable && // title bar?
+ if ( m_name.length() > 0 && m_bMovable && // title bar?
Detect(event.pos) )
{
flags = BorderDetect(event.pos);
@@ -1059,7 +1015,7 @@ bool CWindow::EventProcess(const Event &event)
{
if ( Detect(event.pos) )
{
- if ( m_name[0] != 0 && m_bMovable ) // title bar?
+ if ( m_name.length() > 0 && m_bMovable ) // title bar?
{
m_pressFlags = BorderDetect(event.pos);
if ( m_pressFlags != 0 )
@@ -1125,9 +1081,7 @@ bool CWindow::EventProcess(const Event &event)
m_event->AddEvent(newEvent);
}
- if ( event.type == EVENT_MOUSE_BUTTON_UP &&
- event.mouseButton == 1 &&
- m_bCapture )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 && m_bCapture )
{
m_bCapture = false;
}
@@ -1153,7 +1107,7 @@ void CWindow::Draw()
DrawVertex(m_pos, m_dim, m_icon); // draws the background
- if ( m_name[0] != 0 ) // title bar?
+ if ( m_name.length() > 0 ) // title bar?
{
h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
diff --git a/src/ui/window.h b/src/ui/window.h
index b122b67..9262a1a 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -19,9 +19,33 @@
#pragma once
-
+#include <string>
+
+#include <common/language.h>
+#include <common/event.h>
+#include <common/misc.h>
+#include <common/restext.h>
+
+#include <ui/button.h>
+#include <ui/color.h>
+#include <ui/check.h>
+#include <ui/key.h>
+#include <ui/group.h>
+#include <ui/image.h>
+#include <ui/label.h>
+#include <ui/edit.h>
+#include <ui/editvalue.h>
+#include <ui/scroll.h>
+#include <ui/slider.h>
+#include <ui/list.h>
+#include <ui/shortcut.h>
+#include <ui/map.h>
+#include <ui/gauge.h>
+#include <ui/compass.h>
+#include <ui/target.h>
#include <ui/control.h>
-//#include <common/event.h>
+
+#include <graphics/engine/text.h>
namespace Ui {
@@ -42,7 +66,7 @@ public:
CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
- CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, char *name);
+ CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
@@ -60,7 +84,7 @@ public:
EventType GetEventTypeFull();
EventType GetEventTypeClose();
- void SetName(char* name);
+ void SetName(std::string name);
void SetTrashEvent(bool bTrash);
bool GetTrashEvent();
@@ -89,7 +113,7 @@ public:
void SetFixed(bool bFix);
bool GetFixed();
- bool GetTooltip(Math::Point pos, char* name);
+ bool GetTooltip(Math::Point pos, std::string &name);
bool EventProcess(const Event &event);