Merge branch 'dev-ui' into dev

Conflicts:
	src/CMakeLists.txt
	src/common/misc.cpp
	src/common/misc.h
	src/object/robotmain.cpp
	src/object/robotmain.h
	src/script/cbottoken.cpp
	src/script/cbottoken.h
	src/ui/button.cpp
	src/ui/button.h
	src/ui/check.cpp
	src/ui/check.h
	src/ui/color.cpp
	src/ui/color.h
	src/ui/compass.cpp
	src/ui/compass.h
	src/ui/control.cpp
	src/ui/control.h
	src/ui/displayinfo.cpp
	src/ui/displayinfo.h
	src/ui/displaytext.cpp
	src/ui/displaytext.h
	src/ui/edit.cpp
	src/ui/edit.h
	src/ui/gauge.cpp
	src/ui/gauge.h
	src/ui/interface.cpp
	src/ui/interface.h
	src/ui/key.cpp
	src/ui/map.h
	src/ui/shortcut.h
	src/ui/slider.h
	src/ui/target.cpp
	src/ui/target.h
	src/ui/window.cpp
	src/ui/window.h
dev-ui
Michał Konopacki 2012-09-15 16:35:48 +02:00
commit d439f4fa93
45 changed files with 1709 additions and 1864 deletions

View File

@ -1,11 +1,14 @@
# CBot shared library is built separately
add_subdirectory(CBot)
<<<<<<< HEAD
# Tools directory is built separately
add_subdirectory(tools)
# Tests
add_subdirectory(graphics/engine/test)
=======
>>>>>>> dev-ui
# Configure options
@ -156,10 +159,10 @@ graphics/opengl/gldevice.cpp
# ui/check.cpp
# ui/color.cpp
# ui/compass.cpp
# ui/control.cpp
ui/control.cpp
# ui/displayinfo.cpp
# ui/displaytext.cpp
# ui/edit.cpp
ui/edit.cpp
# ui/editvalue.cpp
# ui/gauge.cpp
# ui/group.cpp

View File

@ -381,7 +381,7 @@ void UserDir(bool bUser, char* dir)
// def = "abc\"
// out: buffer = "abc\toto.txt"
void UserDir(char* buffer, char* dir, const char* def)
void UserDir(char* buffer, const char* dir, const char* def)
{
char ddir[100];
char* add;

View File

@ -99,7 +99,7 @@ extern bool CopyFileToTemp(char* filename);
extern bool CopyFileListToTemp(char* filename, int* list, int total);
extern void AddExt(char* filename, char* ext);
extern void UserDir(bool bUser, char* dir);
extern void UserDir(char* buffer, char* dir, const char* def);
extern void UserDir(char* buffer, const char* dir, const char* def);
extern char GetLanguageLetter();

File diff suppressed because it is too large Load Diff

View File

@ -300,9 +300,9 @@ protected:
Math::Vector LookatPoint( Math::Vector eye, float angleH, float angleV, float length );
CObject* CreateObject(Math::Vector pos, float angle, float zoom, float height, ObjectType type, float power=1.0f, bool bTrainer=false, bool bToy=false, int option=0);
int CreateLight(Math::Vector direction, Gfx::Color color);
void HiliteClear();
void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime);
void HighlightClear();
void HighlightObject(Math::Point pos);
void HighlightFrame(float rTime);
void CreateTooltip(Math::Point pos, char* text);
void ClearTooltip();
CObject* DetectObject(Math::Point pos);
@ -379,7 +379,7 @@ protected:
bool m_bEditLock; // edition in progress?
bool m_bEditFull; // edition in full screen?
bool m_bPause; // simulation paused
bool m_bHilite;
bool m_bHighlight;
bool m_bTrainerPilot; // remote trainer?
bool m_bSuspend;
bool m_bFriendAim;

View File

@ -33,7 +33,7 @@
// Seeking the name of an object.
const char* GetObjectName(ObjectType type)
char* GetObjectName(ObjectType type)
{
if ( type == OBJECT_PORTICO ) return "Portico";
if ( type == OBJECT_BASE ) return "SpaceShip";
@ -126,7 +126,7 @@ const char* GetObjectName(ObjectType type)
// Seeking the name of a secondary object.
// (because Otto thinks that Germans do not like nuclear power)
const char* GetObjectAlias(ObjectType type)
char* GetObjectAlias(ObjectType type)
{
if ( type == OBJECT_NUCLEAR ) return "FuelCellPlant";
if ( type == OBJECT_URANIUM ) return "PlatinumOre";
@ -139,7 +139,7 @@ const char* GetObjectAlias(ObjectType type)
// Returns the help file to use for the object.
const char* GetHelpFilename(ObjectType type)
char* GetHelpFilename(ObjectType type)
{
if ( type == OBJECT_BASE ) return "help\\object\\base.txt";
if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt";
@ -224,7 +224,7 @@ const char* GetHelpFilename(ObjectType type)
// Returns the help file to use for instruction.
const char* GetHelpFilename(const char *token)
char* GetHelpFilename(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt";
if ( strcmp(token, "else" ) == 0 ) return "help\\cbot\\if.txt";
@ -436,7 +436,7 @@ bool IsFunction(const char *token)
// Returns using a compact instruction.
const char* GetHelpText(const char *token)
char* GetHelpText(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }";
if ( strcmp(token, "else" ) == 0 ) return "else { bloc }";

View File

@ -25,10 +25,10 @@
// Procedures.
extern const char* GetObjectName(ObjectType type);
extern const char* GetObjectAlias(ObjectType type);
extern const char* GetHelpFilename(ObjectType type);
extern const char* GetHelpFilename(const char *token);
extern char* GetObjectName(ObjectType type);
extern char* GetObjectAlias(ObjectType type);
extern char* GetHelpFilename(ObjectType type);
extern char* GetHelpFilename(const char *token);
extern bool IsType(const char *token);
extern bool IsFunction(const char *token);
extern char* GetHelpText(const char *token);

View File

@ -16,20 +16,14 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
//#include "common/struct.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
//#include "common/language.h"
//#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
#include "ui/button.h"
#include "button.h"
#include <common/event.h>
#include <common/misc.h>
#include <common/restext.h>
#include <graphics/engine/engine.h>
namespace Ui {

View File

@ -19,39 +19,36 @@
#pragma once
#include "ui/control.h"
namespace Gfx{
class CEngine;
}
#include "control.h"
namespace Ui {
class CButton : public CControl
{
public:
CButton();
virtual ~CButton();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event);
class CButton : public CControl
{
public:
CButton();
virtual ~CButton();
void Draw();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
void SetImmediat(bool bRepeat);
bool GetImmediat();
bool EventProcess(const Event &event);
void SetRepeat(bool bRepeat);
bool GetRepeat();
void Draw();
protected:
void SetImmediat(bool bRepeat);
bool GetImmediat();
protected:
bool m_bCapture;
bool m_bImmediat;
bool m_bRepeat;
float m_repeat;
};
void SetRepeat(bool bRepeat);
bool GetRepeat();
protected:
protected:
bool m_bCapture;
bool m_bImmediat;
bool m_bRepeat;
float m_repeat;
};
}

View File

@ -16,21 +16,16 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
#include "check.h"
#include <common/event.h>
#include <common/iman.h>
#include <common/misc.h>
#include <common/restext.h>
#include <graphics/engine/engine.h>
#include <graphics/engine/text.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 "common/restext.h"
//#include "old/text.h"
#include "graphics/engine/text.h"
#include "ui/check.h"
namespace Ui {

View File

@ -19,30 +19,30 @@
#pragma once
#include "control.h"
#include "ui/control.h"
namespace Gfx{
class CEngine;
class CEngine;
}
namespace Ui {
class CCheck : public CControl
{
public:
CCheck();
virtual ~CCheck();
class CCheck : public CControl
{
public:
CCheck();
virtual ~CCheck();
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();
protected:
protected:
protected:
};
protected:
};
}

View File

@ -16,21 +16,15 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
#include "color.h"
//#include "common/struct.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
#include "graphics/core/device.h"
//#include "common/language.h"
//#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
#include "ui/color.h"
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
namespace Ui {

View File

@ -20,41 +20,40 @@
#pragma once
#include "ui/control.h"
//#include "graphics/engine/engine.h"
#include "control.h"
namespace Gfx{
class CEngine;
struct Color;
class CEngine;
struct Color;
}
namespace Ui {
class CColor : public CControl
{
public:
// CColor(CInstanceManager* iMan);
CColor();
virtual ~CColor();
class CColor : public CControl
{
public:
// CColor(CInstanceManager* iMan);
CColor();
virtual ~CColor();
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 SetRepeat(bool bRepeat);
bool GetRepeat();
void SetRepeat(bool bRepeat);
bool GetRepeat();
void SetColor(Gfx::Color color);
Gfx::Color GetColor();
void SetColor(Gfx::Color color);
Gfx::Color GetColor();
protected:
protected:
protected:
bool m_bRepeat;
float m_repeat;
Gfx::Color m_color;
};
protected:
bool m_bRepeat;
float m_repeat;
Gfx::Color m_color;
};
}

View File

@ -15,23 +15,16 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
#include "compass.h"
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
//#include "common/struct.h"
#include "math/geometry.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
#include "graphics/core/device.h"
//#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "ui/compass.h"
#include "common/misc.h"
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
#include "math/geometry.h"
namespace Ui {
// Object's constructor.

View File

@ -20,34 +20,35 @@
#pragma once
#include "ui/control.h"
#include "control.h"
namespace Gfx {
class CEngine;
class CEngine;
}
namespace Ui {
class CCompass : public CControl
{
public:
// CCompass(CInstanceManager* iMan);
CCompass();
virtual ~CCompass();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
class CCompass : public CControl
{
public:
// CCompass(CInstanceManager* iMan);
CCompass();
virtual ~CCompass();
bool EventProcess(const Event &event);
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
void Draw();
bool EventProcess(const Event &event);
void SetDirection(float dir);
float GetDirection();
void Draw();
protected:
void SetDirection(float dir);
float GetDirection();
protected:
float m_dir;
};
protected:
protected:
float m_dir;
};
}

View File

@ -16,29 +16,7 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
//#include <windows.h>
#include <stdio.h>
//#include <d3d.h>
#include "graphics/core/device.h"
//#include "common/struct.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
#include "common/language.h"
#include "common/restext.h"
//#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "object/robotmain.h"
//#include "old/particule.h"
#include "graphics/engine/particle.h"
#include "common/iman.h"
//#include "old/text.h"
#include "graphics/engine/text.h"
//#include "old/sound.h"
#include "sound/sound.h"
#include "ui/control.h"
#include "control.h"
namespace Ui {
@ -60,8 +38,6 @@ CControl::CControl()
m_fontType = Gfx::FONT_COLOBOT;
m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
// m_justif = 0;
m_name[0] = 0;
m_tooltip[0] = 0;
m_bFocus = false;
m_bCapture = false;
@ -84,10 +60,11 @@ CControl::~CControl()
bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
char text[100];
char* p;
char text[100];
std::string str_text;
if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
if ( eventType == EVENT_NULL )
eventType = GetUniqueEventType();
m_pos = pos;
m_dim = dim;
@ -99,17 +76,13 @@ bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType even
GlintCreate(pos);
GetResource(RES_EVENT, m_eventType, text);
p = strchr(text, '\\');
if ( p == 0 )
{
str_text = std::string(text);
auto p = str_text.find("\\");
if ( p == std::string::npos ) {
if ( icon != -1 )
{
strcpy(m_tooltip, text);
}
}
else
{
strcpy(m_tooltip, p+1); // text after "\\"
m_tooltip = str_text;
} else {
m_tooltip = str_text.substr(p + 1);
}
return true;
@ -202,41 +175,21 @@ int CControl::GetIcon()
// Management of the button name.
void CControl::SetName(char* name, bool bTooltip)
void CControl::SetName(std::string name, bool bTooltip)
{
char* p;
if ( bTooltip )
{
p = strchr(name, '\\');
if ( p == 0 )
{
strncpy(m_name, name, 100);
m_name[100-1] = 0;
if ( bTooltip ) {
auto p = name.find("\\");
if ( p == std::string::npos )
m_name = name;
else {
m_tooltip = name.substr(p + 1);
m_name = name.substr(0, p);
}
else
{
char buffer[100];
strncpy(m_tooltip, p+1, 100); // text after "\\"
m_tooltip[100-1] = 0;
strncpy(buffer, name, 100);
buffer[100-1] = 0;
p = strchr(buffer, '\\');
if ( p != 0 ) *p = 0;
strncpy(m_name, buffer, 100);
m_name[100-1] = 0;
}
}
else
{
strncpy(m_name, name, 100);
m_name[100-1] = 0;
}
} else
m_name = name;
}
char* CControl::GetName()
std::string CControl::GetName()
{
return m_name;
}
@ -298,21 +251,21 @@ Gfx::FontType CControl::GetFontType()
// Specifies the tooltip.
bool CControl::SetTooltip(const char* name)
bool CControl::SetTooltip(std::string name)
{
strcpy(m_tooltip, name);
m_tooltip = name;
return true;
}
bool CControl::GetTooltip(Math::Point pos, char* name)
bool CControl::GetTooltip(Math::Point pos, std::string &name)
{
if ( m_tooltip[0] == 0 ) return false;
if ( (m_state & STATE_VISIBLE) == 0 ) return false;
if ( m_tooltip.length() == 0 ) return false;
if ( (m_state & STATE_VISIBLE) == 0 ) return false;
if ( (m_state & STATE_ENABLE) == 0 ) return false;
if ( m_state & STATE_DEAD ) return false;
if ( !Detect(pos) ) return false;
strcpy(name, m_tooltip);
name = m_tooltip;
return true;
}
@ -454,7 +407,7 @@ void CControl::GlintFrame(const Event &event)
(m_state & STATE_ENABLE ) == 0 ||
(m_state & STATE_VISIBLE) == 0 ) return;
if ( !m_main->RetGlint() ) return;
if ( !m_main->GetGlint() ) return;
m_glintProgress += event.rTime;

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -18,129 +19,130 @@
#pragma once
#include <string>
//#include "old/text.h"
#include "graphics/engine/text.h"
//#include "common/struct.h"
#include "common/event.h"
#include <common/event.h>
#include <common/iman.h>
#include <common/language.h>
#include <common/misc.h>
#include <common/restext.h>
#include <graphics/core/device.h>
#include <graphics/engine/engine.h>
#include <graphics/engine/particle.h>
#include <graphics/engine/text.h>
#include <object/robotmain.h>
#include <sound/sound.h>
namespace Gfx {
class CEngine;
class CParticle;
};
class CInstanceManager;
class CEvent;
//class Gfx::CEngine;
class CRobotMain;
//class Gfx::CParticle;
class CSoundInterface;
namespace Ui {
enum ControlState
{
STATE_ENABLE = (1<<0), // active
STATE_CHECK = (1<<1), // pressed
STATE_HILIGHT = (1<<2), // overflown by mouse
STATE_PRESS = (1<<3), // pressed by mouse
STATE_VISIBLE = (1<<4), // visible
STATE_DEAD = (1<<5), // inaccessible (x)
STATE_DEFAULT = (1<<6), // actuated by RETURN
STATE_OKAY = (1<<7), // green point at the bottom right
STATE_SHADOW = (1<<8), // shadow
STATE_GLINT = (1<<9), // dynamic reflection
STATE_CARD = (1<<10), // tab
STATE_EXTEND = (1<<11), // extended mode
STATE_SIMPLY = (1<<12), // undecorated
STATE_FRAME = (1<<13), // framework highlighting
STATE_WARNING = (1<<14), // framework hatched yellow / black
STATE_VALUE = (1<<15), // displays the value
STATE_RUN = (1<<16) // running program
};
enum ControlState
{
STATE_ENABLE = (1<<0), // active
STATE_CHECK = (1<<1), // pressed
STATE_HILIGHT = (1<<2), // overflown by mouse
STATE_PRESS = (1<<3), // pressed by mouse
STATE_VISIBLE = (1<<4), // visible
STATE_DEAD = (1<<5), // inaccessible (x)
STATE_DEFAULT = (1<<6), // actuated by RETURN
STATE_OKAY = (1<<7), // green point at the bottom right
STATE_SHADOW = (1<<8), // shadow
STATE_GLINT = (1<<9), // dynamic reflection
STATE_CARD = (1<<10), // tab
STATE_EXTEND = (1<<11), // extended mode
STATE_SIMPLY = (1<<12), // undecorated
STATE_FRAME = (1<<13), // framework highlighting
STATE_WARNING = (1<<14), // framework hatched yellow / black
STATE_VALUE = (1<<15), // displays the value
STATE_RUN = (1<<16) // running program
};
class CControl
{
public:
// CControl(CInstanceManager* iMan);
CControl ();
virtual ~CControl();
class CControl
{
public:
// CControl(CInstanceManager* iMan);
CControl ();
virtual ~CControl();
virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
virtual bool EventProcess(const Event &event);
virtual bool EventProcess(const Event &event);
virtual void SetPos(Math::Point pos);
virtual Math::Point GetPos();
virtual void SetDim(Math::Point dim);
virtual Math::Point GetDim();
virtual bool SetState(int state, bool bState);
virtual bool SetState(int state);
virtual bool ClearState(int state);
virtual bool TestState(int state);
virtual int GetState();
virtual void SetIcon(int icon);
virtual int GetIcon();
virtual void SetName(char* name, bool bTooltip=true);
virtual char* GetName();
virtual void SetTextAlign(Gfx::TextAlign mode);
virtual int GetTextAlign();
virtual void SetFontSize(float size);
virtual float GetFontSize();
virtual void SetFontStretch(float stretch);
virtual float GetFontStretch();
virtual void SetFontType(Gfx::FontType font);
virtual Gfx::FontType GetFontType();
virtual bool SetTooltip(const char* name);
virtual bool GetTooltip(Math::Point pos, char* name);
virtual void SetFocus(bool bFocus);
virtual bool GetFocus();
virtual void SetPos(Math::Point pos);
virtual Math::Point GetPos();
virtual void SetDim(Math::Point dim);
virtual Math::Point GetDim();
virtual bool SetState(int state, bool bState);
virtual bool SetState(int state);
virtual bool ClearState(int state);
virtual bool TestState(int state);
virtual int GetState();
virtual void SetIcon(int icon);
virtual int GetIcon();
virtual void SetName(std::string name, bool bTooltip=true);
virtual std::string GetName();
virtual void SetTextAlign(Gfx::TextAlign mode);
virtual int GetTextAlign();
virtual void SetFontSize(float size);
virtual float GetFontSize();
virtual void SetFontStretch(float stretch);
virtual float GetFontStretch();
virtual void SetFontType(Gfx::FontType font);
virtual Gfx::FontType GetFontType();
virtual bool SetTooltip(std::string name);
virtual bool GetTooltip(Math::Point pos, std::string &name);
virtual void SetFocus(bool bFocus);
virtual bool GetFocus();
virtual EventType GetEventType();
virtual EventType GetEventType();
virtual void Draw();
virtual void Draw();
protected:
void GlintDelete();
void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
void GlintFrame(const Event &event);
void DrawPart(int icon, float zoom, float ex);
void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
void DrawWarning(Math::Point pos, Math::Point dim);
void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
virtual bool Detect(Math::Point pos);
protected:
void GlintDelete();
void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
void GlintFrame(const Event &event);
void DrawPart(int icon, float zoom, float ex);
void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
void DrawWarning(Math::Point pos, Math::Point dim);
void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
virtual bool Detect(Math::Point pos);
protected:
CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
CEventQueue* m_event;
CRobotMain* m_main;
Gfx::CParticle* m_particle;
CSoundInterface* m_sound;
protected:
CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
CEventQueue* m_event;
CRobotMain* m_main;
Gfx::CParticle* m_particle;
CSoundInterface* m_sound;
Math::Point m_pos; // corner upper / left
Math::Point m_dim; // dimensions
int m_icon;
EventType m_eventType; // message to send when clicking
int m_state; // states (STATE_ *)
float m_fontSize; // size of the button name
float m_fontStretch; // stretch of the font
Gfx::FontType m_fontType; // type of font
Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
// int m_justif; // type of justification (-1,0,1)
char m_name[100]; // name of the button
char m_tooltip[100]; // name of tooltip
bool m_bFocus;
bool m_bCapture;
bool m_bGlint;
Math::Point m_glintCorner1;
Math::Point m_glintCorner2;
float m_glintProgress;
Math::Point m_glintMouse;
};
Math::Point m_pos; // corner upper / left
Math::Point m_dim; // dimensions
int m_icon;
EventType m_eventType; // message to send when clicking
int m_state; // states (STATE_ *)
float m_fontSize; // size of the button name
float m_fontStretch; // stretch of the font
Gfx::FontType m_fontType; // type of font
Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
// int m_justif; // type of justification (-1,0,1)
std::string m_name; // name of the button
std::string m_tooltip; // name of tooltip
bool m_bFocus;
bool m_bCapture;
bool m_bGlint;
Math::Point m_glintCorner1;
Math::Point m_glintCorner2;
float m_glintProgress;
Math::Point m_glintMouse;
};
}

View File

@ -18,37 +18,32 @@
// displayinfo.cpp
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
#include "displayinfo.h"
#include "interface.h"
#include "button.h"
#include "slider.h"
#include "edit.h"
#include "group.h"
#include "window.h"
//#include "common/struct.h"
//#include "old/d3dengine.h"
//#include "old/d3dmath.h"
#include "graphics/engine/engine.h"
#include "common/language.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/language.h"
#include "common/misc.h"
#include "common/restext.h"
//#include "old/math3d.h"
#include "object/robotmain.h"
//#include "old/camera.h"
#include "graphics/core/light.h"
#include "graphics/engine/engine.h"
#include "graphics/engine/lightman.h"
#include "graphics/engine/particle.h"
#include "object/object.h"
#include "object/robotmain.h"
#include "object/motion/motion.h"
#include "object/motion/motiontoto.h"
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/slider.h"
#include "ui/edit.h"
#include "ui/group.h"
#include "ui/window.h"
//#include "old/particule.h"
#include "graphics/engine/particle.h"
//#include "old/light.h"
//#include "old/text.h"
#include "script/cbottoken.h"
#include "ui/displayinfo.h"
@ -67,7 +62,7 @@ CDisplayInfo::CDisplayInfo()
m_main = static_cast <CRobotMain*> (m_iMan->SearchInstance(CLASS_MAIN));
m_camera = static_cast <Gfx::CCamera*> (m_iMan->SearchInstance(CLASS_CAMERA));
m_particle = static_cast <Gfx::CParticle*> (m_iMan->SearchInstance(CLASS_PARTICULE));
m_light = static_cast <Gfx::CLight*> (m_iMan->SearchInstance(CLASS_LIGHT));
m_light = static_cast <Gfx::CLightManager*> (m_iMan->SearchInstance(CLASS_LIGHT));
m_bInfoMaximized = true;
m_bInfoMinimized = false;
@ -338,9 +333,9 @@ void CDisplayInfo::HyperUpdate()
// Beginning of the display of information.
void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluce)
{
Gfx::CLight light;
Gfx::Light light;
Math::Point pos, dim;
Ui::CWindow* pw;
Ui::CEdit* edit;
@ -389,8 +384,8 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
edit->SetMaxChar(10000);
edit->SetFontType(Gfx::FONT_COLOBOT);
edit->SetSoluceMode(bSoluce);
edit->ReadText(filename);
edit->HyperHome(filename);
edit->ReadText(filename.c_str());
edit->HyperHome(filename.c_str());
edit->SetEditCap(false); // just to see!
edit->SetHiliteCap(false);
edit->SetFocus(true);
@ -435,7 +430,7 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
button->SetState(STATE_SHADOW);
slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE);
slider->SetState(STATE_SHADOW);
slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
button = pw->CreateButton(pos, dim, 61, EVENT_HYPER_COPY);
button->SetState(STATE_SHADOW);
HyperUpdate();
@ -464,16 +459,14 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
toto->StartDisplayInfo();
}
}
// TODO
ZeroMemory(&light, sizeof(light));
light.dltType = D3DLIGHT_DIRECTIONAL;
light.dcvDiffuse.r = 1.0f;
light.dcvDiffuse.g = 1.0f;
light.dcvDiffuse.b = 1.0f;
light.dvDirection = D3DVECTOR(1.0f, 0.0f, 1.0f);
light.type = Gfx::LIGHT_DIRECTIONAL;
light.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f);
light.direction = Math::Vector(1.0f, 0.0f, 1.0f);
m_lightSuppl = m_light->CreateLight();
m_light->SetLight(m_lightSuppl, light);
m_light->SetLightExcluType(m_lightSuppl, TYPETERRAIN);
m_light->SetLightExcludeType(m_lightSuppl, Gfx::ENG_OBJTYPE_TERRAIN);
}
// Repositions all controls editing.
@ -719,7 +712,7 @@ void CDisplayInfo::UpdateIndexButton()
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_HUSTON);
filename = m_main->RetDisplayInfoName(SATCOM_HUSTON);
filename = m_main->GetDisplayInfoName(SATCOM_HUSTON);
button->SetState(STATE_VISIBLE, filename[0]!=0);
}
@ -727,7 +720,7 @@ void CDisplayInfo::UpdateIndexButton()
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_SAT);
filename = m_main->RetDisplayInfoName(SATCOM_SAT);
filename = m_main->GetDisplayInfoName(SATCOM_SAT);
button->SetState(STATE_VISIBLE, filename[0]!=0);
}
@ -735,7 +728,7 @@ void CDisplayInfo::UpdateIndexButton()
//? if ( button != 0 )
//? {
//? button->SetState(STATE_CHECK, m_index==SATCOM_OBJECT);
//? filename = m_main->RetDisplayInfoName(SATCOM_OBJECT);
//? filename = m_main->GetDisplayInfoName(SATCOM_OBJECT);
//? button->SetState(STATE_VISIBLE, filename[0]!=0);
//? }
@ -744,7 +737,7 @@ void CDisplayInfo::UpdateIndexButton()
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_LOADING);
loading = m_main->RetDisplayInfoName(SATCOM_LOADING);
loading = m_main->GetDisplayInfoName(SATCOM_LOADING);
button->SetState(STATE_VISIBLE, loading[0]!=0);
}
@ -752,7 +745,7 @@ void CDisplayInfo::UpdateIndexButton()
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_PROG);
filename = m_main->RetDisplayInfoName(SATCOM_PROG);
filename = m_main->GetDisplayInfoName(SATCOM_PROG);
button->SetState(STATE_VISIBLE, filename[0]!=0 && (m_index==SATCOM_LOADING||m_index==SATCOM_PROG||(loading!=0&&loading[0]==0)));
}
@ -760,7 +753,7 @@ void CDisplayInfo::UpdateIndexButton()
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_SOLUCE);
filename = m_main->RetDisplayInfoName(SATCOM_SOLUCE);
filename = m_main->GetDisplayInfoName(SATCOM_SOLUCE);
button->SetState(STATE_VISIBLE, filename[0]!=0 && m_bSoluce);
}
@ -858,12 +851,12 @@ void CDisplayInfo::StopDisplayInfo()
m_engine->SetDrawWorld(true); // draws all on the interface
m_engine->SetDrawFront(false); // draws nothing on the interface
m_particle->SetFrameUpdate(Gfx::SH_WORLD, true);
m_particle->FlushParticule(Gfx::SH_FRONT);
m_particle->FlushParticule(Gfx::SH_INTERFACE);
m_particle->FlushParticle(Gfx::SH_FRONT);
m_particle->FlushParticle(Gfx::SH_INTERFACE);
if ( m_toto != 0 )
{
toto = (CMotionToto*)m_toto->GetMotion();
toto = static_cast<CMotionToto*>(m_toto->GetMotion());
if ( toto != 0 )
{
toto->StopDisplayInfo();
@ -915,7 +908,7 @@ void CDisplayInfo::ViewDisplayInfo()
{
Ui::CWindow* pw;
Ui::CEdit* edit;
Math::Point dim;
Math::IntPoint dim;
pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
@ -923,7 +916,7 @@ void CDisplayInfo::ViewDisplayInfo()
edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return;
dim = m_engine->GetDim();
dim = m_engine->GetWindowSize();
edit->SetFontSize(m_main->GetFontSize()/(dim.x / 640.0f));
}

View File

@ -19,83 +19,81 @@
#pragma once
#include <string>
#include "common/struct.h"
#include "old/camera.h"
#include "common/event.h"
#include "graphics/engine/camera.h"
class CInstanceManager;
//class CD3DEngine;
class CEvent;
class CRobotMain;
//class CCamera;
class CObject;
//class CLight;
class CEventQueue;
struct Event;
namespace Gfx {
class CEngine;
class Camera;
class Particle;
class CLight;
class CEngine;
class CParticle;
class CLightManager;
}
namespace Ui {
class CInterface;
class CInterface;
class CDisplayInfo
{
public:
// CDisplayInfo(CInstanceManager* iMan);
CDisplayInfo();
~CDisplayInfo();
class CDisplayInfo
{
public:
// CDisplayInfo(CInstanceManager* iMan);
CDisplayInfo();
~CDisplayInfo();
bool EventProcess(const Event &event);
bool EventProcess(const Event &event);
void StartDisplayInfo(char *filename, int index, bool bSoluce);
void StopDisplayInfo();
void StartDisplayInfo(std::string filename, int index, bool bSoluce);
void StopDisplayInfo();
void SetPosition(int pos);
int GetPosition();
void SetPosition(int pos);
int GetPosition();
protected:
bool EventFrame(const Event &event);
void HyperUpdate();
void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
void ChangeIndexButton(int index);
void UpdateIndexButton();
void UpdateCopyButton();
void ViewDisplayInfo();
CObject* SearchToto();
void CreateObjectsFile();
protected:
bool EventFrame(const Event &event);
void HyperUpdate();
void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
void ChangeIndexButton(int index);
void UpdateIndexButton();
void UpdateCopyButton();
void ViewDisplayInfo();
CObject* SearchToto();
void CreateObjectsFile();
protected:
CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
CEventQueue* m_event;
CRobotMain* m_main;
Gfx::CCamera* m_camera;
CInterface* m_interface;
Gfx::CParticle* m_particle;
Gfx::CLight* m_light;
protected:
CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
CEventQueue* m_event;
CRobotMain* m_main;
Gfx::CCamera* m_camera;
CInterface* m_interface;
Gfx::CParticle* m_particle;
Gfx::CLightManager* m_light;
bool m_bInfoMaximized;
bool m_bInfoMinimized;
bool m_bInfoMaximized;
bool m_bInfoMinimized;
int m_index;
Gfx::CameraType m_infoCamera;
Math::Point m_infoNormalPos;
Math::Point m_infoNormalDim;
Math::Point m_infoActualPos;
Math::Point m_infoActualDim;
Math::Point m_infoFinalPos;
Math::Point m_infoFinalDim;
int m_lightSuppl;
bool m_bEditLock;
bool m_bInitPause;
bool m_bSoluce;
CObject* m_toto;
};
int m_index;
Gfx::CameraType m_infoCamera;
Math::Point m_infoNormalPos;
Math::Point m_infoNormalDim;
Math::Point m_infoActualPos;
Math::Point m_infoActualDim;
Math::Point m_infoFinalPos;
Math::Point m_infoFinalDim;
int m_lightSuppl;
bool m_bEditLock;
bool m_bInitPause;
bool m_bSoluce;
CObject* m_toto;
};
}

View File

@ -18,29 +18,26 @@
// displaytext.cpp
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
#include "displaytext.h"
#include "interface.h"
#include "button.h"
#include "label.h"
#include "window.h"
#include "group.h"
//#include "common/struct.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
#include "common/event.h"
#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
#include "common/iman.h"
#include "graphics/engine/engine.h"
#include "object/object.h"
#include "object/motion/motion.h"
#include "object/motion/motiontoto.h"
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/label.h"
#include "ui/window.h"
#include "ui/group.h"
//#include "old/text.h"
//#include "old/sound.h"
//#include "sound/sound.h"
#include "ui/displaytext.h"
namespace Ui {
@ -183,7 +180,7 @@ void CDisplayText::DisplayError(Error err, Math::Vector goal, float height,
// Displays text.
void CDisplayText::DisplayText(const char *text, CObject* pObj,
void CDisplayText::DisplayText(char *text, CObject* pObj,
float time, TextType type)
{
Math::Vector pos;
@ -199,7 +196,7 @@ void CDisplayText::DisplayText(const char *text, CObject* pObj,
// Displays text.
void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height,
void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
float dist, float time, TextType type)
{
CObject* toto;

View File

@ -22,8 +22,9 @@
#include "common/event.h"
#include "common/misc.h"
#include "sound/sound.h"
//#include "old/d3dengine.h"
class CInstanceManager;
@ -31,6 +32,10 @@ class CInstanceManager;
class CObject;
class CSound;
namespace Gfx {
class CEngine;
}
namespace Ui {;
class CInterface;
@ -59,8 +64,8 @@ public:
void DisplayError(Error err, CObject* pObj, float time=10.0f);
void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f);
void DisplayText(const char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO);
void DisplayText(const char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO);
void DisplayText(char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO);
void DisplayText(char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO);
void HideText(bool bHide);
void ClearText();
bool ClearLastText();

View File

@ -18,26 +18,7 @@
// edit.cpp
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
//#include <windows.h>
//#include <d3d.h>
//#include "common/struct.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
#include "common/language.h"
//#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
#include "ui/scroll.h"
//#include "old/text.h"
#include "graphics/engine/text.h"
//#include "graphics/engine/color.h"
#include "ui/edit.h"
#include "edit.h"
namespace Ui {
@ -96,9 +77,9 @@ CEdit::CEdit () : CControl ()
int i;
m_maxChar = 100;
m_text = new char* [sizeof(char)*(m_maxChar+1)]; // TODO
m_format = 0;
m_text = new char[sizeof(char)*(m_maxChar+1)];
m_len = 0;
m_app = CApplication::GetInstancePointer();
m_fontType = Gfx::FONT_COURIER;
m_scroll = 0;
@ -139,7 +120,6 @@ CEdit::~CEdit()
}
delete m_text;
delete m_format;
delete m_scroll;
}
@ -565,7 +545,7 @@ bool CEdit::IsLinkPos(Math::Point pos)
{
int i;
if ( m_format == 0 ) return false;
if ( m_format.size() == 0 ) return false;
i = MouseDetect(pos);
if ( i == -1 ) return false;
@ -645,7 +625,7 @@ void CEdit::MouseRelease(Math::Point mouse)
if ( !m_bEdit )
{
if ( m_format != 0 && i < m_len && m_cursor1 == m_cursor2 &&
if ( m_format.size() > 0 && i < m_len && m_cursor1 == m_cursor2 &&
(m_format[i]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) //TODO
{
rank = -1;
@ -712,7 +692,7 @@ int CEdit::MouseDetect(Math::Point mouse)
pos.y = m_pos.y+m_dim.y-m_lineHeight-(m_bMulti?MARGY:MARGY1);
for ( i=m_lineFirst ; i<m_lineTotal ; i++ )
{
bTitle = ( m_format != 0 && (m_format[m_lineOffset[i]]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG );
bTitle = ( m_format.size() > 0 && (m_format[m_lineOffset[i]]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG );
if ( i >= m_lineFirst+m_lineVisible ) break;
@ -729,12 +709,12 @@ int CEdit::MouseDetect(Math::Point mouse)
{
len = m_lineOffset[i+1] - m_lineOffset[i];
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
// c = m_engine->GetText()->Detect(m_text+m_lineOffset[i],
// len, offset, m_fontSize,
// m_fontStretch, m_fontType);
c = m_engine->GetText()->Detect(m_text+m_lineOffset[i], m_fontType, m_fontSize, offset); // TODO check if good
c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]), m_fontType, m_fontSize, offset); // TODO check if good
}
else
{
@ -745,7 +725,10 @@ int CEdit::MouseDetect(Math::Point mouse)
// m_format+m_lineOffset[i],
// len, offset, size,
// m_fontStretch);
c = m_engine->GetText()->Detect(m_text+m_lineOffset[i],m_format+m_lineOffset[i], size, offset); // TODO check if good
c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]),
std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()),
size,
offset); // TODO check if good
}
return m_lineOffset[i]+c;
}
@ -767,7 +750,7 @@ void CEdit::HyperFlush()
// Indicates which is the home page.
void CEdit::HyperHome(char *filename)
void CEdit::HyperHome(const char *filename)
{
HyperFlush();
HyperAdd(filename, 0);
@ -775,7 +758,7 @@ void CEdit::HyperHome(char *filename)
// Performs a hyper jump through a link.
void CEdit::HyperJump(char *name, char *marker)
void CEdit::HyperJump(const char *name, const char *marker)
{
char filename[100];
char sMarker[100];
@ -826,7 +809,7 @@ void CEdit::HyperJump(char *name, char *marker)
// Adds text to the history of visited.
bool CEdit::HyperAdd(char *filename, int firstLine)
bool CEdit::HyperAdd(const char *filename, int firstLine)
{
if ( m_historyCurrent >= EDITHISTORYMAX-1 ) return false;
@ -958,7 +941,7 @@ void CEdit::Draw()
size = m_fontSize;
// Headline \b;?
if ( beg+len < m_len && m_format != 0 &&
if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG )
{
start.x = ppos.x-MARGX;
@ -972,7 +955,7 @@ void CEdit::Draw()
}
// As \t;?
if ( beg+len < m_len && m_format != 0 &&
if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_NORM )
{
start.x = ppos.x-MARGX;
@ -983,7 +966,7 @@ void CEdit::Draw()
}
// Subtitle \s;?
if ( beg+len < m_len && m_format != 0 &&
if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_LITTLE )
{
start.x = ppos.x-MARGX;
@ -994,7 +977,7 @@ void CEdit::Draw()
}
// Table \tab;?
if ( beg+len < m_len && m_format != 0 &&
if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE )
{
start.x = ppos.x-MARGX;
@ -1005,7 +988,7 @@ void CEdit::Draw()
}
// Image \image; ?
if ( beg+len < m_len && m_format != 0 &&
if ( beg+len < m_len && m_format.size() > 0 &&
(m_format[beg]&Gfx::FONT_MASK_IMAGE) != 0 )
{
line = 1;
@ -1034,20 +1017,24 @@ void CEdit::Draw()
o1 = c1; if ( o1 < beg ) o1 = beg;
o2 = c2; if ( o2 > beg+len ) o2 = beg+len;
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
start.x = ppos.x+m_engine->GetText()->GetStringWidth(m_text+beg, m_fontType, size);
end.x = m_engine->GetText()->GetStringWidth(m_text+o1, m_fontType, size);
start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg), m_fontType, size);
end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1), m_fontType, size);
}
else
{
start.x = ppos.x+m_engine->GetText()->GetStringWidth(m_text+beg, m_format+beg, size);
end.x = m_engine->GetText()->GetStringWidth(m_text+o1, m_format+o1, size);
start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg),
std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()),
size);
end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1),
std::vector<Gfx::FontMetaChar>(m_format.begin()+o1, m_format.end()),
size);
}
start.y = ppos.y-(m_bMulti?0.0f:MARGY1);
end.y = m_lineHeight;
if ( m_format != 0 && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT;
if ( m_format.size() > 0 && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT;
DrawPart(start, end, 1); // plain yellow background
}
@ -1062,13 +1049,19 @@ void CEdit::Draw()
eol = 2; // square (eot)
}
if ( !m_bMulti || !m_bDisplaySpec ) eol = 0;
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
m_engine->GetText()->DrawText(m_text+beg, m_fontType, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, eol);
m_engine->GetText()->DrawText(std::string(m_text+beg), m_fontType, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, eol);
}
else
{
m_engine->GetText()->DrawText(m_text+beg, m_format+beg, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, eol);
m_engine->GetText()->DrawText(std::string(m_text+beg),
std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()),
size,
ppos,
m_dim.x,
Gfx::TEXT_ALIGN_RIGHT,
eol);
}
pos.y -= m_lineHeight;
@ -1096,16 +1089,16 @@ void CEdit::Draw()
len = m_cursor1 - m_lineOffset[i];
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
m_engine->GetText()->SizeText(m_text+m_lineOffset[i], m_fontType,
m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]), m_fontType,
size, pos, Gfx::TEXT_ALIGN_RIGHT,
start, end);
}
else
{
m_engine->GetText()->SizeText(m_text+m_lineOffset[i],
m_format+m_lineOffset[i],
m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]),
std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()),
size, pos, Gfx::TEXT_ALIGN_RIGHT,
start, end);
}
@ -1129,7 +1122,7 @@ void CEdit::Draw()
// Draw an image part.
void CEdit::DrawImage(Math::Point pos, char *name, float width,
void CEdit::DrawImage(Math::Point pos, const char *name, float width,
float offset, float height, int nbLine)
{
Math::Point uv1, uv2, dim;
@ -1242,7 +1235,7 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon)
// Give the text to edit.
void CEdit::SetText(char *text, bool bNew)
void CEdit::SetText(const char *text, bool bNew)
{
int i, j, font;
bool bBOL;
@ -1252,7 +1245,7 @@ void CEdit::SetText(char *text, bool bNew)
m_len = strlen(text);
if ( m_len > m_maxChar ) m_len = m_maxChar;
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
if ( m_bAutoIndent )
{
@ -1382,7 +1375,7 @@ int CEdit::GetTextLength()
// Returns a name in a command.
// \x nom1 nom2 nom3;
void GetNameParam(char *cmd, int rank, char *buffer)
void GetNameParam(const char *cmd, int rank, char *buffer)
{
int i;
@ -1405,7 +1398,7 @@ void GetNameParam(char *cmd, int rank, char *buffer)
// Returns a number of a command.
// \x nom n1 n2;
int GetValueParam(char *cmd, int rank)
int GetValueParam(const char *cmd, int rank)
{
int n, i;
@ -1440,7 +1433,7 @@ void CEdit::FreeImage()
// Reads the texture of an image.
void CEdit::LoadImage(char *name)
void CEdit::LoadImage(const char *name)
{
char filename[100];
@ -1452,7 +1445,7 @@ void CEdit::LoadImage(char *name)
// Read from a text file.
bool CEdit::ReadText(char *filename, int addSize)
bool CEdit::ReadText(const char *filename, int addSize)
{
FILE *file = NULL;
char *buffer;
@ -1482,10 +1475,9 @@ bool CEdit::ReadText(char *filename, int addSize)
buffer = new char[sizeof(char)*(m_maxChar+1)];
fread(buffer, 1, len, file);
if ( m_format != 0 )
if ( m_format.size() > 0 )
{
delete m_format;
m_format = new char[sizeof(char)*m_maxChar];
m_format.clear();
}
fclose(file);
@ -1507,7 +1499,7 @@ bool CEdit::ReadText(char *filename, int addSize)
if ( !bBOL )
{
m_text[j] = buffer[i];
if ( m_format != 0 ) m_format[j] = font;
if ( m_format.size() > 0 ) m_format[j] = font;
j ++;
}
i ++;
@ -1520,7 +1512,7 @@ bool CEdit::ReadText(char *filename, int addSize)
{
i ++;
}
else if ( m_format != 0 && buffer[i] == '\\' && buffer[i+2] == ';' )
else if ( m_format.size() > 0 && buffer[i] == '\\' && buffer[i+2] == ';' )
{
if ( buffer[i+1] == 'n' ) // normal ?
{
@ -1581,7 +1573,7 @@ bool CEdit::ReadText(char *filename, int addSize)
i += 3;
}
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \u marker name; ?
buffer[i+1] == 'u' &&
buffer[i+2] == ' ' )
@ -1598,7 +1590,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \m marker; ?
buffer[i+1] == 'm' &&
buffer[i+2] == ' ' )
@ -1614,7 +1606,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \image name lx ly; ?
buffer[i+1] == 'i' &&
buffer[i+2] == 'm' &&
@ -1651,7 +1643,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \button; ?
buffer[i+1] == 'b' &&
buffer[i+2] == 'u' &&
@ -1669,7 +1661,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \token; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'o' &&
@ -1685,7 +1677,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 7;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \type; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'y' &&
@ -1700,7 +1692,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 6;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \const; ?
buffer[i+1] == 'c' &&
buffer[i+2] == 'o' &&
@ -1716,7 +1708,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 7;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \key; ?
buffer[i+1] == 'k' &&
buffer[i+2] == 'e' &&
@ -1730,7 +1722,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 5;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \tab; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'a' &&
@ -1743,7 +1735,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 5;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \norm; ?
buffer[i+1] == 'n' &&
buffer[i+2] == 'o' &&
@ -1757,7 +1749,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += 6;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \begin soluce; ?
buffer[i+1] == 'b' &&
buffer[i+2] == 's' &&
@ -1766,7 +1758,7 @@ bool CEdit::ReadText(char *filename, int addSize)
bInSoluce = true;
i += 4;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \end soluce; ?
buffer[i+1] == 'e' &&
buffer[i+2] == 's' &&
@ -1775,7 +1767,7 @@ bool CEdit::ReadText(char *filename, int addSize)
bInSoluce = false;
i += 4;
}
else if ( m_format != 0 &&
else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \key name; ?
buffer[i+1] == 'k' &&
buffer[i+2] == 'e' &&
@ -1786,7 +1778,7 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( SearchKey(buffer+i+5, key) )
{
res = m_engine->GetKey(key, 0); // TODO
res = m_app->GetKey(key, 0); // TODO
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@ -1805,7 +1797,7 @@ bool CEdit::ReadText(char *filename, int addSize)
m_format[j] = font;
j ++;
res = m_engine->GetKey(key, 1); // TODO
res = m_app->GetKey(key, 1); // TODO
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@ -1846,7 +1838,7 @@ bool CEdit::ReadText(char *filename, int addSize)
if ( m_bSoluce || !bInSoluce )
{
m_text[j] = buffer[i];
if ( m_format != 0 ) m_format[j] = font;
if ( m_format.size() > 0 ) m_format[j] = font;
j ++;
}
i ++;
@ -1871,7 +1863,7 @@ bool CEdit::ReadText(char *filename, int addSize)
// Writes all the text in a file.
bool CEdit::WriteText(char *filename)
bool CEdit::WriteText(const char *filename)
{
FILE* file;
char buffer[1000+20];
@ -1943,10 +1935,9 @@ void CEdit::SetMaxChar(int max)
delete m_text;
m_text = (char*)malloc(sizeof(char)*(m_maxChar+1));
if ( m_format != 0 )
if ( m_format.size() > 0 )
{
delete m_format;
m_format = (char*)malloc(sizeof(char)*m_maxChar);
m_format.clear();
}
m_len = 0;
@ -2135,22 +2126,12 @@ bool CEdit::GetDisplaySpec()
void CEdit::SetMultiFont(bool bMulti)
{
if ( bMulti )
{
delete m_format;
m_format = (char*)malloc(sizeof(char)*m_maxChar);
memset(m_format, 0, m_maxChar);
}
else
{
delete m_format;
m_format = 0;
}
m_format.clear();
}
bool CEdit::GetMultiFont()
{
return ( m_format != 0 );
return ( m_format.size() > 0 );
}
@ -2439,16 +2420,16 @@ void CEdit::MoveLine(int move, bool bWord, bool bSelect)
column -= indentLength*m_lineIndent[line];
}
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
c = m_engine->GetText()->Detect(m_text+m_lineOffset[line],
c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]),
m_fontType, m_fontSize,
m_lineOffset[line+1]-m_lineOffset[line]);
}
else
{
c = m_engine->GetText()->Detect(m_text+m_lineOffset[line],
m_format+m_lineOffset[line],
c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]),
std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()),
m_fontSize,
m_lineOffset[line+1]-m_lineOffset[line]);
}
@ -2469,17 +2450,17 @@ void CEdit::ColumnFix()
line = GetCursorLine(m_cursor1);
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
m_column = m_engine->GetText()->GetStringWidth(
m_text+m_lineOffset[line],
std::string(m_text+m_lineOffset[line]),
m_fontType, m_fontSize);
}
else
{
m_column = m_engine->GetText()->GetStringWidth(
m_text+m_lineOffset[line],
m_format+m_lineOffset[line],
std::string(m_text+m_lineOffset[line]),
std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()),
m_fontSize
);
}
@ -2497,7 +2478,7 @@ void CEdit::ColumnFix()
bool CEdit::Cut() // TODO MS Windows allocations
{
HGLOBAL hg;
/* HGLOBAL hg;
char* text;
char c;
int c1, c2, start, len, i, j;
@ -2570,7 +2551,7 @@ bool CEdit::Cut() // TODO MS Windows allocations
DeleteOne(0); // deletes the selected characters
Justif();
ColumnFix();
SendModifEvent();
SendModifEvent();*/
return true;
}
@ -2578,7 +2559,7 @@ bool CEdit::Cut() // TODO MS Windows allocations
bool CEdit::Copy() // TODO
{
HGLOBAL hg;
/* HGLOBAL hg;
char* text;
char c;
int c1, c2, start, len, i, j;
@ -2642,7 +2623,7 @@ bool CEdit::Copy() // TODO
return false;
}
CloseClipboard();
*/
return true;
}
@ -2650,7 +2631,7 @@ bool CEdit::Copy() // TODO
bool CEdit::Paste() // TODO
{
HANDLE h;
/*HANDLE h;
char c;
char* p;
@ -2688,7 +2669,7 @@ bool CEdit::Paste() // TODO
Justif();
ColumnFix();
SendModifEvent();
SendModifEvent();*/
return true;
}
@ -2821,7 +2802,7 @@ void CEdit::InsertOne(char character)
{
m_text[i] = m_text[i-1]; // shoot
if ( m_format != 0 )
if ( m_format.size() > 0 )
{
m_format[i] = m_format[i-1]; // shoot
}
@ -2831,7 +2812,7 @@ void CEdit::InsertOne(char character)
m_text[m_cursor1] = character;
if ( m_format != 0 )
if ( m_format.size() > 0 )
{
m_format[m_cursor1] = 0;
}
@ -2882,7 +2863,7 @@ void CEdit::DeleteOne(int dir)
{
m_text[i] = m_text[i+hole];
if ( m_format != 0 )
if ( m_format.size() > 0 )
{
m_format[i] = m_format[i+hole];
}
@ -3074,7 +3055,7 @@ void CEdit::Justif()
width -= indentLength*m_lineIndent[m_lineTotal-1];
}
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
// TODO check if good
i += m_engine->GetText()->Justify(m_text+i, m_fontType,
@ -3097,8 +3078,10 @@ void CEdit::Justif()
else
{
// TODO check if good
i += m_engine->GetText()->Justify(m_text+i, m_format+i,
size, width);
i += m_engine->GetText()->Justify(std::string(m_text+i),
std::vector<Gfx::FontMetaChar>(m_format.begin()+i, m_format.end()),
size,
width);
}
}
@ -3293,11 +3276,11 @@ bool CEdit::UndoRecall()
bool CEdit::ClearFormat()
{
if ( m_format == 0 )
if ( m_format.size() == 0 )
{
SetMultiFont(true);
}
memset(m_format, m_fontType, m_len);
m_format.clear();
return true;
}
@ -3308,7 +3291,7 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format)
{
int i;
if ( m_format == 0 ) return false;
if ( m_format.size() == 0 ) return false;
for ( i=cursor1 ; i<cursor2 ; i++ )
{

View File

@ -24,15 +24,26 @@
#pragma once
//#include "common/struct.h"
#include "ui/control.h"
#include <ui/control.h>
#include <ui/scroll.h>
#include <graphics/engine/engine.h>
#include <graphics/engine/text.h>
#include <common/language.h>
#include <common/event.h>
#include <common/misc.h>
#include <common/iman.h>
#include <common/restext.h>
#include <app/app.h>
#include <vector>
namespace Gfx{
class CEngine;
};
namespace Ui {
class CScroll;
//! maximum number of characters in CBOT edit
@ -128,13 +139,13 @@ public:
bool EventProcess(const Event &event);
void Draw();
void SetText(char *text, bool bNew=true);
void SetText(const char *text, bool bNew=true);
void GetText(char *buffer, int max);
char* GetText();
int GetTextLength();
bool ReadText(char *filename, int addSize=0);
bool WriteText(char *filename);
bool ReadText(const char *filename, int addSize=0);
bool WriteText(const char *filename);
void SetMaxChar(int max);
int GetMaxChar();
@ -176,7 +187,7 @@ public:
bool Undo();
void HyperFlush();
void HyperHome(char *filename);
void HyperHome(const char *filename);
bool HyperTest(EventType event);
bool HyperGo(EventType event);
@ -195,15 +206,15 @@ protected:
int MouseDetect(Math::Point mouse);
void MoveAdjust();
void HyperJump(char *name, char *marker);
bool HyperAdd(char *filename, int firstLine);
void HyperJump(const char *name, const char *marker);
bool HyperAdd(const char *filename, int firstLine);
void DrawImage(Math::Point pos, char *name, float width, float offset, float height, int nbLine);
void DrawImage(Math::Point pos, const char *name, float width, float offset, float height, int nbLine);
void DrawBack(Math::Point pos, Math::Point dim);
void DrawPart(Math::Point pos, Math::Point dim, int icon);
void FreeImage();
void LoadImage(char *name);
void LoadImage(const char *name);
void Scroll(int pos, bool bAdjustCursor);
void Scroll();
void MoveChar(int move, bool bWord, bool bSelect);
@ -232,10 +243,11 @@ protected:
int m_maxChar; // max length of the buffer m_text
char* m_text; // text (without zero terminator)
char* m_format; // format characters
std::vector<Gfx::FontMetaChar> m_format; // format characters
int m_len; // length used in m_text
int m_cursor1; // offset cursor
int m_cursor2; // offset cursor
CApplication *m_app;
bool m_bMulti; // true -> multi-line
bool m_bEdit; // true -> editable

View File

@ -18,19 +18,7 @@
// gauge.cpp
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
//#include "common/struct.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
//#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "ui/gauge.h"
#include <ui/gauge.h>
namespace Ui {

View File

@ -19,35 +19,36 @@
#pragma once
#include <graphics/engine/engine.h>
#include "ui/control.h"
#include <common/event.h>
#include <common/misc.h>
#include <ui/control.h>
namespace Gfx{
class CEngine;
};
namespace Ui {
class CGauge : public CControl
{
public:
// CGauge(CInstanceManager* iMan);
CGauge();
virtual ~CGauge();
public:
// CGauge(CInstanceManager* iMan);
CGauge();
virtual ~CGauge();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event);
bool EventProcess(const Event &event);
void Draw();
void Draw();
void SetLevel(float level);
float GetLevel();
void SetLevel(float level);
float GetLevel();
protected:
protected:
protected:
float m_level;
protected:
float m_level;
};

View File

@ -162,7 +162,7 @@ CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, Even
// Creates a new label.
CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, const char *name)
CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name)
{
CLabel* pc = CreateControl<CLabel>(pos, dim, icon, eventMsg);
if (pc != nullptr)
@ -297,7 +297,7 @@ bool CInterface::EventProcess(const Event &event)
// Gives the tooltip binding to the window.
bool CInterface::GetTooltip(Math::Point pos, const char* name)
bool CInterface::GetTooltip(Math::Point pos, std::string &name)
{
for (int i = MAXCONTROL-1; i >= 0; i--) {
if (m_table[i] != nullptr) {

View File

@ -19,6 +19,7 @@
#pragma once
#include <string>
#include <common/event.h>
#include <common/struct.h>
@ -30,29 +31,29 @@
#include <graphics/engine/camera.h>
#include <graphics/engine/engine.h>
#include <ui/control.h>
#include <ui/button.h>
#include <ui/color.h>
#include <ui/check.h>
#include <ui/key.h>
#include <ui/group.h>
#include <ui/image.h>
#include <ui/label.h>
#include <ui/edit.h>
#include <ui/editvalue.h>
#include <ui/scroll.h>
#include <ui/slider.h>
#include <ui/list.h>
#include <ui/shortcut.h>
#include <ui/compass.h>
#include <ui/target.h>
#include <ui/map.h>
#include <ui/window.h>
namespace Ui {
const int MAXCONTROL = 100;
//Forward declaration
class CButton;
class CCheck;
class CColor;
class CCompass;
class CControl;
class CEdit;
class CEditValue;
class CGroup;
class CImage;
class CKey;
class CLabel;
class CList;
class CMap;
class CScroll;
class CShortcut;
class CSlider;
class CTarget;
class CWindow;
class CInterface
{
@ -61,7 +62,7 @@ class CInterface
~CInterface();
bool EventProcess(const Event &event);
bool GetTooltip(Math::Point pos, const char* name);
bool GetTooltip(Math::Point pos, std::string &name);
void Flush();
CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
@ -81,7 +82,7 @@ class CInterface
CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, const char *name);
CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
bool DeleteControl(EventType eventMsg);
CControl* SearchControl(EventType eventMsg);

View File

@ -64,7 +64,7 @@ bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg
CControl::Create(pos, dim, icon, eventMsg);
GetResource(RES_EVENT, eventMsg, name);
SetName(name);
SetName(std::string(name));
return true;
}

View File

@ -17,16 +17,7 @@
// maindialog.cpp
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <direct.h>
#include <io.h>
#include <d3d.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "common/global.h"
#include "common/language.h"
#include "common/event.h"
@ -34,8 +25,6 @@
#include "common/profile.h"
#include "common/iman.h"
#include "common/restext.h"
#include "old/math3d.h"
#include "old/particule.h"
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/color.h"
@ -50,9 +39,6 @@
#include "ui/window.h"
#include "ui/edit.h"
#include "ui/editvalue.h"
#include "old/text.h"
#include "old/camera.h"
#include "old/sound.h"
#include "script/cmdtoken.h"
#include "object/robotmain.h"
#include "ui/maindialog.h"

View File

@ -20,7 +20,6 @@
#include "common/struct.h"
#include "old/camera.h"
#include "object/robotmain.h"

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -17,37 +18,21 @@
// mainmap.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include <ui/mainmap.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "common/global.h"
#include "common/event.h"
#include "common/iman.h"
#include "ui/interface.h"
#include "ui/map.h"
#include "ui/image.h"
#include "ui/group.h"
#include "ui/slider.h"
#include "ui/scroll.h"
#include "ui/window.h"
#include "ui/mainmap.h"
namespace Ui {
const float ZOOM_MIN = 1.0f;
const float ZOOM_MAX = 16.0f;
// Constructor of the application card.
CMainMap::CMainMap(CInstanceManager* iMan)
CMainMap::CMainMap()
{
m_iMan = iMan;
m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_MAP, this);
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
@ -73,8 +58,7 @@ void CMainMap::CreateMap()
Math::Point pos, dim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 )
{
if (pw == nullptr) {
pos.x = 0.0f;
pos.y = 0.0f;
dim.x = 0.0f;
@ -82,10 +66,10 @@ void CMainMap::CreateMap()
pw = m_interface->CreateWindows(pos, dim, 10, EVENT_WINDOW1);
}
dim.x = 10.0f/640.0f;
dim.y = 10.0f/480.0f;
pos.x = 10.0f/640.0f;
pos.y = 10.0f/480.0f;
dim.x = 10.0f / 640.0f;
dim.y = 10.0f / 480.0f;
pos.x = 10.0f / 640.0f;
pos.y = 10.0f / 480.0f;
pw->CreateMap (pos, dim, 2, EVENT_OBJECT_MAP);
pw->CreateSlider(pos, dim, 0, EVENT_OBJECT_MAPZOOM);
@ -94,16 +78,18 @@ void CMainMap::CreateMap()
// Indicates whether the mini-map should display a still image.
void CMainMap::SetFixImage(char *filename)
void CMainMap::SetFixImage(const char *filename)
{
CWindow* pw;
CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return;
if (pm == nullptr)
return;
pw->DeleteControl(EVENT_OBJECT_MAPZOOM);
m_bFixImage = true;
@ -113,17 +99,17 @@ void CMainMap::SetFixImage(char *filename)
// Choosing colors of soil and water for the mini-map.
void CMainMap::FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water)
void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water)
{
CWindow* pw;
CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm != 0 )
{
if (pm != nullptr) {
pm->SetFloorColor(floor);
pm->SetWaterColor(water);
}
@ -138,25 +124,19 @@ void CMainMap::ShowMap(bool bShow)
CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
if ( bShow )
{
if (bShow) {
DimMap();
}
else
{
} else {
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm != 0 )
{
if (pm != nullptr)
pm->ClearState(STATE_VISIBLE);
}
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
if ( ps != 0 )
{
if (ps != nullptr)
ps->ClearState(STATE_VISIBLE);
}
}
}
@ -171,9 +151,11 @@ void CMainMap::DimMap()
float value;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return;
if (pm == nullptr)
return;
pm->SetState(STATE_VISIBLE, (m_mapMode != 0));
@ -185,19 +167,18 @@ void CMainMap::DimMap()
pm->SetDim(dim);
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
if ( ps != 0 )
{
if (ps != nullptr) {
ps->SetState(STATE_VISIBLE, (m_mapMode != 0));
dim.x = SCROLL_WIDTH;
dim.y = 66.0f/480.0f;
pos.x = 523.0f/640.0f;
pos.y = 3.0f/480.0f;
dim.y = 66.0f / 480.0f;
pos.x = 523.0f / 640.0f;
pos.y = 3.0f / 480.0f;
ps->SetPos(pos);
ps->SetDim(dim);
value = pm->RetZoom();
value = (value-ZOOM_MIN)/(ZOOM_MAX-ZOOM_MIN);
value = pm->GetZoom();
value = (value-ZOOM_MIN) / (ZOOM_MAX-ZOOM_MIN);
value = powf(value, 0.5f);
ps->SetVisibleValue(value);
ps->SetArrowStep(0.2f);
@ -206,22 +187,25 @@ void CMainMap::DimMap()
// Returns the current zoom of the minimap.
float CMainMap::RetZoomMap()
float CMainMap::GetZoomMap()
{
CWindow* pw;
CMap* pm;
CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return ZOOM_MIN;
if (pw == nullptr)
return ZOOM_MIN;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return ZOOM_MIN;
if (pm == nullptr)
return ZOOM_MIN;
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
if ( ps == 0 ) return ZOOM_MIN;
if (ps == nullptr)
return ZOOM_MIN;
return pm->RetZoom();
return pm->GetZoom();
}
// Zoom the mini-map of any factor.
@ -233,15 +217,20 @@ void CMainMap::ZoomMap(float zoom)
CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return;
if (pm == nullptr)
return;
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
if ( ps == 0 ) return;
if (ps == nullptr)
return;
if ( zoom < ZOOM_MIN ) zoom = ZOOM_MIN;
if ( zoom > ZOOM_MAX ) zoom = ZOOM_MAX;
if (zoom < ZOOM_MIN)
zoom = ZOOM_MIN;
if (zoom > ZOOM_MAX)
zoom = ZOOM_MAX;
pm->SetZoom(zoom);
DimMap();
@ -257,16 +246,20 @@ void CMainMap::ZoomMap()
float zoom;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return;
if (pm == nullptr)
return;
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
if ( ps == 0 ) return;
if (ps == nullptr)
return;
zoom = ps->RetVisibleValue();
zoom = ps->GetVisibleValue();
zoom = powf(zoom, 2.0f);
zoom = ZOOM_MIN+zoom*(ZOOM_MAX-ZOOM_MIN);
zoom = ZOOM_MIN+zoom*(ZOOM_MAX - ZOOM_MIN);
pm->SetZoom(zoom);
DimMap();
@ -281,19 +274,16 @@ void CMainMap::MapEnable(bool bEnable)
CSlider* ps;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm != 0 )
{
if (pm != nullptr)
pm->SetEnable(bEnable);
}
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
if ( ps != 0 )
{
if (ps != nullptr)
ps->SetState(STATE_ENABLE, bEnable);
}
}
// Specifies the type of icon for the selected object.
@ -304,10 +294,12 @@ void CMainMap::SetToy(bool bToy)
CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return;
if (pm == nullptr)
return;
pm->SetToy(bToy);
}
@ -321,10 +313,12 @@ void CMainMap::SetFixParam(float zoom, float ox, float oy, float angle,
CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return;
if (pm == nullptr)
return;
pm->SetZoom(zoom);
pm->SetOffset(ox, oy);
@ -341,25 +335,24 @@ void CMainMap::UpdateMap()
CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm != 0 )
{
if (pm != nullptr)
pm->UpdateTerrain();
}
}
// Indicates if the mini-map is visible.
bool CMainMap::RetShowMap()
bool CMainMap::GetShowMap()
{
return ( m_mapMode != 0 );
}
// Indicates whether the mini-map displays a still image.
bool CMainMap::RetFixImage()
bool CMainMap::GetFixImage()
{
return m_bFixImage;
}
@ -373,30 +366,32 @@ CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap)
CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return 0;
if (pw == nullptr)
return 0;
bInMap = false;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm == 0 ) return 0;
if (pm == nullptr)
return 0;
return pm->DetectObject(pos, bInMap);
}
// Indicates the object with the mouse hovers over.
void CMainMap::SetHilite(CObject* pObj)
void CMainMap::SetHighlight(CObject* pObj)
{
CWindow* pw;
CWindow* pw;
CMap* pm;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 ) return;
if (pw == nullptr)
return;
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
if ( pm != 0 )
{
pm->SetHilite(pObj);
}
if (pm != nullptr)
pm->SetHighlight(pObj);
}
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -18,53 +19,54 @@
#pragma once
#include <graphics/core/color.h>
#include "common/struct.h"
#include "math/point.h"
#include <common/struct.h>
#include <common/event.h>
#include <math/point.h>
class CInstanceManager;
class CEvent;
class CD3DEngine;
class CInterface;
class CObject;
#include <object/object.h>
#include <ui/interface.h>
namespace Ui {
class CMainMap
{
public:
CMainMap(CInstanceManager* iMan);
~CMainMap();
public:
CMainMap();
~CMainMap();
void UpdateMap();
void CreateMap();
void SetFixImage(char *filename);
void FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water);
void ShowMap(bool bShow);
void DimMap();
float RetZoomMap();
void ZoomMap(float zoom);
void ZoomMap();
void MapEnable(bool bEnable);
bool RetShowMap();
bool RetFixImage();
CObject* DetectMap(Math::Point pos, bool &bInMap);
void SetHilite(CObject* pObj);
void SetToy(bool bToy);
void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug);
void UpdateMap();
void CreateMap();
void SetFixImage(const char *filename);
void FloorColorMap(Gfx::Color floor, Gfx::Color water);
void ShowMap(bool bShow);
void DimMap();
float GetZoomMap();
void ZoomMap(float zoom);
void ZoomMap();
void MapEnable(bool bEnable);
bool GetShowMap();
bool GetFixImage();
CObject* DetectMap(Math::Point pos, bool &bInMap);
void SetHighlight(CObject* pObj);
void SetToy(bool bToy);
void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug);
protected:
void CenterMap();
protected:
void CenterMap();
protected:
CInstanceManager* m_iMan;
CEvent* m_event;
CD3DEngine* m_engine;
CInterface* m_interface;
protected:
CInstanceManager* m_iMan;
CEvent* m_event;
CD3DEngine* m_engine;
CInterface* m_interface;
int m_mapMode;
bool m_bFixImage;
int m_mapMode;
bool m_bFixImage;
};
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -17,36 +18,21 @@
// mainshort.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "common/global.h"
#include "common/event.h"
#include "common/iman.h"
#include "object/object.h"
#include "ui/interface.h"
#include "ui/map.h"
#include "ui/button.h"
#include "object/robotmain.h"
#include "ui/mainshort.h"
#include <ui/mainshort.h>
namespace Ui {
// Constructor of the application card.
CMainShort::CMainShort(CInstanceManager* iMan)
CMainShort::CMainShort()
{
m_iMan = iMan;
m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_SHORT, this);
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_event = static_cast<CEvent*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
FlushShortcuts();
}
@ -78,7 +64,7 @@ void CMainShort::FlushShortcuts()
}
}
static EventMsg table_sc_em[20] =
static EventType table_sc_em[20] =
{
EVENT_OBJECT_SHORTCUT00,
EVENT_OBJECT_SHORTCUT01,
@ -113,13 +99,13 @@ bool CMainShort::CreateShortcuts()
int i, rank, icon;
char name[100];
if ( m_main->RetFixScene() ) return false;
if ( m_main->GetFixScene() ) return false;
m_interface->DeleteControl(EVENT_OBJECT_MOVIELOCK);
m_interface->DeleteControl(EVENT_OBJECT_EDITLOCK);
for ( i=0 ; i<20 ; i++ )
{
if ( i != 0 && m_shortcuts[i] == 0 ) continue;
if ( i != 0 && m_shortcuts[i] == nullptr ) continue;
m_interface->DeleteControl(table_sc_em[i]);
m_shortcuts[i] = 0;
@ -130,15 +116,15 @@ bool CMainShort::CreateShortcuts()
pos.x = 4.0f/640.0f;
pos.y = (480.0f-32.0f)/480.0f;
if ( m_main->RetMovieLock() &&
!m_main->RetEditLock() ) // hangs during film?
if ( m_main->GetMovieLock() &&
!m_main->GetEditLock() ) // hangs during film?
{
m_interface->CreateShortcut(pos, dim, 7, EVENT_OBJECT_MOVIELOCK);
return true;
}
if ( !m_main->RetFreePhoto() &&
(m_main->RetEditLock() ||
m_engine->RetPause()) ) // hangs during edition?
if ( !m_main->GetFreePhoto() &&
(m_main->GetEditLock() ||
m_engine->GetPause()) ) // hangs during edition?
{
m_interface->CreateShortcut(pos, dim, 6, EVENT_OBJECT_EDITLOCK);
return true;
@ -154,13 +140,13 @@ bool CMainShort::CreateShortcuts()
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
if ( pObj == 0 ) break;
if ( pObj == nullptr ) break;
if ( !pObj->RetActif() ) continue;
if ( !pObj->RetSelectable() ) continue;
if ( pObj->RetProxyActivate() ) continue;
if ( !pObj->GetActif() ) continue;
if ( !pObj->GetSelectable() ) continue;
if ( pObj->GetProxyActivate() ) continue;
type = pObj->RetType();
type = pObj->GetType();
icon = -1;
if ( m_bBuilding )
{
@ -243,12 +229,12 @@ bool CMainShort::UpdateShortcuts()
for ( i=0 ; i<20 ; i++ )
{
if ( m_shortcuts[i] == 0 ) continue;
if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]);
if ( pc != 0 )
if ( pc != nullptr )
{
pc->SetState(STATE_CHECK, m_shortcuts[i]->RetSelect());
pc->SetState(STATE_CHECK, m_shortcuts[i]->GetSelect());
pc->SetState(STATE_RUN, m_shortcuts[i]->IsProgram());
}
}
@ -257,7 +243,7 @@ bool CMainShort::UpdateShortcuts()
// Selects an object through a shortcut.
void CMainShort::SelectShortcut(EventMsg event)
void CMainShort::SelectShortcut(EventType event)
{
int i;
@ -265,7 +251,7 @@ void CMainShort::SelectShortcut(EventMsg event)
{
if ( event == table_sc_em[i] )
{
if ( i != 0 && m_shortcuts[i] == 0 ) continue;
if ( i != 0 && m_shortcuts[i] == nullptr ) continue;
if ( i == 0 ) // buildings <-> vehicles?
{
@ -289,9 +275,9 @@ void CMainShort::SelectNext()
CObject* pPrev;
int i;
if ( m_main->RetMovieLock() ||
m_main->RetEditLock() ||
m_engine->RetPause() ) return;
if ( m_main->GetMovieLock() ||
m_main->GetEditLock() ||
m_engine->GetPause() ) return;
pPrev = m_main->DeselectAll();
@ -299,12 +285,12 @@ void CMainShort::SelectNext()
{
if ( m_shortcuts[i] == pPrev )
{
if ( m_shortcuts[++i] == 0 ) i = 1;
if ( m_shortcuts[++i] == nullptr ) i = 1;
break;
}
}
if ( i == 20 || m_shortcuts[i] == 0 )
if ( i == 20 || m_shortcuts[i] == nullptr )
{
m_main->SelectHuman();
}
@ -325,13 +311,13 @@ CObject* CMainShort::DetectShort(Math::Point pos)
for ( i=0 ; i<20 ; i++ )
{
if ( m_shortcuts[i] == 0 ) continue;
if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]);
if ( pc != 0 )
{
cpos = pc->RetPos();
cdim = pc->RetDim();
cpos = pc->GetPos();
cdim = pc->GetDim();
if ( pos.x >= cpos.x &&
pos.x <= cpos.x+cdim.x &&
@ -347,17 +333,17 @@ CObject* CMainShort::DetectShort(Math::Point pos)
// Reports the object with the mouse hovers over.
void CMainShort::SetHilite(CObject* pObj)
void CMainShort::SetHighlight(CObject* pObj)
{
CControl* pc;
int i;
for ( i=0 ; i<20 ; i++ )
{
if ( m_shortcuts[i] == 0 ) continue;
if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]);
if ( pc == 0 ) continue;
if ( pc == nullptr ) continue;
if ( m_shortcuts[i] == pObj )
{
@ -372,3 +358,5 @@ void CMainShort::SetHilite(CObject* pObj)
}
}
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -18,45 +19,45 @@
#pragma once
#include <ui/interface.h>
#include "common/event.h"
#include "math/point.h"
#include <common/event.h>
#include <math/point.h>
class CInstanceManager;
class CD3DEngine;
class CInterface;
class CRobotMain;
class CObject;
#include <object/object.h>
#include <graphics/engine/engine.h>
namespace Ui {
class CMainShort
{
public:
CMainShort(CInstanceManager* iMan);
~CMainShort();
public:
CMainShort();
~CMainShort();
void SetMode(bool bBuilding);
void FlushShortcuts();
bool CreateShortcuts();
bool UpdateShortcuts();
void SelectShortcut(EventMsg event);
void SelectNext();
CObject* DetectShort(Math::Point pos);
void SetHilite(CObject* pObj);
void SetMode(bool bBuilding);
void FlushShortcuts();
bool CreateShortcuts();
bool UpdateShortcuts();
void SelectShortcut(EventType event);
void SelectNext();
CObject* DetectShort(Math::Point pos);
void SetHighlight(CObject* pObj);
protected:
protected:
protected:
CInstanceManager* m_iMan;
CEvent* m_event;
CD3DEngine* m_engine;
CInterface* m_interface;
CRobotMain* m_main;
protected:
CInstanceManager* m_iMan;
CEvent* m_event;
Gfx::CEngine* m_engine;
CInterface* m_interface;
CRobotMain* m_main;
CObject* m_shortcuts[20];
bool m_bBuilding;
CObject* m_shortcuts[20];
bool m_bBuilding;
};
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -17,34 +18,20 @@
// map.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "math/geometry.h"
#include "old/d3dengine.h"
#include "common/event.h"
#include "old/math3d.h"
#include "old/terrain.h"
#include "old/water.h"
#include "object/object.h"
#include "common/event.h"
#include "common/misc.h"
#include "object/robotmain.h"
#include "common/iman.h"
#include "ui/map.h"
#include "map.h"
namespace Ui {
// Object's constructor.
CMap::CMap(CInstanceManager* iMan) : CControl(iMan)
CMap::CMap() : CControl()
{
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
m_bEnable = true;
m_time = 0.0f;
@ -61,9 +48,9 @@ CMap::CMap(CInstanceManager* iMan) : CControl(iMan)
m_waterColor.g = 0.80f;
m_waterColor.b = 1.00f; // blue
m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
m_half = m_terrain->GetMosaic() * m_terrain->GetBrick() * m_terrain->GetSize() / 2.0f;
m_hiliteRank = -1;
m_highlightRank = -1;
FlushObject();
m_fixImage[0] = 0;
@ -81,9 +68,10 @@ CMap::~CMap()
// Creates a new button.
bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
return true;
@ -96,7 +84,7 @@ void CMap::SetOffset(float ox, float oy)
{
m_offset.x = ox;
m_offset.y = oy;
m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
m_half = m_terrain->GetMosaic() * m_terrain->GetBrick() * m_terrain->GetSize() / 2.0f;
}
// Choice of the global angle of rotation.
@ -131,10 +119,10 @@ void CMap::SetDebug(bool bDebug)
void CMap::SetZoom(float value)
{
m_zoom = value;
m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
m_half = m_terrain->GetMosaic() * m_terrain->GetBrick() * m_terrain->GetSize() / 2.0f;
}
float CMap::RetZoom()
float CMap::GetZoom()
{
return m_zoom;
}
@ -149,7 +137,7 @@ void CMap::SetEnable(bool bEnable)
SetState(STATE_DEAD, !bEnable);
}
bool CMap::RetEnable()
bool CMap::GetEnable()
{
return m_bEnable;
}
@ -157,14 +145,14 @@ bool CMap::RetEnable()
// Choosing the color of the soil.
void CMap::SetFloorColor(D3DCOLORVALUE color)
void CMap::SetFloorColor(Gfx::Color color)
{
m_floorColor = color;
}
// Choosing the color of the water.
void CMap::SetWaterColor(D3DCOLORVALUE color)
void CMap::SetWaterColor(Gfx::Color color)
{
m_waterColor = color;
}
@ -172,14 +160,14 @@ void CMap::SetWaterColor(D3DCOLORVALUE color)
// Specifies a fixed image in place of the drawing of the relief.
void CMap::SetFixImage(char *filename)
void CMap::SetFixImage(const char *filename)
{
strcpy(m_fixImage, filename);
}
// Whether to use a still image.
bool CMap::RetFixImage()
bool CMap::GetFixImage()
{
return (m_fixImage[0] != 0);
}
@ -189,30 +177,24 @@ bool CMap::RetFixImage()
bool CMap::EventProcess(const Event &event)
{
bool bInMap;
bool bInMap;
if ( (m_state & STATE_VISIBLE) == 0 ) return true;
if ( (m_state & STATE_VISIBLE) == 0 )
return true;
CControl::EventProcess(event);
if ( event.event == EVENT_FRAME )
{
if ( event.type == EVENT_FRAME )
m_time += event.rTime;
}
if ( event.event == EVENT_MOUSEMOVE && Detect(event.pos) )
{
m_engine->SetMouseType(D3DMOUSENORM);
if ( event.type == EVENT_MOUSE_MOVE && Detect(event.pos) ) {
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
if ( DetectObject(event.pos, bInMap) != 0 )
{
m_engine->SetMouseType(D3DMOUSEHAND);
}
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
}
if ( event.event == EVENT_LBUTTONDOWN )
{
if ( CControl::Detect(event.pos) )
{
if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 ) {
if ( CControl::Detect(event.pos) ) {
SelectObject(event.pos);
return false;
}
@ -227,7 +209,7 @@ Math::Point CMap::AdjustOffset(Math::Point offset)
{
float limit;
limit = m_half - m_half/m_zoom;
limit = m_half - m_half / m_zoom;
if ( offset.x < -limit ) offset.x = -limit;
if ( offset.x > limit ) offset.x = limit;
if ( offset.y < -limit ) offset.y = -limit;
@ -238,21 +220,20 @@ Math::Point CMap::AdjustOffset(Math::Point offset)
// Indicates the object with the mouse hovers over.
void CMap::SetHilite(CObject* pObj)
void CMap::SetHighlight(CObject* pObj)
{
int i;
m_highlightRank = -1;
if ( m_bToy || m_fixImage[0] != 0 )
return; // card with still image?
if ( pObj == nullptr )
return;
m_hiliteRank = -1;
if ( m_bToy || m_fixImage[0] != 0 ) return; // card with still image?
if ( pObj == 0 ) return;
for (int i = 0; i < MAPMAXOBJECT; i++) {
if ( !m_map[i].bUsed )
continue;
for ( i=0 ; i<MAPMAXOBJECT ; i++ )
{
if ( !m_map[i].bUsed ) continue;
if ( m_map[i].object == pObj )
{
m_hiliteRank = i;
if ( m_map[i].object == pObj ) {
m_highlightRank = i;
break;
}
}
@ -262,39 +243,43 @@ void CMap::SetHilite(CObject* pObj)
CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
{
float dist, min;
int i, best;
float dist, min;
int best;
bInMap = false;
if ( pos.x < m_pos.x ||
pos.y < m_pos.y ||
pos.x > m_pos.x+m_dim.x ||
pos.y > m_pos.y+m_dim.y ) return 0;
if ( pos.x < m_pos.x ||
pos.y < m_pos.y ||
pos.x > m_pos.x + m_dim.x ||
pos.y > m_pos.y + m_dim.y )
return 0;
bInMap = true;
pos.x = (pos.x-m_pos.x)/m_dim.x*256.0f;
pos.y = (pos.y-m_pos.y)/m_dim.y*256.0f; // 0..256
pos.x = (pos.x-128.0f)*m_half/(m_zoom*128.0f)+m_offset.x;
pos.y = (pos.y-128.0f)*m_half/(m_zoom*128.0f)+m_offset.y;
pos.x = (pos.x - m_pos.x) / m_dim.x * 256.0f;
pos.y = (pos.y - m_pos.y) / m_dim.y * 256.0f; // 0..256
pos.x = (pos.x - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.x;
pos.y = (pos.y - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.y;
min = 10000.0f;
best = -1;
for ( i=MAPMAXOBJECT-1 ; i>=0 ; i-- )
{
if ( !m_map[i].bUsed ) continue;
if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar ) continue;
if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar ) continue;
for (int i = MAPMAXOBJECT - 1; i >= 0; i--) {
if ( !m_map[i].bUsed )
continue;
if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar )
continue;
if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar )
continue;
dist = Math::Point(m_map[i].pos.x-pos.x, m_map[i].pos.y-pos.y).Length();
if ( dist > m_half/m_zoom*8.0f/100.0f ) continue; // too far?
if ( dist < min )
{
dist = Math::Point(m_map[i].pos.x - pos.x, m_map[i].pos.y - pos.y).Length();
if ( dist > m_half / m_zoom * 8.0f / 100.0f )
continue; // too far?
if ( dist < min ) {
min = dist;
best = i;
}
}
if ( best == -1 ) return 0;
if ( best == -1 )
return 0;
return m_map[best].object;
}
@ -302,14 +287,12 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
void CMap::SelectObject(Math::Point pos)
{
CObject *pObj;
bool bInMap;
CObject *pObj;
bool bInMap;
pObj = DetectObject(pos, bInMap);
if ( pObj != 0 )
{
m_main->SelectObject(pObj);
}
}
@ -318,34 +301,31 @@ void CMap::SelectObject(Math::Point pos)
void CMap::Draw()
{
Math::Point uv1, uv2;
int i;
int i;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
if ( (m_state & STATE_VISIBLE) == 0 )
return;
CControl::Draw(); // draws the bottom (button)
if ( !m_bEnable ) return;
if ( !m_bEnable )
return;
if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT-1].bUsed )
{
m_offset = AdjustOffset(m_map[MAPMAXOBJECT-1].pos);
}
if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT - 1].bUsed )
m_offset = AdjustOffset(m_map[MAPMAXOBJECT - 1].pos);
if ( m_fixImage[0] == 0 ) // drawing of the relief?
{
if ( m_fixImage[0] == 0 ) { // drawing of the relief?
m_engine->SetTexture("map.tga");
m_engine->SetState(D3DSTATENORMAL);
uv1.x = 0.5f+(m_offset.x-(m_half/m_zoom))/(m_half*2.0f);
uv1.y = 0.5f-(m_offset.y+(m_half/m_zoom))/(m_half*2.0f);
uv2.x = 0.5f+(m_offset.x+(m_half/m_zoom))/(m_half*2.0f);
uv2.y = 0.5f-(m_offset.y-(m_half/m_zoom))/(m_half*2.0f);
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.5f + (m_offset.x - (m_half / m_zoom)) / (m_half * 2.0f);
uv1.y = 0.5f - (m_offset.y + (m_half / m_zoom)) / (m_half * 2.0f);
uv2.x = 0.5f + (m_offset.x + (m_half / m_zoom)) / (m_half * 2.0f);
uv2.y = 0.5f - (m_offset.y - (m_half / m_zoom)) / (m_half * 2.0f);
DrawVertex(uv1, uv2, 0.97f); // drawing the map
}
else // still image?
{
} else { // still image?
m_engine->LoadTexture(m_fixImage);
m_engine->SetTexture(m_fixImage);
m_engine->SetState(D3DSTATENORMAL);
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f;
uv1.y = 0.0f;
uv2.x = 1.0f;
@ -355,33 +335,28 @@ void CMap::Draw()
i = MAPMAXOBJECT-1;
if ( m_map[i].bUsed ) // selection:
{
DrawFocus(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color);
}
for ( i=0 ; i<m_totalFix ; i++ ) // fixed objects:
{
if ( i == m_hiliteRank ) continue;
for ( i=0 ; i<m_totalFix ; i++ ) { // fixed objects:
if ( i == m_highlightRank )
continue;
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
}
for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) // moving objects:
{
if ( i == m_hiliteRank ) continue;
for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) { // moving objects:
if ( i == m_highlightRank )
continue;
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
}
i = MAPMAXOBJECT-1;
if ( m_map[i].bUsed && i != m_hiliteRank ) // selection:
{
if ( m_map[i].bUsed && i != m_highlightRank ) // selection:
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, true, false);
}
if ( m_hiliteRank != -1 && m_map[m_hiliteRank].bUsed )
{
i = m_hiliteRank;
if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) {
i = m_highlightRank;
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, true);
DrawHilite(m_map[i].pos);
DrawHighlight(m_map[i].pos);
}
}
@ -392,35 +367,32 @@ Math::Point CMap::MapInter(Math::Point pos, float dir)
Math::Point p1;
float limit;
p1.x = pos.x+1.0f;
p1.x = pos.x + 1.0f;
p1.y = pos.y;
p1 = Math::RotatePoint(pos, dir, p1);
p1.x -= pos.x;
p1.y -= pos.y;
limit = m_mapPos.x+m_mapDim.x-pos.x;
if ( p1.x > limit ) // exceeds the right?
{
limit = m_mapPos.x + m_mapDim.x - pos.x;
if ( p1.x > limit ) { // exceeds the right?
p1.y = limit*p1.y/p1.x;
p1.x = limit;
}
limit = m_mapPos.y*0.75f+m_mapDim.y*0.75f-pos.y;
if ( p1.y > limit ) // exceeds the top?
{
p1.x = limit*p1.x/p1.y;
limit = m_mapPos.y * 0.75f + m_mapDim.y * 0.75f - pos.y;
if ( p1.y > limit ) { // exceeds the top?
p1.x = limit * p1.x / p1.y;
p1.y = limit;
}
limit = m_mapPos.x-pos.x;
if ( p1.x < limit ) // exceeds the left?
{
p1.y = limit*p1.y/p1.x;
limit = m_mapPos.x - pos.x;
if ( p1.x < limit ) { // exceeds the left?
p1.y = limit * p1.y / p1.x;
p1.x = limit;
}
limit = m_mapPos.y*0.75f-pos.y;
if ( p1.y < limit ) // exceeds the bottom?
{
p1.x = limit*p1.x/p1.y;
limit = m_mapPos.y * 0.75f - pos.y;
if ( p1.y < limit ) { // exceeds the bottom?
p1.x = limit * p1.x / p1.y;
p1.y = limit;
}
@ -454,7 +426,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
pos.x = m_mapPos.x+m_mapDim.x*pos.x;
pos.y = m_mapPos.y*0.75f+m_mapDim.y*pos.y*0.75f;
focus = m_engine->RetFocus();
focus = m_engine->GetFocus();
dir += Math::PI/2.0f;
aMin = Math::NormAngle(dir-Math::PI/4.0f*focus);
aMax = Math::NormAngle(dir+Math::PI/4.0f*focus);
@ -484,7 +456,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
uv2.y = 255.0f/256.0f;
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
bEnding = false;
do
@ -492,7 +464,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
quart ++;
aOct = limit[quart%4];
if ( quart >= 4 ) aOct += Math::PI*2.0f;
if ( aOct >= aMax-Math::VERY_SMALL )
if ( aOct >= aMax - Math::VERY_SMALL_NUM )
{
aOct = aMax;
bEnding = true;
@ -544,7 +516,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
if ( bUp )
{
uv1.x = 160.5f/256.0f; // yellow triangle ^
@ -687,7 +659,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( bSelect )
{
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL);
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( m_bToy )
{
uv1.x = 164.5f/256.0f; // black pentagon
@ -713,7 +685,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( m_bRadar )
{
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 64.5f/256.0f; // blue triangle
uv1.y = 240.5f/256.0f;
uv2.x = 79.0f/256.0f;
@ -733,7 +705,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( color == MAPCOLOR_WAYPOINTb )
{
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 192.5f/256.0f; // blue cross
uv1.y = 240.5f/256.0f;
uv2.x = 207.0f/256.0f;
@ -743,7 +715,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( color == MAPCOLOR_WAYPOINTr )
{
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 208.5f/256.0f; // red cross
uv1.y = 240.5f/256.0f;
uv2.x = 223.0f/256.0f;
@ -753,7 +725,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( color == MAPCOLOR_WAYPOINTg )
{
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 224.5f/256.0f; // green cross
uv1.y = 240.5f/256.0f;
uv2.x = 239.0f/256.0f;
@ -763,7 +735,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( color == MAPCOLOR_WAYPOINTy )
{
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 240.5f/256.0f; // yellow cross
uv1.y = 240.5f/256.0f;
uv2.x = 255.0f/256.0f;
@ -773,7 +745,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( color == MAPCOLOR_WAYPOINTv )
{
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 192.5f/256.0f; // violet cross
uv1.y = 224.5f/256.0f;
uv2.x = 207.0f/256.0f;
@ -794,7 +766,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
dp = 0.5f/256.0f;
m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATENORMAL);
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( color == MAPCOLOR_MOVE )
{
uv1.x = 160.0f/256.0f; // blue
@ -877,7 +849,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
if ( type == OBJECT_TEEN34 ) icon = 48; // stone
if ( icon == -1 ) return;
m_engine->SetState(D3DSTATETTw);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = (32.0f/256.0f)*(icon%8);
uv1.y = (32.0f/256.0f)*(icon/8);
uv2.x = uv1.x+32.0f/256.0f;
@ -892,7 +864,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
// Draw the object with the mouse hovers over.
void CMap::DrawHilite(Math::Point pos)
void CMap::DrawHighlight(Math::Point pos)
{
Math::Point dim, uv1, uv2;
bool bOut, bUp, bDown, bLeft, bRight;
@ -916,7 +888,7 @@ void CMap::DrawHilite(Math::Point pos)
dim.y *= 2.0f+cosf(m_time*8.0f)*0.5f;
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 160.5f/256.0f; // hilite
uv1.y = 224.5f/256.0f;
uv2.x = 175.0f/256.0f;
@ -930,19 +902,19 @@ void CMap::DrawHilite(Math::Point pos)
void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[3]; // 1 triangle
Gfx::CDevice* device;
Gfx::VertexTex2 vertex[3]; // 1 triangle
Math::Vector n;
device = m_engine->RetD3DDevice();
device = m_engine->GetDevice();
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y);
vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y);
vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y);
vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
vertex[2] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL);
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
m_engine->AddStatisticTriangle(1);
}
@ -950,28 +922,28 @@ void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Po
void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[5]; // 1 pentagon
Gfx::CDevice* device;
Gfx::VertexTex2 vertex[5]; // 1 pentagon
Math::Vector n;
device = m_engine->RetD3DDevice();
device = m_engine->GetDevice();
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
#if 1
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y);
vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y);
vertex[2] = D3DVERTEX2(Math::Vector(p5.x, p5.y, 0.0f), n, uv2.x,uv2.y);
vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y);
vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y);
vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
vertex[2] = Gfx::VertexTex2(Math::Vector(p5.x, p5.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
vertex[3] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
vertex[4] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 5, NULL);
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 5);
#else
vertex[0] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv1.y);
vertex[1] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x,uv2.y);
vertex[2] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y);
vertex[0] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
vertex[1] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
vertex[2] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL);
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
#endif
m_engine->AddStatisticTriangle(3);
}
@ -980,12 +952,12 @@ void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point
void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
Gfx::CDevice* device;
Gfx::VertexTex2 vertex[4]; // 2 triangles
Math::Point p1, p2, c;
Math::Vector n;
device = m_engine->RetD3DDevice();
device = m_engine->GetDevice();
p1.x = m_pos.x;
p1.y = m_pos.y;
@ -1007,12 +979,12 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y);
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y);
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y);
vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y);
vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
vertex[1] = Gfx::VertexTex2(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
vertex[2] = Gfx::VertexTex2(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
vertex[3] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x,uv1.y));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
}
@ -1021,7 +993,7 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
void CMap::UpdateTerrain()
{
D3DCOLORVALUE color;
Gfx::Color color;
Math::Vector pos;
float scale, water, level, intensity;
int x, y;
@ -1029,8 +1001,8 @@ void CMap::UpdateTerrain()
if ( m_fixImage[0] != 0 ) return; // still image?
if ( !m_engine->OpenImage("map.tga") ) return;
scale = m_terrain->RetScaleRelief();
water = m_water->RetLevel();
scale = m_terrain->GetScaleRelief();
water = m_water->GetLevel();
color.a = 0.0f;
for ( y=0 ; y<256 ; y++ )
@ -1044,7 +1016,7 @@ void CMap::UpdateTerrain()
if ( pos.x >= -m_half && pos.x <= m_half &&
pos.z >= -m_half && pos.z <= m_half )
{
level = m_terrain->RetFloorLevel(pos, true)/scale;
level = m_terrain->GetFloorLevel(pos, true)/scale;
}
else
{
@ -1080,7 +1052,7 @@ void CMap::UpdateTerrain()
void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
{
D3DCOLORVALUE color;
Gfx::Color color;
Math::Vector pos;
float scale, water, level, intensity;
int x, y;
@ -1089,8 +1061,8 @@ void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
if ( !m_engine->OpenImage("map.tga") ) return;
m_engine->LoadImage();
scale = m_terrain->RetScaleRelief();
water = m_water->RetLevel();
scale = m_terrain->GetScaleRelief();
water = m_water->GetLevel();
color.a = 0.0f;
for ( y=by ; y<ey ; y++ )
@ -1104,7 +1076,7 @@ void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
if ( pos.x >= -m_half && pos.x <= m_half &&
pos.z >= -m_half && pos.z <= m_half )
{
level = m_terrain->RetFloorLevel(pos, true)/scale;
level = m_terrain->GetFloorLevel(pos, true)/scale;
}
else
{
@ -1145,7 +1117,7 @@ void CMap::FlushObject()
m_totalFix = 0; // object index fixed
m_totalMove = MAPMAXOBJECT-2; // moving vehicles index
m_bRadar = m_main->RetCheatRadar(); // no radar
//m_bRadar = m_main->GetCheatRadar(); // no radar
for ( i=0 ; i<MAPMAXOBJECT ; i++ )
{
@ -1166,14 +1138,14 @@ void CMap::UpdateObject(CObject* pObj)
if ( !m_bEnable ) return;
if ( m_totalFix >= m_totalMove ) return; // full table?
if ( !pObj->RetActif() ) return;
if ( !pObj->RetSelectable() ) return;
if ( pObj->RetProxyActivate() ) return;
if ( pObj->RetTruck() != 0 ) return;
if ( !pObj->GetActif() ) return;
if ( !pObj->GetSelectable() ) return;
if ( pObj->GetProxyActivate() ) return;
if ( pObj->GetTruck() != 0 ) return;
type = pObj->RetType();
pos = pObj->RetPosition(0);
dir = -(pObj->RetAngleY(0)+Math::PI/2.0f);
type = pObj->GetType();
pos = pObj->GetPosition(0);
dir = -(pObj->GetAngleY(0)+Math::PI/2.0f);
if ( m_angle != 0.0f )
{
@ -1299,7 +1271,7 @@ void CMap::UpdateObject(CObject* pObj)
color != MAPCOLOR_MOVE ) return;
}
if ( pObj->RetSelect() )
if ( pObj->GetSelect() )
{
m_map[MAPMAXOBJECT-1].type = type;
m_map[MAPMAXOBJECT-1].object = pObj;
@ -1337,3 +1309,4 @@ void CMap::UpdateObject(CObject* pObj)
}
}
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -22,11 +23,21 @@
#include <ui/control.h>
#include <object/object.h>
#include <object/robotmain.h>
#include <common/event.h>
#include <common/iman.h>
class CTerrain;
class CWater;
#include <graphics/engine/terrain.h>
#include <graphics/engine/water.h>
#include <graphics/engine/engine.h>
#include <graphics/core/device.h>
#include <graphics/core/vertex.h>
#include <math/geometry.h>
namespace Ui {
const int MAPMAXOBJECT = 100;
@ -51,7 +62,7 @@ struct MapObject
CObject* object;
MapColor color;
ObjectType type;
Math::Point pos;
Math::Point pos;
float dir;
};
@ -59,77 +70,78 @@ struct MapObject
class CMap : public CControl
{
public:
CMap();
~CMap();
public:
CMap();
~CMap();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event);
void Draw();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event);
void Draw();
void UpdateTerrain();
void UpdateTerrain(int bx, int by, int ex, int ey);
void UpdateTerrain();
void UpdateTerrain(int bx, int by, int ex, int ey);
void SetFixImage(char *filename);
bool RetFixImage();
void SetFixImage(const char *filename);
bool GetFixImage();
void SetOffset(float ox, float oy);
void SetAngle(float angle);
void SetMode(int mode);
void SetToy(bool bToy);
void SetDebug(bool bDebug);
void SetOffset(float ox, float oy);
void SetAngle(float angle);
void SetMode(int mode);
void SetToy(bool bToy);
void SetDebug(bool bDebug);
void SetZoom(float value);
float RetZoom();
void SetZoom(float value);
float GetZoom();
void SetEnable(bool bEnable);
bool RetEnable();
void SetEnable(bool bEnable);
bool GetEnable();
void SetFloorColor(Gfx::Color color);
void SetWaterColor(Gfx::Color color);
void SetFloorColor(Gfx::Color color);
void SetWaterColor(Gfx::Color color);
void FlushObject();
void UpdateObject(CObject* pObj);
void FlushObject();
void UpdateObject(CObject* pObj);
CObject* DetectObject(Math::Point pos, bool &bInMap);
void SetHilite(CObject* pObj);
CObject* DetectObject(Math::Point pos, bool &bInMap);
void SetHighlight(CObject* pObj);
protected:
Math::Point AdjustOffset(Math::Point offset);
void SelectObject(Math::Point pos);
Math::Point MapInter(Math::Point pos, float dir);
void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
void DrawHilite(Math::Point pos);
void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
protected:
Math::Point AdjustOffset(Math::Point offset);
void SelectObject(Math::Point pos);
Math::Point MapInter(Math::Point pos, float dir);
void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
void DrawHighlight(Math::Point pos);
void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
protected:
CTerrain* m_terrain;
CWater* m_water;
CRobotMain* m_main;
protected:
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
CRobotMain* m_main;
bool m_bEnable;
float m_time;
float m_half;
float m_zoom;
Math::Point m_offset;
float m_angle;
Gfx::Color m_floorColor;
Gfx::Color m_waterColor;
MapObject m_map[MAPMAXOBJECT];
int m_totalFix;
int m_totalMove;
int m_hiliteRank;
Math::Point m_mapPos;
Math::Point m_mapDim;
bool m_bRadar;
char m_fixImage[100];
int m_mode;
bool m_bToy;
bool m_bDebug;
bool m_bEnable;
float m_time;
float m_half;
float m_zoom;
Math::Point m_offset;
float m_angle;
Gfx::Color m_floorColor;
Gfx::Color m_waterColor;
MapObject m_map[MAPMAXOBJECT];
int m_totalFix;
int m_totalMove;
int m_highlightRank;
Math::Point m_mapPos;
Math::Point m_mapDim;
bool m_bRadar;
char m_fixImage[100];
int m_mode;
bool m_bToy;
bool m_bDebug;
};
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -17,24 +18,27 @@
// shortcut.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "old/math3d.h"
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
#include <math.h>
//#include "common/struct.h"
//#include "old/d3dengine.h"
//#include "old/math3d.h"
#include "graphics/engine/engine.h"
#include "graphics/core/device.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "ui/shortcut.h"
namespace Ui {
// Object's constructor.
CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan)
//CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan)
CShortcut::CShortcut() : CControl()
{
m_time = 0.0f;
}
@ -48,11 +52,11 @@ CShortcut::~CShortcut()
// Creates a new button.
bool CShortcut::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
bool CShortcut::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
CControl::Create(pos, dim, icon, eventType);
return true;
}
@ -63,17 +67,18 @@ bool CShortcut::EventProcess(const Event &event)
{
CControl::EventProcess(event);
if ( event.event == EVENT_FRAME )
if ( event.type == EVENT_FRAME )
{
m_time += event.rTime;
}
if ( event.event == EVENT_LBUTTONDOWN )
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1)
{
if ( CControl::Detect(event.pos) )
{
Event newEvent = event;
newEvent.event = m_eventMsg;
newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
@ -92,24 +97,24 @@ void CShortcut::Draw()
icon = 0;
zoom = 0.8f;
mode = D3DSTATETTw;
mode = Gfx::ENG_RSTATE_TTEXTURE_WHITE;
if ( m_state & STATE_HILIGHT )
{
icon = 4;
zoom = 0.9f;
mode = D3DSTATENORMAL;
mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_state & STATE_CHECK )
{
icon = 1;
zoom = 0.8f;
mode = D3DSTATENORMAL;
mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_state & STATE_PRESS )
{
icon = 1;
zoom = 1.0f;
mode = D3DSTATENORMAL;
mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_icon == 6 || m_icon == 7 ) // pause or film?
{
@ -125,7 +130,7 @@ void CShortcut::Draw()
DrawVertex(icon, 0.95f);
}
m_engine->SetState(D3DSTATETTb);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
DrawVertex(m_icon, zoom);
if ( m_state & STATE_FRAME )
@ -134,7 +139,7 @@ void CShortcut::Draw()
float zoom, dp;
m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
zoom = 0.9f+sinf(m_time*8.0f)*0.1f;
@ -174,7 +179,7 @@ void CShortcut::Draw()
float dp;
m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATETTw);
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 160.0f/256.0f;
uv1.y = 0.0f/256.0f;
@ -195,13 +200,13 @@ void CShortcut::Draw()
void CShortcut::DrawVertex(int icon, float zoom)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
Gfx::CDevice* device;
Gfx::Vertex vertex[4]; // 2 triangles
Math::Point p1, p2, c;
Math::Vector n;
float u1, u2, v1, v2, dp;
device = m_engine->RetD3DDevice();
device = m_engine->GetDevice();
p1.x = m_pos.x;
p1.y = m_pos.y;
@ -230,12 +235,13 @@ void CShortcut::DrawVertex(int icon, float zoom)
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, u1,v2);
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, u1,v1);
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, u2,v2);
vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, u2,v1);
vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(u1, v2));
vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(u1, v1));
vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(u2, v2));
vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
}
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -22,6 +23,7 @@
#include <common/event.h>
namespace Ui {
class CShortcut : public CControl
{
@ -29,7 +31,7 @@ class CShortcut : public CControl
CShortcut();
~CShortcut();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event);
@ -43,3 +45,4 @@ class CShortcut : public CControl
};
}

View File

@ -26,8 +26,6 @@
namespace Ui {
class CButton;
class CSlider : public CControl
{
public:

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -17,58 +18,27 @@
// studio.cpp
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <windows.h>
#include <direct.h>
#include <io.h>
#include <time.h>
#include <d3d.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "common/language.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
#include "old/math3d.h"
#include "object/robotmain.h"
#include "object/object.h"
#include "old/camera.h"
#include "old/sound.h"
#include "script/script.h"
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/check.h"
#include "ui/slider.h"
#include "ui/edit.h"
#include "ui/list.h"
#include "ui/label.h"
#include "ui/group.h"
#include "ui/window.h"
#include "old/text.h"
#include "script/cbottoken.h"
#include "ui/studio.h"
#include "studio.h"
#include <script/cbottoken.h>
namespace Ui {
// Object's constructor.
CStudio::CStudio(CInstanceManager* iMan)
CStudio::CStudio()
{
m_iMan = iMan;
m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_STUDIO, this);
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_app = CApplication::GetInstancePointer();
m_bEditMaximized = false;
m_bEditMinimized = false;
@ -103,85 +73,85 @@ bool CStudio::EventProcess(const Event &event)
return EventDialog(event);
}
if ( event.event == EVENT_FRAME )
if ( event.type == EVENT_FRAME )
{
EventFrame(event);
}
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
edit = static_cast<CEdit*>(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( edit == 0 ) return false;
if ( event.event == pw->RetEventMsgClose() )
if ( event.type == pw->GetEventTypeClose() )
{
Event newEvent = event;
newEvent.event = EVENT_STUDIO_OK;
newEvent.type = EVENT_STUDIO_OK;
m_event->AddEvent(newEvent);
}
if ( event.event == EVENT_STUDIO_EDIT ) // text modifief?
if ( event.type == EVENT_STUDIO_EDIT ) // text modifief?
{
ColorizeScript(edit);
}
if ( event.event == EVENT_STUDIO_LIST ) // list clicked?
if ( event.type == EVENT_STUDIO_LIST ) // list clicked?
{
m_main->StartDisplayInfo(m_helpFilename, -1);
m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes
}
if ( event.event == EVENT_STUDIO_NEW ) // new?
if ( event.type == EVENT_STUDIO_NEW ) // new?
{
m_script->New(edit, "");
}
if ( event.event == EVENT_STUDIO_OPEN ) // open?
if ( event.type == EVENT_STUDIO_OPEN ) // open?
{
StartDialog(SD_OPEN);
}
if ( event.event == EVENT_STUDIO_SAVE ) // save?
if ( event.type == EVENT_STUDIO_SAVE ) // save?
{
StartDialog(SD_SAVE);
}
if ( event.event == EVENT_STUDIO_UNDO ) // undo?
if ( event.type == EVENT_STUDIO_UNDO ) // undo?
{
edit->Undo();
}
if ( event.event == EVENT_STUDIO_CUT ) // cut?
if ( event.type == EVENT_STUDIO_CUT ) // cut?
{
edit->Cut();
}
if ( event.event == EVENT_STUDIO_COPY ) // copy?
if ( event.type == EVENT_STUDIO_COPY ) // copy?
{
edit->Copy();
}
if ( event.event == EVENT_STUDIO_PASTE ) // paste?
if ( event.type == EVENT_STUDIO_PASTE ) // paste?
{
edit->Paste();
}
if ( event.event == EVENT_STUDIO_SIZE ) // size?
if ( event.type == EVENT_STUDIO_SIZE ) // size?
{
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
if ( slider == 0 ) return false;
m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f);
m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f);
ViewEditScript();
}
if ( event.event == EVENT_STUDIO_TOOL && // instructions?
if ( event.type == EVENT_STUDIO_TOOL && // instructions?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_HUSTON, false);
}
if ( event.event == EVENT_STUDIO_HELP && // help?
if ( event.type == EVENT_STUDIO_HELP && // help?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_PROG, false);
}
if ( event.event == EVENT_STUDIO_COMPILE ) // compile?
if ( event.type == EVENT_STUDIO_COMPILE ) // compile?
{
char buffer[100];
@ -197,12 +167,12 @@ 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() )
{
Event newEvent = event;
newEvent.event = EVENT_OBJECT_PROGSTOP;
newEvent.type = EVENT_OBJECT_PROGSTOP;
m_event->AddEvent(newEvent); // stop
}
else
@ -212,7 +182,7 @@ bool CStudio::EventProcess(const Event &event)
SetInfoText("", false);
Event newEvent = event;
newEvent.event = EVENT_OBJECT_PROGSTART;
newEvent.type = EVENT_OBJECT_PROGSTART;
m_event->AddEvent(newEvent); // start
}
else
@ -224,7 +194,7 @@ bool CStudio::EventProcess(const Event &event)
}
}
if ( event.event == EVENT_STUDIO_REALTIME ) // real time?
if ( event.type == EVENT_STUDIO_REALTIME ) // real time?
{
m_bRealTime = !m_bRealTime;
m_script->SetStepMode(!m_bRealTime);
@ -232,37 +202,37 @@ bool CStudio::EventProcess(const Event &event)
UpdateButtons();
}
if ( event.event == EVENT_STUDIO_STEP ) // step?
if ( event.type == EVENT_STUDIO_STEP ) // step?
{
m_script->Step(event);
}
if ( event.event == EVENT_KEYDOWN )
if ( event.type == EVENT_KEY_DOWN )
{
if ( event.param == m_engine->RetKey(KEYRANK_CBOT, 0) ||
event.param == m_engine->RetKey(KEYRANK_CBOT, 1) )
if ( event.param == m_app->GetKey(KEYRANK_CBOT, 0) ||
event.param == m_app->GetKey(KEYRANK_CBOT, 1) )
{
if ( m_helpFilename[0] != 0 )
if ( m_helpFilename.length() > 0 )
{
m_main->StartDisplayInfo(m_helpFilename, -1);
m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes
}
}
}
if ( event.event == EVENT_WINDOW3 ) // window is moved?
if ( event.type == EVENT_WINDOW3 ) // window is moved?
{
m_editActualPos = m_editFinalPos = pw->RetPos();
m_editActualDim = m_editFinalDim = pw->RetDim();
m_editActualPos = m_editFinalPos = pw->GetPos();
m_editActualDim = m_editFinalDim = pw->GetDim();
m_main->SetWindowPos(m_editActualPos);
m_main->SetWindowDim(m_editActualDim);
AdjustEditScript();
}
if ( event.event == pw->RetEventMsgReduce() )
if ( event.type == pw->GetEventTypeReduce() )
{
if ( m_bEditMinimized )
{
m_editFinalPos = m_main->RetWindowPos();
m_editFinalDim = m_main->RetWindowDim();
m_editFinalPos = m_main->GetWindowPos();
m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@ -277,18 +247,18 @@ bool CStudio::EventProcess(const Event &event)
}
m_main->SetEditFull(m_bEditMaximized);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw != 0 )
if ( pw != nullptr )
{
pw->SetMaximized(m_bEditMaximized);
pw->SetMinimized(m_bEditMinimized);
}
}
if ( event.event == pw->RetEventMsgFull() )
if ( event.type == pw->GetEventTypeFull() )
{
if ( m_bEditMaximized )
{
m_editFinalPos = m_main->RetWindowPos();
m_editFinalDim = m_main->RetWindowDim();
m_editFinalPos = m_main->GetWindowPos();
m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@ -303,7 +273,7 @@ bool CStudio::EventProcess(const Event &event)
}
m_main->SetEditFull(m_bEditMaximized);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw != 0 )
if ( pw != nullptr )
{
pw->SetMaximized(m_bEditMaximized);
pw->SetMinimized(m_bEditMinimized);
@ -349,7 +319,7 @@ bool CStudio::EventFrame(const Event &event)
m_fixInfoTextTime -= event.rTime;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( edit == 0 ) return false;
@ -363,10 +333,10 @@ bool CStudio::EventFrame(const Event &event)
UpdateFlux(); // stop
AdjustEditScript();
GetResource(RES_TEXT, RT_STUDIO_PROGSTOP, res);
SetInfoText(res, false);
SetInfoText(std::string(res), false);
Event newEvent = event;
newEvent.event = EVENT_OBJECT_PROGSTOP;
newEvent.type = EVENT_OBJECT_PROGSTOP;
m_event->AddEvent(newEvent); // stop
}
@ -419,7 +389,7 @@ bool IsToken(int character)
{
char c;
c = tolower(RetNoAccent(character));
c = tolower(GetNoAccent(character));
return ( (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
@ -435,8 +405,8 @@ void CStudio::SearchToken(CEdit* edit)
char* text;
char token[100];
text = edit->RetText();
len = edit->RetTextLength();
text = edit->GetText();
len = edit->GetTextLength();
edit->GetCursor(cursor1, cursor2);
i = cursor1;
@ -499,8 +469,8 @@ void CStudio::SearchToken(CEdit* edit)
}
token[i] = 0;
strcpy(m_helpFilename, RetHelpFilename(token));
if ( m_helpFilename[0] == 0 )
m_helpFilename = std::string(GetHelpFilename(token));
if ( m_helpFilename.length() == 0 )
{
for ( i=0 ; i<OBJECT_MAX ; i++ )
{
@ -510,28 +480,28 @@ void CStudio::SearchToken(CEdit* edit)
{
if ( strcmp(token, text) == 0 )
{
strcpy(m_helpFilename, RetHelpFilename(type));
SetInfoText(token, true);
m_helpFilename = GetHelpFilename(type);
SetInfoText(std::string(token), true);
return;
}
}
text = RetObjectAlias(type);
text = GetObjectAlias(type);
if ( text[0] != 0 )
{
if ( strcmp(token, text) == 0 )
{
strcpy(m_helpFilename, RetHelpFilename(type));
SetInfoText(token, true);
m_helpFilename = GetHelpFilename(type);
SetInfoText(std::string(token), true);
return;
}
}
}
}
text = RetHelpText(token);
if ( text[0] == 0 && m_helpFilename[0] != 0 )
text = GetHelpText(token);
if ( text[0] == 0 && m_helpFilename.length() > 0 )
{
SetInfoText(token, true);
SetInfoText(std::string(token), true);
}
else
{
@ -549,7 +519,7 @@ void CStudio::ColorizeScript(CEdit* edit)
// Starts editing a program.
void CStudio::StartEditScript(CScript *script, char* name, int rank)
void CStudio::StartEditScript(CScript *script, std::string name, int rank)
{
Math::Point pos, dim;
CWindow* pw;
@ -564,10 +534,10 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
m_main->SetEditLock(true, true);
m_main->SetEditFull(false);
m_bInitPause = m_engine->RetPause();
m_bInitPause = m_engine->GetPause();
m_main->SetSpeed(1.0f);
m_editCamera = m_camera->RetType();
m_camera->SetType(CAMERA_EDIT);
m_editCamera = m_camera->GetType();
m_camera->SetType(CAM_TYPE_EDIT);
m_bRunning = m_script->IsRunning();
m_bRealTime = m_bRunning;
@ -579,10 +549,10 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
button->ClearState(STATE_VISIBLE);
}
pos = m_editFinalPos = m_editActualPos = m_main->RetWindowPos();
dim = m_editFinalDim = m_editActualDim = m_main->RetWindowDim();
pos = m_editFinalPos = m_editActualPos = m_main->GetWindowPos();
dim = m_editFinalDim = m_editActualDim = m_main->GetWindowDim();
pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW3);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
pw->SetState(STATE_SHADOW);
pw->SetRedim(true); // before SetName!
pw->SetMovable(true);
@ -600,10 +570,10 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
edit->SetInsideScroll(false);
//? if ( m_bRunning ) edit->SetEdit(false);
edit->SetMaxChar(EDITSTUDIOMAX);
edit->SetFontType(FONT_COURIER);
edit->SetFontType(Gfx::FONT_COURIER);
edit->SetFontStretch(0.7f);
edit->SetDisplaySpec(true);
edit->SetAutoIndent(m_engine->RetEditIndentMode());
edit->SetAutoIndent(m_engine->GetEditIndentMode());
m_script->PutScript(edit, name);
ColorizeScript(edit);
@ -611,7 +581,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
list = pw->CreateList(pos, dim, 1, EVENT_STUDIO_LIST, 1.2f);
list->SetState(STATE_SHADOW);
list->SetFontType(FONT_COURIER);
list->SetFontType(Gfx::FONT_COURIER);
list->SetSelectCap(false);
list->SetFontSize(SMALLFONT*0.85f);
//? list->SetFontStretch(1.0f);
@ -632,7 +602,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
button->SetState(STATE_SHADOW);
slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE);
slider->SetState(STATE_SHADOW);
slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
pw->CreateGroup(pos, dim, 19, EVENT_LABEL1); // SatCom logo
button = pw->CreateButton(pos, dim, 128+57, EVENT_STUDIO_TOOL);
button->SetState(STATE_SHADOW);
@ -674,11 +644,11 @@ void CStudio::AdjustEditScript()
wdim = m_editActualDim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw != 0 )
if ( pw != nullptr )
{
pw->SetPos(wpos);
pw->SetDim(wdim);
wdim = pw->RetDim();
wdim = pw->GetDim();
}
if ( m_bRunning ) hList = 80.0f/480.0f;
@ -852,7 +822,7 @@ bool CStudio::StopEditScript(bool bCancel)
char buffer[100];
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
if ( !bCancel && !m_script->IsRunning() )
{
@ -898,7 +868,7 @@ void CStudio::SetInfoText(char *text, bool bClickable)
if ( !bClickable ) m_fixInfoTextTime = 8.0f;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST);
if ( list == 0 ) return;
@ -933,13 +903,13 @@ void CStudio::ViewEditScript()
POINT dim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( edit == 0 ) return;
dim = m_engine->RetDim();
edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f));
dim = m_engine->GetDim();
edit->SetFontSize(m_main->GetFontSize()/(dim.x/640.0f));
}
@ -981,7 +951,7 @@ void CStudio::UpdateButtons()
CButton* button;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( edit == 0 ) return;
@ -1034,37 +1004,37 @@ void CStudio::StartDialog(StudioDialog type)
m_dialog = type;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8);
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
pos = m_main->RetIOPos();
dim = m_main->RetIODim();
pos = m_main->GetIOPos();
dim = m_main->GetIODim();
}
//? pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW9);
pw = m_interface->CreateWindows(pos, dim, m_dialog==SD_OPEN?14:13, EVENT_WINDOW9);
@ -1084,25 +1054,25 @@ void CStudio::StartDialog(StudioDialog type)
{
GetResource(RES_TEXT, RT_IO_LIST, name);
pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL1, name);
pla->SetJustif(1);
pla->SetTextAlign(1);
pli = pw->CreateList(pos, dim, 0, EVENT_DIALOG_LIST);
pli->SetState(STATE_SHADOW);
GetResource(RES_TEXT, RT_IO_NAME, name);
pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL2, name);
pla->SetJustif(1);
pla->SetTextAlign(1);
pe = pw->CreateEdit(pos, dim, 0, EVENT_DIALOG_EDIT);
pe->SetState(STATE_SHADOW);
if ( m_dialog == SD_SAVE )
{
pe->SetText(m_script->RetFilename());
pe->SetText(m_script->GetFilename());
}
GetResource(RES_TEXT, RT_IO_DIR, name);
pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL3, name);
pla->SetJustif(1);
pla->SetTextAlign(1);
pc = pw->CreateCheck(pos, dim, 0, EVENT_DIALOG_CHECK1);
GetResource(RES_TEXT, RT_IO_PRIVATE, name);
@ -1153,31 +1123,31 @@ void CStudio::StopDialog()
m_dialog = SD_NULL;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8);
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
m_interface->DeleteControl(EVENT_WINDOW9);
m_main->SetSatComLock(false); // possible to use the SatCom
@ -1198,10 +1168,10 @@ void CStudio::AdjustDialog()
char name[100];
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
wpos = pw->RetPos();
wdim = pw->RetDim();
wpos = pw->GetPos();
wdim = pw->GetDim();
pw->SetPos(wpos); // to move the buttons on the titlebar
if ( m_dialog == SD_OPEN ||
@ -1316,12 +1286,12 @@ bool CStudio::EventDialog(const Event &event)
Math::Point wpos, wdim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
if ( event.event == EVENT_WINDOW9 ) // window is moved?
if ( event.type == EVENT_WINDOW9 ) // window is moved?
{
wpos = pw->RetPos();
wdim = pw->RetDim();
wpos = pw->GetPos();
wdim = pw->GetDim();
m_main->SetIOPos(wpos);
m_main->SetIODim(wdim);
AdjustDialog();
@ -1330,22 +1300,22 @@ bool CStudio::EventDialog(const Event &event)
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
if ( event.event == EVENT_DIALOG_LIST )
if ( event.type == EVENT_DIALOG_LIST )
{
UpdateChangeList();
}
if ( event.event == EVENT_DIALOG_EDIT )
if ( event.type == EVENT_DIALOG_EDIT )
{
UpdateChangeEdit();
}
if ( event.event == EVENT_DIALOG_CHECK1 ) // private?
if ( event.type == EVENT_DIALOG_CHECK1 ) // private?
{
m_main->SetIOPublic(false);
UpdateDialogPublic();
UpdateDialogList();
}
if ( event.event == EVENT_DIALOG_CHECK2 ) // public?
if ( event.type == EVENT_DIALOG_CHECK2 ) // public?
{
m_main->SetIOPublic(true);
UpdateDialogPublic();
@ -1353,8 +1323,8 @@ bool CStudio::EventDialog(const Event &event)
}
}
if ( event.event == EVENT_DIALOG_OK ||
(event.event == EVENT_KEYDOWN && event.param == VK_RETURN) )
if ( event.type == EVENT_DIALOG_OK ||
(event.type == EVENT_KEYDOWN && event.param == VK_RETURN) )
{
if ( m_dialog == SD_OPEN )
{
@ -1369,9 +1339,9 @@ bool CStudio::EventDialog(const Event &event)
return true;
}
if ( event.event == EVENT_DIALOG_CANCEL ||
(event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ||
event.event == pw->RetEventMsgClose() )
if ( event.type == EVENT_DIALOG_CANCEL ||
(event.type == EVENT_KEYDOWN && event.param == VK_ESCAPE) ||
event.type == pw->GetEventTypeClose() )
{
StopDialog();
return true;
@ -1391,14 +1361,14 @@ void CStudio::UpdateChangeList()
char* p;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST);
if ( pl == 0 ) return;
pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
if ( pe == 0 ) return;
if ( pe == nullptr ) return;
strcpy(name, pl->RetName(pl->RetSelect()));
name[pe->RetMaxChar()] = 0; // truncates according lg max editable
strcpy(name, pl->GetName(pl->GetSelect()));
name[pe->GetMaxChar()] = 0; // truncates according lg max editable
p = strchr(name, '\t'); // seeks first tab
if ( p != 0 ) *p = 0;
pe->SetText(name);
@ -1416,7 +1386,7 @@ void CStudio::UpdateChangeEdit()
CList* pl;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST);
if ( pl == 0 ) return;
@ -1437,9 +1407,9 @@ void CStudio::UpdateDialogAction()
bool bError;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
if ( pe == 0 ) return;
if ( pe == nullptr ) return;
pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK);
if ( pb == 0 ) return;
@ -1481,18 +1451,18 @@ void CStudio::UpdateDialogPublic()
char text[_MAX_FNAME+100];
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1);
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, !m_main->RetIOPublic());
pc->SetState(STATE_CHECK, !m_main->GetIOPublic());
}
pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2);
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_main->RetIOPublic());
pc->SetState(STATE_CHECK, m_main->GetIOPublic());
}
pl = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1);
@ -1509,7 +1479,8 @@ void CStudio::UpdateDialogPublic()
void CStudio::UpdateDialogList()
{
CWindow* pw;
// TODO rewrite to multiplatform
/*CWindow* pw;
CList* pl;
long hFile;
struct _finddata_t fileBuffer;
@ -1520,7 +1491,7 @@ void CStudio::UpdateDialogList()
int nbFilenames, i;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
if ( pw == nullptr ) return;
pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST);
if ( pl == 0 ) return;
pl->Flush();
@ -1565,7 +1536,7 @@ void CStudio::UpdateDialogList()
pl->SetName(i, temp);
}
free(listBuffer);
free(listBuffer);*/
}
// Constructs the name of the folder or open/save.
@ -1573,13 +1544,13 @@ void CStudio::UpdateDialogList()
void CStudio::SearchDirectory(char *dir, bool bCreate)
{
if ( m_main->RetIOPublic() )
if ( m_main->GetIOPublic() )
{
sprintf(dir, "%s\\", m_main->RetPublicDir());
sprintf(dir, "%s\\", m_main->GetPublicDir());
}
else
{
sprintf(dir, "%s\\%s\\Program\\", m_main->RetSavegameDir(), m_main->RetGamerName());
sprintf(dir, "%s\\%s\\Program\\", m_main->GetSavegameDir(), m_main->GetGamerName());
}
if ( bCreate )
@ -1599,10 +1570,10 @@ bool CStudio::ReadProgram()
char* p;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
if ( pe == 0 ) return false;
if ( pe == nullptr ) return false;
pe->GetText(filename, 100);
if ( filename[0] == 0 ) return false;
@ -1615,9 +1586,9 @@ bool CStudio::ReadProgram()
strcat(dir, filename);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( pe == 0 ) return false;
if ( pe == nullptr ) return false;
if ( !pe->ReadText(dir) ) return false;
@ -1637,10 +1608,10 @@ bool CStudio::WriteProgram()
char* p;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
if ( pe == 0 ) return false;
if ( pe == nullptr ) return false;
pe->GetText(filename, 100);
if ( filename[0] == 0 ) return false;
@ -1653,9 +1624,9 @@ bool CStudio::WriteProgram()
strcat(dir, filename);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
if ( pw == 0 ) return false;
if ( pw == nullptr ) return false;
pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( pe == 0 ) return false;
if ( pe == nullptr ) return false;
if ( !pe->WriteText(dir) ) return false;
@ -1663,3 +1634,4 @@ bool CStudio::WriteProgram()
return true;
}
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@ -18,23 +19,46 @@
#pragma once
#include <string>
#include "object/object.h"
#include "script/script.h"
class CInstanceManager;
class CD3DEngine;
class CEvent;
class CRobotMain;
class CCamera;
class CSound;
class CInterface;
class CScript;
class CList;
class CEdit;
#include <object/object.h>
#include <script/script.h>
#include <graphics/engine/engine.h>
#include <graphics/engine/camera.h>
#include <common/event.h>
#include <common/struct.h>
#include <common/misc.h>
#include <common/iman.h>
#include <sound/sound.h>
#include <ui/control.h>
#include <ui/button.h>
#include <ui/color.h>
#include <ui/check.h>
#include <ui/key.h>
#include <ui/group.h>
#include <ui/image.h>
#include <ui/label.h>
#include <ui/edit.h>
#include <ui/editvalue.h>
#include <ui/scroll.h>
#include <ui/slider.h>
#include <ui/list.h>
#include <ui/shortcut.h>
#include <ui/compass.h>
#include <ui/target.h>
#include <ui/map.h>
#include <ui/window.h>
#include <ui/interface.h>
#include <app/app.h>
namespace Ui {
enum StudioDialog
{
@ -49,67 +73,71 @@ enum StudioDialog
class CStudio
{
public:
CStudio(CInstanceManager* iMan);
~CStudio();
public:
CStudio();
~CStudio();
bool EventProcess(const Event &event);
bool EventProcess(const Event &event);
void StartEditScript(CScript *script, char* name, int rank);
bool StopEditScript(bool bCancel);
void StartEditScript(CScript *script, std::string name, int rank);
bool StopEditScript(bool bCancel);
protected:
bool EventFrame(const Event &event);
void SearchToken(CEdit* edit);
void ColorizeScript(CEdit* edit);
void AdjustEditScript();
void SetInfoText(char *text, bool bClickable);
void ViewEditScript();
void UpdateFlux();
void UpdateButtons();
protected:
bool EventFrame(const Event &event);
void SearchToken(CEdit* edit);
void ColorizeScript(CEdit* edit);
void AdjustEditScript();
void SetInfoText(std::string text, bool bClickable);
void ViewEditScript();
void UpdateFlux();
void UpdateButtons();
void StartDialog(StudioDialog type);
void StopDialog();
void AdjustDialog();
bool EventDialog(const Event &event);
void UpdateChangeList();
void UpdateChangeEdit();
void UpdateDialogAction();
void UpdateDialogPublic();
void UpdateDialogList();
void SearchDirectory(char *dir, bool bCreate);
bool ReadProgram();
bool WriteProgram();
void StartDialog(StudioDialog type);
void StopDialog();
void AdjustDialog();
bool EventDialog(const Event &event);
void UpdateChangeList();
void UpdateChangeEdit();
void UpdateDialogAction();
void UpdateDialogPublic();
void UpdateDialogList();
void SearchDirectory(std::string dir, bool bCreate);
bool ReadProgram();
bool WriteProgram();
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CEvent* m_event;
CRobotMain* m_main;
CCamera* m_camera;
CSound* m_sound;
CInterface* m_interface;
protected:
CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
CEventQueue* m_event;
CRobotMain* m_main;
CCamera* m_camera;
CSoundInterface* m_sound;
CInterface* m_interface;
CApplication *m_app;
int m_rank;
CScript* m_script;
int m_rank;
CScript* m_script;
Gfx::CameraType m_editCamera;
bool m_bEditMaximized;
bool m_bEditMinimized;
bool m_bEditMaximized;
bool m_bEditMinimized;
CameraType m_editCamera;
Math::Point m_editActualPos;
Math::Point m_editActualDim;
Math::Point m_editFinalPos;
Math::Point m_editFinalDim;
CameraType m_editCamera;
Math::Point m_editActualPos;
Math::Point m_editActualDim;
Math::Point m_editFinalPos;
Math::Point m_editFinalDim;
float m_time;
float m_fixInfoTextTime;
bool m_bRunning;
bool m_bRealTime;
bool m_bInitPause;
char m_helpFilename[100];
float m_time;
float m_fixInfoTextTime;
bool m_bRunning;
bool m_bRealTime;
bool m_bInitPause;
std::string m_helpFilename;
StudioDialog m_dialog;
};
}

View File

@ -17,21 +17,7 @@
// target.cpp
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
//#include "common/struct.h"
//#include "old/d3dengine.h"
//#include "old/math3d.h"
#include "graphics/engine/engine.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "object/robotmain.h"
#include "object/object.h"
#include "common/restext.h"
#include "ui/target.h"
#include <ui/target.h>
@ -137,7 +123,7 @@ bool CTarget::EventProcess(const Event &event)
{
if ( CControl::Detect(event.pos) )
{
if ( !m_main->RetFriendAim() )
if ( !m_main->GetFriendAim() )
{
Event newEvent = event;
newEvent.type = EVENT_OBJECT_FIRE;
@ -162,7 +148,7 @@ void CTarget::Draw()
// Returns the tooltip.
bool CTarget::GetTooltip(Math::Point pos, char* name)
bool CTarget::GetTooltip(Math::Point pos, std::string &name)
{
#if 0
if ( (m_state&STATE_VISIBLE) && Detect(pos) ) // in the window?
@ -181,9 +167,9 @@ bool CTarget::GetTooltip(Math::Point pos, char* name)
{
//? pObj = DetectFriendObject(pos);
//? if ( pObj == 0 )
if ( !m_main->RetFriendAim() )
if ( !m_main->GetFriendAim() )
{
strcpy(name, m_tooltip);
m_tooltip = name;
return true; // does not detect objects below!
}
}

View File

@ -18,11 +18,21 @@
#pragma once
#include <string>
#include <ui/control.h>
#include <common/misc.h>
#include <common/iman.h>
#include <common/restext.h>
#include <common/event.h>
#include <graphics/engine/engine.h>
#include <object/robotmain.h>
#include <object/object.h>
namespace Ui {
class CTarget : public CControl
@ -35,7 +45,7 @@ class CTarget : public CControl
bool EventProcess(const Event &event);
void Draw();
bool GetTooltip(Math::Point pos, char* name);
bool GetTooltip(Math::Point pos, std::string &name);
protected:
CObject* DetectFriendObject(Math::Point pos);

View File

@ -18,38 +18,7 @@
// window.cpp
//#include <windows.h>
//#include <stdio.h>
//#include <d3d.h>
//#include "common/struct.h"
//#include "old/d3dengine.h"
#include "common/language.h"
//#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/restext.h"
#include "common/iman.h"
#include "ui/button.h"
#include "ui/color.h"
#include "ui/check.h"
#include "ui/key.h"
#include "ui/group.h"
#include "ui/image.h"
#include "ui/label.h"
#include "ui/edit.h"
#include "ui/editvalue.h"
#include "ui/scroll.h"
#include "ui/slider.h"
#include "ui/list.h"
#include "ui/shortcut.h"
#include "ui/map.h"
#include "ui/gauge.h"
#include "ui/compass.h"
#include "ui/target.h"
//#include "old/text.h"
#include "graphics/engine/text.h"
#include "ui/window.h"
#include <ui/window.h>
@ -280,11 +249,9 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventTy
// Creates a new label.
CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg,
char *name)
CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name)
{
CLabel* pc;
char* p;
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
@ -298,22 +265,11 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventTy
pc = (CLabel*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
p = strchr(name, '\\');
if ( p == 0 )
{
auto p = name.find("\\");
if ( p == std::string::npos )
pc->SetName(name);
}
else
{
char text[100];
strncpy(text, name, 100);
text[100-1] = 0;
if ( p-name < 100 )
{
text[p-name] = 0; // deletes text after "\\" (tooltip)
}
pc->SetName(text);
}
pc->SetName(name.substr(0, p));
return pc;
}
}
@ -589,7 +545,7 @@ CControl* CWindow::SearchControl(EventType eventMsg)
// Makes the tooltip binds to the window.
bool CWindow::GetTooltip(Math::Point pos, char* name)
bool CWindow::GetTooltip(Math::Point pos, std::string &name)
{
int i;
@ -622,7 +578,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name)
if ( Detect(pos) ) // in the window?
{
strcpy(name, m_tooltip);
name = m_tooltip;
return true;
}
@ -632,7 +588,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name)
// Specifies the name for the title bar.
void CWindow::SetName(char* name)
void CWindow::SetName(std::string name)
{
CButton* pc;
bool bAdjust;
@ -659,7 +615,7 @@ void CWindow::SetName(char* name)
bAdjust = false;
if ( m_name[0] != 0 && m_bRedim ) // title bar exists?
if ( m_name.length() > 0 && m_bRedim ) // title bar exists?
{
m_buttonReduce = new CButton();
pc = (CButton*)m_buttonReduce;
@ -672,7 +628,7 @@ void CWindow::SetName(char* name)
bAdjust = true;
}
if ( m_name[0] != 0 && m_bClosable ) // title bar exists?
if ( m_name.length() > 0 && m_bClosable ) // title bar exists?
{
m_buttonClose = new CButton();
pc = (CButton*)m_buttonClose;
@ -852,13 +808,13 @@ void CWindow::AdjustButtons()
{
m_buttonFull->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
m_buttonFull->SetTooltip(res);
m_buttonFull->SetTooltip(std::string(res));
}
else
{
m_buttonFull->SetIcon(52);
GetResource(RES_TEXT, RT_WINDOW_MAXIMIZED, res);
m_buttonFull->SetTooltip(res);
m_buttonFull->SetTooltip(std::string(res));
}
}
@ -868,13 +824,13 @@ void CWindow::AdjustButtons()
{
m_buttonReduce->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
m_buttonReduce->SetTooltip(res);
m_buttonReduce->SetTooltip(std::string(res));
}
else
{
m_buttonReduce->SetIcon(51);
GetResource(RES_TEXT, RT_WINDOW_MINIMIZED, res);
m_buttonReduce->SetTooltip(res);
m_buttonReduce->SetTooltip(std::string(res));
}
}
@ -882,7 +838,7 @@ void CWindow::AdjustButtons()
{
m_buttonClose->SetIcon(11); // x
GetResource(RES_TEXT, RT_WINDOW_CLOSE, res);
m_buttonClose->SetTooltip(res);
m_buttonClose->SetTooltip(std::string(res));
}
}
@ -992,7 +948,7 @@ bool CWindow::EventProcess(const Event &event)
{
m_pressMouse = Gfx::ENG_MOUSE_NORM;
if ( m_name[0] != 0 && m_bMovable && // title bar?
if ( m_name.length() > 0 && m_bMovable && // title bar?
Detect(event.pos) )
{
flags = BorderDetect(event.pos);
@ -1059,7 +1015,7 @@ bool CWindow::EventProcess(const Event &event)
{
if ( Detect(event.pos) )
{
if ( m_name[0] != 0 && m_bMovable ) // title bar?
if ( m_name.length() > 0 && m_bMovable ) // title bar?
{
m_pressFlags = BorderDetect(event.pos);
if ( m_pressFlags != 0 )
@ -1125,9 +1081,7 @@ bool CWindow::EventProcess(const Event &event)
m_event->AddEvent(newEvent);
}
if ( event.type == EVENT_MOUSE_BUTTON_UP &&
event.mouseButton == 1 &&
m_bCapture )
if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 && m_bCapture )
{
m_bCapture = false;
}
@ -1153,7 +1107,7 @@ void CWindow::Draw()
DrawVertex(m_pos, m_dim, m_icon); // draws the background
if ( m_name[0] != 0 ) // title bar?
if ( m_name.length() > 0 ) // title bar?
{
h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);

View File

@ -19,15 +19,38 @@
#pragma once
#include <string>
#include <common/language.h>
#include <common/event.h>
#include <common/misc.h>
#include <common/restext.h>
#include <ui/button.h>
#include <ui/color.h>
#include <ui/check.h>
#include <ui/key.h>
#include <ui/group.h>
#include <ui/image.h>
#include <ui/label.h>
#include <ui/edit.h>
#include <ui/editvalue.h>
#include <ui/scroll.h>
#include <ui/slider.h>
#include <ui/list.h>
#include <ui/shortcut.h>
#include <ui/map.h>
#include <ui/gauge.h>
#include <ui/compass.h>
#include <ui/target.h>
#include <ui/control.h>
//#include <common/event.h>
#include <graphics/engine/text.h>
namespace Ui {
const int MAXWINDOW = 100;
class CGauge;
class CWindow : public CControl
{
@ -43,7 +66,7 @@ public:
CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, char *name);
CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
@ -61,7 +84,7 @@ public:
EventType GetEventTypeFull();
EventType GetEventTypeClose();
void SetName(char* name);
void SetName(std::string name);
void SetTrashEvent(bool bTrash);
bool GetTrashEvent();
@ -90,7 +113,7 @@ public:
void SetFixed(bool bFix);
bool GetFixed();
bool GetTooltip(Math::Point pos, char* name);
bool GetTooltip(Math::Point pos, std::string &name);
bool EventProcess(const Event &event);