summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CBot/CBot.cpp29
-rw-r--r--src/CBot/CBot.h7
-rw-r--r--src/CBot/CBotFunction.cpp5
-rw-r--r--src/CBot/CBotStack.cpp12
-rw-r--r--src/CBot/CBotTwoOpExpr.cpp4
-rw-r--r--src/CBot/CBotVar.cpp114
-rw-r--r--src/CMakeLists.txt15
-rw-r--r--src/app/app.cpp30
-rw-r--r--src/app/system.cpp14
-rw-r--r--src/app/system.h6
-rw-r--r--src/app/system_macosx.cpp116
-rw-r--r--src/app/system_macosx.h39
-rw-r--r--src/common/config.h.cmake5
-rw-r--r--src/common/global.h3
-rw-r--r--src/common/image.cpp30
-rw-r--r--src/common/image.h6
-rw-r--r--src/object/robotmain.cpp4
-rw-r--r--src/ui/control.cpp2
-rw-r--r--src/ui/window.cpp4
19 files changed, 337 insertions, 108 deletions
diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index 513b803..403be6e 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -33,6 +33,9 @@
#include "CBot.h"
+#include <cassert>
+
+
CBotInstr::CBotInstr()
{
name = "CBotInstr";
@@ -285,7 +288,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
bool CBotInstr::Execute(CBotStack* &pj)
{
CBotString ClassManquante = name;
- ASM_TRAP(); // should never go through this routine
+ assert(0); // should never go through this routine
// but use the routines of the subclasses
return false;
}
@@ -300,26 +303,26 @@ bool CBotInstr::Execute(CBotStack* &pj, CBotVar* pVar)
void CBotInstr::RestoreState(CBotStack* &pj, bool bMain)
{
CBotString ClassManquante = name;
- ASM_TRAP(); // should never go through this routine
+ assert(0); // should never go through this routine
// but use the routines of the subclasses
}
bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile)
{
- ASM_TRAP(); // dad do not know, see the girls
+ assert(0); // dad do not know, see the girls
return false;
}
bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend)
{
- ASM_TRAP(); // dad do not know, see the girls
+ assert(0); // dad do not know, see the girls
return false;
}
void CBotInstr::RestoreStateVar(CBotStack* &pile, bool bMain)
{
- ASM_TRAP(); // dad do not know, see the girls
+ assert(0); // dad do not know, see the girls
}
// this routine is defined only for the subclass CBotCase
@@ -531,7 +534,7 @@ void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain)
CBotVar* var1;
var1 = pj->FindVar(m_token.GetString());
- if (var1 == NULL) ASM_TRAP();
+ if (var1 == NULL) assert(0);
var1->SetUniqNum(m_nIdent); // with the unique identifier
}
@@ -1747,7 +1750,7 @@ bool CBotExpression::Execute(CBotStack* &pj)
pile2->SetVar(result);
break;
default:
- ASM_TRAP();
+ assert(0);
}
if (!IsInit)
pile2->SetError(TX_NOTINIT, m_leftop->GetToken());
@@ -2270,7 +2273,7 @@ CBotIndexExpr::~CBotIndexExpr()
bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile)
{
if (pVar->GetType(1) != CBotTypArrayPointer)
- ASM_TRAP();
+ assert(0);
pVar = (static_cast<CBotVarArray*>(pVar))->GetItem(0, false); // at compile time makes the element [0]
if (pVar == NULL)
@@ -2291,7 +2294,7 @@ bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev
CBotStack* pj = pile;
if (pVar->GetType(1) != CBotTypArrayPointer)
- ASM_TRAP();
+ assert(0);
pile = pile->AddStack();
@@ -2372,7 +2375,7 @@ void CBotFieldExpr::SetUniqNum(int num)
bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile)
{
if (pVar->GetType(1) != CBotTypPointer)
- ASM_TRAP();
+ assert(0);
pVar = pVar->GetItemRef(m_nIdent);
if (pVar == NULL)
@@ -2395,7 +2398,7 @@ bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev
if (pVar->GetType(1) != CBotTypPointer)
- ASM_TRAP();
+ assert(0);
CBotVarClass* pItem = pVar->GetPointer();
if (pItem == NULL)
@@ -2648,7 +2651,7 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT
if (pVar == NULL)
{
#ifdef _DEBUG
- ASM_TRAP();
+ assert(0);
#endif
pile->SetError(2, &m_token);
return false;
@@ -3289,7 +3292,7 @@ bool CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToke
if (pVar == NULL)
{
#ifdef _DEBUG
- ASM_TRAP();
+ assert(0);
#endif
pj->SetError(1, &m_token);
return false;
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 8313252..df6614e 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -32,13 +32,6 @@
#define EOX (reinterpret_cast<CBotStack*>(-1)) /// \def tag special condition
-// fix for MSVC instruction __asm int 3 (setting a trap)
-#if defined(__MINGW32__) || defined(__GNUC__)
-#define ASM_TRAP() asm("int $3");
-#else
-#define ASM_TRAP() __asm int 3;
-#endif
-
/////////////////////////////////////////////////////////////////////
// forward declaration
diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp
index 862554e..e6aa2c9 100644
--- a/src/CBot/CBotFunction.cpp
+++ b/src/CBot/CBotFunction.cpp
@@ -20,6 +20,9 @@
#include "CBot.h"
+#include <cassert>
+
+
// various constructors / destructors
// \TODO translation:to liberate all according to esteblished tree
// pour libérer tout selon l'arbre établi
@@ -1046,7 +1049,7 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
}
break;
default:
- ASM_TRAP();
+ assert(0);
}
}
newvar->SetUniqNum(p->m_nIdent);
diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp
index 086442d..1679e5e 100644
--- a/src/CBot/CBotStack.cpp
+++ b/src/CBot/CBotStack.cpp
@@ -18,6 +18,8 @@
#include "CBot.h"
+
+#include <cassert>
#include <cstdlib>
#include <cstring>
@@ -80,12 +82,12 @@ CBotStack* CBotStack::FirstStack()
CBotStack::CBotStack(CBotStack* ppapa)
{
// constructor must exist or the destructor is never called!
- ASM_TRAP();
+ assert(0);
}
CBotStack::~CBotStack()
{
- ASM_TRAP(); // use Delete () instead
+ assert(0); // use Delete () instead
}
void CBotStack::Delete()
@@ -693,7 +695,7 @@ void CBotStack::AddVar(CBotVar* pVar)
*pp = pVar; // added after
#ifdef _DEBUG
- if ( pVar->GetUniqNum() == 0 ) ASM_TRAP();
+ if ( pVar->GetUniqNum() == 0 ) assert(0);
#endif
}
@@ -1091,7 +1093,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
}
break;
default:
- ASM_TRAP();
+ assert(0);
}
if ( pPrev != NULL ) pPrev->m_next = pNew;
@@ -1388,7 +1390,7 @@ void CBotCStack::AddVar(CBotVar* pVar)
*pp = pVar; // added after
#ifdef _DEBUG
- if ( pVar->GetUniqNum() == 0 ) ASM_TRAP();
+ if ( pVar->GetUniqNum() == 0 ) assert(0);
#endif
}
diff --git a/src/CBot/CBotTwoOpExpr.cpp b/src/CBot/CBotTwoOpExpr.cpp
index 6a0d636..4d4add8 100644
--- a/src/CBot/CBotTwoOpExpr.cpp
+++ b/src/CBot/CBotTwoOpExpr.cpp
@@ -20,6 +20,8 @@
#include "CBot.h"
+#include <cassert>
+
// various constructors
CBotTwoOpExpr::CBotTwoOpExpr()
@@ -466,7 +468,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
if ( !IsNan(left, right, &err) ) result->SL(left , right);
break;
default:
- ASM_TRAP();
+ assert(0);
}
delete temp;
diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp
index ad3708d..b84006f 100644
--- a/src/CBot/CBotVar.cpp
+++ b/src/CBot/CBotVar.cpp
@@ -21,8 +21,10 @@
// it never creates an instance of the class mother CBotVar
#include "CBot.h"
-#include <math.h>
-#include <stdio.h>
+
+#include <cassert>
+#include <cmath>
+#include <cstdio>
long CBotVar::m_identcpt = 0;
@@ -124,7 +126,7 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type
!type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types
!type.Eq(CBotTypPointer) &&
!type.Eq(CBotTypArrayPointer) &&
- !type.Eq(CBotTypArrayBody)) ASM_TRAP();
+ !type.Eq(CBotTypArrayBody)) assert(0);
m_token = new CBotToken(name);
m_next = NULL;
@@ -169,7 +171,7 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type
CBotVarClass::~CBotVarClass( )
{
if ( m_CptUse != 0 )
- ASM_TRAP();
+ assert(0);
if ( m_pParent ) delete m_pParent;
m_pParent = NULL;
@@ -242,7 +244,7 @@ void CBotVar::SetUniqNum(long n)
{
m_ident = n;
- if ( n == 0 ) ASM_TRAP();
+ if ( n == 0 ) assert(0);
}
long CBotVar::NextUniqNum()
@@ -267,7 +269,7 @@ bool CBotVar::Save1State(FILE* pf)
// this routine "virtual" must never be called,
// there must be a routine for each of the subclasses (CBotVarInt, CBotVarFloat, etc)
// ( see the type in m_type )
- ASM_TRAP();
+ assert(0);
return false;
}
@@ -335,7 +337,7 @@ CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type)
}
}
- ASM_TRAP();
+ assert(0);
return NULL;
}
@@ -406,7 +408,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type)
}
}
- ASM_TRAP();
+ assert(0);
return NULL;
}
@@ -519,25 +521,25 @@ CBotToken* CBotVar::GetToken()
CBotVar* CBotVar::GetItem(const char* name)
{
- ASM_TRAP();
+ assert(0);
return NULL;
}
CBotVar* CBotVar::GetItemRef(int nIdent)
{
- ASM_TRAP();
+ assert(0);
return NULL;
}
CBotVar* CBotVar::GetItemList()
{
- ASM_TRAP();
+ assert(0);
return NULL;
}
CBotVar* CBotVar::GetItem(int row, bool bGrow)
{
- ASM_TRAP();
+ assert(0);
return NULL;
}
@@ -617,7 +619,7 @@ void CBotVar::SetVal(CBotVar* var)
}
break;
default:
- ASM_TRAP();
+ assert(0);
}
m_binit = var->m_binit; // copie l'état nan s'il y a
@@ -651,12 +653,12 @@ int CBotVar::GetPrivate()
void CBotVar::SetPointer(CBotVar* pVarClass)
{
- ASM_TRAP();
+ assert(0);
}
CBotVarClass* CBotVar::GetPointer()
{
- ASM_TRAP();
+ assert(0);
return NULL;
}
@@ -665,167 +667,167 @@ CBotVarClass* CBotVar::GetPointer()
int CBotVar::GetValInt()
{
- ASM_TRAP();
+ assert(0);
return 0;
}
float CBotVar::GetValFloat()
{
- ASM_TRAP();
+ assert(0);
return 0;
}
void CBotVar::SetValInt(int c, const char* s)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::SetValFloat(float c)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Mul(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Power(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
int CBotVar::Div(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return 0;
}
int CBotVar::Modulo(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return 0;
}
void CBotVar::Add(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Sub(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
bool CBotVar::Lo(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return false;
}
bool CBotVar::Hi(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return false;
}
bool CBotVar::Ls(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return false;
}
bool CBotVar::Hs(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return false;
}
bool CBotVar::Eq(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return false;
}
bool CBotVar::Ne(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
return false;
}
void CBotVar::And(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Or(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::XOr(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::ASR(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::SR(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::SL(CBotVar* left, CBotVar* right)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Neg()
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Not()
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Inc()
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Dec()
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::Copy(CBotVar* pSrc, bool bName)
{
- ASM_TRAP();
+ assert(0);
}
void CBotVar::SetValString(const char* p)
{
- ASM_TRAP();
+ assert(0);
}
CBotString CBotVar::GetValString()
{
- ASM_TRAP();
+ assert(0);
return CBotString();
}
void CBotVar::SetClass(CBotClass* pClass)
{
- ASM_TRAP();
+ assert(0);
}
CBotClass* CBotVar::GetClass()
{
- ASM_TRAP();
+ assert(0);
return NULL;
}
@@ -1398,7 +1400,7 @@ void CBotVarClass::Copy(CBotVar* pSrc, bool bName)
pSrc = pSrc->GetPointer(); // if source given by a pointer
if ( pSrc->GetType() != CBotTypClass )
- ASM_TRAP();
+ assert(0);
CBotVarClass* p = static_cast<CBotVarClass*>(pSrc);
@@ -1410,7 +1412,7 @@ void CBotVarClass::Copy(CBotVar* pSrc, bool bName)
m_pClass = p->m_pClass;
if ( p->m_pParent )
{
- ASM_TRAP(); // "que faire du pParent";
+ assert(0); // "que faire du pParent";
}
// m_next = NULL;
@@ -1768,7 +1770,7 @@ bool CBotVarClass::Ne(CBotVar* left, CBotVar* right)
CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type )
{
if ( !type.Eq(CBotTypArrayPointer) &&
- !type.Eq(CBotTypArrayBody)) ASM_TRAP();
+ !type.Eq(CBotTypArrayBody)) assert(0);
m_token = new CBotToken(name);
m_next = NULL;
@@ -1791,7 +1793,7 @@ CBotVarArray::~CBotVarArray()
void CBotVarArray::Copy(CBotVar* pSrc, bool bName)
{
if ( pSrc->GetType() != CBotTypArrayPointer )
- ASM_TRAP();
+ assert(0);
CBotVarArray* p = static_cast<CBotVarArray*>(pSrc);
@@ -1825,7 +1827,7 @@ void CBotVarArray::SetPointer(CBotVar* pVarClass)
if ( !pVarClass->m_type.Eq(CBotTypClass) &&
!pVarClass->m_type.Eq(CBotTypArrayBody))
- ASM_TRAP();
+ assert(0);
(static_cast<CBotVarClass*>(pVarClass))->IncrementUse(); // incement the reference
}
@@ -1882,7 +1884,7 @@ CBotVarPointer::CBotVarPointer(const CBotToken* name, CBotTypResult& type )
if ( !type.Eq(CBotTypPointer) &&
!type.Eq(CBotTypNullPointer) &&
!type.Eq(CBotTypClass) && // for convenience accepts Class and Intrinsic
- !type.Eq(CBotTypIntrinsic) ) ASM_TRAP();
+ !type.Eq(CBotTypIntrinsic) ) assert(0);
m_token = new CBotToken(name);
m_next = NULL;
@@ -1965,7 +1967,7 @@ void CBotVarPointer::SetPointer(CBotVar* pVarClass)
// if ( pVarClass->GetType() != CBotTypClass )
if ( !pVarClass->m_type.Eq(CBotTypClass) )
- ASM_TRAP();
+ assert(0);
(static_cast<CBotVarClass*>(pVarClass))->IncrementUse(); // increment the reference
m_pClass = (static_cast<CBotVarClass*>(pVarClass))->m_pClass;
@@ -2034,7 +2036,7 @@ void CBotVarPointer::Copy(CBotVar* pSrc, bool bName)
{
if ( pSrc->GetType() != CBotTypPointer &&
pSrc->GetType() != CBotTypNullPointer)
- ASM_TRAP();
+ assert(0);
CBotVarPointer* p = static_cast<CBotVarPointer*>(pSrc);
@@ -2162,11 +2164,11 @@ int CBotTypResult::GetType(int mode) const
m_type == CBotTypClass ||
m_type == CBotTypIntrinsic )
- if ( m_pClass == NULL ) ASM_TRAP();
+ if ( m_pClass == NULL ) assert(0);
if ( m_type == CBotTypArrayPointer )
- if ( m_pNext == NULL ) ASM_TRAP();
+ if ( m_pNext == NULL ) assert(0);
#endif
if ( mode == 3 && m_type == CBotTypNullPointer ) return CBotTypPointer;
return m_type;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2fab853..ef59973 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,21 +56,13 @@ if(PLATFORM_WINDOWS)
set(RES_FILES "../desktop/colobot.rc")
endif()
-# Platform-dependent implementation of system.h
-if(PLATFORM_WINDOWS)
- set(SYSTEM_CPP_MODULE "system_windows.cpp")
-elseif(PLATFORM_LINUX)
- set(SYSTEM_CPP_MODULE "system_linux.cpp")
-else()
- set(SYSTEM_CPP_MODULE "system_other.cpp")
-endif()
-
# Source files
set(SOURCES
app/app.cpp
app/main.cpp
app/system.cpp
app/${SYSTEM_CPP_MODULE}
+app/system_other.cpp
common/event.cpp
common/image.cpp
common/iman.cpp
@@ -237,5 +229,6 @@ add_executable(colobot ${SOURCES})
target_link_libraries(colobot ${LIBS})
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
-set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
-
+if(NOT CBOT_STATIC)
+ set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
+endif()
diff --git a/src/app/app.cpp b/src/app/app.cpp
index d2994a9..4484e2a 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -147,8 +147,8 @@ CApplication::CApplication()
m_mouseButtonsState = 0;
m_trackedKeys = 0;
- m_dataPath = COLOBOT_DEFAULT_DATADIR;
- m_langPath = COLOBOT_I18N_DIR;
+ m_dataPath = GetSystemUtils()->GetDataPath();
+ m_langPath = GetSystemUtils()->GetLangPath();
m_texPackPath = "";
m_runSceneName = "";
@@ -280,7 +280,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
GetLogger()->Message(" -debug modes enable debug modes (more info printed in logs; see code for reference of modes)\n");
GetLogger()->Message(" -runscene sceneNNN run given scene on start\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");
+ GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl, ru)\n");
GetLogger()->Message(" -datadir path set custom data directory path\n");
GetLogger()->Message(" -langdir path set custom language directory path\n");
GetLogger()->Message(" -texpack path set path to custom texture pack\n");
@@ -421,7 +421,10 @@ bool CApplication::Create()
return false;
}
+#if !defined(PLATFORM_MACOSX)
+ // On Mac OSX, the bundle can potentially change place, it doesn't make sense to cache it to the configuration file
GetProfile().SetLocalProfileString("Resources", "Data", m_dataPath);
+#endif
SetLanguage(m_language);
@@ -435,12 +438,16 @@ bool CApplication::Create()
m_sound->Create(true);
+#if !defined(PLATFORM_MACOSX)
+ // On Mac OSX, the bundle can potentially change place, it doesn't make sense to cache it to the configuration file
+
// Cache sound files
if (defaultValues)
{
GetProfile().SetLocalProfileString("Resources", "Sound", GetDataSubdirPath(DIR_SOUND));
GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC));
}
+#endif
if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Sound", path))
{
@@ -1681,6 +1688,10 @@ char CApplication::GetLanguageChar() const
case LANGUAGE_POLISH:
langChar = 'P';
break;
+
+ case LANGUAGE_RUSSIAN:
+ langChar = 'R';
+ break;
}
return langChar;
}
@@ -1707,6 +1718,11 @@ bool CApplication::ParseLanguage(const std::string& str, Language& language)
language = LANGUAGE_POLISH;
return true;
}
+ else if (str == "ru")
+ {
+ language = LANGUAGE_RUSSIAN;
+ return true;
+ }
return false;
}
@@ -1740,6 +1756,10 @@ void CApplication::SetLanguage(Language language)
case LANGUAGE_POLISH:
locale = "pl_PL.utf8";
break;
+
+ case LANGUAGE_RUSSIAN:
+ locale = "ru_RU.utf8";
+ break;
}
if (locale.empty())
@@ -1770,6 +1790,10 @@ void CApplication::SetLanguage(Language language)
{
m_language = LANGUAGE_POLISH;
}
+ else if (strncmp(envLang,"ru",2) == 0)
+ {
+ m_language = LANGUAGE_RUSSIAN;
+ }
else
{
GetLogger()->Warn("Enviromnent locale ('%s') is not supported, setting default language\n", envLang);
diff --git a/src/app/system.cpp b/src/app/system.cpp
index 2eb68ba..eaa9e4c 100644
--- a/src/app/system.cpp
+++ b/src/app/system.cpp
@@ -25,6 +25,8 @@
#include "app/system_windows.h"
#elif defined(PLATFORM_LINUX)
#include "app/system_linux.h"
+#elif defined(PLATFORM_MACOSX)
+ #include "app/system_macosx.h"
#else
#include "app/system_other.h"
#endif
@@ -48,6 +50,8 @@ CSystemUtils* CSystemUtils::Create()
m_instance = new CSystemUtilsWindows();
#elif defined(PLATFORM_LINUX)
m_instance = new CSystemUtilsLinux();
+#elif defined(PLATFORM_MACOSX)
+ m_instance = new CSystemUtilsMacOSX();
#else
m_instance = new CSystemUtilsOther();
#endif
@@ -188,6 +192,16 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte
return result;
}
+std::string CSystemUtils::GetDataPath()
+{
+ return COLOBOT_DEFAULT_DATADIR;
+}
+
+std::string CSystemUtils::GetLangPath()
+{
+ return COLOBOT_I18N_DIR;
+}
+
std::string CSystemUtils::GetProfileFileLocation()
{
return std::string("colobot.ini");
diff --git a/src/app/system.h b/src/app/system.h
index d22a519..c2125fe 100644
--- a/src/app/system.h
+++ b/src/app/system.h
@@ -130,6 +130,12 @@ public:
/** The difference is \a after - \a before. */
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0;
+ //! Returns the data path (containing textures, levels, helpfiles, etc)
+ virtual std::string GetDataPath();
+
+ //! Returns the translations path
+ virtual std::string GetLangPath();
+
//! Returns the profile (colobot.ini) file location
virtual std::string GetProfileFileLocation();
diff --git a/src/app/system_macosx.cpp b/src/app/system_macosx.cpp
new file mode 100644
index 0000000..68f5c79
--- /dev/null
+++ b/src/app/system_macosx.cpp
@@ -0,0 +1,116 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2013, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+#include "app/system_macosx.h"
+
+#include "common/logger.h"
+
+#include <stdlib.h>
+
+// MacOS-specific headers
+#include <CoreFoundation/CFBundle.h>
+#include <CoreServices/CoreServices.h>
+
+#include <boost/filesystem.hpp>
+
+inline std::string CFStringRefToStdString(CFStringRef str) {
+
+ std::string stdstr;
+
+ char *fullPath;
+ CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
+
+ // 1st try for English system
+ fullPath = const_cast<char*>(CFStringGetCStringPtr(str, encodingMethod));
+ if( fullPath == NULL )
+ {
+ // 2nd try for Japanese system
+ encodingMethod = kCFStringEncodingUTF8;
+ fullPath = const_cast<char*>(CFStringGetCStringPtr(str, encodingMethod));
+ }
+
+ // for safer operation.
+ if( fullPath == NULL )
+ {
+ CFIndex length = CFStringGetLength(str);
+ fullPath = static_cast<char *>(malloc( length + 1 ));
+
+ // TODO: Check boolean result of that conversion
+ CFStringGetCString(str, fullPath, length, kCFStringEncodingUTF8 );
+
+ stdstr = fullPath;
+
+ free( fullPath );
+ }
+ else
+ stdstr = fullPath;
+
+ return stdstr;
+}
+
+void CSystemUtilsMacOSX::Init()
+{
+ // These functions are a deprecated way to get the 'Application Support' folder, but they do work, in plain C++
+ FSRef ref;
+ OSType folderType = kApplicationSupportFolderType;
+ char path[PATH_MAX];
+ FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
+ FSRefMakePath( &ref, reinterpret_cast<UInt8*>(&path), PATH_MAX );
+
+ m_ASPath = path;
+ m_ASPath.append("/colobot/");
+
+ // Make sure the directory exists
+ boost::filesystem::create_directories(m_ASPath.c_str());
+
+ // Get the Resources bundle URL
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle);
+ CFStringRef str = CFURLCopyFileSystemPath( resourcesURL, kCFURLPOSIXPathStyle );
+ CFRelease(resourcesURL);
+
+ m_dataPath = CFStringRefToStdString(str);
+ m_dataPath += "/Contents/Resources";
+}
+
+std::string CSystemUtilsMacOSX::GetDataPath()
+{
+ return m_dataPath;
+}
+
+std::string CSystemUtilsMacOSX::GetLangPath()
+{
+ return m_dataPath + "/i18n";
+}
+
+std::string CSystemUtilsMacOSX::GetProfileFileLocation()
+{
+ std::string profileFile = m_ASPath + "/colobot.ini";
+
+ GetLogger()->Trace("Profile file is %s\n", profileFile.c_str());
+ return profileFile;
+}
+
+std::string CSystemUtilsMacOSX::GetSavegameDirectoryLocation()
+{
+ std::string savegameDir = m_ASPath + "/savegame";
+ boost::filesystem::create_directories(savegameDir.c_str());
+ GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
+
+ return savegameDir;
+}
+
diff --git a/src/app/system_macosx.h b/src/app/system_macosx.h
new file mode 100644
index 0000000..b6a044b
--- /dev/null
+++ b/src/app/system_macosx.h
@@ -0,0 +1,39 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * 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/.
+
+/**
+ * \file app/system_macosx.h
+ * \brief MacOSX-specific implementation of system functions
+ */
+
+#include "app/system.h"
+#include "app/system_other.h"
+
+class CSystemUtilsMacOSX : public CSystemUtilsOther
+{
+public:
+ virtual void Init() override;
+
+ virtual std::string GetDataPath() override;
+ virtual std::string GetLangPath() override;
+ virtual std::string GetProfileFileLocation() override;
+ virtual std::string GetSavegameDirectoryLocation() override;
+private:
+ std::string m_ASPath;
+ std::string m_dataPath;
+};
+
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake
index 2f403fa..63cd93b 100644
--- a/src/common/config.h.cmake
+++ b/src/common/config.h.cmake
@@ -6,6 +6,11 @@
#cmakedefine PLATFORM_MACOSX @PLATFORM_MACOSX@
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
+#ifdef PLATFORM_MACOSX
+// Assume we have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework
+#define HAVE_CFLOCALECOPYCURRENT 1
+#endif
+
#cmakedefine GLEW_STATIC
#cmakedefine OPENAL_SOUND
diff --git a/src/common/global.h b/src/common/global.h
index a322057..da62bac 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -173,7 +173,8 @@ enum Language
LANGUAGE_ENGLISH = 0,
LANGUAGE_FRENCH = 1,
LANGUAGE_GERMAN = 2,
- LANGUAGE_POLISH = 3
+ LANGUAGE_POLISH = 3,
+ LANGUAGE_RUSSIAN = 4
};
/**
diff --git a/src/common/image.cpp b/src/common/image.cpp
index a9587ef..8a876e3 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -218,15 +218,30 @@ void CImage::PadToNearestPowerOfTwo()
int w = Math::NextPowerOfTwo(m_data->surface->w);
int h = Math::NextPowerOfTwo(m_data->surface->h);
+ BlitToNewRGBASurface(w, h);
+}
+
+void CImage::ConvertToRGBA()
+{
+ assert(m_data != nullptr);
+
+ int w = m_data->surface->w;
+ int h = m_data->surface->h;
+
+ BlitToNewRGBASurface(w, h);
+}
+
+void CImage::BlitToNewRGBASurface(int width, int height)
+{
m_data->surface->flags &= (~SDL_SRCALPHA);
- SDL_Surface* resizedSurface = SDL_CreateRGBSurface(0, w, h, 32, 0x00ff0000, 0x0000ff00,
- 0x000000ff, 0xff000000);
- assert(resizedSurface != NULL);
- SDL_BlitSurface(m_data->surface, NULL, resizedSurface, NULL);
+ SDL_Surface* convertedSurface = SDL_CreateRGBSurface(0, width, height, 32, 0x00FF0000, 0x0000FF00,
+ 0x000000FF, 0xFF000000);
+ assert(convertedSurface != nullptr);
+ SDL_BlitSurface(m_data->surface, nullptr, convertedSurface, nullptr);
SDL_FreeSurface(m_data->surface);
- m_data->surface = resizedSurface;
+ m_data->surface = convertedSurface;
}
/**
@@ -376,6 +391,11 @@ bool CImage::Load(const std::string& fileName)
return false;
}
+ if (m_data->surface->format->palette != nullptr)
+ {
+ ConvertToRGBA();
+ }
+
return true;
}
diff --git a/src/common/image.h b/src/common/image.h
index 44aedf1..31dab2d 100644
--- a/src/common/image.h
+++ b/src/common/image.h
@@ -97,6 +97,9 @@ public:
//! Pads the image to nearest power of 2 dimensions
void PadToNearestPowerOfTwo();
+ //! Convert the image to RGBA surface
+ void ConvertToRGBA();
+
//! Loads an image from the specified file
bool Load(const std::string &fileName);
@@ -107,6 +110,9 @@ public:
std::string GetError();
private:
+ //! Blit to new RGBA surface with given size
+ void BlitToNewRGBASurface(int width, int height);
+
//! Last encountered error
std::string m_error;
//! Image data
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 6fe85d3..26fa827 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -3138,9 +3138,9 @@ void CRobotMain::CreateTooltip(Math::Point pos, const char* text)
start, end);
start.x -= 0.010f;
- start.y -= 0.002f;
+ start.y -= 0.006f;
end.x += 0.010f;
- end.y += 0.004f; // ch'tite (?) margin
+ end.y += 0.008f; // small'ish margin
pos.x = start.x;
pos.y = start.y;
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 7c77c95..bed84dd 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -57,7 +57,7 @@ CControl::~CControl()
bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- char text[100];
+ char text[200];
std::string str_text;
if ( eventType == EVENT_NULL )
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 8005939..6e082e6 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -1191,8 +1191,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
else if ( icon == 1 )
{
m_engine->SetTexture("button1.png");
- m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
- uv1.x = 128.0f/256.0f; // yellow tooltip
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 128.0f/256.0f; // white tooltip
uv1.y = 0.0f/256.0f;
uv2.x = 224.0f/256.0f;
uv2.y = 16.0f/256.0f;