Merge dev-common and various fixes to achieve compilation
- merged changes from dev-common - fixed many compilation errors (CBrain, UI, ...) - temporarily commented out some problematic code (e.g. input bindings) - (partially) fixed #include styling - everything compiles except for CRobotMain, CMainDialog and CStudiodev-ui
commit
ad6bc13dc2
|
@ -1,14 +1,12 @@
|
|||
# CBot shared library is built separately
|
||||
add_subdirectory(CBot)
|
||||
<<<<<<< HEAD
|
||||
|
||||
# Tools directory is built separately
|
||||
add_subdirectory(tools)
|
||||
|
||||
# Tests
|
||||
add_subdirectory(graphics/engine/test)
|
||||
=======
|
||||
>>>>>>> dev-ui
|
||||
add_subdirectory(math/test)
|
||||
|
||||
|
||||
# Configure options
|
||||
|
@ -67,12 +65,11 @@ app/main.cpp
|
|||
app/system.cpp
|
||||
common/event.cpp
|
||||
common/image.cpp
|
||||
common/logger.cpp
|
||||
common/iman.cpp
|
||||
# common/metafile.cpp
|
||||
# common/misc.cpp
|
||||
# common/modfile.cpp
|
||||
# common/profile.cpp
|
||||
common/logger.cpp
|
||||
common/metafile.cpp
|
||||
common/misc.cpp
|
||||
common/profile.cpp
|
||||
common/restext.cpp
|
||||
common/restext_strings.c
|
||||
common/stringutils.cpp
|
||||
|
@ -116,8 +113,8 @@ object/auto/autoroot.cpp
|
|||
object/auto/autosafe.cpp
|
||||
object/auto/autostation.cpp
|
||||
object/auto/autotower.cpp
|
||||
# object/brain.cpp
|
||||
# object/mainmovie.cpp
|
||||
object/brain.cpp
|
||||
object/mainmovie.cpp
|
||||
object/motion/motion.cpp
|
||||
object/motion/motionant.cpp
|
||||
object/motion/motionbee.cpp
|
||||
|
@ -154,33 +151,32 @@ physics/physics.cpp
|
|||
script/cbottoken.cpp
|
||||
script/cmdtoken.cpp
|
||||
script/script.cpp
|
||||
# sound/sound.cpp
|
||||
# ui/button.cpp
|
||||
# ui/check.cpp
|
||||
# ui/color.cpp
|
||||
# ui/compass.cpp
|
||||
ui/button.cpp
|
||||
ui/check.cpp
|
||||
ui/color.cpp
|
||||
ui/compass.cpp
|
||||
ui/control.cpp
|
||||
# ui/displayinfo.cpp
|
||||
# ui/displaytext.cpp
|
||||
ui/displayinfo.cpp
|
||||
ui/displaytext.cpp
|
||||
ui/edit.cpp
|
||||
# ui/editvalue.cpp
|
||||
# ui/gauge.cpp
|
||||
# ui/group.cpp
|
||||
# ui/image.cpp
|
||||
# ui/interface.cpp
|
||||
# ui/key.cpp
|
||||
# ui/label.cpp
|
||||
# ui/list.cpp
|
||||
ui/editvalue.cpp
|
||||
ui/gauge.cpp
|
||||
ui/group.cpp
|
||||
ui/image.cpp
|
||||
ui/interface.cpp
|
||||
ui/key.cpp
|
||||
ui/label.cpp
|
||||
ui/list.cpp
|
||||
# ui/maindialog.cpp
|
||||
# ui/mainmap.cpp
|
||||
# ui/mainshort.cpp
|
||||
# ui/map.cpp
|
||||
# ui/scroll.cpp
|
||||
# ui/shortcut.cpp
|
||||
# ui/slider.cpp
|
||||
ui/mainmap.cpp
|
||||
ui/mainshort.cpp
|
||||
ui/map.cpp
|
||||
ui/scroll.cpp
|
||||
ui/shortcut.cpp
|
||||
ui/slider.cpp
|
||||
# ui/studio.cpp
|
||||
# ui/target.cpp
|
||||
# ui/window.cpp
|
||||
ui/target.cpp
|
||||
ui/window.cpp
|
||||
)
|
||||
|
||||
set(LIBS
|
||||
|
@ -194,7 +190,10 @@ ${PLATFORM_LIBS}
|
|||
CBot
|
||||
)
|
||||
|
||||
include_directories(. ${CMAKE_CURRENT_BINARY_DIR}
|
||||
include_directories(
|
||||
.
|
||||
..
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${SDL_INCLUDE_DIR}
|
||||
${SDL_IMAGE_INCLUDE_DIR}
|
||||
${SDLTTF_INCLUDE_DIR}
|
||||
|
|
449
src/app/app.cpp
449
src/app/app.cpp
|
@ -29,10 +29,13 @@
|
|||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <libintl.h>
|
||||
|
||||
|
||||
template<> CApplication* CSingleton<CApplication>::mInstance = NULL;
|
||||
template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
|
||||
|
||||
|
||||
//! Interval of timer called to update joystick state
|
||||
|
@ -62,8 +65,8 @@ struct ApplicationPrivate
|
|||
ApplicationPrivate()
|
||||
{
|
||||
memset(¤tEvent, 0, sizeof(SDL_Event));
|
||||
surface = NULL;
|
||||
joystick = NULL;
|
||||
surface = nullptr;
|
||||
joystick = nullptr;
|
||||
joystickTimer = 0;
|
||||
}
|
||||
};
|
||||
|
@ -76,14 +79,10 @@ CApplication::CApplication()
|
|||
m_iMan = new CInstanceManager();
|
||||
m_eventQueue = new CEventQueue(m_iMan);
|
||||
|
||||
m_engine = NULL;
|
||||
m_device = NULL;
|
||||
m_robotMain = NULL;
|
||||
m_sound = NULL;
|
||||
|
||||
m_keyState = 0;
|
||||
m_axeKey = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_axeJoy = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_engine = nullptr;
|
||||
m_device = nullptr;
|
||||
m_robotMain = nullptr;
|
||||
m_sound = nullptr;
|
||||
|
||||
m_exitCode = 0;
|
||||
m_active = false;
|
||||
|
@ -91,29 +90,64 @@ CApplication::CApplication()
|
|||
|
||||
m_windowTitle = "COLOBOT";
|
||||
|
||||
m_simulationSuspended = false;
|
||||
|
||||
m_simulationSpeed = 1.0f;
|
||||
|
||||
m_realAbsTimeBase = 0LL;
|
||||
m_realAbsTime = 0LL;
|
||||
m_realRelTime = 0LL;
|
||||
|
||||
m_absTimeBase = 0LL;
|
||||
m_exactAbsTime = 0LL;
|
||||
m_exactRelTime = 0LL;
|
||||
|
||||
m_absTime = 0.0f;
|
||||
m_relTime = 0.0f;
|
||||
|
||||
m_baseTimeStamp = CreateTimeStamp();
|
||||
m_curTimeStamp = CreateTimeStamp();
|
||||
m_lastTimeStamp = CreateTimeStamp();
|
||||
|
||||
m_joystickEnabled = false;
|
||||
|
||||
m_kmodState = 0;
|
||||
m_mouseButtonsState = 0;
|
||||
|
||||
for (int i = 0; i < TRKEY_MAX; ++i)
|
||||
m_trackedKeysState[i] = false;
|
||||
|
||||
m_keyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_joyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
|
||||
m_dataPath = "./data";
|
||||
|
||||
ResetKey();
|
||||
m_language = LANG_ENGLISH;
|
||||
|
||||
SetDefaultInputBindings();
|
||||
}
|
||||
|
||||
CApplication::~CApplication()
|
||||
{
|
||||
delete m_private;
|
||||
m_private = NULL;
|
||||
m_private = nullptr;
|
||||
|
||||
delete m_eventQueue;
|
||||
m_eventQueue = NULL;
|
||||
m_eventQueue = nullptr;
|
||||
|
||||
delete m_iMan;
|
||||
m_iMan = NULL;
|
||||
m_iMan = nullptr;
|
||||
|
||||
DestroyTimeStamp(m_baseTimeStamp);
|
||||
DestroyTimeStamp(m_curTimeStamp);
|
||||
DestroyTimeStamp(m_lastTimeStamp);
|
||||
}
|
||||
|
||||
bool CApplication::ParseArguments(int argc, char *argv[])
|
||||
{
|
||||
bool waitDataDir = false;
|
||||
bool waitLogLevel = false;
|
||||
bool waitLanguage = false;
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
|
@ -123,6 +157,7 @@ bool CApplication::ParseArguments(int argc, char *argv[])
|
|||
{
|
||||
waitDataDir = false;
|
||||
m_dataPath = arg;
|
||||
GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -146,6 +181,22 @@ bool CApplication::ParseArguments(int argc, char *argv[])
|
|||
continue;
|
||||
}
|
||||
|
||||
if (waitLanguage)
|
||||
{
|
||||
waitLanguage = false;
|
||||
if (arg == "en")
|
||||
m_language = LANG_ENGLISH;
|
||||
else if (arg == "de")
|
||||
m_language = LANG_GERMAN;
|
||||
else if (arg == "fr")
|
||||
m_language = LANG_FRENCH;
|
||||
else if (arg == "pl")
|
||||
m_language = LANG_POLISH;
|
||||
else
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg == "-debug")
|
||||
{
|
||||
SetDebugMode(true);
|
||||
|
@ -158,6 +209,21 @@ bool CApplication::ParseArguments(int argc, char *argv[])
|
|||
{
|
||||
waitDataDir = true;
|
||||
}
|
||||
else if (arg == "-language")
|
||||
{
|
||||
waitLanguage = true;
|
||||
}
|
||||
else if (arg == "-help")
|
||||
{
|
||||
GetLogger()->Message("COLOBOT\n");
|
||||
GetLogger()->Message("\n");
|
||||
GetLogger()->Message("List of available options:\n");
|
||||
GetLogger()->Message(" -help this help\n");
|
||||
GetLogger()->Message(" -datadir path set custom data directory path\n");
|
||||
GetLogger()->Message(" -debug enable debug mode (more info printed in logs)\n");
|
||||
GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
|
||||
GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_exitCode = 1;
|
||||
|
@ -166,7 +232,7 @@ bool CApplication::ParseArguments(int argc, char *argv[])
|
|||
}
|
||||
|
||||
// Args not given?
|
||||
if (waitDataDir || waitLogLevel)
|
||||
if (waitDataDir || waitLogLevel || waitLanguage)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -176,7 +242,50 @@ bool CApplication::Create()
|
|||
{
|
||||
GetLogger()->Info("Creating CApplication\n");
|
||||
|
||||
// TODO: verify that data directory exists
|
||||
// I know, a primitive way to check for dir, but works
|
||||
std::string readmePath = m_dataPath + "/README.txt";
|
||||
std::ifstream testReadme;
|
||||
testReadme.open(readmePath.c_str(), std::ios_base::in);
|
||||
if (!testReadme.good())
|
||||
{
|
||||
GetLogger()->Error("Could not open test file in data dir: '%s'\n", readmePath.c_str());
|
||||
m_errorMessage = std::string("Could not read from data directory:\n") +
|
||||
std::string("'") + m_dataPath + std::string("'\n") +
|
||||
std::string("Please check your installation, or supply a valid data directory by -datadir option.");
|
||||
m_exitCode = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Gettext initialization */
|
||||
|
||||
std::string locale = "C";
|
||||
switch (m_language)
|
||||
{
|
||||
case LANG_ENGLISH:
|
||||
locale = "en_US.utf8";
|
||||
break;
|
||||
|
||||
case LANG_GERMAN:
|
||||
locale = "de_DE.utf8";
|
||||
break;
|
||||
|
||||
case LANG_FRENCH:
|
||||
locale = "fr_FR.utf8";
|
||||
break;
|
||||
|
||||
case LANG_POLISH:
|
||||
locale = "pl_PL.utf8";
|
||||
break;
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, locale.c_str());
|
||||
|
||||
std::string trPath = m_dataPath + std::string("/i18n");
|
||||
bindtextdomain("colobot", trPath.c_str());
|
||||
bind_textdomain_codeset("colobot", "UTF-8");
|
||||
textdomain("colobot");
|
||||
|
||||
GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!"));
|
||||
|
||||
// Temporarily -- only in windowed mode
|
||||
m_deviceConfig.fullScreen = false;
|
||||
|
@ -218,7 +327,7 @@ bool CApplication::Create()
|
|||
if (! CreateVideoSurface())
|
||||
return false; // dialog is in function
|
||||
|
||||
if (m_private->surface == NULL)
|
||||
if (m_private->surface == nullptr)
|
||||
{
|
||||
m_errorMessage = std::string("SDL error while setting video mode:\n") +
|
||||
std::string(SDL_GetError());
|
||||
|
@ -269,7 +378,7 @@ bool CApplication::Create()
|
|||
bool CApplication::CreateVideoSurface()
|
||||
{
|
||||
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
||||
if (videoInfo == NULL)
|
||||
if (videoInfo == nullptr)
|
||||
{
|
||||
m_errorMessage = std::string("SDL error while getting video info:\n ") +
|
||||
std::string(SDL_GetError());
|
||||
|
@ -321,44 +430,44 @@ bool CApplication::CreateVideoSurface()
|
|||
|
||||
void CApplication::Destroy()
|
||||
{
|
||||
/*if (m_robotMain != NULL)
|
||||
/*if (m_robotMain != nullptr)
|
||||
{
|
||||
delete m_robotMain;
|
||||
m_robotMain = NULL;
|
||||
m_robotMain = nullptr;
|
||||
}
|
||||
|
||||
if (m_sound != NULL)
|
||||
if (m_sound != nullptr)
|
||||
{
|
||||
delete m_sound;
|
||||
m_sound = NULL;
|
||||
m_sound = nullptr;
|
||||
}*/
|
||||
|
||||
if (m_engine != NULL)
|
||||
if (m_engine != nullptr)
|
||||
{
|
||||
m_engine->Destroy();
|
||||
|
||||
delete m_engine;
|
||||
m_engine = NULL;
|
||||
m_engine = nullptr;
|
||||
}
|
||||
|
||||
if (m_device != NULL)
|
||||
if (m_device != nullptr)
|
||||
{
|
||||
m_device->Destroy();
|
||||
|
||||
delete m_device;
|
||||
m_device = NULL;
|
||||
m_device = nullptr;
|
||||
}
|
||||
|
||||
if (m_private->joystick != NULL)
|
||||
if (m_private->joystick != nullptr)
|
||||
{
|
||||
SDL_JoystickClose(m_private->joystick);
|
||||
m_private->joystick = NULL;
|
||||
m_private->joystick = nullptr;
|
||||
}
|
||||
|
||||
if (m_private->surface != NULL)
|
||||
if (m_private->surface != nullptr)
|
||||
{
|
||||
SDL_FreeSurface(m_private->surface);
|
||||
m_private->surface = NULL;
|
||||
m_private->surface = nullptr;
|
||||
}
|
||||
|
||||
IMG_Quit();
|
||||
|
@ -383,7 +492,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (m_private->surface == NULL)
|
||||
if (m_private->surface == nullptr)
|
||||
{
|
||||
if (! restore)
|
||||
{
|
||||
|
@ -426,7 +535,7 @@ bool CApplication::OpenJoystick()
|
|||
return false;
|
||||
|
||||
m_private->joystick = SDL_JoystickOpen(m_joystick.index);
|
||||
if (m_private->joystick == NULL)
|
||||
if (m_private->joystick == nullptr)
|
||||
return false;
|
||||
|
||||
m_joystick.axisCount = SDL_JoystickNumAxes(m_private->joystick);
|
||||
|
@ -437,7 +546,7 @@ bool CApplication::OpenJoystick()
|
|||
m_joyButtonState = std::vector<bool>(m_joystick.buttonCount, false);
|
||||
|
||||
// Create a timer for polling joystick state
|
||||
m_private->joystickTimer = SDL_AddTimer(JOYSTICK_TIMER_INTERVAL, JoystickTimerCallback, NULL);
|
||||
m_private->joystickTimer = SDL_AddTimer(JOYSTICK_TIMER_INTERVAL, JoystickTimerCallback, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -447,7 +556,7 @@ void CApplication::CloseJoystick()
|
|||
// Timer will remove itself automatically
|
||||
|
||||
SDL_JoystickClose(m_private->joystick);
|
||||
m_private->joystick = NULL;
|
||||
m_private->joystick = nullptr;
|
||||
}
|
||||
|
||||
bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
|
||||
|
@ -455,7 +564,7 @@ bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
|
|||
if ( (newJoystick.index < 0) || (newJoystick.index >= SDL_NumJoysticks()) )
|
||||
return false;
|
||||
|
||||
if (m_private->joystick != NULL)
|
||||
if (m_private->joystick != nullptr)
|
||||
CloseJoystick();
|
||||
|
||||
return OpenJoystick();
|
||||
|
@ -464,7 +573,7 @@ bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
|
|||
Uint32 JoystickTimerCallback(Uint32 interval, void *)
|
||||
{
|
||||
CApplication *app = CApplication::GetInstancePointer();
|
||||
if ((app == NULL) || (! app->GetJoystickEnabled()))
|
||||
if ((app == nullptr) || (! app->GetJoystickEnabled()))
|
||||
return 0; // don't run the timer again
|
||||
|
||||
app->UpdateJoystick();
|
||||
|
@ -540,6 +649,10 @@ int CApplication::Run()
|
|||
{
|
||||
m_active = true;
|
||||
|
||||
GetCurrentTimeStamp(m_baseTimeStamp);
|
||||
GetCurrentTimeStamp(m_lastTimeStamp);
|
||||
GetCurrentTimeStamp(m_curTimeStamp);
|
||||
|
||||
while (true)
|
||||
{
|
||||
// To be sure no old event remains
|
||||
|
@ -577,7 +690,7 @@ int CApplication::Run()
|
|||
{
|
||||
bool passOn = ProcessEvent(event);
|
||||
|
||||
if (m_engine != NULL && passOn)
|
||||
if (m_engine != nullptr && passOn)
|
||||
passOn = m_engine->ProcessEvent(event);
|
||||
|
||||
if (passOn)
|
||||
|
@ -602,11 +715,11 @@ int CApplication::Run()
|
|||
{
|
||||
passOn = ProcessEvent(event);
|
||||
|
||||
if (passOn && m_engine != NULL)
|
||||
if (passOn && m_engine != nullptr)
|
||||
passOn = m_engine->ProcessEvent(event);
|
||||
}
|
||||
|
||||
/*if (passOn && m_robotMain != NULL)
|
||||
/*if (passOn && m_robotMain != nullptr)
|
||||
m_robotMain->ProcessEvent(event); */
|
||||
}
|
||||
|
||||
|
@ -616,6 +729,9 @@ int CApplication::Run()
|
|||
|
||||
// Update game and render a frame during idle time (no messages are waiting)
|
||||
Render();
|
||||
|
||||
// Update simulation state
|
||||
StepSimulation();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,9 +850,76 @@ bool CApplication::ProcessEvent(const Event &event)
|
|||
|
||||
if (event.type == EVENT_ACTIVE)
|
||||
{
|
||||
m_active = event.active.gain;
|
||||
if (m_debugMode)
|
||||
l->Info("Focus change: active = %s\n", m_active ? "true" : "false");
|
||||
l->Info("Focus change: active = %s\n", event.active.gain ? "true" : "false");
|
||||
|
||||
if (m_active != event.active.gain)
|
||||
{
|
||||
m_active = event.active.gain;
|
||||
|
||||
if (m_active)
|
||||
ResumeSimulation();
|
||||
else
|
||||
SuspendSimulation();
|
||||
}
|
||||
}
|
||||
else if (event.type == EVENT_KEY_DOWN)
|
||||
{
|
||||
m_kmodState = event.key.mod;
|
||||
|
||||
if ((m_kmodState & KEY_MOD(SHIFT)) != 0)
|
||||
m_trackedKeysState[TRKEY_SHIFT] = true;
|
||||
else if ((m_kmodState & KEY_MOD(CTRL)) != 0)
|
||||
m_trackedKeysState[TRKEY_CONTROL] = true;
|
||||
else if (event.key.key == KEY(KP8))
|
||||
m_trackedKeysState[TRKEY_NUM_UP] = true;
|
||||
else if (event.key.key == KEY(KP2))
|
||||
m_trackedKeysState[TRKEY_NUM_DOWN] = true;
|
||||
else if (event.key.key == KEY(KP4))
|
||||
m_trackedKeysState[TRKEY_NUM_LEFT] = true;
|
||||
else if (event.key.key == KEY(KP6))
|
||||
m_trackedKeysState[TRKEY_NUM_RIGHT] = true;
|
||||
else if (event.key.key == KEY(KP_PLUS))
|
||||
m_trackedKeysState[TRKEY_NUM_PLUS] = true;
|
||||
else if (event.key.key == KEY(KP_MINUS))
|
||||
m_trackedKeysState[TRKEY_NUM_MINUS] = true;
|
||||
else if (event.key.key == KEY(PAGEUP))
|
||||
m_trackedKeysState[TRKEY_PAGE_UP] = true;
|
||||
else if (event.key.key == KEY(PAGEDOWN))
|
||||
m_trackedKeysState[TRKEY_PAGE_DOWN] = true;
|
||||
}
|
||||
else if (event.type == EVENT_KEY_UP)
|
||||
{
|
||||
m_kmodState = event.key.mod;
|
||||
|
||||
if ((m_kmodState & KEY_MOD(SHIFT)) != 0)
|
||||
m_trackedKeysState[TRKEY_SHIFT] = false;
|
||||
else if ((m_kmodState & KEY_MOD(CTRL)) != 0)
|
||||
m_trackedKeysState[TRKEY_CONTROL] = false;
|
||||
else if (event.key.key == KEY(KP8))
|
||||
m_trackedKeysState[TRKEY_NUM_UP] = false;
|
||||
else if (event.key.key == KEY(KP2))
|
||||
m_trackedKeysState[TRKEY_NUM_DOWN] = false;
|
||||
else if (event.key.key == KEY(KP4))
|
||||
m_trackedKeysState[TRKEY_NUM_LEFT] = false;
|
||||
else if (event.key.key == KEY(KP6))
|
||||
m_trackedKeysState[TRKEY_NUM_RIGHT] = false;
|
||||
else if (event.key.key == KEY(KP_PLUS))
|
||||
m_trackedKeysState[TRKEY_NUM_PLUS] = false;
|
||||
else if (event.key.key == KEY(KP_MINUS))
|
||||
m_trackedKeysState[TRKEY_NUM_MINUS] = false;
|
||||
else if (event.key.key == KEY(PAGEUP))
|
||||
m_trackedKeysState[TRKEY_PAGE_UP] = false;
|
||||
else if (event.key.key == KEY(PAGEDOWN))
|
||||
m_trackedKeysState[TRKEY_PAGE_DOWN] = false;
|
||||
}
|
||||
else if (event.type == EVENT_MOUSE_BUTTON_DOWN)
|
||||
{
|
||||
m_mouseButtonsState |= 1 << event.mouseButton.button;
|
||||
}
|
||||
else if (event.type == EVENT_MOUSE_BUTTON_UP)
|
||||
{
|
||||
m_mouseButtonsState &= ~(1 << event.mouseButton.button);
|
||||
}
|
||||
|
||||
// Print the events in debug mode to test the code
|
||||
|
@ -798,9 +981,101 @@ void CApplication::Render()
|
|||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
|
||||
void CApplication::StepSimulation(float rTime)
|
||||
void CApplication::SuspendSimulation()
|
||||
{
|
||||
// TODO
|
||||
m_simulationSuspended = true;
|
||||
GetLogger()->Info("Suspend simulation\n");
|
||||
}
|
||||
|
||||
void CApplication::ResumeSimulation()
|
||||
{
|
||||
m_simulationSuspended = false;
|
||||
|
||||
GetCurrentTimeStamp(m_baseTimeStamp);
|
||||
CopyTimeStamp(m_curTimeStamp, m_baseTimeStamp);
|
||||
m_realAbsTimeBase = m_realAbsTime;
|
||||
m_absTimeBase = m_exactAbsTime;
|
||||
|
||||
GetLogger()->Info("Resume simulation\n");
|
||||
}
|
||||
|
||||
bool CApplication::GetSimulationSuspended()
|
||||
{
|
||||
return m_simulationSuspended;
|
||||
}
|
||||
|
||||
void CApplication::SetSimulationSpeed(float speed)
|
||||
{
|
||||
m_simulationSpeed = speed;
|
||||
|
||||
GetCurrentTimeStamp(m_baseTimeStamp);
|
||||
m_realAbsTimeBase = m_realAbsTime;
|
||||
m_absTimeBase = m_exactAbsTime;
|
||||
|
||||
GetLogger()->Info("Simulation speed = %.2f\n", speed);
|
||||
}
|
||||
|
||||
void CApplication::StepSimulation()
|
||||
{
|
||||
if (m_simulationSuspended)
|
||||
return;
|
||||
|
||||
CopyTimeStamp(m_lastTimeStamp, m_curTimeStamp);
|
||||
GetCurrentTimeStamp(m_curTimeStamp);
|
||||
|
||||
long long absDiff = TimeStampExactDiff(m_baseTimeStamp, m_curTimeStamp);
|
||||
m_realAbsTime = m_realAbsTimeBase + absDiff;
|
||||
// m_baseTimeStamp is updated on simulation speed change, so this is OK
|
||||
m_exactAbsTime = m_absTimeBase + m_simulationSpeed * absDiff;
|
||||
m_absTime = (m_absTimeBase + m_simulationSpeed * absDiff) / 1e9f;
|
||||
|
||||
m_realRelTime = TimeStampExactDiff(m_lastTimeStamp, m_curTimeStamp);
|
||||
m_exactRelTime = m_simulationSpeed * m_realRelTime;
|
||||
m_relTime = (m_simulationSpeed * m_realRelTime) / 1e9f;
|
||||
|
||||
|
||||
m_engine->FrameUpdate();
|
||||
//m_sound->FrameMove(m_relTime);
|
||||
|
||||
|
||||
Event frameEvent(EVENT_FRAME);
|
||||
frameEvent.rTime = m_relTime;
|
||||
m_eventQueue->AddEvent(frameEvent);
|
||||
}
|
||||
|
||||
float CApplication::GetSimulationSpeed()
|
||||
{
|
||||
return m_simulationSpeed;
|
||||
}
|
||||
|
||||
float CApplication::GetAbsTime()
|
||||
{
|
||||
return m_absTime;
|
||||
}
|
||||
|
||||
long long CApplication::GetExactAbsTime()
|
||||
{
|
||||
return m_exactAbsTime;
|
||||
}
|
||||
|
||||
long long CApplication::GetRealAbsTime()
|
||||
{
|
||||
return m_realAbsTime;
|
||||
}
|
||||
|
||||
float CApplication::GetRelTime()
|
||||
{
|
||||
return m_relTime;
|
||||
}
|
||||
|
||||
long long CApplication::GetExactRelTime()
|
||||
{
|
||||
return m_exactRelTime;
|
||||
}
|
||||
|
||||
long long CApplication::GetRealRelTime()
|
||||
{
|
||||
return m_realRelTime;
|
||||
}
|
||||
|
||||
Gfx::GLDeviceConfig CApplication::GetVideoConfig()
|
||||
|
@ -814,7 +1089,7 @@ VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntPoint
|
|||
resolutions.clear();
|
||||
|
||||
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
||||
if (videoInfo == NULL)
|
||||
if (videoInfo == nullptr)
|
||||
return VIDEO_QUERY_ERROR;
|
||||
|
||||
Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
|
||||
|
@ -861,25 +1136,79 @@ bool CApplication::GetDebugMode()
|
|||
return m_debugMode;
|
||||
}
|
||||
|
||||
void CApplication::FlushPressKey()
|
||||
void CApplication::SetDefaultInputBindings()
|
||||
{
|
||||
// TODO
|
||||
for (int i = 0; i < KEYRANK_MAX; i++)
|
||||
m_inputBindings[i].Reset();
|
||||
|
||||
m_inputBindings[KEYRANK_LEFT ].key = KEY(LEFT);
|
||||
m_inputBindings[KEYRANK_RIGHT ].key = KEY(RIGHT);
|
||||
m_inputBindings[KEYRANK_UP ].key = KEY(UP);
|
||||
m_inputBindings[KEYRANK_DOWN ].key = KEY(DOWN);
|
||||
m_inputBindings[KEYRANK_GUP ].kmod = KEY_MOD(SHIFT);
|
||||
m_inputBindings[KEYRANK_GDOWN ].kmod = KEY_MOD(CTRL);
|
||||
m_inputBindings[KEYRANK_CAMERA ].key = KEY(SPACE);
|
||||
m_inputBindings[KEYRANK_CAMERA ].joy = 2;
|
||||
m_inputBindings[KEYRANK_DESEL ].key = KEY(KP0);
|
||||
m_inputBindings[KEYRANK_DESEL ].kmod = 6;
|
||||
m_inputBindings[KEYRANK_ACTION ].key = KEY(RETURN);
|
||||
m_inputBindings[KEYRANK_ACTION ].joy = 1;
|
||||
m_inputBindings[KEYRANK_NEAR ].key = KEY(KP_PLUS);
|
||||
m_inputBindings[KEYRANK_NEAR ].joy = 5;
|
||||
m_inputBindings[KEYRANK_AWAY ].key = KEY(KP_MINUS);
|
||||
m_inputBindings[KEYRANK_AWAY ].joy = 4;
|
||||
m_inputBindings[KEYRANK_NEXT ].key = KEY(TAB);
|
||||
m_inputBindings[KEYRANK_NEXT ].joy = 3;
|
||||
m_inputBindings[KEYRANK_HUMAN ].key = KEY(HOME);
|
||||
m_inputBindings[KEYRANK_HUMAN ].joy = 7;
|
||||
m_inputBindings[KEYRANK_QUIT ].key = KEY(ESCAPE);
|
||||
m_inputBindings[KEYRANK_HELP ].key = KEY(F1);
|
||||
m_inputBindings[KEYRANK_PROG ].key = KEY(F2);
|
||||
m_inputBindings[KEYRANK_CBOT ].key = KEY(F3);
|
||||
m_inputBindings[KEYRANK_VISIT ].key = KEY(KP_PERIOD);
|
||||
m_inputBindings[KEYRANK_SPEED10].key = KEY(F4);
|
||||
m_inputBindings[KEYRANK_SPEED15].key = KEY(F5);
|
||||
m_inputBindings[KEYRANK_SPEED20].key = KEY(F6);
|
||||
}
|
||||
|
||||
void CApplication::ResetKey()
|
||||
int CApplication::GetKmods()
|
||||
{
|
||||
// TODO
|
||||
return m_kmodState;
|
||||
}
|
||||
|
||||
void CApplication::SetKey(int keyRank, int option, int key)
|
||||
bool CApplication::GetKmodState(int kmod)
|
||||
{
|
||||
// TODO
|
||||
return (m_kmodState & kmod) != 0;
|
||||
}
|
||||
|
||||
int CApplication::GetKey(int keyRank, int option)
|
||||
bool CApplication::GetTrackedKeyState(TrackedKey key)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
return m_trackedKeysState[key];
|
||||
}
|
||||
|
||||
bool CApplication::GetMouseButtonState(int index)
|
||||
{
|
||||
return (m_mouseButtonsState & (1<<index)) != 0;
|
||||
}
|
||||
|
||||
void CApplication::ResetKeyStates()
|
||||
{
|
||||
for (int i = 0; i < TRKEY_MAX; ++i)
|
||||
m_trackedKeysState[i] = false;
|
||||
|
||||
m_kmodState = 0;
|
||||
m_keyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_joyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
void CApplication::SetInputBinding(InputSlot slot, const InputBinding& binding)
|
||||
{
|
||||
m_inputBindings[slot] = binding;
|
||||
}
|
||||
|
||||
const InputBinding& CApplication::GetInputBinding(InputSlot slot)
|
||||
{
|
||||
return m_inputBindings[slot];
|
||||
}
|
||||
|
||||
void CApplication::SetGrabInput(bool grab)
|
||||
|
@ -964,3 +1293,13 @@ std::string CApplication::GetDataFilePath(const std::string& dirName, const std:
|
|||
{
|
||||
return m_dataPath + "/" + dirName + "/" + fileName;
|
||||
}
|
||||
|
||||
Language CApplication::GetLanguage()
|
||||
{
|
||||
return m_language;
|
||||
}
|
||||
|
||||
void CApplication::SetLanguage(Language language)
|
||||
{
|
||||
m_language = language;
|
||||
}
|
||||
|
|
228
src/app/app.h
228
src/app/app.h
|
@ -22,8 +22,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/global.h"
|
||||
#include "common/singleton.h"
|
||||
#include "graphics/core/device.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
|
@ -39,8 +38,9 @@ class CRobotMain;
|
|||
class CSound;
|
||||
|
||||
/**
|
||||
\struct JoystickDevice
|
||||
\brief Information about a joystick device */
|
||||
* \struct JoystickDevice
|
||||
* \brief Information about a joystick device
|
||||
*/
|
||||
struct JoystickDevice
|
||||
{
|
||||
//! Device index (-1 = invalid device)
|
||||
|
@ -57,8 +57,9 @@ struct JoystickDevice
|
|||
};
|
||||
|
||||
/**
|
||||
\enum VideoQueryResult
|
||||
\brief Result of querying for available video resolutions */
|
||||
* \enum VideoQueryResult
|
||||
* \brief Result of querying for available video resolutions
|
||||
*/
|
||||
enum VideoQueryResult
|
||||
{
|
||||
VIDEO_QUERY_ERROR,
|
||||
|
@ -68,6 +69,83 @@ enum VideoQueryResult
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* \enum TrackedKeys
|
||||
* \brief Keys (or kmods) whose state (pressed/released) is tracked by CApplication
|
||||
*/
|
||||
enum TrackedKey
|
||||
{
|
||||
TRKEY_SHIFT,
|
||||
TRKEY_CONTROL,
|
||||
TRKEY_NUM_UP,
|
||||
TRKEY_NUM_DOWN,
|
||||
TRKEY_NUM_LEFT,
|
||||
TRKEY_NUM_RIGHT,
|
||||
TRKEY_NUM_PLUS,
|
||||
TRKEY_NUM_MINUS,
|
||||
TRKEY_PAGE_UP,
|
||||
TRKEY_PAGE_DOWN,
|
||||
TRKEY_MAX
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum InputSlot
|
||||
* \brief Available slots for input bindings
|
||||
*/
|
||||
enum InputSlot
|
||||
{
|
||||
INPUT_SLOT_LEFT = 0,
|
||||
INPUT_SLOT_RIGHT = 1,
|
||||
INPUT_SLOT_UP = 2,
|
||||
INPUT_SLOT_DOWN = 3,
|
||||
INPUT_SLOT_GUP = 4,
|
||||
INPUT_SLOT_GDOWN = 5,
|
||||
INPUT_SLOT_CAMERA = 6,
|
||||
INPUT_SLOT_DESEL = 7,
|
||||
INPUT_SLOT_ACTION = 8,
|
||||
INPUT_SLOT_NEAR = 9,
|
||||
INPUT_SLOT_AWAY = 10,
|
||||
INPUT_SLOT_NEXT = 11,
|
||||
INPUT_SLOT_HUMAN = 12,
|
||||
INPUT_SLOT_QUIT = 13,
|
||||
INPUT_SLOT_HELP = 14,
|
||||
INPUT_SLOT_PROG = 15,
|
||||
INPUT_SLOT_VISIT = 16,
|
||||
INPUT_SLOT_SPEED10 = 17,
|
||||
INPUT_SLOT_SPEED15 = 18,
|
||||
INPUT_SLOT_SPEED20 = 19,
|
||||
INPUT_SLOT_SPEED30 = 20,
|
||||
INPUT_SLOT_AIMUP = 21,
|
||||
INPUT_SLOT_AIMDOWN = 22,
|
||||
INPUT_SLOT_CBOT = 23,
|
||||
|
||||
INPUT_SLOT_MAX
|
||||
};
|
||||
|
||||
/**
|
||||
* \struct InputBinding
|
||||
* \brief Settable binding for user input
|
||||
*/
|
||||
struct InputBinding
|
||||
{
|
||||
//! Key
|
||||
int key;
|
||||
//! Key modifier (e.g. shift, control)
|
||||
int kmod;
|
||||
//! Joystick button
|
||||
int joy;
|
||||
|
||||
inline InputBinding()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
inline void Reset()
|
||||
{
|
||||
key = kmod = joy = -1;
|
||||
}
|
||||
};
|
||||
|
||||
struct ApplicationPrivate;
|
||||
|
||||
/**
|
||||
|
@ -147,8 +225,37 @@ public:
|
|||
//! Change the video mode to given mode
|
||||
bool ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig);
|
||||
|
||||
//! Suspends animation (time will not be updated)
|
||||
void SuspendSimulation();
|
||||
//! Resumes animation
|
||||
void ResumeSimulation();
|
||||
//! Returns whether simulation is suspended
|
||||
bool GetSimulationSuspended();
|
||||
|
||||
//! Updates the simulation state
|
||||
void StepSimulation(float rTime);
|
||||
void StepSimulation();
|
||||
|
||||
//@{
|
||||
//! Management of simulation speed
|
||||
void SetSimulationSpeed(float speed);
|
||||
float GetSimulationSpeed();
|
||||
//@}
|
||||
|
||||
//! Returns the absolute time counter [seconds]
|
||||
float GetAbsTime();
|
||||
//! Returns the exact absolute time counter [nanoseconds]
|
||||
long long GetExactAbsTime();
|
||||
|
||||
//! Returns the exact absolute time counter disregarding speed setting [nanoseconds]
|
||||
long long GetRealAbsTime();
|
||||
|
||||
//! Returns the relative time since last update [seconds]
|
||||
float GetRelTime();
|
||||
//! Returns the exact realative time since last update [nanoseconds]
|
||||
long long GetExactRelTime();
|
||||
|
||||
//! Returns the exact relative time since last update disregarding speed setting [nanoseconds]
|
||||
long long GetRealRelTime();
|
||||
|
||||
//! Returns a list of available joystick devices
|
||||
std::vector<JoystickDevice> GetJoystickList();
|
||||
|
@ -159,10 +266,11 @@ public:
|
|||
//! Change the current joystick device
|
||||
bool ChangeJoystick(const JoystickDevice &newJoystick);
|
||||
|
||||
//! Enables/disables joystick
|
||||
//! Management of joystick enable state
|
||||
//@{
|
||||
void SetJoystickEnabled(bool enable);
|
||||
//! Returns whether joystick is enabled
|
||||
bool GetJoystickEnabled();
|
||||
//@}
|
||||
|
||||
//! Polls the state of joystick axes and buttons
|
||||
void UpdateJoystick();
|
||||
|
@ -170,34 +278,66 @@ public:
|
|||
//! Updates the mouse position explicitly
|
||||
void UpdateMouse();
|
||||
|
||||
void FlushPressKey();
|
||||
void ResetKey();
|
||||
void SetKey(int keyRank, int option, int key);
|
||||
int GetKey(int keyRank, int option);
|
||||
//! Returns the current key modifiers
|
||||
int GetKmods();
|
||||
//! Returns whether the given kmod is active
|
||||
bool GetKmodState(int kmod);
|
||||
|
||||
//! Sets the grab mode for input (keyboard & mouse)
|
||||
//! Returns whether the tracked key is pressed
|
||||
bool GetTrackedKeyState(TrackedKey key);
|
||||
|
||||
//! Returns whether the mouse button is pressed
|
||||
bool GetMouseButtonState(int index);
|
||||
|
||||
//! Resets tracked key states, modifiers and motion vectors
|
||||
void ResetKeyStates();
|
||||
|
||||
|
||||
// TODO move input binding and motion vectors to CRobotMain
|
||||
|
||||
//! Sets the default input bindings
|
||||
void SetDefaultInputBindings();
|
||||
|
||||
//! Management of input bindings
|
||||
//@{
|
||||
void SetInputBinding(InputSlot slot, const InputBinding& binding);
|
||||
const InputBinding& GetInputBinding(InputSlot slot);
|
||||
//@}
|
||||
|
||||
|
||||
//! Management of the grab mode for input (keyboard & mouse)
|
||||
//@{
|
||||
void SetGrabInput(bool grab);
|
||||
//! Returns the grab mode
|
||||
bool GetGrabInput();
|
||||
//@}
|
||||
|
||||
//! Sets the visiblity of system mouse cursor
|
||||
//! Management of the visiblity of system mouse cursor
|
||||
//@{
|
||||
void SetSystemMouseVisible(bool visible);
|
||||
//! Returns the visiblity of system mouse cursor
|
||||
bool GetSystemMouseVisibile();
|
||||
//@}
|
||||
|
||||
//! Sets the position of system mouse cursor (in interface coords)
|
||||
//! Management of the position of system mouse cursor (in interface coords)
|
||||
//@{
|
||||
void SetSystemMousePos(Math::Point pos);
|
||||
//! Returns the position of system mouse cursor (in interface coords)
|
||||
Math::Point GetSystemMousePos();
|
||||
//@}
|
||||
|
||||
//! Enables/disables debug mode (prints more info in logger)
|
||||
//! Management of debug mode (prints more info in logger)
|
||||
//@{
|
||||
void SetDebugMode(bool mode);
|
||||
//! Returns whether debug mode is enabled
|
||||
bool GetDebugMode();
|
||||
//@}
|
||||
|
||||
//! Returns the full path to a file in data directory
|
||||
std::string GetDataFilePath(const std::string &dirName, const std::string &fileName);
|
||||
|
||||
//! Management of language
|
||||
//@{
|
||||
Language GetLanguage();
|
||||
void SetLanguage(Language language);
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! Creates the window's SDL_Surface
|
||||
bool CreateVideoSurface();
|
||||
|
@ -248,13 +388,44 @@ protected:
|
|||
//! Text set as window title
|
||||
std::string m_windowTitle;
|
||||
|
||||
int m_keyState;
|
||||
Math::Vector m_axeKey;
|
||||
Math::Vector m_axeJoy;
|
||||
Math::Point m_systemMousePos;
|
||||
long m_mouseWheel;
|
||||
//! Animation time stamps, etc.
|
||||
//@{
|
||||
SystemTimeStamp* m_baseTimeStamp;
|
||||
SystemTimeStamp* m_lastTimeStamp;
|
||||
SystemTimeStamp* m_curTimeStamp;
|
||||
|
||||
long m_key[50][2];
|
||||
long long m_realAbsTimeBase;
|
||||
long long m_realAbsTime;
|
||||
long long m_realRelTime;
|
||||
|
||||
long long m_absTimeBase;
|
||||
long long m_exactAbsTime;
|
||||
long long m_exactRelTime;
|
||||
|
||||
float m_absTime;
|
||||
float m_relTime;
|
||||
|
||||
float m_simulationSpeed;
|
||||
bool m_simulationSuspended;
|
||||
//@}
|
||||
|
||||
//! Current state of key modifiers (mask of SDLMod)
|
||||
unsigned int m_kmodState;
|
||||
//! Current state of some tracked keys (mask of TrackedKey)
|
||||
bool m_trackedKeysState[TRKEY_MAX];
|
||||
//! Current state of mouse buttons (mask of button indexes)
|
||||
unsigned int m_mouseButtonsState;
|
||||
|
||||
//! Bindings for user inputs
|
||||
InputBinding m_inputBindings[INPUT_SLOT_MAX];
|
||||
|
||||
//! Motion vector set by keyboard
|
||||
Math::Vector m_keyMotion;
|
||||
//! Motion vector set by joystick
|
||||
Math::Vector m_joyMotion;
|
||||
|
||||
//! Current system mouse position
|
||||
Math::Point m_systemMousePos;
|
||||
|
||||
//! Info about current joystick device
|
||||
JoystickDevice m_joystick;
|
||||
|
@ -267,5 +438,8 @@ protected:
|
|||
|
||||
//! Path to directory with data files
|
||||
std::string m_dataPath;
|
||||
|
||||
//! Application language
|
||||
Language m_language;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
// TODO: move to global.h after restext rewrite
|
||||
|
||||
#pragma once
|
||||
|
||||
enum Error
|
||||
|
@ -23,8 +26,6 @@ enum Error
|
|||
ERR_CONTINUE = 2, // continues
|
||||
ERR_STOP = 3, // stops
|
||||
ERR_CMD = 4, // unknown command
|
||||
ERR_INSTALL = 20, // incorrectly installed program
|
||||
ERR_NOCD = 21, // CD not found
|
||||
ERR_MANIP_VEH = 100, // inappropriate vehicle
|
||||
ERR_MANIP_FLY = 101, // impossible in flight
|
||||
ERR_MANIP_BUSY = 102, // taking: hands already occupied
|
||||
|
|
|
@ -19,6 +19,16 @@
|
|||
#include "common/event.h"
|
||||
#include "common/iman.h"
|
||||
|
||||
static EventType g_uniqueEventType = EVENT_USER;
|
||||
|
||||
|
||||
EventType GetUniqueEventType()
|
||||
{
|
||||
int i = (int)g_uniqueEventType+1;
|
||||
g_uniqueEventType = (EventType)i;
|
||||
return g_uniqueEventType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CEventQueue::CEventQueue(CInstanceManager* iMan)
|
||||
|
|
|
@ -14,17 +14,17 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// event.h
|
||||
/**
|
||||
* \file common/event.h
|
||||
* \brief Event types, structs and event queue
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <common/key.h>
|
||||
#include <common/event_ids.h>
|
||||
#include <math/point.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "common/key.h"
|
||||
#include "common/event_ids.h"
|
||||
#include "math/point.h"
|
||||
|
||||
class CInstanceManager;
|
||||
|
||||
|
@ -171,13 +171,19 @@ struct Event
|
|||
ActiveEventData active;
|
||||
};
|
||||
|
||||
// TODO: refactor/rewrite
|
||||
// TODO: remove
|
||||
long param; // parameter
|
||||
|
||||
// TODO: remove?
|
||||
Math::Point pos; // mouse position (0 .. 1)
|
||||
|
||||
// TODO: ?
|
||||
float axeX; // control the X axis (-1 .. 1)
|
||||
float axeY; // control of the Y axis (-1 .. 1)
|
||||
float axeZ; // control the Z axis (-1 .. 1)
|
||||
short keyState; // state of the keyboard (KS_ *)
|
||||
|
||||
// TODO: remove in longer term (use CApplication's new time functions instead)
|
||||
float rTime; // relative time
|
||||
|
||||
Event(EventType aType = EVENT_NULL)
|
||||
|
@ -193,40 +199,8 @@ struct Event
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
\enum KeyRank
|
||||
\brief Slots for key assignment of user controls
|
||||
*/
|
||||
|
||||
// TODO: move to global.h ?
|
||||
|
||||
enum KeyRank
|
||||
{
|
||||
KEYRANK_LEFT = 0,
|
||||
KEYRANK_RIGHT = 1,
|
||||
KEYRANK_UP = 2,
|
||||
KEYRANK_DOWN = 3,
|
||||
KEYRANK_GUP = 4,
|
||||
KEYRANK_GDOWN = 5,
|
||||
KEYRANK_CAMERA = 6,
|
||||
KEYRANK_DESEL = 7,
|
||||
KEYRANK_ACTION = 8,
|
||||
KEYRANK_NEAR = 9,
|
||||
KEYRANK_AWAY = 10,
|
||||
KEYRANK_NEXT = 11,
|
||||
KEYRANK_HUMAN = 12,
|
||||
KEYRANK_QUIT = 13,
|
||||
KEYRANK_HELP = 14,
|
||||
KEYRANK_PROG = 15,
|
||||
KEYRANK_VISIT = 16,
|
||||
KEYRANK_SPEED10 = 17,
|
||||
KEYRANK_SPEED15 = 18,
|
||||
KEYRANK_SPEED20 = 19,
|
||||
KEYRANK_SPEED30 = 20,
|
||||
KEYRANK_AIMUP = 21,
|
||||
KEYRANK_AIMDOWN = 22,
|
||||
KEYRANK_CBOT = 23,
|
||||
};
|
||||
//! Returns an unique event type (above the standard IDs)
|
||||
EventType GetUniqueEventType();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -261,5 +235,3 @@ protected:
|
|||
int m_tail;
|
||||
int m_total;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
// TODO: move to event.h after restext rewrite
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,53 +14,111 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// global.h
|
||||
/**
|
||||
* \file common/global.h
|
||||
* \brief Some common, global definitions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "error_ids.h"
|
||||
|
||||
/**
|
||||
* \enum Language
|
||||
* \brief Application language
|
||||
*/
|
||||
enum Language
|
||||
{
|
||||
LANG_ENGLISH = 0,
|
||||
LANG_FRENCH = 1,
|
||||
LANG_GERMAN = 2,
|
||||
LANG_POLISH = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum BuildType
|
||||
* \brief Construction actions (buildings, etc.) available to user
|
||||
*
|
||||
* TODO: refactor
|
||||
*/
|
||||
enum BuildType
|
||||
{
|
||||
BUILD_FACTORY = (1<<0), // factory
|
||||
BUILD_DERRICK = (1<<1), // derrick
|
||||
BUILD_CONVERT = (1<<2), // converter
|
||||
BUILD_RADAR = (1<<3), // radar
|
||||
BUILD_ENERGY = (1<<4), // factory of cells
|
||||
BUILD_NUCLEAR = (1<<5), // nuclear power plant
|
||||
BUILD_STATION = (1<<6), // base station
|
||||
BUILD_REPAIR = (1<<7), // repair center
|
||||
BUILD_TOWER = (1<<8), // defense tower
|
||||
BUILD_RESEARCH = (1<<9), // research center
|
||||
BUILD_LABO = (1<<10), // laboratory
|
||||
BUILD_PARA = (1<<11), // lightning protection
|
||||
BUILD_INFO = (1<<12), // information terminal
|
||||
BUILD_GFLAT = (1<<16), // flat floor
|
||||
BUILD_FLAG = (1<<17) // puts / removes colored flag
|
||||
BUILD_FACTORY = (1<<0), //! < factory
|
||||
BUILD_DERRICK = (1<<1), //! < derrick
|
||||
BUILD_CONVERT = (1<<2), //! < converter
|
||||
BUILD_RADAR = (1<<3), //! < radar
|
||||
BUILD_ENERGY = (1<<4), //! < factory of cells
|
||||
BUILD_NUCLEAR = (1<<5), //! < nuclear power plant
|
||||
BUILD_STATION = (1<<6), //! < base station
|
||||
BUILD_REPAIR = (1<<7), //! < repair center
|
||||
BUILD_TOWER = (1<<8), //! < defense tower
|
||||
BUILD_RESEARCH = (1<<9), //! < research center
|
||||
BUILD_LABO = (1<<10), //! < laboratory
|
||||
BUILD_PARA = (1<<11), //! < lightning protection
|
||||
BUILD_INFO = (1<<12), //! < information terminal
|
||||
BUILD_GFLAT = (1<<16), //! < flat floor
|
||||
BUILD_FLAG = (1<<17) //! < puts / removes colored flag
|
||||
};
|
||||
|
||||
|
||||
// Do not change values was because of backups (bits = ...).
|
||||
/**
|
||||
* \enum ResearchType
|
||||
* \brief Research actions available to user
|
||||
*/
|
||||
enum ResearchType
|
||||
{
|
||||
RESEARCH_TANK = (1<<0), // caterpillars
|
||||
RESEARCH_FLY = (1<<1), // wings
|
||||
RESEARCH_CANON = (1<<2), // cannon
|
||||
RESEARCH_TOWER = (1<<3), // defense tower
|
||||
RESEARCH_ATOMIC = (1<<4), // nuclear
|
||||
RESEARCH_THUMP = (1<<5), // thumper
|
||||
RESEARCH_SHIELD = (1<<6), // shield
|
||||
RESEARCH_PHAZER = (1<<7), // phazer gun
|
||||
RESEARCH_iPAW = (1<<8), // legs of insects
|
||||
RESEARCH_iGUN = (1<<9), // cannon of insects
|
||||
RESEARCH_RECYCLER = (1<<10), // recycler
|
||||
RESEARCH_SUBM = (1<<11), // submarine
|
||||
RESEARCH_SNIFFER = (1<<12) // sniffer
|
||||
RESEARCH_TANK = (1<<0), //! < caterpillars
|
||||
RESEARCH_FLY = (1<<1), //! < wings
|
||||
RESEARCH_CANON = (1<<2), //! < cannon
|
||||
RESEARCH_TOWER = (1<<3), //! < defense tower
|
||||
RESEARCH_ATOMIC = (1<<4), //! < nuclear
|
||||
RESEARCH_THUMP = (1<<5), //! < thumper
|
||||
RESEARCH_SHIELD = (1<<6), //! < shield
|
||||
RESEARCH_PHAZER = (1<<7), //! < phazer gun
|
||||
RESEARCH_iPAW = (1<<8), //! < legs of insects
|
||||
RESEARCH_iGUN = (1<<9), //! < cannon of insects
|
||||
RESEARCH_RECYCLER = (1<<10), //! < recycler
|
||||
RESEARCH_SUBM = (1<<11), //! < submarine
|
||||
RESEARCH_SNIFFER = (1<<12) //! < sniffer
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum KeyRank
|
||||
* \brief Slots for key assignment of user controls
|
||||
*/
|
||||
// TODO: remove (use the new InputSlot enum from app/app.h)
|
||||
enum KeyRank
|
||||
{
|
||||
KEYRANK_LEFT = 0,
|
||||
KEYRANK_RIGHT = 1,
|
||||
KEYRANK_UP = 2,
|
||||
KEYRANK_DOWN = 3,
|
||||
KEYRANK_GUP = 4,
|
||||
KEYRANK_GDOWN = 5,
|
||||
KEYRANK_CAMERA = 6,
|
||||
KEYRANK_DESEL = 7,
|
||||
KEYRANK_ACTION = 8,
|
||||
KEYRANK_NEAR = 9,
|
||||
KEYRANK_AWAY = 10,
|
||||
KEYRANK_NEXT = 11,
|
||||
KEYRANK_HUMAN = 12,
|
||||
KEYRANK_QUIT = 13,
|
||||
KEYRANK_HELP = 14,
|
||||
KEYRANK_PROG = 15,
|
||||
KEYRANK_VISIT = 16,
|
||||
KEYRANK_SPEED10 = 17,
|
||||
KEYRANK_SPEED15 = 18,
|
||||
KEYRANK_SPEED20 = 19,
|
||||
KEYRANK_SPEED30 = 20,
|
||||
KEYRANK_AIMUP = 21,
|
||||
KEYRANK_AIMDOWN = 22,
|
||||
KEYRANK_CBOT = 23,
|
||||
|
||||
KEYRANK_MAX
|
||||
};
|
||||
|
||||
// TODO: move to CRobotMain
|
||||
extern long g_id; // unique identifier
|
||||
extern long g_build; // constructible buildings
|
||||
extern long g_researchDone; // research done
|
||||
extern long g_researchEnable; // research available
|
||||
extern float g_unit; // conversion factor
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#include <png.h>
|
||||
|
@ -88,21 +90,21 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf)
|
|||
|
||||
/* Opening output file */
|
||||
fp = fopen(filename, "wb");
|
||||
if (fp == NULL)
|
||||
if (fp == nullptr)
|
||||
{
|
||||
PNG_ERROR = std::string("Could not open file '") + std::string(filename) + std::string("' for saving");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Initializing png structures and callbacks */
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNGUserError, NULL);
|
||||
if (png_ptr == NULL)
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, PNGUserError, nullptr);
|
||||
if (png_ptr == nullptr)
|
||||
return false;
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
if (info_ptr == nullptr)
|
||||
{
|
||||
png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
|
||||
png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
|
||||
PNG_ERROR = "png_create_info_struct() error!";
|
||||
return false;
|
||||
}
|
||||
|
@ -142,7 +144,7 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf)
|
|||
|
||||
CImage::CImage()
|
||||
{
|
||||
m_data = NULL;
|
||||
m_data = nullptr;
|
||||
}
|
||||
|
||||
CImage::~CImage()
|
||||
|
@ -150,22 +152,22 @@ CImage::~CImage()
|
|||
Free();
|
||||
}
|
||||
|
||||
bool CImage::IsEmpty()
|
||||
bool CImage::IsEmpty() const
|
||||
{
|
||||
return m_data == NULL;
|
||||
return m_data == nullptr;
|
||||
}
|
||||
|
||||
void CImage::Free()
|
||||
{
|
||||
if (m_data != NULL)
|
||||
if (m_data != nullptr)
|
||||
{
|
||||
if (m_data->surface != NULL)
|
||||
if (m_data->surface != nullptr)
|
||||
{
|
||||
SDL_FreeSurface(m_data->surface);
|
||||
m_data->surface = NULL;
|
||||
m_data->surface = nullptr;
|
||||
}
|
||||
delete m_data;
|
||||
m_data = NULL;
|
||||
m_data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,6 +176,118 @@ ImageData* CImage::GetData()
|
|||
return m_data;
|
||||
}
|
||||
|
||||
Math::IntPoint CImage::GetSize() const
|
||||
{
|
||||
if (m_data == nullptr)
|
||||
return Math::IntPoint();
|
||||
|
||||
return Math::IntPoint(m_data->surface->w, m_data->surface->h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Image must be valid and pixel coords in valid range.
|
||||
*
|
||||
* \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
|
||||
* \returns color
|
||||
*/
|
||||
Gfx::Color CImage::GetPixel(Math::IntPoint pixel)
|
||||
{
|
||||
assert(m_data != nullptr);
|
||||
assert(pixel.x >= 0 || pixel.x <= m_data->surface->w);
|
||||
assert(pixel.y >= 0 || pixel.y <= m_data->surface->h);
|
||||
|
||||
int bpp = m_data->surface->format->BytesPerPixel;
|
||||
int index = pixel.y * m_data->surface->pitch + pixel.x * bpp;
|
||||
Uint8* p = &static_cast<Uint8*>(m_data->surface->pixels)[index];
|
||||
|
||||
Uint32 u = 0;
|
||||
switch (bpp)
|
||||
{
|
||||
case 1:
|
||||
u = *p;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
u = *reinterpret_cast<Uint16*>(p);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
u = (p[0] << 16) | (p[1] << 8) | p[2];
|
||||
else
|
||||
u = p[0] | (p[1] << 8) | (p[2] << 16);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
u = *reinterpret_cast<Uint32*>(p);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
||||
Uint8 r = 0, g = 0, b = 0, a = 0;
|
||||
SDL_GetRGBA(u, m_data->surface->format, &r, &g, &b, &a);
|
||||
|
||||
return Gfx::Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Image must be valid and pixel coords in valid range.
|
||||
*
|
||||
* \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
|
||||
* \param color color
|
||||
*/
|
||||
void CImage::SetPixel(Math::IntPoint pixel, Gfx::Color color)
|
||||
{
|
||||
assert(m_data != nullptr);
|
||||
assert(pixel.x >= 0 || pixel.x <= m_data->surface->w);
|
||||
assert(pixel.y >= 0 || pixel.y <= m_data->surface->h);
|
||||
|
||||
int bpp = m_data->surface->format->BytesPerPixel;
|
||||
int index = pixel.y * m_data->surface->pitch + pixel.x * bpp;
|
||||
Uint8* p = &static_cast<Uint8*>(m_data->surface->pixels)[index];
|
||||
|
||||
Uint8 r = static_cast<Uint8>(color.r * 255.0f);
|
||||
Uint8 g = static_cast<Uint8>(color.g * 255.0f);
|
||||
Uint8 b = static_cast<Uint8>(color.b * 255.0f);
|
||||
Uint8 a = static_cast<Uint8>(color.a * 255.0f);
|
||||
Uint32 u = SDL_MapRGBA(m_data->surface->format, r, g, b, a);
|
||||
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
*p = u;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*reinterpret_cast<Uint16*>(p) = u;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
p[0] = (u >> 16) & 0xFF;
|
||||
p[1] = (u >> 8) & 0xFF;
|
||||
p[2] = u & 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = u & 0xFF;
|
||||
p[1] = (u >> 8) & 0xFF;
|
||||
p[2] = (u >> 16) & 0xFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*reinterpret_cast<Uint32*>(p) = u;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CImage::GetError()
|
||||
{
|
||||
return m_error;
|
||||
|
@ -189,10 +303,10 @@ bool CImage::Load(const std::string& fileName)
|
|||
m_error = "";
|
||||
|
||||
m_data->surface = IMG_Load(fileName.c_str());
|
||||
if (m_data->surface == NULL)
|
||||
if (m_data->surface == nullptr)
|
||||
{
|
||||
delete m_data;
|
||||
m_data = NULL;
|
||||
m_data = nullptr;
|
||||
|
||||
m_error = std::string(IMG_GetError());
|
||||
return false;
|
||||
|
|
|
@ -14,10 +14,15 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// image.h
|
||||
/**
|
||||
* \file common/image.h
|
||||
* \brief Class for loading and saving images
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "graphics/core/color.h"
|
||||
#include "math/intpoint.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string>
|
||||
|
@ -61,12 +66,21 @@ public:
|
|||
//! Frees the allocated image data
|
||||
void Free();
|
||||
|
||||
//! Returns whether the image is empty (has NULL data)
|
||||
bool IsEmpty();
|
||||
//! Returns whether the image is empty (has null data)
|
||||
bool IsEmpty() const;
|
||||
|
||||
//! Returns the image data; if empty - returns NULL
|
||||
//! Returns the image data; if empty - returns nullptr
|
||||
ImageData* GetData();
|
||||
|
||||
//! Returns the image size
|
||||
Math::IntPoint GetSize() const;
|
||||
|
||||
//! Sets the color at given pixel
|
||||
void SetPixel(Math::IntPoint pixel, Gfx::Color color);
|
||||
|
||||
//! Returns the color at given pixel
|
||||
Gfx::Color GetPixel(Math::IntPoint pixel);
|
||||
|
||||
//! Loads an image from the specified file
|
||||
bool Load(const std::string &fileName);
|
||||
|
||||
|
|
|
@ -16,12 +16,10 @@
|
|||
|
||||
// iman.cpp
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common/struct.h"
|
||||
#include "common/iman.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
template<> CInstanceManager* CSingleton<CInstanceManager>::mInstance = nullptr;
|
||||
|
||||
|
@ -39,139 +37,91 @@ CInstanceManager* CInstanceManager::GetInstancePointer()
|
|||
return mInstance;
|
||||
}
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
||||
CInstanceManager::CInstanceManager()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0 ; i<CLASS_MAX ; i++ )
|
||||
for (int i = 0; i < CLASS_MAX; i++)
|
||||
{
|
||||
m_table[i].totalPossible = 0;
|
||||
m_table[i].totalUsed = 0;
|
||||
m_table[i].classPointer = 0;
|
||||
m_table[i].maxCount = 0;
|
||||
m_table[i].usedCount = 0;
|
||||
m_table[i].instances = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Object's destructor.
|
||||
|
||||
CInstanceManager::~CInstanceManager()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0 ; i<CLASS_MAX ; i++ )
|
||||
{
|
||||
if ( m_table[i].classPointer != 0 )
|
||||
{
|
||||
free(m_table[i].classPointer);
|
||||
}
|
||||
}
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
||||
// Empty the list of all classes.
|
||||
|
||||
void CInstanceManager::Flush()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0 ; i<CLASS_MAX ; i++ )
|
||||
for (int i = 0; i < CLASS_MAX; i++)
|
||||
{
|
||||
if ( m_table[i].classPointer != 0 )
|
||||
{
|
||||
free(m_table[i].classPointer);
|
||||
}
|
||||
m_table[i].classPointer = 0;
|
||||
if (m_table[i].instances != nullptr)
|
||||
delete[] m_table[i].instances;
|
||||
|
||||
m_table[i].instances = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Empty all instances of a given class.
|
||||
|
||||
void CInstanceManager::Flush(ClassType classType)
|
||||
void CInstanceManager::Flush(ManagedClassType classType)
|
||||
{
|
||||
if ( classType < 0 || classType >= CLASS_MAX ) return;
|
||||
if ( m_table[classType].classPointer == 0 ) return;
|
||||
if (classType < 0 || classType >= CLASS_MAX) return;
|
||||
if (m_table[classType].instances == nullptr) return;
|
||||
|
||||
free(m_table[classType].classPointer);
|
||||
m_table[classType].classPointer = 0;
|
||||
delete[] m_table[classType].instances;
|
||||
m_table[classType].instances = nullptr;
|
||||
}
|
||||
|
||||
|
||||
// Adds a new instance of a class.
|
||||
|
||||
bool CInstanceManager::AddInstance(ClassType classType, void* pointer, int max)
|
||||
bool CInstanceManager::AddInstance(ManagedClassType classType, void* instance, int max)
|
||||
{
|
||||
int i;
|
||||
if (classType < 0 || classType >= CLASS_MAX) return false;
|
||||
|
||||
if ( classType < 0 || classType >= CLASS_MAX ) return false;
|
||||
|
||||
if ( m_table[classType].classPointer == 0 )
|
||||
if (m_table[classType].instances == nullptr)
|
||||
{
|
||||
m_table[classType].classPointer = static_cast<void**>( malloc(max*sizeof(void*)) );
|
||||
m_table[classType].totalPossible = max;
|
||||
m_table[classType].totalUsed = 0;
|
||||
m_table[classType].instances = new void*[max];
|
||||
m_table[classType].maxCount = max;
|
||||
m_table[classType].usedCount = 0;
|
||||
}
|
||||
|
||||
if ( m_table[classType].totalUsed >= m_table[classType].totalPossible ) return false;
|
||||
if (m_table[classType].usedCount >= m_table[classType].maxCount) return false;
|
||||
|
||||
i = m_table[classType].totalUsed++;
|
||||
m_table[classType].classPointer[i] = pointer;
|
||||
int i = m_table[classType].usedCount++;
|
||||
m_table[classType].instances[i] = instance;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Deletes an instance of a class.
|
||||
|
||||
bool CInstanceManager::DeleteInstance(ClassType classType, void* pointer)
|
||||
bool CInstanceManager::DeleteInstance(ManagedClassType classType, void* instance)
|
||||
{
|
||||
int i;
|
||||
if (classType < 0 || classType >= CLASS_MAX) return false;
|
||||
|
||||
if ( classType < 0 || classType >= CLASS_MAX ) return false;
|
||||
|
||||
for ( i=0 ; i<m_table[classType].totalUsed ; i++ )
|
||||
for (int i = 0; i < m_table[classType].usedCount; i++)
|
||||
{
|
||||
if ( m_table[classType].classPointer[i] == pointer )
|
||||
{
|
||||
m_table[classType].classPointer[i] = 0;
|
||||
}
|
||||
if (m_table[classType].instances[i] == instance)
|
||||
m_table[classType].instances[i] = nullptr;
|
||||
}
|
||||
|
||||
Compress(classType);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Seeking an existing instance. Returns 0 if it does not exist.
|
||||
// Must be super fast!
|
||||
|
||||
void* CInstanceManager::SearchInstance(ClassType classType, int rank)
|
||||
void* CInstanceManager::SearchInstance(ManagedClassType classType, int rank)
|
||||
{
|
||||
#if _DEBUG
|
||||
if ( classType < 0 || classType >= CLASS_MAX ) return 0;
|
||||
if ( m_table[classType].classPointer == 0 ) return 0;
|
||||
#endif
|
||||
if ( rank >= m_table[classType].totalUsed ) return 0;
|
||||
if (classType < 0 || classType >= CLASS_MAX) return nullptr;
|
||||
if (m_table[classType].instances == nullptr) return nullptr;
|
||||
if (rank >= m_table[classType].usedCount) return nullptr;
|
||||
|
||||
return m_table[classType].classPointer[rank];
|
||||
return m_table[classType].instances[rank];
|
||||
}
|
||||
|
||||
|
||||
// Fills holes in a table.
|
||||
|
||||
void CInstanceManager::Compress(ClassType classType)
|
||||
void CInstanceManager::Compress(ManagedClassType classType)
|
||||
{
|
||||
int i, j;
|
||||
if (classType < 0 || classType >= CLASS_MAX) return;
|
||||
|
||||
if ( classType < 0 || classType >= CLASS_MAX ) return;
|
||||
|
||||
j = 0;
|
||||
for ( i=0 ; i<m_table[classType].totalUsed ; i++ )
|
||||
int j = 0;
|
||||
for (int i = 0; i < m_table[classType].usedCount; i++)
|
||||
{
|
||||
if ( m_table[classType].classPointer[i] != 0 )
|
||||
{
|
||||
m_table[classType].classPointer[j++] = m_table[classType].classPointer[i];
|
||||
}
|
||||
if (m_table[classType].instances[i] != nullptr)
|
||||
m_table[classType].instances[j++] = m_table[classType].instances[i];
|
||||
}
|
||||
m_table[classType].totalUsed = j;
|
||||
m_table[classType].usedCount = j;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// iman.h
|
||||
/**
|
||||
* \file iman.h
|
||||
* \brief Instance manager for managed classes
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -22,36 +25,119 @@
|
|||
#include <common/misc.h>
|
||||
|
||||
|
||||
/**
|
||||
* \enum ManagedClassType
|
||||
* \brief Type of class managed by CInstanceManager
|
||||
*/
|
||||
|
||||
struct BaseClass
|
||||
// TODO: remove unnecessary, refactor to singletons, move to CRobotMain, keep others?
|
||||
|
||||
enum ManagedClassType
|
||||
{
|
||||
int totalPossible;
|
||||
int totalUsed;
|
||||
void** classPointer;
|
||||
//! CEventQueue
|
||||
CLASS_EVENT = 1,
|
||||
//! Ui::CInterface
|
||||
CLASS_INTERFACE = 2,
|
||||
//! CRobotMain
|
||||
CLASS_MAIN = 3,
|
||||
//! Gfx::CEngine
|
||||
CLASS_ENGINE = 4,
|
||||
//! Gfx::CTerrain
|
||||
CLASS_TERRAIN = 5,
|
||||
//! CObject
|
||||
CLASS_OBJECT = 6,
|
||||
//! CPhysics
|
||||
CLASS_PHYSICS = 7,
|
||||
//! CBrain
|
||||
CLASS_BRAIN = 8,
|
||||
//! Gfx::CCamera
|
||||
CLASS_CAMERA = 9,
|
||||
//! Gfx::CLightManager
|
||||
CLASS_LIGHT = 10,
|
||||
//! Gfx::CParticle
|
||||
CLASS_PARTICULE = 11,
|
||||
//! CAuto; TODO: remove (unused)
|
||||
CLASS_AUTO = 12,
|
||||
//! Ui::CDisplayText
|
||||
CLASS_DISPLAYTEXT = 13,
|
||||
//! Gfx::CPyro
|
||||
CLASS_PYRO = 14,
|
||||
//! Ui::CScript; TODO: remove (unused)
|
||||
CLASS_SCRIPT = 15,
|
||||
//! Gfx::CText
|
||||
CLASS_TEXT = 16,
|
||||
//! Ui::CStudio, Ui::CDisplayText; TODO: remove (unused)
|
||||
CLASS_STUDIO = 17,
|
||||
//! Gfx::CWater
|
||||
CLASS_WATER = 18,
|
||||
//! Gfx::CCloud; TODO: remove (unused)
|
||||
CLASS_CLOUD = 19,
|
||||
//! CMotion; TODO: remove (unused)
|
||||
CLASS_MOTION = 20,
|
||||
//! CSoundInterface
|
||||
CLASS_SOUND = 21,
|
||||
//! Gfx::CPlanet
|
||||
CLASS_PLANET = 22,
|
||||
//! CTaskManager; TODO: remove (unused)
|
||||
CLASS_TASKMANAGER = 23,
|
||||
//! Ui::CMainDialog; TODO: remove (unused)
|
||||
CLASS_DIALOG = 24,
|
||||
//! Ui::CMainMap; TODO: remove (unused)
|
||||
CLASS_MAP = 25,
|
||||
//! Ui::CMainShort, CMainMovie; TODO: remove (unused)
|
||||
CLASS_SHORT = 26,
|
||||
//! Gfx::CLightning; TODO: remove (unused)
|
||||
CLASS_BLITZ = 27,
|
||||
|
||||
//! Maximum (number of managed classes)
|
||||
CLASS_MAX = 30
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \enum ManagedClassInstances
|
||||
* \brief Instances of class managed by CInstanceManager
|
||||
*/
|
||||
struct ManagedClassInstances
|
||||
{
|
||||
int maxCount;
|
||||
int usedCount;
|
||||
void** instances;
|
||||
};
|
||||
|
||||
/**
|
||||
* \class CInstanceManager
|
||||
* \brief Manager for instances of certain classes
|
||||
*
|
||||
* Instance manager (often shortened to iMan) allows to register instances of
|
||||
* classes and search them.
|
||||
*/
|
||||
class CInstanceManager : public CSingleton<CInstanceManager>
|
||||
{
|
||||
public:
|
||||
CInstanceManager();
|
||||
~CInstanceManager();
|
||||
|
||||
//! Remove all managed instances
|
||||
void Flush();
|
||||
void Flush(ClassType classType);
|
||||
bool AddInstance(ClassType classType, void* pointer, int max=1);
|
||||
bool DeleteInstance(ClassType classType, void* pointer);
|
||||
void* SearchInstance(ClassType classType, int rank=0);
|
||||
//! Removes instances of one type of class
|
||||
void Flush(ManagedClassType classType);
|
||||
//! Registers new instance of class type
|
||||
bool AddInstance(ManagedClassType classType, void* instance, int max=1);
|
||||
//! Deletes the registered instance of class type
|
||||
bool DeleteInstance(ManagedClassType classType, void* instance);
|
||||
//! Seeks a class instance of given type
|
||||
void* SearchInstance(ManagedClassType classType, int rank=0);
|
||||
|
||||
static CInstanceManager& GetInstance();
|
||||
static CInstanceManager* GetInstancePointer();
|
||||
|
||||
protected:
|
||||
void Compress(ClassType classType);
|
||||
//! Fills holes in instance table
|
||||
void Compress(ManagedClassType classType);
|
||||
|
||||
protected:
|
||||
BaseClass m_table[CLASS_MAX];
|
||||
ManagedClassInstances m_table[CLASS_MAX];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// ioutils.h
|
||||
/**
|
||||
* \file ioutils.h
|
||||
* \brief Functions for binary I/O
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,54 +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/.
|
||||
|
||||
// language.h
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define _FULL true // CoLoBoT
|
||||
#define _SCHOOL false // CeeBot-A or Teen
|
||||
#define _TEEN false // false for CeeBot-A, true for CeeBot-Teen
|
||||
#define _EDU false
|
||||
#define _PERSO false
|
||||
#define _CEEBOTDEMO false
|
||||
#define _NET false
|
||||
#define _DEMO false // DEMO only CoLoBoT (with _Full = false)!
|
||||
|
||||
#define _FRENCH false
|
||||
#define _ENGLISH true
|
||||
#define _GERMAN false
|
||||
#define _WG false
|
||||
#define _POLISH false
|
||||
|
||||
#define _NEWLOOK false // false for CoLoBoT, true for all CeeBot
|
||||
#define _SOUNDTRACKS false // always false since InitAudioTrackVolume crop in Vista
|
||||
|
||||
|
||||
// Verifications
|
||||
|
||||
#if !_FULL & !_SCHOOL & !_NET & !_DEMO
|
||||
-> no version chosen!
|
||||
#endif
|
||||
|
||||
#if _SCHOOL
|
||||
#if !_EDU & !_PERSO & !_CEEBOTDEMO
|
||||
-> EDU or PERSO or CEEBOTDEMO?
|
||||
#endif
|
||||
#if _EDU & _PERSO & _CEEBOTDEMO
|
||||
-> EDU and PERSO and CEEBOTDEMO not at the same time!!!
|
||||
#endif
|
||||
#endif
|
|
@ -14,22 +14,20 @@
|
|||
// * 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
|
||||
/**
|
||||
* \file common/logger.h
|
||||
* \brief Class for logging information to file or console
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
#include <common/singleton.h>
|
||||
|
||||
/**
|
||||
* @file common/logger.h
|
||||
* @brief Class for loggin information to file or console
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \public
|
||||
|
|
|
@ -16,17 +16,15 @@
|
|||
|
||||
// metafile.cpp
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common/language.h"
|
||||
#include "common/metafile.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
#if _FULL | _NET
|
||||
//#if _FULL | _NET
|
||||
static unsigned char table_codec[23] =
|
||||
{
|
||||
0x85, 0x91, 0x73, 0xcf, 0xa2, 0xbb, 0xf4, 0x77,
|
||||
|
@ -44,9 +42,9 @@ void Codec(void* buffer, int len, int start)
|
|||
b[i] ^= table_codec[(start++)%23];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
#if _SCHOOL
|
||||
/*#if _SCHOOL
|
||||
#if _CEEBOTDEMO
|
||||
static unsigned char table_codec[136] =
|
||||
{
|
||||
|
@ -99,9 +97,9 @@ void Codec(void* buffer, int len, int start)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
#if _DEMO
|
||||
/*#if _DEMO
|
||||
static unsigned char table_codec[27] =
|
||||
{
|
||||
0x85, 0x91, 0x77, 0xcf, 0xa3, 0xbb, 0xf4, 0x77,
|
||||
|
@ -120,7 +118,7 @@ void Codec(void* buffer, int len, int start)
|
|||
b[i] ^= table_codec[(start++)%27];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
|
||||
|
||||
|
@ -286,7 +284,7 @@ int CMetaFile::Read(void *buffer, int size)
|
|||
|
||||
int CMetaFile::GetByte()
|
||||
{
|
||||
BYTE b;
|
||||
int b;
|
||||
|
||||
if ( !m_bOpen ) return 1;
|
||||
|
||||
|
@ -303,7 +301,7 @@ int CMetaFile::GetByte()
|
|||
|
||||
int CMetaFile::GetWord()
|
||||
{
|
||||
WORD w;
|
||||
int w;
|
||||
|
||||
if ( !m_bOpen ) return 1;
|
||||
|
||||
|
|
|
@ -17,51 +17,25 @@
|
|||
// misc.cpp
|
||||
|
||||
|
||||
#include "common/misc.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
//#include <direct.h>
|
||||
#include <time.h>
|
||||
//#include <d3d.h>
|
||||
|
||||
#include "common/struct.h"
|
||||
//#include "old/d3dengine.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
//#include "old/d3dmath.h"
|
||||
//#include "math/math.h"
|
||||
//#include "old/d3dutil.h"
|
||||
#include "common/language.h"
|
||||
#include "common/event.h"
|
||||
#include "common/misc.h"
|
||||
|
||||
|
||||
|
||||
CMetaFile g_metafile;
|
||||
|
||||
static EventType g_uniqueEventType = EVENT_USER;
|
||||
static bool g_bUserDir = false;
|
||||
static char g_userDir[100] = "";
|
||||
|
||||
|
||||
|
||||
// Gives a single user event.
|
||||
|
||||
EventType GetUniqueEventType()
|
||||
{
|
||||
int i;
|
||||
|
||||
i = static_cast <int> (g_uniqueEventType+1);
|
||||
g_uniqueEventType = static_cast<EventType>(i);
|
||||
return g_uniqueEventType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Returns a non-accented letter.
|
||||
|
||||
char GetNoAccent(char letter)
|
||||
{
|
||||
/*
|
||||
if ( letter < 0 )
|
||||
{
|
||||
if ( letter == '<EFBFBD>' ||
|
||||
|
@ -125,7 +99,7 @@ char GetNoAccent(char letter)
|
|||
if ( letter == '<EFBFBD>' ) return 'C';
|
||||
|
||||
if ( letter == '<EFBFBD>' ) return 'N';
|
||||
}
|
||||
}*/
|
||||
|
||||
return letter;
|
||||
}
|
||||
|
@ -134,7 +108,7 @@ char GetNoAccent(char letter)
|
|||
|
||||
char GetToUpper(char letter)
|
||||
{
|
||||
if ( letter < 0 )
|
||||
/*if ( letter < 0 )
|
||||
{
|
||||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
|
@ -166,7 +140,7 @@ char GetToUpper(char letter)
|
|||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
|
||||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
}
|
||||
}*/
|
||||
|
||||
return toupper(letter);
|
||||
}
|
||||
|
@ -175,7 +149,7 @@ char GetToUpper(char letter)
|
|||
|
||||
char GetToLower(char letter)
|
||||
{
|
||||
if ( letter < 0 )
|
||||
/*if ( letter < 0 )
|
||||
{
|
||||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
|
@ -207,7 +181,7 @@ char GetToLower(char letter)
|
|||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
|
||||
if ( letter == '<EFBFBD>' ) return '<EFBFBD>';
|
||||
}
|
||||
}*/
|
||||
|
||||
return tolower(letter);
|
||||
}
|
||||
|
@ -224,6 +198,7 @@ void GimeToAscii(time_t time, char *buffer)
|
|||
year = when.tm_year+1900;
|
||||
if ( year < 2000 ) year -= 1900;
|
||||
else year -= 2000;
|
||||
/* TODO
|
||||
#if _FRENCH
|
||||
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
|
||||
when.tm_mday, when.tm_mon+1, year,
|
||||
|
@ -234,7 +209,7 @@ void GimeToAscii(time_t time, char *buffer)
|
|||
when.tm_mday, when.tm_mon+1, year,
|
||||
when.tm_hour, when.tm_min);
|
||||
#endif
|
||||
#if _ENGLISH
|
||||
#if _ENGLISH*/
|
||||
char format[10];
|
||||
int hour;
|
||||
|
||||
|
@ -253,12 +228,12 @@ void GimeToAscii(time_t time, char *buffer)
|
|||
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d %s",
|
||||
when.tm_mon+1, when.tm_mday, year,
|
||||
hour, when.tm_min, format);
|
||||
#endif
|
||||
/*#endif
|
||||
#if _POLISH
|
||||
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
|
||||
when.tm_mday, when.tm_mon+1, year,
|
||||
when.tm_hour, when.tm_min);
|
||||
#endif
|
||||
#endif*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -313,7 +288,9 @@ bool CopyFileToTemp(char* filename)
|
|||
UserDir(dst, filename, "textures");
|
||||
strcpy(g_userDir, save);
|
||||
|
||||
// _mkdir("temp"); TODO
|
||||
//_mkdir("temp");
|
||||
system("mkdir temp");
|
||||
|
||||
if ( !Xfer(src, dst) ) return false;
|
||||
|
||||
strcpy(filename, dst);
|
||||
|
@ -384,7 +361,7 @@ void UserDir(bool bUser, char* dir)
|
|||
void UserDir(char* buffer, const char* dir, const char* def)
|
||||
{
|
||||
char ddir[100];
|
||||
char* add;
|
||||
const char* add;
|
||||
|
||||
if ( strstr(dir, "\\") == 0 && def[0] != 0 )
|
||||
{
|
||||
|
@ -420,24 +397,3 @@ void UserDir(char* buffer, const char* dir, const char* def)
|
|||
}
|
||||
*buffer = 0;
|
||||
}
|
||||
|
||||
|
||||
// Returns the letter corresponding to the language.
|
||||
|
||||
char RetLanguageLetter()
|
||||
{
|
||||
#if _FRENCH
|
||||
return 'F';
|
||||
#endif
|
||||
#if _ENGLISH
|
||||
return 'E';
|
||||
#endif
|
||||
#if _GERMAN | _WG
|
||||
return 'D';
|
||||
#endif
|
||||
#if _POLISH
|
||||
return 'P';
|
||||
#endif
|
||||
return 'X';
|
||||
}
|
||||
|
||||
|
|
|
@ -22,55 +22,7 @@
|
|||
#include <time.h>
|
||||
|
||||
|
||||
#include "common/metafile.h"
|
||||
#include "common/event.h"
|
||||
#include "common/error_ids.h"
|
||||
|
||||
|
||||
extern CMetaFile g_metafile;
|
||||
|
||||
|
||||
|
||||
// Existing classes.
|
||||
|
||||
enum ClassType
|
||||
{
|
||||
CLASS_EVENT = 1,
|
||||
CLASS_INTERFACE = 2,
|
||||
CLASS_MAIN = 3,
|
||||
CLASS_ENGINE = 4,
|
||||
CLASS_TERRAIN = 5,
|
||||
CLASS_OBJECT = 6,
|
||||
CLASS_PHYSICS = 7,
|
||||
CLASS_BRAIN = 8,
|
||||
CLASS_CAMERA = 9,
|
||||
CLASS_LIGHT = 10,
|
||||
CLASS_PARTICULE = 11,
|
||||
CLASS_AUTO = 12,
|
||||
CLASS_DISPLAYTEXT = 13,
|
||||
CLASS_PYRO = 14,
|
||||
CLASS_SCRIPT = 15,
|
||||
CLASS_TEXT = 16,
|
||||
CLASS_STUDIO = 17,
|
||||
CLASS_WATER = 18,
|
||||
CLASS_CLOUD = 19,
|
||||
CLASS_MOTION = 20,
|
||||
CLASS_SOUND = 21,
|
||||
CLASS_PLANET = 22,
|
||||
CLASS_TASKMANAGER = 23,
|
||||
CLASS_DIALOG = 24,
|
||||
CLASS_MAP = 25,
|
||||
CLASS_SHORT = 26,
|
||||
CLASS_BLITZ = 27,
|
||||
};
|
||||
|
||||
const int CLASS_MAX = 30;
|
||||
|
||||
|
||||
|
||||
|
||||
// Keyboard state.
|
||||
|
||||
// TODO: to be removed (replaced by TrackedKey enum and mouse states in app.h)
|
||||
const int KS_PAGEUP = (1<<4);
|
||||
const int KS_PAGEDOWN = (1<<5);
|
||||
const int KS_SHIFT = (1<<6);
|
||||
|
@ -84,10 +36,7 @@ const int KS_NUMRIGHT = (1<<13);
|
|||
const int KS_NUMPLUS = (1<<14);
|
||||
const int KS_NUMMINUS = (1<<15);
|
||||
|
||||
|
||||
// Procedures.
|
||||
|
||||
extern EventType GetUniqueEventType();
|
||||
// TODO: rewrite/refactor or remove
|
||||
|
||||
extern char GetNoAccent(char letter);
|
||||
extern char GetToUpper(char letter);
|
||||
|
@ -100,7 +49,3 @@ extern bool CopyFileListToTemp(char* filename, int* list, int total);
|
|||
extern void AddExt(char* filename, char* ext);
|
||||
extern void UserDir(bool bUser, char* dir);
|
||||
extern void UserDir(char* buffer, const char* dir, const char* def);
|
||||
|
||||
extern char GetLanguageLetter();
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
// profile.cpp
|
||||
|
||||
|
||||
#include <common/profile.h>
|
||||
#include "common/profile.h"
|
||||
|
||||
#include <utility>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
template<> CProfile* CSingleton<CProfile>::mInstance = nullptr;
|
||||
|
|
|
@ -14,22 +14,19 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// profile.h
|
||||
/**
|
||||
* \file common/profile.h
|
||||
* \brief Class for loading profile (currently for loading ini config file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include "lib/simpleini/SimpleIni.h"
|
||||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include <lib/simpleini/SimpleIni.h>
|
||||
|
||||
#include <common/singleton.h>
|
||||
|
||||
/**
|
||||
* @file common/profile.h
|
||||
* @brief Class for loading profile (currently for loading ini config file)
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,147 +14,46 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// restext.h
|
||||
/**
|
||||
* \file common/restext.h
|
||||
* \brief Translation and string resource utilities
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//#include "graphics/engine/engine.h"
|
||||
#include "common/event.h"
|
||||
|
||||
namespace Gfx
|
||||
{
|
||||
class CEngine;
|
||||
}
|
||||
#include "common/global.h"
|
||||
#include "common/restext_ids.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// Possible types of the text resources.
|
||||
|
||||
/**
|
||||
* \enum ResType
|
||||
* \brief Types of text resources
|
||||
*/
|
||||
enum ResType
|
||||
{
|
||||
RES_TEXT = 0, // RT_*
|
||||
RES_EVENT = 1, // EVENT_* (EventType)
|
||||
RES_OBJECT = 2, // OBJECT_* (ObjectType)
|
||||
RES_ERR = 3, // ERR_* (Error)
|
||||
RES_KEY = 4, // VK_* (keys)
|
||||
RES_CBOT = 5, // TX_* (cbot.dll)
|
||||
RES_TEXT = 0, //! < RT_*
|
||||
RES_EVENT = 1, //! < EVENT_* (EventMsg)
|
||||
RES_OBJECT = 2, //! < OBJECT_* (ObjectType)
|
||||
RES_ERR = 3, //! < ERR_* (Error)
|
||||
RES_KEY = 4, //! < KEY() (keys)
|
||||
RES_CBOT = 5, //! < TX_* (CBot)
|
||||
};
|
||||
|
||||
|
||||
// Resources of type RES_TEXT.
|
||||
// TODO: move to CRobotMain
|
||||
|
||||
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 bool SearchKey(char *cmd, KeyRank &key);
|
||||
extern void PutKeyName(char* dst, char* src);
|
||||
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;
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
// TODO: move to restext.h after restext rewrite
|
||||
|
||||
#pragma once
|
||||
|
||||
enum ResTextType
|
||||
|
|
|
@ -22,36 +22,8 @@
|
|||
|
||||
const char * const strings_text[] =
|
||||
{
|
||||
#if _FULL
|
||||
[RT_VERSION_ID] = "1.18 /e",
|
||||
#endif
|
||||
#if _NET
|
||||
[RT_VERSION_ID] = "CeeBot-A 1.18",
|
||||
#endif
|
||||
#if _SCHOOL & _EDU
|
||||
#if _TEEN
|
||||
[RT_VERSION_ID] = "CeeBot-Teen EDU 1.18",
|
||||
#else
|
||||
[RT_VERSION_ID] = "CeeBot-A EDU 1.18",
|
||||
#endif
|
||||
#endif
|
||||
#if _SCHOOL & _PERSO
|
||||
#if _TEEN
|
||||
[RT_VERSION_ID] = "CeeBot-Teen PERSO 1.18",
|
||||
#else
|
||||
[RT_VERSION_ID] = "CeeBot-A PERSO 1.18",
|
||||
#endif
|
||||
#endif
|
||||
#if _SCHOOL & _CEEBOTDEMO
|
||||
#if _TEEN
|
||||
[RT_VERSION_ID] = "CeeBot-Teen DEMO 1.18",
|
||||
#else
|
||||
[RT_VERSION_ID] = "CeeBot-A DEMO 1.18",
|
||||
#endif
|
||||
#endif
|
||||
#if _DEMO
|
||||
[RT_VERSION_ID] = "Demo 1.18 /e",
|
||||
#endif
|
||||
[RT_VERSION_ID] = "Colobot Gold",
|
||||
|
||||
[RT_DISINFO_TITLE] = "SatCom",
|
||||
[RT_WINDOW_MAXIMIZED] = "Maximize",
|
||||
[RT_WINDOW_MINIMIZED] = "Minimize",
|
||||
|
@ -64,13 +36,8 @@ const char * const strings_text[] =
|
|||
[RT_IO_NEW] = "New ...",
|
||||
[RT_KEY_OR] = " or ",
|
||||
|
||||
#if _NEWLOOK
|
||||
[RT_TITLE_BASE] = "CeeBot",
|
||||
[RT_TITLE_INIT] = "CeeBot",
|
||||
#else
|
||||
[RT_TITLE_BASE] = "COLOBOT",
|
||||
[RT_TITLE_INIT] = "COLOBOT",
|
||||
#endif
|
||||
[RT_TITLE_TRAINER] = "Programming exercises",
|
||||
[RT_TITLE_DEFI] = "Challenges",
|
||||
[RT_TITLE_MISSION] = "Missions",
|
||||
|
@ -111,15 +78,9 @@ const char * const strings_text[] =
|
|||
[RT_PERSO_COMBI] = "Suit color:",
|
||||
[RT_PERSO_BAND] = "Strip color:",
|
||||
|
||||
#if _NEWLOOK
|
||||
[RT_DIALOG_QUIT] = "Do you want to quit CeeBot ?",
|
||||
[RT_DIALOG_TITLE] = "CeeBot",
|
||||
[RT_DIALOG_YESQUIT] = "Quit\\Quit CeeBot",
|
||||
#else
|
||||
[RT_DIALOG_QUIT] = "Do you want to quit COLOBOT ?",
|
||||
[RT_DIALOG_TITLE] = "COLOBOT",
|
||||
[RT_DIALOG_YESQUIT] = "Quit\\Quit COLOBOT",
|
||||
#endif
|
||||
[RT_DIALOG_ABORT] = "Quit the mission?",
|
||||
[RT_DIALOG_YES] = "Abort\\Abort the current mission",
|
||||
[RT_DIALOG_NO] = "Continue\\Continue the current mission",
|
||||
|
@ -182,13 +143,8 @@ const char * const strings_event[] =
|
|||
[EVENT_INTERFACE_AGAIN] = "Restart\\Restart the mission from the beginning",
|
||||
[EVENT_INTERFACE_WRITE] = "Save\\Save the current mission ",
|
||||
[EVENT_INTERFACE_READ] = "Load\\Load a saved mission",
|
||||
#if _NEWLOOK
|
||||
[EVENT_INTERFACE_ABORT] = "\\Return to CeeBot",
|
||||
[EVENT_INTERFACE_QUIT] = "Quit\\Quit CeeBot",
|
||||
#else
|
||||
[EVENT_INTERFACE_ABORT] = "\\Return to COLOBOT",
|
||||
[EVENT_INTERFACE_QUIT] = "Quit\\Quit COLOBOT",
|
||||
#endif
|
||||
[EVENT_INTERFACE_BACK] = "<< Back \\Back to the previous screen",
|
||||
[EVENT_INTERFACE_PLAY] = "Play\\Start mission!",
|
||||
[EVENT_INTERFACE_SETUPd] = "Device\\Driver and resolution settings",
|
||||
|
@ -432,11 +388,7 @@ const char * const strings_event[] =
|
|||
[EVENT_HYPER_SIZE4] = "Size 4",
|
||||
[EVENT_HYPER_SIZE5] = "Size 5",
|
||||
[EVENT_SATCOM_HUSTON] = "Instructions from Houston",
|
||||
#if _TEEN
|
||||
[EVENT_SATCOM_SAT] = "Dictionnary",
|
||||
#else
|
||||
[EVENT_SATCOM_SAT] = "Satellite report",
|
||||
#endif
|
||||
[EVENT_SATCOM_LOADING] = "Programs dispatched by Houston",
|
||||
[EVENT_SATCOM_OBJECT] = "List of objects",
|
||||
[EVENT_SATCOM_PROG] = "Programming help",
|
||||
|
@ -475,11 +427,7 @@ const char * const strings_object[] =
|
|||
[OBJECT_RESEARCH] = "Research center",
|
||||
[OBJECT_RADAR] = "Radar station",
|
||||
[OBJECT_INFO] = "Information exchange post",
|
||||
#if _TEEN
|
||||
[OBJECT_ENERGY] = "Disintegrator",
|
||||
#else
|
||||
[OBJECT_ENERGY] = "Power cell factory",
|
||||
#endif
|
||||
[OBJECT_LABO] = "Autolab",
|
||||
[OBJECT_NUCLEAR] = "Nuclear power station",
|
||||
[OBJECT_PARA] = "Lightning conductor",
|
||||
|
@ -574,13 +522,6 @@ const char * const strings_object[] =
|
|||
const char * const strings_err[] =
|
||||
{
|
||||
[ERR_CMD] = "Unknown command",
|
||||
#if _NEWLOOK
|
||||
[ERR_INSTALL] = "CeeBot not installed.",
|
||||
[ERR_NOCD] = "Please insert the CeeBot CD\nand re-run the game.",
|
||||
#else
|
||||
[ERR_INSTALL] = "COLOBOT not installed.",
|
||||
[ERR_NOCD] = "Please insert the COLOBOT CD\nand re-run the game.",
|
||||
#endif
|
||||
[ERR_MANIP_VEH] = "Inappropriate bot",
|
||||
[ERR_MANIP_FLY] = "Impossible when flying",
|
||||
[ERR_MANIP_BUSY] = "Already carrying something",
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
// * 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
|
||||
/**
|
||||
* \file common/singleton.h
|
||||
* \brief CSingleton base class for singletons
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// stringutils.h
|
||||
/**
|
||||
* \file common/stringutils.h
|
||||
* \brief Some useful string operations
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,54 +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/.
|
||||
|
||||
// struct.h
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <math/vector.h>
|
||||
|
||||
|
||||
#define D3DFVF_VERTEX2 (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
|
||||
|
||||
struct D3DVERTEX2
|
||||
{
|
||||
float x,y,z;
|
||||
float nx,ny,nz;
|
||||
float tu, tv;
|
||||
float tu2, tv2;
|
||||
|
||||
D3DVERTEX2() { }
|
||||
D3DVERTEX2(const Math::Vector& _v, const Math::Vector& _n, float _tu=0.0f, float _tv=0.0f, float _tu2=0.0f, float _tv2=0.0f)
|
||||
{
|
||||
x = _v.x;
|
||||
y = _v.y;
|
||||
z = _v.z;
|
||||
nx = _n.x;
|
||||
ny = _n.y;
|
||||
nz = _n.z;
|
||||
tu = _tu;
|
||||
tv = _tv;
|
||||
tu2 = _tu2;
|
||||
tv2 = _tv2;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct ColorHSV
|
||||
{
|
||||
float h,s,v;
|
||||
};
|
|
@ -7,6 +7,8 @@ include_directories("../../")
|
|||
include_directories("../../../")
|
||||
|
||||
add_executable(image_test ../image.cpp image_test.cpp)
|
||||
target_link_libraries(image_test -lpng -lSDL -lSDL_image)
|
||||
|
||||
add_executable(profile_test ../profile.cpp profile_test.cpp)
|
||||
|
||||
add_test(profile_test ./profile_test)
|
||||
|
|
|
@ -22,6 +22,29 @@ int main(int argc, char *argv[])
|
|||
printf("Error loading '%s': %s\n", err.c_str());
|
||||
return 1;
|
||||
}
|
||||
Gfx::Color color;
|
||||
std::string str;
|
||||
|
||||
color = image.GetPixel(Math::IntPoint(0, 0));
|
||||
str = color.ToString();
|
||||
printf("pixel @ (0,0): %s\n", str.c_str());
|
||||
|
||||
color = image.GetPixel(Math::IntPoint(0, 1));
|
||||
str = color.ToString();
|
||||
printf("pixel @ (0,1): %s\n", str.c_str());
|
||||
|
||||
color = image.GetPixel(Math::IntPoint(1, 0));
|
||||
str = color.ToString();
|
||||
printf("pixel @ (1,0): %s\n", str.c_str());
|
||||
|
||||
color = image.GetPixel(Math::IntPoint(1, 1));
|
||||
str = color.ToString();
|
||||
printf("pixel @ (1,1): %s\n", str.c_str());
|
||||
|
||||
image.SetPixel(Math::IntPoint(0, 0), Gfx::Color(0.1f, 0.2f, 0.3f, 0.0f));
|
||||
image.SetPixel(Math::IntPoint(1, 0), Gfx::Color(0.3f, 0.2f, 0.1f, 1.0f));
|
||||
image.SetPixel(Math::IntPoint(0, 1), Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
image.SetPixel(Math::IntPoint(1, 1), Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
if (! image.SavePNG(argv[2]))
|
||||
{
|
||||
|
|
|
@ -357,22 +357,22 @@ bool Gfx::CEngine::ProcessEvent(const Event &event)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (event.type == EVENT_FRAME)
|
||||
{
|
||||
m_highlightTime += event.rTime;
|
||||
}
|
||||
|
||||
// By default, pass on all events
|
||||
return true;
|
||||
}
|
||||
|
||||
void Gfx::CEngine::FrameMove(float rTime)
|
||||
void Gfx::CEngine::FrameUpdate()
|
||||
{
|
||||
float rTime = m_app->GetRelTime();
|
||||
|
||||
m_lightMan->UpdateProgression(rTime);
|
||||
m_particle->FrameParticle(rTime);
|
||||
ComputeDistance();
|
||||
UpdateGeometry();
|
||||
|
||||
m_highlightTime = m_app->GetAbsTime();
|
||||
|
||||
if (m_groundMark.draw)
|
||||
{
|
||||
if (m_groundMark.phase == Gfx::ENG_GR_MARK_PHASE_INC) // growing?
|
||||
|
@ -402,16 +402,6 @@ void Gfx::CEngine::FrameMove(float rTime)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_sound == nullptr)
|
||||
m_sound = static_cast<CSoundInterface*>( m_iMan->SearchInstance(CLASS_SOUND) );
|
||||
|
||||
m_sound->FrameMove(rTime);
|
||||
}
|
||||
|
||||
void Gfx::CEngine::StepSimulation(float rTime)
|
||||
{
|
||||
m_app->StepSimulation(rTime);
|
||||
}
|
||||
|
||||
bool Gfx::CEngine::WriteScreenShot(const std::string& fileName, int width, int height)
|
||||
|
@ -2726,16 +2716,6 @@ int Gfx::CEngine::GetEditIndentValue()
|
|||
return m_editIndentValue;
|
||||
}
|
||||
|
||||
void Gfx::CEngine::SetSpeed(float speed)
|
||||
{
|
||||
m_speed = speed;
|
||||
}
|
||||
|
||||
float Gfx::CEngine::GetSpeed()
|
||||
{
|
||||
return m_speed;
|
||||
}
|
||||
|
||||
void Gfx::CEngine::SetTracePrecision(float factor)
|
||||
{
|
||||
m_tracePrecision = factor;
|
||||
|
|
|
@ -664,9 +664,7 @@ public:
|
|||
bool ProcessEvent(const Event& event);
|
||||
|
||||
//! Called once per frame, the call is the entry point for animating the scene
|
||||
void FrameMove(float rTime);
|
||||
//! Evolved throughout the game
|
||||
void StepSimulation(float rTime);
|
||||
void FrameUpdate();
|
||||
|
||||
|
||||
//! Writes a screenshot containing the current frame
|
||||
|
@ -1098,11 +1096,6 @@ public:
|
|||
int GetEditIndentValue();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
//! Management of game speed
|
||||
void SetSpeed(float speed);
|
||||
float GetSpeed();
|
||||
|
||||
//@{
|
||||
//! Management of precision of robot tracks
|
||||
void SetTracePrecision(float factor);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/event.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/event.h"
|
||||
#include "common/global.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
#include "object/object.h"
|
||||
|
||||
|
|
|
@ -27,5 +27,3 @@
|
|||
#include "vector.h"
|
||||
#include "matrix.h"
|
||||
#include "geometry.h"
|
||||
|
||||
#include "conv.h"
|
||||
|
|
|
@ -51,4 +51,3 @@ const float RAD_TO_DEG = 57.29577951308232286465f;
|
|||
const float LOG_2 = log(2.0f);
|
||||
|
||||
}; // namespace Math
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/* math/conv.h
|
||||
|
||||
Temporary conversion functions for D3DVECTOR and D3DMATRIX */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include "vector.h"
|
||||
#include "matrix.h"
|
||||
|
||||
inline D3DVECTOR VEC_TO_D3DVEC(Math::Vector vec)
|
||||
{
|
||||
return D3DVECTOR(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
inline Math::Vector D3DVEC_TO_VEC(D3DVECTOR vec)
|
||||
{
|
||||
return Math::Vector(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
inline D3DMATRIX MAT_TO_D3DMAT(Math::Matrix mat)
|
||||
{
|
||||
D3DMATRIX result;
|
||||
mat.Transpose();
|
||||
for (int r = 0; r < 4; ++r)
|
||||
{
|
||||
for (int c = 0; c < 16; ++c)
|
||||
result.m[r][c] = mat.m[4*c+r];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline Math::Matrix D3DMAT_TO_MAT(D3DMATRIX mat)
|
||||
{
|
||||
Math::Matrix result(mat.m);
|
||||
result.Transpose();
|
||||
return result;
|
||||
}
|
|
@ -76,9 +76,11 @@ inline bool IsInsideTriangle(Math::Point a, Math::Point b, Math::Point c, Math::
|
|||
}
|
||||
|
||||
//! Rotates a point around a center
|
||||
/** \a center center of rotation
|
||||
\a angle angle is in radians (positive is counterclockwise (CCW) )
|
||||
\a p the point */
|
||||
/**
|
||||
* \param center center of rotation
|
||||
* \param angle angle [radians] (positive is CCW)
|
||||
* \param p the point to be rotated
|
||||
*/
|
||||
inline Math::Point RotatePoint(const Math::Point ¢er, float angle, const Math::Point &p)
|
||||
{
|
||||
Math::Point a;
|
||||
|
@ -96,8 +98,10 @@ inline Math::Point RotatePoint(const Math::Point ¢er, float angle, const Mat
|
|||
}
|
||||
|
||||
//! Rotates a point around the origin (0,0)
|
||||
/** \a angle angle in radians (positive is counterclockwise (CCW) )
|
||||
\a p the point */
|
||||
/**
|
||||
* \param angle angle [radians] (positive is CCW)
|
||||
* \param p the point to be rotated
|
||||
*/
|
||||
inline Math::Point RotatePoint(float angle, const Math::Point &p)
|
||||
{
|
||||
float x = p.x*cosf(angle) - p.y*sinf(angle);
|
||||
|
@ -106,9 +110,11 @@ inline Math::Point RotatePoint(float angle, const Math::Point &p)
|
|||
return Math::Point(x, y);
|
||||
}
|
||||
|
||||
//! Rotates a vector (dist, 0).
|
||||
/** \a angle angle is in radians (positive is counterclockwise (CCW) )
|
||||
\a dist distance to origin */
|
||||
//! Rotates a vector (dist, 0)
|
||||
/**
|
||||
* \param angle angle [radians] (positive is CCW)
|
||||
* \param dist distance to origin
|
||||
*/
|
||||
inline Math::Point RotatePoint(float angle, float dist)
|
||||
{
|
||||
float x = dist*cosf(angle);
|
||||
|
@ -117,7 +123,12 @@ inline Math::Point RotatePoint(float angle, float dist)
|
|||
return Math::Point(x, y);
|
||||
}
|
||||
|
||||
//! TODO documentation
|
||||
//! Rotates a point around a center on 2D plane
|
||||
/**
|
||||
* \param cx,cy center of rotation
|
||||
* \param angle angle of rotation [radians] (positive is CCW)
|
||||
* \param px,py point coordinates to rotate
|
||||
*/
|
||||
inline void RotatePoint(float cx, float cy, float angle, float &px, float &py)
|
||||
{
|
||||
float ax, ay;
|
||||
|
@ -132,11 +143,14 @@ inline void RotatePoint(float cx, float cy, float angle, float &px, float &py)
|
|||
py = cy+ay;
|
||||
}
|
||||
|
||||
//! Rotates a point around a center in space.
|
||||
/** \a center center of rotation
|
||||
\a angleH,angleV rotation angles in radians (positive is counterclockwise (CCW) ) )
|
||||
\a p the point
|
||||
\returns the rotated point */
|
||||
//! Rotates a point around a center in space
|
||||
/**
|
||||
* \a angleH is rotation along Y axis (heading) while \a angleV is rotation along X axis (TODO: ?).
|
||||
*
|
||||
* \param center center of rotation
|
||||
* \param angleH,angleV rotation angles [radians] (positive is CCW)
|
||||
* \param p the point to be rotated
|
||||
*/
|
||||
inline void RotatePoint(const Math::Vector ¢er, float angleH, float angleV, Math::Vector &p)
|
||||
{
|
||||
p.x -= center.x;
|
||||
|
@ -151,11 +165,14 @@ inline void RotatePoint(const Math::Vector ¢er, float angleH, float angleV,
|
|||
p = center + b;
|
||||
}
|
||||
|
||||
//! Rotates a point around a center in space.
|
||||
/** \a center center of rotation
|
||||
\a angleH,angleV rotation angles in radians (positive is counterclockwise (CCW) ) )
|
||||
\a p the point
|
||||
\returns the rotated point */
|
||||
//! Rotates a point around a center in space
|
||||
/**
|
||||
* The rotation is performed first along Y axis (\a angleH) and then along X axis (\a angleV).
|
||||
*
|
||||
* \param center center of rotation
|
||||
* \param angleH,angleV rotation angles [radians] (positive is CCW)
|
||||
* \param p the point to be rotated
|
||||
*/
|
||||
inline void RotatePoint2(const Math::Vector center, float angleH, float angleV, Math::Vector &p)
|
||||
{
|
||||
p.x -= center.x;
|
||||
|
@ -189,10 +206,12 @@ inline float RotateAngle(float x, float y)
|
|||
return -atan + 0.5f*PI;
|
||||
}
|
||||
|
||||
//! Calculates the angle between two points and one center
|
||||
/** \a center the center point
|
||||
\a p1,p2 the two points
|
||||
\returns The angle in radians (positive is counterclockwise (CCW) ) */
|
||||
//! Calculates the angle between two points and a center
|
||||
/**
|
||||
* \param center the center point
|
||||
* \param p1,p2 the two points
|
||||
* \returns the angle [radians] (positive is CCW)
|
||||
*/
|
||||
inline float RotateAngle(const Math::Point ¢er, const Math::Point &p1, const Math::Point &p2)
|
||||
{
|
||||
if (PointsEqual(p1, center))
|
||||
|
@ -215,9 +234,11 @@ inline float RotateAngle(const Math::Point ¢er, const Math::Point &p1, const
|
|||
}
|
||||
|
||||
//! Loads view matrix from the given vectors
|
||||
/** \a from origin
|
||||
\a at view direction
|
||||
\a worldUp up vector */
|
||||
/**
|
||||
* \param from origin
|
||||
* \param at view direction
|
||||
* \param worldUp up vector
|
||||
*/
|
||||
inline void LoadViewMatrix(Math::Matrix &mat, const Math::Vector &from,
|
||||
const Math::Vector &at, const Math::Vector &worldUp)
|
||||
{
|
||||
|
@ -280,10 +301,12 @@ inline void LoadViewMatrix(Math::Matrix &mat, const Math::Vector &from,
|
|||
}
|
||||
|
||||
//! Loads a perspective projection matrix
|
||||
/** \a fov field of view in radians
|
||||
\a aspect aspect ratio (width / height)
|
||||
\a nearPlane distance to near cut plane
|
||||
\a farPlane distance to far cut plane */
|
||||
/**
|
||||
* \param fov field of view in radians
|
||||
* \param aspect aspect ratio (width / height)
|
||||
* \param nearPlane distance to near cut plane
|
||||
* \param farPlane distance to far cut plane
|
||||
*/
|
||||
inline void LoadProjectionMatrix(Math::Matrix &mat, float fov = Math::PI / 2.0f, float aspect = 1.0f,
|
||||
float nearPlane = 1.0f, float farPlane = 1000.0f)
|
||||
{
|
||||
|
@ -302,9 +325,11 @@ inline void LoadProjectionMatrix(Math::Matrix &mat, float fov = Math::PI / 2.0f,
|
|||
}
|
||||
|
||||
//! Loads an othogonal projection matrix
|
||||
/** \a left,right coordinates for left and right vertical clipping planes
|
||||
\a bottom,top coordinates for bottom and top horizontal clipping planes
|
||||
\a zNear,zFar distance to nearer and farther depth clipping planes */
|
||||
/**
|
||||
* \param left,right coordinates for left and right vertical clipping planes
|
||||
* \param bottom,top coordinates for bottom and top horizontal clipping planes
|
||||
* \param zNear,zFar distance to nearer and farther depth clipping planes
|
||||
*/
|
||||
inline void LoadOrthoProjectionMatrix(Math::Matrix &mat, float left, float right, float bottom, float top,
|
||||
float zNear = -1.0f, float zFar = 1.0f)
|
||||
{
|
||||
|
@ -320,7 +345,10 @@ inline void LoadOrthoProjectionMatrix(Math::Matrix &mat, float left, float right
|
|||
}
|
||||
|
||||
//! Loads a translation matrix from given vector
|
||||
/** \a trans vector of translation*/
|
||||
/**
|
||||
* \param mat result matrix
|
||||
* \param trans vector of translation
|
||||
*/
|
||||
inline void LoadTranslationMatrix(Math::Matrix &mat, const Math::Vector &trans)
|
||||
{
|
||||
mat.LoadIdentity();
|
||||
|
@ -330,7 +358,10 @@ inline void LoadTranslationMatrix(Math::Matrix &mat, const Math::Vector &trans)
|
|||
}
|
||||
|
||||
//! Loads a scaling matrix fom given vector
|
||||
/** \a scale vector with scaling factors for X, Y, Z */
|
||||
/**
|
||||
* \param mat result matrix
|
||||
* \param scale vector with scaling factors for X, Y, Z
|
||||
*/
|
||||
inline void LoadScaleMatrix(Math::Matrix &mat, const Math::Vector &scale)
|
||||
{
|
||||
mat.LoadIdentity();
|
||||
|
@ -340,7 +371,10 @@ inline void LoadScaleMatrix(Math::Matrix &mat, const Math::Vector &scale)
|
|||
}
|
||||
|
||||
//! Loads a rotation matrix along the X axis
|
||||
/** \a angle angle in radians */
|
||||
/**
|
||||
* \param mat result matrix
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationXMatrix(Math::Matrix &mat, float angle)
|
||||
{
|
||||
mat.LoadIdentity();
|
||||
|
@ -351,7 +385,10 @@ inline void LoadRotationXMatrix(Math::Matrix &mat, float angle)
|
|||
}
|
||||
|
||||
//! Loads a rotation matrix along the Y axis
|
||||
/** \a angle angle in radians */
|
||||
/**
|
||||
* \param mat result matrix
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationYMatrix(Math::Matrix &mat, float angle)
|
||||
{
|
||||
mat.LoadIdentity();
|
||||
|
@ -362,7 +399,10 @@ inline void LoadRotationYMatrix(Math::Matrix &mat, float angle)
|
|||
}
|
||||
|
||||
//! Loads a rotation matrix along the Z axis
|
||||
/** \a angle angle in radians */
|
||||
/**
|
||||
* \param mat result matrix
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationZMatrix(Math::Matrix &mat, float angle)
|
||||
{
|
||||
mat.LoadIdentity();
|
||||
|
@ -373,8 +413,11 @@ inline void LoadRotationZMatrix(Math::Matrix &mat, float angle)
|
|||
}
|
||||
|
||||
//! Loads a rotation matrix along the given axis
|
||||
/** \a dir axis of rotation
|
||||
\a angle angle in radians */
|
||||
/**
|
||||
* \param mat result matrix
|
||||
* \param dir axis of rotation
|
||||
* \param angle angle [radians]
|
||||
*/
|
||||
inline void LoadRotationMatrix(Math::Matrix &mat, const Math::Vector &dir, float angle)
|
||||
{
|
||||
float cos = cosf(angle);
|
||||
|
@ -397,28 +440,28 @@ inline void LoadRotationMatrix(Math::Matrix &mat, const Math::Vector &dir, float
|
|||
}
|
||||
|
||||
//! Calculates the matrix to make three rotations in the order X, Z and Y
|
||||
inline void LoadRotationXZYMatrix(Math::Matrix &mat, const Math::Vector &angle)
|
||||
inline void LoadRotationXZYMatrix(Math::Matrix &mat, const Math::Vector &angles)
|
||||
{
|
||||
Math::Matrix temp;
|
||||
LoadRotationXMatrix(temp, angle.x);
|
||||
LoadRotationXMatrix(temp, angles.x);
|
||||
|
||||
LoadRotationZMatrix(mat, angle.z);
|
||||
LoadRotationZMatrix(mat, angles.z);
|
||||
mat = Math::MultiplyMatrices(temp, mat);
|
||||
|
||||
LoadRotationYMatrix(temp, angle.y);
|
||||
LoadRotationYMatrix(temp, angles.y);
|
||||
mat = Math::MultiplyMatrices(temp, mat);
|
||||
}
|
||||
|
||||
//! Calculates the matrix to make three rotations in the order Z, X and Y
|
||||
inline void LoadRotationZXYMatrix(Math::Matrix &mat, const Math::Vector &angle)
|
||||
inline void LoadRotationZXYMatrix(Math::Matrix &mat, const Math::Vector &angles)
|
||||
{
|
||||
Math::Matrix temp;
|
||||
LoadRotationZMatrix(temp, angle.z);
|
||||
LoadRotationZMatrix(temp, angles.z);
|
||||
|
||||
LoadRotationXMatrix(mat, angle.x);
|
||||
LoadRotationXMatrix(mat, angles.x);
|
||||
mat = Math::MultiplyMatrices(temp, mat);
|
||||
|
||||
LoadRotationYMatrix(temp, angle.y);
|
||||
LoadRotationYMatrix(temp, angles.y);
|
||||
mat = Math::MultiplyMatrices(temp, mat);
|
||||
}
|
||||
|
||||
|
@ -430,7 +473,9 @@ inline float DistanceProjected(const Math::Vector &a, const Math::Vector &b)
|
|||
}
|
||||
|
||||
//! Returns the normal vector to a plane
|
||||
/** \param p1,p2,p3 points defining the plane */
|
||||
/**
|
||||
* \param p1,p2,p3 points defining the plane
|
||||
*/
|
||||
inline Math::Vector NormalToPlane(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3)
|
||||
{
|
||||
Math::Vector u = p3 - p1;
|
||||
|
@ -440,16 +485,20 @@ inline Math::Vector NormalToPlane(const Math::Vector &p1, const Math::Vector &p2
|
|||
}
|
||||
|
||||
//! Returns a point on the line \a p1 - \a p2, in \a dist distance from \a p1
|
||||
/** \a p1,p2 line start and end
|
||||
\a dist scaling factor from \a p1, relative to distance between \a p1 and \a p2 */
|
||||
/**
|
||||
* \param p1,p2 line start and end
|
||||
* \param dist scaling factor from \a p1, relative to distance between \a p1 and \a p2
|
||||
*/
|
||||
inline Math::Vector SegmentPoint(const Math::Vector &p1, const Math::Vector &p2, float dist)
|
||||
{
|
||||
return p1 + (p2 - p1) * dist;
|
||||
}
|
||||
|
||||
//! Returns the distance between given point and a plane
|
||||
/** \param p the point
|
||||
\param a,b,c points defining the plane */
|
||||
/**
|
||||
* \param p the point
|
||||
* \param a,b,c points defining the plane
|
||||
*/
|
||||
inline float DistanceToPlane(const Math::Vector &a, const Math::Vector &b,
|
||||
const Math::Vector &c, const Math::Vector &p)
|
||||
{
|
||||
|
@ -460,8 +509,10 @@ inline float DistanceToPlane(const Math::Vector &a, const Math::Vector &b,
|
|||
}
|
||||
|
||||
//! Checks if two planes defined by three points are the same
|
||||
/** \a plane1 array of three vectors defining the first plane
|
||||
\a plane2 array of three vectors defining the second plane */
|
||||
/**
|
||||
* \param plane1 array of three vectors defining the first plane
|
||||
* \param plane2 array of three vectors defining the second plane
|
||||
*/
|
||||
inline bool IsSamePlane(const Math::Vector (&plane1)[3], const Math::Vector (&plane2)[3])
|
||||
{
|
||||
Math::Vector n1 = NormalToPlane(plane1[0], plane1[1], plane1[2]);
|
||||
|
@ -479,7 +530,7 @@ inline bool IsSamePlane(const Math::Vector (&plane1)[3], const Math::Vector (&pl
|
|||
return true;
|
||||
}
|
||||
|
||||
//! Calculates the intersection "i" right "of" the plane "abc".
|
||||
//! Calculates the intersection "i" right "of" the plane "abc" (TODO: ?)
|
||||
inline bool Intersect(const Math::Vector &a, const Math::Vector &b, const Math::Vector &c,
|
||||
const Math::Vector &d, const Math::Vector &e, Math::Vector &i)
|
||||
{
|
||||
|
@ -502,7 +553,7 @@ inline bool Intersect(const Math::Vector &a, const Math::Vector &b, const Math::
|
|||
}
|
||||
|
||||
//! Calculates the intersection of the straight line passing through p (x, z)
|
||||
/** Line is parallel to the y axis, with the plane abc. Returns p.y. */
|
||||
/** Line is parallel to the y axis, with the plane abc. Returns p.y. (TODO: ?) */
|
||||
inline bool IntersectY(const Math::Vector &a, const Math::Vector &b, const Math::Vector &c, Math::Vector &p)
|
||||
{
|
||||
float d = (b.x-a.x)*(c.z-a.z) - (c.x-a.x)*(b.z-a.z);
|
||||
|
@ -528,15 +579,18 @@ inline Math::Vector LookatPoint(const Math::Vector &eye, float angleH, float ang
|
|||
return lookat;
|
||||
}
|
||||
|
||||
//! TODO documentation
|
||||
//! Transforms the point \a p by matrix \a m
|
||||
/** Is equal to multiplying the matrix by the vector (of course without perspective divide). */
|
||||
inline Math::Vector Transform(const Math::Matrix &m, const Math::Vector &p)
|
||||
{
|
||||
return MatrixVectorMultiply(m, p);
|
||||
}
|
||||
|
||||
//! Calculates the projection of the point \a p on a straight line \a a to \a b.
|
||||
/** \a p point to project
|
||||
\a a,b two ends of the line */
|
||||
//! Calculates the projection of the point \a p on a straight line \a a to \a b
|
||||
/**
|
||||
* \param point to project
|
||||
* \param a,b two ends of the line
|
||||
*/
|
||||
inline Math::Vector Projection(const Math::Vector &a, const Math::Vector &b, const Math::Vector &p)
|
||||
{
|
||||
float k = DotProduct(b - a, p - a);
|
||||
|
|
|
@ -33,13 +33,14 @@
|
|||
namespace Math
|
||||
{
|
||||
|
||||
/** \struct Matrix math/matrix.h
|
||||
\brief 4x4 matrix
|
||||
|
||||
Represents an universal 4x4 matrix that can be used in OpenGL and DirectX engines.
|
||||
Contains the required methods for operating on matrices (inverting, multiplying, etc.).
|
||||
|
||||
The internal representation is a 16-value table in column-major order, thus:
|
||||
/**
|
||||
* \struct Matrix math/matrix.h
|
||||
* \brief 4x4 matrix
|
||||
*
|
||||
* Represents an universal 4x4 matrix that can be used in OpenGL and DirectX engines.
|
||||
* Contains the required methods for operating on matrices (inverting, multiplying, etc.).
|
||||
*
|
||||
* The internal representation is a 16-value table in column-major order, thus:
|
||||
|
||||
\verbatim
|
||||
m[0 ] m[4 ] m[8 ] m[12]
|
||||
|
@ -48,16 +49,16 @@ m[2 ] m[6 ] m[10] m[14]
|
|||
m[3 ] m[7 ] m[11] m[15]
|
||||
\endverbatim
|
||||
|
||||
This representation is native to OpenGL; DirectX requires transposing the matrix.
|
||||
|
||||
The order of multiplication of matrix and vector is also OpenGL-native
|
||||
(see the function MatrixVectorMultiply).
|
||||
|
||||
All methods are made inline to maximize optimization.
|
||||
|
||||
Unit tests for the structure and related functions are in module: math/test/matrix_test.cpp.
|
||||
|
||||
**/
|
||||
* This representation is native to OpenGL; DirectX requires transposing the matrix.
|
||||
*
|
||||
* The order of multiplication of matrix and vector is also OpenGL-native
|
||||
* (see the function MatrixVectorMultiply).
|
||||
*
|
||||
* All methods are made inline to maximize optimization.
|
||||
*
|
||||
* Unit tests for the structure and related functions are in module: math/test/matrix_test.cpp.
|
||||
*
|
||||
*/
|
||||
struct Matrix
|
||||
{
|
||||
//! Matrix values in column-major order
|
||||
|
@ -78,8 +79,10 @@ struct Matrix
|
|||
}
|
||||
|
||||
//! Creates the matrix from 2D array
|
||||
/** The array's first index is row, second is column.
|
||||
\a m array with values */
|
||||
/**
|
||||
* The array's first index is row, second is column.
|
||||
* \param m array with values
|
||||
*/
|
||||
inline explicit Matrix(const float (&m)[4][4])
|
||||
{
|
||||
for (int c = 0; c < 4; ++c)
|
||||
|
@ -91,11 +94,23 @@ struct Matrix
|
|||
}
|
||||
}
|
||||
|
||||
//! Sets value in given row and col
|
||||
/**
|
||||
* \param row row (0 to 3)
|
||||
* \param col column (0 to 3)
|
||||
* \param value value
|
||||
*/
|
||||
inline void Set(int row, int col, float value)
|
||||
{
|
||||
m[(col-1)*4+(row-1)] = value;
|
||||
}
|
||||
|
||||
//! Returns the value in given row and col
|
||||
/**
|
||||
* \param row row (0 to 3)
|
||||
* \param col column (0 to 3)
|
||||
* \returns value
|
||||
*/
|
||||
inline float Get(int row, int col)
|
||||
{
|
||||
return m[(col-1)*4+(row-1)];
|
||||
|
@ -148,9 +163,11 @@ struct Matrix
|
|||
}
|
||||
|
||||
//! Calculates the cofactor of the matrix
|
||||
/** \a r row (0 to 3)
|
||||
\a c column (0 to 3)
|
||||
\returns the cofactor */
|
||||
/**
|
||||
* \param r row (0 to 3)
|
||||
* \param c column (0 to 3)
|
||||
* \returns the cofactor
|
||||
*/
|
||||
inline float Cofactor(int r, int c) const
|
||||
{
|
||||
assert(r >= 0 && r <= 3);
|
||||
|
@ -330,8 +347,10 @@ struct Matrix
|
|||
}
|
||||
|
||||
//! Calculates the inverse matrix
|
||||
/** The determinant of the matrix must not be zero.
|
||||
\returns the inverted matrix */
|
||||
/**
|
||||
* The determinant of the matrix must not be zero.
|
||||
* \returns the inverted matrix
|
||||
*/
|
||||
inline Matrix Inverse() const
|
||||
{
|
||||
float d = Det();
|
||||
|
@ -352,8 +371,10 @@ struct Matrix
|
|||
}
|
||||
|
||||
//! Calculates the multiplication of this matrix * given matrix
|
||||
/** \a right right-hand matrix
|
||||
\returns multiplication result */
|
||||
/**
|
||||
* \param right right-hand matrix
|
||||
* \returns multiplication result
|
||||
*/
|
||||
inline Matrix Multiply(const Matrix &right) const
|
||||
{
|
||||
float result[16] = { 0.0f };
|
||||
|
|
|
@ -32,14 +32,14 @@
|
|||
namespace Math
|
||||
{
|
||||
|
||||
/** \struct Point math/point.h
|
||||
\brief 2D point
|
||||
|
||||
Represents a 2D point (x, y).
|
||||
Contains the required methods for operating on points.
|
||||
|
||||
All methods are made inline to maximize optimization.
|
||||
|
||||
/**
|
||||
* \struct Point
|
||||
* \brief 2D point
|
||||
*
|
||||
* Represents a 2D point (x, y).
|
||||
* Contains the required methods for operating on points.
|
||||
*
|
||||
* All methods are made inline to maximize optimization.
|
||||
*/
|
||||
struct Point
|
||||
{
|
||||
|
|
|
@ -1,33 +1,23 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
|
||||
add_executable(matrix_test matrix_test.cpp)
|
||||
add_executable(vector_test vector_test.cpp)
|
||||
add_executable(geometry_test geometry_test.cpp ../old/math3d.cpp ../old/d3dmath.cpp ../../graphics/d3d/d3dutil.cpp)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(matrix_test ./matrix_test)
|
||||
add_test(vector_test ./vector_test)
|
||||
add_test(geometry_test ./geometry_test)
|
||||
|
||||
# Change to DirectX SDK directory
|
||||
include_directories("c:/dxsdk/include")
|
||||
|
||||
add_definitions(-DSTRICT -DD3D_OVERLOADS)
|
||||
|
||||
# 'make check' will compile the required test programs
|
||||
# Note that 'make test' will still fail without compiled programs
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS matrix_test vector_test)
|
||||
|
||||
# Files to be removed in distclean
|
||||
set(REMOVE_FILES
|
||||
CMakeFiles Testing cmake_install.cmake CMakeCache.txt CTestTestfile.cmake Makefile
|
||||
./matrix_test
|
||||
./vector_test
|
||||
./geometry_test
|
||||
include_directories(
|
||||
.
|
||||
../../..
|
||||
${GTEST_DIR}/include
|
||||
)
|
||||
|
||||
add_custom_target(distclean COMMAND rm -rf ${REMOVE_FILES})
|
||||
add_executable(matrix_test matrix_test.cpp)
|
||||
target_link_libraries(matrix_test gtest)
|
||||
|
||||
add_executable(vector_test vector_test.cpp)
|
||||
target_link_libraries(vector_test gtest)
|
||||
|
||||
add_executable(geometry_test geometry_test.cpp)
|
||||
target_link_libraries(geometry_test gtest)
|
||||
|
||||
add_test(matrix_test matrix_test)
|
||||
add_test(vector_test vector_test)
|
||||
add_test(geometry_test geometry_test)
|
||||
|
|
|
@ -20,53 +20,41 @@
|
|||
|
||||
#include "../func.h"
|
||||
#include "../geometry.h"
|
||||
#include "../conv.h"
|
||||
#include "../../old/math3d.h"
|
||||
#include "../../old/d3dutil.h"
|
||||
|
||||
#include <d3d.h>
|
||||
#include <cstdio>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const float TEST_TOLERANCE = 1e-5;
|
||||
|
||||
|
||||
// Test for rewritten function RotateAngle()
|
||||
int TestRotateAngle()
|
||||
TEST(GeometryTest, RotateAngleTest)
|
||||
{
|
||||
if (! Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE))
|
||||
return __LINE__;
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
// Tests for other altered, complex or uncertain functions
|
||||
|
||||
/*
|
||||
|
||||
TODO: write meaningful tests with proper test values
|
||||
|
||||
int TestAngle()
|
||||
{
|
||||
const Math::Vector u(-0.0786076246943884, 0.2231249091714256, -1.1601361718477805);
|
||||
|
@ -360,42 +348,12 @@ int TestTransform()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
*/
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Functions to test
|
||||
int (*TESTS[])() =
|
||||
{
|
||||
TestRotateAngle,
|
||||
TestAngle,
|
||||
TestRotateView,
|
||||
TestLookatPoint,
|
||||
TestProjection,
|
||||
TestLoadViewMatrix,
|
||||
TestLoadProjectionMatrix,
|
||||
TestLoadTranslationMatrix,
|
||||
TestLoadScaleMatrix,
|
||||
TestLoadRotationXMatrix,
|
||||
TestLoadRotationYMatrix,
|
||||
TestLoadRotationZMatrix,
|
||||
TestLoadRotationMatrix,
|
||||
TestLoadRotationXZYMatrix,
|
||||
TestLoadRotationZXYMatrix,
|
||||
TestTransform
|
||||
};
|
||||
const int TESTS_SIZE = sizeof(TESTS) / sizeof(*TESTS);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
int result = 0;
|
||||
for (int i = 0; i < TESTS_SIZE; ++i)
|
||||
{
|
||||
result = TESTS[i]();
|
||||
if (result != 0)
|
||||
{
|
||||
fprintf(stderr, "Test function %d failed at line %d\n", i+1, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "All tests successful\n");
|
||||
|
||||
return 0;
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
#include "../func.h"
|
||||
#include "../matrix.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const float TEST_TOLERANCE = 1e-6;
|
||||
|
||||
int TestTranspose()
|
||||
|
||||
TEST(MatrixTest, TransposeTest)
|
||||
{
|
||||
const Math::Matrix mat(
|
||||
(float[4][4])
|
||||
|
@ -56,16 +56,10 @@ int TestTranspose()
|
|||
|
||||
Math::Matrix transpose = Math::Transpose(mat);
|
||||
|
||||
if (! Math::MatricesEqual(transpose, expectedTranspose, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Transpose mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::MatricesEqual(transpose, expectedTranspose, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int TestCofactor()
|
||||
TEST(MatrixTest, CofactorTest)
|
||||
{
|
||||
const Math::Matrix mat1(
|
||||
(float[4][4])
|
||||
|
@ -93,12 +87,7 @@ int TestCofactor()
|
|||
{
|
||||
float ret = mat1.Cofactor(r, c);
|
||||
float exp = expectedCofactors1.m[4*c+r];
|
||||
if (! Math::IsEqual(ret, exp, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Cofactors 1 mismatch!\n");
|
||||
fprintf(stderr, "r=%d, c=%d, %f (returned) != %f (expected)\n", r, c, ret, exp);
|
||||
return __LINE__;
|
||||
}
|
||||
EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,19 +118,12 @@ int TestCofactor()
|
|||
{
|
||||
float ret = mat2.Cofactor(r, c);
|
||||
float exp = expectedCofactors2.m[4*c+r];
|
||||
if (! Math::IsEqual(ret, exp, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Cofactors 2 mismatch!\n");
|
||||
fprintf(stderr, "r=%d, c=%d, %f (returned) != %f (expected)\n", r, c, ret, exp);
|
||||
return __LINE__;
|
||||
}
|
||||
EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TestDet()
|
||||
TEST(MatrixTest, DetTest)
|
||||
{
|
||||
const Math::Matrix mat1(
|
||||
(float[4][4])
|
||||
|
@ -156,12 +138,7 @@ int TestDet()
|
|||
const float expectedDet1 = 4.07415413729671;
|
||||
|
||||
float ret1 = mat1.Det();
|
||||
if (! Math::IsEqual(ret1, expectedDet1, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Det mismatch!\n");
|
||||
fprintf(stderr, "%f (returned) != %f (expected)\n", ret1, expectedDet1);
|
||||
return __LINE__;
|
||||
}
|
||||
EXPECT_TRUE(Math::IsEqual(ret1, expectedDet1, TEST_TOLERANCE));
|
||||
|
||||
const Math::Matrix mat2(
|
||||
(float[4][4])
|
||||
|
@ -176,17 +153,10 @@ int TestDet()
|
|||
const float expectedDet2 = -6.35122307880942;
|
||||
|
||||
float ret2 = mat2.Det();
|
||||
if (! Math::IsEqual(ret2, expectedDet2, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Det mismatch!\n");
|
||||
fprintf(stderr, "%f (returned) != %f (expected)\n", ret2, expectedDet2);
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::IsEqual(ret2, expectedDet2, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int TestInverse()
|
||||
TEST(MatrixTest, InverseTest)
|
||||
{
|
||||
const Math::Matrix mat1(
|
||||
(float[4][4])
|
||||
|
@ -210,11 +180,7 @@ int TestInverse()
|
|||
|
||||
Math::Matrix inverse1 = mat1.Inverse();
|
||||
|
||||
if (! Math::MatricesEqual(inverse1, expectedInverse1, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Inverse 1 mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
EXPECT_TRUE(Math::MatricesEqual(inverse1, expectedInverse1, TEST_TOLERANCE));
|
||||
|
||||
const Math::Matrix mat2(
|
||||
(float[4][4])
|
||||
|
@ -238,16 +204,10 @@ int TestInverse()
|
|||
|
||||
Math::Matrix inverse2 = mat2.Inverse();
|
||||
|
||||
if (! Math::MatricesEqual(inverse2, expectedInverse2, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Inverse 2 mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::MatricesEqual(inverse2, expectedInverse2, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int TestMultiply()
|
||||
TEST(MatrixTest, MultiplyTest)
|
||||
{
|
||||
const Math::Matrix mat1A(
|
||||
(float[4][4])
|
||||
|
@ -280,11 +240,7 @@ int TestMultiply()
|
|||
);
|
||||
|
||||
Math::Matrix multiply1 = Math::MultiplyMatrices(mat1A, mat1B);
|
||||
if (! Math::MatricesEqual(multiply1, expectedMultiply1, TEST_TOLERANCE ) )
|
||||
{
|
||||
fprintf(stderr, "Multiply 1 mismath!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
EXPECT_TRUE(Math::MatricesEqual(multiply1, expectedMultiply1, TEST_TOLERANCE));
|
||||
|
||||
const Math::Matrix mat2A(
|
||||
(float[4][4])
|
||||
|
@ -317,16 +273,10 @@ int TestMultiply()
|
|||
);
|
||||
|
||||
Math::Matrix multiply2 = Math::MultiplyMatrices(mat2A, mat2B);
|
||||
if (! Math::MatricesEqual(multiply2, expectedMultiply2, TEST_TOLERANCE ) )
|
||||
{
|
||||
fprintf(stderr, "Multiply 2 mismath!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::MatricesEqual(multiply2, expectedMultiply2, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int TestMultiplyVector()
|
||||
TEST(MatrixTest, MultiplyVectorTest)
|
||||
{
|
||||
const Math::Matrix mat1(
|
||||
(float[4][4])
|
||||
|
@ -343,11 +293,7 @@ int TestMultiplyVector()
|
|||
const Math::Vector expectedMultiply1(0.608932463260470, -1.356893266403749, 3.457156276255142);
|
||||
|
||||
Math::Vector multiply1 = Math::MatrixVectorMultiply(mat1, vec1, false);
|
||||
if (! Math::VectorsEqual(multiply1, expectedMultiply1, TEST_TOLERANCE ) )
|
||||
{
|
||||
fprintf(stderr, "Multiply vector 1 mismath!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
EXPECT_TRUE(Math::VectorsEqual(multiply1, expectedMultiply1, TEST_TOLERANCE));
|
||||
|
||||
const Math::Matrix mat2(
|
||||
(float[4][4])
|
||||
|
@ -364,39 +310,13 @@ int TestMultiplyVector()
|
|||
const Math::Vector expectedMultiply2(0.2816820577317669, 0.0334468811767428, 0.1996974284970455);
|
||||
|
||||
Math::Vector multiply2 = Math::MatrixVectorMultiply(mat2, vec2, true);
|
||||
if (! Math::VectorsEqual(multiply2, expectedMultiply2, TEST_TOLERANCE ) )
|
||||
{
|
||||
fprintf(stderr, "Multiply vector 2 mismath!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::VectorsEqual(multiply2, expectedMultiply2, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int main()
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Functions to test
|
||||
int (*TESTS[])() =
|
||||
{
|
||||
TestTranspose,
|
||||
TestCofactor,
|
||||
TestDet,
|
||||
TestInverse,
|
||||
TestMultiply,
|
||||
TestMultiplyVector
|
||||
};
|
||||
const int TESTS_SIZE = sizeof(TESTS) / sizeof(*TESTS);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
int result = 0;
|
||||
for (int i = 0; i < TESTS_SIZE; ++i)
|
||||
{
|
||||
result = TESTS[i]();
|
||||
if (result != 0)
|
||||
return result;
|
||||
}
|
||||
|
||||
fprintf(stderr, "All tests successful\n");
|
||||
|
||||
return 0;
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,59 +26,41 @@
|
|||
#include "../func.h"
|
||||
#include "../vector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const float TEST_TOLERANCE = 1e-6;
|
||||
|
||||
int TestLength()
|
||||
|
||||
TEST(VectorTest, LengthTest)
|
||||
{
|
||||
Math::Vector vec(-1.288447945923275, 0.681452565308134, -0.633761098985957);
|
||||
const float expectedLength = 1.58938001708428;
|
||||
|
||||
if (! Math::IsEqual(vec.Length(), expectedLength, TEST_TOLERANCE) )
|
||||
{
|
||||
fprintf(stderr, "Length mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::IsEqual(vec.Length(), expectedLength, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int TestNormalize()
|
||||
TEST(VectorTest, NormalizeTest)
|
||||
{
|
||||
Math::Vector vec(1.848877241804398, -0.157262961268577, -1.963031403332377);
|
||||
const Math::Vector expectedNormalized(0.6844609421393856, -0.0582193085618106, -0.7267212194481797);
|
||||
|
||||
vec.Normalize();
|
||||
|
||||
if (! Math::VectorsEqual(vec, expectedNormalized, TEST_TOLERANCE))
|
||||
{
|
||||
fprintf(stderr, "Normalize mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::VectorsEqual(vec, expectedNormalized, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int TestDot()
|
||||
TEST(VectorTest, DotTest)
|
||||
{
|
||||
Math::Vector vecA(0.8202190530968309, 0.0130926060162780, 0.2411914183883510);
|
||||
Math::Vector vecB(-0.0524083951404069, 1.5564932716738220, -0.8971342631500536);
|
||||
|
||||
float expectedDot = -0.238988896477326;
|
||||
|
||||
if (! Math::IsEqual(Math::DotProduct(vecA, vecB), expectedDot, TEST_TOLERANCE) )
|
||||
{
|
||||
fprintf(stderr, "Dot product mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::IsEqual(Math::DotProduct(vecA, vecB), expectedDot, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int TestCross()
|
||||
TEST(VectorTest, CrossTest)
|
||||
{
|
||||
Math::Vector vecA(1.37380499798567, 1.18054518384682, 1.95166361293121);
|
||||
Math::Vector vecB(0.891657855926886, 0.447591335394532, -0.901604070087823);
|
||||
|
@ -86,42 +68,14 @@ int TestCross()
|
|||
Math::Vector expectedCross(-1.937932065431669, 2.978844370287636, -0.437739173833581);
|
||||
Math::Vector expectedReverseCross = -expectedCross;
|
||||
|
||||
if (! Math::VectorsEqual(vecA.CrossMultiply(vecB), expectedCross, TEST_TOLERANCE) )
|
||||
{
|
||||
fprintf(stderr, "Cross product mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
EXPECT_TRUE(Math::VectorsEqual(vecA.CrossMultiply(vecB), expectedCross, TEST_TOLERANCE));
|
||||
|
||||
if (! Math::VectorsEqual(vecB.CrossMultiply(vecA), expectedReverseCross, TEST_TOLERANCE) )
|
||||
{
|
||||
fprintf(stderr, "Reverse cross product mismatch!\n");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXPECT_TRUE(Math::VectorsEqual(vecB.CrossMultiply(vecA), expectedReverseCross, TEST_TOLERANCE));
|
||||
}
|
||||
|
||||
int main()
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Functions to test
|
||||
int (*TESTS[])() =
|
||||
{
|
||||
TestLength,
|
||||
TestNormalize,
|
||||
TestDot,
|
||||
TestCross
|
||||
};
|
||||
const int TESTS_SIZE = sizeof(TESTS) / sizeof(*TESTS);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
int result = 0;
|
||||
for (int i = 0; i < TESTS_SIZE; ++i)
|
||||
{
|
||||
result = TESTS[i]();
|
||||
if (result != 0)
|
||||
return result;
|
||||
}
|
||||
|
||||
fprintf(stderr, "All tests successful\n");
|
||||
|
||||
return 0;
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -32,16 +32,17 @@
|
|||
namespace Math
|
||||
{
|
||||
|
||||
/** \struct Vector math/vector.h
|
||||
\brief 3D (3x1) vector
|
||||
|
||||
Represents a universal 3x1 vector that can be used in OpenGL and DirectX engines.
|
||||
Contains the required methods for operating on vectors.
|
||||
|
||||
All methods are made inline to maximize optimization.
|
||||
|
||||
Unit tests for the structure and related functions are in module: math/test/vector_test.cpp.
|
||||
|
||||
/**
|
||||
* \struct Vector
|
||||
* \brief 3D (3x1) vector
|
||||
*
|
||||
* Represents a universal 3x1 vector that can be used in OpenGL and DirectX engines.
|
||||
* Contains the required methods for operating on vectors.
|
||||
*
|
||||
* All methods are made inline to maximize optimization.
|
||||
*
|
||||
* Unit tests for the structure and related functions are in module: math/test/vector_test.cpp.
|
||||
*
|
||||
*/
|
||||
struct Vector
|
||||
{
|
||||
|
@ -103,8 +104,10 @@ struct Vector
|
|||
}
|
||||
|
||||
//! Calculates the cross product with another vector
|
||||
/** \a right right-hand side vector
|
||||
\returns the cross product*/
|
||||
/**
|
||||
* \param right right-hand side vector
|
||||
* \returns the cross product
|
||||
*/
|
||||
inline Vector CrossMultiply(const Vector &right) const
|
||||
{
|
||||
float px = y * right.z - z * right.y;
|
||||
|
@ -114,8 +117,10 @@ struct Vector
|
|||
}
|
||||
|
||||
//! Calculates the dot product with another vector
|
||||
/** \a right right-hand side vector
|
||||
\returns the dot product */
|
||||
/**
|
||||
* \param right right-hand side vector
|
||||
* \returns the dot product
|
||||
*/
|
||||
inline float DotMultiply(const Vector &right) const
|
||||
{
|
||||
return x * right.x + y * right.y + z * right.z;
|
||||
|
@ -218,7 +223,7 @@ struct Vector
|
|||
return s.str();
|
||||
}
|
||||
|
||||
}; // struct Point
|
||||
}; // struct Vector
|
||||
|
||||
//! Checks if two vectors are equal within given \a tolerance
|
||||
inline bool VectorsEqual(const Math::Vector &a, const Math::Vector &b, float tolerance = TOLERANCE)
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/auto.h"
|
||||
|
||||
|
||||
|
@ -26,7 +24,8 @@
|
|||
#include "ui/gauge.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/global.h"
|
||||
#include "object/object.h"
|
||||
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoconvert.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -27,7 +25,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoderrick.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -28,7 +26,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float DERRICK_DELAY = 10.0f; // duration of the extraction
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autodestroyer.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -25,7 +23,8 @@
|
|||
#include "ui/interface.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,15 +16,14 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoegg.h"
|
||||
|
||||
#include "math/geometry.h"
|
||||
#include "common/iman.h"
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoenergy.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -29,6 +27,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float ENERGY_POWER = 0.4f; // Necessary energy for a battery
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autofactory.h"
|
||||
|
||||
#include "common/global.h"
|
||||
|
@ -30,7 +28,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoflag.h"
|
||||
|
||||
#include "math/geometry.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
#define ADJUST_ANGLE false // true -> adjusts the angles of the members
|
||||
|
|
|
@ -16,14 +16,12 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autohuston.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoinfo.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
@ -25,7 +23,8 @@
|
|||
#include "ui/list.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autojostle.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,13 +16,12 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autokid.h"
|
||||
|
||||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/water.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autolabo.h"
|
||||
|
||||
#include "common/global.h"
|
||||
|
@ -29,6 +27,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float LABO_DELAY = 20.0f; // duration of the analysis
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/automush.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,15 +16,14 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autonest.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autonuclear.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -27,6 +25,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float NUCLEAR_DELAY = 30.0f; // duration of the generation
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autopara.h"
|
||||
|
||||
|
||||
|
@ -27,6 +25,8 @@
|
|||
#include "ui/interface.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,14 +16,13 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoportico.h"
|
||||
|
||||
|
||||
#include "object/robotmain.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const int PARAM_DEPOSE = 2; // run=2 -> deposits the spaceship
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoradar.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -26,6 +24,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/gauge.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autorepair.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -26,6 +24,9 @@
|
|||
#include "ui/interface.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoresearch.h"
|
||||
|
||||
#include "common/global.h"
|
||||
|
@ -29,6 +27,8 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float SEARCH_TIME = 30.0f; // duration of a research
|
||||
|
|
|
@ -15,15 +15,13 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autoroot.h"
|
||||
|
||||
#include "graphics/engine/particle.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
#include "math/geometry.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autosafe.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -27,6 +25,9 @@
|
|||
#include "ui/interface.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float OPEN_DELAY = 8.0f; // duration of opening
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autostation.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -28,7 +26,7 @@
|
|||
#include "ui/gauge.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/auto/autotower.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
|
@ -29,6 +27,9 @@
|
|||
#include "ui/window.h"
|
||||
#include "ui/gauge.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float TOWER_SCOPE = 200.0f; // range of beam
|
||||
const float ENERGY_FIRE = 0.125f; // energy consumed by fire
|
||||
|
|
|
@ -15,57 +15,23 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
// #include <stdio.h>
|
||||
//
|
||||
#include "object/brain.h"
|
||||
//
|
||||
// #include "CBot/CBotDll.h"
|
||||
// #include "common/struct.h"
|
||||
// #include "math/geometry.h"
|
||||
// #include "math/const.h"
|
||||
// #include "old/d3dengine.h"
|
||||
// #include "old/d3dmath.h"
|
||||
// #include "common/language.h"
|
||||
// #include "common/global.h"
|
||||
// #include "common/event.h"
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/iman.h"
|
||||
// #include "common/restext.h"
|
||||
// #include "old/math3d.h"
|
||||
// #include "object/robotmain.h"
|
||||
#include "graphics/core/color.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
// #include "old/water.h"
|
||||
// #include "old/camera.h"
|
||||
// #include "object/object.h"
|
||||
// #include "physics/physics.h"
|
||||
// #include "object/motion/motion.h"
|
||||
// #include "object/motion/motionspider.h"
|
||||
// #include "old/pyro.h"
|
||||
#include "object/motion/motion.h"
|
||||
#include "object/task/taskmanager.h"
|
||||
// #include "object/task/task.h"
|
||||
// #include "object/task/taskmanip.h"
|
||||
// #include "object/task/taskflag.h"
|
||||
// #include "object/task/taskshield.h"
|
||||
#include "script/script.h"
|
||||
// #include "ui/studio.h"
|
||||
#include "ui/interface.h"
|
||||
// #include "ui/button.h"
|
||||
// #include "ui/color.h"
|
||||
// #include "ui/edit.h"
|
||||
// #include "ui/list.h"
|
||||
// #include "ui/label.h"
|
||||
// #include "ui/group.h"
|
||||
// #include "ui/gauge.h"
|
||||
#include "ui/slider.h"
|
||||
// #include "ui/compass.h"
|
||||
// #include "ui/target.h"
|
||||
#include "ui/window.h"
|
||||
// #include "ui/displaytext.h"
|
||||
// #include "old/text.h"
|
||||
#include "sound/sound.h"
|
||||
// #include "old/particule.h"
|
||||
#include "physics/physics.h"
|
||||
#include "script/cmdtoken.h"
|
||||
#include "script/script.h"
|
||||
#include "sound/sound.h"
|
||||
#include "ui/displaytext.h"
|
||||
#include "ui/interface.h"
|
||||
#include "ui/slider.h"
|
||||
#include "ui/studio.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
|
||||
|
||||
|
@ -96,8 +62,7 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
|
|||
m_motion = 0;
|
||||
m_primaryTask = 0;
|
||||
m_secondaryTask = 0;
|
||||
// TODO uncoment when ui/studio will be implemented.
|
||||
// m_studio = 0;
|
||||
m_studio = 0;
|
||||
|
||||
m_program = -1;
|
||||
m_bActivity = true;
|
||||
|
@ -144,8 +109,7 @@ CBrain::~CBrain()
|
|||
|
||||
delete m_primaryTask;
|
||||
delete m_secondaryTask;
|
||||
// TODO uncoment when ui/studio will be implemented.
|
||||
// delete m_studio;
|
||||
delete m_studio;
|
||||
delete m_traceRecordBuffer;
|
||||
m_iMan->DeleteInstance(CLASS_BRAIN, this);
|
||||
}
|
||||
|
@ -172,8 +136,7 @@ void CBrain::DeleteObject(bool bAll)
|
|||
}
|
||||
}
|
||||
|
||||
// TODO uncoment when ui/studio will be implemented.
|
||||
// if ( m_studio != 0 ) // current edition?
|
||||
if ( m_studio != 0 ) // current edition?
|
||||
{
|
||||
StopEditScript(true);
|
||||
}
|
||||
|
@ -239,9 +202,12 @@ bool CBrain::EventProcess(const Event &event)
|
|||
|
||||
action = EVENT_NULL;
|
||||
|
||||
CApplication* app = CApplication::GetInstancePointer();
|
||||
|
||||
if ( event.type == EVENT_KEY_DOWN &&
|
||||
(event.param == m_engine->GetKey(KEYRANK_ACTION, 0) ||
|
||||
event.param == m_engine->GetKey(KEYRANK_ACTION, 1) ) &&
|
||||
(event.key.key == app->GetInputBinding(INPUT_SLOT_ACTION).key
|
||||
/* TODO joystick input binding
|
||||
event.param == app->GetInputBinding(INPUT_SLOT_ACTION).joy*/ ) &&
|
||||
!m_main->GetEditLock() )
|
||||
{
|
||||
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
|
||||
|
@ -250,7 +216,7 @@ bool CBrain::EventProcess(const Event &event)
|
|||
pc = pw->SearchControl(m_defaultEnter);
|
||||
if ( pc != 0 )
|
||||
{
|
||||
if ( pc->TestState(STATE_ENABLE) )
|
||||
if ( pc->TestState(Ui::STATE_ENABLE) )
|
||||
{
|
||||
action = m_defaultEnter;
|
||||
}
|
||||
|
@ -274,9 +240,8 @@ bool CBrain::EventProcess(const Event &event)
|
|||
EventFrame(event);
|
||||
}
|
||||
|
||||
// TODO uncoment when ui/studio will be implemented.
|
||||
if ( m_object->GetSelect() && // robot selected?
|
||||
/* m_studio != 0 */ ) // current issue?
|
||||
m_studio != 0 ) // current issue?
|
||||
{
|
||||
// m_studio->EventProcess(event);
|
||||
|
||||
|
@ -394,8 +359,7 @@ bool CBrain::EventProcess(const Event &event)
|
|||
{
|
||||
m_buttonAxe = action;
|
||||
}
|
||||
if ( action == EVENT_LBUTTONUP ||
|
||||
action == EVENT_RBUTTONUP )
|
||||
if ( action == EVENT_MOUSE_BUTTON_UP )
|
||||
{
|
||||
m_buttonAxe = EVENT_NULL;
|
||||
}
|
||||
|
@ -770,11 +734,10 @@ bool CBrain::EventFrame(const Event &event)
|
|||
m_sound->Position(m_soundChannelAlarm, m_object->GetPosition(0));
|
||||
}
|
||||
|
||||
// TODO uncoment when ui/studio will be implemented.
|
||||
// if ( m_studio != 0 ) // current edition?
|
||||
// {
|
||||
// m_studio->EventProcess(event);
|
||||
// }
|
||||
if ( m_studio != 0 ) // current edition?
|
||||
{
|
||||
m_studio->EventProcess(event);
|
||||
}
|
||||
|
||||
UpdateInterface(event.rTime);
|
||||
|
||||
|
@ -826,7 +789,7 @@ void CBrain::StopProgram()
|
|||
|
||||
UpdateInterface();
|
||||
m_main->UpdateShortcuts();
|
||||
m_object->CreateSelectParticule();
|
||||
m_object->CreateSelectParticle();
|
||||
}
|
||||
|
||||
// Stops the current task.
|
||||
|
@ -897,9 +860,8 @@ void CBrain::StartEditScript(int rank, char* name)
|
|||
m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
|
||||
}
|
||||
|
||||
// TODO uncoment when ui/studio will be implemented.
|
||||
// m_studio = new CStudio(m_iMan);
|
||||
// m_studio->StartEditScript(m_script[rank], name, rank);
|
||||
m_studio = new Ui::CStudio();
|
||||
m_studio->StartEditScript(m_script[rank], name, rank);
|
||||
}
|
||||
|
||||
// End of editing a program.
|
||||
|
@ -908,11 +870,10 @@ void CBrain::StopEditScript(bool bCancel)
|
|||
{
|
||||
if ( !bCancel ) SetActiveVirus(false);
|
||||
|
||||
// TODO uncoment when ui/studio will be implemented.
|
||||
// if ( !m_studio->StopEditScript(bCancel) ) return;
|
||||
if ( !m_studio->StopEditScript(bCancel) ) return;
|
||||
|
||||
// delete m_studio;
|
||||
// m_studio = 0;
|
||||
delete m_studio;
|
||||
m_studio = 0;
|
||||
|
||||
CreateInterface(true); // puts the control buttons
|
||||
}
|
||||
|
@ -1506,19 +1467,19 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
pos.x = ox+sx*10.1f;
|
||||
pos.y = oy+sy*2.0f-ddim.y;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORb);
|
||||
pc->SetColor(GetColor(Gfx::Color(0.28f, 0.56f, 1.0f, 0.0f)));
|
||||
pc->SetColor(Gfx::Color(0.28f, 0.56f, 1.0f, 0.0f));
|
||||
pos.x += ddim.x;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORr);
|
||||
pc->SetColor(GetColor(Gfx::Color(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
pc->SetColor(Gfx::Color(1.0f, 0.0f, 0.0f, 0.0f));
|
||||
pos.x += ddim.x;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORg);
|
||||
pc->SetColor(GetColor(Gfx::Color(0.0f, 0.8f, 0.0f, 0.0f)));
|
||||
pc->SetColor(Gfx::Color(0.0f, 0.8f, 0.0f, 0.0f));
|
||||
pos.x += ddim.x;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORy);
|
||||
pc->SetColor(GetColor(Gfx::Color(1.0f, 0.93f, 0.0f, 0.0f); //0x00ffec00
|
||||
pc->SetColor(Gfx::Color(1.0f, 0.93f, 0.0f, 0.0f)); //0x00ffec00
|
||||
pos.x += ddim.x;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORv);
|
||||
pc->SetColor(GetColor(Gfx::Color(0.82f, 0.004f, 0.99f, 0.0f); //0x00d101fe
|
||||
pc->SetColor(Gfx::Color(0.82f, 0.004f, 0.99f, 0.0f)); //0x00d101fe
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1577,7 +1538,7 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
ddim.x = dim.x*0.5f;
|
||||
ddim.y = dim.y*2.0f;
|
||||
ps = pw->CreateSlider(pos, ddim, 0, EVENT_OBJECT_DIMSHIELD);
|
||||
ps->SetState(STATE_VALUE);
|
||||
ps->SetState(Ui::STATE_VALUE);
|
||||
ps->SetLimit((RADIUS_SHIELD_MIN/g_unit), (RADIUS_SHIELD_MAX/g_unit));
|
||||
ps->SetArrowStep(1.0f);
|
||||
}
|
||||
|
@ -1628,35 +1589,35 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
pos.x = ox+sx*10.15f;
|
||||
pos.y = oy+sy*1.50f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN1); // black
|
||||
pc->SetColor(GetColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)));
|
||||
pc->SetColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
pos.x = ox+sx*10.65f;
|
||||
pos.y = oy+sy*1.25f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN2); // yellow
|
||||
pc->SetColor(GetColor(Gfx::Color(1.0f, 1.0f, 0.0f, 0.0f )));
|
||||
pc->SetColor(Gfx::Color(1.0f, 1.0f, 0.0f, 0.0f ));
|
||||
pos.x = ox+sx*10.90f;
|
||||
pos.y = oy+sy*0.75f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN3); // orange
|
||||
pc->SetColor(GetColor(Gfx::Color(1.0f, 0.53f, 0x00, 0x00)));
|
||||
pc->SetColor(Gfx::Color(1.0f, 0.53f, 0x00, 0x00));
|
||||
pos.x = ox+sx*10.65f;
|
||||
pos.y = oy+sy*0.25f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN4); // red
|
||||
pc->SetColor(GetColor(Gfx::Color(1.0f, 0.0f, 0.0f, 0.0f)));
|
||||
pc->SetColor(Gfx::Color(1.0f, 0.0f, 0.0f, 0.0f));
|
||||
pos.x = ox+sx*10.15f;
|
||||
pos.y = oy+sy*0.00f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN5); // violet
|
||||
pc->SetColor(GetColor(Gfx::Color(1.0f, 0.0f, 1.0f 0.0f )));
|
||||
pc->SetColor(Gfx::Color(1.0f, 0.0f, 1.0f, 0.0f));
|
||||
pos.x = ox+sx*9.65f;
|
||||
pos.y = oy+sy*0.25f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN6); // blue
|
||||
pc->SetColor(GetColor(Gfx::Color(0.0f, 0.4f, 1.0f, 0.0f)));//0x000066ff));
|
||||
pc->SetColor(Gfx::Color(0.0f, 0.4f, 1.0f, 0.0f));//0x000066ff));
|
||||
pos.x = ox+sx*9.40f;
|
||||
pos.y = oy+sy*0.75f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN7); // green
|
||||
pc->SetColor(GetColor(Gfx::Color(0.0f, 0.0f, 0.8f, 0.0f)));//0x0000cc00));
|
||||
pc->SetColor(Gfx::Color(0.0f, 0.0f, 0.8f, 0.0f));//0x0000cc00));
|
||||
pos.x = ox+sx*9.65f;
|
||||
pos.y = oy+sy*1.25f;
|
||||
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN8); // brown
|
||||
pc->SetColor(GetColor(Gfx::Color(0.53f, 0.27f, 0.0f, 0.0f)));//0x00884400));
|
||||
pc->SetColor(Gfx::Color(0.53f, 0.27f, 0.0f, 0.0f));//0x00884400));
|
||||
|
||||
pos.x = ox+sx*6.9f;
|
||||
pos.y = oy+sy*1.2f;
|
||||
|
@ -1869,7 +1830,7 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
pc = (CCompass*)pw->SearchControl(EVENT_OBJECT_COMPASS);
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_VISIBLE, m_main->GetShowMap());
|
||||
pc->SetState(Ui::STATE_VISIBLE, m_main->GetShowMap());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1895,7 +1856,7 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
ddim.x = 600.0f/640.0f;
|
||||
ddim.y = 340.0f/480.0f;
|
||||
pt = pw->CreateTarget(pos, ddim, 0, EVENT_OBJECT_TARGET);
|
||||
pt->ClearState(STATE_GLINT);
|
||||
pt->ClearState(Ui::STATE_GLINT);
|
||||
}
|
||||
|
||||
ddim.x = 64.0f/640.0f;
|
||||
|
@ -1935,14 +1896,14 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
void CBrain::UpdateInterface(float rTime)
|
||||
{
|
||||
Ui::CWindow* pw;
|
||||
#if _TEEN
|
||||
CButton* pb;
|
||||
#endif
|
||||
CGauge* pg;
|
||||
CCompass* pc;
|
||||
CGroup* pgr;
|
||||
CTarget* ptg;
|
||||
CObject* power;
|
||||
/* TODO: #if _TEEN
|
||||
Ui::CButton* pb;
|
||||
#endif*/
|
||||
Ui::CGauge* pg;
|
||||
Ui::CCompass* pc;
|
||||
Ui::CGroup* pgr;
|
||||
Ui::CTarget* ptg;
|
||||
CObject* power;
|
||||
Math::Vector pos, hPos;
|
||||
Math::Point ppos;
|
||||
float energy, limit, angle, range;
|
||||
|
@ -2045,7 +2006,7 @@ void CBrain::UpdateInterface(float rTime)
|
|||
angle = -(m_object->GetAngleY(0)+Math::PI/2.0f);
|
||||
pc->SetDirection(angle);
|
||||
|
||||
pc->SetState(STATE_VISIBLE, m_main->GetShowMap());
|
||||
pc->SetState(Ui::STATE_VISIBLE, m_main->GetShowMap());
|
||||
}
|
||||
|
||||
#if _TEEN
|
||||
|
@ -2054,16 +2015,16 @@ void CBrain::UpdateInterface(float rTime)
|
|||
{
|
||||
if ( m_bTraceRecord && Math::Mod(m_time, 0.4f) >= 0.2f )
|
||||
{
|
||||
pb->SetState(STATE_CHECK);
|
||||
pb->SetState(Ui::STATE_CHECK);
|
||||
}
|
||||
else
|
||||
{
|
||||
pb->ClearState(STATE_CHECK);
|
||||
pb->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bOnBoard = m_camera->GetType() == CAMERA_ONBOARD;
|
||||
bOnBoard = m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD;
|
||||
|
||||
pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CROSSHAIR));
|
||||
if ( pgr != 0 )
|
||||
|
@ -2087,11 +2048,11 @@ void CBrain::UpdateInterface(float rTime)
|
|||
ppos.y += m_object->GetGunGoalV()/1.3f;
|
||||
pgr->SetPos(ppos);
|
||||
#endif
|
||||
pgr->SetState(STATE_VISIBLE, !m_main->GetFriendAim());
|
||||
pgr->SetState(Ui::STATE_VISIBLE, !m_main->GetFriendAim());
|
||||
}
|
||||
else
|
||||
{
|
||||
pgr->ClearState(STATE_VISIBLE);
|
||||
pgr->ClearState(Ui::STATE_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2100,36 +2061,36 @@ void CBrain::UpdateInterface(float rTime)
|
|||
{
|
||||
if ( bOnBoard )
|
||||
{
|
||||
ptg->SetState(STATE_VISIBLE);
|
||||
ptg->SetState(Ui::STATE_VISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptg->ClearState(STATE_VISIBLE);
|
||||
ptg->ClearState(Ui::STATE_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERul));
|
||||
if ( pgr != 0 )
|
||||
{
|
||||
pgr->SetState(STATE_VISIBLE, bOnBoard);
|
||||
pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
|
||||
}
|
||||
|
||||
pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERur));
|
||||
if ( pgr != 0 )
|
||||
{
|
||||
pgr->SetState(STATE_VISIBLE, bOnBoard);
|
||||
pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
|
||||
}
|
||||
|
||||
pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERdl));
|
||||
if ( pgr != 0 )
|
||||
{
|
||||
pgr->SetState(STATE_VISIBLE, bOnBoard);
|
||||
pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
|
||||
}
|
||||
|
||||
pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERdr));
|
||||
if ( pgr != 0 )
|
||||
{
|
||||
pgr->SetState(STATE_VISIBLE, bOnBoard);
|
||||
pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2213,7 +2174,7 @@ void CBrain::UpdateInterface()
|
|||
pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_GFLAT));
|
||||
if ( pb != 0 )
|
||||
{
|
||||
pb->SetState(STATE_VISIBLE, m_engine->GetGroundSpot());
|
||||
pb->SetState(Ui::STATE_VISIBLE, m_engine->GetGroundSpot());
|
||||
}
|
||||
|
||||
if ( type == OBJECT_HUMAN || // builder?
|
||||
|
@ -2347,49 +2308,49 @@ void CBrain::UpdateInterface()
|
|||
pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_PEN0));
|
||||
if ( pb != 0 )
|
||||
{
|
||||
pb->ClearState(STATE_CHECK);
|
||||
pb->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
|
||||
color = m_object->GetTraceColor();
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN1));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==1);
|
||||
pc->SetState(Ui::STATE_CHECK, color==1);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN2));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==8);
|
||||
pc->SetState(Ui::STATE_CHECK, color==8);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN3));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==7);
|
||||
pc->SetState(Ui::STATE_CHECK, color==7);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN4));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==4);
|
||||
pc->SetState(Ui::STATE_CHECK, color==4);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN5));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==6);
|
||||
pc->SetState(Ui::STATE_CHECK, color==6);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN6));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==14);
|
||||
pc->SetState(Ui::STATE_CHECK, color==14);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN7));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==12);
|
||||
pc->SetState(Ui::STATE_CHECK, color==12);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN8));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->SetState(STATE_CHECK, color==10);
|
||||
pc->SetState(Ui::STATE_CHECK, color==10);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2397,48 +2358,48 @@ void CBrain::UpdateInterface()
|
|||
pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_PEN0));
|
||||
if ( pb != 0 )
|
||||
{
|
||||
pb->SetState(STATE_CHECK);
|
||||
pb->SetState(Ui::STATE_CHECK);
|
||||
}
|
||||
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN1));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN2));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN3));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN4));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN5));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN6));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN7));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN8));
|
||||
if ( pc != 0 )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK);
|
||||
pc->ClearState(Ui::STATE_CHECK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2535,7 +2496,7 @@ void CBrain::CheckInterface(Ui::CWindow *pw, EventType event, bool bState)
|
|||
control = pw->SearchControl(event);
|
||||
if ( control == 0 ) return;
|
||||
|
||||
control->SetState(STATE_CHECK, bState);
|
||||
control->SetState(Ui::STATE_CHECK, bState);
|
||||
}
|
||||
|
||||
// Changes the state of a button interface.
|
||||
|
@ -2547,7 +2508,7 @@ void CBrain::EnableInterface(Ui::CWindow *pw, EventType event, bool bState)
|
|||
control = pw->SearchControl(event);
|
||||
if ( control == 0 ) return;
|
||||
|
||||
control->SetState(STATE_ENABLE, bState);
|
||||
control->SetState(Ui::STATE_ENABLE, bState);
|
||||
}
|
||||
|
||||
// Changes the state of a button on the interface.
|
||||
|
@ -2559,7 +2520,7 @@ void CBrain::DeadInterface(Ui::CWindow *pw, EventType event, bool bState)
|
|||
control = pw->SearchControl(event);
|
||||
if ( control == 0 ) return;
|
||||
|
||||
control->SetState(STATE_DEAD, !bState);
|
||||
control->SetState(Ui::STATE_DEAD, !bState);
|
||||
}
|
||||
|
||||
// Change the default input state of a button interface.
|
||||
|
@ -2573,12 +2534,12 @@ void CBrain::DefaultEnter(Ui::CWindow *pw, EventType event, bool bState)
|
|||
|
||||
if ( bState )
|
||||
{
|
||||
control->SetState(STATE_DEFAULT);
|
||||
control->SetState(Ui::STATE_DEFAULT);
|
||||
m_defaultEnter = event;
|
||||
}
|
||||
else
|
||||
{
|
||||
control->ClearState(STATE_DEFAULT);
|
||||
control->ClearState(Ui::STATE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
// #include <stdio.h>
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/misc.h"
|
||||
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
// motion.cpp
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/motion/motion.h"
|
||||
|
||||
#include "common/iman.h"
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/misc.h"
|
||||
#include "common/global.h"
|
||||
#include "object/object.h"
|
||||
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
// motionvehicle.cpp
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "object/motion/motionvehicle.h"
|
||||
|
||||
#include "graphics/engine/modelfile.h"
|
||||
|
@ -28,6 +26,8 @@
|
|||
#include "object/brain.h"
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2760,7 +2760,7 @@ void CRobotMain::HiliteFrame(float rTime)
|
|||
}
|
||||
|
||||
//! Creates a tooltip
|
||||
void CRobotMain::CreateTooltip(Math::Point pos, char* text)
|
||||
void CRobotMain::CreateTooltip(Math::Point pos, const char* text)
|
||||
{
|
||||
Math::Point corner;
|
||||
corner.x = pos.x+0.022f;
|
||||
|
@ -6193,7 +6193,7 @@ Error CRobotMain::CheckEndMission(bool frame)
|
|||
}
|
||||
|
||||
//! Checks if the mission is finished after displaying a message
|
||||
void CRobotMain::CheckEndMessage(char *message)
|
||||
void CRobotMain::CheckEndMessage(const char* message)
|
||||
{
|
||||
for (int t = 0; t < m_endTakeTotal; t++)
|
||||
{
|
||||
|
@ -6222,7 +6222,7 @@ char* CRobotMain::GetObligatoryToken(int i)
|
|||
}
|
||||
|
||||
//! Checks if an instruction is part of the obligatory list
|
||||
int CRobotMain::IsObligatoryToken(char *token)
|
||||
int CRobotMain::IsObligatoryToken(const char* token)
|
||||
{
|
||||
for (int i = 0; i < m_obligatoryTotal; i++)
|
||||
{
|
||||
|
@ -6233,7 +6233,7 @@ int CRobotMain::IsObligatoryToken(char *token)
|
|||
}
|
||||
|
||||
//! Checks if an instruction is not part of the banned list
|
||||
bool CRobotMain::IsProhibitedToken(char *token)
|
||||
bool CRobotMain::IsProhibitedToken(const char* token)
|
||||
{
|
||||
for (int i = 0; i < m_prohibitedTotal; i++)
|
||||
{
|
||||
|
|
|
@ -189,11 +189,11 @@ public:
|
|||
void ResetObject();
|
||||
void ResetCreate();
|
||||
Error CheckEndMission(bool frame);
|
||||
void CheckEndMessage(char *message);
|
||||
void CheckEndMessage(const char* message);
|
||||
int GetObligatoryToken();
|
||||
char* GetObligatoryToken(int i);
|
||||
int IsObligatoryToken(char *token);
|
||||
bool IsProhibitedToken(char *token);
|
||||
int IsObligatoryToken(const char* token);
|
||||
bool IsProhibitedToken(const char* token);
|
||||
void UpdateMap();
|
||||
bool GetShowMap();
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/event.h"
|
||||
#include "common/global.h"
|
||||
#include "math/const.h"
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "physics/physics.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// Object's constructor.
|
||||
|
||||
CTaskBuild::CTaskBuild(CInstanceManager* iMan, CObject* object)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "math/geometry.h"
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const float FLY_DIST_GROUND = 80.0f; // minimum distance to remain on the ground
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "graphics/engine/particle.h"
|
||||
#include "object/auto/autoinfo.h"
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "object/brain.h"
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
const float ENERGY_TIME = 20.0f; // maximum duration if full battery
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/global.h"
|
||||
#include "object/object.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
|
|
101
src/po/de.po
101
src/po/de.po
|
@ -1,29 +1,17 @@
|
|||
msgid "1.18 /e"
|
||||
msgstr "1.18 /d"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Language: de_DE\n"
|
||||
"X-Source-Language: en_US\n"
|
||||
|
||||
msgid "CeeBot-A 1.18"
|
||||
msgstr "CeeBot-A 1.18"
|
||||
msgid "Colobot rules!"
|
||||
msgstr "Colobot ist wunderbar!"
|
||||
|
||||
msgid "CeeBot-Teen EDU 1.18"
|
||||
msgstr "CeeBot-Teen EDU 1.18"
|
||||
|
||||
msgid "CeeBot-A EDU 1.18"
|
||||
msgstr "CeeBot-A EDU 1.18"
|
||||
|
||||
msgid "CeeBot-Teen PERSO 1.18"
|
||||
msgstr "CeeBot-Teen PERSO 1.18"
|
||||
|
||||
msgid "CeeBot-A PERSO 1.18"
|
||||
msgstr "CeeBot-A PERSO 1.18"
|
||||
|
||||
msgid "CeeBot-Teen DEMO 1.18"
|
||||
msgstr "CeeBot-Teen DEMO 1.18"
|
||||
|
||||
msgid "CeeBot-A DEMO 1.18"
|
||||
msgstr "CeeBot-A DEMO 1.18"
|
||||
|
||||
msgid "Demo 1.18 /e"
|
||||
msgstr "Demo 1.18 /d"
|
||||
msgid "Colobot Gold"
|
||||
msgstr "Colobot Gold"
|
||||
|
||||
msgid "SatCom"
|
||||
msgstr "SatCom"
|
||||
|
@ -55,9 +43,6 @@ msgstr "Neu ..."
|
|||
msgid " or "
|
||||
msgstr " oder "
|
||||
|
||||
msgid "CeeBot"
|
||||
msgstr "CeeBot"
|
||||
|
||||
msgid "COLOBOT"
|
||||
msgstr "COLOBOT"
|
||||
|
||||
|
@ -154,12 +139,6 @@ msgstr "Farbe des Anzugs:"
|
|||
msgid "Strip color:"
|
||||
msgstr "Farbe der Streifen:"
|
||||
|
||||
msgid "Do you want to quit CeeBot ?"
|
||||
msgstr "Wollen Sie CeeBot schließen ?"
|
||||
|
||||
msgid "Quit\\Quit CeeBot"
|
||||
msgstr "Schließen\\CeeBot schließen"
|
||||
|
||||
msgid "Do you want to quit COLOBOT ?"
|
||||
msgstr "Wollen Sie COLOBOT schließen ?"
|
||||
|
||||
|
@ -223,8 +202,10 @@ msgstr "\\c; (keine)\\n;\n"
|
|||
msgid "\\b;Error\n"
|
||||
msgstr "\\b;Fehler\n"
|
||||
|
||||
msgid "The list is only available if a \\l;radar station\\u object\\radar; is working.\n"
|
||||
msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar !\n"
|
||||
msgid ""
|
||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
||||
"working.\n"
|
||||
msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar.\n"
|
||||
|
||||
msgid "Open"
|
||||
msgstr "Öffnen"
|
||||
|
@ -266,7 +247,7 @@ msgid "Next"
|
|||
msgstr "Nächster"
|
||||
|
||||
msgid "Previous"
|
||||
msgstr "Vorherg."
|
||||
msgstr "Vorherg"
|
||||
|
||||
msgid "Menu (\\key quit;)"
|
||||
msgstr "Menü (\\key quit;)"
|
||||
|
@ -304,9 +285,6 @@ msgstr "Speichern\\Aktuelle Mission speichern"
|
|||
msgid "Load\\Load a saved mission"
|
||||
msgstr "Laden\\Eine gespeicherte Mission öffnen"
|
||||
|
||||
msgid "\\Return to CeeBot"
|
||||
msgstr "\\Zurück zu CeeBot"
|
||||
|
||||
msgid "\\Return to COLOBOT"
|
||||
msgstr "\\Zurück zu COLOBOT"
|
||||
|
||||
|
@ -314,7 +292,7 @@ msgid "<< Back \\Back to the previous screen"
|
|||
msgstr "<< Zurück \\Zurück zum Hauptmenü"
|
||||
|
||||
msgid "Play\\Start mission!"
|
||||
msgstr "Spielen ...\\Los geht's"
|
||||
msgstr "Spielen ...\\Los geht's!"
|
||||
|
||||
msgid "Device\\Driver and resolution settings"
|
||||
msgstr "Bildschirm\\Driver und Bildschirmauflösung"
|
||||
|
@ -401,10 +379,11 @@ msgid "Exit film\\Film at the exit of exercises"
|
|||
msgstr "Zurücksetzen \\Kleine Show beim Zurücksetzen in den Übungen"
|
||||
|
||||
msgid "Friendly fire\\Your shooting can damage your own objects "
|
||||
msgstr "Eigenbeschuss\\Ihre Einheiten werden von Ihren Waffen beschädigt."
|
||||
msgstr "Eigenbeschuss\\Ihre Einheiten werden von Ihren Waffen beschädigt"
|
||||
|
||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
||||
msgstr "Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht"
|
||||
msgstr ""
|
||||
"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht"
|
||||
|
||||
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
|
||||
msgstr "Umkehr X\\Umkehr der Kameradrehung X-Achse"
|
||||
|
@ -425,7 +404,8 @@ msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces"
|
|||
msgstr "Einrücken mit 4 Leerstellen\\Einrücken mit 2 oder 4 Leerstellen"
|
||||
|
||||
msgid "Access to solutions\\Show program \"4: Solution\" in the exercises"
|
||||
msgstr "Lösung zugänglich\\Die Lösung ist im Programmslot \"4: Lösung\" zugänglich"
|
||||
msgstr ""
|
||||
"Lösung zugänglich\\Die Lösung ist im Programmslot \"4: Lösung\" zugänglich"
|
||||
|
||||
msgid "Standard controls\\Standard key functions"
|
||||
msgstr "Alles zurücksetzen\\Standarddefinition aller Tasten"
|
||||
|
@ -454,8 +434,9 @@ msgstr "Andere Kamera\\Sichtpunkt einstellen"
|
|||
msgid "Previous object\\Selects the previous object"
|
||||
msgstr "Vorherg. Auswahl\\Das vorhergehende Objekt auswählen"
|
||||
|
||||
msgid "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
|
||||
msgstr "Standardhandlung\\Führt die Standardhandlung des Roboters aus."
|
||||
msgid ""
|
||||
"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
|
||||
msgstr "Standardhandlung\\Führt die Standardhandlung des Roboters aus"
|
||||
|
||||
msgid "Camera closer\\Moves the camera forward"
|
||||
msgstr "Kamera näher\\Bewegung der Kamera vorwärts"
|
||||
|
@ -523,7 +504,8 @@ msgstr "Normal\\Normale Lautstärke"
|
|||
msgid "Use a joystick\\Joystick or keyboard"
|
||||
msgstr "Joystick\\Joystick oder Tastatur"
|
||||
|
||||
msgid "Access to solution\\Shows the solution (detailed instructions for missions)"
|
||||
msgid ""
|
||||
"Access to solution\\Shows the solution (detailed instructions for missions)"
|
||||
msgstr "Zeigt die Lösung\\Zeigt nach 3mal Scheitern die Lösung"
|
||||
|
||||
msgid "\\New player name"
|
||||
|
@ -1312,22 +1294,6 @@ msgstr "Fehler"
|
|||
msgid "Unknown command"
|
||||
msgstr "Befehl unbekannt"
|
||||
|
||||
msgid "CeeBot not installed."
|
||||
msgstr "CeeBot wurde nicht installiert."
|
||||
|
||||
msgid ""
|
||||
"Please insert the CeeBot CD\n"
|
||||
"and re-run the game."
|
||||
msgstr "Legen Sie die CeeBot-CD ein\nund starten Sie das Spiel neu."
|
||||
|
||||
msgid "COLOBOT not installed."
|
||||
msgstr "COLOBOT wurde nicht installiert."
|
||||
|
||||
msgid ""
|
||||
"Please insert the COLOBOT CD\n"
|
||||
"and re-run the game."
|
||||
msgstr "Legen Sie die COLOBOT-CD ein\nund starten Sie das Spiel neu."
|
||||
|
||||
msgid "Inappropriate bot"
|
||||
msgstr "Roboter ungeeignet"
|
||||
|
||||
|
@ -1490,8 +1456,11 @@ msgstr "Zu nahe an einer anderen Fahne"
|
|||
msgid "No flag nearby"
|
||||
msgstr "Keine Fahne in Reichweite"
|
||||
|
||||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "Mission noch nicht beendet (Drücken Sie auf \\key help; für weitere Informationen)"
|
||||
msgid ""
|
||||
"The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr ""
|
||||
"Mission noch nicht beendet (Drücken Sie auf \\key help; für weitere "
|
||||
"Informationen)"
|
||||
|
||||
msgid "Bot destroyed"
|
||||
msgstr "Roboter zerstört"
|
||||
|
@ -1647,7 +1616,9 @@ msgid "Instruction \"break\" outside a loop"
|
|||
msgstr "Anweisung \"break\" außerhalb einer Schleife"
|
||||
|
||||
msgid "A label must be followed by \"for\", \"while\", \"do\" or \"switch\""
|
||||
msgstr "Ein Label kann nur vor den Anweisungen \"for\", \"while\", \"do\" oder \"switch\" vorkommen"
|
||||
msgstr ""
|
||||
"Ein Label kann nur vor den Anweisungen \"for\", \"while\", \"do\" oder "
|
||||
"\"switch\" vorkommen"
|
||||
|
||||
msgid "This label does not exist"
|
||||
msgstr "Dieses Label existiert nicht"
|
||||
|
|
101
src/po/fr.po
101
src/po/fr.po
|
@ -1,29 +1,17 @@
|
|||
msgid "1.18 /e"
|
||||
msgstr "1.18 /f"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
"X-Language: fr_FR\n"
|
||||
"X-Source-Language: en_US\n"
|
||||
|
||||
msgid "CeeBot-A 1.18"
|
||||
msgstr "CeeBot-A 1.18"
|
||||
msgid "Colobot rules!"
|
||||
msgstr "Colobot est super!"
|
||||
|
||||
msgid "CeeBot-Teen EDU 1.18"
|
||||
msgstr "CeeBot-Teen EDU 1.18"
|
||||
|
||||
msgid "CeeBot-A EDU 1.18"
|
||||
msgstr "CeeBot-A EDU 1.18"
|
||||
|
||||
msgid "CeeBot-Teen PERSO 1.18"
|
||||
msgstr "CeeBot-Teen PERSO 1.18"
|
||||
|
||||
msgid "CeeBot-A PERSO 1.18"
|
||||
msgstr "CeeBot-A PERSO 1.18"
|
||||
|
||||
msgid "CeeBot-Teen DEMO 1.18"
|
||||
msgstr "CeeBot-Teen DEMO 1.18"
|
||||
|
||||
msgid "CeeBot-A DEMO 1.18"
|
||||
msgstr "CeeBot-A DEMO 1.18"
|
||||
|
||||
msgid "Demo 1.18 /e"
|
||||
msgstr "Demo 1.18 /f"
|
||||
msgid "Colobot Gold"
|
||||
msgstr "Colobot Gold"
|
||||
|
||||
msgid "SatCom"
|
||||
msgstr "SatCom"
|
||||
|
@ -55,9 +43,6 @@ msgstr "Nouveau ..."
|
|||
msgid " or "
|
||||
msgstr " ou "
|
||||
|
||||
msgid "CeeBot"
|
||||
msgstr "CeeBot"
|
||||
|
||||
msgid "COLOBOT"
|
||||
msgstr "COLOBOT"
|
||||
|
||||
|
@ -154,12 +139,6 @@ msgstr "Couleur de la combinaison :"
|
|||
msgid "Strip color:"
|
||||
msgstr "Couleur des bandes :"
|
||||
|
||||
msgid "Do you want to quit CeeBot ?"
|
||||
msgstr "Voulez-vous quitter CeeBot ?"
|
||||
|
||||
msgid "Quit\\Quit CeeBot"
|
||||
msgstr "Quitter\\Quitter CeeBot"
|
||||
|
||||
msgid "Do you want to quit COLOBOT ?"
|
||||
msgstr "Voulez-vous quitter COLOBOT ?"
|
||||
|
||||
|
@ -223,8 +202,10 @@ msgstr "\\c; (aucun)\\n;\n"
|
|||
msgid "\\b;Error\n"
|
||||
msgstr "\\b;Erreur\n"
|
||||
|
||||
msgid "The list is only available if a \\l;radar station\\u object\\radar; is working.\n"
|
||||
msgstr "Liste non disponible sans \\l;radar\\u object\\radar; !\n"
|
||||
msgid ""
|
||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
||||
"working.\n"
|
||||
msgstr "Liste non disponible sans \\l;radar\\u object\\radar;.\n"
|
||||
|
||||
msgid "Open"
|
||||
msgstr "Ouvrir"
|
||||
|
@ -304,9 +285,6 @@ msgstr "Enregistrer\\Enregistrer la mission en cours"
|
|||
msgid "Load\\Load a saved mission"
|
||||
msgstr "Charger\\Charger une mission enregistrée"
|
||||
|
||||
msgid "\\Return to CeeBot"
|
||||
msgstr "\\Retourner dans CeeBot"
|
||||
|
||||
msgid "\\Return to COLOBOT"
|
||||
msgstr "\\Retourner dans COLOBOT"
|
||||
|
||||
|
@ -314,7 +292,7 @@ msgid "<< Back \\Back to the previous screen"
|
|||
msgstr "<< Retour \\Retour au niveau précédent"
|
||||
|
||||
msgid "Play\\Start mission!"
|
||||
msgstr "Jouer ...\\Démarrer l'action"
|
||||
msgstr "Jouer ...\\Démarrer l'action!"
|
||||
|
||||
msgid "Device\\Driver and resolution settings"
|
||||
msgstr "Affichage\\Pilote et résolution d'affichage"
|
||||
|
@ -404,13 +382,17 @@ msgid "Friendly fire\\Your shooting can damage your own objects "
|
|||
msgstr "Dégâts ŕ soi-męme\\Vos tirs infligent des dommages ŕ vos unités"
|
||||
|
||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
||||
msgstr "Défilement dans les bords\\Défilement lorsque la souris touches les bords gauche ou droite"
|
||||
msgstr ""
|
||||
"Défilement dans les bords\\Défilement lorsque la souris touches les bords "
|
||||
"gauche ou droite"
|
||||
|
||||
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
|
||||
msgstr "Inversion souris X\\Inversion de la rotation lorsque la souris touche un bord"
|
||||
msgstr ""
|
||||
"Inversion souris X\\Inversion de la rotation lorsque la souris touche un bord"
|
||||
|
||||
msgid "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis"
|
||||
msgstr "Inversion souris Y\\Inversion de la rotation lorsque la souris touche un bord"
|
||||
msgstr ""
|
||||
"Inversion souris Y\\Inversion de la rotation lorsque la souris touche un bord"
|
||||
|
||||
msgid "Quake at explosions\\The screen shakes at explosions"
|
||||
msgstr "Secousses lors d'explosions\\L'écran vibre lors d'une explosion"
|
||||
|
@ -454,7 +436,8 @@ msgstr "Changement de caméra\\Autre de point de vue"
|
|||
msgid "Previous object\\Selects the previous object"
|
||||
msgstr "Sélection précédente\\Sélectionne l'objet précédent"
|
||||
|
||||
msgid "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
|
||||
msgid ""
|
||||
"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
|
||||
msgstr "Action standard\\Action du bouton avec le cadre rouge"
|
||||
|
||||
msgid "Camera closer\\Moves the camera forward"
|
||||
|
@ -523,7 +506,8 @@ msgstr "Normal\\Niveaux normaux"
|
|||
msgid "Use a joystick\\Joystick or keyboard"
|
||||
msgstr "Utilise un joystick\\Joystick ou clavier"
|
||||
|
||||
msgid "Access to solution\\Shows the solution (detailed instructions for missions)"
|
||||
msgid ""
|
||||
"Access to solution\\Shows the solution (detailed instructions for missions)"
|
||||
msgstr "Accčs ŕ la solution\\Donne la solution"
|
||||
|
||||
msgid "\\New player name"
|
||||
|
@ -1312,22 +1296,6 @@ msgstr "Erreur"
|
|||
msgid "Unknown command"
|
||||
msgstr "Commande inconnue"
|
||||
|
||||
msgid "CeeBot not installed."
|
||||
msgstr "CeeBot n'est pas installé."
|
||||
|
||||
msgid ""
|
||||
"Please insert the CeeBot CD\n"
|
||||
"and re-run the game."
|
||||
msgstr "Veuillez mettre le CD de CeeBot\net relancer le jeu."
|
||||
|
||||
msgid "COLOBOT not installed."
|
||||
msgstr "COLOBOT n'est pas installé."
|
||||
|
||||
msgid ""
|
||||
"Please insert the COLOBOT CD\n"
|
||||
"and re-run the game."
|
||||
msgstr "Veuillez mettre le CD de COLOBOT\net relancer le jeu."
|
||||
|
||||
msgid "Inappropriate bot"
|
||||
msgstr "Robot inadapté"
|
||||
|
||||
|
@ -1490,8 +1458,10 @@ msgstr "Trop proche d'un drapeau existant"
|
|||
msgid "No flag nearby"
|
||||
msgstr "Aucun drapeau ŕ proximité"
|
||||
|
||||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "La misssion n'est pas terminée (appuyez sur \\key help; pour plus de détails)"
|
||||
msgid ""
|
||||
"The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr ""
|
||||
"La misssion n'est pas terminée (appuyez sur \\key help; pour plus de détails)"
|
||||
|
||||
msgid "Bot destroyed"
|
||||
msgstr "Robot détruit"
|
||||
|
@ -1521,7 +1491,8 @@ msgid "Plans for tracked robots available "
|
|||
msgstr "Fabrication d'un robot ŕ chenilles possible"
|
||||
|
||||
msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)"
|
||||
msgstr "Il est possible de voler avec les touches (\\key gup;) et (\\key gdown;)"
|
||||
msgstr ""
|
||||
"Il est possible de voler avec les touches (\\key gup;) et (\\key gdown;)"
|
||||
|
||||
msgid "Plans for thumper available"
|
||||
msgstr "Fabrication d'un robot secoueur possible"
|
||||
|
@ -1647,7 +1618,9 @@ msgid "Instruction \"break\" outside a loop"
|
|||
msgstr "Instruction \"break\" en dehors d'une boucle"
|
||||
|
||||
msgid "A label must be followed by \"for\", \"while\", \"do\" or \"switch\""
|
||||
msgstr "Un label ne peut se placer que devant un \"for\", un \"while\", un \"do\" ou un \"switch\""
|
||||
msgstr ""
|
||||
"Un label ne peut se placer que devant un \"for\", un \"while\", un \"do\" ou "
|
||||
"un \"switch\""
|
||||
|
||||
msgid "This label does not exist"
|
||||
msgstr "Cette étiquette n'existe pas"
|
||||
|
|
114
src/po/pl.po
114
src/po/pl.po
|
@ -1,29 +1,17 @@
|
|||
msgid "1.18 /e"
|
||||
msgstr "Wersja 1.18 /pl"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||
"X-Language: pl_PL\n"
|
||||
"X-Source-Language: en_US\n"
|
||||
|
||||
msgid "CeeBot-A 1.18"
|
||||
msgstr "CeeBot-A 1.18"
|
||||
msgid "Colobot rules!"
|
||||
msgstr "Colobot rządzi!"
|
||||
|
||||
msgid "CeeBot-Teen EDU 1.18"
|
||||
msgstr "CeeBot-Teen EDU 1.18"
|
||||
|
||||
msgid "CeeBot-A EDU 1.18"
|
||||
msgstr "CeeBot-A EDU 1.18"
|
||||
|
||||
msgid "CeeBot-Teen PERSO 1.18"
|
||||
msgstr "CeeBot-Teen PERSO 1.18"
|
||||
|
||||
msgid "CeeBot-A PERSO 1.18"
|
||||
msgstr "CeeBot-A PERSO 1.18"
|
||||
|
||||
msgid "CeeBot-Teen DEMO 1.18"
|
||||
msgstr "CeeBot-Teen DEMO 1.18"
|
||||
|
||||
msgid "CeeBot-A DEMO 1.18"
|
||||
msgstr "CeeBot-A DEMO 1.18"
|
||||
|
||||
msgid "Demo 1.18 /e"
|
||||
msgstr "Demo 1.18 /pl"
|
||||
msgid "Colobot Gold"
|
||||
msgstr "Colobot Gold"
|
||||
|
||||
msgid "SatCom"
|
||||
msgstr "SatCom"
|
||||
|
@ -55,9 +43,6 @@ msgstr "Nowy ..."
|
|||
msgid " or "
|
||||
msgstr " lub "
|
||||
|
||||
msgid "CeeBot"
|
||||
msgstr "CeeBot"
|
||||
|
||||
msgid "COLOBOT"
|
||||
msgstr "COLOBOT"
|
||||
|
||||
|
@ -154,12 +139,6 @@ msgstr "Kolor skafandra:"
|
|||
msgid "Strip color:"
|
||||
msgstr "Kolor pasków:"
|
||||
|
||||
msgid "Do you want to quit CeeBot ?"
|
||||
msgstr "Czy na pewno chcesz opuścić grę CeeBot?"
|
||||
|
||||
msgid "Quit\\Quit CeeBot"
|
||||
msgstr "Zakończ\\Kończy grę CeeBot"
|
||||
|
||||
msgid "Do you want to quit COLOBOT ?"
|
||||
msgstr "Czy na pewno chcesz opuścić grę COLOBOT?"
|
||||
|
||||
|
@ -223,8 +202,12 @@ msgstr "\\c; (brak)\\n;\n"
|
|||
msgid "\\b;Error\n"
|
||||
msgstr "\\b;Błąd\n"
|
||||
|
||||
msgid "The list is only available if a \\l;radar station\\u object\\radar; is working.\n"
|
||||
msgstr "Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u object\\radar;.\n"
|
||||
msgid ""
|
||||
"The list is only available if a \\l;radar station\\u object\\radar; is "
|
||||
"working.\n"
|
||||
msgstr ""
|
||||
"Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u "
|
||||
"object\\radar;.\n"
|
||||
|
||||
msgid "Open"
|
||||
msgstr "Otwórz"
|
||||
|
@ -304,9 +287,6 @@ msgstr "Zapisz\\Zapisuje bieżącą misję"
|
|||
msgid "Load\\Load a saved mission"
|
||||
msgstr "Wczytaj\\Wczytuje zapisaną misję"
|
||||
|
||||
msgid "\\Return to CeeBot"
|
||||
msgstr "\\Powróć do gry CeeBot"
|
||||
|
||||
msgid "\\Return to COLOBOT"
|
||||
msgstr "\\Powróć do gry COLOBOT"
|
||||
|
||||
|
@ -404,7 +384,9 @@ msgid "Friendly fire\\Your shooting can damage your own objects "
|
|||
msgstr "Przyjacielski ogień\\Własne strzały uszkadzają Twoje obiekty"
|
||||
|
||||
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
|
||||
msgstr "Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego krawędzi"
|
||||
msgstr ""
|
||||
"Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego "
|
||||
"krawędzi"
|
||||
|
||||
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
|
||||
msgstr "Odwrócenie myszy X\\Odwrócenie kierunków przewijania w poziomie"
|
||||
|
@ -422,7 +404,9 @@ msgid "Automatic indent\\When program editing"
|
|||
msgstr "Automatyczne wcięcia\\Automatyczne wcięcia podczas edycji programu"
|
||||
|
||||
msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces"
|
||||
msgstr "Duże wcięcie\\2 lub 4 spacje wcięcia na każdy poziom zdefiniowany przez klamry"
|
||||
msgstr ""
|
||||
"Duże wcięcie\\2 lub 4 spacje wcięcia na każdy poziom zdefiniowany przez "
|
||||
"klamry"
|
||||
|
||||
msgid "Access to solutions\\Show program \"4: Solution\" in the exercises"
|
||||
msgstr "Accčs aux solutions\\Programme \"4: Solution\" dans les exercices"
|
||||
|
@ -454,8 +438,11 @@ msgstr "Zmień kamerę\\Przełącza pomiędzy kamerą pokładową i śledzącą"
|
|||
msgid "Previous object\\Selects the previous object"
|
||||
msgstr "Poprzedni obiekt\\Zaznacz poprzedni obiekt"
|
||||
|
||||
msgid "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
|
||||
msgstr "Standardowa akcja\\Standardowa akcja robota (podnieś/upuść, strzelaj, szukaj, itp.)"
|
||||
msgid ""
|
||||
"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
|
||||
msgstr ""
|
||||
"Standardowa akcja\\Standardowa akcja robota (podnieś/upuść, strzelaj, "
|
||||
"szukaj, itp.)"
|
||||
|
||||
msgid "Camera closer\\Moves the camera forward"
|
||||
msgstr "Kamera bliżej\\Przybliża kamerę"
|
||||
|
@ -479,10 +466,12 @@ msgid "Programming help\\Gives more detailed help with programming"
|
|||
msgstr "Podręcznik programowania\\Dostarcza szczegółową pomoc w programowaniu"
|
||||
|
||||
msgid "Key word help\\More detailed help about key words"
|
||||
msgstr "Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych"
|
||||
msgstr ""
|
||||
"Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych"
|
||||
|
||||
msgid "Origin of last message\\Shows where the last message was sent from"
|
||||
msgstr "Miejsce nadania wiadomości\\Pokazuje skąd została wysłana ostatnia wiadomość"
|
||||
msgstr ""
|
||||
"Miejsce nadania wiadomości\\Pokazuje skąd została wysłana ostatnia wiadomość"
|
||||
|
||||
msgid "Speed 1.0x\\Normal speed"
|
||||
msgstr "Prędkość 1,0x\\Prędkość normalna"
|
||||
|
@ -506,13 +495,15 @@ msgid "3D sound\\3D positioning of the sound"
|
|||
msgstr "Dźwięk 3D\\Przestrzenne pozycjonowanie dźwięków"
|
||||
|
||||
msgid "Lowest\\Minimum graphic quality (highest frame rate)"
|
||||
msgstr "Najniższa\\Minimalna jakość grafiki (najwyższa częstotliwość odświeżania)"
|
||||
msgstr ""
|
||||
"Najniższa\\Minimalna jakość grafiki (najwyższa częstotliwość odświeżania)"
|
||||
|
||||
msgid "Normal\\Normal graphic quality"
|
||||
msgstr "Normalna\\Normalna jakość grafiki"
|
||||
|
||||
msgid "Highest\\Highest graphic quality (lowest frame rate)"
|
||||
msgstr "Najwyższa\\Maksymalna jakość grafiki (najniższa częstotliwość odświeżania)"
|
||||
msgstr ""
|
||||
"Najwyższa\\Maksymalna jakość grafiki (najniższa częstotliwość odświeżania)"
|
||||
|
||||
msgid "Mute\\No sound"
|
||||
msgstr "Cisza\\Brak dźwięków"
|
||||
|
@ -523,8 +514,11 @@ msgstr "Normalne\\Normalna głośność dźwięków"
|
|||
msgid "Use a joystick\\Joystick or keyboard"
|
||||
msgstr "Używaj joysticka\\Joystick lub klawiatura"
|
||||
|
||||
msgid "Access to solution\\Shows the solution (detailed instructions for missions)"
|
||||
msgstr "Dostęp do rozwiązania\\Pokazuje rozwiązanie (szczegółowe instrukcje dotyczące misji)"
|
||||
msgid ""
|
||||
"Access to solution\\Shows the solution (detailed instructions for missions)"
|
||||
msgstr ""
|
||||
"Dostęp do rozwiązania\\Pokazuje rozwiązanie (szczegółowe instrukcje "
|
||||
"dotyczące misji)"
|
||||
|
||||
msgid "\\New player name"
|
||||
msgstr "\\Nowe imię gracza"
|
||||
|
@ -1312,22 +1306,6 @@ msgstr "Błąd"
|
|||
msgid "Unknown command"
|
||||
msgstr "Nieznane polecenie"
|
||||
|
||||
msgid "CeeBot not installed."
|
||||
msgstr "Gra CeeBot nie jest zainstalowana."
|
||||
|
||||
msgid ""
|
||||
"Please insert the CeeBot CD\n"
|
||||
"and re-run the game."
|
||||
msgstr "Włóż dysk CD z grą CeeBot\ni uruchom grę jeszcze raz."
|
||||
|
||||
msgid "COLOBOT not installed."
|
||||
msgstr "Gra COLOBOT nie jest zainstalowana."
|
||||
|
||||
msgid ""
|
||||
"Please insert the COLOBOT CD\n"
|
||||
"and re-run the game."
|
||||
msgstr "Włóż dysk CD z grą COLOBOT\ni uruchom grę jeszcze raz."
|
||||
|
||||
msgid "Inappropriate bot"
|
||||
msgstr "Nieodpowiedni robot"
|
||||
|
||||
|
@ -1490,7 +1468,8 @@ msgstr "Za blisko istniejącej flagi"
|
|||
msgid "No flag nearby"
|
||||
msgstr "Nie ma flagi w pobliżu"
|
||||
|
||||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgid ""
|
||||
"The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "Misja nie jest wypełniona (naciśnij \\key help; aby uzyskać szczegóły)"
|
||||
|
||||
msgid "Bot destroyed"
|
||||
|
@ -1590,7 +1569,8 @@ msgid "Spider fatally wounded"
|
|||
msgstr "Pająk śmiertelnie raniony"
|
||||
|
||||
msgid "Press \\key help; to read instructions on your SatCom"
|
||||
msgstr "Naciśnij klawisz \\key help; aby wyświetlić rozkazy na przekaźniku SatCom"
|
||||
msgstr ""
|
||||
"Naciśnij klawisz \\key help; aby wyświetlić rozkazy na przekaźniku SatCom"
|
||||
|
||||
msgid "Opening bracket missing"
|
||||
msgstr "Brak nawiasu otwierającego"
|
||||
|
@ -1638,7 +1618,7 @@ msgid "Unknown function"
|
|||
msgstr "Funkcja nieznana"
|
||||
|
||||
msgid "Sign \" : \" missing"
|
||||
msgstr "Brak znaku \" : "
|
||||
msgstr "Brak znaku \" :\""
|
||||
|
||||
msgid "Keyword \"while\" missing"
|
||||
msgstr "Brak kluczowego słowa \"while"
|
||||
|
|
|
@ -15,20 +15,11 @@
|
|||
// * 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/event.h"
|
||||
#include "script/cbottoken.h"
|
||||
|
||||
#include "object/object.h"
|
||||
// #include "script/cbottoken.h"
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Seeking the name of an object.
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include "common/global.h"
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "common/global.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
// #include "old/d3denum.h"
|
||||
// #include "old/d3dengine.h"
|
||||
// #include "object/object.h"
|
||||
#include "graphics/engine/water.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
#include "graphics/engine/pyro.h"
|
||||
|
|
|
@ -18,37 +18,27 @@
|
|||
|
||||
|
||||
#include "script/script.h"
|
||||
// #include <windows.h>
|
||||
#include <stdio.h>
|
||||
// #include <d3d.h>
|
||||
//
|
||||
#include "math/vector.h"
|
||||
// #include "common/struct.h"
|
||||
#include "math/geometry.h"
|
||||
// #include "old/d3dengine.h"
|
||||
// #include "old/d3dmath.h"
|
||||
|
||||
#include "common/global.h"
|
||||
// #include "common/event.h"
|
||||
// #include "common/misc.h"
|
||||
#include "common/iman.h"
|
||||
#include "common/restext.h"
|
||||
// #include "old/math3d.h"
|
||||
#include "object/robotmain.h"
|
||||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/engine/water.h"
|
||||
#include "graphics/engine/text.h"
|
||||
#include "math/geometry.h"
|
||||
#include "math/vector.h"
|
||||
#include "object/object.h"
|
||||
#include "object/robotmain.h"
|
||||
#include "object/task/taskmanager.h"
|
||||
#include "physics/physics.h"
|
||||
#include "script/cbottoken.h"
|
||||
#include "ui/interface.h"
|
||||
#include "ui/edit.h"
|
||||
#include "ui/list.h"
|
||||
#include "ui/displaytext.h"
|
||||
#include "object/task/taskmanager.h"
|
||||
// #include "object/task/task.h"
|
||||
// #include "object/task/taskmanip.h"
|
||||
// #include "object/task/taskgoto.h"
|
||||
// #include "object/task/taskshield.h"
|
||||
#include "script/cbottoken.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
|
@ -3101,7 +3091,7 @@ bool CScript::Step(const Event &event)
|
|||
if ( !m_bStepMode ) return false;
|
||||
|
||||
m_engine->SetPause(false);
|
||||
m_engine->StepSimulation(0.01f); // advance of 10ms
|
||||
// TODO: m_app StepSimulation??? m_engine->StepSimulation(0.01f); // advance of 10ms
|
||||
m_engine->SetPause(true);
|
||||
|
||||
m_event = event;
|
||||
|
@ -3650,7 +3640,7 @@ bool CScript::SendScript(char* text)
|
|||
|
||||
// Reads a script as a text file.
|
||||
|
||||
bool CScript::ReadScript(char* filename)
|
||||
bool CScript::ReadScript(const char* filename)
|
||||
{
|
||||
FILE* file;
|
||||
Ui::CEdit* edit;
|
||||
|
@ -3685,7 +3675,7 @@ bool CScript::ReadScript(char* filename)
|
|||
|
||||
// Writes a script as a text file.
|
||||
|
||||
bool CScript::WriteScript(char* filename)
|
||||
bool CScript::WriteScript(const char* filename)
|
||||
{
|
||||
Ui::CEdit* edit;
|
||||
char name[100];
|
||||
|
|
|
@ -76,8 +76,8 @@ public:
|
|||
|
||||
void New(Ui::CEdit* edit, char* name);
|
||||
bool SendScript(char* text);
|
||||
bool ReadScript(char* filename);
|
||||
bool WriteScript(char* filename);
|
||||
bool ReadScript(const char* filename);
|
||||
bool WriteScript(const char* filename);
|
||||
bool ReadStack(FILE *file);
|
||||
bool WriteStack(FILE *file);
|
||||
bool Compare(CScript* other);
|
||||
|
|
|
@ -17,13 +17,15 @@
|
|||
|
||||
|
||||
|
||||
#include "button.h"
|
||||
#include "ui/button.h"
|
||||
|
||||
#include <common/event.h>
|
||||
#include <common/misc.h>
|
||||
#include <common/restext.h>
|
||||
#include "common/event.h"
|
||||
#include "common/misc.h"
|
||||
#include "common/restext.h"
|
||||
|
||||
#include <graphics/engine/engine.h>
|
||||
#include "graphics/engine/engine.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "control.h"
|
||||
#include "ui/control.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
|
||||
|
|
|
@ -16,16 +16,17 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include "check.h"
|
||||
#include "ui/check.h"
|
||||
|
||||
#include <common/event.h>
|
||||
#include <common/iman.h>
|
||||
#include <common/misc.h>
|
||||
#include <common/restext.h>
|
||||
#include "common/event.h"
|
||||
#include "common/iman.h"
|
||||
#include "common/misc.h"
|
||||
#include "common/restext.h"
|
||||
|
||||
#include <graphics/engine/engine.h>
|
||||
#include <graphics/engine/text.h>
|
||||
#include "graphics/engine/engine.h"
|
||||
#include "graphics/engine/text.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "control.h"
|
||||
#include "ui/control.h"
|
||||
|
||||
|
||||
namespace Gfx{
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include "color.h"
|
||||
#include "ui/color.h"
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/iman.h"
|
||||
|
@ -26,6 +26,8 @@
|
|||
#include "graphics/core/device.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
const float DELAY1 = 0.4f;
|
||||
|
@ -188,10 +190,10 @@ void CColor::Draw()
|
|||
m_engine->SetTexture("xxx.tga"); // no texture
|
||||
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
|
||||
|
||||
vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point(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] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f));
|
||||
vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point(0.0f, 0.0f));
|
||||
vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
|
||||
vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
|
||||
vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
|
||||
vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
|
||||
|
||||
device = m_engine->GetDevice();
|
||||
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ui/control.h"
|
||||
|
||||
#include "control.h"
|
||||
|
||||
namespace Gfx{
|
||||
class CEngine;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
#include "compass.h"
|
||||
#include "ui/compass.h"
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/iman.h"
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ui/control.h"
|
||||
|
||||
#include "control.h"
|
||||
|
||||
namespace Gfx {
|
||||
class CEngine;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <common/event.h>
|
||||
#include <common/iman.h>
|
||||
#include <common/language.h>
|
||||
#include <common/misc.h>
|
||||
#include <common/restext.h>
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue