Merge with changes from Zaba999 fork.

dev-ui
Zaba999 2012-09-10 23:29:38 +02:00
parent cf2295d08d
commit 479a67a731
72 changed files with 8813 additions and 5479 deletions

View File

@ -124,7 +124,7 @@ graphics/opengl/gldevice.cpp
# object/motion/motiontoto.cpp # object/motion/motiontoto.cpp
# object/motion/motionvehicle.cpp # object/motion/motionvehicle.cpp
# object/motion/motionworm.cpp # object/motion/motionworm.cpp
# object/object.cpp object/object.cpp
# object/robotmain.cpp # object/robotmain.cpp
# object/task/task.cpp # object/task/task.cpp
# object/task/taskadvance.cpp # object/task/taskadvance.cpp
@ -147,10 +147,10 @@ graphics/opengl/gldevice.cpp
# object/task/taskterraform.cpp # object/task/taskterraform.cpp
# object/task/taskturn.cpp # object/task/taskturn.cpp
# object/task/taskwait.cpp # object/task/taskwait.cpp
# physics/physics.cpp physics/physics.cpp
# script/cbottoken.cpp script/cbottoken.cpp
# script/cmdtoken.cpp script/cmdtoken.cpp
# script/script.cpp script/script.cpp
# sound/sound.cpp # sound/sound.cpp
# ui/button.cpp # ui/button.cpp
# ui/check.cpp # ui/check.cpp
@ -197,6 +197,7 @@ ${SDL_IMAGE_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR}
${PNG_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS}
${OPTIONAL_INCLUDE_DIRS} ${OPTIONAL_INCLUDE_DIRS}
..
) )
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)

View File

@ -29,6 +29,7 @@
// If need arises, it can be changed to custom function or anything else // If need arises, it can be changed to custom function or anything else
#define KEY(x) SDLK_ ## x #define KEY(x) SDLK_ ## x
// Key modifier defined as concatenation to KMOD_... // Key modifier defined as concatenation to KMOD_...
// If need arises, it can be changed to custom function or anything else // If need arises, it can be changed to custom function or anything else
#define KEY_MOD(x) KMOD_ ## x #define KEY_MOD(x) KMOD_ ## x

View File

@ -21,14 +21,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <direct.h> //#include <direct.h>
#include <time.h> #include <time.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" #include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/d3dmath.h" #include "graphics/engine/engine.h"
#include "old/d3dutil.h" //#include "old/d3dmath.h"
//#include "math/math.h"
//#include "old/d3dutil.h"
#include "common/language.h" #include "common/language.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
@ -37,7 +39,7 @@
CMetaFile g_metafile; CMetaFile g_metafile;
static EventMsg g_uniqueEventMsg = EVENT_USER; static EventType g_uniqueEventType = EVENT_USER;
static bool g_bUserDir = false; static bool g_bUserDir = false;
static char g_userDir[100] = ""; static char g_userDir[100] = "";
@ -45,84 +47,84 @@ static char g_userDir[100] = "";
// Gives a single user event. // Gives a single user event.
EventMsg GetUniqueEventMsg() EventType GetUniqueEventType()
{ {
int i; int i;
i = (int)g_uniqueEventMsg+1; i = static_cast <int> (g_uniqueEventType+1);
g_uniqueEventMsg = (EventMsg)i; g_uniqueEventType = static_cast<EventType>(i);
return g_uniqueEventMsg; return g_uniqueEventType;
} }
// Returns a non-accented letter. // Returns a non-accented letter.
char RetNoAccent(char letter) char GetNoAccent(char letter)
{ {
if ( letter < 0 ) if ( letter < 0 )
{ {
if ( letter == 'á' || if ( letter == '<EFBFBD>' ||
letter == 'à' || letter == '<EFBFBD>' ||
letter == 'â' || letter == '<EFBFBD>' ||
letter == 'ä' || letter == '<EFBFBD>' ||
letter == 'ã' ) return 'a'; letter == '<EFBFBD>' ) return 'a';
if ( letter == 'é' || if ( letter == '<EFBFBD>' ||
letter == 'è' || letter == '<EFBFBD>' ||
letter == 'ê' || letter == '<EFBFBD>' ||
letter == 'ë' ) return 'e'; letter == '<EFBFBD>' ) return 'e';
if ( letter == 'í' || if ( letter == '<EFBFBD>' ||
letter == 'ì' || letter == '<EFBFBD>' ||
letter == 'î' || letter == '<EFBFBD>' ||
letter == 'ï' ) return 'i'; letter == '<EFBFBD>' ) return 'i';
if ( letter == 'ó' || if ( letter == '<EFBFBD>' ||
letter == 'ò' || letter == '<EFBFBD>' ||
letter == 'ô' || letter == '<EFBFBD>' ||
letter == 'ö' || letter == '<EFBFBD>' ||
letter == 'õ' ) return 'o'; letter == '<EFBFBD>' ) return 'o';
if ( letter == 'ú' || if ( letter == '<EFBFBD>' ||
letter == 'ù' || letter == '<EFBFBD>' ||
letter == 'û' || letter == '<EFBFBD>' ||
letter == 'ü' ) return 'u'; letter == '<EFBFBD>' ) return 'u';
if ( letter == 'ç' ) return 'c'; if ( letter == '<EFBFBD>' ) return 'c';
if ( letter == 'ñ' ) return 'n'; if ( letter == '<EFBFBD>' ) return 'n';
if ( letter == 'Á' || if ( letter == '<EFBFBD>' ||
letter == 'À' || letter == '<EFBFBD>' ||
letter == 'Â' || letter == '<EFBFBD>' ||
letter == 'Ä' || letter == '<EFBFBD>' ||
letter == 'Ã' ) return 'A'; letter == '<EFBFBD>' ) return 'A';
if ( letter == 'É' || if ( letter == '<EFBFBD>' ||
letter == 'È' || letter == '<EFBFBD>' ||
letter == 'Ê' || letter == '<EFBFBD>' ||
letter == 'Ë' ) return 'E'; letter == '<EFBFBD>' ) return 'E';
if ( letter == 'Í' || if ( letter == '<EFBFBD>' ||
letter == 'Ì' || letter == '<EFBFBD>' ||
letter == 'Î' || letter == '<EFBFBD>' ||
letter == 'Ï' ) return 'I'; letter == '<EFBFBD>' ) return 'I';
if ( letter == 'Ó' || if ( letter == '<EFBFBD>' ||
letter == 'Ò' || letter == '<EFBFBD>' ||
letter == 'Ô' || letter == '<EFBFBD>' ||
letter == 'Ö' || letter == '<EFBFBD>' ||
letter == 'Õ' ) return 'O'; letter == '<EFBFBD>' ) return 'O';
if ( letter == 'Ú' || if ( letter == '<EFBFBD>' ||
letter == 'Ù' || letter == '<EFBFBD>' ||
letter == 'Û' || letter == '<EFBFBD>' ||
letter == 'Ü' ) return 'U'; letter == '<EFBFBD>' ) return 'U';
if ( letter == 'Ç' ) return 'C'; if ( letter == '<EFBFBD>' ) return 'C';
if ( letter == 'Ñ' ) return 'N'; if ( letter == '<EFBFBD>' ) return 'N';
} }
return letter; return letter;
@ -130,40 +132,40 @@ char RetNoAccent(char letter)
// Returns an uppercase letter. // Returns an uppercase letter.
char RetToUpper(char letter) char GetToUpper(char letter)
{ {
if ( letter < 0 ) if ( letter < 0 )
{ {
if ( letter == 'á' ) return 'Á'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'à' ) return 'À'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'â' ) return 'Â'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ä' ) return 'Ä'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ã' ) return 'Ã'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'é' ) return 'É'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'è' ) return 'È'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ê' ) return 'Ê'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ë' ) return 'Ë'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'í' ) return 'Í'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ì' ) return 'Ì'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'î' ) return 'Î'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ï' ) return 'Ï'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ó' ) return 'Ó'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ò' ) return 'Ò'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ô' ) return 'Ô'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ö' ) return 'Ö'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'õ' ) return 'Õ'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ú' ) return 'Ú'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ù' ) return 'Ù'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'û' ) return 'Û'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ü' ) return 'Ü'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ç' ) return 'Ç'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'ñ' ) return 'Ñ'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
} }
return toupper(letter); return toupper(letter);
@ -171,40 +173,40 @@ char RetToUpper(char letter)
// Returns a lowercase letter. // Returns a lowercase letter.
char RetToLower(char letter) char GetToLower(char letter)
{ {
if ( letter < 0 ) if ( letter < 0 )
{ {
if ( letter == 'Á' ) return 'á'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'À' ) return 'à'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Â' ) return 'â'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ä' ) return 'ä'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ã' ) return 'ã'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'É' ) return 'é'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'È' ) return 'è'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ê' ) return 'ê'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ë' ) return 'ë'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Í' ) return 'í'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ì' ) return 'ì'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Î' ) return 'î'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ï' ) return 'ï'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ó' ) return 'ó'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ò' ) return 'ò'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ô' ) return 'ô'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ö' ) return 'ö'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Õ' ) return 'õ'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ú' ) return 'ú'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ù' ) return 'ù'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Û' ) return 'û'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ü' ) return 'ü'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ç' ) return 'ç'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
if ( letter == 'Ñ' ) return 'ñ'; if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
} }
return tolower(letter); return tolower(letter);
@ -213,7 +215,7 @@ char RetToLower(char letter)
// Converting time to string. // Converting time to string.
void TimeToAscii(time_t time, char *buffer) void GimeToAscii(time_t time, char *buffer)
{ {
struct tm when; struct tm when;
int year; int year;
@ -311,7 +313,7 @@ bool CopyFileToTemp(char* filename)
UserDir(dst, filename, "textures"); UserDir(dst, filename, "textures");
strcpy(g_userDir, save); strcpy(g_userDir, save);
_mkdir("temp"); // _mkdir("temp"); TODO
if ( !Xfer(src, dst) ) return false; if ( !Xfer(src, dst) ) return false;
strcpy(filename, dst); strcpy(filename, dst);
@ -379,7 +381,7 @@ void UserDir(bool bUser, char* dir)
// def = "abc\" // def = "abc\"
// out: buffer = "abc\toto.txt" // out: buffer = "abc\toto.txt"
void UserDir(char* buffer, char* dir, char* def) void UserDir(char* buffer, char* dir, const char* def)
{ {
char ddir[100]; char ddir[100];
char* add; char* add;

View File

@ -89,9 +89,9 @@ const int KS_NUMMINUS = (1<<15);
extern EventType GetUniqueEventType(); extern EventType GetUniqueEventType();
extern char RetNoAccent(char letter); extern char GetNoAccent(char letter);
extern char RetToUpper(char letter); extern char GetToUpper(char letter);
extern char RetToLower(char letter); extern char GetToLower(char letter);
extern void TimeToAscii(time_t time, char *buffer); extern void TimeToAscii(time_t time, char *buffer);
@ -99,8 +99,8 @@ extern bool CopyFileToTemp(char* filename);
extern bool CopyFileListToTemp(char* filename, int* list, int total); extern bool CopyFileListToTemp(char* filename, int* list, int total);
extern void AddExt(char* filename, char* ext); extern void AddExt(char* filename, char* ext);
extern void UserDir(bool bUser, char* dir); extern void UserDir(bool bUser, char* dir);
extern void UserDir(char* buffer, char* dir, char* def); extern void UserDir(char* buffer, char* dir, const char* def);
extern char RetLanguageLetter(); extern char GetLanguageLetter();

File diff suppressed because it is too large Load Diff

View File

@ -18,38 +18,143 @@
#pragma once #pragma once
#include "common/restext_ids.h" //#include "graphics/engine/engine.h"
#include "common/event.h"
namespace Gfx
{
class CEngine;
}
class CD3DEngine;
// Possible types of the text resources. // Possible types of the text resources.
enum ResType enum ResType
{ {
RES_TEXT = 0, // RT_* RES_TEXT = 0, // RT_*
RES_EVENT = 1, // EVENT_* (EventMsg) RES_EVENT = 1, // EVENT_* (EventType)
RES_OBJECT = 2, // OBJECT_* (ObjectType) RES_OBJECT = 2, // OBJECT_* (ObjectType)
RES_ERR = 3, // ERR_* (Error) RES_ERR = 3, // ERR_* (Error)
RES_KEY = 4, // VK_* (keys) RES_KEY = 4, // VK_* (keys)
RES_CBOT = 5, // TX_* (cbot.dll) RES_CBOT = 5, // TX_* (cbot.dll)
}; };
extern void SetEngine(CD3DEngine *engine); // Resources of type RES_TEXT.
enum ResTextType
{
RT_VERSION_ID = 1,
RT_DISINFO_TITLE = 2,
RT_WINDOW_MAXIMIZED = 3,
RT_WINDOW_MINIMIZED = 4,
RT_WINDOW_STANDARD = 5,
RT_WINDOW_CLOSE = 6,
RT_STUDIO_TITLE = 10,
RT_SCRIPT_NEW = 20,
RT_NAME_DEFAULT = 21,
RT_IO_NEW = 22,
RT_KEY_OR = 23,
RT_TITLE_BASE = 40,
RT_TITLE_INIT = 41,
RT_TITLE_TRAINER = 42,
RT_TITLE_DEFI = 43,
RT_TITLE_MISSION = 44,
RT_TITLE_FREE = 45,
RT_TITLE_PROTO = 46,
RT_TITLE_SETUP = 47,
RT_TITLE_NAME = 48,
RT_TITLE_PERSO = 49,
RT_TITLE_WRITE = 50,
RT_TITLE_READ = 51,
RT_TITLE_USER = 52,
RT_TITLE_TEEN = 53,
RT_PLAY_CHAPt = 60,
RT_PLAY_CHAPd = 61,
RT_PLAY_CHAPm = 62,
RT_PLAY_CHAPf = 63,
RT_PLAY_CHAPp = 64,
RT_PLAY_LISTt = 65,
RT_PLAY_LISTd = 66,
RT_PLAY_LISTm = 67,
RT_PLAY_LISTf = 68,
RT_PLAY_LISTp = 69,
RT_PLAY_RESUME = 70,
RT_PLAY_CHAPu = 71,
RT_PLAY_LISTu = 72,
RT_PLAY_CHAPte = 73,
RT_PLAY_LISTk = 74,
RT_SETUP_DEVICE = 80,
RT_SETUP_MODE = 81,
RT_SETUP_KEY1 = 82,
RT_SETUP_KEY2 = 83,
RT_PERSO_FACE = 90,
RT_PERSO_GLASSES = 91,
RT_PERSO_HAIR = 92,
RT_PERSO_COMBI = 93,
RT_PERSO_BAND = 94,
RT_DIALOG_TITLE = 100,
RT_DIALOG_ABORT = 101,
RT_DIALOG_QUIT = 102,
RT_DIALOG_YES = 103,
RT_DIALOG_NO = 104,
RT_DIALOG_DELOBJ = 105,
RT_DIALOG_DELGAME = 106,
RT_DIALOG_YESDEL = 107,
RT_DIALOG_NODEL = 108,
RT_DIALOG_LOADING = 109,
RT_DIALOG_YESQUIT = 110,
RT_DIALOG_NOQUIT = 111,
RT_STUDIO_LISTTT = 120,
RT_STUDIO_COMPOK = 121,
RT_STUDIO_PROGSTOP = 122,
RT_SATCOM_LIST = 140,
RT_SATCOM_BOT = 141,
RT_SATCOM_BUILDING = 142,
RT_SATCOM_FRET = 143,
RT_SATCOM_ALIEN = 144,
RT_SATCOM_NULL = 145,
RT_SATCOM_ERROR1 = 146,
RT_SATCOM_ERROR2 = 147,
RT_IO_OPEN = 150,
RT_IO_SAVE = 151,
RT_IO_LIST = 152,
RT_IO_NAME = 153,
RT_IO_DIR = 154,
RT_IO_PRIVATE = 155,
RT_IO_PUBLIC = 156,
RT_GENERIC_DEV1 = 170,
RT_GENERIC_DEV2 = 171,
RT_GENERIC_EDIT1 = 172,
RT_GENERIC_EDIT2 = 173,
RT_INTERFACE_REC = 180,
RT_MESSAGE_WIN = 200,
RT_MESSAGE_LOST = 201,
};
static Gfx::CEngine* g_engine = 0;
static char g_gamerName[100];
extern void SetEngine(Gfx::CEngine *engine);
extern void SetGlobalGamerName(char *name); extern void SetGlobalGamerName(char *name);
extern bool SearchKey(char *cmd, KeyRank &key); extern bool SearchKey(char *cmd, KeyRank &key);
extern void PutKeyName(char* dst, char* src);
extern bool GetResource(ResType type, int num, char* text); extern bool GetResource(ResType type, int num, char* text);
extern bool GetResourceBase(ResType type, int num, char* text);
extern const char * const strings_text[];
extern const char * const strings_event[];
extern const char * const strings_object[];
extern const char * const strings_err[];
extern const char * const strings_cbot[];
extern const int strings_text_len;
extern const int strings_event_len;
extern const int strings_object_len;
extern const int strings_err_len;
extern const int strings_cbot_len;

View File

@ -28,67 +28,6 @@
#include "object/object.h" #include "object/object.h"
#include "physics/physics.h" #include "physics/physics.h"
// TODO temporary stubs for CObject and CPhysics
void CObject::SetTransparency(float)
{
}
CObject* CObject::GetFret()
{
return nullptr;
}
CObject* CObject::GetPower()
{
return nullptr;
}
CObject* CObject::GetTruck()
{
return nullptr;
}
ObjectType CObject::GetType()
{
return OBJECT_NULL;
}
void CObject::SetGunGoalH(float)
{
}
void CObject::GetGlobalSphere(Math::Vector &pos, float &radius)
{
}
float CObject::GetAngleY(int)
{
return 0.0f;
}
Math::Vector CObject::GetPosition(int)
{
return Math::Vector();
}
void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
Math::Vector &lookat, Math::Vector &upVec,
Gfx::CameraType type)
{
}
CPhysics* CObject::GetPhysics()
{
return nullptr;
}
bool CPhysics::GetLand()
{
return false;
}
//! Changes the level of transparency of an object and objects transported (battery & cargo) //! Changes the level of transparency of an object and objects transported (battery & cargo)
void SetTransparency(CObject* obj, float value) void SetTransparency(CObject* obj, float value)
{ {

View File

@ -15,55 +15,55 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <stdio.h> // #include <stdio.h>
//
#include "object/brain.h" #include "object/brain.h"
//
#include "CBot/CBotDll.h" // #include "CBot/CBotDll.h"
#include "common/struct.h" // #include "common/struct.h"
#include "math/geometry.h" // #include "math/geometry.h"
#include "math/const.h" // #include "math/const.h"
#include "old/d3dengine.h" // #include "old/d3dengine.h"
#include "old/d3dmath.h" // #include "old/d3dmath.h"
#include "common/language.h" // #include "common/language.h"
#include "common/global.h" // #include "common/global.h"
#include "common/event.h" // #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
#include "common/restext.h" // #include "common/restext.h"
#include "old/math3d.h" // #include "old/math3d.h"
#include "object/robotmain.h" // #include "object/robotmain.h"
#include "old/terrain.h" // #include "old/terrain.h"
#include "old/water.h" // #include "old/water.h"
#include "old/camera.h" // #include "old/camera.h"
#include "object/object.h" // #include "object/object.h"
#include "physics/physics.h" // #include "physics/physics.h"
#include "object/motion/motion.h" // #include "object/motion/motion.h"
#include "object/motion/motionspider.h" // #include "object/motion/motionspider.h"
#include "old/pyro.h" // #include "old/pyro.h"
#include "object/task/taskmanager.h" #include "object/task/taskmanager.h"
#include "object/task/task.h" // #include "object/task/task.h"
#include "object/task/taskmanip.h" // #include "object/task/taskmanip.h"
#include "object/task/taskflag.h" // #include "object/task/taskflag.h"
#include "object/task/taskshield.h" // #include "object/task/taskshield.h"
#include "script/script.h" #include "script/script.h"
#include "ui/studio.h" // #include "ui/studio.h"
#include "ui/interface.h" // #include "ui/interface.h"
#include "ui/button.h" // #include "ui/button.h"
#include "ui/color.h" // #include "ui/color.h"
#include "ui/edit.h" // #include "ui/edit.h"
#include "ui/list.h" // #include "ui/list.h"
#include "ui/label.h" // #include "ui/label.h"
#include "ui/group.h" // #include "ui/group.h"
#include "ui/gauge.h" // #include "ui/gauge.h"
#include "ui/slider.h" #include "ui/slider.h"
#include "ui/compass.h" // #include "ui/compass.h"
#include "ui/target.h" // #include "ui/target.h"
#include "ui/window.h" #include "ui/window.h"
#include "ui/displaytext.h" // #include "ui/displaytext.h"
#include "old/text.h" // #include "old/text.h"
#include "old/sound.h" #include "sound/sound.h"
#include "old/particule.h" // #include "old/particule.h"
#include "script/cmdtoken.h" #include "script/cmdtoken.h"
@ -82,20 +82,21 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
m_iMan->AddInstance(CLASS_BRAIN, this, 100); m_iMan->AddInstance(CLASS_BRAIN, this, 100);
m_object = object; m_object = object;
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN); m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER); m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_displayText = (CDisplayText*)m_iMan->SearchInstance(CLASS_DISPLAYTEXT); m_displayText = static_cast<CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); m_particle = static_cast<CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
m_physics = 0; m_physics = 0;
m_motion = 0; m_motion = 0;
m_primaryTask = 0; m_primaryTask = 0;
m_secondaryTask = 0; m_secondaryTask = 0;
m_studio = 0; // TODO uncoment when ui/studio will be implemented.
// m_studio = 0;
m_program = -1; m_program = -1;
m_bActivity = true; m_bActivity = true;
@ -142,7 +143,8 @@ CBrain::~CBrain()
delete m_primaryTask; delete m_primaryTask;
delete m_secondaryTask; delete m_secondaryTask;
delete m_studio; // TODO uncoment when ui/studio will be implemented.
// delete m_studio;
delete m_traceRecordBuffer; delete m_traceRecordBuffer;
m_iMan->DeleteInstance(CLASS_BRAIN, this); m_iMan->DeleteInstance(CLASS_BRAIN, this);
} }
@ -169,7 +171,8 @@ void CBrain::DeleteObject(bool bAll)
} }
} }
if ( m_studio != 0 ) // current edition? // TODO uncoment when ui/studio will be implemented.
// if ( m_studio != 0 ) // current edition?
{ {
StopEditScript(true); StopEditScript(true);
} }
@ -213,13 +216,13 @@ bool CBrain::Read(char *line)
bool CBrain::EventProcess(const Event &event) bool CBrain::EventProcess(const Event &event)
{ {
CWindow* pw; Ui::CWindow* pw;
CControl* pc; Ui::CControl* pc;
CSlider* ps; Ui::CSlider* ps;
EventMsg action; Event action;
ObjectType type; ObjectType type;
Error err; Error err;
float axeX, axeY, axeZ, factor; float axeX, axeY, axeZ, factor;
type = m_object->RetType(); type = m_object->RetType();
@ -240,7 +243,7 @@ bool CBrain::EventProcess(const Event &event)
event.param == m_engine->RetKey(KEYRANK_ACTION, 1) ) && event.param == m_engine->RetKey(KEYRANK_ACTION, 1) ) &&
!m_main->RetEditLock() ) !m_main->RetEditLock() )
{ {
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw != 0 ) if ( pw != 0 )
{ {
pc = pw->SearchControl(m_defaultEnter); pc = pw->SearchControl(m_defaultEnter);
@ -270,10 +273,11 @@ bool CBrain::EventProcess(const Event &event)
EventFrame(event); EventFrame(event);
} }
// TODO uncoment when ui/studio will be implemented.
if ( m_object->RetSelect() && // robot selected? if ( m_object->RetSelect() && // robot selected?
m_studio != 0 ) // current issue? /* m_studio != 0 */ ) // current issue?
{ {
m_studio->EventProcess(event); // m_studio->EventProcess(event);
if ( action == EVENT_OBJECT_PROGRUN ) if ( action == EVENT_OBJECT_PROGRUN )
{ {
@ -591,10 +595,10 @@ bool CBrain::EventProcess(const Event &event)
if ( action == EVENT_OBJECT_DIMSHIELD ) if ( action == EVENT_OBJECT_DIMSHIELD )
{ {
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw != 0 ) if ( pw != 0 )
{ {
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_DIMSHIELD); ps = (Ui::CSlider*)pw->SearchControl(EVENT_OBJECT_DIMSHIELD);
if ( ps != 0 ) if ( ps != 0 )
{ {
m_object->SetParam((ps->RetVisibleValue()-(RADIUS_SHIELD_MIN/g_unit))/((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit)); m_object->SetParam((ps->RetVisibleValue()-(RADIUS_SHIELD_MIN/g_unit))/((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit));
@ -687,7 +691,7 @@ bool CBrain::EventProcess(const Event &event)
TraceRecordStart(); TraceRecordStart();
} }
UpdateInterface(); UpdateInterface();
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw != 0 ) if ( pw != 0 )
{ {
UpdateScript(pw); UpdateScript(pw);
@ -701,7 +705,7 @@ bool CBrain::EventProcess(const Event &event)
TraceRecordStop(); TraceRecordStop();
} }
UpdateInterface(); UpdateInterface();
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw != 0 ) if ( pw != 0 )
{ {
UpdateScript(pw); UpdateScript(pw);
@ -765,10 +769,11 @@ bool CBrain::EventFrame(const Event &event)
m_sound->Position(m_soundChannelAlarm, m_object->RetPosition(0)); m_sound->Position(m_soundChannelAlarm, m_object->RetPosition(0));
} }
if ( m_studio != 0 ) // <20>urrent edition? // TODO uncoment when ui/studio will be implemented.
{ // if ( m_studio != 0 ) // current edition?
m_studio->EventProcess(event); // {
} // m_studio->EventProcess(event);
// }
UpdateInterface(event.rTime); UpdateInterface(event.rTime);
@ -891,8 +896,9 @@ void CBrain::StartEditScript(int rank, char* name)
m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask); m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
} }
m_studio = new CStudio(m_iMan); // TODO uncoment when ui/studio will be implemented.
m_studio->StartEditScript(m_script[rank], name, rank); // m_studio = new CStudio(m_iMan);
// m_studio->StartEditScript(m_script[rank], name, rank);
} }
// End of editing a program. // End of editing a program.
@ -901,10 +907,11 @@ void CBrain::StopEditScript(bool bCancel)
{ {
if ( !bCancel ) SetActiveVirus(false); if ( !bCancel ) SetActiveVirus(false);
if ( !m_studio->StopEditScript(bCancel) ) return; // TODO uncoment when ui/studio will be implemented.
// if ( !m_studio->StopEditScript(bCancel) ) return;
delete m_studio; // delete m_studio;
m_studio = 0; // m_studio = 0;
CreateInterface(true); // puts the control buttons CreateInterface(true); // puts the control buttons
} }
@ -1209,7 +1216,7 @@ void CBrain::GroundFlat()
speed = Math::Vector(0.0f, 0.0f, 0.0f); speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 40.0f; dim.x = 40.0f;
dim.y = dim.x; dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGFLAT, 1.0f); m_particle->CreateParticle(pos, speed, dim, PARTIGFLAT, 1.0f);
} }
@ -1227,17 +1234,17 @@ void CBrain::ColorFlag(int color)
bool CBrain::CreateInterface(bool bSelect) bool CBrain::CreateInterface(bool bSelect)
{ {
ObjectType type; ObjectType type;
CWindow* pw; Ui::CWindow* pw;
CButton* pb; CButton* pb;
CColor* pc; CColor* pc;
CSlider* ps; Ui::CSlider* ps;
CTarget* pt; CTarget* pt;
CLabel* pl; CLabel* pl;
Math::Point pos, dim, ddim; Math::Point pos, dim, ddim;
float ox, oy, sx, sy; float ox, oy, sx, sy;
char name[100]; char name[100];
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw != 0 ) if ( pw != 0 )
{ {
pw->Flush(); // destroys the window buttons pw->Flush(); // destroys the window buttons
@ -1253,7 +1260,7 @@ bool CBrain::CreateInterface(bool bSelect)
if ( !m_main->RetShowMap() ) dim.x = 640.0f/640.0f; if ( !m_main->RetShowMap() ) dim.x = 640.0f/640.0f;
dim.y = 86.0f/480.0f; dim.y = 86.0f/480.0f;
m_interface->CreateWindows(pos, dim, 3, EVENT_WINDOW0); m_interface->CreateWindows(pos, dim, 3, EVENT_WINDOW0);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw == 0 ) return false; if ( pw == 0 ) return false;
m_object->GetTooltipName(name); m_object->GetTooltipName(name);
@ -1926,7 +1933,7 @@ bool CBrain::CreateInterface(bool bSelect)
void CBrain::UpdateInterface(float rTime) void CBrain::UpdateInterface(float rTime)
{ {
CWindow* pw; Ui::CWindow* pw;
#if _TEEN #if _TEEN
CButton* pb; CButton* pb;
#endif #endif
@ -1956,7 +1963,7 @@ void CBrain::UpdateInterface(float rTime)
return; return;
} }
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw == 0 ) return; if ( pw == 0 ) return;
pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY); pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY);
@ -2130,9 +2137,9 @@ void CBrain::UpdateInterface(float rTime)
void CBrain::UpdateInterface() void CBrain::UpdateInterface()
{ {
ObjectType type; ObjectType type;
CWindow* pw; Ui::CWindow* pw;
CButton* pb; CButton* pb;
CSlider* ps; Ui::CSlider* ps;
#if _TEEN #if _TEEN
CColor* pc; CColor* pc;
int color; int color;
@ -2142,7 +2149,7 @@ void CBrain::UpdateInterface()
if ( !m_object->RetSelect() ) return; if ( !m_object->RetSelect() ) return;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw == 0 ) return; if ( pw == 0 ) return;
type = m_object->RetType(); type = m_object->RetType();
@ -2235,7 +2242,7 @@ void CBrain::UpdateInterface()
DefaultEnter (pw, EVENT_OBJECT_ENDSHIELD, false); DefaultEnter (pw, EVENT_OBJECT_ENDSHIELD, false);
} }
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_DIMSHIELD); ps = (Ui::CSlider*)pw->SearchControl(EVENT_OBJECT_DIMSHIELD);
if ( ps != 0 ) if ( ps != 0 )
{ {
ps->SetVisibleValue((RADIUS_SHIELD_MIN/g_unit)+m_object->RetParam()*((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit)); ps->SetVisibleValue((RADIUS_SHIELD_MIN/g_unit)+m_object->RetParam()*((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit));
@ -2438,7 +2445,7 @@ void CBrain::UpdateInterface()
// Updates the list of programs. // Updates the list of programs.
void CBrain::UpdateScript(CWindow *pw) void CBrain::UpdateScript(Ui::CWindow *pw)
{ {
CList* pl; CList* pl;
char name[100]; char name[100];
@ -2488,10 +2495,10 @@ void CBrain::UpdateScript(CWindow *pw)
int CBrain::RetSelScript() int CBrain::RetSelScript()
{ {
CWindow* pw; Ui::CWindow* pw;
CList* pl; CList* pl;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw == 0 ) return -1; if ( pw == 0 ) return -1;
pl = (CList*)pw->SearchControl(EVENT_OBJECT_PROGLIST); pl = (CList*)pw->SearchControl(EVENT_OBJECT_PROGLIST);
@ -2504,12 +2511,12 @@ int CBrain::RetSelScript()
void CBrain::BlinkScript(bool bEnable) void CBrain::BlinkScript(bool bEnable)
{ {
CWindow* pw; Ui::CWindow* pw;
CList* pl; CList* pl;
if ( !m_object->RetSelect() ) return; // robot not selected? if ( !m_object->RetSelect() ) return; // robot not selected?
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); pw = (Ui::CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
if ( pw == 0 ) return; if ( pw == 0 ) return;
pl = (CList*)pw->SearchControl(EVENT_OBJECT_PROGLIST); pl = (CList*)pw->SearchControl(EVENT_OBJECT_PROGLIST);
@ -2520,9 +2527,9 @@ void CBrain::BlinkScript(bool bEnable)
// Check the status of a button interface. // Check the status of a button interface.
void CBrain::CheckInterface(CWindow *pw, EventMsg event, bool bState) void CBrain::CheckInterface(Ui::CWindow *pw, EventMsg event, bool bState)
{ {
CControl* control; Ui::CControl* control;
control = pw->SearchControl(event); control = pw->SearchControl(event);
if ( control == 0 ) return; if ( control == 0 ) return;
@ -2532,9 +2539,9 @@ void CBrain::CheckInterface(CWindow *pw, EventMsg event, bool bState)
// Changes the state of a button interface. // Changes the state of a button interface.
void CBrain::EnableInterface(CWindow *pw, EventMsg event, bool bState) void CBrain::EnableInterface(Ui::CWindow *pw, EventMsg event, bool bState)
{ {
CControl* control; Ui::CControl* control;
control = pw->SearchControl(event); control = pw->SearchControl(event);
if ( control == 0 ) return; if ( control == 0 ) return;
@ -2544,9 +2551,9 @@ void CBrain::EnableInterface(CWindow *pw, EventMsg event, bool bState)
// Changes the state of a button on the interface. // Changes the state of a button on the interface.
void CBrain::DeadInterface(CWindow *pw, EventMsg event, bool bState) void CBrain::DeadInterface(Ui::CWindow *pw, EventMsg event, bool bState)
{ {
CControl* control; Ui::CControl* control;
control = pw->SearchControl(event); control = pw->SearchControl(event);
if ( control == 0 ) return; if ( control == 0 ) return;
@ -2556,9 +2563,9 @@ void CBrain::DeadInterface(CWindow *pw, EventMsg event, bool bState)
// Change the default input state of a button interface. // Change the default input state of a button interface.
void CBrain::DefaultEnter(CWindow *pw, EventMsg event, bool bState) void CBrain::DefaultEnter(Ui::CWindow *pw, EventMsg event, bool bState)
{ {
CControl* control; Ui::CControl* control;
control = pw->SearchControl(event); control = pw->SearchControl(event);
if ( control == 0 ) return; if ( control == 0 ) return;
@ -2708,7 +2715,7 @@ bool CBrain::ReadSoluce(char* filename)
// Load a script with a text file. // Load a script with a text file.
bool CBrain::ReadProgram(int rank, char* filename) bool CBrain::ReadProgram(int rank, const char* filename)
{ {
if ( m_script[rank] == 0 ) if ( m_script[rank] == 0 )
{ {

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include <stdio.h> // #include <stdio.h>
#include "common/misc.h" #include "common/misc.h"
#include "common/event.h" #include "common/event.h"
@ -30,10 +30,6 @@
class CInstanceManager; class CInstanceManager;
class CD3DEngine;
class CTerrain;
class CWater;
class CCamera;
class CObject; class CObject;
class CPhysics; class CPhysics;
class CMotion; class CMotion;
@ -44,8 +40,18 @@ class CDisplayText;
class CScript; class CScript;
class CRobotMain; class CRobotMain;
class CStudio; class CStudio;
class CSound; class CSoundInterface;
class CParticule; class CParticle;
namespace Gfx
{
class CEngine;
class CTerrain;
class CWater;
class CCamera;
} /* Gfx */
const int BRAINMAXSCRIPT = 10; const int BRAINMAXSCRIPT = 10;
@ -88,29 +94,29 @@ public:
bool IsBusy(); bool IsBusy();
void SetActivity(bool bMode); void SetActivity(bool bMode);
bool RetActivity(); bool GetActivity();
bool IsProgram(); bool IsProgram();
bool ProgramExist(int rank); bool ProgramExist(int rank);
void RunProgram(int rank); void RunProgram(int rank);
int FreeProgram(); int FreeProgram();
int RetProgram(); int GetProgram();
void StopProgram(); void StopProgram();
void StopTask(); void StopTask();
bool IntroduceVirus(); bool IntroduceVirus();
void SetActiveVirus(bool bActive); void SetActiveVirus(bool bActive);
bool RetActiveVirus(); bool GetActiveVirus();
void SetScriptRun(int rank); void SetScriptRun(int rank);
int RetScriptRun(); int GetScriptRun();
void SetScriptName(int rank, char *name); void SetScriptName(int rank, char *name);
char* RetScriptName(int rank); char* GetScriptName(int rank);
void SetSoluceName(char *name); void SetSoluceName(char *name);
char* RetSoluceName(); char* GetSoluceName();
bool ReadSoluce(char* filename); bool ReadSoluce(char* filename);
bool ReadProgram(int rank, char* filename); bool ReadProgram(int rank, const char* filename);
bool RetCompile(int rank); bool GetCompile(int rank);
bool WriteProgram(int rank, char* filename); bool WriteProgram(int rank, char* filename);
bool ReadStack(FILE *file); bool ReadStack(FILE *file);
bool WriteStack(FILE *file); bool WriteStack(FILE *file);
@ -144,13 +150,13 @@ protected:
void ColorFlag(int color); void ColorFlag(int color);
void UpdateScript(CWindow *pw); void UpdateScript(CWindow *pw);
int RetSelScript(); int GetSelScript();
void BlinkScript(bool bEnable); void BlinkScript(bool bEnable);
void CheckInterface(CWindow *pw, EventMsg event, bool bState); void CheckInterface(CWindow *pw, EventType event, bool bState);
void EnableInterface(CWindow *pw, EventMsg event, bool bState); void EnableInterface(CWindow *pw, EventType event, bool bState);
void DeadInterface(CWindow *pw, EventMsg event, bool bState); void DeadInterface(CWindow *pw, EventType event, bool bState);
void DefaultEnter(CWindow *pw, EventMsg event, bool bState=true); void DefaultEnter(CWindow *pw, EventType event, bool bState=true);
void TraceRecordStart(); void TraceRecordStart();
void TraceRecordFrame(); void TraceRecordFrame();
@ -159,60 +165,60 @@ protected:
bool TraceRecordPut(char *buffer, int max, TraceOper oper, float param); bool TraceRecordPut(char *buffer, int max, TraceOper oper, float param);
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CD3DEngine* m_engine; Gfx::CEngine* m_engine;
CTerrain* m_terrain; Gfx::CTerrain* m_terrain;
CWater* m_water; Gfx::CWater* m_water;
CCamera* m_camera; Gfx::CCamera* m_camera;
CObject* m_object; CObject* m_object;
CPhysics* m_physics; CPhysics* m_physics;
CMotion* m_motion; CMotion* m_motion;
CInterface* m_interface; CInterface* m_interface;
CDisplayText* m_displayText; CDisplayText* m_displayText;
CRobotMain* m_main; CRobotMain* m_main;
CStudio* m_studio; CStudio* m_studio;
CSound* m_sound; CSoundInterface* m_sound;
CParticule* m_particule; CParticle* m_particle;
CTaskManager* m_primaryTask; CTaskManager* m_primaryTask;
CTaskManager* m_secondaryTask; CTaskManager* m_secondaryTask;
CScript* m_script[BRAINMAXSCRIPT]; CScript* m_script[BRAINMAXSCRIPT];
int m_selScript; // rank of the selected script int m_selScript; // rank of the selected script
int m_program; // rank of the executed program / -1 int m_program; // rank of the executed program / -1
bool m_bActivity; bool m_bActivity;
bool m_bBurn; bool m_bBurn;
bool m_bActiveVirus; bool m_bActiveVirus;
int m_scriptRun; int m_scriptRun;
char m_scriptName[BRAINMAXSCRIPT][50]; char m_scriptName[BRAINMAXSCRIPT][50];
char m_soluceName[50]; char m_soluceName[50];
EventMsg m_buttonAxe; EventType m_buttonAxe;
EventMsg m_manipStyle; EventType m_manipStyle;
EventMsg m_defaultEnter; EventType m_defaultEnter;
EventMsg m_interfaceEvent[100]; EventType m_interfaceEvent[100];
CObject* m_antTarget; CObject* m_antTarget;
CObject* m_beeBullet; CObject* m_beeBullet;
float m_beeBulletSpeed; float m_beeBulletSpeed;
Math::Vector m_startPos; Math::Vector m_startPos;
float m_time; float m_time;
float m_burnTime; float m_burnTime;
float m_lastUpdateTime; float m_lastUpdateTime;
float m_lastHumanTime; float m_lastHumanTime;
float m_lastSpiderTime; float m_lastSpiderTime;
float m_lastWormTime; float m_lastWormTime;
float m_lastBulletTime; float m_lastBulletTime;
float m_lastAlarmTime; float m_lastAlarmTime;
int m_soundChannelAlarm; int m_soundChannelAlarm;
int m_flagColor; int m_flagColor;
bool m_bTraceRecord; bool m_bTraceRecord;
TraceOper m_traceOper; TraceOper m_traceOper;
Math::Vector m_tracePos; Math::Vector m_tracePos;
float m_traceAngle; float m_traceAngle;
int m_traceColor; int m_traceColor;
int m_traceRecordIndex; int m_traceRecordIndex;
TraceRecord* m_traceRecordBuffer; TraceRecord* m_traceRecordBuffer;
}; };

View File

@ -25,13 +25,15 @@
class CInstanceManager; class CInstanceManager;
class CEvent; class CEvent;
class CD3DEngine;
class CInterface; class CInterface;
class CRobotMain; class CRobotMain;
class CCamera; class CCamera;
class CSound; class CSoundInterface;
namespace Gfx
{
class CEngine;
} /* Gfx */
enum MainMovieType enum MainMovieType
@ -61,17 +63,17 @@ protected:
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CEvent* m_event; CEvent* m_event;
CD3DEngine* m_engine; Gfx::CEngine* m_engine;
CInterface* m_interface; CInterface* m_interface;
CRobotMain* m_main; CRobotMain* m_main;
CCamera* m_camera; CCamera* m_camera;
CSound* m_sound; CSoundInterface* m_sound;
MainMovieType m_type; MainMovieType m_type;
MainMovieType m_stopType; MainMovieType m_stopType;
float m_speed; float m_speed;
float m_progress; float m_progress;
Math::Vector m_initialEye; Math::Vector m_initialEye;
Math::Vector m_initialLookat; Math::Vector m_initialLookat;
Math::Vector m_finalEye[2]; Math::Vector m_finalEye[2];

View File

@ -95,16 +95,16 @@ bool CMotion::EventProcess(const Event &event)
Math::Vector pos, dir; Math::Vector pos, dir;
float time; float time;
if ( m_object->RetType() != OBJECT_TOTO && if ( m_object->GetType() != OBJECT_TOTO &&
m_engine->RetPause() ) return true; m_engine->GetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true; if ( event.event != EVENT_FRAME ) return true;
m_progress += event.rTime*m_actionTime; m_progress += event.rTime*m_actionTime;
if ( m_progress > 1.0f ) m_progress = 1.0f; // (*) if ( m_progress > 1.0f ) m_progress = 1.0f; // (*)
pos = m_object->RetPosition(0); pos = m_object->GetPosition(0);
if ( pos.y < m_water->RetLevel(m_object) ) // underwater? if ( pos.y < m_water->GetLevel(m_object) ) // underwater?
{ {
time = event.rTime*3.0f; // everything is slower time = event.rTime*3.0f; // everything is slower
} }
@ -113,19 +113,19 @@ bool CMotion::EventProcess(const Event &event)
time = event.rTime*10.0f; time = event.rTime*10.0f;
} }
dir = m_object->RetLinVibration(); dir = m_object->GetLinVibration();
dir.x = Math::Smooth(dir.x, m_linVibration.x, time); dir.x = Math::Smooth(dir.x, m_linVibration.x, time);
dir.y = Math::Smooth(dir.y, m_linVibration.y, time); dir.y = Math::Smooth(dir.y, m_linVibration.y, time);
dir.z = Math::Smooth(dir.z, m_linVibration.z, time); dir.z = Math::Smooth(dir.z, m_linVibration.z, time);
m_object->SetLinVibration(dir); m_object->SetLinVibration(dir);
dir = m_object->RetCirVibration(); dir = m_object->GetCirVibration();
dir.x = Math::Smooth(dir.x, m_cirVibration.x, time); dir.x = Math::Smooth(dir.x, m_cirVibration.x, time);
dir.y = Math::Smooth(dir.y, m_cirVibration.y, time); dir.y = Math::Smooth(dir.y, m_cirVibration.y, time);
dir.z = Math::Smooth(dir.z, m_cirVibration.z, time); dir.z = Math::Smooth(dir.z, m_cirVibration.z, time);
m_object->SetCirVibration(dir); m_object->SetCirVibration(dir);
dir = m_object->RetInclinaison(); dir = m_object->GetInclinaison();
dir.x = Math::Smooth(dir.x, m_inclinaison.x, time); dir.x = Math::Smooth(dir.x, m_inclinaison.x, time);
dir.y = Math::Smooth(dir.y, m_inclinaison.y, time); dir.y = Math::Smooth(dir.y, m_inclinaison.y, time);
dir.z = Math::Smooth(dir.z, m_inclinaison.z, time); dir.z = Math::Smooth(dir.z, m_inclinaison.z, time);
@ -148,9 +148,9 @@ Error CMotion::SetAction(int action, float time)
return ERR_OK; return ERR_OK;
} }
// Returns the current action. // Geturns the current action.
int CMotion::RetAction() int CMotion::GetAction()
{ {
return m_actionType; return m_actionType;
} }
@ -163,7 +163,7 @@ bool CMotion::SetParam(int rank, float value)
return false; return false;
} }
float CMotion::RetParam(int rank) float CMotion::GetParam(int rank)
{ {
return 0.0f; return 0.0f;
} }
@ -208,7 +208,7 @@ void CMotion::SetLinVibration(Math::Vector dir)
m_linVibration = dir; m_linVibration = dir;
} }
Math::Vector CMotion::RetLinVibration() Math::Vector CMotion::GetLinVibration()
{ {
return m_linVibration; return m_linVibration;
} }
@ -220,7 +220,7 @@ void CMotion::SetCirVibration(Math::Vector dir)
m_cirVibration = dir; m_cirVibration = dir;
} }
Math::Vector CMotion::RetCirVibration() Math::Vector CMotion::GetCirVibration()
{ {
return m_cirVibration; return m_cirVibration;
} }
@ -232,7 +232,7 @@ void CMotion::SetInclinaison(Math::Vector dir)
m_inclinaison = dir; m_inclinaison = dir;
} }
Math::Vector CMotion::RetInclinaison() Math::Vector CMotion::GetInclinaison()
{ {
return m_inclinaison; return m_inclinaison;
} }

View File

@ -51,20 +51,20 @@ public:
virtual bool Create(Math::Vector pos, float angle, ObjectType type, float power); virtual bool Create(Math::Vector pos, float angle, ObjectType type, float power);
virtual bool EventProcess(const Event &event); virtual bool EventProcess(const Event &event);
virtual Error SetAction(int action, float time=0.2f); virtual Error SetAction(int action, float time=0.2f);
virtual int RetAction(); virtual int GetAction();
virtual bool SetParam(int rank, float value); virtual bool SetParam(int rank, float value);
virtual float RetParam(int rank); virtual float GetParam(int rank);
virtual bool Write(char *line); virtual bool Write(char *line);
virtual bool Read(char *line); virtual bool Read(char *line);
virtual void SetLinVibration(Math::Vector dir); virtual void SetLinVibration(Math::Vector dir);
virtual Math::Vector RetLinVibration(); virtual Math::Vector GetLinVibration();
virtual void SetCirVibration(Math::Vector dir); virtual void SetCirVibration(Math::Vector dir);
virtual Math::Vector RetCirVibration(); virtual Math::Vector GetCirVibration();
virtual void SetInclinaison(Math::Vector dir); virtual void SetInclinaison(Math::Vector dir);
virtual Math::Vector RetInclinaison(); virtual Math::Vector GetInclinaison();
protected: protected:

View File

@ -33,11 +33,11 @@ public:
bool Create(Math::Vector pos, float angle, ObjectType type, float power); bool Create(Math::Vector pos, float angle, ObjectType type, float power);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
bool RetTraceDown(); bool GetTraceDown();
void SetTraceDown(bool bDown); void SetTraceDown(bool bDown);
int RetTraceColor(); int GetTraceColor();
void SetTraceColor(int color); void SetTraceColor(int color);
float RetTraceWidth(); float GetTraceWidth();
void SetTraceWidth(float width); void SetTraceWidth(float width);
protected: protected:

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,10 @@ class CRobotMain;
class CBotVar; class CBotVar;
class CScript; class CScript;
namespace Ui
{
class CDisplayText;
}
// The father of all parts must always be the part number zero! // The father of all parts must always be the part number zero!
@ -46,69 +49,70 @@ const int OBJECTMAXDESELLIST = 10;
const int OBJECTMAXINFO = 10; const int OBJECTMAXINFO = 10;
const int OBJECTMAXCMDLINE = 20; const int OBJECTMAXCMDLINE = 20;
enum ObjectMaterial enum ObjectMaterial
{ {
OM_METAL = 0, // metal OM_METAL = 0, // metal
OM_PLASTIC = 1, // plastic OM_PLASTIC = 1, // plastic
OM_HUMAN = 2, // cosmonaut OM_HUMAN = 2, // cosmonaut
OM_ANIMAL = 3, // insect OM_ANIMAL = 3, // insect
OM_VEGETAL = 4, // plant OM_VEGETAL = 4, // plant
OM_MINERAL = 5, // stone OM_MINERAL = 5, // stone
}; };
struct ObjectPart struct ObjectPart
{ {
char bUsed; char bUsed;
int object; // number of the object in CEngine int object; // number of the object in CEngine
int parentPart; // number of father part int parentPart; // number of father part
int masterParti; // master canal of the particle int masterParti; // master canal of the particle
Math::Vector position; Math::Vector position;
Math::Vector angle; Math::Vector angle;
Math::Vector zoom; Math::Vector zoom;
char bTranslate; char bTranslate;
char bRotate; char bRotate;
char bZoom; char bZoom;
Math::Matrix matTranslate; Math::Matrix matTranslate;
Math::Matrix matRotate; Math::Matrix matRotate;
Math::Matrix matTransform; Math::Matrix matTransform;
Math::Matrix matWorld; Math::Matrix matWorld;
}; };
struct Character struct Character
{ {
float wheelFront; // position X of the front wheels float wheelFront; // position X of the front wheels
float wheelBack; // position X of the back wheels float wheelBack; // position X of the back wheels
float wheelLeft; // position Z of the left wheels float wheelLeft; // position Z of the left wheels
float wheelRight; // position Z of the right wheels float wheelRight; // position Z of the right wheels
float height; // normal height on top of ground float height; // normal height on top of ground
Math::Vector posPower; // position of the battery Math::Vector posPower; // position of the battery
}; };
struct Info struct Info
{ {
char name[20]; // name of the information char name[20]; // name of the information
float value; // value of the information float value; // value of the information
}; };
enum ExploType enum ExploType
{ {
EXPLO_BOUM = 1, EXPLO_BOUM = 1,
EXPLO_BURN = 2, EXPLO_BURN = 2,
EXPLO_WATER = 3, EXPLO_WATER = 3,
}; };
enum ResetCap enum ResetCap
{ {
RESET_NONE = 0, RESET_NONE = 0,
RESET_MOVE = 1, RESET_MOVE = 1,
RESET_DELETE = 2, RESET_DELETE = 2,
}; };
enum RadarFilter enum RadarFilter
{ {
FILTER_NONE = 0, FILTER_NONE = 0,
FILTER_ONLYLANDING = 1, FILTER_ONLYLANDING = 1,
FILTER_ONLYFLYING = 2, FILTER_ONLYFLYING = 2,
}; };
@ -162,7 +166,7 @@ public:
bool CreateRuin(Math::Vector pos, float angle, float height, ObjectType type); bool CreateRuin(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateApollo(Math::Vector pos, float angle, ObjectType type); bool CreateApollo(Math::Vector pos, float angle, ObjectType type);
bool ReadProgram(int rank, char* filename); bool ReadProgram(int rank, const char* filename);
bool WriteProgram(int rank, char* filename); bool WriteProgram(int rank, char* filename);
bool RunProgram(int rank); bool RunProgram(int rank);
@ -235,8 +239,8 @@ public:
void SetResetRun(int run); void SetResetRun(int run);
int GetResetRun(); int GetResetRun();
void SetMasterParticule(int part, int parti); void SetMasterParticle(int part, int parti);
int GetMasterParticule(int part); int GetMasterParticle(int part);
void SetPower(CObject* power); void SetPower(CObject* power);
CObject* GetPower(); CObject* GetPower();
@ -252,8 +256,8 @@ public:
void SetInfo(int rank, Info info); void SetInfo(int rank, Info info);
Info GetInfo(int rank); Info GetInfo(int rank);
int GetInfoTotal(); int GetInfoTotal();
void SetInfoGeturn(float value); void SetInfoReturn(float value);
float GetInfoGeturn(); float GetInfoReturn();
void SetInfoUpdate(bool bUpdate); void SetInfoUpdate(bool bUpdate);
bool GetInfoUpdate(); bool GetInfoUpdate();
@ -370,7 +374,7 @@ public:
void StopShowLimit(); void StopShowLimit();
bool IsProgram(); bool IsProgram();
void CreateSelectParticule(); void CreateSelectParticle();
void SetRunScript(CScript* script); void SetRunScript(CScript* script);
CScript* GetRunScript(); CScript* GetRunScript();
@ -414,25 +418,25 @@ protected:
void UpdateEnergyMapping(); void UpdateEnergyMapping();
bool UpdateTransformObject(int part, bool bForceUpdate); bool UpdateTransformObject(int part, bool bForceUpdate);
bool UpdateTransformObject(); bool UpdateTransformObject();
void UpdateSelectParticule(); void UpdateSelectParticle();
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
Gfx::CEngine* m_engine; Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan; Gfx::CLightManager* m_lightMan;
Gfx::CTerrain* m_terrain; Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water; Gfx::CWater* m_water;
Gfx::CCamera* m_camera; Gfx::CCamera* m_camera;
Gfx::CParticle* m_particle; Gfx::CParticle* m_particle;
CPhysics* m_physics; CPhysics* m_physics;
CBrain* m_brain; CBrain* m_brain;
CMotion* m_motion; CMotion* m_motion;
CAuto* m_auto; CAuto* m_auto;
CDisplayText* m_displayText; Ui::CDisplayText* m_displayText;
CRobotMain* m_main; CRobotMain* m_main;
CSoundInterface* m_sound; CSoundInterface* m_sound;
CBotVar* m_botVar; CBotVar* m_botVar;
CScript* m_runScript; CScript* m_runScript;
ObjectType m_type; // OBJECT_* ObjectType m_type; // OBJECT_*
int m_id; // unique identifier int m_id; // unique identifier
@ -462,8 +466,8 @@ protected:
float m_shotTime; // time since last shot float m_shotTime; // time since last shot
bool m_bVirusMode; // virus activated/triggered bool m_bVirusMode; // virus activated/triggered
float m_virusTime; // lifetime of the virus float m_virusTime; // lifetime of the virus
float m_lastVirusParticule; float m_lastVirusParticle;
float m_lastParticule; float m_lastParticle;
bool m_bHilite; bool m_bHilite;
bool m_bSelect; // object selected bool m_bSelect; // object selected
bool m_bSelectable; // selectable object bool m_bSelectable; // selectable object
@ -522,7 +526,7 @@ protected:
int m_infoTotal; int m_infoTotal;
Info m_info[OBJECTMAXINFO]; Info m_info[OBJECTMAXINFO];
float m_infoGeturn; float m_infoReturn;
bool m_bInfoUpdate; bool m_bInfoUpdate;
float m_cmdLine[OBJECTMAXCMDLINE]; float m_cmdLine[OBJECTMAXCMDLINE];

View File

@ -615,7 +615,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT); m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); m_particle = (CParticle*)m_iMan->SearchInstance(CLASS_PARTICULE);
m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER); m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
m_cloud = (CCloud*)m_iMan->SearchInstance(CLASS_CLOUD); m_cloud = (CCloud*)m_iMan->SearchInstance(CLASS_CLOUD);
m_blitz = (CBlitz*)m_iMan->SearchInstance(CLASS_BLITZ); m_blitz = (CBlitz*)m_iMan->SearchInstance(CLASS_BLITZ);
@ -740,7 +740,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
for ( i=0 ; i<OBJECT_MAX ; i++ ) for ( i=0 ; i<OBJECT_MAX ; i++ )
{ {
type = (ObjectType)i; type = (ObjectType)i;
token = RetObjectName(type); token = GetObjectName(type);
if ( token[0] != 0 ) if ( token[0] != 0 )
{ {
CBotProgram::DefineNum(token, type); CBotProgram::DefineNum(token, type);
@ -913,7 +913,7 @@ void CRobotMain::ChangePhase(Phase phase)
m_terrain->FlushBuildingLevel(); m_terrain->FlushBuildingLevel();
m_terrain->FlushFlyingLimit(); m_terrain->FlushFlyingLimit();
m_light->FlushLight(); m_light->FlushLight();
m_particule->FlushParticule(); m_particle->FlushParticule();
m_water->Flush(); m_water->Flush();
m_cloud->Flush(); m_cloud->Flush();
m_blitz->Flush(); m_blitz->Flush();
@ -1323,7 +1323,7 @@ bool CRobotMain::EventProcess(const Event &event)
HiliteClear(); HiliteClear();
if ( event.param == VK_F11 ) if ( event.param == VK_F11 )
{ {
m_particule->WriteWheelTrace("Savegame\\t.bmp", 256, 256, Math::Vector(16.0f, 0.0f, -368.0f), Math::Vector(140.0f, 0.0f, -248.0f)); m_particle->WriteWheelTrace("Savegame\\t.bmp", 256, 256, Math::Vector(16.0f, 0.0f, -368.0f), Math::Vector(140.0f, 0.0f, -248.0f));
return false; return false;
} }
if ( m_bEditLock ) // current edition? if ( m_bEditLock ) // current edition?
@ -2374,7 +2374,7 @@ void CRobotMain::StartDisplayVisit(EventMsg event)
m_visitTime = 0.0; m_visitTime = 0.0;
m_visitParticule = 0.0f; m_visitParticule = 0.0f;
m_particule->DeleteParticule(PARTISHOW); m_particle->DeleteParticule(PARTISHOW);
m_camera->StartVisit(m_displayText->RetVisitGoal(event), m_camera->StartVisit(m_displayText->RetVisitGoal(event),
m_displayText->RetVisitDist(event)); m_displayText->RetVisitDist(event));
@ -2412,7 +2412,7 @@ void CRobotMain::FrameVisit(float rTime)
speed = Math::Vector(0.0f, 0.0f, 0.0f); speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 30.0f; dim.x = 30.0f;
dim.y = dim.x; dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISHOW, 2.0f); m_particle->CreateParticle(pos, speed, dim, PARTISHOW, 2.0f);
} }
} }
@ -2434,7 +2434,7 @@ void CRobotMain::StopDisplayVisit()
} }
// Removes particles "arrows". // Removes particles "arrows".
m_particule->DeleteParticule(PARTISHOW); m_particle->DeleteParticule(PARTISHOW);
m_camera->StopVisit(); m_camera->StopVisit();
m_displayText->ClearVisit(); m_displayText->ClearVisit();
@ -3517,7 +3517,7 @@ bool CRobotMain::EventFrame(const Event &event)
if ( m_engine->RetFog() ) if ( m_engine->RetFog() )
{ {
m_camera->SetOverBaseColor(m_particule->RetFogColor(m_engine->RetEyePt())); m_camera->SetOverBaseColor(m_particle->RetFogColor(m_engine->RetEyePt()));
} }
} }
if ( m_phase == PHASE_PERSO || if ( m_phase == PHASE_PERSO ||
@ -3932,7 +3932,7 @@ void CRobotMain::ScenePerso()
m_terrain->FlushBuildingLevel(); m_terrain->FlushBuildingLevel();
m_terrain->FlushFlyingLimit(); m_terrain->FlushFlyingLimit();
m_light->FlushLight(); m_light->FlushLight();
m_particule->FlushParticule(); m_particle->FlushParticule();
m_iMan->Flush(CLASS_OBJECT); m_iMan->Flush(CLASS_OBJECT);
m_iMan->Flush(CLASS_PHYSICS); m_iMan->Flush(CLASS_PHYSICS);
m_iMan->Flush(CLASS_BRAIN); m_iMan->Flush(CLASS_BRAIN);
@ -4615,7 +4615,7 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
pos.y += height; pos.y += height;
dim.x = ddim; dim.x = ddim;
dim.y = dim.x; dim.y = dim.x;
m_particule->CreateParticule(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f); m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f);
} }
if ( Cmd(line, "CreateLight") && !bResetObject ) if ( Cmd(line, "CreateLight") && !bResetObject )
@ -5767,7 +5767,7 @@ void CRobotMain::FlushShowLimit(int i)
{ {
if ( m_showLimit[i].parti[j] == 0 ) continue; if ( m_showLimit[i].parti[j] == 0 ) continue;
m_particule->DeleteParticule(m_showLimit[i].parti[j]); m_particle->DeleteParticule(m_showLimit[i].parti[j]);
m_showLimit[i].parti[j] = 0; m_showLimit[i].parti[j] = 0;
} }
@ -5811,7 +5811,7 @@ void CRobotMain::SetShowLimit(int i, ParticuleType parti, CObject *pObj,
for ( j=0 ; j<m_showLimit[i].total ; j++ ) for ( j=0 ; j<m_showLimit[i].total ; j++ )
{ {
m_showLimit[i].parti[j] = m_particule->CreateParticule(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, parti, duration); m_showLimit[i].parti[j] = m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, parti, duration);
} }
} }
@ -5890,8 +5890,8 @@ void CRobotMain::FrameShowLimit(float rTime)
m_terrain->MoveOnFloor(pos, true); m_terrain->MoveOnFloor(pos, true);
if ( m_showLimit[i].radius <= 50.0f ) pos.y += 0.5f; if ( m_showLimit[i].radius <= 50.0f ) pos.y += 0.5f;
else pos.y += 2.0f; else pos.y += 2.0f;
m_particule->SetPosition(m_showLimit[i].parti[j], pos); m_particle->SetPosition(m_showLimit[i].parti[j], pos);
//? m_particule->SetAngle(m_showLimit[i].parti[j], angle-Math::PI/2.0f); //? m_particle->SetAngle(m_showLimit[i].parti[j], angle-Math::PI/2.0f);
angle += (2.0f*Math::PI)/m_showLimit[i].total; angle += (2.0f*Math::PI)/m_showLimit[i].total;
} }
@ -6787,10 +6787,10 @@ void CRobotMain::ResetObject()
} }
// Removes all bullets in progress. // Removes all bullets in progress.
m_particule->DeleteParticule(PARTIGUN1); m_particle->DeleteParticule(PARTIGUN1);
m_particule->DeleteParticule(PARTIGUN2); m_particle->DeleteParticule(PARTIGUN2);
m_particule->DeleteParticule(PARTIGUN3); m_particle->DeleteParticule(PARTIGUN3);
m_particule->DeleteParticule(PARTIGUN4); m_particle->DeleteParticule(PARTIGUN4);
for ( i=0 ; i<1000000 ; i++ ) for ( i=0 ; i<1000000 ; i++ )
{ {
@ -6869,15 +6869,15 @@ void CRobotMain::ResetCreate()
SaveAllScript(); SaveAllScript();
// Removes all bullets in progress. // Removes all bullets in progress.
m_particule->DeleteParticule(PARTIGUN1); m_particle->DeleteParticule(PARTIGUN1);
m_particule->DeleteParticule(PARTIGUN2); m_particle->DeleteParticule(PARTIGUN2);
m_particule->DeleteParticule(PARTIGUN3); m_particle->DeleteParticule(PARTIGUN3);
m_particule->DeleteParticule(PARTIGUN4); m_particle->DeleteParticule(PARTIGUN4);
DeselectAll(); // removes the control buttons DeselectAll(); // removes the control buttons
DeleteAllObjects(); // removes all the current 3D Scene DeleteAllObjects(); // removes all the current 3D Scene
m_particule->FlushParticule(); m_particle->FlushParticule();
m_terrain->FlushBuildingLevel(); m_terrain->FlushBuildingLevel();
m_iMan->Flush(CLASS_OBJECT); m_iMan->Flush(CLASS_OBJECT);
m_iMan->Flush(CLASS_PHYSICS); m_iMan->Flush(CLASS_PHYSICS);
@ -7028,7 +7028,7 @@ Error CRobotMain::CheckEndMission(bool bFrame)
// Checks if the mission is finished after displaying a message. // Checks if the mission is finished after displaying a message.
void CRobotMain::CheckEndMessage(char *message) void CRobotMain::CheckEndMessage(const char *message)
{ {
int t; int t;
@ -7062,7 +7062,7 @@ char* CRobotMain::RetObligatoryToken(int i)
// Checks if an instruction is part of the obligatory list. // Checks if an instruction is part of the obligatory list.
int CRobotMain::IsObligatoryToken(char *token) int CRobotMain::IsObligatoryToken(const char *token)
{ {
int i; int i;
@ -7078,7 +7078,7 @@ int CRobotMain::IsObligatoryToken(char *token)
// Checks if an instruction is not part of the banned list. // Checks if an instruction is not part of the banned list.
bool CRobotMain::IsProhibitedToken(char *token) bool CRobotMain::IsProhibitedToken(const char *token)
{ {
int i; int i;

View File

@ -22,12 +22,11 @@
#include <stdio.h> #include <stdio.h>
#include "common/misc.h" #include "common/misc.h"
#include "old/d3dengine.h" #include "graphics/engine/engine.h"
#include "object/object.h" #include "object/object.h"
#include "object/mainmovie.h" #include "object/mainmovie.h"
#include "old/camera.h" #include "graphics/engine/camera.h"
#include "old/particule.h" #include "graphics/engine/particle.h"
enum Phase enum Phase
{ {
@ -86,7 +85,7 @@ class CWindow;
class CControl; class CControl;
class CDisplayText; class CDisplayText;
class CDisplayInfo; class CDisplayInfo;
class CSound; class CSoundInterface;
struct EndTake struct EndTake
@ -154,25 +153,25 @@ public:
void ScenePerso(); void ScenePerso();
void SetMovieLock(bool bLock); void SetMovieLock(bool bLock);
bool RetMovieLock(); bool GetMovieLock();
bool RetInfoLock(); bool GetInfoLock();
void SetSatComLock(bool bLock); void SetSatComLock(bool bLock);
bool RetSatComLock(); bool GetSatComLock();
void SetEditLock(bool bLock, bool bEdit); void SetEditLock(bool bLock, bool bEdit);
bool RetEditLock(); bool GetEditLock();
void SetEditFull(bool bFull); void SetEditFull(bool bFull);
bool RetEditFull(); bool GetEditFull();
bool RetFreePhoto(); bool GetFreePhoto();
void SetFriendAim(bool bFriend); void SetFriendAim(bool bFriend);
bool RetFriendAim(); bool GetFriendAim();
void SetTracePrecision(float factor); void SetTracePrecision(float factor);
float RetTracePrecision(); float GetTracePrecision();
void ChangePause(bool bPause); void ChangePause(bool bPause);
void SetSpeed(float speed); void SetSpeed(float speed);
float RetSpeed(); float GetSpeed();
void UpdateShortcuts(); void UpdateShortcuts();
void SelectHuman(); void SelectHuman();
@ -180,75 +179,75 @@ public:
CObject* SearchToto(); CObject* SearchToto();
CObject* SearchNearest(Math::Vector pos, CObject* pExclu); CObject* SearchNearest(Math::Vector pos, CObject* pExclu);
bool SelectObject(CObject* pObj, bool bDisplayError=true); bool SelectObject(CObject* pObj, bool bDisplayError=true);
CObject* RetSelectObject(); CObject* GetSelectObject();
CObject* DeselectAll(); CObject* DeselectAll();
bool DeleteObject(); bool DeleteObject();
void ResetObject(); void ResetObject();
void ResetCreate(); void ResetCreate();
Error CheckEndMission(bool bFrame); Error CheckEndMission(bool bFrame);
void CheckEndMessage(char *message); void CheckEndMessage(const char *message);
int RetObligatoryToken(); int GetObligatoryToken();
char* RetObligatoryToken(int i); char* GetObligatoryToken(int i);
int IsObligatoryToken(char *token); int IsObligatoryToken(const char *token);
bool IsProhibitedToken(char *token); bool IsProhibitedToken(const char *token);
void UpdateMap(); void UpdateMap();
bool RetShowMap(); bool GetShowMap();
MainMovieType RetMainMovie(); MainMovieType GetMainMovie();
void FlushDisplayInfo(); void FlushDisplayInfo();
void StartDisplayInfo(int index, bool bMovie); void StartDisplayInfo(int index, bool bMovie);
void StartDisplayInfo(char *filename, int index); void StartDisplayInfo(char *filename, int index);
void StopDisplayInfo(); void StopDisplayInfo();
char* RetDisplayInfoName(int index); char* GetDisplayInfoName(int index);
int RetDisplayInfoPosition(int index); int GetDisplayInfoPosition(int index);
void SetDisplayInfoPosition(int index, int pos); void SetDisplayInfoPosition(int index, int pos);
void StartSuspend(); void StartSuspend();
void StopSuspend(); void StopSuspend();
float RetGameTime(); float GetGameTime();
void SetFontSize(float size); void SetFontSize(float size);
float RetFontSize(); float GetFontSize();
void SetWindowPos(Math::Point pos); void SetWindowPos(Math::Point pos);
Math::Point RetWindowPos(); Math::Point GetWindowPos();
void SetWindowDim(Math::Point dim); void SetWindowDim(Math::Point dim);
Math::Point RetWindowDim(); Math::Point GetWindowDim();
void SetIOPublic(bool bMode); void SetIOPublic(bool bMode);
bool RetIOPublic(); bool GetIOPublic();
void SetIOPos(Math::Point pos); void SetIOPos(Math::Point pos);
Math::Point RetIOPos(); Math::Point GetIOPos();
void SetIODim(Math::Point dim); void SetIODim(Math::Point dim);
Math::Point RetIODim(); Math::Point GetIODim();
char* RetTitle(); char* GetTitle();
char* RetResume(); char* GetResume();
char* RetScriptName(); char* GetScriptName();
char* RetScriptFile(); char* GetScriptFile();
bool RetTrainerPilot(); bool GetTrainerPilot();
bool RetFixScene(); bool GetFixScene();
bool RetGlint(); bool GetGlint();
bool RetSoluce4(); bool GetSoluce4();
bool RetMovies(); bool GetMovies();
bool RetNiceReset(); bool GetNiceReset();
bool RetHimselfDamage(); bool GetHimselfDamage();
bool RetShowSoluce(); bool GetShowSoluce();
bool RetSceneSoluce(); bool GetSceneSoluce();
bool RetShowAll(); bool GetShowAll();
bool RetCheatRadar(); bool GetCheatRadar();
char* RetSavegameDir(); char* GetSavegameDir();
char* RetPublicDir(); char* GetPublicDir();
char* RetFilesDir(); char* GetFilesDir();
void SetGamerName(char *name); void SetGamerName(char *name);
char* RetGamerName(); char* GetGamerName();
int RetGamerFace(); int GetGamerFace();
int RetGamerGlasses(); int GetGamerGlasses();
bool RetGamerOnlyHead(); bool GetGamerOnlyHead();
float RetPersoAngle(); float GetPersoAngle();
void StartMusic(); void StartMusic();
void ClearInterface(); void ClearInterface();
@ -256,11 +255,11 @@ public:
float SearchNearestObject(Math::Vector center, CObject *exclu); float SearchNearestObject(Math::Vector center, CObject *exclu);
bool FreeSpace(Math::Vector &center, float minRadius, float maxRadius, float space, CObject *exclu); bool FreeSpace(Math::Vector &center, float minRadius, float maxRadius, float space, CObject *exclu);
float RetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu); float GetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu);
void HideDropZone(CObject* metal); void HideDropZone(CObject* metal);
void ShowDropZone(CObject* metal, CObject* truck); void ShowDropZone(CObject* metal, CObject* truck);
void FlushShowLimit(int i); void FlushShowLimit(int i);
void SetShowLimit(int i, ParticuleType parti, CObject *pObj, Math::Vector pos, float radius, float duration=SHOWLIMITTIME); void SetShowLimit(int i, Gfx::ParticleType parti, CObject *pObj, Math::Vector pos, float radius, float duration=SHOWLIMITTIME);
void AdjustShowLimit(int i, Math::Vector pos); void AdjustShowLimit(int i, Math::Vector pos);
void StartShowLimit(); void StartShowLimit();
void FrameShowLimit(float rTime); void FrameShowLimit(float rTime);
@ -276,7 +275,7 @@ public:
bool FlushNewScriptName(); bool FlushNewScriptName();
bool AddNewScriptName(ObjectType type, char *name); bool AddNewScriptName(ObjectType type, char *name);
char* RetNewScriptName(ObjectType type, int rank); char* GetNewScriptName(ObjectType type, int rank);
void WriteFreeParam(); void WriteFreeParam();
void ReadFreeParam(); void ReadFreeParam();
@ -287,7 +286,7 @@ public:
void IOWriteObject(FILE *file, CObject* pObj, char *cmd); void IOWriteObject(FILE *file, CObject* pObj, char *cmd);
CObject* IOReadObject(char *line, char* filename, int objRank); CObject* IOReadObject(char *line, char* filename, int objRank);
int CreateSpot(Math::Vector pos, D3DCOLORVALUE color); int CreateSpot(Math::Vector pos, Gfx::Color color);
protected: protected:
bool EventFrame(const Event &event); bool EventFrame(const Event &event);
@ -300,7 +299,7 @@ protected:
void CreateModel(); void CreateModel();
Math::Vector LookatPoint( Math::Vector eye, float angleH, float angleV, float length ); 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); 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, D3DCOLORVALUE color); int CreateLight(Math::Vector direction, Gfx::Color color);
void HiliteClear(); void HiliteClear();
void HiliteObject(Math::Point pos); void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime); void HiliteFrame(float rTime);
@ -309,7 +308,7 @@ protected:
CObject* DetectObject(Math::Point pos); CObject* DetectObject(Math::Point pos);
void ChangeCamera(); void ChangeCamera();
void RemoteCamera(float pan, float zoom, float rTime); void RemoteCamera(float pan, float zoom, float rTime);
void KeyCamera(EventMsg event, long param); void KeyCamera(EventType event, long param);
void AbortMovie(); void AbortMovie();
bool IsSelectable(CObject* pObj); bool IsSelectable(CObject* pObj);
void SelectOneObject(CObject* pObj, bool bDisplayError=true); void SelectOneObject(CObject* pObj, bool bDisplayError=true);
@ -318,8 +317,8 @@ protected:
void DeleteAllObjects(); void DeleteAllObjects();
void UpdateInfoText(); void UpdateInfoText();
CObject* SearchObject(ObjectType type); CObject* SearchObject(ObjectType type);
CObject* RetSelect(); CObject* GetSelect();
void StartDisplayVisit(EventMsg event); void StartDisplayVisit(EventType event);
void FrameVisit(float rTime); void FrameVisit(float rTime);
void StopDisplayVisit(); void StopDisplayVisit();
void ExecuteCmd(char *cmd); void ExecuteCmd(char *cmd);
@ -333,7 +332,7 @@ protected:
CMainMap* m_map; CMainMap* m_map;
CEvent* m_event; CEvent* m_event;
CD3DEngine* m_engine; CD3DEngine* m_engine;
CParticule* m_particule; Gfx::CParticle* m_particle;
CWater* m_water; CWater* m_water;
CCloud* m_cloud; CCloud* m_cloud;
CBlitz* m_blitz; CBlitz* m_blitz;
@ -359,7 +358,7 @@ protected:
Phase m_phase; Phase m_phase;
int m_cameraRank; int m_cameraRank;
D3DCOLORVALUE m_color; Gfx::Color m_color;
bool m_bFreePhoto; bool m_bFreePhoto;
bool m_bCmdEdit; bool m_bCmdEdit;
bool m_bShowPos; bool m_bShowPos;
@ -420,7 +419,7 @@ protected:
float m_cameraPan; float m_cameraPan;
float m_cameraZoom; float m_cameraZoom;
EventMsg m_visitLast; EventType m_visitLast;
CObject* m_visitObject; CObject* m_visitObject;
CObject* m_visitArrow; CObject* m_visitArrow;
float m_visitTime; float m_visitTime;
@ -446,14 +445,14 @@ protected:
ShowLimit m_showLimit[MAXSHOWLIMIT]; ShowLimit m_showLimit[MAXSHOWLIMIT];
D3DCOLORVALUE m_colorRefBot; Gfx::Color m_colorRefBot;
D3DCOLORVALUE m_colorNewBot; Gfx::Color m_colorNewBot;
D3DCOLORVALUE m_colorRefAlien; Gfx::Color m_colorRefAlien;
D3DCOLORVALUE m_colorNewAlien; Gfx::Color m_colorNewAlien;
D3DCOLORVALUE m_colorRefGreen; Gfx::Color m_colorRefGreen;
D3DCOLORVALUE m_colorNewGreen; Gfx::Color m_colorNewGreen;
D3DCOLORVALUE m_colorRefWater; Gfx::Color m_colorRefWater;
D3DCOLORVALUE m_colorNewWater; Gfx::Color m_colorNewWater;
float m_colorShiftWater; float m_colorShiftWater;
}; };

View File

@ -17,7 +17,7 @@
// task.cpp // task.cpp
#include <stdio.h> // #include <stdio.h>
#include "object/task/task.h" #include "object/task/task.h"
@ -32,20 +32,20 @@ CTask::CTask(CInstanceManager* iMan, CObject* object)
{ {
m_iMan = iMan; m_iMan = iMan;
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT); m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN); m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER); m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
m_displayText = (CDisplayText*)m_iMan->SearchInstance(CLASS_DISPLAYTEXT); m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_object = object; m_object = object;
m_physics = m_object->RetPhysics(); m_physics = m_object->GetPhysics();
m_brain = m_object->RetBrain(); m_brain = m_object->GetBrain();
m_motion = m_object->RetMotion(); m_motion = m_object->GetMotion();
} }
// Object's destructor. // Object's destructor.

View File

@ -24,19 +24,25 @@
class CInstanceManager; class CInstanceManager;
class CD3DEngine;
class CLight;
class CParticule;
class CTerrain;
class CWater;
class CCamera;
class CBrain; class CBrain;
class CPhysics; class CPhysics;
class CMotion; class CMotion;
class CObject; class CObject;
class CRobotMain; class CRobotMain;
class CSoundInterface;
namespace Ui {
class CDisplayText; class CDisplayText;
class CSound; } /* Ui */
namespace Gfx {
class CEngine;
class CLightManager;
class CParticle;
class CTerrain;
class CWater;
class CCamera;
} /* Gfx */
const float TAKE_DIST = 6.0f; // distance to an object to pick it const float TAKE_DIST = 6.0f; // distance to an object to pick it
@ -66,21 +72,19 @@ public:
virtual bool Abort(); virtual bool Abort();
protected: protected:
CInstanceManager* m_iMan;
protected: Gfx::CEngine* m_engine;
CInstanceManager* m_iMan; Gfx::CLightManager* m_lightMan;
CD3DEngine* m_engine; Gfx::CParticle* m_particle;
CLight* m_light; Gfx::CTerrain* m_terrain;
CParticule* m_particule; Gfx::CWater* m_water;
CTerrain* m_terrain; Gfx::CCamera* m_camera;
CWater* m_water; CMotion* m_motion;
CCamera* m_camera; CBrain* m_brain;
CMotion* m_motion; CPhysics* m_physics;
CBrain* m_brain; CObject* m_object;
CPhysics* m_physics; CRobotMain* m_main;
CObject* m_object; Ui::CDisplayText* m_displayText;
CRobotMain* m_main; CSoundInterface* m_sound;
CDisplayText* m_displayText;
CSound* m_sound;
}; };

View File

@ -136,7 +136,7 @@ Error CTaskManager::StartTaskSearch()
// Reads an information terminal. // Reads an information terminal.
Error CTaskManager::StartTaskInfo(char *name, float value, float power, bool bSend) Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
{ {
m_task = new CTaskInfo(m_iMan, m_object); m_task = new CTaskInfo(m_iMan, m_object);
return ((CTaskInfo*)m_task)->Start(name, value, power, bSend); return ((CTaskInfo*)m_task)->Start(name, value, power, bSend);

View File

@ -43,7 +43,7 @@ public:
Error StartTaskFlag(TaskFlagOrder order, int rank); Error StartTaskFlag(TaskFlagOrder order, int rank);
Error StartTaskBuild(ObjectType type); Error StartTaskBuild(ObjectType type);
Error StartTaskSearch(); Error StartTaskSearch();
Error StartTaskInfo(char *name, float value, float power, bool bSend); Error StartTaskInfo(const char *name, float value, float power, bool bSend);
Error StartTaskTerraform(); Error StartTaskTerraform();
Error StartTaskPen(bool bDown, int color); Error StartTaskPen(bool bDown, int color);
Error StartTaskRecover(); Error StartTaskRecover();

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -14,10 +15,14 @@
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
// physics.h
#pragma once #pragma once
/**
* \file physics/physics.h
* \brief Responsible for physics "and more" in game
*/
#include "common/misc.h" #include "common/misc.h"
#include "object/object.h" #include "object/object.h"
@ -25,17 +30,17 @@
class CInstanceManager; class CInstanceManager;
class CCamera;
class CObject; class CObject;
class CBrain; class CBrain;
class CMotion; class CMotion;
class CSound; class CSoundInterface;
namespace Gfx namespace Gfx
{ {
class CCamera;
class CEngine; class CEngine;
class CLight; class CLight;
class CParticule; class CParticle;
class CTerrain; class CTerrain;
class CWater; class CWater;
}; };
@ -170,7 +175,7 @@ protected:
void SoundMotorStop(float rTime, ObjectType type); void SoundMotorStop(float rTime, ObjectType type);
void SoundReactorFull(float rTime, ObjectType type); void SoundReactorFull(float rTime, ObjectType type);
void SoundReactorStop(float rTime, ObjectType type); void SoundReactorStop(float rTime, ObjectType type);
void FrameParticule(float aTime, float rTime); void FrameParticle(float aTime, float rTime);
void MotorUpdate(float aTime, float rTime); void MotorUpdate(float aTime, float rTime);
void EffectUpdate(float aTime, float rTime); void EffectUpdate(float aTime, float rTime);
void UpdateMotionStruct(float rTime, Motion &motion); void UpdateMotionStruct(float rTime, Motion &motion);
@ -182,24 +187,24 @@ protected:
bool ExploOther(ObjectType iType, CObject *pObj, ObjectType oType, float force); bool ExploOther(ObjectType iType, CObject *pObj, ObjectType oType, float force);
int ExploHimself(ObjectType iType, ObjectType oType, float force); int ExploHimself(ObjectType iType, ObjectType oType, float force);
void PowerParticule(float factor, bool bBreak); void PowerParticle(float factor, bool bBreak);
void CrashParticule(float crash); void CrashParticle(float crash);
void MotorParticule(float aTime, float rTime); void MotorParticle(float aTime, float rTime);
void WaterParticule(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn); void WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn);
void WheelParticule(int color, float width); void WheelParticle(int color, float width);
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
Gfx::CEngine* m_engine; Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan; Gfx::CLightManager* m_lightMan;
Gfx::CParticle* m_particle; Gfx::CParticle* m_particle;
Gfx::CTerrain* m_terrain; Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water; Gfx::CWater* m_water;
Gfx::CCamera* m_camera; Gfx::CCamera* m_camera;
CObject* m_object; CObject* m_object;
CBrain* m_brain; CBrain* m_brain;
CMotion* m_motion; CMotion* m_motion;
CSound* m_sound; CSoundInterface* m_sound;
PhysicsType m_type; // TYPE_* PhysicsType m_type; // TYPE_*
float m_gravity; // force of gravity float m_gravity; // force of gravity
@ -217,15 +222,15 @@ protected:
float m_linVibrationFactor; float m_linVibrationFactor;
float m_cirVibrationFactor; float m_cirVibrationFactor;
float m_inclinaisonFactor; float m_inclinaisonFactor;
float m_lastPowerParticule; float m_lastPowerParticle;
float m_lastSlideParticule; float m_lastSlideParticle;
float m_lastMotorParticule; float m_lastMotorParticle;
float m_lastWaterParticule; float m_lastWaterParticle;
float m_lastUnderParticule; float m_lastUnderParticle;
float m_lastPloufParticule; float m_lastPloufParticle;
float m_lastFlameParticule; float m_lastFlameParticle;
bool m_bWheelParticuleBrake; bool m_bWheelParticleBrake;
Math::Vector m_wheelParticulePos[2]; Math::Vector m_wheelParticlePos[2];
float m_absorbWater; float m_absorbWater;
float m_reactorTemperature; float m_reactorTemperature;
float m_reactorRange; float m_reactorRange;
@ -234,7 +239,7 @@ protected:
float m_lastEnergy; float m_lastEnergy;
float m_lastSoundWater; float m_lastSoundWater;
float m_lastSoundInsect; float m_lastSoundInsect;
float m_restBreakParticule; float m_restBreakParticle;
float m_floorLevel; // ground level float m_floorLevel; // ground level
float m_floorHeight; // height above the ground float m_floorHeight; // height above the ground
int m_soundChannel; int m_soundChannel;

View File

@ -15,25 +15,25 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h> // #include <windows.h>
#include <stdio.h> // #include <stdio.h>
#include <d3d.h> // #include <d3d.h>
//
#include "common/struct.h" // #include "common/struct.h"
#include "old/d3dengine.h" // #include "old/d3dengine.h"
#include "old/d3dmath.h" // #include "old/d3dmath.h"
#include "common/language.h" // #include "common/language.h"
#include "common/global.h" // #include "common/global.h"
#include "common/event.h" // #include "common/event.h"
#include "object/object.h" #include "object/object.h"
#include "script/cbottoken.h" // #include "script/cbottoken.h"
// Seeking the name of an object. // Seeking the name of an object.
char* RetObjectName(ObjectType type) const char* GetObjectName(ObjectType type)
{ {
if ( type == OBJECT_PORTICO ) return "Portico"; if ( type == OBJECT_PORTICO ) return "Portico";
if ( type == OBJECT_BASE ) return "SpaceShip"; if ( type == OBJECT_BASE ) return "SpaceShip";
@ -126,7 +126,7 @@ char* RetObjectName(ObjectType type)
// Seeking the name of a secondary object. // Seeking the name of a secondary object.
// (because Otto thinks that Germans do not like nuclear power) // (because Otto thinks that Germans do not like nuclear power)
char* RetObjectAlias(ObjectType type) const char* GetObjectAlias(ObjectType type)
{ {
if ( type == OBJECT_NUCLEAR ) return "FuelCellPlant"; if ( type == OBJECT_NUCLEAR ) return "FuelCellPlant";
if ( type == OBJECT_URANIUM ) return "PlatinumOre"; if ( type == OBJECT_URANIUM ) return "PlatinumOre";
@ -139,7 +139,7 @@ char* RetObjectAlias(ObjectType type)
// Returns the help file to use for the object. // Returns the help file to use for the object.
char* RetHelpFilename(ObjectType type) const char* GetHelpFilename(ObjectType type)
{ {
if ( type == OBJECT_BASE ) return "help\\object\\base.txt"; if ( type == OBJECT_BASE ) return "help\\object\\base.txt";
if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt"; if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt";
@ -224,7 +224,7 @@ char* RetHelpFilename(ObjectType type)
// Returns the help file to use for instruction. // Returns the help file to use for instruction.
char* RetHelpFilename(const char *token) const char* GetHelpFilename(const char *token)
{ {
if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt"; if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt";
if ( strcmp(token, "else" ) == 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. // Returns using a compact instruction.
char* RetHelpText(const char *token) const char* GetHelpText(const char *token)
{ {
if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }"; if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }";
if ( strcmp(token, "else" ) == 0 ) return "else { bloc }"; if ( strcmp(token, "else" ) == 0 ) return "else { bloc }";

View File

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

View File

@ -15,20 +15,7 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "common/language.h"
#include "common/global.h" #include "common/global.h"
#include "common/event.h"
#include "old/water.h"
#include "old/pyro.h"
#include "old/camera.h"
#include "object/object.h"
#include "script/cmdtoken.h" #include "script/cmdtoken.h"
@ -48,7 +35,7 @@ char* SkipSpace(char *line)
// Checks if a line contains a command. // Checks if a line contains a command.
bool Cmd(char *line, char *token) bool Cmd(char *line, const char *token)
{ {
char* p; char* p;
@ -59,7 +46,7 @@ bool Cmd(char *line, char *token)
// Seeking an operator. // Seeking an operator.
char* SearchOp(char *line, char *op) char* SearchOp(char *line, const char *op)
{ {
char opeq[50]; char opeq[50];
char* p; char* p;
@ -418,7 +405,7 @@ ObjectType GetTypeObject(char *line, int rank, ObjectType def)
// Returns the name of an object type. // Returns the name of an object type.
char* GetTypeObject(ObjectType type) const char* GetTypeObject(ObjectType type)
{ {
if ( type == OBJECT_PORTICO ) return "Portico"; if ( type == OBJECT_PORTICO ) return "Portico";
if ( type == OBJECT_BASE ) return "SpaceShip"; if ( type == OBJECT_BASE ) return "SpaceShip";
@ -663,35 +650,35 @@ char* GetTypeObject(ObjectType type)
// Returns the type of water. // Returns the type of water.
WaterType GetTypeWater(char *line, int rank, WaterType def) Gfx::WaterType GetTypeWater(char *line, int rank, Gfx::WaterType def)
{ {
char* p; char* p;
p = SearchArg(line, rank); p = SearchArg(line, rank);
if ( *p == 0 ) return def; if ( *p == 0 ) return def;
if ( Cmd(p, "NULL" ) ) return WATER_NULL; if ( Cmd(p, "NULL" ) ) return Gfx::WATER_NULL;
if ( Cmd(p, "TT" ) ) return WATER_TT; if ( Cmd(p, "TT" ) ) return Gfx::WATER_TT;
if ( Cmd(p, "TO" ) ) return WATER_TO; if ( Cmd(p, "TO" ) ) return Gfx::WATER_TO;
if ( Cmd(p, "CT" ) ) return WATER_CT; if ( Cmd(p, "CT" ) ) return Gfx::WATER_CT;
if ( Cmd(p, "CO" ) ) return WATER_CO; if ( Cmd(p, "CO" ) ) return Gfx::WATER_CO;
return def; return def;
} }
// Returns the type of terrain. // Returns the type of terrain.
D3DTypeObj GetTypeTerrain(char *line, int rank, D3DTypeObj def) Gfx::EngineObjectType GetTypeTerrain(char *line, int rank, Gfx::EngineObjectType def)
{ {
char* p; char* p;
p = SearchArg(line, rank); p = SearchArg(line, rank);
if ( *p == 0 ) return def; if ( *p == 0 ) return def;
if ( Cmd(p, "Terrain" ) ) return TYPETERRAIN; if ( Cmd(p, "Terrain" ) ) return Gfx::ENG_OBJTYPE_TERRAIN;
if ( Cmd(p, "Object" ) ) return TYPEFIX; if ( Cmd(p, "Object" ) ) return Gfx::ENG_OBJTYPE_FIX;
if ( Cmd(p, "Quartz" ) ) return TYPEQUARTZ; if ( Cmd(p, "Quartz" ) ) return Gfx::ENG_OBJTYPE_QUARTZ;
if ( Cmd(p, "Metal" ) ) return TYPEMETAL; if ( Cmd(p, "Metal" ) ) return Gfx::ENG_OBJTYPE_METAL;
return def; return def;
} }
@ -753,64 +740,64 @@ int GetResearch(char *line, int rank)
// Returns the type of pyrotechnic effect. // Returns the type of pyrotechnic effect.
PyroType GetPyro(char *line, int rank) Gfx::PyroType GetPyro(char *line, int rank)
{ {
char* p; char* p;
p = SearchArg(line, rank); p = SearchArg(line, rank);
if ( *p == 0 ) return PT_NULL; if ( *p == 0 ) return Gfx::PT_NULL;
if ( Cmd(p, "FRAGt" ) ) return PT_FRAGT; if ( Cmd(p, "FRAGt" ) ) return Gfx::PT_FRAGT;
if ( Cmd(p, "FRAGo" ) ) return PT_FRAGO; if ( Cmd(p, "FRAGo" ) ) return Gfx::PT_FRAGO;
if ( Cmd(p, "FRAGw" ) ) return PT_FRAGW; if ( Cmd(p, "FRAGw" ) ) return Gfx::PT_FRAGW;
if ( Cmd(p, "EXPLOt" ) ) return PT_EXPLOT; if ( Cmd(p, "EXPLOt" ) ) return Gfx::PT_EXPLOT;
if ( Cmd(p, "EXPLOo" ) ) return PT_EXPLOO; if ( Cmd(p, "EXPLOo" ) ) return Gfx::PT_EXPLOO;
if ( Cmd(p, "EXPLOw" ) ) return PT_EXPLOW; if ( Cmd(p, "EXPLOw" ) ) return Gfx::PT_EXPLOW;
if ( Cmd(p, "SHOTt" ) ) return PT_SHOTT; if ( Cmd(p, "SHOTt" ) ) return Gfx::PT_SHOTT;
if ( Cmd(p, "SHOTh" ) ) return PT_SHOTH; if ( Cmd(p, "SHOTh" ) ) return Gfx::PT_SHOTH;
if ( Cmd(p, "SHOTm" ) ) return PT_SHOTM; if ( Cmd(p, "SHOTm" ) ) return Gfx::PT_SHOTM;
if ( Cmd(p, "SHOTw" ) ) return PT_SHOTW; if ( Cmd(p, "SHOTw" ) ) return Gfx::PT_SHOTW;
if ( Cmd(p, "EGG" ) ) return PT_EGG; if ( Cmd(p, "EGG" ) ) return Gfx::PT_EGG;
if ( Cmd(p, "BURNt" ) ) return PT_BURNT; if ( Cmd(p, "BURNt" ) ) return Gfx::PT_BURNT;
if ( Cmd(p, "BURNo" ) ) return PT_BURNO; if ( Cmd(p, "BURNo" ) ) return Gfx::PT_BURNO;
if ( Cmd(p, "SPIDER" ) ) return PT_SPIDER; if ( Cmd(p, "SPIDER" ) ) return Gfx::PT_SPIDER;
if ( Cmd(p, "FALL" ) ) return PT_FALL; if ( Cmd(p, "FALL" ) ) return Gfx::PT_FALL;
if ( Cmd(p, "RESET" ) ) return PT_RESET; if ( Cmd(p, "RESET" ) ) return Gfx::PT_RESET;
if ( Cmd(p, "WIN" ) ) return PT_WIN; if ( Cmd(p, "WIN" ) ) return Gfx::PT_WIN;
if ( Cmd(p, "LOST" ) ) return PT_LOST; if ( Cmd(p, "LOST" ) ) return Gfx::PT_LOST;
return PT_NULL; return Gfx::PT_NULL;
} }
// Returns the type of camera. // Returns the type of camera.
CameraType GetCamera(char *line, int rank) Gfx::CameraType GetCamera(char *line, int rank)
{ {
char* p; char* p;
p = SearchArg(line, rank); p = SearchArg(line, rank);
if ( *p == 0 ) return CAMERA_NULL; if ( *p == 0 ) return Gfx::CAM_TYPE_NULL;
if ( Cmd(p, "BACK" ) ) return CAMERA_BACK; if ( Cmd(p, "BACK" ) ) return Gfx::CAM_TYPE_BACK;
if ( Cmd(p, "PLANE" ) ) return CAMERA_PLANE; if ( Cmd(p, "PLANE" ) ) return Gfx::CAM_TYPE_PLANE;
if ( Cmd(p, "ONBOARD" ) ) return CAMERA_ONBOARD; if ( Cmd(p, "ONBOARD" ) ) return Gfx::CAM_TYPE_ONBOARD;
if ( Cmd(p, "FIX" ) ) return CAMERA_FIX; if ( Cmd(p, "FIX" ) ) return Gfx::CAM_TYPE_FIX;
return CAMERA_NULL; return Gfx::CAM_TYPE_NULL;
} }
// Returns the name of a camera. // Returns the name of a camera.
char* GetCamera(CameraType type) const char* GetCamera(Gfx::CameraType type)
{ {
if ( type == CAMERA_ONBOARD ) return "ONBOARD"; if ( type == Gfx::CAM_TYPE_ONBOARD ) return "ONBOARD";
if ( type == CAMERA_FIX ) return "FIX"; if ( type == Gfx::CAM_TYPE_FIX ) return "FIX";
return "BACK"; return "BACK";
} }
// Returns an integer. // Returns an integer.
int OpInt(char *line, char *op, int def) int OpInt(char *line, const char *op, int def)
{ {
line = SearchOp(line, op); line = SearchOp(line, op);
if ( *line == 0 ) return def; if ( *line == 0 ) return def;
@ -819,7 +806,7 @@ int OpInt(char *line, char *op, int def)
// Returns a float number. // Returns a float number.
float OpFloat(char *line, char *op, float def) float OpFloat(char *line, const char *op, float def)
{ {
line = SearchOp(line, op); line = SearchOp(line, op);
if ( *line == 0 ) return def; if ( *line == 0 ) return def;
@ -852,7 +839,7 @@ ObjectType OpTypeObject(char *line, char *op, ObjectType def)
// Returns the type of a water. // Returns the type of a water.
WaterType OpTypeWater(char *line, char *op, WaterType def) Gfx::WaterType OpTypeWater(char *line, char *op, Gfx::WaterType def)
{ {
line = SearchOp(line, op); line = SearchOp(line, op);
if ( *line == 0 ) return def; if ( *line == 0 ) return def;
@ -861,7 +848,7 @@ WaterType OpTypeWater(char *line, char *op, WaterType def)
// Returns the type of a terrain. // Returns the type of a terrain.
D3DTypeObj OpTypeTerrain(char *line, char *op, D3DTypeObj def) Gfx::EngineObjectType OpTypeTerrain(char *line, char *op, Gfx::EngineObjectType def)
{ {
line = SearchOp(line, op); line = SearchOp(line, op);
if ( *line == 0 ) return def; if ( *line == 0 ) return def;
@ -879,19 +866,19 @@ int OpResearch(char *line, char *op)
// Returns the type of pyrotechnic effect. // Returns the type of pyrotechnic effect.
PyroType OpPyro(char *line, char *op) Gfx::PyroType OpPyro(char *line, char *op)
{ {
line = SearchOp(line, op); line = SearchOp(line, op);
if ( *line == 0 ) return PT_NULL; if ( *line == 0 ) return Gfx::PT_NULL;
return GetPyro(line, 0); return GetPyro(line, 0);
} }
// Returns the type of camera. // Returns the type of camera.
CameraType OpCamera(char *line, char *op) Gfx::CameraType OpCamera(char *line, const char *op)
{ {
line = SearchOp(line, op); line = SearchOp(line, op);
if ( *line == 0 ) return CAMERA_NULL; if ( *line == 0 ) return Gfx::CAM_TYPE_NULL;
return GetCamera(line, 0); return GetCamera(line, 0);
} }
@ -924,7 +911,7 @@ Math::Vector OpPos(char *line, char *op)
// Returns a direction. // Returns a direction.
Math::Vector OpDir(char *line, char *op) Math::Vector OpDir(char *line, const char *op)
{ {
Math::Vector dir; Math::Vector dir;
@ -940,28 +927,10 @@ Math::Vector OpDir(char *line, char *op)
return dir; return dir;
} }
// Reads a color (0 .. 255).
D3DCOLOR OpColor(char *line, char *op, D3DCOLOR def)
{
D3DCOLOR color;
line = SearchOp(line, op);
if ( *line == 0 ) return def;
color = 0;
color |= (GetInt(line, 0, 0)&0xff)<<16; // r
color |= (GetInt(line, 1, 0)&0xff)<<8; // g
color |= (GetInt(line, 2, 0)&0xff)<<0; // b
color |= (GetInt(line, 3, 0)&0xff)<<24; // a
return color;
}
// Reads a color (-1 .. 1). // Reads a color (-1 .. 1).
Gfx::Color OpColor(char *line, char *op, Gfx::Color def)
D3DCOLORVALUE OpColorValue(char *line, char *op, D3DCOLORVALUE def)
{ {
D3DCOLORVALUE color; Gfx::Color color;
line = SearchOp(line, op); line = SearchOp(line, op);
if ( *line == 0 ) return def; if ( *line == 0 ) return def;

View File

@ -19,46 +19,44 @@
#pragma once #pragma once
#include "old/d3denum.h" // #include "old/d3denum.h"
#include "old/d3dengine.h" // #include "old/d3dengine.h"
#include "object/object.h" // #include "object/object.h"
#include "old/water.h" #include "graphics/engine/water.h"
#include "old/pyro.h" #include "graphics/engine/engine.h"
#include "old/camera.h" #include "graphics/engine/pyro.h"
// Procedures. // Procedures.
extern bool Cmd(char *line, char *token); extern bool Cmd(char *line, const char *token);
extern char* SearchOp(char *line, char *op); extern char* SearchOp(char *line, const char *op);
extern int GetInt(char *line, int rank, int def); extern int GetInt(char *line, int rank, int def);
extern float GetFloat(char *line, int rank, float def); extern float GetFloat(char *line, int rank, float def);
extern void GetString(char *line, int rank, char *buffer); extern void GetString(char *line, int rank, char *buffer);
extern ObjectType GetTypeObject(char *line, int rank, ObjectType def); extern ObjectType GetTypeObject(char *line, int rank, ObjectType def);
extern char* GetTypeObject(ObjectType type); extern const char* GetTypeObject(ObjectType type);
extern WaterType GetTypeWater(char *line, int rank, WaterType def); extern Gfx::WaterType GetTypeWater(char *line, int rank, Gfx::WaterType def);
extern D3DTypeObj GetTypeTerrain(char *line, int rank, D3DTypeObj def); extern Gfx::EngineObjectType GetTypeTerrain(char *line, int rank, Gfx::EngineObjectType def);
extern int GetBuild(char *line, int rank); extern int GetBuild(char *line, int rank);
extern int GetResearch(char *line, int rank); extern int GetResearch(char *line, int rank);
extern PyroType GetPyro(char *line, int rank); extern Gfx::PyroType GetPyro(char *line, int rank);
extern CameraType GetCamera(char *line, int rank); extern Gfx::CameraType GetCamera(char *line, int rank);
extern char* GetCamera(CameraType type); extern const char* GetCamera(Gfx::CameraType type);
extern int OpInt(char *line, char *op, int def); extern int OpInt(char *line, const char *op, int def);
extern float OpFloat(char *line, char *op, float def); extern float OpFloat(char *line, const char *op, float def);
extern void OpString(char *line, char *op, char *buffer); extern void OpString(char *line, char *op, char *buffer);
extern ObjectType OpTypeObject(char *line, char *op, ObjectType def); extern ObjectType OpTypeObject(char *line, char *op, ObjectType def);
extern WaterType OpTypeWater(char *line, char *op, WaterType def); extern Gfx::WaterType OpTypeWater(char *line, char *op, Gfx::WaterType def);
extern D3DTypeObj OpTypeTerrain(char *line, char *op, D3DTypeObj def); extern Gfx::EngineObjectType OpTypeTerrain(char *line, char *op, Gfx::EngineObjectType def);
extern int OpResearch(char *line, char *op); extern int OpResearch(char *line, char *op);
extern PyroType OpPyro(char *line, char *op); extern Gfx::PyroType OpPyro(char *line, char *op);
extern CameraType OpCamera(char *line, char *op); extern Gfx::CameraType OpCamera(char *line, const char *op);
extern int OpBuild(char *line, char *op); extern int OpBuild(char *line, char *op);
extern Math::Vector OpPos(char *line, char *op); extern Math::Vector OpPos(char *line, char *op);
extern Math::Vector OpDir(char *line, char *op); extern Math::Vector OpDir(char *line, const char *op);
extern D3DCOLOR OpColor(char *line, char *op, D3DCOLOR def); extern Gfx::Color OpColor(char *line, char *op, Gfx::Color def);
extern D3DCOLORVALUE OpColorValue(char *line, char *op, D3DCOLORVALUE def);

File diff suppressed because it is too large Load Diff

View File

@ -22,20 +22,26 @@
#include <stdio.h> #include <stdio.h>
#include "common/event.h" #include "common/event.h"
#include "CBot/CBotDll.h"
class CInstanceManager; class CInstanceManager;
class CD3DEngine;
class CInterface;
class CDisplayText;
class CEdit;
class CList;
class CObject; class CObject;
class CTaskManager; class CTaskManager;
class CBotProgram;
class CRobotMain; class CRobotMain;
namespace Ui{
class CDisplayText;
class CEdit;
class CInterface;
class CList;
} /* Ui */
namespace Gfx {
class CEngine;
class CTerrain; class CTerrain;
class CWater; class CWater;
} /* Gfx */
@ -47,9 +53,9 @@ public:
static void InitFonctions(); static void InitFonctions();
void PutScript(CEdit* edit, char* name); void PutScript(Ui::CEdit* edit, char* name);
bool GetScript(CEdit* edit); bool GetScript(Ui::CEdit* edit);
bool RetCompile(); bool GetCompile();
void GetTitle(char* buffer); void GetTitle(char* buffer);
@ -61,14 +67,14 @@ public:
bool IsRunning(); bool IsRunning();
bool IsContinue(); bool IsContinue();
bool GetCursor(int &cursor1, int &cursor2); bool GetCursor(int &cursor1, int &cursor2);
void UpdateList(CList* list); void UpdateList(Ui::CList* list);
void ColorizeScript(CEdit* edit); void ColorizeScript(Ui::CEdit* edit);
bool IntroduceVirus(); bool IntroduceVirus();
int RetError(); int GetError();
void GetError(char* buffer); void GetError(char* buffer);
void New(CEdit* edit, char* name); void New(Ui::CEdit* edit, char* name);
bool SendScript(char* text); bool SendScript(char* text);
bool ReadScript(char* filename); bool ReadScript(char* filename);
bool WriteScript(char* filename); bool WriteScript(char* filename);
@ -77,42 +83,124 @@ public:
bool Compare(CScript* other); bool Compare(CScript* other);
void SetFilename(char *filename); void SetFilename(char *filename);
char* RetFilename(); char* GetFilename();
protected: protected:
bool IsEmpty(); bool IsEmpty();
bool CheckToken(); bool CheckToken();
bool Compile(); bool Compile();
public: private:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CInterface* m_interface;
CDisplayText* m_displayText;
CBotProgram* m_botProg;
CRobotMain* m_main;
CTerrain* m_terrain;
CWater* m_water;
CTaskManager* m_primaryTask;
CTaskManager** m_secondaryTask;
CObject* m_object;
int m_ipf; // number of instructions/second static CBotTypResult cNull(CBotVar* &var, void* user);
int m_errMode; // what to do in case of error static CBotTypResult cOneFloat(CBotVar* &var, void* user);
int m_len; // length of the script (without <0>) static CBotTypResult cTwoFloat(CBotVar* &var, void* user);
char* m_script; // script ends with <0> static CBotTypResult cString(CBotVar* &var, void* user);
bool m_bRun; // program during execution? static CBotTypResult cGetObject(CBotVar* &var, void* user);
bool m_bStepMode; // step by step static CBotTypResult cSearch(CBotVar* &var, void* user);
bool m_bContinue; // external function to continue static CBotTypResult cRadar(CBotVar* &var, void* user);
bool m_bCompile; // compilation ok? static CBotTypResult cDetect(CBotVar* &var, void* user);
char m_title[50]; // script title static CBotTypResult cDirection(CBotVar* &var, void* user);
char m_filename[50]; // file name static CBotTypResult cProduce(CBotVar* &var, void* user);
char m_token[50]; // missing instruction static CBotTypResult cDistance(CBotVar* &var, void* user);
int m_error; // error (0=ok) static CBotTypResult cSpace(CBotVar* &var, void* user);
int m_cursor1; static CBotTypResult cFlatGround(CBotVar* &var, void* user);
int m_cursor2; static CBotTypResult cGoto(CBotVar* &var, void* user);
Event m_event; static CBotTypResult cGrabDrop(CBotVar* &var, void* user);
float m_returnValue; static CBotTypResult cReceive(CBotVar* &var, void* user);
static CBotTypResult cSend(CBotVar* &var, void* user);
static CBotTypResult cDeleteInfo(CBotVar* &var, void* user);
static CBotTypResult cTestInfo(CBotVar* &var, void* user);
static CBotTypResult cShield(CBotVar* &var, void* user);
static CBotTypResult cFire(CBotVar* &var, void* user);
static CBotTypResult cMotor(CBotVar* &var, void* user);
static CBotTypResult cTopo(CBotVar* &var, void* user);
static CBotTypResult cMessage(CBotVar* &var, void* user);
static CBotTypResult cPenDown(CBotVar* &var, void* user);
static CBotTypResult cOnePoint(CBotVar* &var, void* user);
static CBotTypResult cPoint(CBotVar* &var, void* user);
static bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rCos(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rTan(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rSqrt(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rPow(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDistance(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDistance2d(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rFlatGround(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rWait(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rMove(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rTurn(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rGoto(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rGrab(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDrop(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rSniff(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rReceive(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rSend(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rThump(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rShield(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rFire(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rAim(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rMotor(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rJet(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rTopo(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rMessage(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rCmdline(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rIsMovie(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rErrMode(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rIPF(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rAbsTime(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDeleteFile(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool Process(CScript* script, CBotVar* result, int &exception);
static CObject* SearchInfo(CScript* script, CObject* object, float power);
CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Ui::CInterface* m_interface;
Ui::CDisplayText* m_displayText;
CBotProgram* m_botProg;
CRobotMain* m_main;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
CTaskManager* m_primaryTask;
CTaskManager** m_secondaryTask;
CObject* m_object;
int m_ipf; // number of instructions/second
int m_errMode; // what to do in case of error
int m_len; // length of the script (without <0>)
char* m_script; // script ends with <0>
bool m_bRun; // program during execution?
bool m_bStepMode; // step by step
bool m_bContinue; // external function to continue
bool m_bCompile; // compilation ok?
char m_title[50]; // script title
char m_filename[50]; // file name
char m_token[50]; // missing instruction
int m_error; // error (0=ok)
int m_cursor1;
int m_cursor2;
Event m_event;
float m_returnValue;
}; };

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -15,14 +16,15 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "common/language.h" #include "graphics/engine/engine.h"
#include "old/math3d.h" //#include "common/language.h"
//#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -30,15 +32,15 @@
#include "ui/button.h" #include "ui/button.h"
namespace Ui {
const float DELAY1 = 0.4f; const float DELAY1 = 0.4f;
const float DELAY2 = 0.1f; const float DELAY2 = 0.1f;
// Object's constructor. // Object's constructor.
CButton::CButton(CInstanceManager* iMan) : CControl(iMan) CButton::CButton() : CControl()
{ {
m_bCapture = false; m_bCapture = false;
m_bImmediat = false; m_bImmediat = false;
@ -55,18 +57,18 @@ CButton::~CButton()
// Creates a new button. // Creates a new button.
bool CButton::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CButton::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);
if ( icon == -1 ) if ( icon == -1 )
{ {
char name[100]; char name[100];
char* p; char* p;
GetResource(RES_EVENT, eventMsg, name); GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\'); p = strchr(name, '\\');
if ( p != 0 ) *p = 0; if ( p != 0 ) *p = 0;
SetName(name); SetName(name);
@ -85,7 +87,7 @@ bool CButton::EventProcess(const Event &event)
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_FRAME ) if ( event.type == EVENT_FRAME )
{ {
if ( m_bRepeat && m_repeat != 0.0f ) if ( m_bRepeat && m_repeat != 0.0f )
{ {
@ -95,14 +97,15 @@ bool CButton::EventProcess(const Event &event)
m_repeat = DELAY2; m_repeat = DELAY2;
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
} }
} }
if ( event.event == EVENT_LBUTTONDOWN && if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) && (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) ) (m_state & STATE_ENABLE) )
{ {
@ -114,25 +117,27 @@ bool CButton::EventProcess(const Event &event)
if ( m_bImmediat || m_bRepeat ) if ( m_bImmediat || m_bRepeat )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
return false; return false;
} }
} }
if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{ {
} }
if ( event.event == EVENT_LBUTTONUP && m_bCapture ) if ( event.type == EVENT_MOUSE_BUTTON_UP && //left
event.mouseButton.button == 1 &&
m_bCapture )
{ {
if ( CControl::Detect(event.pos) ) if ( CControl::Detect(event.pos) )
{ {
if ( !m_bImmediat && !m_bRepeat ) if ( !m_bImmediat && !m_bRepeat )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
} }
@ -158,10 +163,10 @@ void CButton::Draw()
if ( m_state & STATE_WARNING ) // shading yellow-black? if ( m_state & STATE_WARNING ) // shading yellow-black?
{ {
pos.x = m_pos.x-( 8.0f/640.0f); pos.x = m_pos.x - ( 8.0f / 640.0f);
pos.y = m_pos.y-( 4.0f/480.0f); pos.y = m_pos.y - ( 4.0f / 480.0f);
dim.x = m_dim.x+(16.0f/640.0f); dim.x = m_dim.x + (16.0f / 640.0f);
dim.y = m_dim.y+( 8.0f/480.0f); dim.y = m_dim.y + ( 8.0f / 480.0f);
if ( m_state & STATE_SHADOW ) if ( m_state & STATE_SHADOW )
{ {
DrawShadow(pos, dim); DrawShadow(pos, dim);
@ -182,19 +187,19 @@ void CButton::Draw()
(m_state & STATE_SIMPLY) == 0 ) (m_state & STATE_SIMPLY) == 0 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
dp = 0.5f/256.0f; dp = 0.5f / 256.0f;
uv1.x = 128.0f/256.0f; uv1.x = 128.0f / 256.0f;
uv1.y = 96.0f/256.0f; uv1.y = 96.0f / 256.0f;
uv2.x = 136.0f/256.0f; uv2.x = 136.0f / 256.0f;
uv2.y = 128.0f/256.0f; uv2.y = 128.0f / 256.0f;
if ( (m_state & STATE_ENABLE) == 0 ) if ( (m_state & STATE_ENABLE) == 0 )
{ {
uv1.x += 16.0f/256.0f; uv1.x += 16.0f / 256.0f;
uv2.x += 16.0f/256.0f; uv2.x += 16.0f / 256.0f;
} }
uv1.x += dp; uv1.x += dp;
@ -202,15 +207,15 @@ void CButton::Draw()
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
pos.y = m_pos.y+5.0f/480.0f; pos.y = m_pos.y + 5.0f / 480.0f;
dim.y = m_dim.y-10.0f/480.0f; dim.y = m_dim.y - 10.0f / 480.0f;
pos.x = m_pos.x+5.0f/640.0f; pos.x = m_pos.x + 5.0f / 640.0f;
dim.x = 3.0f/640.0f; dim.x = 3.0f / 640.0f;
DrawIcon(pos, dim, uv1, uv2, 0.0f); DrawIcon(pos, dim, uv1, uv2, 0.0f);
uv1.x += 8.0f/256.0f; uv1.x += 8.0f / 256.0f;
uv2.x += 8.0f/256.0f; uv2.x += 8.0f / 256.0f;
pos.x = m_pos.x+m_dim.x-5.0f/640.0f-3.0f/640.0f; pos.x = m_pos.x + m_dim.x - 5.0f / 640.0f - 3.0f / 640.0f;
DrawIcon(pos, dim, uv1, uv2, 0.0f); DrawIcon(pos, dim, uv1, uv2, 0.0f);
} }
#endif #endif
@ -225,7 +230,7 @@ void CButton::SetImmediat(bool bImmediat)
m_bImmediat = bImmediat; m_bImmediat = bImmediat;
} }
bool CButton::RetImmediat() bool CButton::GetImmediat()
{ {
return m_bImmediat; return m_bImmediat;
} }
@ -239,8 +244,9 @@ void CButton::SetRepeat(bool bRepeat)
m_bRepeat = bRepeat; m_bRepeat = bRepeat;
} }
bool CButton::RetRepeat() bool CButton::GetRepeat()
{ {
return m_bRepeat; return m_bRepeat;
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -21,28 +22,28 @@
#include "ui/control.h" #include "ui/control.h"
namespace Gfx{
class CEngine;
}
class CD3DEngine; namespace Ui {
class CButton : public CControl class CButton : public CControl
{ {
public: public:
CButton(CInstanceManager* iMan); CButton();
virtual ~CButton(); virtual ~CButton();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); 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 SetImmediat(bool bRepeat); void SetImmediat(bool bRepeat);
bool RetImmediat(); bool GetImmediat();
void SetRepeat(bool bRepeat); void SetRepeat(bool bRepeat);
bool RetRepeat(); bool GetRepeat();
protected: protected:
@ -53,4 +54,4 @@ protected:
float m_repeat; float m_repeat;
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -15,26 +16,28 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" #include "graphics/engine/engine.h"
//#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
#include "common/restext.h" #include "common/restext.h"
#include "old/text.h" //#include "old/text.h"
#include "graphics/engine/text.h"
#include "ui/check.h" #include "ui/check.h"
namespace Ui {
// Object's constructor. // Object's constructor.
CCheck::CCheck(CInstanceManager* iMan) : CControl(iMan) CCheck::CCheck() : CControl()
{ {
} }
@ -47,16 +50,16 @@ CCheck::~CCheck()
// Creates a new button. // Creates a new button.
bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{ {
char name[100]; char name[100];
char* p; char* p;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg); CControl::Create(pos, dim, icon, eventType);
GetResource(RES_EVENT, eventMsg, name); GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\'); p = strchr(name, '\\');
if ( p != 0 ) *p = 0; if ( p != 0 ) *p = 0;
SetName(name); SetName(name);
@ -73,14 +76,15 @@ bool CCheck::EventProcess(const Event &event)
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_LBUTTONDOWN && if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
(m_state & STATE_VISIBLE) && event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) ) (m_state & STATE_ENABLE) )
{ {
if ( CControl::Detect(event.pos) ) if ( CControl::Detect(event.pos) )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
@ -101,7 +105,7 @@ void CCheck::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 ) return;
iDim = m_dim; iDim = m_dim;
m_dim.x = m_dim.y*0.75f; // square m_dim.x = m_dim.y * 0.75f; // square
if ( m_state & STATE_SHADOW ) if ( m_state & STATE_SHADOW )
{ {
@ -109,7 +113,7 @@ void CCheck::Draw()
} }
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
zoomExt = 1.00f; zoomExt = 1.00f;
zoomInt = 0.95f; zoomInt = 0.95f;
@ -143,7 +147,7 @@ void CCheck::Draw()
if ( (m_state & STATE_DEAD) == 0 ) if ( (m_state & STATE_DEAD) == 0 )
{ {
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
if ( m_state & STATE_CHECK ) if ( m_state & STATE_CHECK )
{ {
@ -157,10 +161,10 @@ void CCheck::Draw()
if ( m_state & STATE_DEAD ) return; if ( m_state & STATE_DEAD ) return;
// Draw the name. // Draw the name.
pos.x = m_pos.x+m_dim.y/0.9f; pos.x = m_pos.x + m_dim.y / 0.9f;
pos.y = m_pos.y+m_dim.y*0.50f; pos.y = m_pos.y + m_dim.y * 0.50f;
pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f;
m_engine->RetText()->DrawText(m_name, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -21,18 +22,18 @@
#include "ui/control.h" #include "ui/control.h"
namespace Gfx{
class CEngine;
}
class CD3DEngine; namespace Ui {
class CCheck : public CControl class CCheck : public CControl
{ {
public: public:
CCheck(CInstanceManager* iMan); CCheck();
virtual ~CCheck(); virtual ~CCheck();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
@ -43,4 +44,5 @@ protected:
protected: protected:
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -15,14 +16,16 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "common/language.h" #include "graphics/engine/engine.h"
#include "old/math3d.h" #include "graphics/core/device.h"
//#include "common/language.h"
//#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -30,7 +33,7 @@
#include "ui/color.h" #include "ui/color.h"
namespace Ui {
const float DELAY1 = 0.4f; const float DELAY1 = 0.4f;
const float DELAY2 = 0.1f; const float DELAY2 = 0.1f;
@ -38,7 +41,8 @@ const float DELAY2 = 0.1f;
// Object's constructor. // Object's constructor.
CColor::CColor(CInstanceManager* iMan) : CControl(iMan) //CColor::CColor(CInstanceManager* iMan) : CControl(iMan)
CColor::CColor() : CControl()
{ {
m_bRepeat = false; m_bRepeat = false;
m_repeat = 0.0f; m_repeat = 0.0f;
@ -58,18 +62,18 @@ CColor::~CColor()
// Creates a new button. // Creates a new button.
bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CColor::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);
if ( icon == -1 ) if ( icon == -1 )
{ {
char name[100]; char name[100];
char* p; char* p;
GetResource(RES_EVENT, eventMsg, name); GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\'); p = strchr(name, '\\');
if ( p != 0 ) *p = 0; if ( p != 0 ) *p = 0;
SetName(name); SetName(name);
@ -87,7 +91,7 @@ bool CColor::EventProcess(const Event &event)
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_FRAME && m_bRepeat ) if ( event.type == EVENT_FRAME && m_bRepeat )
{ {
if ( m_repeat != 0.0f ) if ( m_repeat != 0.0f )
{ {
@ -97,14 +101,15 @@ bool CColor::EventProcess(const Event &event)
m_repeat = DELAY2; m_repeat = DELAY2;
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
} }
} }
if ( event.event == EVENT_LBUTTONDOWN && if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) && (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) ) (m_state & STATE_ENABLE) )
{ {
@ -113,13 +118,13 @@ bool CColor::EventProcess(const Event &event)
m_repeat = DELAY1; m_repeat = DELAY1;
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
} }
if ( event.event == EVENT_LBUTTONUP ) if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1)
{ {
m_repeat = 0.0f; m_repeat = 0.0f;
} }
@ -132,9 +137,9 @@ bool CColor::EventProcess(const Event &event)
void CColor::Draw() void CColor::Draw()
{ {
LPDIRECT3DDEVICE7 device; Gfx::CDevice* device;
D3DLVERTEX vertex[4]; // 2 triangles Gfx::VertexCol vertex[4]; // 2 triangles
D3DCOLOR color; Gfx::Color color;
Math::Point p1, p2; Math::Point p1, p2;
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 ) return;
@ -145,56 +150,57 @@ void CColor::Draw()
} }
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
CControl::Draw(); CControl::Draw();
#if _TEEN #if _TEEN
color = ::RetColor(m_color); // color = GetColor(m_color);
color = GetColor();
m_engine->SetTexture("xxx.tga"); // no texture m_engine->SetTexture("xxx.tga"); // no texture
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
device = m_engine->RetD3DDevice(); device = m_engine->GetDevice();
p1.x = m_pos.x+(4.0f/640.0f); p1.x = m_pos.x + (4.0f / 640.0f);
p1.y = m_pos.y+(4.0f/480.0f); p1.y = m_pos.y + (4.0f / 480.0f);
p2.x = m_pos.x+m_dim.x-(4.0f/640.0f); p2.x = m_pos.x + m_dim.x - (4.0f / 640.0f);
p2.y = m_pos.y+m_dim.y-(4.0f/480.0f); p2.y = m_pos.y + m_dim.y - (4.0f / 480.0f);
vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f); vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
p1.x = m_pos.x+(5.0f/640.0f); p1.x = m_pos.x + (5.0f / 640.0f);
p1.y = m_pos.y+(5.0f/480.0f); p1.y = m_pos.y + (5.0f / 480.0f);
p2.x = m_pos.x+m_dim.x-(5.0f/640.0f); p2.x = m_pos.x + m_dim.x - (5.0f / 640.0f);
p2.y = m_pos.y+m_dim.y-(5.0f/480.0f); p2.y = m_pos.y + m_dim.y - (5.0f / 480.0f);
vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(4); m_engine->AddStatisticTriangle(4);
#else #else
p1.x = m_pos.x+(3.0f/640.0f); p1.x = m_pos.x + (3.0f / 640.0f);
p1.y = m_pos.y+(3.0f/480.0f); p1.y = m_pos.y + (3.0f / 480.0f);
p2.x = m_pos.x+m_dim.x-(3.0f/640.0f); p2.x = m_pos.x + m_dim.x - (3.0f / 640.0f);
p2.y = m_pos.y+m_dim.y-(3.0f/480.0f); p2.y = m_pos.y + m_dim.y - (3.0f / 480.0f);
color = ::RetColor(m_color); color = GetColor();
m_engine->SetTexture("xxx.tga"); // no texture m_engine->SetTexture("xxx.tga"); // no texture
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f));
vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f));
vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f));
vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f); vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f));
device = m_engine->RetD3DDevice(); device = m_engine->GetDevice();
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2); m_engine->AddStatisticTriangle(2);
#endif #endif
} }
@ -205,20 +211,21 @@ void CColor::SetRepeat(bool bRepeat)
m_bRepeat = bRepeat; m_bRepeat = bRepeat;
} }
bool CColor::RetRepeat() bool CColor::GetRepeat()
{ {
return m_bRepeat; return m_bRepeat;
} }
void CColor::SetColor(D3DCOLORVALUE color) void CColor::SetColor(Gfx::Color color)
{ {
m_color = color; m_color = color;
} }
D3DCOLORVALUE CColor::RetColor() Gfx::Color CColor::GetColor()
{ {
return m_color; return m_color;
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -20,37 +21,40 @@
#include "ui/control.h" #include "ui/control.h"
#include "old/d3dengine.h" //#include "graphics/engine/engine.h"
class CD3DEngine;
namespace Gfx{
class CEngine;
struct Color;
}
namespace Ui {
class CColor : public CControl class CColor : public CControl
{ {
public: public:
CColor(CInstanceManager* iMan); // CColor(CInstanceManager* iMan);
virtual ~CColor(); CColor();
virtual ~CColor();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); 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); void SetRepeat(bool bRepeat);
bool RetRepeat(); bool GetRepeat();
void SetColor(D3DCOLORVALUE color); void SetColor(Gfx::Color color);
D3DCOLORVALUE RetColor(); Gfx::Color GetColor();
protected: protected:
protected: protected:
bool m_bRepeat; bool m_bRepeat;
float m_repeat; float m_repeat;
D3DCOLORVALUE m_color; Gfx::Color m_color;
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -15,14 +16,16 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "math/geometry.h" #include "math/geometry.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" #include "graphics/engine/engine.h"
#include "graphics/core/device.h"
//#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -30,10 +33,11 @@
namespace Ui {
// Object's constructor. // Object's constructor.
CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan) //CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan)
CCompass::CCompass() : CControl()
{ {
m_dir = 0.0f; m_dir = 0.0f;
} }
@ -47,11 +51,11 @@ CCompass::~CCompass()
// Creates a new button. // Creates a new button.
bool CCompass::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CCompass::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; return true;
} }
@ -62,12 +66,13 @@ bool CCompass::EventProcess(const Event &event)
{ {
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_LBUTTONDOWN ) if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1)
{ {
if ( CControl::Detect(event.pos) ) if ( CControl::Detect(event.pos) )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
@ -81,33 +86,33 @@ bool CCompass::EventProcess(const Event &event)
void CCompass::Draw() void CCompass::Draw()
{ {
LPDIRECT3DDEVICE7 device; Gfx::CDevice* device;
D3DVERTEX2 vertex[4]; // 2 triangles Gfx::Vertex vertex[4]; // 2 triangles
Math::Point p1, p2, p3, c, uv1, uv2; Math::Point p1, p2, p3, c, uv1, uv2;
Math::Vector n; Math::Vector n;
float dp; float dp;
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 ) return;
device = m_engine->RetD3DDevice(); device = m_engine->GetDevice();
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
p1.x = m_pos.x; p1.x = m_pos.x;
p1.y = m_pos.y; p1.y = m_pos.y;
p2.x = m_pos.x + m_dim.x; p2.x = m_pos.x + m_dim.x;
p2.y = m_pos.y + m_dim.y; p2.y = m_pos.y + m_dim.y;
c.x = (p1.x+p2.x)/2.0f; c.x = (p1.x + p2.x) / 2.0f;
c.y = (p1.y+p2.y)/2.0f; // center c.y = (p1.y + p2.y) / 2.0f; // center
uv1.x = 64.0f/256.0f; uv1.x = 64.0f / 256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f / 256.0f;
uv2.x = 96.0f/256.0f; uv2.x = 96.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
dp = 0.5f/256.0f; dp = 0.5f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -115,46 +120,46 @@ void CCompass::Draw()
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal 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[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y); vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y));
vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y); vertex[3] = Gfx::Vertex(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); m_engine->AddStatisticTriangle(2);
if ( m_state & STATE_ENABLE ) if ( m_state & STATE_ENABLE )
{ {
p1.x = c.x; p1.x = c.x;
p1.y = c.y+m_dim.x*0.40f; p1.y = c.y + m_dim.x * 0.40f;
p1 = Math::RotatePoint(c, m_dir, p1); p1 = Math::RotatePoint(c, m_dir, p1);
p1.x = c.x+(p1.x-c.x)*(m_dim.x/m_dim.y); p1.x = c.x + (p1.x - c.x) * (m_dim.x / m_dim.y);
p2.x = c.x+m_dim.x*0.20f; p2.x = c.x + m_dim.x * 0.20f;
p2.y = c.y-m_dim.x*0.40f; p2.y = c.y - m_dim.x * 0.40f;
p2 = Math::RotatePoint(c, m_dir, p2); p2 = Math::RotatePoint(c, m_dir, p2);
p2.x = c.x+(p2.x-c.x)*(m_dim.x/m_dim.y); p2.x = c.x + (p2.x - c.x) * (m_dim.x / m_dim.y);
p3.x = c.x-m_dim.x*0.20f; p3.x = c.x - m_dim.x * 0.20f;
p3.y = c.y-m_dim.x*0.40f; p3.y = c.y - m_dim.x * 0.40f;
p3 = Math::RotatePoint(c, m_dir, p3); p3 = Math::RotatePoint(c, m_dir, p3);
p3.x = c.x+(p3.x-c.x)*(m_dim.x/m_dim.y); p3.x = c.x + (p3.x - c.x) * (m_dim.x / m_dim.y);
uv1.x = 96.0f/256.0f; uv1.x = 96.0f / 256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f / 256.0f;
uv2.x = 104.0f/256.0f; uv2.x = 104.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y); vertex[1] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y); vertex[2] = Gfx::Vertex(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); m_engine->AddStatisticTriangle(1);
} }
} }
@ -167,9 +172,10 @@ void CCompass::SetDirection(float dir)
m_dir = dir; m_dir = dir;
} }
float CCompass::RetDirection() float CCompass::GetDirection()
{ {
return m_dir; return m_dir;
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -21,25 +22,26 @@
#include "ui/control.h" #include "ui/control.h"
namespace Gfx {
class CEngine;
}
class CD3DEngine; namespace Ui {
class CCompass : public CControl class CCompass : public CControl
{ {
public: public:
CCompass(CInstanceManager* iMan); // CCompass(CInstanceManager* iMan);
CCompass();
virtual ~CCompass(); virtual ~CCompass();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); 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 SetDirection(float dir); void SetDirection(float dir);
float RetDirection(); float GetDirection();
protected: protected:
@ -48,3 +50,4 @@ protected:
}; };
}

View File

@ -1,6 +1,7 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * // * Copyright (C) 2012, Polish Portal of Colobot (PPC)
//
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or // * the Free Software Foundation, either version 3 of the License, or
@ -15,45 +16,50 @@
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h> //#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" #include "graphics/core/device.h"
#include "old/d3dengine.h" //#include "common/struct.h"
//#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
#include "common/language.h" #include "common/language.h"
#include "common/restext.h" #include "common/restext.h"
#include "old/math3d.h" //#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "object/robotmain.h" #include "object/robotmain.h"
#include "old/particule.h" //#include "old/particule.h"
#include "common/misc.h" #include "graphics/engine/particle.h"
#include "common/iman.h" #include "common/iman.h"
#include "old/text.h" //#include "old/text.h"
#include "old/sound.h" #include "graphics/engine/text.h"
//#include "old/sound.h"
#include "sound/sound.h"
#include "ui/control.h" #include "ui/control.h"
namespace Ui {
// Object's constructor. // Object's constructor.
CControl::CControl(CInstanceManager* iMan) CControl::CControl()
{ {
m_iMan = iMan; m_iMan = CInstanceManager::GetInstancePointer();
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = static_cast< Gfx::CEngine* > ( m_iMan->SearchInstance(CLASS_ENGINE) );
m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); m_event = static_cast< CEventQueue* > ( m_iMan->SearchInstance(CLASS_EVENT) );
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); m_main = static_cast< CRobotMain* > ( m_iMan->SearchInstance(CLASS_MAIN) );
m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); m_particle = static_cast< Gfx::CParticle* > (m_iMan->SearchInstance(CLASS_PARTICULE));
m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); m_sound = static_cast< CSoundInterface* > (m_iMan->SearchInstance(CLASS_SOUND));
m_eventMsg = EVENT_NULL; m_eventType = EVENT_NULL;
m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT; m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT;
m_fontSize = SMALLFONT; m_fontSize = Gfx::FONT_SIZE_SMALL;
m_fontStretch = NORMSTRETCH; // m_fontStretch = Gfx::FONT_NORM_STRETCH; //there is font stretching no more master
m_fontType = FONT_COLOBOT; m_fontType = Gfx::FONT_COLOBOT;
m_justif = 0; m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
// m_justif = 0;
m_name[0] = 0; m_name[0] = 0;
m_tooltip[0] = 0; m_tooltip[0] = 0;
m_bFocus = false; m_bFocus = false;
@ -76,23 +82,23 @@ CControl::~CControl()
// Creates a new button. // Creates a new button.
// pos: [0..1] // pos: [0..1]
bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{ {
char text[100]; char text[100];
char* p; char* p;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
m_pos = pos; m_pos = pos;
m_dim = dim; m_dim = dim;
m_icon = icon; m_icon = icon;
m_eventMsg = eventMsg; m_eventType = eventType;
pos.x = m_pos.x; pos.x = m_pos.x;
pos.y = m_pos.y+m_dim.y; pos.y = m_pos.y + m_dim.y;
GlintCreate(pos); GlintCreate(pos);
GetResource(RES_EVENT, m_eventMsg, text); GetResource(RES_EVENT, m_eventType, text);
p = strchr(text, '\\'); p = strchr(text, '\\');
if ( p == 0 ) if ( p == 0 )
{ {
@ -115,11 +121,11 @@ void CControl::SetPos(Math::Point pos)
m_pos = pos; m_pos = pos;
pos.x = m_pos.x; pos.x = m_pos.x;
pos.y = m_pos.y+m_dim.y; pos.y = m_pos.y + m_dim.y;
GlintCreate(pos); GlintCreate(pos);
} }
Math::Point CControl::RetPos() Math::Point CControl::GetPos()
{ {
return m_pos; return m_pos;
} }
@ -131,11 +137,11 @@ void CControl::SetDim(Math::Point dim)
m_dim = dim; m_dim = dim;
pos.x = m_pos.x; pos.x = m_pos.x;
pos.y = m_pos.y+m_dim.y; pos.y = m_pos.y + m_dim.y;
GlintCreate(pos); GlintCreate(pos);
} }
Math::Point CControl::RetDim() Math::Point CControl::GetDim()
{ {
return m_dim; return m_dim;
} }
@ -175,7 +181,7 @@ bool CControl::TestState(int state)
// Returns all attributes of state. // Returns all attributes of state.
int CControl::RetState() int CControl::GetState()
{ {
return m_state; return m_state;
} }
@ -188,7 +194,7 @@ void CControl::SetIcon(int icon)
m_icon = icon; m_icon = icon;
} }
int CControl::RetIcon() int CControl::GetIcon()
{ {
return m_icon; return m_icon;
} }
@ -230,7 +236,7 @@ void CControl::SetName(char* name, bool bTooltip)
} }
} }
char* CControl::RetName() char* CControl::GetName()
{ {
return m_name; return m_name;
} }
@ -238,14 +244,16 @@ char* CControl::RetName()
// Management of the mode of justification (-1,0,1). // Management of the mode of justification (-1,0,1).
void CControl::SetJustif(int mode) void CControl::SetTextAlign(Gfx::TextAlign mode)
{ {
m_justif = mode; m_textAlign = mode;
// m_justif = mode;
} }
int CControl::RetJustif() int CControl::GetTextAlign()
{ {
return m_justif; return m_textAlign;
// return m_justif;
} }
@ -256,7 +264,7 @@ void CControl::SetFontSize(float size)
m_fontSize = size; m_fontSize = size;
} }
float CControl::RetFontSize() float CControl::GetFontSize()
{ {
return m_fontSize; return m_fontSize;
} }
@ -269,7 +277,7 @@ void CControl::SetFontStretch(float stretch)
m_fontStretch = stretch; m_fontStretch = stretch;
} }
float CControl::RetFontStretch() float CControl::GetFontStretch()
{ {
return m_fontStretch; return m_fontStretch;
} }
@ -277,12 +285,12 @@ float CControl::RetFontStretch()
// Choice of the font. // Choice of the font.
void CControl::SetFontType(FontType font) void CControl::SetFontType(Gfx::FontType font)
{ {
m_fontType = font; m_fontType = font;
} }
FontType CControl::RetFontType() Gfx::FontType CControl::GetFontType()
{ {
return m_fontType; return m_fontType;
} }
@ -290,7 +298,7 @@ FontType CControl::RetFontType()
// Specifies the tooltip. // Specifies the tooltip.
bool CControl::SetTooltip(char* name) bool CControl::SetTooltip(const char* name)
{ {
strcpy(m_tooltip, name); strcpy(m_tooltip, name);
return true; return true;
@ -316,7 +324,7 @@ void CControl::SetFocus(bool bFocus)
m_bFocus = bFocus; m_bFocus = bFocus;
} }
bool CControl::RetFocus() bool CControl::GetFocus()
{ {
return m_bFocus; return m_bFocus;
} }
@ -324,9 +332,9 @@ bool CControl::RetFocus()
// Returns the event associated with the control. // Returns the event associated with the control.
EventMsg CControl::RetEventMsg() EventType CControl::GetEventType()
{ {
return m_eventMsg; return m_eventType;
} }
@ -336,21 +344,21 @@ bool CControl::EventProcess(const Event &event)
{ {
if ( m_state & STATE_DEAD ) return true; if ( m_state & STATE_DEAD ) return true;
if ( event.event == EVENT_FRAME && m_bGlint ) if ( event.type == EVENT_FRAME && m_bGlint )
{ {
GlintFrame(event); GlintFrame(event);
} }
if ( event.event == EVENT_MOUSEMOVE ) if ( event.type == EVENT_MOUSE_MOVE )
{ {
m_glintMouse = event.pos; m_glintMouse = event.mouseMove.pos;
if ( Detect(event.pos) ) if ( Detect(event.mouseMove.pos) )
{ {
if ( (m_state & STATE_VISIBLE) && if ( (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE ) ) (m_state & STATE_ENABLE ) )
{ {
m_engine->SetMouseType(D3DMOUSEHAND); m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
} }
SetState(STATE_HILIGHT); SetState(STATE_HILIGHT);
} }
@ -360,7 +368,7 @@ bool CControl::EventProcess(const Event &event)
} }
} }
if ( event.event == EVENT_LBUTTONDOWN ) if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1)
{ {
if ( Detect(event.pos) ) if ( Detect(event.pos) )
{ {
@ -369,7 +377,7 @@ bool CControl::EventProcess(const Event &event)
} }
} }
if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{ {
if ( Detect(event.pos) ) if ( Detect(event.pos) )
{ {
@ -381,7 +389,7 @@ bool CControl::EventProcess(const Event &event)
} }
} }
if ( event.event == EVENT_LBUTTONUP && m_bCapture ) if ( event.type == EVENT_MOUSE_BUTTON_UP && m_bCapture && event.mouseButton.button == 1)
{ {
m_bCapture = false; m_bCapture = false;
ClearState(STATE_PRESS); ClearState(STATE_PRESS);
@ -404,8 +412,8 @@ void CControl::GlintCreate(Math::Point ref, bool bLeft, bool bUp)
{ {
float offset; float offset;
offset = 8.0f/640.0f; offset = 8.0f / 640.0f;
if ( offset > m_dim.x/4.0f) offset = m_dim.x/4.0f; if ( offset > m_dim.x / 4.0f) offset = m_dim.x / 4.0f;
if ( bLeft ) if ( bLeft )
{ {
@ -419,17 +427,17 @@ void CControl::GlintCreate(Math::Point ref, bool bLeft, bool bUp)
} }
offset = 8.0f/480.0f; offset = 8.0f/480.0f;
if ( offset > m_dim.y/4.0f) offset = m_dim.y/4.0f; if ( offset > m_dim.y / 4.0f) offset = m_dim.y / 4.0f;
if ( bUp ) if ( bUp )
{ {
m_glintCorner1.y = ref.y-offset; m_glintCorner1.y = ref.y - offset;
m_glintCorner2.y = ref.y; m_glintCorner2.y = ref.y;
} }
else else
{ {
m_glintCorner1.y = ref.y; m_glintCorner1.y = ref.y;
m_glintCorner2.y = ref.y+offset; m_glintCorner2.y = ref.y + offset;
} }
m_bGlint = true; m_bGlint = true;
@ -452,14 +460,14 @@ void CControl::GlintFrame(const Event &event)
if ( m_glintProgress >= 2.0f && Detect(m_glintMouse) ) if ( m_glintProgress >= 2.0f && Detect(m_glintMouse) )
{ {
pos.x = m_glintCorner1.x + (m_glintCorner2.x-m_glintCorner1.x)*Math::Rand(); pos.x = m_glintCorner1.x + (m_glintCorner2.x - m_glintCorner1.x) * Math::Rand();
pos.y = m_glintCorner1.y + (m_glintCorner2.y-m_glintCorner1.y)*Math::Rand(); pos.y = m_glintCorner1.y + (m_glintCorner2.y - m_glintCorner1.y) * Math::Rand();
pos.z = 0.0f; pos.z = 0.0f;
speed = Math::Vector(0.0f, 0.0f, 0.0f); speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = ((15.0f+Math::Rand()*15.0f)/640.0f); dim.x = ((15.0f + Math::Rand() * 15.0f) / 640.0f);
dim.y = dim.x/0.75f; dim.y = dim.x / 0.75f;
m_particule->CreateParticule(pos, speed, dim, PARTICONTROL, m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICONTROL,
1.0f, 0.0f, 0.0f, SH_INTERFACE); 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE );
m_glintProgress = 0.0f; m_glintProgress = 0.0f;
} }
@ -477,7 +485,7 @@ void CControl::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 ) return;
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
zoomExt = 1.00f; zoomExt = 1.00f;
zoomInt = 0.95f; zoomInt = 0.95f;
@ -537,7 +545,7 @@ void CControl::Draw()
if ( m_name[0] == 0 ) // button without name? if ( m_name[0] == 0 ) // button without name?
{ {
//? DrawPart(icon, zoomExt, 0.0f); //? DrawPart(icon, zoomExt, 0.0f);
DrawPart(icon, zoomExt, 8.0f/256.0f); DrawPart(icon, zoomExt, 8.0f / 256.0f);
if ( m_state & STATE_DEAD ) return; if ( m_state & STATE_DEAD ) return;
@ -550,23 +558,23 @@ void CControl::Draw()
#else #else
m_engine->SetTexture("text.tga"); m_engine->SetTexture("text.tga");
#endif #endif
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
} }
else if ( icon >= 128 ) else if ( icon >= 128 )
{ {
icon -= 128; icon -= 128;
m_engine->SetTexture("button3.tga"); m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
} }
else if ( icon >= 64 ) else if ( icon >= 64 )
{ {
icon -= 64; icon -= 64;
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
} }
else else
{ {
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
} }
if ( icon != -1 ) if ( icon != -1 )
{ {
@ -579,26 +587,28 @@ void CControl::Draw()
if ( m_state & STATE_DEAD ) return; if ( m_state & STATE_DEAD ) return;
if ( m_justif < 0 ) // if ( m_justif < 0 )
if ( m_textAlign == Gfx::TEXT_ALIGN_LEFT )
{ {
pos.x = m_pos.x+m_dim.x-m_dim.y*0.5f; pos.x = m_pos.x + m_dim.x - m_dim.y * 0.5f;
pos.y = m_pos.y+m_dim.y*0.5f; pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2; pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f;
m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
} }
else if ( m_justif > 0 ) else if ( m_textAlign == Gfx::TEXT_ALIGN_RIGHT )
// else if ( m_justif > 0 )
{ {
pos.x = m_pos.x+m_dim.y*0.5f; pos.x = m_pos.x + m_dim.y * 0.5f;
pos.y = m_pos.y+m_dim.y*0.5f; pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f;
m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
} }
else else
{ {
pos.x = m_pos.x+m_dim.x*0.5f; pos.x = m_pos.x + m_dim.x * 0.5f;
pos.y = m_pos.y+m_dim.y*0.5f; pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; pos.y -= m_engine->GetText()->GetHeight( m_fontType, m_fontSize)/2.0f;
m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
} }
} }
} }
@ -618,26 +628,26 @@ void CControl::DrawPart(int icon, float zoom, float ex)
if ( (m_state & STATE_CARD ) && if ( (m_state & STATE_CARD ) &&
(m_state & STATE_CHECK) ) (m_state & STATE_CHECK) )
{ {
p2.y += (2.0f/480.0f); // a bit above p2.y += (2.0f / 480.0f); // a bit above
} }
c.x = (p1.x+p2.x)/2.0f; c.x = (p1.x + p2.x)/2.0f;
c.y = (p1.y+p2.y)/2.0f; // center c.y = (p1.y + p2.y)/2.0f; // center
p1.x = (p1.x-c.x)*zoom + c.x; p1.x = (p1.x - c.x) * zoom + c.x;
p1.y = (p1.y-c.y)*zoom + c.y; p1.y = (p1.y - c.y) * zoom + c.y;
p2.x = (p2.x-c.x)*zoom + c.x; p2.x = (p2.x - c.x) * zoom + c.x;
p2.y = (p2.y-c.y)*zoom + c.y; p2.y = (p2.y - c.y) * zoom + c.y;
p2.x -= p1.x; p2.x -= p1.x;
p2.y -= p1.y; p2.y -= p1.y;
uv1.x = (32.0f/256.0f)*(icon%8); uv1.x = (32.0f / 256.0f) * (icon%8);
uv1.y = (32.0f/256.0f)*(icon/8); // uv texture uv1.y = (32.0f / 256.0f) * (icon/8); // uv texture
uv2.x = (32.0f/256.0f)+uv1.x; uv2.x = (32.0f / 256.0f) + uv1.x;
uv2.y = (32.0f/256.0f)+uv1.y; uv2.y = (32.0f / 256.0f) + uv1.y;
dp = 0.5f/256.0f; dp = 0.5f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -652,12 +662,12 @@ void CControl::DrawPart(int icon, float zoom, float ex)
void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2,
float ex) float ex)
{ {
LPDIRECT3DDEVICE7 device; Gfx::CDevice* device;
D3DVERTEX2 vertex[8]; // 6 triangles Gfx::Vertex vertex[8]; // 6 triangles
Math::Point p1, p2, p3, p4; Math::Point p1, p2, p3, p4;
Math::Vector n; Math::Vector n;
device = m_engine->RetD3DDevice(); device = m_engine->GetDevice();
p1.x = pos.x; p1.x = pos.x;
p1.y = pos.y; p1.y = pos.y;
@ -668,48 +678,48 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
if ( ex == 0.0f ) // one piece? if ( ex == 0.0f ) // one piece?
{ {
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y); vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y); vertex[3] = Gfx::Vertex(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); m_engine->AddStatisticTriangle(2);
} }
else // 3 pieces? else // 3 pieces?
{ {
if ( dim.x >= dim.y ) if ( dim.x >= dim.y )
{ {
p3.x = p1.x + ex*dim.y/(uv2.y-uv1.y); p3.x = p1.x + ex*dim.y / (uv2.y - uv1.y);
p4.x = p2.x - ex*dim.y/(uv2.y-uv1.y); p4.x = p2.x - ex*dim.y / (uv2.y - uv1.y);
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x, uv2.y); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x, uv1.y); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p1.y, 0.0f), n, uv1.x+ex,uv2.y); vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p1.y, 0.0f), n, Math::Point(uv1.x+ex,uv2.y));
vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p2.y, 0.0f), n, uv1.x+ex,uv1.y); vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p2.y, 0.0f), n, Math::Point(uv1.x+ex,uv1.y));
vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p1.y, 0.0f), n, uv2.x-ex,uv2.y); vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p1.y, 0.0f), n, Math::Point(uv2.x-ex,uv2.y));
vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p2.y, 0.0f), n, uv2.x-ex,uv1.y); vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p2.y, 0.0f), n, Math::Point(uv2.x-ex,uv1.y));
vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x, uv2.y); vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y));
vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x, uv1.y); vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6); m_engine->AddStatisticTriangle(6);
} }
else else
{ {
p3.y = p1.y + ex*dim.x/(uv2.x-uv1.x); p3.y = p1.y + ex*dim.x / (uv2.x - uv1.x);
p4.y = p2.y - ex*dim.x/(uv2.x-uv1.x); p4.y = p2.y - ex*dim.x / (uv2.x - uv1.x);
vertex[0] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y ); vertex[0] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y ));
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y ); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y ));
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x,uv2.y-ex); vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex));
vertex[3] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x,uv2.y-ex); vertex[3] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex));
vertex[4] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x,uv1.y+ex); vertex[4] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex));
vertex[5] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x,uv1.y+ex); vertex[5] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex));
vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y ); vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y ));
vertex[7] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y ); vertex[7] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y ));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6); m_engine->AddStatisticTriangle(6);
} }
} }
@ -720,12 +730,12 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2,
Math::Point corner, float ex) Math::Point corner, float ex)
{ {
LPDIRECT3DDEVICE7 device; Gfx::CDevice* device;
D3DVERTEX2 vertex[8]; // 6 triangles Gfx::Vertex vertex[8]; // 6 triangles
Math::Point p1, p2, p3, p4; Math::Point p1, p2, p3, p4;
Math::Vector n; Math::Vector n;
device = m_engine->RetD3DDevice(); device = m_engine->GetDevice();
p1.x = pos.x; p1.x = pos.x;
p1.y = pos.y; p1.y = pos.y;
@ -734,8 +744,8 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
if ( corner.x > dim.x/2.0f ) corner.x = dim.x/2.0f; if ( corner.x > dim.x / 2.0f ) corner.x = dim.x / 2.0f;
if ( corner.y > dim.y/2.0f ) corner.y = dim.y/2.0f; if ( corner.y > dim.y / 2.0f ) corner.y = dim.y / 2.0f;
p1.x = pos.x; p1.x = pos.x;
p1.y = pos.y; p1.y = pos.y;
@ -747,39 +757,39 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
p4.y = p2.y - corner.y; p4.y = p2.y - corner.y;
// Bottom horizontal band. // Bottom horizontal band.
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x, uv2.y ); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y ));
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x, uv2.y-ex); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex));
vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p1.y, 0.0f), n, uv1.x+ex,uv2.y ); vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p1.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y ));
vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x+ex,uv2.y-ex); vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y - ex));
vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p1.y, 0.0f), n, uv2.x-ex,uv2.y ); vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p1.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y ));
vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p3.y, 0.0f), n, uv2.x-ex,uv2.y-ex); vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p3.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y - ex));
vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x, uv2.y ); vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y ));
vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x, uv2.y-ex); vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6); m_engine->AddStatisticTriangle(6);
// Central horizontal band. // Central horizontal band.
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x, uv2.y-ex); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex));
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x, uv1.y+ex); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex));
vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x+ex,uv2.y-ex); vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y - ex));
vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p4.y, 0.0f), n, uv1.x+ex,uv1.y+ex); vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p4.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y + ex));
vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p3.y, 0.0f), n, uv2.x-ex,uv2.y-ex); vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p3.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y - ex));
vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x-ex,uv1.y+ex); vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y + ex));
vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x, uv2.y-ex); vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex));
vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x, uv1.y+ex); vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6); m_engine->AddStatisticTriangle(6);
// Top horizontal band. // Top horizontal band.
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x, uv1.y+ex); vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex));
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x, uv1.y ); vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y ));
vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p4.y, 0.0f), n, uv1.x+ex,uv1.y+ex); vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p4.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y + ex));
vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p2.y, 0.0f), n, uv1.x+ex,uv1.y ); vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p2.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y ));
vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x-ex,uv1.y+ex); vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y + ex));
vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p2.y, 0.0f), n, uv2.x-ex,uv1.y ); vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p2.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y ));
vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x, uv1.y+ex); vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex));
vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x, uv1.y ); vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y ));
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL); device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6); m_engine->AddStatisticTriangle(6);
} }
@ -790,15 +800,15 @@ void CControl::DrawWarning(Math::Point pos, Math::Point dim)
Math::Point uv1, uv2; Math::Point uv1, uv2;
float dp; float dp;
dp = 0.5f/256.0f; dp = 0.5f / 256.0f;
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; uv1.x = 64.0f / 256.0f;
uv1.y = 208.0f/256.0f; uv1.y = 208.0f / 256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f / 256.0f;
uv2.y = 224.0f/256.0f; uv2.y = 224.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
@ -837,27 +847,27 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep)
dp = 0.5f/256.0f; dp = 0.5f/256.0f;
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState( Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x += deep*0.010f*0.75f; pos.x += deep * 0.010f * 0.75f;
pos.y -= deep*0.015f; pos.y -= deep * 0.015f;
dim.x += deep*0.005f*0.75f; dim.x += deep * 0.005f * 0.75f;
dim.y += deep*0.005f; dim.y += deep * 0.005f;
uv1.x = 192.0f/256.0f; uv1.x = 192.0f / 256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f / 256.0f;
uv2.x = 224.0f/256.0f; uv2.x = 224.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 10.0f/640.0f; corner.x = 10.0f / 640.0f;
corner.y = 10.0f/480.0f; corner.y = 10.0f / 480.0f;
DrawIcon(pos, dim, uv1, uv2, corner, 6.0f/256.0f); DrawIcon(pos, dim, uv1, uv2, corner, 6.0f / 256.0f);
} }
@ -865,10 +875,10 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep)
bool CControl::Detect(Math::Point pos) bool CControl::Detect(Math::Point pos)
{ {
return ( pos.x >= m_pos.x && return ( pos.x >= m_pos.x &&
pos.x <= m_pos.x+m_dim.x && pos.x <= m_pos.x + m_dim.x &&
pos.y >= m_pos.y && pos.y >= m_pos.y &&
pos.y <= m_pos.y+m_dim.y ); pos.y <= m_pos.y + m_dim.y );
} }
}

View File

@ -19,19 +19,24 @@
#pragma once #pragma once
#include "old/text.h" //#include "old/text.h"
#include "common/struct.h" #include "graphics/engine/text.h"
//#include "common/struct.h"
#include "common/event.h" #include "common/event.h"
namespace Gfx {
class CEngine;
class CParticle;
};
class CInstanceManager; class CInstanceManager;
class CEvent; class CEvent;
class CD3DEngine; //class Gfx::CEngine;
class CRobotMain; class CRobotMain;
class CParticule; //class Gfx::CParticle;
class CSound; class CSoundInterface;
namespace Ui {
enum ControlState enum ControlState
{ {
STATE_ENABLE = (1<<0), // active STATE_ENABLE = (1<<0), // active
@ -58,42 +63,43 @@ enum ControlState
class CControl class CControl
{ {
public: public:
CControl(CInstanceManager* iMan); // CControl(CInstanceManager* iMan);
CControl ();
virtual ~CControl(); virtual ~CControl();
virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); 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 void SetPos(Math::Point pos);
virtual Math::Point RetPos(); virtual Math::Point GetPos();
virtual void SetDim(Math::Point dim); virtual void SetDim(Math::Point dim);
virtual Math::Point RetDim(); virtual Math::Point GetDim();
virtual bool SetState(int state, bool bState); virtual bool SetState(int state, bool bState);
virtual bool SetState(int state); virtual bool SetState(int state);
virtual bool ClearState(int state); virtual bool ClearState(int state);
virtual bool TestState(int state); virtual bool TestState(int state);
virtual int RetState(); virtual int GetState();
virtual void SetIcon(int icon); virtual void SetIcon(int icon);
virtual int RetIcon(); virtual int GetIcon();
virtual void SetName(char* name, bool bTooltip=true); virtual void SetName(char* name, bool bTooltip=true);
virtual char* RetName(); virtual char* GetName();
virtual void SetJustif(int mode); virtual void SetTextAlign(Gfx::TextAlign mode);
virtual int RetJustif(); virtual int GetTextAlign();
virtual void SetFontSize(float size); virtual void SetFontSize(float size);
virtual float RetFontSize(); virtual float GetFontSize();
virtual void SetFontStretch(float stretch); virtual void SetFontStretch(float stretch);
virtual float RetFontStretch(); virtual float GetFontStretch();
virtual void SetFontType(FontType font); virtual void SetFontType(Gfx::FontType font);
virtual FontType RetFontType(); virtual Gfx::FontType GetFontType();
virtual bool SetTooltip(char* name); virtual bool SetTooltip(const char* name);
virtual bool GetTooltip(Math::Point pos, char* name); virtual bool GetTooltip(Math::Point pos, char* name);
virtual void SetFocus(bool bFocus); virtual void SetFocus(bool bFocus);
virtual bool RetFocus(); virtual bool GetFocus();
virtual EventMsg RetEventMsg(); virtual EventType GetEventType();
virtual void Draw(); virtual void Draw();
protected: protected:
void GlintDelete(); void GlintDelete();
@ -108,31 +114,33 @@ protected:
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CD3DEngine* m_engine; Gfx::CEngine* m_engine;
CEvent* m_event; CEventQueue* m_event;
CRobotMain* m_main; CRobotMain* m_main;
CParticule* m_particule; Gfx::CParticle* m_particle;
CSound* m_sound; CSoundInterface* m_sound;
Math::Point m_pos; // corner upper / left Math::Point m_pos; // corner upper / left
Math::Point m_dim; // dimensions Math::Point m_dim; // dimensions
int m_icon; int m_icon;
EventMsg m_eventMsg; // message to send when clicking EventType m_eventType; // message to send when clicking
int m_state; // states (STATE_ *) int m_state; // states (STATE_ *)
float m_fontSize; // size of the button name float m_fontSize; // size of the button name
float m_fontStretch; // stretch of the font float m_fontStretch; // stretch of the font
FontType m_fontType; // type of font Gfx::FontType m_fontType; // type of font
int m_justif; // type of justification (-1,0,1) Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
char m_name[100]; // name of the button // int m_justif; // type of justification (-1,0,1)
char m_tooltip[100]; // name of tooltip char m_name[100]; // name of the button
bool m_bFocus; char m_tooltip[100]; // name of tooltip
bool m_bCapture; bool m_bFocus;
bool m_bCapture;
bool m_bGlint; bool m_bGlint;
Math::Point m_glintCorner1; Math::Point m_glintCorner1;
Math::Point m_glintCorner2; Math::Point m_glintCorner2;
float m_glintProgress; float m_glintProgress;
Math::Point m_glintMouse; Math::Point m_glintMouse;
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,21 +18,22 @@
// displayinfo.cpp // displayinfo.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/d3dmath.h" //#include "old/d3dmath.h"
#include "graphics/engine/engine.h"
#include "common/language.h" #include "common/language.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
#include "common/restext.h" #include "common/restext.h"
#include "old/math3d.h" //#include "old/math3d.h"
#include "object/robotmain.h" #include "object/robotmain.h"
#include "old/camera.h" //#include "old/camera.h"
#include "object/object.h" #include "object/object.h"
#include "object/motion/motion.h" #include "object/motion/motion.h"
#include "object/motion/motiontoto.h" #include "object/motion/motiontoto.h"
@ -41,29 +43,31 @@
#include "ui/edit.h" #include "ui/edit.h"
#include "ui/group.h" #include "ui/group.h"
#include "ui/window.h" #include "ui/window.h"
#include "old/particule.h" //#include "old/particule.h"
#include "old/light.h" #include "graphics/engine/particle.h"
#include "old/text.h" //#include "old/light.h"
//#include "old/text.h"
#include "script/cbottoken.h" #include "script/cbottoken.h"
#include "ui/displayinfo.h" #include "ui/displayinfo.h"
namespace Ui {
// Object's constructor. // Object's constructor.
CDisplayInfo::CDisplayInfo(CInstanceManager* iMan) //CDisplayInfo::CDisplayInfo(CInstanceManager* iMan)
CDisplayInfo::CDisplayInfo()
{ {
m_iMan = iMan; m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_STUDIO, this); m_iMan->AddInstance(CLASS_STUDIO, this);
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = static_cast <Gfx::CEngine*> (m_iMan->SearchInstance(CLASS_ENGINE));
m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT); m_event = static_cast <CEventQueue*> (m_iMan->SearchInstance(CLASS_EVENT));
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); m_interface = static_cast <CInterface*> (m_iMan->SearchInstance(CLASS_INTERFACE));
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN); m_main = static_cast <CRobotMain*> (m_iMan->SearchInstance(CLASS_MAIN));
m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA); m_camera = static_cast <Gfx::CCamera*> (m_iMan->SearchInstance(CLASS_CAMERA));
m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE); m_particle = static_cast <Gfx::CParticle*> (m_iMan->SearchInstance(CLASS_PARTICULE));
m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT); m_light = static_cast <Gfx::CLight*> (m_iMan->SearchInstance(CLASS_LIGHT));
m_bInfoMaximized = true; m_bInfoMaximized = true;
m_bInfoMinimized = false; m_bInfoMinimized = false;
@ -87,22 +91,22 @@ CDisplayInfo::~CDisplayInfo()
bool CDisplayInfo::EventProcess(const Event &event) bool CDisplayInfo::EventProcess(const Event &event)
{ {
CWindow* pw; Ui::CWindow* pw;
CEdit* edit; Ui::CEdit* edit;
CSlider* slider; Ui::CSlider* slider;
CMotionToto* toto; CMotionToto* toto;
if ( event.event == EVENT_FRAME ) if ( event.type == EVENT_FRAME )
{ {
EventFrame(event); EventFrame(event);
HyperUpdate(); HyperUpdate();
} }
if ( event.event == EVENT_MOUSEMOVE ) if ( event.type == EVENT_MOUSE_MOVE )
{ {
if ( m_toto != 0 ) if ( m_toto != 0 )
{ {
toto = (CMotionToto*)m_toto->RetMotion(); toto = static_cast<CMotionToto*>(m_toto->GetMotion());
if ( toto != 0 ) if ( toto != 0 )
{ {
toto->SetMousePos(event.pos); toto->SetMousePos(event.pos);
@ -110,21 +114,21 @@ bool CDisplayInfo::EventProcess(const Event &event)
} }
} }
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 ) if ( pw != 0 )
{ {
if ( event.event == pw->RetEventMsgClose() ) if ( event.type == pw->GetEventTypeClose() )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = EVENT_OBJECT_INFOOK; newEvent.type = EVENT_OBJECT_INFOOK;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
if ( event.event == EVENT_SATCOM_HUSTON ) if ( event.type == EVENT_SATCOM_HUSTON )
{ {
ChangeIndexButton(SATCOM_HUSTON); ChangeIndexButton(SATCOM_HUSTON);
} }
if ( event.event == EVENT_SATCOM_SAT ) if ( event.type == EVENT_SATCOM_SAT )
{ {
ChangeIndexButton(SATCOM_SAT); ChangeIndexButton(SATCOM_SAT);
} }
@ -132,90 +136,90 @@ bool CDisplayInfo::EventProcess(const Event &event)
//? { //? {
//? ChangeIndexButton(SATCOM_OBJECT); //? ChangeIndexButton(SATCOM_OBJECT);
//? } //? }
if ( event.event == EVENT_SATCOM_LOADING ) if ( event.type == EVENT_SATCOM_LOADING )
{ {
ChangeIndexButton(SATCOM_LOADING); ChangeIndexButton(SATCOM_LOADING);
} }
if ( event.event == EVENT_SATCOM_PROG ) if ( event.type == EVENT_SATCOM_PROG )
{ {
ChangeIndexButton(SATCOM_PROG); ChangeIndexButton(SATCOM_PROG);
} }
if ( event.event == EVENT_SATCOM_SOLUCE ) if ( event.type == EVENT_SATCOM_SOLUCE )
{ {
ChangeIndexButton(SATCOM_SOLUCE); ChangeIndexButton(SATCOM_SOLUCE);
} }
if ( event.event == EVENT_HYPER_HOME || if ( event.type == EVENT_HYPER_HOME ||
event.event == EVENT_HYPER_PREV || event.type == EVENT_HYPER_PREV ||
event.event == EVENT_HYPER_NEXT ) event.type == EVENT_HYPER_NEXT )
{ {
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 ) if ( edit != 0 )
{ {
edit->HyperGo(event.event); edit->HyperGo(event.type);
HyperUpdate(); HyperUpdate();
} }
} }
if ( event.event == EVENT_HYPER_SIZE1 ) // size 1? if ( event.type == EVENT_HYPER_SIZE1 ) // size 1?
{ {
m_main->SetFontSize(9.0f); m_main->SetFontSize(9.0f);
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo(); ViewDisplayInfo();
} }
if ( event.event == EVENT_HYPER_SIZE2 ) // size 2? if ( event.type == EVENT_HYPER_SIZE2 ) // size 2?
{ {
m_main->SetFontSize(10.0f); m_main->SetFontSize(10.0f);
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo(); ViewDisplayInfo();
} }
if ( event.event == EVENT_HYPER_SIZE3 ) // size 3? if ( event.type == EVENT_HYPER_SIZE3 ) // size 3?
{ {
m_main->SetFontSize(12.0f); m_main->SetFontSize(12.0f);
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo(); ViewDisplayInfo();
} }
if ( event.event == EVENT_HYPER_SIZE4 ) // size 4? if ( event.type == EVENT_HYPER_SIZE4 ) // size 4?
{ {
m_main->SetFontSize(15.0f); m_main->SetFontSize(15.0f);
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f); if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo(); ViewDisplayInfo();
} }
if ( event.event == EVENT_STUDIO_SIZE ) // size? if ( event.type == EVENT_STUDIO_SIZE ) // size?
{ {
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider == 0 ) return false; if ( slider == 0 ) return false;
m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f); m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f);
ViewDisplayInfo(); ViewDisplayInfo();
} }
if ( event.event == EVENT_HYPER_COPY ) // copy ? if ( event.type == EVENT_HYPER_COPY ) // copy ?
{ {
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 ) if ( edit != 0 )
{ {
edit->Copy(); edit->Copy();
} }
} }
if ( event.event == EVENT_LBUTTONDOWN || if ( ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 )||
event.event == EVENT_LBUTTONUP ) ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 ))
{ {
UpdateCopyButton(); UpdateCopyButton();
} }
if ( event.event == EVENT_WINDOW4 ) // window moved? if ( event.type == EVENT_WINDOW4 ) // window moved?
{ {
m_infoNormalPos = m_infoActualPos = m_infoFinalPos = pw->RetPos(); m_infoNormalPos = m_infoActualPos = m_infoFinalPos = pw->GetPos();
m_infoNormalDim = m_infoActualDim = m_infoFinalDim = pw->RetDim(); m_infoNormalDim = m_infoActualDim = m_infoFinalDim = pw->GetDim();
AdjustDisplayInfo(m_infoActualPos, m_infoActualDim); AdjustDisplayInfo(m_infoActualPos, m_infoActualDim);
} }
if ( event.event == pw->RetEventMsgReduce() ) if ( event.type == pw->GetEventTypeReduce() )
{ {
if ( m_bInfoMinimized ) if ( m_bInfoMinimized )
{ {
@ -241,7 +245,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
pw->SetMinimized(m_bInfoMinimized); pw->SetMinimized(m_bInfoMinimized);
} }
} }
if ( event.event == pw->RetEventMsgFull() ) if ( event.type == pw->GetEventTypeFull() )
{ {
if ( m_bInfoMaximized ) if ( m_bInfoMaximized )
{ {
@ -260,7 +264,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
m_bInfoMaximized = true; m_bInfoMaximized = true;
} }
//? m_main->SetEditFull(m_bInfoMaximized); //? m_main->SetEditFull(m_bInfoMaximized);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 ) if ( pw != 0 )
{ {
pw->SetMaximized(m_bInfoMaximized); pw->SetMaximized(m_bInfoMaximized);
@ -299,31 +303,31 @@ bool CDisplayInfo::EventFrame(const Event &event)
void CDisplayInfo::HyperUpdate() void CDisplayInfo::HyperUpdate()
{ {
CWindow* pw; Ui::CWindow* pw;
CEdit* edit; Ui::CEdit* edit;
CButton* button; Ui::CButton* button;
bool bEnable; bool bEnable;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return; if ( pw == 0 ) return;
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return; if ( edit == 0 ) return;
button = (CButton*)pw->SearchControl(EVENT_HYPER_HOME); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_HOME));
if ( button != 0 ) if ( button != 0 )
{ {
bEnable = edit->HyperTest(EVENT_HYPER_HOME); bEnable = edit->HyperTest(EVENT_HYPER_HOME);
button->SetState(STATE_ENABLE, bEnable); button->SetState(STATE_ENABLE, bEnable);
} }
button = (CButton*)pw->SearchControl(EVENT_HYPER_PREV); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_PREV));
if ( button != 0 ) if ( button != 0 )
{ {
bEnable = edit->HyperTest(EVENT_HYPER_PREV); bEnable = edit->HyperTest(EVENT_HYPER_PREV);
button->SetState(STATE_ENABLE, bEnable); button->SetState(STATE_ENABLE, bEnable);
} }
button = (CButton*)pw->SearchControl(EVENT_HYPER_NEXT); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_NEXT));
if ( button != 0 ) if ( button != 0 )
{ {
bEnable = edit->HyperTest(EVENT_HYPER_NEXT); bEnable = edit->HyperTest(EVENT_HYPER_NEXT);
@ -336,12 +340,12 @@ void CDisplayInfo::HyperUpdate()
void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce) void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
{ {
D3DLIGHT7 light; Gfx::CLight light;
Math::Point pos, dim; Math::Point pos, dim;
CWindow* pw; Ui::CWindow* pw;
CEdit* edit; Ui::CEdit* edit;
CButton* button; Ui::CButton* button;
CSlider* slider; Ui::CSlider* slider;
CMotionToto* toto; CMotionToto* toto;
m_index = index; m_index = index;
@ -349,10 +353,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
//? CreateObjectsFile(); //? CreateObjectsFile();
m_bEditLock = m_main->RetEditLock(); m_bEditLock = m_main->GetEditLock();
if ( m_bEditLock ) // edition running program? if ( m_bEditLock ) // edition running program?
{ {
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw != 0 ) if ( pw != 0 )
{ {
pw->ClearState(STATE_ENABLE); // CStudio inactive pw->ClearState(STATE_ENABLE); // CStudio inactive
@ -361,10 +365,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
m_main->SetEditLock(true, false); m_main->SetEditLock(true, false);
m_main->SetEditFull(false); m_main->SetEditFull(false);
m_bInitPause = m_engine->RetPause(); m_bInitPause = m_engine->GetPause();
m_engine->SetPause(true); m_engine->SetPause(true);
m_infoCamera = m_camera->RetType(); m_infoCamera = m_camera->GetType();
m_camera->SetType(CAMERA_INFO); m_camera->SetType(Gfx::CAM_TYPE_INFO);
pos = m_infoActualPos = m_infoFinalPos; pos = m_infoActualPos = m_infoFinalPos;
dim = m_infoActualDim = m_infoFinalDim; dim = m_infoActualDim = m_infoFinalDim;
@ -383,7 +387,7 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
edit->SetState(STATE_SHADOW); edit->SetState(STATE_SHADOW);
edit->SetMultiFont(true); edit->SetMultiFont(true);
edit->SetMaxChar(10000); edit->SetMaxChar(10000);
edit->SetFontType(FONT_COLOBOT); edit->SetFontType(Gfx::FONT_COLOBOT);
edit->SetSoluceMode(bSoluce); edit->SetSoluceMode(bSoluce);
edit->ReadText(filename); edit->ReadText(filename);
edit->HyperHome(filename); edit->HyperHome(filename);
@ -447,20 +451,20 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
m_engine->SetDrawWorld(false); // doesn't draw anything in the interface m_engine->SetDrawWorld(false); // doesn't draw anything in the interface
m_engine->SetDrawFront(true); // toto draws on the interface m_engine->SetDrawFront(true); // toto draws on the interface
m_particule->SetFrameUpdate(SH_WORLD, false); // particles break into world m_particle->SetFrameUpdate(Gfx::SH_WORLD, false); // particles break into world
m_toto = SearchToto(); m_toto = SearchToto();
if ( m_toto != 0 ) if ( m_toto != 0 )
{ {
m_toto->SetDrawFront(true); m_toto->SetDrawFront(true);
toto = (CMotionToto*)m_toto->RetMotion(); toto = static_cast<CMotionToto*>(m_toto->GetMotion());
if ( toto != 0 ) if ( toto != 0 )
{ {
toto->StartDisplayInfo(); toto->StartDisplayInfo();
} }
} }
// TODO
ZeroMemory(&light, sizeof(light)); ZeroMemory(&light, sizeof(light));
light.dltType = D3DLIGHT_DIRECTIONAL; light.dltType = D3DLIGHT_DIRECTIONAL;
light.dcvDiffuse.r = 1.0f; light.dcvDiffuse.r = 1.0f;
@ -483,31 +487,31 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim)
CGroup* group; CGroup* group;
Math::Point pos, dim; Math::Point pos, dim;
wpos.x = 50.0f/640.0f; wpos.x = 50.0f / 640.0f;
wpos.y = 30.0f/480.0f; wpos.y = 30.0f / 480.0f;
wdim.x = 540.0f/640.0f; wdim.x = 540.0f / 640.0f;
wdim.y = 420.0f/480.0f; wdim.y = 420.0f / 480.0f;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 ) if ( pw != 0 )
{ {
pw->SetPos(wpos); pw->SetPos(wpos);
pw->SetDim(wdim); pw->SetDim(wdim);
wdim = pw->RetDim(); wdim = pw->GetDim();
} }
pos.x = (50.0f+10.0f)/640.0f; pos.x = (50.0f + 10.0f) / 640.0f;
pos.y = (30.0f+10.0f+24.0f+10.0f+324.0f-48.0f)/480.0f; pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f - 48.0f) / 480.0f;
dim.x = 48.0f/640.0f; dim.x = 48.0f / 640.0f;
dim.y = 48.0f/480.0f; dim.y = 48.0f / 480.0f;
button = (CButton*)pw->SearchControl(EVENT_SATCOM_HUSTON); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_HUSTON));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.y -= (48.0f+4.0f)/480.0f; pos.y -= (48.0f + 4.0f) / 480.0f;
button = (CButton*)pw->SearchControl(EVENT_SATCOM_SAT); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SAT));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
@ -520,136 +524,136 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim)
//? button->SetPos(pos); //? button->SetPos(pos);
//? button->SetDim(dim); //? button->SetDim(dim);
//? } //? }
pos.y -= (48.0f+4.0f)/480.0f; pos.y -= (48.0f + 4.0f) / 480.0f;
button = (CButton*)pw->SearchControl(EVENT_SATCOM_LOADING); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_LOADING));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.y -= (48.0f+4.0f)/480.0f; pos.y -= (48.0f + 4.0f) / 480.0f;
button = (CButton*)pw->SearchControl(EVENT_SATCOM_PROG); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_PROG));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.y -= (48.0f+4.0f)/480.0f; pos.y -= (48.0f + 4.0f) / 480.0f;
button = (CButton*)pw->SearchControl(EVENT_SATCOM_SOLUCE); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SOLUCE));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x = (50.0f+10.0f+5.0f)/640.0f; pos.x = (50.0f + 10.0f + 5.0f) / 640.0f;
pos.y = (30.0f+10.0f+4.0f)/480.0f; pos.y = (30.0f + 10.0f + 4.0f) / 480.0f;
dim.x = (48.0f-10.0f)/640.0f; dim.x = (48.0f - 10.0f) / 640.0f;
dim.y = 24.0f/480.0f; dim.y = 24.0f / 480.0f;
button = (CButton*)pw->SearchControl(EVENT_OBJECT_INFOOK); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_OBJECT_INFOOK));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x = (50.0f+10.0f+48.0f+10.0f)/640.0f; pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f;
pos.y = (30.0f+10.0f)/480.0f; pos.y = (30.0f + 10.0f) / 480.0f;
dim.x = 462.0f/640.0f; dim.x = 462.0f / 640.0f;
dim.y = 358.0f/480.0f; dim.y = 358.0f / 480.0f;
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 ) if ( edit != 0 )
{ {
edit->SetPos(pos); edit->SetPos(pos);
edit->SetDim(dim); edit->SetDim(dim);
} }
pos.x = (50.0f+10.0f+48.0f+10.0f)/640.0f; pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f;
pos.y = (30.0f+10.0f+358.0f+10.0f)/480.0f; pos.y = (30.0f + 10.0f + 358.0f + 10.0f) / 480.0f;
dim.x = 32.0f/640.0f; dim.x = 32.0f / 640.0f;
dim.y = 32.0f/480.0f; dim.y = 32.0f / 480.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_PREV); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_PREV));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x += 35.0f/640.0f; pos.x += 35.0f / 640.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_NEXT); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_NEXT));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x += 35.0f/640.0f; pos.x += 35.0f / 640.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_HOME); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_HOME));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x += 50.0f/640.0f; pos.x += 50.0f / 640.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE1); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE1));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x += 35.0f/640.0f; pos.x += 35.0f / 640.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE2); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE2));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x += 35.0f/640.0f; pos.x += 35.0f / 640.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE3); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE3));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x += 35.0f/640.0f; pos.x += 35.0f / 640.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE4); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE4));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x += 35.0f/640.0f; pos.x += 35.0f / 640.0f;
dim.x = 18.0f/640.0f; dim.x = 18.0f / 640.0f;
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider != 0 ) if ( slider != 0 )
{ {
slider->SetPos(pos); slider->SetPos(pos);
slider->SetDim(dim); slider->SetDim(dim);
} }
pos.x += 50.0f/640.0f; pos.x += 50.0f / 640.0f;
dim.x = 32.0f/640.0f; dim.x = 32.0f / 640.0f;
button = (CButton*)pw->SearchControl(EVENT_HYPER_COPY); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_COPY));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetPos(pos); button->SetPos(pos);
button->SetDim(dim); button->SetDim(dim);
} }
pos.x = (50.0f+10.0f)/640.0f; pos.x = (50.0f + 10.0f) / 640.0f;
pos.y = (30.0f+10.0f+24.0f+10.0f+324.0f+6.0f)/480.0f; pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f + 6.0f) / 480.0f;
dim.x = 48.0f/640.0f; dim.x = 48.0f / 640.0f;
dim.y = 40.0f/480.0f; dim.y = 40.0f / 480.0f;
group = (CGroup*)pw->SearchControl(EVENT_LABEL2); // symbol SatCom group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL2)); // symbol SatCom
if ( group != 0 ) if ( group != 0 )
{ {
group->SetPos(pos); group->SetPos(pos);
group->SetDim(dim); group->SetDim(dim);
} }
pos.x = (50.0f+10.0f+14.0f)/640.0f; pos.x = (50.0f + 10.0f + 14.0f) / 640.0f;
pos.y = (30.0f+10.0f+6.0f)/480.0f; pos.y = (30.0f + 10.0f + 6.0f) / 480.0f;
dim.x = 20.0f/640.0f; dim.x = 20.0f / 640.0f;
dim.y = 20.0f/480.0f; dim.y = 20.0f / 480.0f;
group = (CGroup*)pw->SearchControl(EVENT_LABEL3); // symbol stand-by group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL3)); // symbol stand-by
if ( group != 0 ) if ( group != 0 )
{ {
group->SetPos(pos); group->SetPos(pos);
@ -661,26 +665,26 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim)
void CDisplayInfo::ChangeIndexButton(int index) void CDisplayInfo::ChangeIndexButton(int index)
{ {
CWindow* pw; Ui::CWindow* pw;
CEdit* edit; Ui::CEdit* edit;
char* filename; char* filename;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return; if ( pw == 0 ) return;
if ( m_index != -1 ) if ( m_index != -1 )
{ {
m_main->SetDisplayInfoPosition(m_index, RetPosition()); m_main->SetDisplayInfoPosition(m_index, GetPosition());
} }
m_index = index; m_index = index;
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 ) if ( edit != 0 )
{ {
filename = m_main->RetDisplayInfoName(m_index); filename = m_main->GetDisplayInfoName(m_index);
edit->ReadText(filename); edit->ReadText(filename);
edit->HyperHome(filename); edit->HyperHome(filename);
SetPosition(m_main->RetDisplayInfoPosition(m_index)); SetPosition(m_main->GetDisplayInfoPosition(m_index));
} }
UpdateIndexButton(); UpdateIndexButton();
@ -690,10 +694,10 @@ void CDisplayInfo::ChangeIndexButton(int index)
void CDisplayInfo::UpdateIndexButton() void CDisplayInfo::UpdateIndexButton()
{ {
CWindow* pw; Ui::CWindow* pw;
CButton* button; Ui::CButton* button;
CGroup* group; Ui::CGroup* group;
CEdit* edit; Ui::CEdit* edit;
Math::Point pos, dim; Math::Point pos, dim;
char* filename; char* filename;
char* loading; char* loading;
@ -708,10 +712,10 @@ void CDisplayInfo::UpdateIndexButton()
4, // SATCOM_SOLUCE 4, // SATCOM_SOLUCE
}; };
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return; if ( pw == 0 ) return;
button = (CButton*)pw->SearchControl(EVENT_SATCOM_HUSTON); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_HUSTON));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetState(STATE_CHECK, m_index==SATCOM_HUSTON); button->SetState(STATE_CHECK, m_index==SATCOM_HUSTON);
@ -719,7 +723,7 @@ void CDisplayInfo::UpdateIndexButton()
button->SetState(STATE_VISIBLE, filename[0]!=0); button->SetState(STATE_VISIBLE, filename[0]!=0);
} }
button = (CButton*)pw->SearchControl(EVENT_SATCOM_SAT); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SAT));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetState(STATE_CHECK, m_index==SATCOM_SAT); button->SetState(STATE_CHECK, m_index==SATCOM_SAT);
@ -736,7 +740,7 @@ void CDisplayInfo::UpdateIndexButton()
//? } //? }
loading = 0; loading = 0;
button = (CButton*)pw->SearchControl(EVENT_SATCOM_LOADING); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_LOADING));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetState(STATE_CHECK, m_index==SATCOM_LOADING); button->SetState(STATE_CHECK, m_index==SATCOM_LOADING);
@ -744,7 +748,7 @@ void CDisplayInfo::UpdateIndexButton()
button->SetState(STATE_VISIBLE, loading[0]!=0); button->SetState(STATE_VISIBLE, loading[0]!=0);
} }
button = (CButton*)pw->SearchControl(EVENT_SATCOM_PROG); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_PROG));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetState(STATE_CHECK, m_index==SATCOM_PROG); button->SetState(STATE_CHECK, m_index==SATCOM_PROG);
@ -752,7 +756,7 @@ void CDisplayInfo::UpdateIndexButton()
button->SetState(STATE_VISIBLE, filename[0]!=0 && (m_index==SATCOM_LOADING||m_index==SATCOM_PROG||(loading!=0&&loading[0]==0))); button->SetState(STATE_VISIBLE, filename[0]!=0 && (m_index==SATCOM_LOADING||m_index==SATCOM_PROG||(loading!=0&&loading[0]==0)));
} }
button = (CButton*)pw->SearchControl(EVENT_SATCOM_SOLUCE); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SOLUCE));
if ( button != 0 ) if ( button != 0 )
{ {
button->SetState(STATE_CHECK, m_index==SATCOM_SOLUCE); button->SetState(STATE_CHECK, m_index==SATCOM_SOLUCE);
@ -760,7 +764,7 @@ void CDisplayInfo::UpdateIndexButton()
button->SetState(STATE_VISIBLE, filename[0]!=0 && m_bSoluce); button->SetState(STATE_VISIBLE, filename[0]!=0 && m_bSoluce);
} }
group = (CGroup*)pw->SearchControl(EVENT_LABEL1); group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL1));
if ( group != 0 ) if ( group != 0 )
{ {
if ( m_index == -1 ) if ( m_index == -1 )
@ -789,7 +793,7 @@ void CDisplayInfo::UpdateIndexButton()
} }
#endif #endif
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 ) if ( edit != 0 )
{ {
//? edit->SetHiliteCap(m_index==SATCOM_LOADING); //? edit->SetHiliteCap(m_index==SATCOM_LOADING);
@ -803,20 +807,20 @@ void CDisplayInfo::UpdateIndexButton()
void CDisplayInfo::UpdateCopyButton() void CDisplayInfo::UpdateCopyButton()
{ {
CWindow* pw; Ui::CWindow* pw;
CButton* button; Ui::CButton* button;
CEdit* edit; Ui::CEdit* edit;
int c1, c2; int c1, c2;
//? if ( m_index != SATCOM_LOADING ) return; //? if ( m_index != SATCOM_LOADING ) return;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return; if ( pw == 0 ) return;
button = (CButton*)pw->SearchControl(EVENT_HYPER_COPY); button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_COPY));
if ( button == 0 ) return; if ( button == 0 ) return;
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return; if ( edit == 0 ) return;
edit->GetCursor(c1, c2); edit->GetCursor(c1, c2);
@ -828,10 +832,10 @@ void CDisplayInfo::UpdateCopyButton()
void CDisplayInfo::StopDisplayInfo() void CDisplayInfo::StopDisplayInfo()
{ {
CWindow* pw; Ui::CWindow* pw;
CMotionToto* toto; CMotionToto* toto;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return; if ( pw == 0 ) return;
m_interface->DeleteControl(EVENT_WINDOW4); m_interface->DeleteControl(EVENT_WINDOW4);
@ -853,13 +857,13 @@ void CDisplayInfo::StopDisplayInfo()
m_engine->SetDrawWorld(true); // draws all on the interface m_engine->SetDrawWorld(true); // draws all on the interface
m_engine->SetDrawFront(false); // draws nothing on the interface m_engine->SetDrawFront(false); // draws nothing on the interface
m_particule->SetFrameUpdate(SH_WORLD, true); m_particle->SetFrameUpdate(Gfx::SH_WORLD, true);
m_particule->FlushParticule(SH_FRONT); m_particle->FlushParticule(Gfx::SH_FRONT);
m_particule->FlushParticule(SH_INTERFACE); m_particle->FlushParticule(Gfx::SH_INTERFACE);
if ( m_toto != 0 ) if ( m_toto != 0 )
{ {
toto = (CMotionToto*)m_toto->RetMotion(); toto = (CMotionToto*)m_toto->GetMotion();
if ( toto != 0 ) if ( toto != 0 )
{ {
toto->StopDisplayInfo(); toto->StopDisplayInfo();
@ -875,13 +879,13 @@ void CDisplayInfo::StopDisplayInfo()
void CDisplayInfo::SetPosition(int pos) void CDisplayInfo::SetPosition(int pos)
{ {
CWindow* pw; Ui::CWindow* pw;
CEdit* edit; Ui::CEdit* edit;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return; if ( pw == 0 ) return;
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return; if ( edit == 0 ) return;
edit->SetFirstLine(pos); edit->SetFirstLine(pos);
@ -889,18 +893,18 @@ void CDisplayInfo::SetPosition(int pos)
// Returns the position. // Returns the position.
int CDisplayInfo::RetPosition() int CDisplayInfo::GetPosition()
{ {
CWindow* pw; Ui::CWindow* pw;
CEdit* edit; Ui::CEdit* edit;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return 0; if ( pw == 0 ) return 0;
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return 0; if ( edit == 0 ) return 0;
return edit->RetFirstLine(); return edit->GetFirstLine();
} }
@ -909,18 +913,18 @@ int CDisplayInfo::RetPosition()
void CDisplayInfo::ViewDisplayInfo() void CDisplayInfo::ViewDisplayInfo()
{ {
CWindow* pw; Ui::CWindow* pw;
CEdit* edit; Ui::CEdit* edit;
POINT dim; Math::Point dim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return; if ( pw == 0 ) return;
edit = (CEdit*)pw->SearchControl(EVENT_EDIT1); edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return; if ( edit == 0 ) return;
dim = m_engine->RetDim(); dim = m_engine->GetDim();
edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f)); edit->SetFontSize(m_main->GetFontSize()/(dim.x / 640.0f));
} }
// Returns the object human. // Returns the object human.
@ -936,7 +940,7 @@ CObject* CDisplayInfo::SearchToto()
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
if ( pObj == 0 ) break; if ( pObj == 0 ) break;
type = pObj->RetType(); type = pObj->GetType();
if ( type == OBJECT_TOTO ) if ( type == OBJECT_TOTO )
{ {
return pObj; return pObj;
@ -995,7 +999,7 @@ void ObjectWrite(FILE* file, ObjectList list[], int i)
strcat(line, res); strcat(line, res);
strcat(line, "\\u "); strcat(line, "\\u ");
p = RetHelpFilename(list[i].type); p = GetHelpFilename(list[i].type);
if ( p[0] == 0 ) return; if ( p[0] == 0 ) return;
strcat(line, p+5); // skip "help\" strcat(line, p+5); // skip "help\"
p = strstr(line, ".txt"); p = strstr(line, ".txt");
@ -1026,11 +1030,11 @@ void CDisplayInfo::CreateObjectsFile()
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
if ( pObj == 0 ) break; if ( pObj == 0 ) break;
if ( !pObj->RetActif() ) continue; if ( !pObj->GetActif() ) continue;
if ( !pObj->RetSelectable() ) continue; if ( !pObj->GetSelectable() ) continue;
if ( pObj->RetProxyActivate() ) continue; if ( pObj->GetProxyActivate() ) continue;
type = pObj->RetType(); type = pObj->GetType();
if ( type == OBJECT_NULL ) continue; if ( type == OBJECT_NULL ) continue;
if ( type == OBJECT_FIX ) continue; if ( type == OBJECT_FIX ) continue;
@ -1217,3 +1221,4 @@ void CDisplayInfo::CreateObjectsFile()
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -24,20 +25,29 @@
class CInstanceManager; class CInstanceManager;
class CD3DEngine; //class CD3DEngine;
class CEvent; class CEvent;
class CRobotMain; class CRobotMain;
class CCamera; //class CCamera;
class CInterface;
class CObject;
class CParticule;
class CLight;
class CObject;
//class CLight;
namespace Gfx {
class CEngine;
class Camera;
class Particle;
class CLight;
}
namespace Ui {
class CInterface;
class CDisplayInfo class CDisplayInfo
{ {
public: public:
CDisplayInfo(CInstanceManager* iMan); // CDisplayInfo(CInstanceManager* iMan);
CDisplayInfo();
~CDisplayInfo(); ~CDisplayInfo();
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
@ -46,7 +56,7 @@ public:
void StopDisplayInfo(); void StopDisplayInfo();
void SetPosition(int pos); void SetPosition(int pos);
int RetPosition(); int GetPosition();
protected: protected:
bool EventFrame(const Event &event); bool EventFrame(const Event &event);
@ -61,19 +71,19 @@ protected:
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CD3DEngine* m_engine; Gfx::CEngine* m_engine;
CEvent* m_event; CEventQueue* m_event;
CRobotMain* m_main; CRobotMain* m_main;
CCamera* m_camera; Gfx::CCamera* m_camera;
CInterface* m_interface; CInterface* m_interface;
CParticule* m_particule; Gfx::CParticle* m_particle;
CLight* m_light; Gfx::CLight* m_light;
bool m_bInfoMaximized; bool m_bInfoMaximized;
bool m_bInfoMinimized; bool m_bInfoMinimized;
int m_index; int m_index;
CameraType m_infoCamera; Gfx::CameraType m_infoCamera;
Math::Point m_infoNormalPos; Math::Point m_infoNormalPos;
Math::Point m_infoNormalDim; Math::Point m_infoNormalDim;
Math::Point m_infoActualPos; Math::Point m_infoActualPos;
@ -88,3 +98,4 @@ protected:
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,12 +18,13 @@
// displaytext.cpp // displaytext.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "graphics/engine/engine.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/restext.h" #include "common/restext.h"
@ -35,28 +37,31 @@
#include "ui/label.h" #include "ui/label.h"
#include "ui/window.h" #include "ui/window.h"
#include "ui/group.h" #include "ui/group.h"
#include "old/text.h" //#include "old/text.h"
#include "old/sound.h" //#include "old/sound.h"
//#include "sound/sound.h"
#include "ui/displaytext.h" #include "ui/displaytext.h"
namespace Ui {
const float FONTSIZE = 12.0f; const float FONTSIZE = 12.0f;
// Object's constructor. // Object's constructor.
CDisplayText::CDisplayText(CInstanceManager* iMan) //CDisplayText::CDisplayText(CInstanceManager* iMan)
CDisplayText::CDisplayText()
{ {
int i; int i;
m_iMan = iMan; // m_iMan = iMan;
m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_DISPLAYTEXT, this); m_iMan->AddInstance(CLASS_DISPLAYTEXT, this);
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); m_engine = (Gfx::CEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE); m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND); m_sound = (CSoundInterface*)m_iMan->SearchInstance(CLASS_SOUND);
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )
{ {
@ -94,9 +99,9 @@ bool CDisplayText::EventProcess(const Event &event)
{ {
int i; int i;
if ( m_engine->RetPause() ) return true; if ( m_engine->GetPause() ) return true;
if ( event.event == EVENT_FRAME ) if ( event.type == EVENT_FRAME )
{ {
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )
{ {
@ -124,9 +129,9 @@ void CDisplayText::DisplayError(Error err, CObject* pObj, float time)
if ( pObj == 0 ) return; if ( pObj == 0 ) return;
pos = pObj->RetPosition(0); pos = pObj->GetPosition(0);
h = RetIdealHeight(pObj); h = GetIdealHeight(pObj);
d = RetIdealDist(pObj); d = GetIdealDist(pObj);
DisplayError(err, pos, h, d, time); DisplayError(err, pos, h, d, time);
} }
@ -178,7 +183,7 @@ void CDisplayText::DisplayError(Error err, Math::Vector goal, float height,
// Displays text. // Displays text.
void CDisplayText::DisplayText(char *text, CObject* pObj, void CDisplayText::DisplayText(const char *text, CObject* pObj,
float time, TextType type) float time, TextType type)
{ {
Math::Vector pos; Math::Vector pos;
@ -186,23 +191,23 @@ void CDisplayText::DisplayText(char *text, CObject* pObj,
if ( pObj == 0 ) return; if ( pObj == 0 ) return;
pos = pObj->RetPosition(0); pos = pObj->GetPosition(0);
h = RetIdealHeight(pObj); h = GetIdealHeight(pObj);
d = RetIdealDist(pObj); d = GetIdealDist(pObj);
DisplayText(text, pos, h, d, time, type); DisplayText(text, pos, h, d, time, type);
} }
// Displays text. // Displays text.
void CDisplayText::DisplayText(char *text, Math::Vector goal, float height, void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height,
float dist, float time, TextType type) float dist, float time, TextType type)
{ {
CObject* toto; CObject* toto;
CMotion* motion; CMotion* motion;
CWindow* pw; Ui::CWindow* pw;
CButton* button; Ui::CButton* button;
CGroup* group; Ui::CGroup* group;
CLabel* label; Ui::CLabel* label;
Math::Point pos, ppos, dim; Math::Point pos, ppos, dim;
Sound sound; Sound sound;
float hLine, hBox; float hLine, hBox;
@ -210,7 +215,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
if ( !m_bEnable ) return; if ( !m_bEnable ) return;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) if ( pw == 0 )
{ {
pos.x = 0.0f; pos.x = 0.0f;
@ -221,12 +226,12 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
} }
hBox = 0.045f; hBox = 0.045f;
hLine = m_engine->RetText()->RetHeight(FONTSIZE, FONT_COLOBOT); hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, FONTSIZE);
nLine = 0; nLine = 0;
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )
{ {
group = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i)); group = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i)));
if ( group == 0 ) break; if ( group == 0 ) break;
nLine ++; nLine ++;
} }
@ -247,13 +252,13 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
if ( type == TT_WARNING ) icon = 10; // blue if ( type == TT_WARNING ) icon = 10; // blue
if ( type == TT_INFO ) icon = 8; // green if ( type == TT_INFO ) icon = 8; // green
if ( type == TT_MESSAGE ) icon = 11; // yellow if ( type == TT_MESSAGE ) icon = 11; // yellow
pw->CreateGroup(pos, dim, icon, EventMsg(EVENT_DT_GROUP0+nLine)); pw->CreateGroup(pos, dim, icon, EventType(EVENT_DT_GROUP0+nLine));
pw->SetTrashEvent(false); pw->SetTrashEvent(false);
ppos = pos; ppos = pos;
ppos.y -= hLine/2.0f; ppos.y -= hLine/2.0f;
label = pw->CreateLabel(ppos, dim, -1, EventMsg(EVENT_DT_LABEL0+nLine), text); label = pw->CreateLabel(ppos, dim, -1, EventType(EVENT_DT_LABEL0+nLine), text);
if ( label != 0 ) if ( label != 0 )
{ {
label->SetFontSize(FONTSIZE); label->SetFontSize(FONTSIZE);
@ -261,7 +266,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
dim.x = dim.y*0.75f; dim.x = dim.y*0.75f;
pos.x -= dim.x; pos.x -= dim.x;
button = pw->CreateButton(pos, dim, 14, EventMsg(EVENT_DT_VISIT0+nLine)); button = pw->CreateButton(pos, dim, 14, EventType(EVENT_DT_VISIT0+nLine));
if ( goal.x == 0.0f && if ( goal.x == 0.0f &&
goal.y == 0.0f && goal.y == 0.0f &&
@ -279,7 +284,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
toto = SearchToto(); toto = SearchToto();
if ( toto != 0 ) if ( toto != 0 )
{ {
motion = toto->RetMotion(); motion = toto->GetMotion();
if ( motion != 0 ) if ( motion != 0 )
{ {
if ( type == TT_ERROR ) if ( type == TT_ERROR )
@ -324,18 +329,18 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
void CDisplayText::ClearText() void CDisplayText::ClearText()
{ {
CWindow* pw; Ui::CWindow* pw;
int i; int i;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )
{ {
if ( pw != 0 ) if ( pw != 0 )
{ {
pw->DeleteControl(EventMsg(EVENT_DT_GROUP0+i)); pw->DeleteControl(EventType(EVENT_DT_GROUP0+i));
pw->DeleteControl(EventMsg(EVENT_DT_LABEL0+i)); pw->DeleteControl(EventType(EVENT_DT_LABEL0+i));
pw->DeleteControl(EventMsg(EVENT_DT_VISIT0+i)); pw->DeleteControl(EventType(EVENT_DT_VISIT0+i));
} }
m_bExist[i] = false; m_bExist[i] = false;
m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f); m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f);
@ -349,32 +354,32 @@ void CDisplayText::ClearText()
void CDisplayText::HideText(bool bHide) void CDisplayText::HideText(bool bHide)
{ {
CWindow* pw; Ui::CWindow* pw;
CGroup* pg; Ui::CGroup* pg;
CLabel* pl; Ui::CLabel* pl;
CButton* pb; Ui::CButton* pb;
int i; int i;
m_bHide = bHide; m_bHide = bHide;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return; if ( pw == 0 ) return;
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )
{ {
pg = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i)); pg = static_cast<Ui::CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i)));
if ( pg != 0 ) if ( pg != 0 )
{ {
pg->SetState(STATE_VISIBLE, !bHide); pg->SetState(STATE_VISIBLE, !bHide);
} }
pl = (CLabel* )pw->SearchControl(EventMsg(EVENT_DT_LABEL0+i)); pl = static_cast<Ui::CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i)));
if ( pl != 0 ) if ( pl != 0 )
{ {
pl->SetState(STATE_VISIBLE, !bHide); pl->SetState(STATE_VISIBLE, !bHide);
} }
pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb != 0 ) if ( pb != 0 )
{ {
pb->SetState(STATE_VISIBLE, !bHide); pb->SetState(STATE_VISIBLE, !bHide);
@ -386,20 +391,20 @@ void CDisplayText::HideText(bool bHide)
bool CDisplayText::ClearLastText() bool CDisplayText::ClearLastText()
{ {
CWindow *pw; Ui::CWindow *pw;
CButton *pb1, *pb2; Ui::CButton *pb1, *pb2;
CGroup *pg1, *pg2; Ui::CGroup *pg1, *pg2;
CLabel *pl1, *pl2; Ui::CLabel *pl1, *pl2;
int i; int i;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return false; if ( pw == 0 ) return false;
pb2 = (CButton*)pw->SearchControl(EVENT_DT_VISIT0); pb2 = static_cast<CButton*>(pw->SearchControl(EVENT_DT_VISIT0));
if ( pb2 == 0 ) return false; // same not of first-line if ( pb2 == 0 ) return false; // same not of first-line
pg2 = (CGroup*)pw->SearchControl(EVENT_DT_GROUP0); pg2 = static_cast<CGroup*>(pw->SearchControl(EVENT_DT_GROUP0));
if ( pg2 == 0 ) return false; if ( pg2 == 0 ) return false;
pl2 = (CLabel*)pw->SearchControl(EVENT_DT_LABEL0); pl2 = static_cast<CLabel*>(pw->SearchControl(EVENT_DT_LABEL0));
if ( pl2 == 0 ) return false; if ( pl2 == 0 ) return false;
for ( i=0 ; i<MAXDTLINE-1 ; i++ ) for ( i=0 ; i<MAXDTLINE-1 ; i++ )
@ -408,18 +413,18 @@ bool CDisplayText::ClearLastText()
pg1 = pg2; pg1 = pg2;
pl1 = pl2; pl1 = pl2;
pb2 = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i+1)); pb2 = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i+1)));
if ( pb2 == 0 ) break; if ( pb2 == 0 ) break;
pg2 = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i+1)); pg2 = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i+1)));
if ( pg2 == 0 ) break; if ( pg2 == 0 ) break;
pl2 = (CLabel*)pw->SearchControl(EventMsg(EVENT_DT_LABEL0+i+1)); pl2 = static_cast<CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i+1)));
if ( pl2 == 0 ) break; if ( pl2 == 0 ) break;
pb1->SetState(STATE_ENABLE, pb2->TestState(STATE_ENABLE)); pb1->SetState(STATE_ENABLE, pb2->TestState(STATE_ENABLE));
pg1->SetIcon(pg2->RetIcon()); pg1->SetIcon(pg2->GetIcon());
pl1->SetName(pl2->RetName()); pl1->SetName(pl2->GetName());
m_time[i] = m_time[i+1]; m_time[i] = m_time[i+1];
m_visitGoal[i] = m_visitGoal[i+1]; m_visitGoal[i] = m_visitGoal[i+1];
@ -427,9 +432,9 @@ bool CDisplayText::ClearLastText()
m_visitHeight[i] = m_visitHeight[i+1]; // shift m_visitHeight[i] = m_visitHeight[i+1]; // shift
} }
pw->DeleteControl(EventMsg(EVENT_DT_VISIT0+i)); pw->DeleteControl(EventType(EVENT_DT_VISIT0+i));
pw->DeleteControl(EventMsg(EVENT_DT_GROUP0+i)); pw->DeleteControl(EventType(EVENT_DT_GROUP0+i));
pw->DeleteControl(EventMsg(EVENT_DT_LABEL0+i)); pw->DeleteControl(EventType(EVENT_DT_LABEL0+i));
m_bExist[i] = false; m_bExist[i] = false;
return true; return true;
} }
@ -453,7 +458,7 @@ void CDisplayText::SetEnable(bool bEnable)
// Returns the goal during a visit. // Returns the goal during a visit.
Math::Vector CDisplayText::RetVisitGoal(EventMsg event) Math::Vector CDisplayText::GetVisitGoal(EventType event)
{ {
int i; int i;
@ -464,7 +469,7 @@ Math::Vector CDisplayText::RetVisitGoal(EventMsg event)
// Returns the distance during a visit. // Returns the distance during a visit.
float CDisplayText::RetVisitDist(EventMsg event) float CDisplayText::GetVisitDist(EventType event)
{ {
int i; int i;
@ -475,7 +480,7 @@ float CDisplayText::RetVisitDist(EventMsg event)
// Returns the height on a visit. // Returns the height on a visit.
float CDisplayText::RetVisitHeight(EventMsg event) float CDisplayText::GetVisitHeight(EventType event)
{ {
int i; int i;
@ -487,13 +492,13 @@ float CDisplayText::RetVisitHeight(EventMsg event)
// Ranges from ideal visit for a given object. // Ranges from ideal visit for a given object.
float CDisplayText::RetIdealDist(CObject* pObj) float CDisplayText::GetIdealDist(CObject* pObj)
{ {
ObjectType type; ObjectType type;
if ( pObj == 0 ) return 40.0f; if ( pObj == 0 ) return 40.0f;
type = pObj->RetType(); type = pObj->GetType();
if ( type == OBJECT_PORTICO ) return 200.0f; if ( type == OBJECT_PORTICO ) return 200.0f;
if ( type == OBJECT_BASE ) return 200.0f; if ( type == OBJECT_BASE ) return 200.0f;
if ( type == OBJECT_NUCLEAR ) return 100.0f; if ( type == OBJECT_NUCLEAR ) return 100.0f;
@ -506,13 +511,13 @@ float CDisplayText::RetIdealDist(CObject* pObj)
// Returns the height of ideal visit for a given object. // Returns the height of ideal visit for a given object.
float CDisplayText::RetIdealHeight(CObject* pObj) float CDisplayText::GetIdealHeight(CObject* pObj)
{ {
ObjectType type; ObjectType type;
if ( pObj == 0 ) return 5.0f; if ( pObj == 0 ) return 5.0f;
type = pObj->RetType(); type = pObj->GetType();
if ( type == OBJECT_DERRICK ) return 35.0f; if ( type == OBJECT_DERRICK ) return 35.0f;
if ( type == OBJECT_FACTORY ) return 22.0f; if ( type == OBJECT_FACTORY ) return 22.0f;
if ( type == OBJECT_REPAIR ) return 30.0f; if ( type == OBJECT_REPAIR ) return 30.0f;
@ -537,16 +542,16 @@ float CDisplayText::RetIdealHeight(CObject* pObj)
void CDisplayText::ClearVisit() void CDisplayText::ClearVisit()
{ {
CWindow* pw; Ui::CWindow* pw;
CButton* pb; Ui::CButton* pb;
int i; int i;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return; if ( pw == 0 ) return;
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )
{ {
pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb == 0 ) break; if ( pb == 0 ) break;
pb->SetIcon(14); // eyes pb->SetIcon(14); // eyes
} }
@ -554,38 +559,38 @@ void CDisplayText::ClearVisit()
// Puts a button in "visit". // Puts a button in "visit".
void CDisplayText::SetVisit(EventMsg event) void CDisplayText::SetVisit(EventType event)
{ {
CWindow* pw; Ui::CWindow* pw;
CButton* pb; Ui::CButton* pb;
int i; int i;
i = event-EVENT_DT_VISIT0; i = event-EVENT_DT_VISIT0;
if ( i < 0 || i >= MAXDTLINE ) return; if ( i < 0 || i >= MAXDTLINE ) return;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return; if ( pw == 0 ) return;
pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb == 0 ) return; if ( pb == 0 ) return;
pb->SetIcon(48); // > pb->SetIcon(48); // >
} }
// Indicates whether a button is set to "visit". // Indicates whether a button is set to "visit".
bool CDisplayText::IsVisit(EventMsg event) bool CDisplayText::IsVisit(EventType event)
{ {
CWindow* pw; Ui::CWindow* pw;
CButton* pb; Ui::CButton* pb;
int i; int i;
i = event-EVENT_DT_VISIT0; i = event-EVENT_DT_VISIT0;
if ( i < 0 || i >= MAXDTLINE ) return false; if ( i < 0 || i >= MAXDTLINE ) return false;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return false; if ( pw == 0 ) return false;
pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i)); pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb == 0 ) return false; if ( pb == 0 ) return false;
return (pb->RetIcon() == 48); // > ? return (pb->GetIcon() == 48); // > ?
} }
@ -599,10 +604,10 @@ CObject* CDisplayText::SearchToto()
for ( i=0 ; i<1000000 ; i++ ) for ( i=0 ; i<1000000 ; i++ )
{ {
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break; if ( pObj == 0 ) break;
type = pObj->RetType(); type = pObj->GetType();
if ( type == OBJECT_TOTO ) if ( type == OBJECT_TOTO )
{ {
return pObj; return pObj;
@ -611,3 +616,4 @@ CObject* CDisplayText::SearchToto()
return 0; return 0;
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -21,15 +22,18 @@
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "old/d3dengine.h" #include "sound/sound.h"
//#include "old/d3dengine.h"
class CInstanceManager; class CInstanceManager;
class CD3DEngine; //class CD3DEngine
class CInterface;
class CObject; class CObject;
class CSound; class CSound;
namespace Ui {;
class CInterface;
enum TextType enum TextType
{ {
@ -45,7 +49,8 @@ const int MAXDTLINE = 4;
class CDisplayText class CDisplayText
{ {
public: public:
CDisplayText(CInstanceManager* iMan); // CDisplayText(CInstanceManager* iMan);
CDisplayText();
~CDisplayText(); ~CDisplayText();
void DeleteObject(); void DeleteObject();
@ -54,33 +59,33 @@ public:
void DisplayError(Error err, CObject* pObj, float time=10.0f); 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 DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f);
void DisplayText(char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO); void DisplayText(const 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 DisplayText(const 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 HideText(bool bHide);
void ClearText(); void ClearText();
bool ClearLastText(); bool ClearLastText();
void SetDelay(float factor); void SetDelay(float factor);
void SetEnable(bool bEnable); void SetEnable(bool bEnable);
Math::Vector RetVisitGoal(EventMsg event); Math::Vector GetVisitGoal(EventType event);
float RetVisitDist(EventMsg event); float GetVisitDist(EventType event);
float RetVisitHeight(EventMsg event); float GetVisitHeight(EventType event);
float RetIdealDist(CObject* pObj); float GetIdealDist(CObject* pObj);
float RetIdealHeight(CObject* pObj); float GetIdealHeight(CObject* pObj);
void ClearVisit(); void ClearVisit();
void SetVisit(EventMsg event); void SetVisit(EventType event);
bool IsVisit(EventMsg event); bool IsVisit(EventType event);
protected: protected:
CObject* SearchToto(); CObject* SearchToto();
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CD3DEngine* m_engine; Gfx::CEngine* m_engine;
CInterface* m_interface; Ui::CInterface* m_interface;
CSound* m_sound; CSoundInterface* m_sound;
bool m_bExist[MAXDTLINE]; bool m_bExist[MAXDTLINE];
float m_time[MAXDTLINE]; float m_time[MAXDTLINE];
@ -94,3 +99,4 @@ protected:
}; };
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -14,69 +15,99 @@
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
// edit.h
/**
* \file ui/edit.h
* \brief CEdit class
*/
#pragma once #pragma once
#include "common/struct.h" //#include "common/struct.h"
#include "ui/control.h" #include "ui/control.h"
namespace Gfx{
class CEngine;
};
class CD3DEngine; namespace Ui {
class CScroll; class CScroll;
//! maximum number of characters in CBOT edit
const int EDITSTUDIOMAX = 20000;
//! maximum total number of lines
const int EDITLINEMAX = 1000;
//! maximum total number of lines with images
const int EDITIMAGEMAX = 50;
//! maximum number of links
const int EDITLINKMAX = 100;
//! max number of levels preserves
const int EDITHISTORYMAX = 50;
const int EDITSTUDIOMAX = 20000; // maximum number of characters in CBOT edit //! max number of successive undo
const int EDITLINEMAX = 1000; // maximum total number of lines const int EDITUNDOMAX = 20;
const int EDITIMAGEMAX = 50; // maximum total number of lines with images
const int EDITLINKMAX = 100; // maximum number of links
const int EDITHISTORYMAX = 50; // max number of levels preserves
const int EDITUNDOMAX = 20; // max number of successive undo
struct EditUndo struct EditUndo
{ {
char* text; // original text //! original text
int len; // length of the text char* text;
int cursor1; // offset cursor //! length of the text
int cursor2; // offset cursor int len;
int lineFirst; // the first line displayed. //! offset cursor
int cursor1;
//! offset cursor
int cursor2;
//! the first line displayed.
int lineFirst;
}; };
enum OperUndo enum OperUndo
{ {
OPERUNDO_SPEC = 0, // special operation //! special operation
OPERUNDO_INSERT = 1, // inserting characters OPERUNDO_SPEC = 0,
OPERUNDO_DELETE = 2, // deleting characters //! inserting characters
OPERUNDO_INSERT = 1,
//! deleting characters
OPERUNDO_DELETE = 2,
}; };
struct ImageLine struct ImageLine
{ {
char name[40]; // name of the image (without diagram \) //! name of the image (without diagram \)
float offset; // vertical offset (v texture) char name[40];
float height; // height of the part (dv texture) //! vertical offset (v texture)
float width; // width float offset;
//! height of the part (dv texture)
float height;
//! width
float width;
}; };
struct HyperLink struct HyperLink
{ {
char name[40]; // text file name (without help \) //! text file name (without help \)
char marker[20]; // name of the marker char name[40];
//! name of the marker
char marker[20];
}; };
struct HyperMarker struct HyperMarker
{ {
char name[20]; // name of the marker //! name of the marker
int pos; // position in the text char name[20];
//! position in the text
int pos;
}; };
struct HyperHistory struct HyperHistory
{ {
char filename[50]; // full file name text //! full file name text
int firstLine; // rank of the first displayed line char filename[50];
//! rank of the first displayed line
int firstLine;
}; };
@ -85,10 +116,11 @@ struct HyperHistory
class CEdit : public CControl class CEdit : public CControl
{ {
public: public:
CEdit(CInstanceManager* iMan); // CEdit(CInstanceManager* iMan);
CEdit ();
virtual ~CEdit(); virtual ~CEdit();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
void SetPos(Math::Point pos); void SetPos(Math::Point pos);
void SetDim(Math::Point dim); void SetDim(Math::Point dim);
@ -98,45 +130,45 @@ public:
void SetText(char *text, bool bNew=true); void SetText(char *text, bool bNew=true);
void GetText(char *buffer, int max); void GetText(char *buffer, int max);
char* RetText(); char* GetText();
int RetTextLength(); int GetTextLength();
bool ReadText(char *filename, int addSize=0); bool ReadText(char *filename, int addSize=0);
bool WriteText(char *filename); bool WriteText(char *filename);
void SetMaxChar(int max); void SetMaxChar(int max);
int RetMaxChar(); int GetMaxChar();
void SetEditCap(bool bMode); void SetEditCap(bool bMode);
bool RetEditCap(); bool GetEditCap();
void SetHiliteCap(bool bEnable); void SetHiliteCap(bool bEnable);
bool RetHiliteCap(); bool GetHiliteCap();
void SetInsideScroll(bool bInside); void SetInsideScroll(bool bInside);
bool RetInsideScroll(); bool GetInsideScroll();
void SetSoluceMode(bool bSoluce); void SetSoluceMode(bool bSoluce);
bool RetSoluceMode(); bool GetSoluceMode();
void SetGenericMode(bool bGeneric); void SetGenericMode(bool bGeneric);
bool RetGenericMode(); bool GetGenericMode();
void SetAutoIndent(bool bMode); void SetAutoIndent(bool bMode);
bool RetAutoIndent(); bool GetAutoIndent();
void SetCursor(int cursor1, int cursor2); void SetCursor(int cursor1, int cursor2);
void GetCursor(int &cursor1, int &cursor2); void GetCursor(int &cursor1, int &cursor2);
void SetFirstLine(int rank); void SetFirstLine(int rank);
int RetFirstLine(); int GetFirstLine();
void ShowSelect(); void ShowSelect();
void SetDisplaySpec(bool bDisplay); void SetDisplaySpec(bool bDisplay);
bool RetDisplaySpec(); bool GetDisplaySpec();
void SetMultiFont(bool bMulti); void SetMultiFont(bool bMulti);
bool RetMultiFont(); bool GetMultiFont();
bool Cut(); bool Cut();
bool Copy(); bool Copy();
@ -145,8 +177,8 @@ public:
void HyperFlush(); void HyperFlush();
void HyperHome(char *filename); void HyperHome(char *filename);
bool HyperTest(EventMsg event); bool HyperTest(EventType event);
bool HyperGo(EventMsg event); bool HyperGo(EventType event);
void SetFontSize(float size); void SetFontSize(float size);
@ -189,7 +221,7 @@ protected:
bool Shift(bool bLeft); bool Shift(bool bLeft);
bool MinMaj(bool bMaj); bool MinMaj(bool bMaj);
void Justif(); void Justif();
int RetCursorLine(int cursor); int GetCursorLine(int cursor);
void UndoFlush(); void UndoFlush();
void UndoMemorize(OperUndo oper); void UndoMemorize(OperUndo oper);
@ -246,3 +278,4 @@ protected:
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,13 +18,13 @@
// editvalue.cpp // editvalue.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" //#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -33,10 +34,11 @@
namespace Ui {
// Object's constructor. // Object's constructor.
CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan) //CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan)
CEditValue::CEditValue() : CControl ()
{ {
m_edit = 0; m_edit = 0;
m_buttonUp = 0; m_buttonUp = 0;
@ -60,28 +62,28 @@ CEditValue::~CEditValue()
// Creates a new button. // Creates a new button.
bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{ {
CEdit* pe; Ui::CEdit* pe;
CButton* pc; Ui::CButton* pc;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg); CControl::Create(pos, dim, icon, eventType);
GlintDelete(); GlintDelete();
m_edit = new CEdit(m_iMan); m_edit = new Ui::CEdit();
pe = (CEdit*)m_edit; pe = static_cast<Ui::CEdit*>(m_edit);
pe->Create(pos, dim, 0, EVENT_NULL); pe->Create(pos, dim, 0, EVENT_NULL);
pe->SetMaxChar(4); pe->SetMaxChar(4);
m_buttonUp = new CButton(m_iMan); m_buttonUp = new Ui::CButton();
pc = (CButton*)m_buttonUp; pc = static_cast<Ui::CButton*>(m_buttonUp);
pc->Create(pos, dim, 49, EVENT_NULL); // ^ pc->Create(pos, dim, 49, EVENT_NULL); // ^
pc->SetRepeat(true); pc->SetRepeat(true);
m_buttonDown = new CButton(m_iMan); m_buttonDown = new Ui::CButton();
pc = (CButton*)m_buttonDown; pc = static_cast<Ui::CButton*>(m_buttonDown);
pc->Create(pos, dim, 50, EVENT_NULL); // v pc->Create(pos, dim, 50, EVENT_NULL); // v
pc->SetRepeat(true); pc->SetRepeat(true);
@ -151,11 +153,11 @@ bool CEditValue::EventProcess(const Event &event)
if ( m_edit != 0 ) if ( m_edit != 0 )
{ {
if ( m_edit->RetFocus() && if ( m_edit->GetFocus() &&
event.event == EVENT_KEYDOWN && event.type == EVENT_KEY_DOWN &&
event.param == VK_RETURN ) event.param == KEY(RETURN) )
{ {
value = RetValue(); value = GetValue();
if ( value > m_maxValue ) value = m_maxValue; if ( value > m_maxValue ) value = m_maxValue;
if ( value < m_minValue ) value = m_minValue; if ( value < m_minValue ) value = m_minValue;
SetValue(value, true); SetValue(value, true);
@ -163,19 +165,18 @@ bool CEditValue::EventProcess(const Event &event)
} }
if ( !m_edit->EventProcess(event) ) return false; if ( !m_edit->EventProcess(event) ) return false;
if ( event.event == m_edit->RetEventMsg() ) if ( event.type == m_edit->GetEventType() )
{ {
Event newEvent; Event newEvent(m_eventType);
m_event->MakeEvent(newEvent, m_eventMsg);
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
} }
if ( m_buttonUp != 0 ) if ( m_buttonUp != 0 )
{ {
if ( event.event == m_buttonUp->RetEventMsg() ) if ( event.type == m_buttonUp->GetEventType() )
{ {
value = RetValue()+m_stepValue; value = GetValue()+m_stepValue;
if ( value > m_maxValue ) value = m_maxValue; if ( value > m_maxValue ) value = m_maxValue;
SetValue(value, true); SetValue(value, true);
HiliteValue(event); HiliteValue(event);
@ -185,9 +186,9 @@ bool CEditValue::EventProcess(const Event &event)
if ( m_buttonDown != 0 ) if ( m_buttonDown != 0 )
{ {
if ( event.event == m_buttonDown->RetEventMsg() ) if ( event.type == m_buttonDown->GetEventType() )
{ {
value = RetValue()-m_stepValue; value = GetValue()-m_stepValue;
if ( value < m_minValue ) value = m_minValue; if ( value < m_minValue ) value = m_minValue;
SetValue(value, true); SetValue(value, true);
HiliteValue(event); HiliteValue(event);
@ -195,20 +196,20 @@ bool CEditValue::EventProcess(const Event &event)
if ( !m_buttonDown->EventProcess(event) ) return false; if ( !m_buttonDown->EventProcess(event) ) return false;
} }
if ( event.event == EVENT_KEYDOWN && if ( event.type == EVENT_KEY_DOWN &&
event.param == VK_WHEELUP && event.mouseButton.button == 4 &&
Detect(event.pos) ) Detect(event.pos) )
{ {
value = RetValue()+m_stepValue; value = GetValue()+m_stepValue;
if ( value > m_maxValue ) value = m_maxValue; if ( value > m_maxValue ) value = m_maxValue;
SetValue(value, true); SetValue(value, true);
HiliteValue(event); HiliteValue(event);
} }
if ( event.event == EVENT_KEYDOWN && if ( event.type == EVENT_KEY_DOWN &&
event.param == VK_WHEELDOWN && event.mouseButton.button == 5 &&
Detect(event.pos) ) Detect(event.pos) )
{ {
value = RetValue()-m_stepValue; value = GetValue()-m_stepValue;
if ( value < m_minValue ) value = m_minValue; if ( value < m_minValue ) value = m_minValue;
SetValue(value, true); SetValue(value, true);
HiliteValue(event); HiliteValue(event);
@ -226,7 +227,7 @@ void CEditValue::HiliteValue(const Event &event)
if ( m_edit == 0 ) return; if ( m_edit == 0 ) return;
pos = m_edit->RetTextLength(); pos = m_edit->GetTextLength();
if ( m_type == EVT_100 && pos > 0 ) if ( m_type == EVT_100 && pos > 0 )
{ {
pos --; // not only selects the "%" pos --; // not only selects the "%"
@ -236,8 +237,9 @@ void CEditValue::HiliteValue(const Event &event)
m_edit->SetFocus(true); m_edit->SetFocus(true);
Event newEvent = event; Event newEvent = event;
newEvent.event = EVENT_FOCUS; newEvent.type = EVENT_ACTIVE;
newEvent.param = m_edit->RetEventMsg(); newEvent.active.gain = true; // TODO not much pretty sure about it
newEvent.param = m_edit->GetEventType();
m_event->AddEvent(newEvent); // defocus the other objects m_event->AddEvent(newEvent); // defocus the other objects
} }
@ -275,7 +277,7 @@ void CEditValue::SetType(EditValueType type)
m_type = type; m_type = type;
} }
EditValueType CEditValue::RetType() EditValueType CEditValue::GetType()
{ {
return m_type; return m_type;
} }
@ -310,15 +312,14 @@ void CEditValue::SetValue(float value, bool bSendMessage)
if ( bSendMessage ) if ( bSendMessage )
{ {
Event newEvent; Event newEvent(m_eventType);
m_event->MakeEvent(newEvent, m_eventMsg);
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
} }
// Return the edited value. // Return the edited value.
float CEditValue::RetValue() float CEditValue::GetValue()
{ {
char text[100]; char text[100];
float value; float value;
@ -345,7 +346,7 @@ void CEditValue::SetStepValue(float value)
m_stepValue = value; m_stepValue = value;
} }
float CEditValue::RetStepValue() float CEditValue::GetStepValue()
{ {
return m_stepValue; return m_stepValue;
} }
@ -358,7 +359,7 @@ void CEditValue::SetMinValue(float value)
m_minValue = value; m_minValue = value;
} }
float CEditValue::RetMinValue() float CEditValue::GetMinValue()
{ {
return m_minValue; return m_minValue;
} }
@ -371,8 +372,9 @@ void CEditValue::SetMaxValue(float value)
m_maxValue = value; m_maxValue = value;
} }
float CEditValue::RetMaxValue() float CEditValue::GetMaxValue()
{ {
return m_maxValue; return m_maxValue;
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -22,6 +23,12 @@
#include "ui/control.h" #include "ui/control.h"
namespace Gfx{
class CEngine;
}
namespace Ui {
enum EditValueType enum EditValueType
{ {
EVT_INT = 1, // integer EVT_INT = 1, // integer
@ -29,8 +36,6 @@ enum EditValueType
EVT_100 = 3, // percent (0 .. 1) EVT_100 = 3, // percent (0 .. 1)
}; };
class CD3DEngine;
class CEdit; class CEdit;
class CButton; class CButton;
@ -39,10 +44,11 @@ class CButton;
class CEditValue : public CControl class CEditValue : public CControl
{ {
public: public:
CEditValue(CInstanceManager* iMan); // CEditValue(CInstanceManager* iMan);
CEditValue();
virtual ~CEditValue(); virtual ~CEditValue();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
void SetPos(Math::Point pos); void SetPos(Math::Point pos);
void SetDim(Math::Point dim); void SetDim(Math::Point dim);
@ -51,28 +57,28 @@ public:
void Draw(); void Draw();
void SetType(EditValueType type); void SetType(EditValueType type);
EditValueType RetType(); EditValueType GetType();
void SetValue(float value, bool bSendMessage=false); void SetValue(float value, bool bSendMessage=false);
float RetValue(); float GetValue();
void SetStepValue(float value); void SetStepValue(float value);
float RetStepValue(); float GetStepValue();
void SetMinValue(float value); void SetMinValue(float value);
float RetMinValue(); float GetMinValue();
void SetMaxValue(float value); void SetMaxValue(float value);
float RetMaxValue(); float GetMaxValue();
protected: protected:
void MoveAdjust(); void MoveAdjust();
void HiliteValue(const Event &event); void HiliteValue(const Event &event);
protected: protected:
CEdit* m_edit; Ui::CEdit* m_edit;
CButton* m_buttonUp; Ui::CButton* m_buttonUp;
CButton* m_buttonDown; Ui::CButton* m_buttonDown;
EditValueType m_type; EditValueType m_type;
float m_stepValue; float m_stepValue;
@ -81,3 +87,4 @@ protected:
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,13 +18,14 @@
// gauge.cpp // gauge.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" #include "graphics/engine/engine.h"
//#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -31,10 +33,11 @@
namespace Ui {
// Object's constructor. // Object's constructor.
CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan) //CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan)
CGauge::CGauge() : CControl()
{ {
m_level = 0.0f; m_level = 0.0f;
} }
@ -48,11 +51,11 @@ CGauge::~CGauge()
// Creates a new button. // Creates a new button.
bool CGauge::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CGauge::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; return true;
} }
@ -63,12 +66,12 @@ bool CGauge::EventProcess(const Event &event)
{ {
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_LBUTTONDOWN ) if ( event.type == EVENT_MOUSE_BUTTON_DOWN )
{ {
if ( CControl::Detect(event.pos) ) if ( CControl::Detect(event.pos) )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
@ -88,47 +91,47 @@ void CGauge::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 ) return;
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
dp = 0.5f/256.0f; dp = 0.5f/256.0f;
pos = m_pos; pos = m_pos;
dim = m_dim; dim = m_dim;
uv1.x = 32.0f/256.0f; uv1.x = 32.0f / 256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f / 256.0f;
uv2.x = 64.0f/256.0f; uv2.x = 64.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 10.0f/640.0f; corner.x = 10.0f / 640.0f;
corner.y = 10.0f/480.0f; corner.y = 10.0f / 480.0f;
DrawIcon(pos, dim, uv1, uv2, corner, 8.0f/256.0f); DrawIcon(pos, dim, uv1, uv2, corner, 8.0f/256.0f);
pos.x += 3.0f/640.0f; pos.x += 3.0f / 640.0f;
pos.y += 3.0f/480.0f; pos.y += 3.0f / 480.0f;
dim.x -= 6.0f/640.0f; dim.x -= 6.0f / 640.0f;
dim.y -= 6.0f/480.0f; dim.y -= 6.0f / 480.0f;
if ( m_dim.x < m_dim.y ) // vertical gauge? if ( m_dim.x < m_dim.y ) // vertical gauge?
{ {
uv1.x = (0.0f+m_icon*16.0f)/256.0f; uv1.x = (0.0f + m_icon * 16.0f) / 256.0f;
uv2.x = uv1.x+16.0f/256.0f; uv2.x = uv1.x + 16.0f / 256.0f;
uv1.y = 128.0f/256.0f+m_level*(64.0f/256.0f); uv1.y = 128.0f/256.0f + m_level * (64.0f/256.0f);
uv2.y = uv1.y+64.0f/256.0f; uv2.y = uv1.y + 64.0f/256.0f;
} }
else // horizontal gauge? else // horizontal gauge?
{ {
uv1.x = 64.0f/256.0f+(1.0f-m_level)*(64.0f/256.0f); uv1.x = 64.0f/256.0f + (1.0f - m_level) * (64.0f/256.0f);
uv2.x = uv1.x+64.0f/256.0f; uv2.x = uv1.x + 64.0f/256.0f;
uv1.y = (128.0f+m_icon*16.0f)/256.0f; uv1.y = (128.0f + m_icon*16.0f) / 256.0f;
uv2.y = uv1.y+16.0f/256.0f; uv2.y = uv1.y + 16.0f/256.0f;
} }
uv1.x += dp; uv1.x += dp;
@ -149,9 +152,10 @@ void CGauge::SetLevel(float level)
m_level = level; m_level = level;
} }
float CGauge::RetLevel() float CGauge::GetLevel()
{ {
return m_level; return m_level;
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -21,25 +22,27 @@
#include "ui/control.h" #include "ui/control.h"
namespace Gfx{
class CEngine;
};
class CD3DEngine; namespace Ui {
class CGauge : public CControl class CGauge : public CControl
{ {
public: public:
CGauge(CInstanceManager* iMan); // CGauge(CInstanceManager* iMan);
CGauge();
virtual ~CGauge(); virtual ~CGauge();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void Draw(); void Draw();
void SetLevel(float level); void SetLevel(float level);
float RetLevel(); float GetLevel();
protected: protected:
@ -48,3 +51,4 @@ protected:
}; };
}

View File

@ -17,13 +17,14 @@
// group.cpp // group.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" #include "graphics/engine/engine.h"
//#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -32,10 +33,11 @@
namespace Ui {
// Object's constructor. // Object's constructor.
CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan) //CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan)
CGroup::CGroup() : CControl()
{ {
} }
@ -48,18 +50,18 @@ CGroup::~CGroup()
// Creates a new button. // Creates a new button.
bool CGroup::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CGroup::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);
if ( icon == -1 ) if ( icon == -1 )
{ {
char name[100]; char name[100];
char* p; char* p;
GetResource(RES_EVENT, eventMsg, name); GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\'); p = strchr(name, '\\');
if ( p != 0 ) *p = 0; if ( p != 0 ) *p = 0;
SetName(name); SetName(name);
@ -92,16 +94,16 @@ void CGroup::Draw()
DrawShadow(m_pos, m_dim); DrawShadow(m_pos, m_dim);
} }
dp = 0.5f/256.0f; dp = 0.5f / 256.0f;
if ( m_icon == 0 ) // hollow frame? if ( m_icon == 0 ) // hollow frame?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 160.0f/256.0f; uv1.x = 160.0f / 256.0f;
uv1.y = 192.0f/256.0f; // u-v texture uv1.y = 192.0f / 256.0f; // u-v texture
uv2.x = 192.0f/256.0f; uv2.x = 192.0f / 256.0f;
uv2.y = 224.0f/256.0f; uv2.y = 224.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -113,11 +115,11 @@ void CGroup::Draw()
if ( m_icon == 1 ) // orange solid opaque? if ( m_icon == 1 ) // orange solid opaque?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 104.0f/256.0f; uv1.x = 104.0f / 256.0f;
uv1.y = 48.0f/256.0f; uv1.y = 48.0f / 256.0f;
uv2.x = 112.0f/256.0f; uv2.x = 112.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -127,11 +129,11 @@ void CGroup::Draw()
if ( m_icon == 2 ) // orange degrade -> transparent? if ( m_icon == 2 ) // orange degrade -> transparent?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 112.0f/256.0f; uv1.x = 112.0f / 256.0f;
uv1.y = 48.0f/256.0f; uv1.y = 48.0f / 256.0f;
uv2.x = 120.0f/256.0f; uv2.x = 120.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -141,11 +143,11 @@ void CGroup::Draw()
if ( m_icon == 3 ) // transparent gradient -> gray? if ( m_icon == 3 ) // transparent gradient -> gray?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 120.0f/256.0f; uv1.x = 120.0f / 256.0f;
uv1.y = 48.0f/256.0f; uv1.y = 48.0f / 256.0f;
uv2.x = 128.0f/256.0f; uv2.x = 128.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -155,11 +157,11 @@ void CGroup::Draw()
if ( m_icon == 4 ) // degrade blue corner? if ( m_icon == 4 ) // degrade blue corner?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 192.0f/256.0f; uv1.x = 192.0f / 256.0f;
uv1.y = 128.0f/256.0f; uv1.y = 128.0f / 256.0f;
uv2.x = 224.0f/256.0f; uv2.x = 224.0f / 256.0f;
uv2.y = 160.0f/256.0f; uv2.y = 160.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -169,11 +171,11 @@ void CGroup::Draw()
if ( m_icon == 5 ) // degrade orange corner? if ( m_icon == 5 ) // degrade orange corner?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 224.0f/256.0f; uv1.x = 224.0f / 256.0f;
uv1.y = 128.0f/256.0f; uv1.y = 128.0f / 256.0f;
uv2.x = 256.0f/256.0f; uv2.x = 256.0f / 256.0f;
uv2.y = 160.0f/256.0f; uv2.y = 160.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -183,27 +185,27 @@ void CGroup::Draw()
if ( m_icon == 6 ) if ( m_icon == 6 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 0.0f/256.0f; // brown transparent uv1.x = 0.0f / 256.0f; // brown transparent
uv1.y = 75.0f/256.0f; uv1.y = 75.0f / 256.0f;
uv2.x = 64.0f/256.0f; uv2.x = 64.0f / 256.0f;
uv2.y = 128.0f/256.0f; uv2.y = 128.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 4.0f/640.0f; corner.x = 4.0f / 640.0f;
corner.y = 4.0f/480.0f; corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f);
} }
if ( m_icon == 7 ) if ( m_icon == 7 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; uv1.x = 64.0f / 256.0f;
uv1.y = 0.0f/256.0f; uv1.y = 0.0f / 256.0f;
uv2.x = 96.0f/256.0f; uv2.x = 96.0f / 256.0f;
uv2.y = 32.0f/256.0f; uv2.y = 32.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -213,11 +215,11 @@ void CGroup::Draw()
if ( m_icon == 8 ) if ( m_icon == 8 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // green transparent uv1.x = 64.0f / 256.0f; // green transparent
uv1.y = 160.0f/256.0f; uv1.y = 160.0f / 256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f / 256.0f;
uv2.y = 176.0f/256.0f; uv2.y = 176.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -227,8 +229,8 @@ void CGroup::Draw()
if ( m_icon == 9 ) if ( m_icon == 9 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // red transparent uv1.x = 64.0f / 256.0f; // red transparent
uv1.y = 176.0f/256.0f; uv1.y = 176.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
uv2.y = 192.0f/256.0f; uv2.y = 192.0f/256.0f;
@ -241,11 +243,11 @@ void CGroup::Draw()
if ( m_icon == 10 ) if ( m_icon == 10 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // blue transparent uv1.x = 64.0f / 256.0f; // blue transparent
uv1.y = 192.0f/256.0f; uv1.y = 192.0f / 256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f / 256.0f;
uv2.y = 208.0f/256.0f; uv2.y = 208.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -255,11 +257,11 @@ void CGroup::Draw()
if ( m_icon == 11 ) if ( m_icon == 11 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // yellow transparent uv1.x = 64.0f / 256.0f; // yellow transparent
uv1.y = 224.0f/256.0f; uv1.y = 224.0f / 256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f / 256.0f;
uv2.y = 240.0f/256.0f; uv2.y = 240.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -268,17 +270,17 @@ void CGroup::Draw()
} }
if ( m_icon == 12 ) // viewfinder cross? if ( m_icon == 12 ) // viewfinder cross?
{ {
dim.x = m_dim.x/2.0f; dim.x = m_dim.x / 2.0f;
dim.y = m_dim.y/2.0f; dim.y = m_dim.y / 2.0f;
m_engine->SetTexture("mouse.tga"); m_engine->SetTexture("mouse.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/300.0f; pos.x = m_pos.x-m_dim.x/300.0f;
pos.y = m_pos.y+m_dim.y/300.0f+dim.y; pos.y = m_pos.y+m_dim.y/300.0f+dim.y;
uv1.x = 0.5f/256.0f; uv1.x = 0.5f / 256.0f;
uv1.y = 192.5f/256.0f; uv1.y = 192.5f / 256.0f;
uv2.x = 63.5f/256.0f; uv2.x = 63.5f / 256.0f;
uv2.y = 255.5f/256.0f; uv2.y = 255.5f / 256.0f;
DrawIcon(pos, dim, uv1, uv2); // ul DrawIcon(pos, dim, uv1, uv2); // ul
pos.x += dim.x; pos.x += dim.x;
Math::Swap(uv1.x, uv2.x); Math::Swap(uv1.x, uv2.x);
@ -290,13 +292,13 @@ void CGroup::Draw()
Math::Swap(uv1.x, uv2.x); Math::Swap(uv1.x, uv2.x);
DrawIcon(pos, dim, uv1, uv2); // dl DrawIcon(pos, dim, uv1, uv2); // dl
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/300.0f; pos.x = m_pos.x+m_dim.x/300.0f;
pos.y = m_pos.y-m_dim.y/300.0f+dim.y; pos.y = m_pos.y-m_dim.y/300.0f+dim.y;
uv1.x = 64.5f/256.0f; uv1.x = 64.5f / 256.0f;
uv1.y = 192.5f/256.0f; uv1.y = 192.5f / 256.0f;
uv2.x = 127.5f/256.0f; uv2.x = 127.5f / 256.0f;
uv2.y = 255.5f/256.0f; uv2.y = 255.5f / 256.0f;
DrawIcon(pos, dim, uv1, uv2); // ul DrawIcon(pos, dim, uv1, uv2); // ul
pos.x += dim.x; pos.x += dim.x;
Math::Swap(uv1.x, uv2.x); Math::Swap(uv1.x, uv2.x);
@ -311,111 +313,111 @@ void CGroup::Draw()
if ( m_icon == 13 ) // corner upper / left? if ( m_icon == 13 ) // corner upper / left?
{ {
m_engine->SetTexture("mouse.tga"); m_engine->SetTexture("mouse.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f; pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f; pos.y = m_pos.y+m_dim.y/150.0f;
uv1.x = 128.5f/256.0f; uv1.x = 128.5f / 256.0f;
uv1.y = 192.5f/256.0f; uv1.y = 192.5f / 256.0f;
uv2.x = 191.5f/256.0f; uv2.x = 191.5f / 256.0f;
uv2.y = 255.5f/256.0f; uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f; pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f; pos.y = m_pos.y-m_dim.y/150.0f;
uv1.x = 192.5f/256.0f; uv1.x = 192.5f / 256.0f;
uv1.y = 192.5f/256.0f; uv1.y = 192.5f / 256.0f;
uv2.x = 255.5f/256.0f; uv2.x = 255.5f / 256.0f;
uv2.y = 255.5f/256.0f; uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
} }
if ( m_icon == 14 ) // corner upper / right? if ( m_icon == 14 ) // corner upper / right?
{ {
m_engine->SetTexture("mouse.tga"); m_engine->SetTexture("mouse.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f; pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f; pos.y = m_pos.y+m_dim.y/150.0f;
uv2.x = 128.5f/256.0f; uv2.x = 128.5f / 256.0f;
uv1.y = 192.5f/256.0f; uv1.y = 192.5f / 256.0f;
uv1.x = 191.5f/256.0f; uv1.x = 191.5f / 256.0f;
uv2.y = 255.5f/256.0f; uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f; pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f; pos.y = m_pos.y-m_dim.y/150.0f;
uv2.x = 192.5f/256.0f; uv2.x = 192.5f / 256.0f;
uv1.y = 192.5f/256.0f; uv1.y = 192.5f / 256.0f;
uv1.x = 255.5f/256.0f; uv1.x = 255.5f / 256.0f;
uv2.y = 255.5f/256.0f; uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
} }
if ( m_icon == 15 ) // corner lower / left? if ( m_icon == 15 ) // corner lower / left?
{ {
m_engine->SetTexture("mouse.tga"); m_engine->SetTexture("mouse.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f; pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f; pos.y = m_pos.y+m_dim.y/150.0f;
uv1.x = 128.5f/256.0f; uv1.x = 128.5f / 256.0f;
uv2.y = 192.5f/256.0f; uv2.y = 192.5f / 256.0f;
uv2.x = 191.5f/256.0f; uv2.x = 191.5f / 256.0f;
uv1.y = 255.5f/256.0f; uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f; pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f; pos.y = m_pos.y-m_dim.y/150.0f;
uv1.x = 192.5f/256.0f; uv1.x = 192.5f / 256.0f;
uv2.y = 192.5f/256.0f; uv2.y = 192.5f / 256.0f;
uv2.x = 255.5f/256.0f; uv2.x = 255.5f / 256.0f;
uv1.y = 255.5f/256.0f; uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
} }
if ( m_icon == 16 ) // corner lower / left? if ( m_icon == 16 ) // corner lower / left?
{ {
m_engine->SetTexture("mouse.tga"); m_engine->SetTexture("mouse.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f; pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f; pos.y = m_pos.y+m_dim.y/150.0f;
uv2.x = 128.5f/256.0f; uv2.x = 128.5f / 256.0f;
uv2.y = 192.5f/256.0f; uv2.y = 192.5f / 256.0f;
uv1.x = 191.5f/256.0f; uv1.x = 191.5f / 256.0f;
uv1.y = 255.5f/256.0f; uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f; pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f; pos.y = m_pos.y-m_dim.y/150.0f;
uv2.x = 192.5f/256.0f; uv2.x = 192.5f / 256.0f;
uv2.y = 192.5f/256.0f; uv2.y = 192.5f / 256.0f;
uv1.x = 255.5f/256.0f; uv1.x = 255.5f / 256.0f;
uv1.y = 255.5f/256.0f; uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2); DrawIcon(pos, m_dim, uv1, uv2);
} }
if ( m_icon == 17 ) if ( m_icon == 17 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // blue frame uv1.x = 0.0f / 256.0f; // blue frame
uv1.y = 75.0f/256.0f; uv1.y = 75.0f / 256.0f;
uv2.x = 64.0f/256.0f; uv2.x = 64.0f / 256.0f;
uv2.y = 128.0f/256.0f; uv2.y = 128.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 6.0f/640.0f; corner.x = 6.0f / 640.0f;
corner.y = 6.0f/480.0f; corner.y = 6.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
} }
if ( m_icon == 18 ) // arrow> for SatCom? if ( m_icon == 18 ) // arrow> for SatCom?
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 0.0f/256.0f; // > uv1.x = 0.0f / 256.0f; // >
uv1.y = 192.0f/256.0f; uv1.y = 192.0f / 256.0f;
uv2.x = 32.0f/256.0f; uv2.x = 32.0f / 256.0f;
uv2.y = 224.0f/256.0f; uv2.y = 224.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -425,11 +427,11 @@ void CGroup::Draw()
if ( m_icon == 19 ) // SatCom symbol? if ( m_icon == 19 ) // SatCom symbol?
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 224.0f/256.0f; // SatCom symbol uv1.x = 224.0f / 256.0f; // SatCom symbol
uv1.y = 224.0f/256.0f; uv1.y = 224.0f / 256.0f;
uv2.x = 256.0f/256.0f; uv2.x = 256.0f / 256.0f;
uv2.y = 256.0f/256.0f; uv2.y = 256.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -439,11 +441,11 @@ void CGroup::Draw()
if ( m_icon == 20 ) // solid blue background? if ( m_icon == 20 ) // solid blue background?
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 224.0f/256.0f; uv1.x = 224.0f / 256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f / 256.0f;
uv2.x = 256.0f/256.0f; uv2.x = 256.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -453,11 +455,11 @@ void CGroup::Draw()
if ( m_icon == 21 ) // stand-by symbol? if ( m_icon == 21 ) // stand-by symbol?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 160.0f/256.0f; uv1.x = 160.0f / 256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f / 256.0f;
uv2.x = 192.0f/256.0f; uv2.x = 192.0f / 256.0f;
uv2.y = 64.0f/256.0f; uv2.y = 64.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -467,92 +469,92 @@ void CGroup::Draw()
if ( m_icon == 22 ) if ( m_icon == 22 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // opaque yellow uv1.x = 64.0f / 256.0f; // opaque yellow
uv1.y = 224.0f/256.0f; uv1.y = 224.0f / 256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f / 256.0f;
uv2.y = 240.0f/256.0f; uv2.y = 240.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 5.0f/640.0f; corner.x = 5.0f / 640.0f;
corner.y = 5.0f/480.0f; corner.y = 5.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 3.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 3.0f/256.0f);
} }
if ( m_icon == 23 ) if ( m_icon == 23 )
{ {
m_engine->SetTexture("button3.tga"); m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // yellow uv1.x = 64.0f / 256.0f; // yellow
uv1.y = 192.0f/256.0f; uv1.y = 192.0f / 256.0f;
uv2.x = 80.0f/256.0f; uv2.x = 80.0f / 256.0f;
uv2.y = 208.0f/256.0f; uv2.y = 208.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 4.0f/640.0f; corner.x = 4.0f / 640.0f;
corner.y = 4.0f/480.0f; corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
} }
if ( m_icon == 24 ) if ( m_icon == 24 )
{ {
m_engine->SetTexture("button3.tga"); m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 80.0f/256.0f; // orange uv1.x = 80.0f / 256.0f; // orange
uv1.y = 192.0f/256.0f; uv1.y = 192.0f / 256.0f;
uv2.x = 96.0f/256.0f; uv2.x = 96.0f / 256.0f;
uv2.y = 208.0f/256.0f; uv2.y = 208.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 4.0f/640.0f; corner.x = 4.0f / 640.0f;
corner.y = 4.0f/480.0f; corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
} }
if ( m_icon == 25 ) if ( m_icon == 25 )
{ {
m_engine->SetTexture("button3.tga"); m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // orange uv1.x = 64.0f / 256.0f; // orange
uv1.y = 208.0f/256.0f; uv1.y = 208.0f / 256.0f;
uv2.x = 80.0f/256.0f; uv2.x = 80.0f / 256.0f;
uv2.y = 224.0f/256.0f; uv2.y = 224.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 4.0f/640.0f; corner.x = 4.0f / 640.0f;
corner.y = 4.0f/480.0f; corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
} }
if ( m_icon == 26 ) if ( m_icon == 26 )
{ {
m_engine->SetTexture("button3.tga"); m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 80.0f/256.0f; // red uv1.x = 80.0f / 256.0f; // red
uv1.y = 208.0f/256.0f; uv1.y = 208.0f / 256.0f;
uv2.x = 96.0f/256.0f; uv2.x = 96.0f / 256.0f;
uv2.y = 224.0f/256.0f; uv2.y = 224.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 4.0f/640.0f; corner.x = 4.0f / 640.0f;
corner.y = 4.0f/480.0f; corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
} }
if ( m_icon == 27 ) if ( m_icon == 27 )
{ {
m_engine->SetTexture("button3.tga"); m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 32.0f/256.0f; uv1.x = 32.0f / 256.0f;
uv1.y = 0.0f/256.0f; uv1.y = 0.0f / 256.0f;
uv2.x = 64.0f/256.0f; uv2.x = 64.0f / 256.0f;
uv2.y = 32.0f/256.0f; uv2.y = 32.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
@ -566,9 +568,9 @@ void CGroup::Draw()
dim = m_dim; dim = m_dim;
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 32.0f/256.0f; uv1.x = 32.0f / 256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f / 256.0f;
uv2.x = uv1.x+32.0f/256.0f; uv2.x = uv1.x+32.0f/256.0f;
uv2.y = uv1.y+32.0f/256.0f; uv2.y = uv1.y+32.0f/256.0f;
uv1.x += dp; uv1.x += dp;
@ -578,13 +580,13 @@ void CGroup::Draw()
DrawIcon(pos, dim, uv1, uv2); DrawIcon(pos, dim, uv1, uv2);
m_engine->SetTexture("button3.tga"); m_engine->SetTexture("button3.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
pos.x += 8.0f/640.0f; pos.x += 8.0f / 640.0f;
pos.y += 8.0f/480.0f; pos.y += 8.0f / 480.0f;
dim.x -= 16.0f/640.0f; dim.x -= 16.0f / 640.0f;
dim.y -= 16.0f/480.0f; dim.y -= 16.0f / 480.0f;
uv1.x = 32.0f/256.0f; uv1.x = 32.0f / 256.0f;
uv1.y = 0.0f/256.0f; uv1.y = 0.0f / 256.0f;
uv2.x = uv1.x+32.0f/256.0f; uv2.x = uv1.x+32.0f/256.0f;
uv2.y = uv1.y+32.0f/256.0f; uv2.y = uv1.y+32.0f/256.0f;
uv1.x += dp; uv1.x += dp;
@ -593,13 +595,13 @@ void CGroup::Draw()
uv2.y -= dp; uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2); DrawIcon(pos, dim, uv1, uv2);
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
pos.x += 2.0f/640.0f; pos.x += 2.0f / 640.0f;
pos.y += 2.0f/480.0f; pos.y += 2.0f / 480.0f;
dim.x -= 4.0f/640.0f; dim.x -= 4.0f / 640.0f;
dim.y -= 4.0f/480.0f; dim.y -= 4.0f / 480.0f;
uv1.x = 0.0f/256.0f; uv1.x = 0.0f / 256.0f;
uv1.y = 0.0f/256.0f; uv1.y = 0.0f / 256.0f;
uv2.x = uv1.x+32.0f/256.0f; uv2.x = uv1.x+32.0f/256.0f;
uv2.y = uv1.y+32.0f/256.0f; uv2.y = uv1.y+32.0f/256.0f;
uv1.x += dp; uv1.x += dp;
@ -608,11 +610,11 @@ void CGroup::Draw()
uv2.y -= dp; uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2); DrawIcon(pos, dim, uv1, uv2);
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x += 8.0f/640.0f; pos.x += 8.0f / 640.0f;
pos.y += 8.0f/480.0f; pos.y += 8.0f / 480.0f;
dim.x -= 16.0f/640.0f; dim.x -= 16.0f / 640.0f;
dim.y -= 16.0f/480.0f; dim.y -= 16.0f / 480.0f;
if ( m_icon == 100 ) icon = 43; // base ? if ( m_icon == 100 ) icon = 43; // base ?
if ( m_icon == 101 ) icon = 32; // factory ? if ( m_icon == 101 ) icon = 32; // factory ?
if ( m_icon == 102 ) icon = 35; // research ? if ( m_icon == 102 ) icon = 35; // research ?
@ -642,3 +644,4 @@ void CGroup::Draw()
} }
}

View File

@ -21,18 +21,20 @@
#include "ui/control.h" #include "ui/control.h"
namespace Gfx{
class CEngine;
};
class CD3DEngine; namespace Ui {
class CGroup : public CControl class CGroup : public CControl
{ {
public: public:
CGroup(CInstanceManager* iMan); // CGroup(CInstanceManager* iMan);
CGroup();
virtual ~CGroup(); virtual ~CGroup();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
@ -44,3 +46,4 @@ protected:
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,13 +18,14 @@
// image.cpp // image.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" #include "graphics/engine/engine.h"
//#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -32,10 +34,11 @@
namespace Ui {
// Object's constructor. // Object's constructor.
CImage::CImage(CInstanceManager* iMan) : CControl(iMan) //CImage::CImage(CInstanceManager* iMan) : CControl(iMan)
CImage::CImage() : CControl()
{ {
m_filename[0] = 0; m_filename[0] = 0;
} }
@ -46,25 +49,25 @@ CImage::~CImage()
{ {
if ( m_filename[0] != 0 ) if ( m_filename[0] != 0 )
{ {
m_engine->FreeTexture(m_filename); m_engine->DeleteTexture(m_filename);
} }
} }
// Creates a new button. // Creates a new button.
bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CImage::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);
if ( icon == -1 ) if ( icon == -1 )
{ {
char name[100]; char name[100];
char* p; char* p;
GetResource(RES_EVENT, eventMsg, name); GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\'); p = strchr(name, '\\');
if ( p != 0 ) *p = 0; if ( p != 0 ) *p = 0;
SetName(name); SetName(name);
@ -80,13 +83,13 @@ void CImage::SetFilenameImage(char *name)
{ {
if ( m_filename[0] != 0 ) if ( m_filename[0] != 0 )
{ {
m_engine->FreeTexture(m_filename); m_engine->DeleteTexture(m_filename);
} }
strcpy(m_filename, name); strcpy(m_filename, name);
} }
char* CImage::RetFilenameImage() char* CImage::GetFilenameImage()
{ {
return m_filename; return m_filename;
} }
@ -119,17 +122,17 @@ void CImage::Draw()
if ( m_icon == 0 ) // hollow frame? if ( m_icon == 0 ) // hollow frame?
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 160.0f/256.0f; uv1.x = 160.0f / 256.0f;
uv1.y = 192.0f/256.0f; // u-v texture uv1.y = 192.0f / 256.0f; // u-v texture
uv2.x = 192.0f/256.0f; uv2.x = 192.0f / 256.0f;
uv2.y = 224.0f/256.0f; uv2.y = 224.0f / 256.0f;
uv1.x += dp; uv1.x += dp;
uv1.y += dp; uv1.y += dp;
uv2.x -= dp; uv2.x -= dp;
uv2.y -= dp; uv2.y -= dp;
corner.x = 10.0f/640.0f; corner.x = 10.0f / 640.0f;
corner.y = 10.0f/480.0f; corner.y = 10.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f); DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f);
} }
@ -137,13 +140,13 @@ void CImage::Draw()
{ {
m_engine->LoadTexture(m_filename); m_engine->LoadTexture(m_filename);
m_engine->SetTexture(m_filename); m_engine->SetTexture(m_filename);
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
pos = m_pos; pos = m_pos;
dim = m_dim; dim = m_dim;
pos.x += 5.0f/640.0f; pos.x += 5.0f / 640.0f;
pos.y += 5.0f/480.0f; pos.y += 5.0f / 480.0f;
dim.x -= 10.0f/640.0f; dim.x -= 10.0f / 640.0f;
dim.y -= 10.0f/480.0f; dim.y -= 10.0f / 480.0f;
uv1.x = 0.0f; uv1.x = 0.0f;
uv1.y = 0.0f; uv1.y = 0.0f;
uv2.x = 1.0f; uv2.x = 1.0f;
@ -153,3 +156,4 @@ void CImage::Draw()
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -21,25 +22,28 @@
#include "ui/control.h" #include "ui/control.h"
namespace Gfx{
class CD3DEngine; class CEngine;
};
namespace Ui {
class CImage : public CControl class CImage : public CControl
{ {
public: public:
CImage(CInstanceManager* iMan); // CImage(CInstanceManager* iMan);
CImage ();
virtual ~CImage(); virtual ~CImage();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); 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 SetFilenameImage(char *name); void SetFilenameImage(char *name);
char* RetFilenameImage(); char* GetFilenameImage();
protected: protected:
@ -48,3 +52,4 @@ protected:
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,55 +18,21 @@
// interface.cpp // interface.cpp
#include <windows.h> #include <ui/interface.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h" namespace Ui {
#include "old/d3dengine.h"
#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.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 "old/camera.h"
#include "ui/interface.h"
CInterface::CInterface()
// Object's constructor.
CInterface::CInterface(CInstanceManager* iMan)
{ {
int i; m_iMan = CInstanceManager::GetInstancePointer();
m_iMan = iMan;
m_iMan->AddInstance(CLASS_INTERFACE, this); m_iMan->AddInstance(CLASS_INTERFACE, this);
m_event = static_cast<CEventQueue *>( m_iMan->SearchInstance(CLASS_EVENT) );
m_engine = static_cast<Gfx::CEngine *>( m_iMan->SearchInstance(CLASS_ENGINE) );
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE); for (int i = 0; i < MAXCONTROL; i++ )
m_camera = 0;
for ( i=0 ; i<MAXCONTROL ; i++ )
{ {
m_table[i] = 0; m_table[i] = nullptr;
} }
} }
@ -74,6 +41,7 @@ CInterface::CInterface(CInstanceManager* iMan)
CInterface::~CInterface() CInterface::~CInterface()
{ {
Flush(); Flush();
m_iMan->DeleteInstance(CLASS_INTERFACE, this);
} }
@ -81,424 +49,210 @@ CInterface::~CInterface()
void CInterface::Flush() void CInterface::Flush()
{ {
int i; for (int i = 0; i < MAXCONTROL; i++ ) {
if ( m_table[i] != nullptr ) {
for ( i=0 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] != 0 )
{
delete m_table[i]; delete m_table[i];
m_table[i] = 0; m_table[i] = nullptr;
} }
} }
} }
int CInterface::GetNextFreeControl()
{
for (int i = 10; i < MAXCONTROL-1; i++) {
if (m_table[i] == nullptr)
return i;
}
return -1;
}
template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
T* pc;
int index;
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
if ((index = GetNextFreeControl()) < 0)
return nullptr;
m_table[index] = new T();
pc = static_cast<T *>(m_table[index]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
// Creates a new button. // Creates a new button.
CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CWindow* pc; CWindow* pc;
int i; int index;
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); switch (eventMsg) {
case EVENT_WINDOW0: index = 0; break;
if ( eventMsg == EVENT_WINDOW0 ) {i=0; goto create;} case EVENT_WINDOW1: index = 1; break;
if ( eventMsg == EVENT_WINDOW1 ) {i=1; goto create;} case EVENT_WINDOW2: index = 2; break;
if ( eventMsg == EVENT_WINDOW2 ) {i=2; goto create;} case EVENT_WINDOW3: index = 3; break;
if ( eventMsg == EVENT_WINDOW3 ) {i=3; goto create;} case EVENT_WINDOW4: index = 4; break;
if ( eventMsg == EVENT_WINDOW4 ) {i=4; goto create;} case EVENT_WINDOW5: index = 5; break;
if ( eventMsg == EVENT_WINDOW5 ) {i=5; goto create;} case EVENT_WINDOW6: index = 6; break;
if ( eventMsg == EVENT_WINDOW6 ) {i=6; goto create;} case EVENT_WINDOW7: index = 7; break;
if ( eventMsg == EVENT_WINDOW7 ) {i=7; goto create;} case EVENT_WINDOW8: index = 8; break;
if ( eventMsg == EVENT_WINDOW8 ) {i=8; goto create;} case EVENT_WINDOW9: index = 9; break;
if ( eventMsg == EVENT_WINDOW9 ) {i=9; goto create;} case EVENT_TOOLTIP: index = MAXCONTROL-1; break;
default: index = GetNextFreeControl(); break;
if ( eventMsg == EVENT_TOOLTIP ) {i=MAXCONTROL-1; goto create;}
for ( i=10 ; i<MAXCONTROL-1 ; i++ )
{
if ( m_table[i] == 0 )
{
create:
m_table[i] = new CWindow(m_iMan);
pc = (CWindow*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
} }
return 0;
if (index < 0)
return nullptr;
m_table[index] = new CWindow();
pc = static_cast<CWindow *>(m_table[index]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
} }
// Creates a new button. // Creates a new button.
CButton* CInterface::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CButton* CInterface::CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CButton* pc; return CreateControl<CButton>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CButton(m_iMan);
pc = (CButton*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new button. // Creates a new button.
CColor* CInterface::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CColor* CInterface::CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CColor* pc; return CreateControl<CColor>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CColor(m_iMan);
pc = (CColor*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new button. // Creates a new button.
CCheck* CInterface::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CCheck* CInterface::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CCheck* pc; return CreateControl<CCheck>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CCheck(m_iMan);
pc = (CCheck*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new button. // Creates a new button.
CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CKey* pc; return CreateControl<CKey>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CKey(m_iMan);
pc = (CKey*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new button. // Creates a new button.
CGroup* CInterface::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CGroup* CInterface::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CGroup* pc; return CreateControl<CGroup>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CGroup(m_iMan);
pc = (CGroup*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new button. // Creates a new button.
CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CImage* pc; return CreateControl<CImage>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CImage(m_iMan);
pc = (CImage*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new label. // Creates a new label.
CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, const char *name)
char *name)
{ {
CLabel* pc; CLabel* pc = CreateControl<CLabel>(pos, dim, icon, eventMsg);
int i; if (pc != nullptr)
pc->SetName(name);
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); return pc;
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CLabel(m_iMan);
pc = (CLabel*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
pc->SetName(name);
return pc;
}
}
return 0;
} }
// Creates a new pave editable. // Creates a new pave editable.
CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CEdit* pc; return CreateControl<CEdit>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CEdit(m_iMan);
pc = (CEdit*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new pave editable. // Creates a new pave editable.
CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CEditValue* pc; return CreateControl<CEditValue>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CEditValue(m_iMan);
pc = (CEditValue*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new lift. // Creates a new lift.
CScroll* CInterface::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CScroll* CInterface::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CScroll* pc; return CreateControl<CScroll>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CScroll(m_iMan);
pc = (CScroll*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new cursor. // Creates a new cursor.
CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CSlider* pc; return CreateControl<CSlider>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CSlider(m_iMan);
pc = (CSlider*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new list. // Creates a new list.
CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand)
float expand)
{ {
CList* pc; CList* pc;
int i; int index;
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ((index = GetNextFreeControl()) < 0)
return nullptr;
for ( i=10 ; i<MAXCONTROL ; i++ ) m_table[index] = new CList();
{ pc = static_cast<CList *>(m_table[index]);
if ( m_table[i] == 0 ) pc->Create(pos, dim, icon, eventMsg, expand);
{ return pc;
m_table[i] = new CList(m_iMan);
pc = (CList*)m_table[i];
pc->Create(pos, dim, icon, eventMsg, expand);
return pc;
}
}
return 0;
} }
// Creates a new shortcut. // Creates a new shortcut.
CShortcut* CInterface::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CShortcut* CInterface::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CShortcut* ps; return CreateControl<CShortcut>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CShortcut(m_iMan);
ps = (CShortcut*)m_table[i];
ps->Create(pos, dim, icon, eventMsg);
return ps;
}
}
return 0;
} }
// Creates a new compass. // Creates a new compass.
CCompass* CInterface::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CCompass* CInterface::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CCompass* pc; return CreateControl<CCompass>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CCompass(m_iMan);
pc = (CCompass*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new target. // Creates a new target.
CTarget* CInterface::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CTarget* CInterface::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CTarget* pc; return CreateControl<CTarget>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CTarget(m_iMan);
pc = (CTarget*)m_table[i];
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
} }
// Creates a new map. // Creates a new map.
CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CMap* pm; return CreateControl<CMap>(pos, dim, icon, eventMsg);
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
for ( i=10 ; i<MAXCONTROL ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CMap(m_iMan);
pm = (CMap*)m_table[i];
pm->Create(pos, dim, icon, eventMsg);
return pm;
}
}
return 0;
} }
// Removes a control. // Removes a control.
bool CInterface::DeleteControl(EventMsg eventMsg) bool CInterface::DeleteControl(EventType eventMsg)
{ {
int i; for (int i = 0; i < MAXCONTROL; i++) {
if ( m_table[i] != nullptr ) {
for ( i=0 ; i<MAXCONTROL ; i++ ) if (eventMsg == m_table[i]->GetEventType()) {
{
if ( m_table[i] != 0 )
{
if ( eventMsg == m_table[i]->RetEventMsg() )
{
delete m_table[i]; delete m_table[i];
m_table[i] = 0; m_table[i] = nullptr;
return true; return true;
} }
} }
@ -508,47 +262,32 @@ bool CInterface::DeleteControl(EventMsg eventMsg)
// Gives a control. // Gives a control.
CControl* CInterface::SearchControl(EventMsg eventMsg) CControl* CInterface::SearchControl(EventType eventMsg)
{ {
int i; for (int i = 0; i < MAXCONTROL; i++) {
if (m_table[i] != nullptr) {
for ( i=0 ; i<MAXCONTROL ; i++ ) if (eventMsg == m_table[i]->GetEventType())
{
if ( m_table[i] != 0 )
{
if ( eventMsg == m_table[i]->RetEventMsg() )
{
return m_table[i]; return m_table[i];
}
} }
} }
return 0; return nullptr;
} }
// Management of an event. // Management of an event.
bool CInterface::EventProcess(const Event &event) bool CInterface::EventProcess(const Event &event)
{ {
int i; if (event.type == EVENT_MOUSE_MOVE) {
if (m_camera == nullptr) {
if ( event.event == EVENT_MOUSEMOVE ) m_camera = static_cast<Gfx::CCamera *>(m_iMan->SearchInstance(CLASS_CAMERA));
{
if ( m_camera == 0 )
{
m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
} }
m_engine->SetMouseType(m_camera->RetMouseDef(event.pos)); m_engine->SetMouseType(m_camera->GetMouseDef(event.pos));
} }
for ( i=MAXCONTROL-1 ; i>=0 ; i-- ) for (int i = MAXCONTROL-1; i >= 0; i--) {
{ if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE)) {
if ( m_table[i] != 0 &&
m_table[i]->TestState(STATE_ENABLE) )
{
if ( !m_table[i]->EventProcess(event) ) if ( !m_table[i]->EventProcess(event) )
{
return false; return false;
}
} }
} }
@ -558,18 +297,12 @@ bool CInterface::EventProcess(const Event &event)
// Gives the tooltip binding to the window. // Gives the tooltip binding to the window.
bool CInterface::GetTooltip(Math::Point pos, char* name) bool CInterface::GetTooltip(Math::Point pos, const char* name)
{ {
int i; for (int i = MAXCONTROL-1; i >= 0; i--) {
if (m_table[i] != nullptr) {
for ( i=MAXCONTROL-1 ; i>=0 ; i-- ) if (m_table[i]->GetTooltip(pos, name))
{
if ( m_table[i] != 0 )
{
if ( m_table[i]->GetTooltip(pos, name) )
{
return true; return true;
}
} }
} }
return false; return false;
@ -580,26 +313,19 @@ bool CInterface::GetTooltip(Math::Point pos, char* name)
void CInterface::Draw() void CInterface::Draw()
{ {
D3DMATERIAL7 material; /*ZeroMemory( &material, sizeof(D3DMATERIAL7) );
int i;
ZeroMemory( &material, sizeof(D3DMATERIAL7) );
material.diffuse.r = 1.0f; material.diffuse.r = 1.0f;
material.diffuse.g = 1.0f; material.diffuse.g = 1.0f;
material.diffuse.b = 1.0f; material.diffuse.b = 1.0f;
material.ambient.r = 0.5f; material.ambient.r = 0.5f;
material.ambient.g = 0.5f; material.ambient.g = 0.5f;
material.ambient.b = 0.5f; material.ambient.b = 0.5f;
m_engine->SetMaterial(material); m_engine->SetMaterial(material);*/
for ( i=0 ; i<MAXCONTROL ; i++ ) for (int i = 0; i < MAXCONTROL; i++) {
//? for ( i=MAXCONTROL-1 ; i>=0 ; i-- ) if ( m_table[i] != nullptr )
{
if ( m_table[i] != 0 )
{
m_table[i]->Draw(); m_table[i]->Draw();
}
} }
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -19,77 +20,85 @@
#pragma once #pragma once
#include "common/event.h" #include <common/event.h>
#include "math/point.h" #include <common/struct.h>
#include <common/misc.h>
#include <common/iman.h>
#include <math/point.h>
class CInstanceManager; #include <graphics/engine/camera.h>
class CD3DEngine; #include <graphics/engine/engine.h>
class CControl;
class CWindow;
class CButton;
class CColor;
class CCheck;
class CKey;
class CGroup;
class CImage;
class CLabel;
class CEdit;
class CEditValue;
class CScroll;
class CSlider;
class CList;
class CShortcut;
class CMap;
class CGauge;
class CCompass;
class CTarget;
class CCamera;
namespace Ui {
const int MAXCONTROL = 100; 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 class CInterface
{ {
public: public:
CInterface(CInstanceManager* iMan); CInterface();
~CInterface(); ~CInterface();
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
bool GetTooltip(Math::Point pos, char* name); bool GetTooltip(Math::Point pos, const char* name);
void Flush(); void Flush();
CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name); CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f); CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool DeleteControl(EventMsg eventMsg);
CControl* SearchControl(EventMsg eventMsg);
void Draw(); 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);
protected: bool DeleteControl(EventType eventMsg);
CControl* SearchControl(EventType eventMsg);
protected: void Draw();
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CCamera* m_camera;
CControl* m_table[MAXCONTROL]; protected:
int GetNextFreeControl();
template <typename T> inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CInstanceManager* m_iMan;
CEventQueue* m_event;
Gfx::CEngine* m_engine;
Gfx::CCamera* m_camera;
CControl* m_table[MAXCONTROL];
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,54 +18,33 @@
// key.cpp // key.cpp
#include <windows.h> #include <ui/key.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h" namespace Ui {
#include "old/d3dengine.h"
#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
#include "old/sound.h"
#include "old/text.h"
#include "ui/key.h"
// Constructs the name of a button.
void GetKeyName(char *name, int key) void GetKeyName(char *name, int key)
{ {
if ( !GetResource(RES_KEY, key, name) ) if ( !GetResource(RES_KEY, key, name) ) {
{ if (isalnum(key)) {
if ( (key >= '0' && key <= '9') ||
(key >= 'A' && key <= 'Z') ||
(key >= 'a' && key <= 'z') )
{
name[0] = key; name[0] = key;
name[1] = 0; name[1] = 0;
} }
else else {
{
sprintf(name, "Code %d", key); sprintf(name, "Code %d", key);
} }
} }
} }
// Object's constructor. // Object's constructor.
CKey::CKey(CInstanceManager* iMan) : CControl(iMan) CKey::CKey() : CControl()
{ {
m_key[0] = 0; m_key[0] = 0;
m_key[1] = 0; m_key[1] = 0;
m_bCatch = false; m_bCatch = false;
m_app = CApplication::GetInstancePointer();
} }
// Object's destructor. // Object's destructor.
@ -76,18 +56,14 @@ CKey::~CKey()
// Creates a new button. // Creates a new button.
bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
char name[100]; char name[100];
char* p; if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
CControl::Create(pos, dim, icon, eventMsg); CControl::Create(pos, dim, icon, eventMsg);
GetResource(RES_EVENT, eventMsg, name); GetResource(RES_EVENT, eventMsg, name);
p = strchr(name, '\\');
if ( p != 0 ) *p = 0;
SetName(name); SetName(name);
return true; return true;
@ -98,47 +74,33 @@ bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
bool CKey::EventProcess(const Event &event) bool CKey::EventProcess(const Event &event)
{ {
if ( m_state & STATE_DEAD ) return true; if (m_state & STATE_DEAD)
return true;
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_LBUTTONDOWN ) if (event.type == EVENT_MOUSE_BUTTON_DOWN) {
{ if (event.mouseButton.button == 1) // left
if ( Detect(event.pos) ) m_bCatch = Detect(event.pos);
{
m_bCatch = true;
}
else
{
m_bCatch = false;
}
} }
if ( event.event == EVENT_KEYDOWN && m_bCatch ) if (event.type == EVENT_MOUSE_BUTTON_DOWN && m_bCatch) {
{
m_bCatch = false; m_bCatch = false;
if ( TestKey(event.param) ) // impossible ? if ( TestKey(event.param) ) { // impossible ?
{
m_sound->Play(SOUND_TZOING); m_sound->Play(SOUND_TZOING);
} } else {
else if ( event.param == m_key[0] || event.param == m_key[1] ) {
{
if ( event.param == m_key[0] ||
event.param == m_key[1] )
{
m_key[0] = event.param; m_key[0] = event.param;
m_key[1] = 0; m_key[1] = 0;
} } else {
else
{
m_key[1] = m_key[0]; m_key[1] = m_key[0];
m_key[0] = event.param; m_key[0] = event.param;
} }
m_sound->Play(SOUND_CLICK); m_sound->Play(SOUND_CLICK);
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
return false; return false;
@ -152,25 +114,17 @@ bool CKey::EventProcess(const Event &event)
bool CKey::TestKey(int key) bool CKey::TestKey(int key)
{ {
int i, j; if ( key == KEY(PAUSE) || key == KEY(PRINT) ) return true; // blocked key
if ( key == VK_PAUSE || for (int i = 0; i < 20; i++) {
key == VK_SNAPSHOT ) return true; // blocked key for (int j = 0; j < 2; j++) {
if (key == m_app->GetKey(i, j) ) // key used?
for ( i=0 ; i<20 ; i++ ) m_app->SetKey(i, j, 0); // nothing!
{
for ( j=0 ; j<2 ; j++ )
{
if ( key == m_engine->RetKey(i, j) ) // key used?
{
m_engine->SetKey(i, j, 0); // nothing!
}
} }
if ( m_engine->RetKey(i, 0) == 0 ) // first free option? if ( m_app->GetKey(i, 0) == 0 ) { // first free option?
{ m_app->SetKey(i, 0, m_app->GetKey(i, 1)); // shift
m_engine->SetKey(i, 0, m_engine->RetKey(i, 1)); // shift m_app->SetKey(i, 1, 0);
m_engine->SetKey(i, 1, 0);
} }
} }
@ -182,107 +136,99 @@ bool CKey::TestKey(int key)
void CKey::Draw() void CKey::Draw()
{ {
Math::Point iDim, pos; Math::Point iDim, pos;
float zoomExt, zoomInt, h; float zoomExt, zoomInt, h;
int icon; int icon;
char text[100]; char text[100];
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 )
return;
iDim = m_dim; iDim = m_dim;
m_dim.x = 200.0f/640.0f; m_dim.x = 200.0f/640.0f;
if ( m_state & STATE_SHADOW ) if ( m_state & STATE_SHADOW )
{
DrawShadow(m_pos, m_dim); DrawShadow(m_pos, m_dim);
}
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL
zoomExt = 1.00f; zoomExt = 1.00f;
zoomInt = 0.95f; zoomInt = 0.95f;
icon = 2; icon = 2;
if ( m_key[0] == 0 && if ( m_key[0] == 0 && m_key[1] == 0 ) // no shortcut?
m_key[1] == 0 ) // no shortcut?
{
icon = 3; icon = 3;
}
if ( m_state & STATE_DEFAULT ) if ( m_state & STATE_DEFAULT ) {
{
DrawPart(23, 1.3f, 0.0f); DrawPart(23, 1.3f, 0.0f);
zoomExt *= 1.15f; zoomExt *= 1.15f;
zoomInt *= 1.15f; zoomInt *= 1.15f;
} }
if ( m_state & STATE_HILIGHT ) if ( m_state & STATE_HILIGHT )
{
icon = 1; icon = 1;
}
if ( m_state & STATE_CHECK ) if ( m_state & STATE_CHECK )
{
icon = 0; icon = 0;
}
if ( m_state & STATE_PRESS ) if ( m_state & STATE_PRESS ) {
{
icon = 3; icon = 3;
zoomInt *= 0.9f; zoomInt *= 0.9f;
} }
if ( (m_state & STATE_ENABLE) == 0 )
{
icon = 7;
}
if ( m_state & STATE_DEAD )
{
icon = 17;
}
if ( m_bCatch )
{
icon = 23;
}
DrawPart(icon, zoomExt, 8.0f/256.0f); // draws the button
h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f; if ( (m_state & STATE_ENABLE) == 0 )
icon = 7;
if ( m_state & STATE_DEAD )
icon = 17;
if ( m_bCatch )
icon = 23;
DrawPart(icon, zoomExt, 8.0f / 256.0f); // draws the button
h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
GetKeyName(text, m_key[0]); GetKeyName(text, m_key[0]);
if ( m_key[1] != 0 ) if ( m_key[1] != 0 ) {
{
GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text)); GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text));
GetKeyName(text+strlen(text), m_key[1]); GetKeyName(text+strlen(text), m_key[1]);
} }
pos.x = m_pos.x+m_dim.x*0.5f; pos.x = m_pos.x + m_dim.x * 0.5f;
pos.y = m_pos.y+m_dim.y*0.5f; pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h; pos.y -= h;
m_engine->RetText()->DrawText(text, pos, m_dim.x, 0, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_CENTER, 0);
m_dim = iDim; m_dim = iDim;
if ( m_state & STATE_DEAD ) return; if ( m_state & STATE_DEAD )
return;
// Draws the name. // Draws the name.
pos.x = m_pos.x+(214.0f/640.0f); pos.x = m_pos.x + (214.0f / 640.0f);
pos.y = m_pos.y+m_dim.y*0.5f; pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h; pos.y -= h;
m_engine->RetText()->DrawText(m_name, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, 0);
} }
void CKey::SetKey(int option, int key) void CKey::SetKey(int option, int key)
{ {
if ( option < 0 || if ( option < 0 || option > 1 ) return;
option > 1 ) return;
m_key[option] = key; m_key[option] = key;
} }
int CKey::RetKey(int option) int CKey::GetKey(int option)
{ {
if ( option < 0 || if ( option < 0 || option > 1 ) return 0;
option > 1 ) return 0;
return m_key[option]; return m_key[option];
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -18,35 +19,43 @@
#pragma once #pragma once
#include <cctype>
#include <string>
#include "ui/control.h" #include <ui/control.h>
#include <common/iman.h>
#include <common/event.h>
#include <common/restext.h>
#include <common/key.h>
class CD3DEngine; #include <app/app.h>
namespace Ui {
class CKey : public CControl class CKey : public CControl
{ {
public: public:
CKey(CInstanceManager* iMan); CKey();
virtual ~CKey(); virtual ~CKey();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event);
bool EventProcess(const Event &event); void Draw();
void Draw(); void SetKey(int option, int key);
int GetKey(int option);
void SetKey(int option, int key); protected:
int RetKey(int option); bool TestKey(int key);
protected: int m_key[2];
bool TestKey(int key); bool m_bCatch;
protected: CApplication *m_app;
int m_key[2];
bool m_bCatch;
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,25 +18,14 @@
// label.cpp // label.cpp
#include <windows.h> #include <ui/label.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "old/d3dengine.h"
#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "old/text.h"
#include "ui/label.h"
namespace Ui {
// Object's constructor. // Object's constructor.
CLabel::CLabel(CInstanceManager* iMan) : CControl(iMan) CLabel::CLabel() : CControl()
{ {
} }
@ -48,9 +38,10 @@ CLabel::~CLabel()
// Creates a new button. // Creates a new button.
bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CLabel::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); CControl::Create(pos, dim, icon, eventMsg);
return true; return true;
@ -72,22 +63,18 @@ void CLabel::Draw()
{ {
Math::Point pos; Math::Point pos;
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 )
return;
pos.y = m_pos.y+m_dim.y/2.0f; pos.y = m_pos.y + m_dim.y / 2.0f;
if ( m_justif > 0 ) switch (m_textAlign) {
{ case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x; break;
pos.x = m_pos.x; case Gfx::TEXT_ALIGN_CENTER: pos.x = m_pos.x + m_dim.x / 2.0f; break;
case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x + m_dim.x; break;
} }
if ( m_justif == 0 )
{ m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
pos.x = m_pos.x+m_dim.x/2.0f;
}
if ( m_justif < 0 )
{
pos.x = m_pos.x+m_dim.x;
}
m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0);
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -19,28 +20,24 @@
#pragma once #pragma once
#include "ui/control.h" #include <ui/control.h>
class CD3DEngine;
#include <common/event.h>
#include <common/misc.h>
namespace Ui {
class CLabel : public CControl class CLabel : public CControl
{ {
public: public:
CLabel(CInstanceManager* iMan); CLabel();
virtual ~CLabel(); virtual ~CLabel();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event);
bool EventProcess(const Event &event); void Draw();
void Draw();
protected:
protected:
}; };
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -19,14 +20,17 @@
#pragma once #pragma once
#include "ui/control.h" #include <ui/control.h>
#include "common/event.h" #include <ui/button.h>
#include <ui/scroll.h>
#include <common/event.h>
#include <common/misc.h>
#include <graphics/engine/text.h>
class CD3DEngine; namespace Ui {
class CButton;
class CScroll;
const int LISTMAXDISPLAY = 20; // maximum number of visible lines const int LISTMAXDISPLAY = 20; // maximum number of visible lines
const int LISTMAXTOTAL = 100; // maximum total number of lines const int LISTMAXTOTAL = 100; // maximum total number of lines
@ -35,81 +39,83 @@ const int LISTMAXTOTAL = 100; // maximum total number of lines
class CList : public CControl class CList : public CControl
{ {
public: public:
CList(CInstanceManager* iMan); CList();
~CList(); ~CList();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand);
void SetPos(Math::Point pos); void SetPos(Math::Point pos);
void SetDim(Math::Point dim); void SetDim(Math::Point dim);
bool SetState(int state, bool bState); bool SetState(int state, bool bState);
bool SetState(int state); bool SetState(int state);
bool ClearState(int state); bool ClearState(int state);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void Draw(); void Draw();
void Flush(); void Flush();
void SetTotal(int i); void SetTotal(int i);
int RetTotal(); int GetTotal();
void SetSelect(int i); void SetSelect(int i);
int RetSelect(); int GetSelect();
void SetSelectCap(bool bEnable); void SetSelectCap(bool bEnable);
bool RetSelectCap(); bool GetSelectCap();
void SetBlink(bool bEnable); void SetBlink(bool bEnable);
bool RetBlink(); bool GetBlink();
void SetName(int i, char* name); void SetName(int i, char* name);
char* RetName(int i); char* GetName(int i);
void SetCheck(int i, bool bMode); void SetCheck(int i, bool bMode);
bool RetCheck(int i); bool GetCheck(int i);
void SetEnable(int i, bool bEnable); void SetEnable(int i, bool bEnable);
bool RetEnable(int i); bool GetEnable(int i);
void SetTabs(int i, float pos, int justif=1); void SetTabs(int i, float pos, Gfx::TextAlign justif=Gfx::TEXT_ALIGN_CENTER);
float RetTabs(int i); float GetTabs(int i);
void ShowSelect(bool bFixed); void ShowSelect(bool bFixed);
EventMsg RetEventMsgButton(int i); EventType GetEventMsgButton(int i);
EventMsg RetEventMsgScroll(); EventType GetEventMsgScroll();
protected: protected:
bool MoveAdjust(); bool MoveAdjust();
void UpdateButton(); void UpdateButton();
void UpdateScroll(); void UpdateScroll();
void MoveScroll(); void MoveScroll();
void DrawCase(char *text, Math::Point pos, float width, int justif); void DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif);
protected: protected:
CButton* m_button[LISTMAXDISPLAY]; CButton* m_button[LISTMAXDISPLAY];
CScroll* m_scroll; CScroll* m_scroll;
EventMsg m_eventButton[LISTMAXDISPLAY]; EventType m_eventButton[LISTMAXDISPLAY];
EventMsg m_eventScroll; EventType m_eventScroll;
float m_expand; float m_expand;
int m_totalLine; // total number of lines int m_totalLine; // total number of lines
int m_displayLine; // number of visible lines int m_displayLine; // number of visible lines
int m_selectLine; // selected line int m_selectLine; // selected line
int m_firstLine; // first visible line int m_firstLine; // first visible line
bool m_bBlink; bool m_bBlink;
bool m_bSelectCap; bool m_bSelectCap;
float m_blinkTime; float m_blinkTime;
float m_tabs[10]; float m_tabs[10];
int m_justifs[10]; Gfx::TextAlign m_justifs[10];
char m_text[LISTMAXTOTAL][100]; char m_text[LISTMAXTOTAL][100];
char m_check[LISTMAXTOTAL]; char m_check[LISTMAXTOTAL];
char m_enable[LISTMAXTOTAL]; char m_enable[LISTMAXTOTAL];
}; };
}

View File

@ -19,16 +19,14 @@
#pragma once #pragma once
#include "ui/control.h" #include <ui/control.h>
#include "object/object.h"
#include <object/object.h>
#include <common/event.h>
class CD3DEngine;
class CTerrain; class CTerrain;
class CWater; class CWater;
class CRobotMain;
const int MAPMAXOBJECT = 100; const int MAPMAXOBJECT = 100;
@ -53,7 +51,7 @@ struct MapObject
CObject* object; CObject* object;
MapColor color; MapColor color;
ObjectType type; ObjectType type;
Math::Point pos; Math::Point pos;
float dir; float dir;
}; };
@ -62,10 +60,10 @@ struct MapObject
class CMap : public CControl class CMap : public CControl
{ {
public: public:
CMap(CInstanceManager* iMan); CMap();
~CMap(); ~CMap();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void Draw(); void Draw();
@ -87,8 +85,8 @@ public:
void SetEnable(bool bEnable); void SetEnable(bool bEnable);
bool RetEnable(); bool RetEnable();
void SetFloorColor(D3DCOLORVALUE color); void SetFloorColor(Gfx::Color color);
void SetWaterColor(D3DCOLORVALUE color); void SetWaterColor(Gfx::Color color);
void FlushObject(); void FlushObject();
void UpdateObject(CObject* pObj); void UpdateObject(CObject* pObj);
@ -97,9 +95,9 @@ public:
void SetHilite(CObject* pObj); void SetHilite(CObject* pObj);
protected: protected:
Math::Point AdjustOffset(Math::Point offset); Math::Point AdjustOffset(Math::Point offset);
void SelectObject(Math::Point pos); void SelectObject(Math::Point pos);
Math::Point MapInter(Math::Point pos, float dir); Math::Point MapInter(Math::Point pos, float dir);
void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color); 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 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 DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
@ -117,16 +115,16 @@ protected:
float m_time; float m_time;
float m_half; float m_half;
float m_zoom; float m_zoom;
Math::Point m_offset; Math::Point m_offset;
float m_angle; float m_angle;
D3DCOLORVALUE m_floorColor; Gfx::Color m_floorColor;
D3DCOLORVALUE m_waterColor; Gfx::Color m_waterColor;
MapObject m_map[MAPMAXOBJECT]; MapObject m_map[MAPMAXOBJECT];
int m_totalFix; int m_totalFix;
int m_totalMove; int m_totalMove;
int m_hiliteRank; int m_hiliteRank;
Math::Point m_mapPos; Math::Point m_mapPos;
Math::Point m_mapDim; Math::Point m_mapDim;
bool m_bRadar; bool m_bRadar;
char m_fixImage[100]; char m_fixImage[100];
int m_mode; int m_mode;

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,13 +18,14 @@
// scroll.cpp // scroll.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" //#include "old/math3d.h"
#include "graphics/engine/engine.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -31,11 +33,11 @@
#include "ui/scroll.h" #include "ui/scroll.h"
namespace Ui {
// Object's constructor. // Object's constructor.
CScroll::CScroll(CInstanceManager* iMan) : CControl(iMan) CScroll::CScroll() : CControl()
{ {
m_buttonUp = 0; m_buttonUp = 0;
m_buttonDown = 0; m_buttonDown = 0;
@ -61,9 +63,9 @@ CScroll::~CScroll()
// Creates a new button. // Creates a new button.
bool CScroll::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CScroll::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); CControl::Create(pos, dim, icon, eventMsg);
MoveAdjust(); MoveAdjust();
@ -102,20 +104,20 @@ void CScroll::MoveAdjust()
{ {
if ( m_buttonUp == 0 ) if ( m_buttonUp == 0 )
{ {
m_buttonUp = new CButton(m_iMan); m_buttonUp = new CButton();
pc = (CButton*)m_buttonUp; pc = (CButton*)m_buttonUp;
pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL); pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL);
pc->SetRepeat(true); pc->SetRepeat(true);
m_eventUp = pc->RetEventMsg(); m_eventUp = pc->GetEventType();
} }
if ( m_buttonDown == 0 ) if ( m_buttonDown == 0 )
{ {
m_buttonDown = new CButton(m_iMan); m_buttonDown = new CButton();
pc = (CButton*)m_buttonDown; pc = (CButton*)m_buttonDown;
pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL); pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL);
pc->SetRepeat(true); pc->SetRepeat(true);
m_eventDown = pc->RetEventMsg(); m_eventDown = pc->GetEventType();
} }
} }
@ -213,31 +215,32 @@ bool CScroll::EventProcess(const Event &event)
if ( !m_buttonDown->EventProcess(event) ) return false; if ( !m_buttonDown->EventProcess(event) ) return false;
} }
if ( event.event == m_eventUp && m_step > 0.0f ) if ( event.type == m_eventUp && m_step > 0.0f )
{ {
m_visibleValue -= m_step; m_visibleValue -= m_step;
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f; if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
if ( event.event == m_eventDown && m_step > 0.0f ) if ( event.type == m_eventDown && m_step > 0.0f )
{ {
m_visibleValue += m_step; m_visibleValue += m_step;
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f; if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
hButton = m_buttonUp?m_dim.x/0.75f:0.0f; hButton = m_buttonUp?m_dim.x/0.75f:0.0f;
if ( event.event == EVENT_LBUTTONDOWN && if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) && (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) ) (m_state & STATE_ENABLE) )
{ {
@ -258,7 +261,7 @@ bool CScroll::EventProcess(const Event &event)
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
m_bCapture = true; m_bCapture = true;
@ -267,7 +270,7 @@ bool CScroll::EventProcess(const Event &event)
} }
} }
if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{ {
h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio); h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio);
if ( h != 0 ) if ( h != 0 )
@ -282,33 +285,35 @@ bool CScroll::EventProcess(const Event &event)
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
} }
} }
if ( event.event == EVENT_LBUTTONUP && m_bCapture ) if ( event.type == EVENT_MOUSE_BUTTON_UP &&
event.mouseButton.button == 1 &&
m_bCapture )
{ {
m_bCapture = false; m_bCapture = false;
} }
if ( event.event == EVENT_KEYDOWN && if ( event.type == EVENT_KEY_DOWN &&
event.param == VK_WHEELUP && event.mouseButton.button == 4 &&
Detect(event.pos) && Detect(event.pos) &&
m_buttonUp != 0 ) m_buttonUp != 0 )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_buttonUp->RetEventMsg(); newEvent.type = m_buttonUp->GetEventType();
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
if ( event.event == EVENT_KEYDOWN && if ( event.type == EVENT_KEY_DOWN &&
event.param == VK_WHEELDOWN && event.mouseButton.button == 5 &&
Detect(event.pos) && Detect(event.pos) &&
m_buttonDown != 0 ) m_buttonDown != 0 )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_buttonDown->RetEventMsg(); newEvent.type = m_buttonDown->GetEventType();
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
@ -381,7 +386,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 ) if ( icon == 0 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // yellow rectangle uv1.x = 0.0f/256.0f; // yellow rectangle
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 32.0f/256.0f; uv2.x = 32.0f/256.0f;
@ -391,7 +396,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 1 ) else if ( icon == 1 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // gray rectangle uv1.x = 128.0f/256.0f; // gray rectangle
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
@ -401,7 +406,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 2 ) else if ( icon == 2 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // blue rectangle uv1.x = 64.0f/256.0f; // blue rectangle
uv1.y = 0.0f/256.0f; uv1.y = 0.0f/256.0f;
uv2.x = 96.0f/256.0f; uv2.x = 96.0f/256.0f;
@ -411,7 +416,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else else
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 104.0f/256.0f; // blue line - uv1.x = 104.0f/256.0f; // blue line -
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 128.0f/256.0f; uv2.x = 128.0f/256.0f;
@ -437,7 +442,7 @@ void CScroll::SetVisibleValue(float value)
AdjustGlint(); AdjustGlint();
} }
float CScroll::RetVisibleValue() float CScroll::GetVisibleValue()
{ {
return m_visibleValue; return m_visibleValue;
} }
@ -451,7 +456,7 @@ void CScroll::SetVisibleRatio(float value)
AdjustGlint(); AdjustGlint();
} }
float CScroll::RetVisibleRatio() float CScroll::GetVisibleRatio()
{ {
return m_visibleRatio; return m_visibleRatio;
} }
@ -462,8 +467,9 @@ void CScroll::SetArrowStep(float step)
m_step = step; m_step = step;
} }
float CScroll::RetArrowStep() float CScroll::GetArrowStep()
{ {
return m_step; return m_step;
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -19,63 +20,65 @@
#pragma once #pragma once
#include "ui/control.h" #include <ui/control.h>
#include <common/event.h>
namespace Ui {
class CD3DEngine;
class CButton; class CButton;
const float SCROLL_WIDTH = (15.0f/640.0f); const float SCROLL_WIDTH = (15.0f/640.0f);
class CScroll : public CControl class CScroll : public CControl
{ {
public: public:
CScroll(CInstanceManager* iMan); CScroll();
~CScroll(); ~CScroll();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
void SetPos(Math::Point pos); void SetPos(Math::Point pos);
void SetDim(Math::Point dim); void SetDim(Math::Point dim);
bool SetState(int state, bool bState); bool SetState(int state, bool bState);
bool SetState(int state); bool SetState(int state);
bool ClearState(int state); bool ClearState(int state);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void Draw(); void Draw();
void SetVisibleValue(float value); void SetVisibleValue(float value);
float RetVisibleValue(); float GetVisibleValue();
void SetVisibleRatio(float value); void SetVisibleRatio(float value);
float RetVisibleRatio(); float GetVisibleRatio();
void SetArrowStep(float step); void SetArrowStep(float step);
float RetArrowStep(); float GetArrowStep();
protected: protected:
void MoveAdjust(); void MoveAdjust();
void AdjustGlint(); void AdjustGlint();
void DrawVertex(Math::Point pos, Math::Point dim, int icon); void DrawVertex(Math::Point pos, Math::Point dim, int icon);
protected: protected:
CButton* m_buttonUp; CButton* m_buttonUp;
CButton* m_buttonDown; CButton* m_buttonDown;
float m_visibleValue; float m_visibleValue;
float m_visibleRatio; float m_visibleRatio;
float m_step; float m_step;
bool m_bCapture; bool m_bCapture;
Math::Point m_pressPos; Math::Point m_pressPos;
float m_pressValue; float m_pressValue;
EventMsg m_eventUp; EventType m_eventUp;
EventMsg m_eventDown; EventType m_eventDown;
}; };
}

View File

@ -18,31 +18,28 @@
#pragma once #pragma once
#include <ui/control.h>
#include "ui/control.h" #include <common/event.h>
class CD3DEngine;
class CShortcut : public CControl class CShortcut : public CControl
{ {
public: public:
CShortcut(CInstanceManager* iMan); CShortcut();
~CShortcut(); ~CShortcut();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void Draw(); void Draw();
protected: protected:
void DrawVertex(int icon, float zoom); void DrawVertex(int icon, float zoom);
protected: protected:
float m_time; float m_time;
}; };

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,21 +18,24 @@
// slider.cpp // slider.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" //#include "old/math3d.h"
#include "graphics/engine/engine.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
#include "old/text.h" //#include "old/text.h"
#include "graphics/engine/text.h"
#include "ui/button.h" #include "ui/button.h"
#include "ui/slider.h" #include "ui/slider.h"
namespace Ui {
const float CURSOR_WIDTH = (10.0f/640.0f); const float CURSOR_WIDTH = (10.0f/640.0f);
const float HOLE_WIDTH = (5.0f/480.0f); const float HOLE_WIDTH = (5.0f/480.0f);
@ -41,7 +45,7 @@ const float HOLE_WIDTH = (5.0f/480.0f);
// Object's constructor. // Object's constructor.
CSlider::CSlider(CInstanceManager* iMan) : CControl(iMan) CSlider::CSlider() : CControl()
{ {
m_buttonLeft = 0; m_buttonLeft = 0;
m_buttonRight = 0; m_buttonRight = 0;
@ -71,10 +75,10 @@ CSlider::~CSlider()
// Creates a new button. // Creates a new button.
bool CSlider::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CSlider::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);
MoveAdjust(); MoveAdjust();
return true; return true;
@ -115,20 +119,20 @@ void CSlider::MoveAdjust()
#if 1 #if 1
if ( m_buttonLeft == 0 ) if ( m_buttonLeft == 0 )
{ {
m_buttonLeft = new CButton(m_iMan); m_buttonLeft = new CButton();
m_buttonLeft->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?55:49, EVENT_NULL); // </^ m_buttonLeft->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?55:49, EVENT_NULL); // </^
m_buttonLeft->SetRepeat(true); m_buttonLeft->SetRepeat(true);
if ( m_state & STATE_SHADOW ) m_buttonLeft->SetState(STATE_SHADOW); if ( m_state & STATE_SHADOW ) m_buttonLeft->SetState(STATE_SHADOW);
m_eventUp = m_buttonLeft->RetEventMsg(); m_eventUp = m_buttonLeft->GetEventType();
} }
if ( m_buttonRight == 0 ) if ( m_buttonRight == 0 )
{ {
m_buttonRight = new CButton(m_iMan); m_buttonRight = new CButton();
m_buttonRight->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?48:50, EVENT_NULL); // >/v m_buttonRight->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?48:50, EVENT_NULL); // >/v
m_buttonRight->SetRepeat(true); m_buttonRight->SetRepeat(true);
if ( m_state & STATE_SHADOW ) m_buttonRight->SetState(STATE_SHADOW); if ( m_state & STATE_SHADOW ) m_buttonRight->SetState(STATE_SHADOW);
m_eventDown = m_buttonRight->RetEventMsg(); m_eventDown = m_buttonRight->GetEventType();
} }
m_marginButton = m_bHoriz?(m_dim.y*0.75f):(m_dim.x/0.75f); m_marginButton = m_bHoriz?(m_dim.y*0.75f):(m_dim.x/0.75f);
@ -261,7 +265,7 @@ bool CSlider::EventProcess(const Event &event)
if ( !m_buttonRight->EventProcess(event) ) return false; if ( !m_buttonRight->EventProcess(event) ) return false;
} }
if ( event.event == m_eventUp && m_step > 0.0f ) if ( event.type == m_eventUp && m_step > 0.0f )
{ {
m_visibleValue -= m_bHoriz?m_step:-m_step; m_visibleValue -= m_bHoriz?m_step:-m_step;
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f; if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
@ -269,11 +273,11 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
if ( event.event == m_eventDown && m_step > 0.0f ) if ( event.type == m_eventDown && m_step > 0.0f )
{ {
m_visibleValue += m_bHoriz?m_step:-m_step; m_visibleValue += m_bHoriz?m_step:-m_step;
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f; if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
@ -281,12 +285,13 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
if ( event.event == EVENT_LBUTTONDOWN && if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
(m_state & STATE_VISIBLE) && (event.mouseButton.button == 1 ) &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) ) (m_state & STATE_ENABLE) )
{ {
if ( CControl::Detect(event.pos) ) if ( CControl::Detect(event.pos) )
@ -311,7 +316,7 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
m_bCapture = true; m_bCapture = true;
@ -320,7 +325,7 @@ bool CSlider::EventProcess(const Event &event)
} }
} }
if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{ {
if ( m_bHoriz ) if ( m_bHoriz )
{ {
@ -345,32 +350,35 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint(); AdjustGlint();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
} }
if ( event.event == EVENT_LBUTTONUP && m_bCapture ) if ( ( event.type == EVENT_MOUSE_BUTTON_UP ) &&
( event.mouseButton.button == 1 ) &&
m_bCapture )
{ {
m_bCapture = false; m_bCapture = false;
} }
if ( event.event == EVENT_KEYDOWN && if ( event.type == EVENT_KEY_DOWN &&
event.param == VK_WHEELUP && event.mouseButton.button == 4 &&
Detect(event.pos) && Detect(event.pos) &&
m_buttonLeft != 0 ) m_buttonLeft != 0 )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_buttonLeft->RetEventMsg(); newEvent.type = m_buttonLeft->GetEventType();
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
if ( event.event == EVENT_KEYDOWN &&
event.param == VK_WHEELDOWN && if ( event.type == EVENT_KEY_DOWN &&
event.mouseButton.button == 5 &&
Detect(event.pos) && Detect(event.pos) &&
m_buttonRight != 0 ) m_buttonRight != 0 )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = m_buttonRight->RetEventMsg(); newEvent.type = m_buttonRight->GetEventType();
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
@ -466,10 +474,10 @@ void CSlider::Draw()
if ( m_bHoriz ) if ( m_bHoriz )
{ {
sprintf(text, "%d", (int)(m_min+m_visibleValue*(m_max-m_min))); sprintf(text, "%d", (int)(m_min+m_visibleValue*(m_max-m_min)));
h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
pos.x = m_pos.x+m_dim.x+(10.0f/640.0f); pos.x = m_pos.x+m_dim.x+(10.0f/640.0f);
pos.y = m_pos.y+(m_dim.y-h)/2.0f; pos.y = m_pos.y+(m_dim.y-h)/2.0f;
m_engine->RetText()->DrawText(text, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_RIGHT, 0);
} }
else else
{ {
@ -482,7 +490,7 @@ void CSlider::Draw()
dim.x = 50.0f/640.0f; dim.x = 50.0f/640.0f;
dim.y = 16.0f/480.0f; dim.y = 16.0f/480.0f;
sprintf(text, "%d", (int)(m_min+(m_visibleValue*(m_max-m_min)))); sprintf(text, "%d", (int)(m_min+(m_visibleValue*(m_max-m_min))));
m_engine->RetText()->DrawText(text, pos, dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0);
} }
} }
} }
@ -497,7 +505,7 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 ) if ( icon == 0 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // yellow rectangle uv1.x = 0.0f/256.0f; // yellow rectangle
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 32.0f/256.0f; uv2.x = 32.0f/256.0f;
@ -509,7 +517,7 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 1 ) else if ( icon == 1 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // gray rectangle uv1.x = 128.0f/256.0f; // gray rectangle
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
@ -521,7 +529,7 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else else
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 224.0f/256.0f; // cursor uv1.x = 224.0f/256.0f; // cursor
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 256.0f/256.0f; uv2.x = 256.0f/256.0f;
@ -561,7 +569,7 @@ void CSlider::SetVisibleValue(float value)
AdjustGlint(); AdjustGlint();
} }
float CSlider::RetVisibleValue() float CSlider::GetVisibleValue()
{ {
return m_min+m_visibleValue*(m_max-m_min); return m_min+m_visibleValue*(m_max-m_min);
} }
@ -572,9 +580,10 @@ void CSlider::SetArrowStep(float step)
m_step = step/(m_max-m_min); m_step = step/(m_max-m_min);
} }
float CSlider::RetArrowStep() float CSlider::GetArrowStep()
{ {
return m_step*(m_max-m_min); return m_step*(m_max-m_min);
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -19,63 +20,64 @@
#pragma once #pragma once
#include "ui/control.h" #include <ui/control.h>
#include <common/event.h>
namespace Ui {
class CD3DEngine;
class CButton; class CButton;
class CSlider : public CControl class CSlider : public CControl
{ {
public: public:
CSlider(CInstanceManager* iMan); CSlider();
~CSlider(); ~CSlider();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
void SetPos(Math::Point pos); void SetPos(Math::Point pos);
void SetDim(Math::Point dim); void SetDim(Math::Point dim);
bool SetState(int state, bool bState); bool SetState(int state, bool bState);
bool SetState(int state); bool SetState(int state);
bool ClearState(int state); bool ClearState(int state);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void Draw(); void Draw();
void SetLimit(float min, float max); void SetLimit(float min, float max);
void SetVisibleValue(float value); void SetVisibleValue(float value);
float RetVisibleValue(); float GetVisibleValue();
void SetArrowStep(float step); void SetArrowStep(float step);
float RetArrowStep(); float GetArrowStep();
protected: protected:
void MoveAdjust(); void MoveAdjust();
void AdjustGlint(); void AdjustGlint();
void DrawVertex(Math::Point pos, Math::Point dim, int icon); void DrawVertex(Math::Point pos, Math::Point dim, int icon);
protected: protected:
CButton* m_buttonLeft; CButton* m_buttonLeft;
CButton* m_buttonRight; CButton* m_buttonRight;
float m_min; float m_min;
float m_max; float m_max;
float m_visibleValue; float m_visibleValue;
float m_step; float m_step;
bool m_bHoriz; bool m_bHoriz;
float m_marginButton; float m_marginButton;
bool m_bCapture; bool m_bCapture;
Math::Point m_pressPos; Math::Point m_pressPos;
float m_pressValue; float m_pressValue;
EventMsg m_eventUp; EventType m_eventUp;
EventMsg m_eventDown; EventType m_eventDown;
}; };
}

View File

@ -505,7 +505,7 @@ void CStudio::SearchToken(CEdit* edit)
for ( i=0 ; i<OBJECT_MAX ; i++ ) for ( i=0 ; i<OBJECT_MAX ; i++ )
{ {
type = (ObjectType)i; type = (ObjectType)i;
text = RetObjectName(type); text = GetObjectName(type);
if ( text[0] != 0 ) if ( text[0] != 0 )
{ {
if ( strcmp(token, text) == 0 ) if ( strcmp(token, text) == 0 )

View File

@ -17,13 +17,14 @@
// target.cpp // target.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "old/math3d.h" //#include "old/math3d.h"
#include "graphics/engine/engine.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/iman.h" #include "common/iman.h"
@ -34,10 +35,10 @@
namespace Ui {
// Object's constructor. // Object's constructor.
CTarget::CTarget(CInstanceManager* iMan) : CControl(iMan) CTarget::CTarget() : CControl()
{ {
} }
@ -50,11 +51,11 @@ CTarget::~CTarget()
// Creates a new button. // Creates a new button.
bool CTarget::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CTarget::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; return true;
} }
@ -70,26 +71,27 @@ bool CTarget::EventProcess(const Event &event)
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_MOUSEMOVE ) if ( event.type == EVENT_MOUSE_MOVE )
{ {
if ( CControl::Detect(event.pos) ) if ( CControl::Detect(event.pos) )
{ {
m_engine->SetMouseType(D3DMOUSETARGET); m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
} }
if ( event.event == EVENT_LBUTTONDOWN && if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) && (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) ) (m_state & STATE_ENABLE) )
{ {
if ( CControl::Detect(event.pos) ) if ( CControl::Detect(event.pos) )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = EVENT_OBJECT_FIRE; newEvent.type = EVENT_OBJECT_FIRE;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
@ -104,7 +106,7 @@ bool CTarget::EventProcess(const Event &event)
CControl::EventProcess(event); CControl::EventProcess(event);
if ( event.event == EVENT_MOUSEMOVE ) if ( event.type == EVENT_MOUSE_MOVE )
{ {
m_main->SetFriendAim(false); m_main->SetFriendAim(false);
@ -113,22 +115,23 @@ bool CTarget::EventProcess(const Event &event)
pObj = DetectFriendObject(event.pos); pObj = DetectFriendObject(event.pos);
if ( pObj == 0 ) if ( pObj == 0 )
{ {
m_engine->SetMouseType(D3DMOUSETARGET); m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
else else
{ {
m_main->SetFriendAim(true); m_main->SetFriendAim(true);
m_engine->SetMouseType(D3DMOUSENORM); m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
} }
} }
} }
if ( event.event == EVENT_LBUTTONDOWN && if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) && (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) ) (m_state & STATE_ENABLE) )
{ {
@ -137,7 +140,7 @@ bool CTarget::EventProcess(const Event &event)
if ( !m_main->RetFriendAim() ) if ( !m_main->RetFriendAim() )
{ {
Event newEvent = event; Event newEvent = event;
newEvent.event = EVENT_OBJECT_FIRE; newEvent.type = EVENT_OBJECT_FIRE;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
return false; return false;
} }
@ -202,15 +205,15 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
for ( i=0 ; i<1000000 ; i++ ) for ( i=0 ; i<1000000 ; i++ )
{ {
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break; if ( pObj == 0 ) break;
if ( !pObj->RetActif() ) continue; if ( !pObj->GetActif() ) continue;
if ( pObj->RetProxyActivate() ) continue; if ( pObj->GetProxyActivate() ) continue;
if ( pObj->RetSelect() ) continue; if ( pObj->GetSelect() ) continue;
pTarget = 0; pTarget = 0;
type = pObj->RetType(); type = pObj->GetType();
if ( type == OBJECT_DERRICK || if ( type == OBJECT_DERRICK ||
type == OBJECT_FACTORY || type == OBJECT_FACTORY ||
type == OBJECT_REPAIR || type == OBJECT_REPAIR ||
@ -261,10 +264,10 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
} }
else if ( (type == OBJECT_POWER || else if ( (type == OBJECT_POWER ||
type == OBJECT_ATOMIC ) && type == OBJECT_ATOMIC ) &&
pObj->RetTruck() != 0 ) // battery used? pObj->GetTruck() != 0 ) // battery used?
{ {
pTarget = pObj->RetTruck(); pTarget = pObj->GetTruck();
if ( pTarget->RetType() == OBJECT_MOBILEtg ) if ( pTarget->GetType() == OBJECT_MOBILEtg )
{ {
pTarget = 0; pTarget = 0;
} }
@ -272,7 +275,7 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
for ( j=0 ; j<OBJECTMAXPART ; j++ ) for ( j=0 ; j<OBJECTMAXPART ; j++ )
{ {
rank = pObj->RetObjectRank(j); rank = pObj->GetObjectRank(j);
if ( rank == -1 ) continue; if ( rank == -1 ) continue;
if ( rank != objRank ) continue; if ( rank != objRank ) continue;
return pTarget; return pTarget;
@ -281,3 +284,4 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
return 0; return 0;
} }
}

View File

@ -19,30 +19,27 @@
#pragma once #pragma once
#include "ui/control.h" #include <ui/control.h>
class CD3DEngine;
class CObject;
#include <common/event.h>
namespace Ui {
class CTarget : public CControl class CTarget : public CControl
{ {
public: public:
CTarget(CInstanceManager* iMan); CTarget();
~CTarget(); ~CTarget();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
void Draw(); void Draw();
bool GetTooltip(Math::Point pos, char* name); bool GetTooltip(Math::Point pos, char* name);
protected: protected:
CObject* DetectFriendObject(Math::Point pos); CObject* DetectFriendObject(Math::Point pos);
protected:
}; };
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -17,14 +18,14 @@
// window.cpp // window.cpp
#include <windows.h> //#include <windows.h>
#include <stdio.h> //#include <stdio.h>
#include <d3d.h> //#include <d3d.h>
#include "common/struct.h" //#include "common/struct.h"
#include "old/d3dengine.h" //#include "old/d3dengine.h"
#include "common/language.h" #include "common/language.h"
#include "old/math3d.h" //#include "old/math3d.h"
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/restext.h" #include "common/restext.h"
@ -46,15 +47,17 @@
#include "ui/gauge.h" #include "ui/gauge.h"
#include "ui/compass.h" #include "ui/compass.h"
#include "ui/target.h" #include "ui/target.h"
#include "old/text.h" //#include "old/text.h"
#include "graphics/engine/text.h"
#include "ui/window.h" #include "ui/window.h"
namespace Ui {
// Object's constructor. // Object's constructor.
CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan) //CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
CWindow::CWindow() : CControl()
{ {
int i; int i;
@ -80,7 +83,7 @@ CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
m_bClosable = false; m_bClosable = false;
m_bCapture = false; m_bCapture = false;
m_fontStretch = NORMSTRETCH*1.2f; // m_fontStretch = NORMSTRETCH*1.2f;
} }
// Object's destructor. // Object's destructor.
@ -128,9 +131,9 @@ void CWindow::Flush()
// Creates a new window. // Creates a new window.
bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) bool CWindow::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); CControl::Create(pos, dim, icon, eventMsg);
return true; return true;
@ -139,18 +142,19 @@ bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventM
// Creates a new button. // Creates a new button.
CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CButton* pc; CButton* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CButton(m_iMan); // m_table[i] = new CButton(m_iMan);
m_table[i] = new CButton();
pc = (CButton*)m_table[i]; pc = (CButton*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -161,18 +165,19 @@ CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, Event
// Creates a new button. // Creates a new button.
CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CColor* pc; CColor* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CColor(m_iMan); // m_table[i] = new CColor(m_iMan);
m_table[i] = new CColor();
pc = (CColor*)m_table[i]; pc = (CColor*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -183,18 +188,19 @@ CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new button. // Creates a new button.
CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CCheck* pc; CCheck* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CCheck(m_iMan); // m_table[i] = new CCheck(m_iMan);
m_table[i] = new CCheck();
pc = (CCheck*)m_table[i]; pc = (CCheck*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -205,18 +211,19 @@ CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new button. // Creates a new button.
CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CKey* pc; CKey* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CKey(m_iMan); // m_table[i] = new CKey(m_iMan);
m_table[i] = new CKey();
pc = (CKey*)m_table[i]; pc = (CKey*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -227,18 +234,19 @@ CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg ev
// Creates a new button. // Creates a new button.
CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CGroup* pc; CGroup* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CGroup(m_iMan); // m_table[i] = new CGroup(m_iMan);
m_table[i] = new CGroup();
pc = (CGroup*)m_table[i]; pc = (CGroup*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -249,18 +257,19 @@ CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new button. // Creates a new button.
CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CImage* pc; CImage* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CImage(m_iMan); // m_table[i] = new CImage(m_iMan);
m_table[i] = new CImage();
pc = (CImage*)m_table[i]; pc = (CImage*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -271,20 +280,21 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new label. // Creates a new label.
CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg,
char *name) char *name)
{ {
CLabel* pc; CLabel* pc;
char* p; char* p;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CLabel(m_iMan); // m_table[i] = new CLabel(m_iMan);
m_table[i] = new CLabel();
pc = (CLabel*)m_table[i]; pc = (CLabel*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
@ -312,18 +322,19 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new editable pave. // Creates a new editable pave.
CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CEdit* pc; CEdit* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CEdit(m_iMan); // m_table[i] = new CEdit(m_iMan);
m_table[i] = new CEdit();
pc = (CEdit*)m_table[i]; pc = (CEdit*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -334,18 +345,19 @@ CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg
// Creates a new editable pave. // Creates a new editable pave.
CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CEditValue* pc; CEditValue* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CEditValue(m_iMan); // m_table[i] = new CEditValue(m_iMan);
m_table[i] = new CEditValue();
pc = (CEditValue*)m_table[i]; pc = (CEditValue*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -356,18 +368,19 @@ CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon,
// Creates a new elevator. // Creates a new elevator.
CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CScroll* pc; CScroll* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CScroll(m_iMan); // m_table[i] = new CScroll(m_iMan);
m_table[i] = new CScroll();
pc = (CScroll*)m_table[i]; pc = (CScroll*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -378,18 +391,19 @@ CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, Event
// Creates a new cursor. // Creates a new cursor.
CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CSlider* pc; CSlider* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CSlider(m_iMan); // m_table[i] = new CSlider(m_iMan);
m_table[i] = new CSlider();
pc = (CSlider*)m_table[i]; pc = (CSlider*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -400,19 +414,20 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event
// Creates a new list. // Creates a new list.
CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg,
float expand) float expand)
{ {
CList* pc; CList* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CList(m_iMan); // m_table[i] = new CList(m_iMan);
m_table[i] = new CList();
pc = (CList*)m_table[i]; pc = (CList*)m_table[i];
pc->Create(pos, dim, icon, eventMsg, expand); pc->Create(pos, dim, icon, eventMsg, expand);
return pc; return pc;
@ -423,18 +438,18 @@ CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg
// Creates a new shortcut. // Creates a new shortcut.
CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CShortcut* ps; CShortcut* ps;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CShortcut(m_iMan); m_table[i] = new CShortcut();
ps = (CShortcut*)m_table[i]; ps = (CShortcut*)m_table[i];
ps->Create(pos, dim, icon, eventMsg); ps->Create(pos, dim, icon, eventMsg);
return ps; return ps;
@ -445,18 +460,18 @@ CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, E
// Creates a new card. // Creates a new card.
CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CMap* pm; CMap* pm;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CMap(m_iMan); m_table[i] = new CMap();
pm = (CMap*)m_table[i]; pm = (CMap*)m_table[i];
pm->Create(pos, dim, icon, eventMsg); pm->Create(pos, dim, icon, eventMsg);
return pm; return pm;
@ -467,18 +482,18 @@ CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg ev
// Creates a new gauge. // Creates a new gauge.
CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CGauge* pc; CGauge* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CGauge(m_iMan); m_table[i] = new CGauge();
pc = (CGauge*)m_table[i]; pc = (CGauge*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -489,18 +504,18 @@ CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new compass. // Creates a new compass.
CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CCompass* pc; CCompass* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CCompass(m_iMan); m_table[i] = new CCompass();
pc = (CCompass*)m_table[i]; pc = (CCompass*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -511,18 +526,18 @@ CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, Eve
// Creates a new target. // Creates a new target.
CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
CTarget* pc; CTarget* pc;
int i; int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ ) for ( i=0 ; i<MAXWINDOW ; i++ )
{ {
if ( m_table[i] == 0 ) if ( m_table[i] == 0 )
{ {
m_table[i] = new CTarget(m_iMan); m_table[i] = new CTarget();
pc = (CTarget*)m_table[i]; pc = (CTarget*)m_table[i];
pc->Create(pos, dim, icon, eventMsg); pc->Create(pos, dim, icon, eventMsg);
return pc; return pc;
@ -533,7 +548,7 @@ CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, Event
// Removes a control. // Removes a control.
bool CWindow::DeleteControl(EventMsg eventMsg) bool CWindow::DeleteControl(EventType eventMsg)
{ {
int i; int i;
@ -541,7 +556,7 @@ bool CWindow::DeleteControl(EventMsg eventMsg)
{ {
if ( m_table[i] != 0 ) if ( m_table[i] != 0 )
{ {
if ( eventMsg == m_table[i]->RetEventMsg() ) if ( eventMsg == m_table[i]->GetEventType() )
{ {
delete m_table[i]; delete m_table[i];
m_table[i] = 0; m_table[i] = 0;
@ -554,7 +569,7 @@ bool CWindow::DeleteControl(EventMsg eventMsg)
// Gives a control. // Gives a control.
CControl* CWindow::SearchControl(EventMsg eventMsg) CControl* CWindow::SearchControl(EventType eventMsg)
{ {
int i; int i;
@ -562,7 +577,7 @@ CControl* CWindow::SearchControl(EventMsg eventMsg)
{ {
if ( m_table[i] != 0 ) if ( m_table[i] != 0 )
{ {
if ( eventMsg == m_table[i]->RetEventMsg() ) if ( eventMsg == m_table[i]->GetEventType() )
{ {
return m_table[i]; return m_table[i];
} }
@ -646,11 +661,11 @@ void CWindow::SetName(char* name)
if ( m_name[0] != 0 && m_bRedim ) // title bar exists? if ( m_name[0] != 0 && m_bRedim ) // title bar exists?
{ {
m_buttonReduce = new CButton(m_iMan); m_buttonReduce = new CButton();
pc = (CButton*)m_buttonReduce; pc = (CButton*)m_buttonReduce;
pc->Create(m_pos, m_dim, 0, EVENT_NULL); pc->Create(m_pos, m_dim, 0, EVENT_NULL);
m_buttonFull = new CButton(m_iMan); m_buttonFull = new CButton();
pc = (CButton*)m_buttonFull; pc = (CButton*)m_buttonFull;
pc->Create(m_pos, m_dim, 0, EVENT_NULL); pc->Create(m_pos, m_dim, 0, EVENT_NULL);
@ -659,7 +674,7 @@ void CWindow::SetName(char* name)
if ( m_name[0] != 0 && m_bClosable ) // title bar exists? if ( m_name[0] != 0 && m_bClosable ) // title bar exists?
{ {
m_buttonClose = new CButton(m_iMan); m_buttonClose = new CButton();
pc = (CButton*)m_buttonClose; pc = (CButton*)m_buttonClose;
pc->Create(m_pos, m_dim, 0, EVENT_NULL); pc->Create(m_pos, m_dim, 0, EVENT_NULL);
@ -697,7 +712,7 @@ void CWindow::MoveAdjust()
Math::Point pos, dim; Math::Point pos, dim;
float h, offset; float h, offset;
h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
dim.y = h*1.2f; dim.y = h*1.2f;
dim.x = dim.y*0.75f; dim.x = dim.y*0.75f;
@ -742,12 +757,12 @@ void CWindow::SetMaxDim(Math::Point dim)
m_maxDim = dim; m_maxDim = dim;
} }
Math::Point CWindow::RetMinDim() Math::Point CWindow::GetMinDim()
{ {
return m_minDim; return m_minDim;
} }
Math::Point CWindow::RetMaxDim() Math::Point CWindow::GetMaxDim()
{ {
return m_maxDim; return m_maxDim;
} }
@ -760,7 +775,7 @@ void CWindow::SetMovable(bool bMode)
m_bMovable = bMode; m_bMovable = bMode;
} }
bool CWindow::RetMovable() bool CWindow::GetMovable()
{ {
return m_bMovable; return m_bMovable;
} }
@ -773,7 +788,7 @@ void CWindow::SetRedim(bool bMode)
m_bRedim = bMode; m_bRedim = bMode;
} }
bool CWindow::RetRedim() bool CWindow::GetRedim()
{ {
return m_bRedim; return m_bRedim;
} }
@ -786,7 +801,7 @@ void CWindow::SetClosable(bool bMode)
m_bClosable = bMode; m_bClosable = bMode;
} }
bool CWindow::RetClosable() bool CWindow::GetClosable()
{ {
return m_bClosable; return m_bClosable;
} }
@ -798,7 +813,7 @@ void CWindow::SetMaximized(bool bMaxi)
AdjustButtons(); AdjustButtons();
} }
bool CWindow::RetMaximized() bool CWindow::GetMaximized()
{ {
return m_bMaximized; return m_bMaximized;
} }
@ -809,7 +824,7 @@ void CWindow::SetMinimized(bool bMini)
AdjustButtons(); AdjustButtons();
} }
bool CWindow::RetMinimized() bool CWindow::GetMinimized()
{ {
return m_bMinimized; return m_bMinimized;
} }
@ -819,7 +834,7 @@ void CWindow::SetFixed(bool bFix)
m_bFixed = bFix; m_bFixed = bFix;
} }
bool CWindow::RetFixed() bool CWindow::GetFixed()
{ {
return m_bFixed; return m_bFixed;
} }
@ -877,7 +892,7 @@ void CWindow::SetTrashEvent(bool bTrash)
m_bTrashEvent = bTrash; m_bTrashEvent = bTrash;
} }
bool CWindow::RetTrashEvent() bool CWindow::GetTrashEvent()
{ {
return m_bTrashEvent; return m_bTrashEvent;
} }
@ -885,26 +900,26 @@ bool CWindow::RetTrashEvent()
// Returns the message from the button "reduce". // Returns the message from the button "reduce".
EventMsg CWindow::RetEventMsgReduce() EventType CWindow::GetEventTypeReduce()
{ {
if ( m_buttonReduce == 0 ) return EVENT_NULL; if ( m_buttonReduce == 0 ) return EVENT_NULL;
return m_buttonReduce->RetEventMsg(); return m_buttonReduce->GetEventType();
} }
// Returns the message from the button "full". // Returns the message from the button "full".
EventMsg CWindow::RetEventMsgFull() EventType CWindow::GetEventTypeFull()
{ {
if ( m_buttonFull == 0 ) return EVENT_NULL; if ( m_buttonFull == 0 ) return EVENT_NULL;
return m_buttonFull->RetEventMsg(); return m_buttonFull->GetEventType();
} }
// Returns the message from the button "close". // Returns the message from the button "close".
EventMsg CWindow::RetEventMsgClose() EventType CWindow::GetEventTypeClose()
{ {
if ( m_buttonClose == 0 ) return EVENT_NULL; if ( m_buttonClose == 0 ) return EVENT_NULL;
return m_buttonClose->RetEventMsg(); return m_buttonClose->GetEventType();
} }
@ -947,7 +962,7 @@ int CWindow::BorderDetect(Math::Point pos)
if ( flags == 0 ) if ( flags == 0 )
{ {
h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
dim.y = h*1.2f; dim.y = h*1.2f;
dim.x = dim.y*0.75f; dim.x = dim.y*0.75f;
if ( pos.x < m_pos.x+m_dim.x-0.01f-dim.x*3.0f && if ( pos.x < m_pos.x+m_dim.x-0.01f-dim.x*3.0f &&
@ -967,7 +982,7 @@ bool CWindow::EventProcess(const Event &event)
Math::Point pos; Math::Point pos;
int i, flags; int i, flags;
if ( event.event == EVENT_MOUSEMOVE ) if ( event.type == EVENT_MOUSE_MOVE )
{ {
if ( m_bCapture ) if ( m_bCapture )
{ {
@ -975,7 +990,7 @@ bool CWindow::EventProcess(const Event &event)
} }
else else
{ {
m_pressMouse = D3DMOUSENORM; m_pressMouse = Gfx::ENG_MOUSE_NORM;
if ( m_name[0] != 0 && m_bMovable && // title bar? if ( m_name[0] != 0 && m_bMovable && // title bar?
Detect(event.pos) ) Detect(event.pos) )
@ -983,29 +998,29 @@ bool CWindow::EventProcess(const Event &event)
flags = BorderDetect(event.pos); flags = BorderDetect(event.pos);
if ( flags == -1 ) if ( flags == -1 )
{ {
m_pressMouse = D3DMOUSEMOVE; // + m_pressMouse = Gfx::ENG_MOUSE_MOVE; // +
} }
else if ( ((flags & (1<<0)) && (flags & (1<<3))) || else if ( ((flags & (1<<0)) && (flags & (1<<3))) ||
((flags & (1<<1)) && (flags & (1<<2))) ) ((flags & (1<<1)) && (flags & (1<<2))) )
{ {
m_pressMouse = D3DMOUSEMOVEI; // \ // m_pressMouse = Gfx::ENG_MOUSE_MOVEI; // \ //
} }
else if ( ((flags & (1<<0)) && (flags & (1<<1))) || else if ( ((flags & (1<<0)) && (flags & (1<<1))) ||
((flags & (1<<2)) && (flags & (1<<3))) ) ((flags & (1<<2)) && (flags & (1<<3))) )
{ {
m_pressMouse = D3DMOUSEMOVED; // / m_pressMouse = Gfx::ENG_MOUSE_MOVED; // /
} }
else if ( (flags & (1<<0)) || (flags & (1<<2)) ) else if ( (flags & (1<<0)) || (flags & (1<<2)) )
{ {
m_pressMouse = D3DMOUSEMOVEH; // - m_pressMouse = Gfx::ENG_MOUSE_MOVEH; // -
} }
else if ( (flags & (1<<1)) || (flags & (1<<3)) ) else if ( (flags & (1<<1)) || (flags & (1<<3)) )
{ {
m_pressMouse = D3DMOUSEMOVEV; // | m_pressMouse = Gfx::ENG_MOUSE_MOVEV; // |
} }
} }
if ( m_pressMouse != D3DMOUSENORM ) if ( m_pressMouse != Gfx::ENG_MOUSE_NORM )
{ {
m_engine->SetMouseType(m_pressMouse); m_engine->SetMouseType(m_pressMouse);
} }
@ -1039,7 +1054,8 @@ bool CWindow::EventProcess(const Event &event)
} }
} }
if ( m_bTrashEvent && event.event == EVENT_LBUTTONDOWN ) if ( m_bTrashEvent && event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.mouseButton.button == 1)
{ {
if ( Detect(event.pos) ) if ( Detect(event.pos) )
{ {
@ -1056,7 +1072,7 @@ bool CWindow::EventProcess(const Event &event)
} }
} }
if ( event.event == EVENT_MOUSEMOVE && m_bCapture ) if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{ {
pos = event.pos; pos = event.pos;
if ( m_pressFlags == -1 ) // all moves? if ( m_pressFlags == -1 ) // all moves?
@ -1105,11 +1121,13 @@ bool CWindow::EventProcess(const Event &event)
AdjustButtons(); AdjustButtons();
Event newEvent = event; Event newEvent = event;
newEvent.event = m_eventMsg; newEvent.type = m_eventType;
m_event->AddEvent(newEvent); m_event->AddEvent(newEvent);
} }
if ( event.event == EVENT_LBUTTONUP && m_bCapture ) if ( event.type == EVENT_MOUSE_BUTTON_UP &&
event.mouseButton == 1 &&
m_bCapture )
{ {
m_bCapture = false; m_bCapture = false;
} }
@ -1137,7 +1155,7 @@ void CWindow::Draw()
if ( m_name[0] != 0 ) // title bar? if ( m_name[0] != 0 ) // title bar?
{ {
h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType); h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
// Draws the shadow under the title bar. // Draws the shadow under the title bar.
{ {
@ -1160,7 +1178,7 @@ void CWindow::Draw()
dim.y = h*1.2f; dim.y = h*1.2f;
DrawVertex(pos, dim, (m_state&STATE_ENABLE)?2:9); DrawVertex(pos, dim, (m_state&STATE_ENABLE)?2:9);
sw = m_engine->RetText()->RetStringWidth(m_name, strlen(m_name), m_fontSize, m_fontStretch, m_fontType); sw = m_engine->GetText()->GetStringWidth(m_name, m_fontType, m_fontSize);
if ( m_state&STATE_ENABLE ) if ( m_state&STATE_ENABLE )
{ {
@ -1175,7 +1193,7 @@ void CWindow::Draw()
pos.x = m_pos.x+width/2.0f; pos.x = m_pos.x+width/2.0f;
pos.y = m_pos.y+m_dim.y-0.01f-h*1.10f; pos.y = m_pos.y+m_dim.y-0.01f-h*1.10f;
m_engine->RetText()->DrawText(m_name, pos, width, 0, m_fontSize, m_fontStretch, m_fontType, 0); m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, width, Gfx::TEXT_ALIGN_CENTER, 0);
if ( m_buttonReduce != 0 ) if ( m_buttonReduce != 0 )
{ {
@ -1215,7 +1233,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 ) if ( icon == 0 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 64.0f/256.0f; // dark blue transparent uv1.x = 64.0f/256.0f; // dark blue transparent
uv1.y = 64.0f/256.0f; uv1.y = 64.0f/256.0f;
uv2.x = 128.0f/256.0f; uv2.x = 128.0f/256.0f;
@ -1231,7 +1249,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 1 ) else if ( icon == 1 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 128.0f/256.0f; // yellow tooltip uv1.x = 128.0f/256.0f; // yellow tooltip
uv1.y = 0.0f/256.0f; uv1.y = 0.0f/256.0f;
uv2.x = 224.0f/256.0f; uv2.x = 224.0f/256.0f;
@ -1245,7 +1263,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 2 ) else if ( icon == 2 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // yellow uv1.x = 128.0f/256.0f; // yellow
uv1.y = 16.0f/256.0f; uv1.y = 16.0f/256.0f;
uv2.x = 224.0f/256.0f; uv2.x = 224.0f/256.0f;
@ -1259,7 +1277,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 3 ) else if ( icon == 3 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 0.0f/256.0f; // transparent blue bar with yellow upper uv1.x = 0.0f/256.0f; // transparent blue bar with yellow upper
uv1.y = 64.0f/256.0f; uv1.y = 64.0f/256.0f;
uv2.x = 64.0f/256.0f; uv2.x = 64.0f/256.0f;
@ -1278,7 +1296,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.y += 60.0f/480.0f; dim.y += 60.0f/480.0f;
m_engine->SetTexture("human.tga"); m_engine->SetTexture("human.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 140.0f/256.0f; uv1.x = 140.0f/256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 182.0f/256.0f; uv2.x = 182.0f/256.0f;
@ -1295,7 +1313,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.y += 0.0f/480.0f; dim.y += 0.0f/480.0f;
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTw); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 192.0f/256.0f; uv1.x = 192.0f/256.0f;
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 224.0f/256.0f; uv2.x = 224.0f/256.0f;
@ -1314,7 +1332,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.y -= 20.0f/480.0f; dim.y -= 20.0f/480.0f;
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; uv1.x = 64.0f/256.0f;
uv1.y = 0.0f/256.0f; uv1.y = 0.0f/256.0f;
uv2.x = 96.0f/256.0f; uv2.x = 96.0f/256.0f;
@ -1433,7 +1451,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 5 ) else if ( icon == 5 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent green uv1.x = 64.0f/256.0f; // transparent green
uv1.y = 160.0f/256.0f; uv1.y = 160.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
@ -1447,7 +1465,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 6 ) else if ( icon == 6 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent red uv1.x = 64.0f/256.0f; // transparent red
uv1.y = 176.0f/256.0f; uv1.y = 176.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
@ -1461,7 +1479,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 7 ) else if ( icon == 7 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent blue uv1.x = 64.0f/256.0f; // transparent blue
uv1.y = 192.0f/256.0f; uv1.y = 192.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
@ -1475,7 +1493,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 8 ) else if ( icon == 8 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // opaque orange uv1.x = 0.0f/256.0f; // opaque orange
uv1.y = 0.0f/256.0f; uv1.y = 0.0f/256.0f;
uv2.x = 32.0f/256.0f; uv2.x = 32.0f/256.0f;
@ -1491,7 +1509,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 9 ) else if ( icon == 9 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 32.0f/256.0f; // opaque gray uv1.x = 32.0f/256.0f; // opaque gray
uv1.y = 32.0f/256.0f; uv1.y = 32.0f/256.0f;
uv2.x = 64.0f/256.0f; uv2.x = 64.0f/256.0f;
@ -1511,7 +1529,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 11 ) else if ( icon == 11 )
{ {
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATETTb); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent yellow uv1.x = 64.0f/256.0f; // transparent yellow
uv1.y = 224.0f/256.0f; uv1.y = 224.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
@ -1525,7 +1543,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 12 ) else if ( icon == 12 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // dirty opaque gray uv1.x = 128.0f/256.0f; // dirty opaque gray
uv1.y = 128.0f/256.0f; uv1.y = 128.0f/256.0f;
uv2.x = 160.0f/256.0f; uv2.x = 160.0f/256.0f;
@ -1541,7 +1559,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 13 ) else if ( icon == 13 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 192.0f/256.0f; // dirty opaque blue uv1.x = 192.0f/256.0f; // dirty opaque blue
uv1.y = 128.0f/256.0f; uv1.y = 128.0f/256.0f;
uv2.x = 224.0f/256.0f; uv2.x = 224.0f/256.0f;
@ -1557,7 +1575,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 14 ) else if ( icon == 14 )
{ {
m_engine->SetTexture("button1.tga"); m_engine->SetTexture("button1.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 160.0f/256.0f; // dirty opaque red uv1.x = 160.0f/256.0f; // dirty opaque red
uv1.y = 128.0f/256.0f; uv1.y = 128.0f/256.0f;
uv2.x = 192.0f/256.0f; uv2.x = 192.0f/256.0f;
@ -1585,7 +1603,7 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
dp = 0.5f/256.0f; dp = 0.5f/256.0f;
m_engine->SetTexture("button2.tga"); m_engine->SetTexture("button2.tga");
m_engine->SetState(D3DSTATENORMAL); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // hatching uv1.x = 64.0f/256.0f; // hatching
uv1.y = 208.0f/256.0f; uv1.y = 208.0f/256.0f;
uv2.x = 145.0f/256.0f; uv2.x = 145.0f/256.0f;
@ -1618,3 +1636,4 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
#endif #endif
} }
}

View File

@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code // * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// * // *
// * This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by // * it under the terms of the GNU General Public License as published by
@ -19,92 +20,75 @@
#pragma once #pragma once
#include "ui/control.h" #include <ui/control.h>
//#include <common/event.h>
class CD3DEngine;
class CButton;
class CColor;
class CCheck;
class CKey;
class CGroup;
class CImage;
class CLabel;
class CEdit;
class CEditValue;
class CScroll;
class CSlider;
class CList;
class CShortcut;
class CMap;
class CGauge;
class CCompass;
class CTarget;
namespace Ui {
const int MAXWINDOW = 100; const int MAXWINDOW = 100;
class CGauge;
class CWindow : public CControl class CWindow : public CControl
{ {
public: public:
CWindow(CInstanceManager* iMan); CWindow();
~CWindow(); ~CWindow();
void Flush(); void Flush();
bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name); CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, char *name);
CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f); CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool DeleteControl(EventMsg eventMsg); bool DeleteControl(EventType eventMsg);
CControl* SearchControl(EventMsg eventMsg); CControl* SearchControl(EventType eventMsg);
EventMsg RetEventMsgReduce(); EventType GetEventTypeReduce();
EventMsg RetEventMsgFull(); EventType GetEventTypeFull();
EventMsg RetEventMsgClose(); EventType GetEventTypeClose();
void SetName(char* name); void SetName(char* name);
void SetTrashEvent(bool bTrash); void SetTrashEvent(bool bTrash);
bool RetTrashEvent(); bool GetTrashEvent();
void SetPos(Math::Point pos); void SetPos(Math::Point pos);
void SetDim(Math::Point dim); void SetDim(Math::Point dim);
void SetMinDim(Math::Point dim); void SetMinDim(Math::Point dim);
void SetMaxDim(Math::Point dim); void SetMaxDim(Math::Point dim);
Math::Point RetMinDim(); Math::Point GetMinDim();
Math::Point RetMaxDim(); Math::Point GetMaxDim();
void SetMovable(bool bMode); void SetMovable(bool bMode);
bool RetMovable(); bool GetMovable();
void SetRedim(bool bMode); void SetRedim(bool bMode);
bool RetRedim(); bool GetRedim();
void SetClosable(bool bMode); void SetClosable(bool bMode);
bool RetClosable(); bool GetClosable();
void SetMaximized(bool bMaxi); void SetMaximized(bool bMaxi);
bool RetMaximized(); bool GetMaximized();
void SetMinimized(bool bMini); void SetMinimized(bool bMini);
bool RetMinimized(); bool GetMinimized();
void SetFixed(bool bFix); void SetFixed(bool bFix);
bool RetFixed(); bool GetFixed();
bool GetTooltip(Math::Point pos, char* name); bool GetTooltip(Math::Point pos, char* name);
@ -140,7 +124,8 @@ protected:
bool m_bCapture; bool m_bCapture;
Math::Point m_pressPos; Math::Point m_pressPos;
int m_pressFlags; int m_pressFlags;
D3DMouse m_pressMouse; Gfx::EngineMouseType m_pressMouse;
}; };
}