Merged changes from dev

Resolved conflicts & added fixes.
dev-ui
Piotr Dziwinski 2012-07-04 19:56:22 +02:00
parent f95df35dc5
commit af3057df7e
19 changed files with 1250 additions and 741 deletions

4
README-DEV.txt Normal file
View File

@ -0,0 +1,4 @@
README for Developers
Please refer to our wiki for developers for current information. Its current address is:
http://colobot.info/wiki/doku.php?id=developers

View File

@ -21,7 +21,7 @@
#include <string.h> #include <string.h>
HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("Cbot.dll"); // comment le récupérer autrement ?? HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("libCbot.dll"); // comment le récupérer autrement ??
CBotString::CBotString() CBotString::CBotString()

View File

@ -10,6 +10,7 @@ CBotToken.cpp
CBotTwoOpExpr.cpp CBotTwoOpExpr.cpp
CBotVar.cpp CBotVar.cpp
CBotWhile.cpp CBotWhile.cpp
CBot.rc
) )
add_library(CBot SHARED ${SOURCES}) add_library(CBot SHARED ${SOURCES})

View File

@ -31,6 +31,7 @@ app/main.cpp
app/system.cpp app/system.cpp
common/event.cpp common/event.cpp
common/image.cpp common/image.cpp
common/logger.cpp
common/iman.cpp common/iman.cpp
# common/metafile.cpp # common/metafile.cpp
# common/misc.cpp # common/misc.cpp
@ -118,7 +119,7 @@ graphics/opengl/glengine.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
# ui/color.cpp # ui/color.cpp

View File

@ -20,6 +20,7 @@
#include "app/app.h" #include "app/app.h"
#include "app/system.h" #include "app/system.h"
#include "common/logger.h"
#include "common/iman.h" #include "common/iman.h"
#include "graphics/opengl/gldevice.h" #include "graphics/opengl/gldevice.h"
@ -153,6 +154,7 @@ bool CApplication::Create()
{ {
SystemDialog(SDT_ERROR, "COLOBOT - Error", std::string("Error in CEngine::BeforeCreateInit() :\n") + SystemDialog(SDT_ERROR, "COLOBOT - Error", std::string("Error in CEngine::BeforeCreateInit() :\n") +
std::string(m_engine->GetError()) ); std::string(m_engine->GetError()) );
m_exitCode = 1;
return false; return false;
} }
@ -173,6 +175,15 @@ bool CApplication::Create()
{ {
SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL initialization error:\n" + SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL initialization error:\n" +
std::string(SDL_GetError()) ); std::string(SDL_GetError()) );
m_exitCode = 2;
return false;
}
if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) == 0)
{
SystemDialog( SDT_ERROR, "COLOBOT - Error", std::string("SDL_Image initialization error:\n") +
std::string(IMG_GetError()) );
m_exitCode = 3;
return false; return false;
} }
@ -181,6 +192,7 @@ bool CApplication::Create()
{ {
SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL error while getting video info:\n " + SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL error while getting video info:\n " +
std::string(SDL_GetError()) ); std::string(SDL_GetError()) );
m_exitCode = 2;
return false; return false;
} }
@ -219,13 +231,6 @@ bool CApplication::Create()
if (m_private->deviceConfig.hardwareAccel) if (m_private->deviceConfig.hardwareAccel)
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) == 0)
{
SystemDialog( SDT_ERROR, "COLOBOT - Error", std::string("SDL_Image initialization error:\n") +
std::string(IMG_GetError()) );
return false;
}
m_private->surface = SDL_SetVideoMode(m_private->deviceConfig.width, m_private->deviceConfig.height, m_private->surface = SDL_SetVideoMode(m_private->deviceConfig.width, m_private->deviceConfig.height,
m_private->deviceConfig.bpp, videoFlags); m_private->deviceConfig.bpp, videoFlags);
@ -233,6 +238,7 @@ bool CApplication::Create()
{ {
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("SDL error while setting video mode:\n") + SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("SDL error while setting video mode:\n") +
std::string(SDL_GetError()) ); std::string(SDL_GetError()) );
m_exitCode = 2;
return false; return false;
} }
@ -255,6 +261,7 @@ bool CApplication::Create()
{ {
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CDevice::Create() :\n") + SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CDevice::Create() :\n") +
std::string(m_device->GetError()) ); std::string(m_device->GetError()) );
m_exitCode = 1;
return false; return false;
} }
@ -263,6 +270,7 @@ bool CApplication::Create()
{ {
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CEngine::Create() :\n") + SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CEngine::Create() :\n") +
std::string(m_engine->GetError()) ); std::string(m_engine->GetError()) );
m_exitCode = 1;
return false; return false;
} }
@ -270,6 +278,7 @@ bool CApplication::Create()
{ {
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CEngine::AfterDeviceSetInit() :\n") + SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CEngine::AfterDeviceSetInit() :\n") +
std::string(m_engine->GetError()) ); std::string(m_engine->GetError()) );
m_exitCode = 1;
return false; return false;
} }
@ -478,6 +487,11 @@ end:
return m_exitCode; return m_exitCode;
} }
int CApplication::GetExitCode()
{
return m_exitCode;
}
//! Translates SDL press state to PressState //! Translates SDL press state to PressState
PressState TranslatePressState(unsigned char state) PressState TranslatePressState(unsigned char state)
{ {
@ -499,7 +513,6 @@ Math::Point CApplication::WindowToInterfaceCoords(int x, int y)
1.0f - (float)y / (float)m_private->deviceConfig.height); 1.0f - (float)y / (float)m_private->deviceConfig.height);
} }
void CApplication::ParseEvent() void CApplication::ParseEvent()
{ {
Event event; Event event;
@ -567,6 +580,7 @@ void CApplication::ParseEvent()
void CApplication::ProcessEvent(Event event) void CApplication::ProcessEvent(Event event)
{ {
CLogger *l = GetLogger();
// Print the events in debug mode to test the code // Print the events in debug mode to test the code
if (m_debugMode) if (m_debugMode)
{ {
@ -574,34 +588,34 @@ void CApplication::ProcessEvent(Event event)
{ {
case EVENT_KEY_DOWN: case EVENT_KEY_DOWN:
case EVENT_KEY_UP: case EVENT_KEY_UP:
printf("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP"); l->Info("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP");
printf(" key = %4x\n", event.key.key); l->Info(" key = %4x\n", event.key.key);
printf(" state = %s\n", (event.key.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED"); l->Info(" state = %s\n", (event.key.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
printf(" mod = %4x\n", event.key.mod); l->Info(" mod = %4x\n", event.key.mod);
printf(" unicode = %4x\n", event.key.unicode); l->Info(" unicode = %4x\n", event.key.unicode);
break; break;
case EVENT_MOUSE_MOVE: case EVENT_MOUSE_MOVE:
printf("EVENT_MOUSE_MOVE:\n"); l->Info("EVENT_MOUSE_MOVE:\n");
printf(" state = %s\n", (event.mouseMove.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED"); l->Info(" state = %s\n", (event.mouseMove.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
printf(" pos = (%f, %f)\n", event.mouseMove.pos.x, event.mouseMove.pos.y); l->Info(" pos = (%f, %f)\n", event.mouseMove.pos.x, event.mouseMove.pos.y);
break; break;
case EVENT_MOUSE_BUTTON_DOWN: case EVENT_MOUSE_BUTTON_DOWN:
case EVENT_MOUSE_BUTTON_UP: case EVENT_MOUSE_BUTTON_UP:
printf("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP"); l->Info("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP");
printf(" button = %d\n", event.mouseButton.button); l->Info(" button = %d\n", event.mouseButton.button);
printf(" state = %s\n", (event.mouseButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED"); l->Info(" state = %s\n", (event.mouseButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
printf(" pos = (%f, %f)\n", event.mouseButton.pos.x, event.mouseButton.pos.y); l->Info(" pos = (%f, %f)\n", event.mouseButton.pos.x, event.mouseButton.pos.y);
break; break;
case EVENT_JOY_AXIS: case EVENT_JOY_AXIS:
printf("EVENT_JOY_AXIS:\n"); l->Info("EVENT_JOY_AXIS:\n");
printf(" axis = %d\n", event.joyAxis.axis); l->Info(" axis = %d\n", event.joyAxis.axis);
printf(" value = %d\n", event.joyAxis.value); l->Info(" value = %d\n", event.joyAxis.value);
break; break;
case EVENT_JOY_BUTTON_DOWN: case EVENT_JOY_BUTTON_DOWN:
case EVENT_JOY_BUTTON_UP: case EVENT_JOY_BUTTON_UP:
printf("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP"); l->Info("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP");
printf(" button = %d\n", event.joyButton.button); l->Info(" button = %d\n", event.joyButton.button);
printf(" state = %s\n", (event.joyButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED"); l->Info(" state = %s\n", (event.joyButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
break; break;
default: default:
break; break;

View File

@ -84,10 +84,13 @@ public:
Error ParseArguments(int argc, char *argv[]); Error ParseArguments(int argc, char *argv[]);
//! Initializes the application //! Initializes the application
bool Create(); bool Create();
//! Cleans up before exit
void Destroy();
//! Main event loop //! Main event loop
int Run(); int Run();
//! Returns the code to be returned at main() exit
int GetExitCode();
//! Cleans up before exit
void Destroy();
//! Enters the pause mode //! Enters the pause mode
void Pause(bool pause); void Pause(bool pause);
@ -96,7 +99,7 @@ public:
void StepSimulation(float rTime); void StepSimulation(float rTime);
//! Polls the state of joystick axes and buttons //! Polls the state of joystick axes and buttons
void UpdateJoystick(); void UpdateJoystick();
void SetShowStat(bool show); void SetShowStat(bool show);
bool GetShowStat(); bool GetShowStat();

View File

@ -19,6 +19,7 @@
#include "app/app.h" #include "app/app.h"
#include "app/system.h" #include "app/system.h"
#include "common/logger.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/restext.h" #include "common/restext.h"
@ -26,6 +27,10 @@
//! Entry point to the program //! Entry point to the program
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
CLogger logger; // Create the logger
logger.Info("Colobot starting\n");
CApplication app; // single instance of the application CApplication app; // single instance of the application
Error err = app.ParseArguments(argc, argv); Error err = app.ParseArguments(argc, argv);
@ -34,11 +39,19 @@ int main(int argc, char *argv[])
SystemDialog(SDT_ERROR, "COLOBOT", "Invalid commandline arguments!\n"); SystemDialog(SDT_ERROR, "COLOBOT", "Invalid commandline arguments!\n");
} }
int code = 0;
if (! app.Create()) if (! app.Create())
{ {
app.Destroy(); // ensure a clean exit app.Destroy(); // ensure a clean exit
return 1; code = app.GetExitCode();
logger.Info("Didn't run main loop. Exiting with code %d\n", code);
return code;
} }
return app.Run(); code = app.Run();
logger.Info("Exiting with code %d\n", code);
return code;
} }

136
src/common/logger.cpp Normal file
View File

@ -0,0 +1,136 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// logger.cpp
#include <common/logger.h>
#include <stdio.h>
template<> CLogger* CSingleton<CLogger>::mInstance = 0;
CLogger& CLogger::GetInstance()
{
assert(mInstance);
return *mInstance;
}
CLogger* CLogger::GetInstancePointer()
{
assert(mInstance);
return mInstance;
}
CLogger::CLogger()
{
mFile = NULL;
mLogLevel = LOG_INFO;
}
CLogger::~CLogger()
{
Close();
}
void CLogger::Log(LogType type, const char *str, va_list args)
{
if (type < mLogLevel)
return;
switch (type) {
case LOG_WARN: fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); break;
case LOG_INFO: fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); break;
case LOG_ERROR: fprintf(IsOpened() ? mFile : stderr, "[ERROR]: "); break;
default: break;
}
vfprintf(IsOpened() ? mFile : stderr, str, args);
}
void CLogger::Info(const char *str, ...)
{
va_list args;
va_start(args, str);
Log(LOG_INFO, str, args);
va_end(args);
}
void CLogger::Warn(const char *str, ...)
{
va_list args;
va_start(args, str);
Log(LOG_WARN, str, args);
va_end(args);
}
void CLogger::Error(const char *str, ...)
{
va_list args;
va_start(args, str);
Log(LOG_ERROR, str, args);
va_end(args);
}
void CLogger::Message(const char *str, ...)
{
va_list args;
va_start(args, str);
Log(LOG_NONE, str, args);
va_end(args);
}
void CLogger::SetOutputFile(std::string filename)
{
mFilename = filename;
Open();
}
void CLogger::Open()
{
mFile = fopen(mFilename.c_str(), "w");
if (mFile == NULL)
fprintf(stderr, "Could not create file %s\n", mFilename.c_str());
}
void CLogger::Close()
{
if (IsOpened())
fclose(mFile);
}
bool CLogger::IsOpened()
{
return mFile != NULL;
}
void CLogger::SetLogLevel(LogType type) {
mLogLevel = type;
}

111
src/common/logger.h Normal file
View File

@ -0,0 +1,111 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// logger.h
#pragma once
#include <string>
#include <cstdarg>
#include <common/singleton.h>
/**
* @file common/logger.h
* @brief Class for loggin information to file or console
*/
/**
* \public
* \enum LogType common/logger.h
* \brief Enum representing log level
**/
enum LogType
{
LOG_INFO = 1, /*!< lowest level, information */
LOG_WARN = 2, /*!< warning */
LOG_ERROR = 3, /*!< error */
LOG_NONE = 4 /*!< none level, used for custom messages */
};
/**
* @class CLogger
*
* @brief Class for loggin information to file or console
*
*/
class CLogger : public CSingleton<CLogger>
{
public:
CLogger();
~CLogger();
/** Write message to console or file
* @param const char str - message to write
* @param ... - additional arguments
*/
void Message(const char *str, ...);
/** Write message to console or file with LOG_INFO level
* @param const char str - message to write
* @param ... - additional arguments
*/
void Info(const char *str, ...);
/** Write message to console or file with LOG_WARN level
* @param const char str - message to write
* @param ... - additional arguments
*/
void Warn(const char *str, ...);
/** Write message to console or file with LOG_ERROR level
* @param const char str - message to write
* @param ... - additional arguments
*/
void Error(const char *str, ...);
/** Set output file to write logs to
* @param std::string filename - output file to write to
*/
void SetOutputFile(std::string filename);
/** Set log level. Logs with level below will not be shown
* @param LogType level - minimum log level to write
*/
void SetLogLevel(LogType level);
static CLogger& GetInstance();
static CLogger* GetInstancePointer();
private:
std::string mFilename;
FILE *mFile;
LogType mLogLevel;
void Open();
void Close();
bool IsOpened();
void Log(LogType type, const char* str, va_list args);
};
//! Global function to get Logger instance
inline CLogger* GetLogger() {
return CLogger::GetInstancePointer();
}

View File

@ -42,13 +42,13 @@ bool InitCurrentDirectory()
} }
bool SetProfileString(char* section, char* key, char* string) bool SetLocalProfileString(char* section, char* key, char* string)
{ {
WritePrivateProfileString(section, key, string, g_filename); WritePrivateProfileString(section, key, string, g_filename);
return true; return true;
} }
bool GetProfileString(char* section, char* key, char* buffer, int max) bool GetLocalProfileString(char* section, char* key, char* buffer, int max)
{ {
int nb; int nb;
@ -62,7 +62,7 @@ bool GetProfileString(char* section, char* key, char* buffer, int max)
} }
bool SetProfileInt(char* section, char* key, int value) bool SetLocalProfileInt(char* section, char* key, int value)
{ {
char s[20]; char s[20];
@ -71,7 +71,7 @@ bool SetProfileInt(char* section, char* key, int value)
return true; return true;
} }
bool GetProfileInt(char* section, char* key, int &value) bool GetLocalProfileInt(char* section, char* key, int &value)
{ {
char s[20]; char s[20];
int nb; int nb;
@ -87,7 +87,7 @@ bool GetProfileInt(char* section, char* key, int &value)
} }
bool SetProfileFloat(char* section, char* key, float value) bool SetLocalProfileFloat(char* section, char* key, float value)
{ {
char s[20]; char s[20];
@ -96,7 +96,7 @@ bool SetProfileFloat(char* section, char* key, float value)
return true; return true;
} }
bool GetProfileFloat(char* section, char* key, float &value) bool GetLocalProfileFloat(char* section, char* key, float &value)
{ {
char s[20]; char s[20];
int nb; int nb;

View File

@ -20,11 +20,11 @@
extern bool InitCurrentDirectory(); extern bool InitCurrentDirectory();
extern bool SetProfileString(char* section, char* key, char* string); extern bool SetLocalProfileString(char* section, char* key, char* string);
extern bool GetProfileString(char* section, char* key, char* buffer, int max); extern bool GetLocalProfileString(char* section, char* key, char* buffer, int max);
extern bool SetProfileInt(char* section, char* key, int value); extern bool SetLocalProfileInt(char* section, char* key, int value);
extern bool GetProfileInt(char* section, char* key, int &value); extern bool GetLocalProfileInt(char* section, char* key, int &value);
extern bool SetProfileFloat(char* section, char* key, float value); extern bool SetLocalProfileFloat(char* section, char* key, float value);
extern bool GetProfileFloat(char* section, char* key, float &value); extern bool GetLocalProfileFloat(char* section, char* key, float &value);

57
src/common/singleton.h Normal file
View File

@ -0,0 +1,57 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// singleton.h
#pragma once
#include <cassert>
template<typename T> class CSingleton
{
protected:
static T* mInstance;
public:
static T& GetInstance() {
aserrt(mInstance);
return *mInstance;
}
static T& GetInstancePointer() {
aserrt(mInstance);
return mInstance;
}
static bool IsCreated() {
return mInstance != NULL;
}
CSingleton() {
assert(!mInstance);
mInstance = static_cast<T *>(this);
}
~CSingleton() {
mInstance = NULL;
}
private:
CSingleton& operator=(const CSingleton<T> &);
CSingleton(const CSingleton<T> &);
};

View File

@ -26,6 +26,7 @@
class CInstanceManager; class CInstanceManager;
class CRobotMain; class CRobotMain;
class CObject; class CObject;
class CSound;
@ -303,7 +304,7 @@ protected:
void DrawParticleWheel(int i); void DrawParticleWheel(int i);
CObject* SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father); CObject* SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father);
CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father); CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father);
void Play(Snd::Sound sound, Math::Vector pos, float amplitude); void Play(Sound sound, Math::Vector pos, float amplitude);
bool TrackMove(int i, Math::Vector pos, float progress); bool TrackMove(int i, Math::Vector pos, float progress);
void TrackDraw(int i, ParticleType type); void TrackDraw(int i, ParticleType type);
@ -314,7 +315,7 @@ protected:
CRobotMain* m_main; CRobotMain* m_main;
CTerrain* m_terrain; CTerrain* m_terrain;
CWater* m_water; CWater* m_water;
Snd::CSound* m_sound; CSound* m_sound;
Gfx::Particle m_particule[MAXPARTICULE*MAXPARTITYPE]; Gfx::Particle m_particule[MAXPARTICULE*MAXPARTITYPE];
Gfx::Triangle m_triangle[MAXPARTICULE]; // triangle if PartiType == 0 Gfx::Triangle m_triangle[MAXPARTICULE]; // triangle if PartiType == 0

View File

@ -96,7 +96,414 @@ float g_unit; // conversion factor
#include "script/ClassFILE.cpp" // Static variables
static CBotClass* m_pClassFILE;
static CBotProgram* m_pFuncFile;
static int m_CompteurFileOpen = 0;
static char* m_filesDir;
// Prepares a file name.
void PrepareFilename(CBotString &filename)
{
int pos;
pos = filename.ReverseFind('\\');
if ( pos > 0 )
{
filename = filename.Mid(pos+1); // Remove files with
}
pos = filename.ReverseFind('/');
if ( pos > 0 )
{
filename = filename.Mid(pos+1); // also with /
}
pos = filename.ReverseFind(':');
if ( pos > 0 )
{
filename = filename.Mid(pos+1); // also removes the drive letter C:
}
filename = CBotString(m_filesDir) + CBotString("\\") + filename;
}
// constructor of the class
// get the filename as a parameter
// execution
bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
CBotString mode;
// accepts no parameters
if ( pVar == NULL ) return true;
// must be a character string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
CBotString filename = pVar->GivValString();
PrepareFilename(filename);
// there may be a second parameter
pVar = pVar->GivNext();
if ( pVar != NULL )
{
// recover mode
mode = pVar->GivValString();
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
// no third parameter
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
}
// saves the file name
pVar = pThis->GivItem("filename");
pVar->SetValString(filename);
if ( ! mode.IsEmpty() )
{
// opens the requested file
FILE* pFile = fopen( filename, mode );
if ( pFile == NULL ) { Exception = CBotErrFileOpen; return false; }
m_CompteurFileOpen ++;
// save the channel file
pVar = pThis->GivItem("handle");
pVar->SetValInt((long)pFile);
}
return true;
}
// compilation
CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
{
// accepts no parameters
if ( pVar == NULL ) return CBotTypResult( 0 );
// must be a character string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// there may be a second parameter
pVar = pVar->GivNext();
if ( pVar != NULL )
{
// which must be a string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
}
// the result is void (constructor)
return CBotTypResult( 0 );
}
// destructor of the class
// execution
bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
// don't open? no problem :)
if ( pVar->GivInit() != IS_DEF) return true;
FILE* pFile= (FILE*)pVar->GivValInt();
fclose(pFile);
m_CompteurFileOpen --;
pVar->SetInit(IS_NAN);
return true;
}
// process FILE :: open
// get the r/w mode as a parameter
// execution
bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// there must be a parameter
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
// which must be a character string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
// There may be a second parameter
if ( pVar->GivNext() != NULL )
{
// if the first parameter is the file name
CBotString filename = pVar->GivValString();
PrepareFilename(filename);
// saves the file name
CBotVar* pVar2 = pThis->GivItem("filename");
pVar2->SetValString(filename);
// next parameter is the mode
pVar = pVar -> GivNext();
}
CBotString mode = pVar->GivValString();
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
// no third parameter
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
// which must not be initialized
if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
// file contains the name
pVar = pThis->GivItem("filename");
CBotString filename = pVar->GivValString();
PrepareFilename(filename); // if the name was h.filename attribute = "...";
// opens the requested file
FILE* pFile = fopen( filename, mode );
if ( pFile == NULL )
{
pResult->SetValInt(false);
return true;
}
m_CompteurFileOpen ++;
// Registered the channel file
pVar = pThis->GivItem("handle");
pVar->SetValInt((long)pFile);
pResult->SetValInt(true);
return true;
}
// compilation
CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
{
// there must be a parameter
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
// which must be a string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// there may be a second parameter
pVar = pVar->GivNext();
if ( pVar != NULL )
{
// which must be a string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
}
// the result is bool
return CBotTypResult(CBotTypBoolean);
}
// process FILE :: close
// execeution
bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// it shouldn't be any parameters
if ( pVar != NULL ) return CBotErrOverParam;
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
fclose(pFile);
m_CompteurFileOpen --;
pVar->SetInit(IS_NAN);
return true;
}
// compilation
CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
{
// it shouldn't be any parameters
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
// function returns a result "void"
return CBotTypResult( 0 );
}
// process FILE :: writeln
// execution
bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// there must be a parameter
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
// which must be a character string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
CBotString param = pVar->GivValString();
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
int res = fputs(param+CBotString("\n"), pFile);
// if an error occurs generate an exception
if ( res < 0 ) { Exception = CBotErrWrite; return false; }
return true;
}
// compilation
CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
{
// there must be a parameter
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
// which must be a character string
if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
// no other parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
// the function returns a void result
return CBotTypResult( 0 );
}
// process FILE :: readln
// execution
bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// it shouldn't be any parameters
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
char chaine[2000];
int i;
for ( i = 0 ; i < 2000 ; i++ ) chaine[i] = 0;
fgets(chaine, 1999, pFile);
for ( i = 0 ; i < 2000 ; i++ ) if (chaine[i] == '\n') chaine[i] = 0;
// if an error occurs generate an exception
if ( ferror(pFile) ) { Exception = CBotErrRead; return false; }
pResult->SetValString( chaine );
return true;
}
// compilation
CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
{
// it should not be any parameter
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
// function returns a result "string"
return CBotTypResult( CBotTypString );
}
// process FILE :: readln
// execution
bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// it should not be any parameter
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
pResult->SetValInt( feof( pFile ) );
return true;
}
// compilation
CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar)
{
// it shouldn't be any parameter
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
// the function returns a boolean result
return CBotTypResult( CBotTypBoolean );
}
void InitClassFILE()
{
// create a class for file management
// the use is as follows:
// file canal( "NomFichier.txt" )
// canal.open( "r" ); // open for read
// s = canal.readln( ); // reads a line
// canal.close(); // close the file
// create the class FILE
m_pClassFILE = new CBotClass("file", NULL);
// adds the component ".filename"
m_pClassFILE->AddItem("filename", CBotTypString);
// adds the component ".handle"
m_pClassFILE->AddItem("handle", CBotTypInt, PR_PRIVATE);
// define a constructor and a destructor
m_pClassFILE->AddFunction("file", rfconstruct, cfconstruct );
m_pClassFILE->AddFunction("~file", rfdestruct, NULL );
// end of the methods associated
m_pClassFILE->AddFunction("open", rfopen, cfopen );
m_pClassFILE->AddFunction("close", rfclose, cfclose );
m_pClassFILE->AddFunction("writeln", rfwrite, cfwrite );
m_pClassFILE->AddFunction("readln", rfread, cfread );
m_pClassFILE->AddFunction("eof", rfeof, cfeof );
m_pFuncFile = new CBotProgram( );
CBotStringArray ListFonctions;
m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
}
@ -283,22 +690,22 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
m_windowPos = Math::Point(0.15f, 0.17f); m_windowPos = Math::Point(0.15f, 0.17f);
m_windowDim = Math::Point(0.70f, 0.66f); m_windowDim = Math::Point(0.70f, 0.66f);
if ( GetProfileFloat("Edit", "FontSize", fValue) ) m_fontSize = fValue; if ( GetLocalProfileFloat("Edit", "FontSize", fValue) ) m_fontSize = fValue;
if ( GetProfileFloat("Edit", "WindowPos.x", fValue) ) m_windowPos.x = fValue; if ( GetLocalProfileFloat("Edit", "WindowPos.x", fValue) ) m_windowPos.x = fValue;
if ( GetProfileFloat("Edit", "WindowPos.y", fValue) ) m_windowPos.y = fValue; if ( GetLocalProfileFloat("Edit", "WindowPos.y", fValue) ) m_windowPos.y = fValue;
if ( GetProfileFloat("Edit", "WindowDim.x", fValue) ) m_windowDim.x = fValue; if ( GetLocalProfileFloat("Edit", "WindowDim.x", fValue) ) m_windowDim.x = fValue;
if ( GetProfileFloat("Edit", "WindowDim.y", fValue) ) m_windowDim.y = fValue; if ( GetLocalProfileFloat("Edit", "WindowDim.y", fValue) ) m_windowDim.y = fValue;
m_IOPublic = false; m_IOPublic = false;
m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f);
m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle
m_IOPos.y = (1.0f-m_IODim.y)/2.0f; m_IOPos.y = (1.0f-m_IODim.y)/2.0f;
if ( GetProfileInt ("Edit", "IOPublic", iValue) ) m_IOPublic = iValue; if ( GetLocalProfileInt ("Edit", "IOPublic", iValue) ) m_IOPublic = iValue;
if ( GetProfileFloat("Edit", "IOPos.x", fValue) ) m_IOPos.x = fValue; if ( GetLocalProfileFloat("Edit", "IOPos.x", fValue) ) m_IOPos.x = fValue;
if ( GetProfileFloat("Edit", "IOPos.y", fValue) ) m_IOPos.y = fValue; if ( GetLocalProfileFloat("Edit", "IOPos.y", fValue) ) m_IOPos.y = fValue;
if ( GetProfileFloat("Edit", "IODim.x", fValue) ) m_IODim.x = fValue; if ( GetLocalProfileFloat("Edit", "IODim.x", fValue) ) m_IODim.x = fValue;
if ( GetProfileFloat("Edit", "IODim.y", fValue) ) m_IODim.y = fValue; if ( GetLocalProfileFloat("Edit", "IODim.y", fValue) ) m_IODim.y = fValue;
m_short->FlushShortcuts(); m_short->FlushShortcuts();
InitEye(); InitEye();
@ -315,7 +722,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
g_unit = 4.0f; g_unit = 4.0f;
m_gamerName[0] = 0; m_gamerName[0] = 0;
GetProfileString("Gamer", "LastName", m_gamerName, 100); GetLocalProfileString("Gamer", "LastName", m_gamerName, 100);
SetGlobalGamerName(m_gamerName); SetGlobalGamerName(m_gamerName);
ReadFreeParam(); ReadFreeParam();
m_dialog->SetupRecall(); m_dialog->SetupRecall();
@ -430,7 +837,7 @@ void CRobotMain::CreateIni()
int iValue; int iValue;
// colobot.ini don't exist? // colobot.ini don't exist?
if ( !GetProfileInt("Setup", "TotoMode", iValue) ) if ( !GetLocalProfileInt("Setup", "TotoMode", iValue) )
{ {
m_dialog->SetupMemorize(); m_dialog->SetupMemorize();
} }
@ -1801,7 +2208,7 @@ float CRobotMain::RetGameTime()
void CRobotMain::SetFontSize(float size) void CRobotMain::SetFontSize(float size)
{ {
m_fontSize = size; m_fontSize = size;
SetProfileFloat("Edit", "FontSize", m_fontSize); SetLocalProfileFloat("Edit", "FontSize", m_fontSize);
} }
float CRobotMain::RetFontSize() float CRobotMain::RetFontSize()
@ -1814,8 +2221,8 @@ float CRobotMain::RetFontSize()
void CRobotMain::SetWindowPos(Math::Point pos) void CRobotMain::SetWindowPos(Math::Point pos)
{ {
m_windowPos = pos; m_windowPos = pos;
SetProfileFloat("Edit", "WindowPos.x", m_windowPos.x); SetLocalProfileFloat("Edit", "WindowPos.x", m_windowPos.x);
SetProfileFloat("Edit", "WindowPos.y", m_windowPos.y); SetLocalProfileFloat("Edit", "WindowPos.y", m_windowPos.y);
} }
Math::Point CRobotMain::RetWindowPos() Math::Point CRobotMain::RetWindowPos()
@ -1826,8 +2233,8 @@ Math::Point CRobotMain::RetWindowPos()
void CRobotMain::SetWindowDim(Math::Point dim) void CRobotMain::SetWindowDim(Math::Point dim)
{ {
m_windowDim = dim; m_windowDim = dim;
SetProfileFloat("Edit", "WindowDim.x", m_windowDim.x); SetLocalProfileFloat("Edit", "WindowDim.x", m_windowDim.x);
SetProfileFloat("Edit", "WindowDim.y", m_windowDim.y); SetLocalProfileFloat("Edit", "WindowDim.y", m_windowDim.y);
} }
Math::Point CRobotMain::RetWindowDim() Math::Point CRobotMain::RetWindowDim()
@ -1841,7 +2248,7 @@ Math::Point CRobotMain::RetWindowDim()
void CRobotMain::SetIOPublic(bool bMode) void CRobotMain::SetIOPublic(bool bMode)
{ {
m_IOPublic = bMode; m_IOPublic = bMode;
SetProfileInt("Edit", "IOPublic", m_IOPublic); SetLocalProfileInt("Edit", "IOPublic", m_IOPublic);
} }
bool CRobotMain::RetIOPublic() bool CRobotMain::RetIOPublic()
@ -1852,8 +2259,8 @@ bool CRobotMain::RetIOPublic()
void CRobotMain::SetIOPos(Math::Point pos) void CRobotMain::SetIOPos(Math::Point pos)
{ {
m_IOPos = pos; m_IOPos = pos;
SetProfileFloat("Edit", "IOPos.x", m_IOPos.x); SetLocalProfileFloat("Edit", "IOPos.x", m_IOPos.x);
SetProfileFloat("Edit", "IOPos.y", m_IOPos.y); SetLocalProfileFloat("Edit", "IOPos.y", m_IOPos.y);
} }
Math::Point CRobotMain::RetIOPos() Math::Point CRobotMain::RetIOPos()
@ -1864,8 +2271,8 @@ Math::Point CRobotMain::RetIOPos()
void CRobotMain::SetIODim(Math::Point dim) void CRobotMain::SetIODim(Math::Point dim)
{ {
m_IODim = dim; m_IODim = dim;
SetProfileFloat("Edit", "IODim.x", m_IODim.x); SetLocalProfileFloat("Edit", "IODim.x", m_IODim.x);
SetProfileFloat("Edit", "IODim.y", m_IODim.y); SetLocalProfileFloat("Edit", "IODim.y", m_IODim.y);
} }
Math::Point CRobotMain::RetIODim() Math::Point CRobotMain::RetIODim()

33
src/plugins/plugin.h Normal file
View File

@ -0,0 +1,33 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// plugin.h
#pragma once
#define PLUGIN_INTERFACE(class_type, interface_type) \
extern "C" interface_type* installPlugin() { return (interface_type *)new class_type(); } \
extern "C" void uninstallPlugin(class_type *_class) { delete _class; }
class CPlugin {
public:
virtual char* PluginName() = 0;
virtual int PluginVersion() = 0;
};

View File

@ -1,425 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * 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
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// Static variables
static CBotClass* m_pClassFILE;
static CBotProgram* m_pFuncFile;
static int m_CompteurFileOpen = 0;
static char* m_filesDir;
// Prepares a file name.
void PrepareFilename(CBotString &filename)
{
int pos;
pos = filename.ReverseFind('\\');
if ( pos > 0 )
{
filename = filename.Mid(pos+1); // Remove files with
}
pos = filename.ReverseFind('/');
if ( pos > 0 )
{
filename = filename.Mid(pos+1); // also with /
}
pos = filename.ReverseFind(':');
if ( pos > 0 )
{
filename = filename.Mid(pos+1); // also removes the drive letter C:
}
filename = CBotString(m_filesDir) + CBotString("\\") + filename;
}
// constructor of the class
// get the filename as a parameter
// execution
bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
CBotString mode;
// accepts no parameters
if ( pVar == NULL ) return true;
// must be a character string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
CBotString filename = pVar->GivValString();
PrepareFilename(filename);
// there may be a second parameter
pVar = pVar->GivNext();
if ( pVar != NULL )
{
// recover mode
mode = pVar->GivValString();
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
// no third parameter
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
}
// saves the file name
pVar = pThis->GivItem("filename");
pVar->SetValString(filename);
if ( ! mode.IsEmpty() )
{
// opens the requested file
FILE* pFile = fopen( filename, mode );
if ( pFile == NULL ) { Exception = CBotErrFileOpen; return false; }
m_CompteurFileOpen ++;
// save the channel file
pVar = pThis->GivItem("handle");
pVar->SetValInt((long)pFile);
}
return true;
}
// compilation
CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
{
// accepts no parameters
if ( pVar == NULL ) return CBotTypResult( 0 );
// must be a character string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// there may be a second parameter
pVar = pVar->GivNext();
if ( pVar != NULL )
{
// which must be a string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
}
// the result is void (constructor)
return CBotTypResult( 0 );
}
// destructor of the class
// execution
bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
// don't open? no problem :)
if ( pVar->GivInit() != IS_DEF) return true;
FILE* pFile= (FILE*)pVar->GivValInt();
fclose(pFile);
m_CompteurFileOpen --;
pVar->SetInit(IS_NAN);
return true;
}
// process FILE :: open
// get the r/w mode as a parameter
// execution
bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// there must be a parameter
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
// which must be a character string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
// There may be a second parameter
if ( pVar->GivNext() != NULL )
{
// if the first parameter is the file name
CBotString filename = pVar->GivValString();
PrepareFilename(filename);
// saves the file name
CBotVar* pVar2 = pThis->GivItem("filename");
pVar2->SetValString(filename);
// next parameter is the mode
pVar = pVar -> GivNext();
}
CBotString mode = pVar->GivValString();
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
// no third parameter
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
// which must not be initialized
if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
// file contains the name
pVar = pThis->GivItem("filename");
CBotString filename = pVar->GivValString();
PrepareFilename(filename); // if the name was h.filename attribute = "...";
// opens the requested file
FILE* pFile = fopen( filename, mode );
if ( pFile == NULL )
{
pResult->SetValInt(false);
return true;
}
m_CompteurFileOpen ++;
// Registered the channel file
pVar = pThis->GivItem("handle");
pVar->SetValInt((long)pFile);
pResult->SetValInt(true);
return true;
}
// compilation
CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
{
// there must be a parameter
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
// which must be a string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// there may be a second parameter
pVar = pVar->GivNext();
if ( pVar != NULL )
{
// which must be a string
if ( pVar->GivType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
}
// the result is bool
return CBotTypResult(CBotTypBoolean);
}
// process FILE :: close
// execeution
bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// it shouldn't be any parameters
if ( pVar != NULL ) return CBotErrOverParam;
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
fclose(pFile);
m_CompteurFileOpen --;
pVar->SetInit(IS_NAN);
return true;
}
// compilation
CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
{
// it shouldn't be any parameters
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
// function returns a result "void"
return CBotTypResult( 0 );
}
// process FILE :: writeln
// execution
bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// there must be a parameter
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
// which must be a character string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
CBotString param = pVar->GivValString();
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
int res = fputs(param+CBotString("\n"), pFile);
// if an error occurs generate an exception
if ( res < 0 ) { Exception = CBotErrWrite; return false; }
return true;
}
// compilation
CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
{
// there must be a parameter
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
// which must be a character string
if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
// no other parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
// the function returns a void result
return CBotTypResult( 0 );
}
// process FILE :: readln
// execution
bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// it shouldn't be any parameters
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
char chaine[2000];
int i;
for ( i = 0 ; i < 2000 ; i++ ) chaine[i] = 0;
fgets(chaine, 1999, pFile);
for ( i = 0 ; i < 2000 ; i++ ) if (chaine[i] == '\n') chaine[i] = 0;
// if an error occurs generate an exception
if ( ferror(pFile) ) { Exception = CBotErrRead; return false; }
pResult->SetValString( chaine );
return true;
}
// compilation
CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
{
// it should not be any parameter
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
// function returns a result "string"
return CBotTypResult( CBotTypString );
}
// process FILE :: readln
// execution
bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// it should not be any parameter
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieve the item "handle"
pVar = pThis->GivItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
pResult->SetValInt( feof( pFile ) );
return true;
}
// compilation
CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar)
{
// it shouldn't be any parameter
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
// the function returns a boolean result
return CBotTypResult( CBotTypBoolean );
}
void InitClassFILE()
{
// create a class for file management
// the use is as follows:
// file canal( "NomFichier.txt" )
// canal.open( "r" ); // open for read
// s = canal.readln( ); // reads a line
// canal.close(); // close the file
// create the class FILE
m_pClassFILE = new CBotClass("file", NULL);
// adds the component ".filename"
m_pClassFILE->AddItem("filename", CBotTypString);
// adds the component ".handle"
m_pClassFILE->AddItem("handle", CBotTypInt, PR_PRIVATE);
// define a constructor and a destructor
m_pClassFILE->AddFunction("file", rfconstruct, cfconstruct );
m_pClassFILE->AddFunction("~file", rfdestruct, NULL );
// end of the methods associated
m_pClassFILE->AddFunction("open", rfopen, cfopen );
m_pClassFILE->AddFunction("close", rfclose, cfclose );
m_pClassFILE->AddFunction("writeln", rfwrite, cfwrite );
m_pClassFILE->AddFunction("readln", rfread, cfread );
m_pClassFILE->AddFunction("eof", rfeof, cfeof );
m_pFuncFile = new CBotProgram( );
CBotStringArray ListFonctions;
m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
}

View File

View File

@ -1,165 +1,318 @@
// * 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) // * 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
// * (at your option) any later version. // * (at your option) any later version.
// * // *
// * This program is distributed in the hope that it will be useful, // * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of // * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details. // * GNU General Public License for more details.
// * // *
// * 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/.
// sound.h // soundinterface.h
#pragma once /**
* @file sound/soundinterface.h
* @brief Sound plugin interface
#include "math/vector.h" */
#pragma once
class CInstanceManager;
#include <math/vector.h>
namespace Snd {
#include <plugins/plugin.h>
const int MAXFILES = 200;
const int MAXSOUND = 32; /*!
const int MAXVOLUME = 20; * Maximum possible audio volume
const int MAXOPER = 4; */
#define MAXVOLUME 100
enum Sound
{ /**
SOUND_CLICK = 0, * \public
SOUND_BOUM = 1, * \enum Sound sound/soundinterface.h
SOUND_EXPLO = 2, * \brief Sound enum representing sound file
SOUND_FLYh = 3, // human **/
SOUND_FLY = 4, enum Sound
SOUND_STEPs = 5, // smooth {
SOUND_MOTORw = 6, // wheel SOUND_CLICK = 0,
SOUND_MOTORt = 7, // tank SOUND_BOUM = 1,
SOUND_MOTORr = 8, // roller SOUND_EXPLO = 2,
SOUND_ERROR = 9, SOUND_FLYh = 3, /*!< human */
SOUND_CONVERT = 10, SOUND_FLY = 4,
SOUND_ENERGY = 11, SOUND_STEPs = 5, /*!< smooth */
SOUND_PLOUF = 12, SOUND_MOTORw = 6, /*!< wheel */
SOUND_BLUP = 13, SOUND_MOTORt = 7, /*!< tank */
SOUND_WARNING = 14, SOUND_MOTORr = 8, /*!< roller */
SOUND_DERRICK = 15, SOUND_ERROR = 9,
SOUND_LABO = 16, SOUND_CONVERT = 10,
SOUND_STATION = 17, SOUND_ENERGY = 11,
SOUND_REPAIR = 18, SOUND_PLOUF = 12,
SOUND_RESEARCH = 19, SOUND_BLUP = 13,
SOUND_INSECTs = 20, // spider SOUND_WARNING = 14,
SOUND_BURN = 21, SOUND_DERRICK = 15,
SOUND_TZOING = 22, SOUND_LABO = 16,
SOUND_GGG = 23, SOUND_STATION = 17,
SOUND_MANIP = 24, SOUND_REPAIR = 18,
SOUND_FIRE = 25, // shooting with fireball SOUND_RESEARCH = 19,
SOUND_HUMAN1 = 26, // breathing SOUND_INSECTs = 20, /*!< spider */
SOUND_STEPw = 27, // water SOUND_BURN = 21,
SOUND_SWIM = 28, SOUND_TZOING = 22,
SOUND_RADAR = 29, SOUND_GGG = 23,
SOUND_BUILD = 30, SOUND_MANIP = 24,
SOUND_ALARM = 31, // energy alarm SOUND_FIRE = 25, /*!< shooting with fireball */
SOUND_SLIDE = 32, SOUND_HUMAN1 = 26, /*!< breathing */
SOUND_EXPLOi = 33, // insect SOUND_STEPw = 27, /*!< water */
SOUND_INSECTa = 34, // ant SOUND_SWIM = 28,
SOUND_INSECTb = 35, // bee SOUND_RADAR = 29,
SOUND_INSECTw = 36, // worm SOUND_BUILD = 30,
SOUND_INSECTm = 37, // mother SOUND_ALARM = 31, /*!< energy alarm */
SOUND_TREMBLE = 38, SOUND_SLIDE = 32,
SOUND_PSHHH = 39, SOUND_EXPLOi = 33, /*!< insect */
SOUND_NUCLEAR = 40, SOUND_INSECTa = 34, /*!< ant */
SOUND_INFO = 41, SOUND_INSECTb = 35, /*!< bee */
SOUND_OPEN = 42, SOUND_INSECTw = 36, /*!< worm */
SOUND_CLOSE = 43, SOUND_INSECTm = 37, /*!< mother */
SOUND_FACTORY = 44, SOUND_TREMBLE = 38,
SOUND_EGG = 45, SOUND_PSHHH = 39,
SOUND_MOTORs = 46, // submarine SOUND_NUCLEAR = 40,
SOUND_MOTORi = 47, // insect (legs) SOUND_INFO = 41,
SOUND_SHIELD = 48, SOUND_OPEN = 42,
SOUND_FIREi = 49, // shooting with orgaball (insect) SOUND_CLOSE = 43,
SOUND_GUNDEL = 50, SOUND_FACTORY = 44,
SOUND_PSHHH2 = 51, // shield SOUND_EGG = 45,
SOUND_MESSAGE = 52, SOUND_MOTORs = 46, /*!< submarine */
SOUND_BOUMm = 53, // metal SOUND_MOTORi = 47, /*!< insect (legs) */
SOUND_BOUMv = 54, // plant SOUND_SHIELD = 48,
SOUND_BOUMs = 55, // smooth SOUND_FIREi = 49, /*!< shooting with orgaball (insect) */
SOUND_EXPLOl = 56, // little SOUND_GUNDEL = 50,
SOUND_EXPLOlp = 57, // little power SOUND_PSHHH2 = 51, /*!< shield */
SOUND_EXPLOp = 58, // power SOUND_MESSAGE = 52,
SOUND_STEPh = 59, // hard SOUND_BOUMm = 53, /*!< metal */
SOUND_STEPm = 60, // metal SOUND_BOUMv = 54, /*!< plant */
SOUND_POWERON = 61, SOUND_BOUMs = 55, /*!< smooth */
SOUND_POWEROFF = 62, SOUND_EXPLOl = 56, /*!< little */
SOUND_AIE = 63, SOUND_EXPLOlp = 57, /*!< little power */
SOUND_WAYPOINT = 64, SOUND_EXPLOp = 58, /*!< power */
SOUND_RECOVER = 65, SOUND_STEPh = 59, /*!< hard */
SOUND_DEADi = 66, SOUND_STEPm = 60, /*!< metal */
SOUND_JOSTLE = 67, SOUND_POWERON = 61,
SOUND_GFLAT = 68, SOUND_POWEROFF = 62,
SOUND_DEADg = 69, // shooting death SOUND_AIE = 63,
SOUND_DEADw = 70, // drowning SOUND_WAYPOINT = 64,
SOUND_FLYf = 71, // reactor fail SOUND_RECOVER = 65,
SOUND_ALARMt = 72, // temperature alarm SOUND_DEADi = 66,
SOUND_FINDING = 73, // finds a cache object SOUND_JOSTLE = 67,
SOUND_THUMP = 74, SOUND_GFLAT = 68,
SOUND_TOUCH = 75, SOUND_DEADg = 69, /*!< shooting death */
SOUND_BLITZ = 76, SOUND_DEADw = 70, /*!< drowning */
SOUND_MUSHROOM = 77, SOUND_FLYf = 71, /*!< reactor fail */
SOUND_FIREp = 78, // shooting with phazer SOUND_ALARMt = 72, /*!< temperature alarm */
SOUND_EXPLOg1 = 79, // impact gun 1 SOUND_FINDING = 73, /*!< finds a cache object */
SOUND_EXPLOg2 = 80, // impact gun 2 SOUND_THUMP = 74,
SOUND_MOTORd = 81, // engine friction SOUND_TOUCH = 75,
}; SOUND_BLITZ = 76,
SOUND_MUSHROOM = 77,
enum SoundNext SOUND_FIREp = 78, /*!< shooting with phazer */
{ SOUND_EXPLOg1 = 79, /*!< impact gun 1 */
SOPER_CONTINUE = 1, SOUND_EXPLOg2 = 80, /*!< impact gun 2 */
SOPER_STOP = 2, SOUND_MOTORd = 81, /*!< engine friction */
SOPER_LOOP = 3, };
};
struct SoundOper /**
{ * \public
char bUsed; * \enum SoundNext sound/soundinterface.h
float finalAmplitude; * \brief Enum representing operation that will be performend on a sound at given time
float finalFrequency; **/
float totalTime; enum SoundNext
float currentTime; {
Snd::SoundNext nextOper; SOPER_CONTINUE = 1, /*!< continue playing */
}; SOPER_STOP = 2, /*!< stop playing */
SOPER_LOOP = 3, /*!< start over */
struct SoundChannel };
{
char bUsed; // buffer used?
char bMute; // silence? /**
Snd::Sound type; // SOUND_* * @class CSoundInterface
int priority; // so great -> important *
Math::Vector pos; // position in space * @brief Sound plugin interface
unsigned short uniqueStamp; // unique marker *
// LPDIRECTSOUNDBUFFER soundBuffer; */
// LPDIRECTSOUND3DBUFFER soundBuffer3D; class CSoundInterface : public CPlugin
float startAmplitude; {
float startFrequency; public:
float changeFrequency; CSoundInterface() {
int initFrequency; //CInstanceManager::getInstance().AddInstance(CLASS_SOUND, this);
float volume; // 2D: volume 1..0 depending on position //m_iMan->AddInstance(CLASS_SOUND, this);
float pan; // 2D: pan -1..+1 depending on position };
Snd::SoundOper oper[MAXOPER]; virtual ~CSoundInterface() = 0;
};
/** Function to initialize sound device
* @param bool b3D - enable support for 3D sound
*/
class CSound virtual bool Create(bool b3D) = 0;
{
// TODO /** Function called to cache all sound effect files.
}; * Function calls \link CSoundInterface::Cache() \endlink for each file
*/
}; // namespace Sound virtual void CacheAll() = 0;
/** Function called to cache sound effect file.
* This function is called by plugin interface for each file.
* @param Sound bSound - id of a file, will be used to identify sound files
* @param std::string bFile - file to load
* @return return true on success
*/
virtual bool Cache(Sound bSound, std::string bFile) = 0;
/** Return if plugin is enabled
* @return return true if plugin is enabled
*/
virtual bool RetEnable() = 0;
/** Change sound mode to 2D/3D
* @param bool bMode - true to enable 3D sound
*/
virtual void SetSound3D(bool bMode) = 0;
/** Return if we use 3D sound
* @return true if we have 3D sound enabled
*/
virtual bool RetSound3D() = 0;
/** Return if we have 3D sound capable card
* @return true for 3D sound support
*/
virtual bool RetSound3DCap() = 0;
/** Change global sound volume
* @param int volume - range from 0 to MAXVOLUME
*/
virtual void SetAudioVolume(int volume) = 0;
/** Return global sound volume
* @return global volume as int in range from 0 to MAXVOLUME
*/
virtual int RetAudioVolume() = 0;
/** Set music volume
* @param int volume - range from 0 to MAXVOLUME
*/
virtual void SetMusicVolume(int volume) = 0;
/** Return music volume
* @return music volume as int in range from 0 to MAXVOLUME
*/
virtual int RetMusicVolume() = 0;
/** Set listener position
* @param Math::Vector eye - position of listener
* @param Math::Vector lookat - direction listener is looking at
*/
virtual void SetListener(Math::Vector eye, Math::Vector lookat) = 0;
/** Update data each frame
* @param float rTime - time since last update
*/
virtual void FrameMove(float rTime) = 0;
/** Play specific sound
* @param Sound sound - sound to play
* @param float amplitude - change amplitude of sound before playing
* @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
* @param bool bLoop - loop sound
* @return identifier of channel that sound will be played on
*/
virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
/** Play specific sound
* @param Sound sound - sound to play
* @param Math:Vector pos - position of sound in space
* @param float amplitude - change amplitude of sound before playing
* @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
* @param bool bLoop - loop sound
* @return identifier of channel that sound will be played on
*/
virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
/** Remove all operations that would be made on sound in channel.
* @param int channel - channel to work on
* @return return true on success
*/
virtual bool FlushEnvelope(int channel) = 0;
/** Add envelope to sound. Envelope is a operatino that will be performend on sound in future like changing frequency
* @param int channel - channel to work on
* @param float amplitude - change amplitude
* @param float frequency - change frequency
* @param float time - when to change (sample time)
* @param SoundNext oper - operation to perform
* @return return true on success
*/
virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) = 0;
/** Set sound position in space
* @param int channel - channel to work on
* @param Math::Vector pos - new positino of a sound
* @return return true on success
*/
virtual bool Position(int channel, Math::Vector pos) = 0;
/** Set sound frequency
* @param int channel - channel to work on
* @param float frequency - change sound frequency
* @return return true on success
*/
virtual bool Frequency(int channel, float frequency) = 0;
/** Stop playing sound
* @param int channel - channel to work on
* @return return true on success
*/
virtual bool Stop(int channel) = 0;
/** Stop playing all sounds
* @return return true on success
*/
virtual bool StopAll() = 0;
/** Mute/unmute all sounds
* @param bool bMute
* @return return true on success
*/
virtual bool MuteAll(bool bMute) = 0;
/** Start playing music
* @param int rank - track number
* @param bool bRepeat - repeat playing
* @return return true on success
*/
virtual bool PlayMusic(int rank, bool bRepeat) = 0;
/** Restart music
* @return return true on success
*/
virtual bool RestartMusic() = 0;
/** Susspend paying music
* @return return true on success
*/
virtual void SuspendMusic() = 0;
/** Stop playing music
* @return return true on success
*/
virtual void StopMusic() = 0;
/** Check if music if playing
* @return return true if music is playing
*/
virtual bool IsPlayingMusic() = 0;
};

View File

@ -3884,7 +3884,7 @@ void CMainDialog::NameSelect()
RetGamerFace(m_main->RetGamerName()); RetGamerFace(m_main->RetGamerName());
SetProfileString("Gamer", "LastName", m_main->RetGamerName()); SetLocalProfileString("Gamer", "LastName", m_main->RetGamerName());
} }
// Creates a new player. // Creates a new player.
@ -5522,104 +5522,104 @@ void CMainDialog::SetupMemorize()
char key[500]; char key[500];
char num[10]; char num[10];
SetProfileString("Directory", "scene", m_sceneDir); SetLocalProfileString("Directory", "scene", m_sceneDir);
SetProfileString("Directory", "savegame", m_savegameDir); SetLocalProfileString("Directory", "savegame", m_savegameDir);
SetProfileString("Directory", "public", m_publicDir); SetLocalProfileString("Directory", "public", m_publicDir);
SetProfileString("Directory", "user", m_userDir); SetLocalProfileString("Directory", "user", m_userDir);
SetProfileString("Directory", "files", m_filesDir); SetLocalProfileString("Directory", "files", m_filesDir);
iValue = m_engine->RetTotoMode(); iValue = m_engine->RetTotoMode();
SetProfileInt("Setup", "TotoMode", iValue); SetLocalProfileInt("Setup", "TotoMode", iValue);
iValue = m_bTooltip; iValue = m_bTooltip;
SetProfileInt("Setup", "Tooltips", iValue); SetLocalProfileInt("Setup", "Tooltips", iValue);
iValue = m_bGlint; iValue = m_bGlint;
SetProfileInt("Setup", "InterfaceGlint", iValue); SetLocalProfileInt("Setup", "InterfaceGlint", iValue);
iValue = m_bRain; iValue = m_bRain;
SetProfileInt("Setup", "InterfaceGlint", iValue); SetLocalProfileInt("Setup", "InterfaceGlint", iValue);
iValue = m_engine->RetNiceMouse(); iValue = m_engine->RetNiceMouse();
SetProfileInt("Setup", "NiceMouse", iValue); SetLocalProfileInt("Setup", "NiceMouse", iValue);
iValue = m_bSoluce4; iValue = m_bSoluce4;
SetProfileInt("Setup", "Soluce4", iValue); SetLocalProfileInt("Setup", "Soluce4", iValue);
iValue = m_bMovies; iValue = m_bMovies;
SetProfileInt("Setup", "Movies", iValue); SetLocalProfileInt("Setup", "Movies", iValue);
iValue = m_bNiceReset; iValue = m_bNiceReset;
SetProfileInt("Setup", "NiceReset", iValue); SetLocalProfileInt("Setup", "NiceReset", iValue);
iValue = m_bHimselfDamage; iValue = m_bHimselfDamage;
SetProfileInt("Setup", "HimselfDamage", iValue); SetLocalProfileInt("Setup", "HimselfDamage", iValue);
iValue = m_bCameraScroll; iValue = m_bCameraScroll;
SetProfileInt("Setup", "CameraScroll", iValue); SetLocalProfileInt("Setup", "CameraScroll", iValue);
iValue = m_bCameraInvertX; iValue = m_bCameraInvertX;
SetProfileInt("Setup", "CameraInvertX", iValue); SetLocalProfileInt("Setup", "CameraInvertX", iValue);
iValue = m_bEffect; iValue = m_bEffect;
SetProfileInt("Setup", "InterfaceEffect", iValue); SetLocalProfileInt("Setup", "InterfaceEffect", iValue);
iValue = m_engine->RetShadow(); iValue = m_engine->RetShadow();
SetProfileInt("Setup", "GroundShadow", iValue); SetLocalProfileInt("Setup", "GroundShadow", iValue);
iValue = m_engine->RetGroundSpot(); iValue = m_engine->RetGroundSpot();
SetProfileInt("Setup", "GroundSpot", iValue); SetLocalProfileInt("Setup", "GroundSpot", iValue);
iValue = m_engine->RetDirty(); iValue = m_engine->RetDirty();
SetProfileInt("Setup", "ObjectDirty", iValue); SetLocalProfileInt("Setup", "ObjectDirty", iValue);
iValue = m_engine->RetFog(); iValue = m_engine->RetFog();
SetProfileInt("Setup", "FogMode", iValue); SetLocalProfileInt("Setup", "FogMode", iValue);
iValue = m_engine->RetLensMode(); iValue = m_engine->RetLensMode();
SetProfileInt("Setup", "LensMode", iValue); SetLocalProfileInt("Setup", "LensMode", iValue);
iValue = m_engine->RetSkyMode(); iValue = m_engine->RetSkyMode();
SetProfileInt("Setup", "SkyMode", iValue); SetLocalProfileInt("Setup", "SkyMode", iValue);
iValue = m_engine->RetPlanetMode(); iValue = m_engine->RetPlanetMode();
SetProfileInt("Setup", "PlanetMode", iValue); SetLocalProfileInt("Setup", "PlanetMode", iValue);
iValue = m_engine->RetLightMode(); iValue = m_engine->RetLightMode();
SetProfileInt("Setup", "LightMode", iValue); SetLocalProfileInt("Setup", "LightMode", iValue);
iValue = m_engine->RetJoystick(); iValue = m_engine->RetJoystick();
SetProfileInt("Setup", "UseJoystick", iValue); SetLocalProfileInt("Setup", "UseJoystick", iValue);
fValue = m_engine->RetParticuleDensity(); fValue = m_engine->RetParticuleDensity();
SetProfileFloat("Setup", "ParticuleDensity", fValue); SetLocalProfileFloat("Setup", "ParticuleDensity", fValue);
fValue = m_engine->RetClippingDistance(); fValue = m_engine->RetClippingDistance();
SetProfileFloat("Setup", "ClippingDistance", fValue); SetLocalProfileFloat("Setup", "ClippingDistance", fValue);
fValue = m_engine->RetObjectDetail(); fValue = m_engine->RetObjectDetail();
SetProfileFloat("Setup", "ObjectDetail", fValue); SetLocalProfileFloat("Setup", "ObjectDetail", fValue);
fValue = m_engine->RetGadgetQuantity(); fValue = m_engine->RetGadgetQuantity();
SetProfileFloat("Setup", "GadgetQuantity", fValue); SetLocalProfileFloat("Setup", "GadgetQuantity", fValue);
iValue = m_engine->RetTextureQuality(); iValue = m_engine->RetTextureQuality();
SetProfileInt("Setup", "TextureQuality", iValue); SetLocalProfileInt("Setup", "TextureQuality", iValue);
iValue = m_sound->RetAudioVolume(); iValue = m_sound->RetAudioVolume();
SetProfileInt("Setup", "AudioVolume", iValue); SetLocalProfileInt("Setup", "AudioVolume", iValue);
iValue = m_sound->RetMidiVolume(); iValue = m_sound->RetMidiVolume();
SetProfileInt("Setup", "MidiVolume", iValue); SetLocalProfileInt("Setup", "MidiVolume", iValue);
iValue = m_sound->RetSound3D(); iValue = m_sound->RetSound3D();
SetProfileInt("Setup", "Sound3D", iValue); SetLocalProfileInt("Setup", "Sound3D", iValue);
iValue = m_engine->RetEditIndentMode(); iValue = m_engine->RetEditIndentMode();
SetProfileInt("Setup", "EditIndentMode", iValue); SetLocalProfileInt("Setup", "EditIndentMode", iValue);
iValue = m_engine->RetEditIndentValue(); iValue = m_engine->RetEditIndentValue();
SetProfileInt("Setup", "EditIndentValue", iValue); SetLocalProfileInt("Setup", "EditIndentValue", iValue);
key[0] = 0; key[0] = 0;
for ( i=0 ; i<100 ; i++ ) for ( i=0 ; i<100 ; i++ )
@ -5633,21 +5633,21 @@ void CMainDialog::SetupMemorize()
strcat(key, num); strcat(key, num);
} }
} }
SetProfileString("Setup", "KeyMap", key); SetLocalProfileString("Setup", "KeyMap", key);
#if _NET #if _NET
if ( m_accessEnable ) if ( m_accessEnable )
{ {
iValue = m_accessMission; iValue = m_accessMission;
SetProfileInt("Setup", "AccessMission", iValue); SetLocalProfileInt("Setup", "AccessMission", iValue);
iValue = m_accessUser; iValue = m_accessUser;
SetProfileInt("Setup", "AccessUser", iValue); SetLocalProfileInt("Setup", "AccessUser", iValue);
} }
#endif #endif
iValue = m_bDeleteGamer; iValue = m_bDeleteGamer;
SetProfileInt("Setup", "DeleteGamer", iValue); SetLocalProfileInt("Setup", "DeleteGamer", iValue);
m_engine->WriteProfile(); m_engine->WriteProfile();
} }
@ -5661,192 +5661,192 @@ void CMainDialog::SetupRecall()
char key[500]; char key[500];
char* p; char* p;
if ( GetProfileString("Directory", "scene", key, _MAX_FNAME) ) if ( GetLocalProfileString("Directory", "scene", key, _MAX_FNAME) )
{ {
strcpy(m_sceneDir, key); strcpy(m_sceneDir, key);
} }
if ( GetProfileString("Directory", "savegame", key, _MAX_FNAME) ) if ( GetLocalProfileString("Directory", "savegame", key, _MAX_FNAME) )
{ {
strcpy(m_savegameDir, key); strcpy(m_savegameDir, key);
} }
if ( GetProfileString("Directory", "public", key, _MAX_FNAME) ) if ( GetLocalProfileString("Directory", "public", key, _MAX_FNAME) )
{ {
strcpy(m_publicDir, key); strcpy(m_publicDir, key);
} }
if ( GetProfileString("Directory", "user", key, _MAX_FNAME) ) if ( GetLocalProfileString("Directory", "user", key, _MAX_FNAME) )
{ {
strcpy(m_userDir, key); strcpy(m_userDir, key);
} }
if ( GetProfileString("Directory", "files", key, _MAX_FNAME) ) if ( GetLocalProfileString("Directory", "files", key, _MAX_FNAME) )
{ {
strcpy(m_filesDir, key); strcpy(m_filesDir, key);
} }
if ( GetProfileInt("Setup", "TotoMode", iValue) ) if ( GetLocalProfileInt("Setup", "TotoMode", iValue) )
{ {
m_engine->SetTotoMode(iValue); m_engine->SetTotoMode(iValue);
} }
if ( GetProfileInt("Setup", "Tooltips", iValue) ) if ( GetLocalProfileInt("Setup", "Tooltips", iValue) )
{ {
m_bTooltip = iValue; m_bTooltip = iValue;
} }
if ( GetProfileInt("Setup", "InterfaceGlint", iValue) ) if ( GetLocalProfileInt("Setup", "InterfaceGlint", iValue) )
{ {
m_bGlint = iValue; m_bGlint = iValue;
} }
if ( GetProfileInt("Setup", "InterfaceGlint", iValue) ) if ( GetLocalProfileInt("Setup", "InterfaceGlint", iValue) )
{ {
m_bRain = iValue; m_bRain = iValue;
} }
if ( GetProfileInt("Setup", "NiceMouse", iValue) ) if ( GetLocalProfileInt("Setup", "NiceMouse", iValue) )
{ {
m_engine->SetNiceMouse(iValue); m_engine->SetNiceMouse(iValue);
} }
if ( GetProfileInt("Setup", "Soluce4", iValue) ) if ( GetLocalProfileInt("Setup", "Soluce4", iValue) )
{ {
m_bSoluce4 = iValue; m_bSoluce4 = iValue;
} }
if ( GetProfileInt("Setup", "Movies", iValue) ) if ( GetLocalProfileInt("Setup", "Movies", iValue) )
{ {
m_bMovies = iValue; m_bMovies = iValue;
} }
if ( GetProfileInt("Setup", "NiceReset", iValue) ) if ( GetLocalProfileInt("Setup", "NiceReset", iValue) )
{ {
m_bNiceReset = iValue; m_bNiceReset = iValue;
} }
if ( GetProfileInt("Setup", "HimselfDamage", iValue) ) if ( GetLocalProfileInt("Setup", "HimselfDamage", iValue) )
{ {
m_bHimselfDamage = iValue; m_bHimselfDamage = iValue;
} }
if ( GetProfileInt("Setup", "CameraScroll", iValue) ) if ( GetLocalProfileInt("Setup", "CameraScroll", iValue) )
{ {
m_bCameraScroll = iValue; m_bCameraScroll = iValue;
m_camera->SetCameraScroll(m_bCameraScroll); m_camera->SetCameraScroll(m_bCameraScroll);
} }
if ( GetProfileInt("Setup", "CameraInvertX", iValue) ) if ( GetLocalProfileInt("Setup", "CameraInvertX", iValue) )
{ {
m_bCameraInvertX = iValue; m_bCameraInvertX = iValue;
m_camera->SetCameraInvertX(m_bCameraInvertX); m_camera->SetCameraInvertX(m_bCameraInvertX);
} }
if ( GetProfileInt("Setup", "CameraInvertY", iValue) ) if ( GetLocalProfileInt("Setup", "CameraInvertY", iValue) )
{ {
m_bCameraInvertY = iValue; m_bCameraInvertY = iValue;
m_camera->SetCameraInvertY(m_bCameraInvertY); m_camera->SetCameraInvertY(m_bCameraInvertY);
} }
if ( GetProfileInt("Setup", "InterfaceEffect", iValue) ) if ( GetLocalProfileInt("Setup", "InterfaceEffect", iValue) )
{ {
m_bEffect = iValue; m_bEffect = iValue;
} }
if ( GetProfileInt("Setup", "GroundShadow", iValue) ) if ( GetLocalProfileInt("Setup", "GroundShadow", iValue) )
{ {
m_engine->SetShadow(iValue); m_engine->SetShadow(iValue);
} }
if ( GetProfileInt("Setup", "GroundSpot", iValue) ) if ( GetLocalProfileInt("Setup", "GroundSpot", iValue) )
{ {
m_engine->SetGroundSpot(iValue); m_engine->SetGroundSpot(iValue);
} }
if ( GetProfileInt("Setup", "ObjectDirty", iValue) ) if ( GetLocalProfileInt("Setup", "ObjectDirty", iValue) )
{ {
m_engine->SetDirty(iValue); m_engine->SetDirty(iValue);
} }
if ( GetProfileInt("Setup", "FogMode", iValue) ) if ( GetLocalProfileInt("Setup", "FogMode", iValue) )
{ {
m_engine->SetFog(iValue); m_engine->SetFog(iValue);
m_camera->SetOverBaseColor(RetColor(RetColor(0.0f))); m_camera->SetOverBaseColor(RetColor(RetColor(0.0f)));
} }
if ( GetProfileInt("Setup", "LensMode", iValue) ) if ( GetLocalProfileInt("Setup", "LensMode", iValue) )
{ {
m_engine->SetLensMode(iValue); m_engine->SetLensMode(iValue);
} }
if ( GetProfileInt("Setup", "SkyMode", iValue) ) if ( GetLocalProfileInt("Setup", "SkyMode", iValue) )
{ {
m_engine->SetSkyMode(iValue); m_engine->SetSkyMode(iValue);
} }
if ( GetProfileInt("Setup", "PlanetMode", iValue) ) if ( GetLocalProfileInt("Setup", "PlanetMode", iValue) )
{ {
m_engine->SetPlanetMode(iValue); m_engine->SetPlanetMode(iValue);
} }
if ( GetProfileInt("Setup", "LightMode", iValue) ) if ( GetLocalProfileInt("Setup", "LightMode", iValue) )
{ {
m_engine->SetLightMode(iValue); m_engine->SetLightMode(iValue);
} }
if ( GetProfileInt("Setup", "UseJoystick", iValue) ) if ( GetLocalProfileInt("Setup", "UseJoystick", iValue) )
{ {
m_engine->SetJoystick(iValue); m_engine->SetJoystick(iValue);
} }
if ( GetProfileFloat("Setup", "ParticuleDensity", fValue) ) if ( GetLocalProfileFloat("Setup", "ParticuleDensity", fValue) )
{ {
m_engine->SetParticuleDensity(fValue); m_engine->SetParticuleDensity(fValue);
} }
if ( GetProfileFloat("Setup", "ClippingDistance", fValue) ) if ( GetLocalProfileFloat("Setup", "ClippingDistance", fValue) )
{ {
m_engine->SetClippingDistance(fValue); m_engine->SetClippingDistance(fValue);
} }
if ( GetProfileFloat("Setup", "ObjectDetail", fValue) ) if ( GetLocalProfileFloat("Setup", "ObjectDetail", fValue) )
{ {
m_engine->SetObjectDetail(fValue); m_engine->SetObjectDetail(fValue);
} }
if ( GetProfileFloat("Setup", "GadgetQuantity", fValue) ) if ( GetLocalProfileFloat("Setup", "GadgetQuantity", fValue) )
{ {
m_engine->SetGadgetQuantity(fValue); m_engine->SetGadgetQuantity(fValue);
} }
if ( GetProfileInt("Setup", "TextureQuality", iValue) ) if ( GetLocalProfileInt("Setup", "TextureQuality", iValue) )
{ {
m_engine->SetTextureQuality(iValue); m_engine->SetTextureQuality(iValue);
} }
if ( GetProfileInt("Setup", "AudioVolume", iValue) ) if ( GetLocalProfileInt("Setup", "AudioVolume", iValue) )
{ {
m_sound->SetAudioVolume(iValue); m_sound->SetAudioVolume(iValue);
} }
if ( GetProfileInt("Setup", "MidiVolume", iValue) ) if ( GetLocalProfileInt("Setup", "MidiVolume", iValue) )
{ {
m_sound->SetMidiVolume(iValue); m_sound->SetMidiVolume(iValue);
} }
if ( GetProfileInt("Setup", "EditIndentMode", iValue) ) if ( GetLocalProfileInt("Setup", "EditIndentMode", iValue) )
{ {
m_engine->SetEditIndentMode(iValue); m_engine->SetEditIndentMode(iValue);
} }
if ( GetProfileInt("Setup", "EditIndentValue", iValue) ) if ( GetLocalProfileInt("Setup", "EditIndentValue", iValue) )
{ {
m_engine->SetEditIndentValue(iValue); m_engine->SetEditIndentValue(iValue);
} }
if ( GetProfileString("Setup", "KeyMap", key, 500) ) if ( GetLocalProfileString("Setup", "KeyMap", key, 500) )
{ {
p = key; p = key;
for ( i=0 ; i<100 ; i++ ) for ( i=0 ; i<100 ; i++ )
@ -5866,19 +5866,19 @@ void CMainDialog::SetupRecall()
#if _NET #if _NET
if ( m_accessEnable ) if ( m_accessEnable )
{ {
if ( GetProfileInt("Setup", "AccessMission", iValue) ) if ( GetLocalProfileInt("Setup", "AccessMission", iValue) )
{ {
m_accessMission = iValue; m_accessMission = iValue;
} }
if ( GetProfileInt("Setup", "AccessUser", iValue) ) if ( GetLocalProfileInt("Setup", "AccessUser", iValue) )
{ {
m_accessUser = iValue; m_accessUser = iValue;
} }
} }
#endif #endif
if ( GetProfileInt("Setup", "DeleteGamer", iValue) ) if ( GetLocalProfileInt("Setup", "DeleteGamer", iValue) )
{ {
m_bDeleteGamer = iValue; m_bDeleteGamer = iValue;
} }