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