robotmain, restext and engine fixes

dev-ui
Piotr Dziwinski 2012-09-21 00:01:03 +02:00
parent 34a11021da
commit 60c37aac3a
7 changed files with 118 additions and 355 deletions

View File

@ -19,6 +19,7 @@
#include "common/global.h"
#include "common/event.h"
#include "common/logger.h"
#include "common/stringutils.h"
#include "CBot/resource.h"
#include "object/object.h"
#include "object/robotmain.h"
@ -136,41 +137,66 @@ static const char* GetResourceBase(ResType type, int num)
switch (type)
{
case RES_TEXT:
assert(num < strings_text_len);
str = strings_text[num];
break;
case RES_EVENT:
// assert(num < strings_event_len);
if (num >= strings_event_len)
{
GetLogger()->Warn("GetResource invalid event num: %d\n", num);
return "";
}
str = strings_event[num];
break;
case RES_OBJECT:
assert(num < strings_object_len);
if (num == OBJECT_HUMAN)
return g_gamerName;
str = strings_object[num];
break;
case RES_ERR:
assert(num < strings_err_len);
str = strings_err[num];
break;
case RES_CBOT:
assert(num < strings_cbot_len);
str = strings_cbot[num];
break;
case RES_KEY:
assert(num < SDLK_LAST);
// TODO: virtual keys
str = SDL_GetKeyName(static_cast<SDLKey>(num));
break;
default:
assert(false);
case RES_TEXT:
assert(num < strings_text_len);
str = strings_text[num];
break;
case RES_EVENT:
// assert(num < strings_event_len);
if (num >= strings_event_len)
{
GetLogger()->Trace("GetResource event num out of range: %d\n", num); // TODO: fix later
return "";
}
str = strings_event[num];
break;
case RES_OBJECT:
assert(num < strings_object_len);
if (num == OBJECT_HUMAN)
return g_gamerName;
str = strings_object[num];
break;
case RES_ERR:
assert(num < strings_err_len);
str = strings_err[num];
break;
case RES_CBOT:
assert(num < strings_cbot_len);
str = strings_cbot[num];
break;
case RES_KEY:
if (num == VIRTUAL_KMOD_CTRL)
return "Ctrl";
else if (num == VIRTUAL_KMOD_SHIFT)
return "Shift";
else if (num == VIRTUAL_KMOD_ALT)
return "Alt";
else if (num == VIRTUAL_KMOD_META)
return "Win";
else if (num > VIRTUAL_JOY(0))
{
// TODO: temporary fix
static std::string sstr;
sstr = gettext("Button %1");
StrUtils::Replace(sstr, "%1", StrUtils::ToString<int>(1 + num - VIRTUAL_JOY(0)));
return sstr.c_str();
}
else
str = SDL_GetKeyName(static_cast<SDLKey>(num));
break;
default:
assert(false);
}
return gettext(str);
}

View File

@ -3049,7 +3049,10 @@ void CEngine::Draw3DScene()
m_particle->DrawParticle(SH_WORLD); // draws the particles of the 3D world
m_lightning->Draw(); // draws lightning
if (m_lensMode) DrawForegroundImage(); // draws the foreground
// TODO: fix white screen error; commenting out temporarily
// if (m_lensMode) DrawForegroundImage(); // draws the foreground
if (! m_overFront) DrawOverColor(); // draws the foreground color
}

View File

@ -3747,6 +3747,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
char dir[100];
char op[100];
memset(line, 0, 500);
memset(name, 0, 200);
memset(dir, 0, 100);
memset(op, 0, 100);
m_dialog->BuildSceneName(line, base, rank);
FILE* file = fopen(line, "r");
if (file == NULL) return;

View File

@ -1965,101 +1965,8 @@ msgstr "Zoom"
msgid "PA1"
msgstr "PA1"
msgid "Button 1"
msgstr "Knopf 1"
msgid "Button 2"
msgstr "Knopf 2"
msgid "Button 3"
msgstr "Knopf 3"
msgid "Button 4"
msgstr "Knopf 4"
msgid "Button 5"
msgstr "Knopf 5"
msgid "Button 6"
msgstr "Knopf 6"
msgid "Button 7"
msgstr "Knopf 7"
msgid "Button 8"
msgstr "Knopf 8"
msgid "Button 9"
msgstr "Knopf 9"
msgid "Button 10"
msgstr "Knopf 10"
msgid "Button 11"
msgstr "Knopf 11"
msgid "Button 12"
msgstr "Knopf 12"
msgid "Button 13"
msgstr "Knopf 13"
msgid "Button 14"
msgstr "Knopf 14"
msgid "Button 15"
msgstr "Knopf 15"
msgid "Button 16"
msgstr "Knopf 16"
msgid "Button 17"
msgstr "Knopf 17"
msgid "Button 18"
msgstr "Knopf 18"
msgid "Button 19"
msgstr "Knopf 19"
msgid "Button 20"
msgstr "Knopf 20"
msgid "Button 21"
msgstr "Knopf 21"
msgid "Button 22"
msgstr "Knopf 22"
msgid "Button 23"
msgstr "Knopf 23"
msgid "Button 24"
msgstr "Knopf 24"
msgid "Button 25"
msgstr "Knopf 25"
msgid "Button 26"
msgstr "Knopf 26"
msgid "Button 27"
msgstr "Knopf 27"
msgid "Button 28"
msgstr "Knopf 28"
msgid "Button 29"
msgstr "Knopf 29"
msgid "Button 30"
msgstr "Knopf 30"
msgid "Button 31"
msgstr "Knopf 31"
msgid "Button 32"
msgstr "Knopf 32"
msgid "Button %1"
msgstr "Knopf %1"
msgid "Wheel up"
msgstr "Mausrad nach vorne"

View File

@ -1967,101 +1967,8 @@ msgstr "Zoom"
msgid "PA1"
msgstr "PA1"
msgid "Button 1"
msgstr "Bouton 1"
msgid "Button 2"
msgstr "Bouton 2"
msgid "Button 3"
msgstr "Bouton 3"
msgid "Button 4"
msgstr "Bouton 4"
msgid "Button 5"
msgstr "Bouton 5"
msgid "Button 6"
msgstr "Bouton 6"
msgid "Button 7"
msgstr "Bouton 7"
msgid "Button 8"
msgstr "Bouton 8"
msgid "Button 9"
msgstr "Bouton 9"
msgid "Button 10"
msgstr "Bouton 10"
msgid "Button 11"
msgstr "Bouton 11"
msgid "Button 12"
msgstr "Bouton 12"
msgid "Button 13"
msgstr "Bouton 13"
msgid "Button 14"
msgstr "Bouton 14"
msgid "Button 15"
msgstr "Bouton 15"
msgid "Button 16"
msgstr "Bouton 16"
msgid "Button 17"
msgstr "Bouton 17"
msgid "Button 18"
msgstr "Bouton 18"
msgid "Button 19"
msgstr "Bouton 19"
msgid "Button 20"
msgstr "Bouton 20"
msgid "Button 21"
msgstr "Bouton 21"
msgid "Button 22"
msgstr "Bouton 22"
msgid "Button 23"
msgstr "Bouton 23"
msgid "Button 24"
msgstr "Bouton 24"
msgid "Button 25"
msgstr "Bouton 25"
msgid "Button 26"
msgstr "Bouton 26"
msgid "Button 27"
msgstr "Bouton 27"
msgid "Button 28"
msgstr "Bouton 28"
msgid "Button 29"
msgstr "Bouton 29"
msgid "Button 30"
msgstr "Bouton 30"
msgid "Button 31"
msgstr "Bouton 31"
msgid "Button 32"
msgstr "Bouton 32"
msgid "Button %1"
msgstr "Bouton %1"
msgid "Wheel up"
msgstr "Molette haut"

View File

@ -1974,101 +1974,8 @@ msgstr "Powiększenie"
msgid "PA1"
msgstr "PA1"
msgid "Button 1"
msgstr "Przycisk 1"
msgid "Button 2"
msgstr "Przycisk 2"
msgid "Button 3"
msgstr "Przycisk 3"
msgid "Button 4"
msgstr "Przycisk 4"
msgid "Button 5"
msgstr "Przycisk 5"
msgid "Button 6"
msgstr "Przycisk 6"
msgid "Button 7"
msgstr "Przycisk 7"
msgid "Button 8"
msgstr "Przycisk 8"
msgid "Button 9"
msgstr "Przycisk 9"
msgid "Button 10"
msgstr "Przycisk 10"
msgid "Button 11"
msgstr "Przycisk 11"
msgid "Button 12"
msgstr "Przycisk 12"
msgid "Button 13"
msgstr "Przycisk 13"
msgid "Button 14"
msgstr "Przycisk 14"
msgid "Button 15"
msgstr "Przycisk 15"
msgid "Button 16"
msgstr "Przycisk 16"
msgid "Button 17"
msgstr "Przycisk 17"
msgid "Button 18"
msgstr "Przycisk 18"
msgid "Button 19"
msgstr "Przycisk 19"
msgid "Button 20"
msgstr "Przycisk 20"
msgid "Button 21"
msgstr "Przycisk 21"
msgid "Button 22"
msgstr "Przycisk 22"
msgid "Button 23"
msgstr "Przycisk 23"
msgid "Button 24"
msgstr "Przycisk 24"
msgid "Button 25"
msgstr "Przycisk 25"
msgid "Button 26"
msgstr "Przycisk 26"
msgid "Button 27"
msgstr "Przycisk 27"
msgid "Button 28"
msgstr "Przycisk 28"
msgid "Button 29"
msgstr "Przycisk 29"
msgid "Button 30"
msgstr "Przycisk 30"
msgid "Button 31"
msgstr "Przycisk 31"
msgid "Button 32"
msgstr "Przycisk 32"
msgid "Button %1"
msgstr "Przycisk %1"
msgid "Wheel up"
msgstr "Kółko w górę"

View File

@ -1831,7 +1831,7 @@ void CMainDialog::ChangePhase(Phase phase)
pe->SetHiliteCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(8.0f);
pe->ReadText("help\\authors.txt");
pe->ReadText("help/authors.txt");
pos.x = 80.0f/640.0f;
pos.y = 140.0f/480.0f;
@ -1843,7 +1843,7 @@ void CMainDialog::ChangePhase(Phase phase)
pe->SetHiliteCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(6.5f);
pe->ReadText("help\\licences.txt");
pe->ReadText("help/licences.txt");
// #endif
/* TODO: #if _SCHOOL
#if _CEEBOTDEMO
@ -1863,7 +1863,7 @@ void CMainDialog::ChangePhase(Phase phase)
pe->SetHiliteCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(8.0f);
pe->ReadText("help\\authors.txt");
pe->ReadText("help/authors.txt");
/* #if _DEMO
//? pos.x = 80.0f/640.0f;
@ -1876,7 +1876,7 @@ void CMainDialog::ChangePhase(Phase phase)
//? pe->SetHiliteCap(false);
//? pe->SetFontType(Gfx::FONT_COURIER);
//? pe->SetFontSize(8.0f);
//? pe->ReadText("help\\demo.txt");
//? pe->ReadText("help/demo.txt");
//? pos.x = 80.0f/640.0f;
//? pos.y = 140.0f/480.0f;
@ -1888,7 +1888,7 @@ void CMainDialog::ChangePhase(Phase phase)
//? pe->SetHiliteCap(false);
//? pe->SetFontType(Gfx::FONT_COURIER);
//? pe->SetFontSize(8.0f);
//? pe->ReadText("help\\authors.txt");
//? pe->ReadText("help/authors.txt");
#endif */
// TODO: #if !_DEMO
@ -2097,7 +2097,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE )
{
m_glintMouse = event.pos;
NiceParticle(event.pos, event.keyState&KS_MLEFT);
NiceParticle(event.pos, event.trackedKeys & TRKEY_NUM_LEFT);
}
if ( m_bDialog ) // this dialogue?
@ -3573,7 +3573,7 @@ void CMainDialog::SetUserDir(char *base, int rank)
if ( strcmp(base, "user") == 0 && rank >= 100 )
{
sprintf(dir, "%s\\%s", m_userDir, m_userList[rank/100-1]);
sprintf(dir, "%s/%s", m_userDir, m_userList[rank/100-1]);
UserDir(true, dir);
}
else
@ -3588,11 +3588,11 @@ void CMainDialog::BuildSceneName(char *filename, char *base, int rank)
{
if ( strcmp(base, "user") == 0 )
{
sprintf(filename, "%s\\%s\\scene%.2d.txt", m_userDir, m_userList[rank/100-1], rank%100);
sprintf(filename, "%s/%s/scene%.2d.txt", m_userDir, m_userList[rank/100-1], rank%100);
}
else
{
sprintf(filename, "%s\\%s%.3d.txt", m_sceneDir, base, rank);
sprintf(filename, "%s/%s%.3d.txt", m_sceneDir, base, rank);
}
}
@ -3633,7 +3633,7 @@ void CMainDialog::ReadNameList()
nbFilenames = 0;
sprintf(dir, ".\\%s", m_savegameDir);
sprintf(dir, "./%s", m_savegameDir);
// if (! boost::filesystem::exists(dir))
// {
@ -3902,7 +3902,7 @@ void CMainDialog::NameCreate()
// TODO: _mkdir(m_savegameDir); // if does not exist yet!
sprintf(dir, "%s\\%s", m_savegameDir, name);
sprintf(dir, "%s/%s", m_savegameDir, name);
// TODO: if ( _mkdir(dir) != 0 )
{
m_sound->Play(SOUND_TZOING);
@ -3927,7 +3927,7 @@ bool RemoveDir(char *dirname)
struct _finddata_t fBuffer;
char filename[100];
sprintf(filename, "%s\\*", dirname);
sprintf(filename, "%s/*", dirname);
hFile = _findfirst(filename, &fBuffer);
if ( hFile != -1 )
{
@ -3937,12 +3937,12 @@ bool RemoveDir(char *dirname)
{
if ( fBuffer.attrib & _A_SUBDIR )
{
sprintf(filename, "%s\\%s", dirname, fBuffer.name);
sprintf(filename, "%s/%s", dirname, fBuffer.name);
RemoveDir(filename);
}
else
{
sprintf(filename, "%s\\%s", dirname, fBuffer.name);
sprintf(filename, "%s/%s", dirname, fBuffer.name);
remove(filename);
}
}
@ -3981,7 +3981,7 @@ void CMainDialog::NameDelete()
gamer = pl->GetName(sel);
// Deletes all the contents of the file.
sprintf(dir, "%s\\%s", m_savegameDir, gamer);
sprintf(dir, "%s/%s", m_savegameDir, gamer);
if ( !RemoveDir(dir) )
{
m_sound->Play(SOUND_TZOING);
@ -4295,7 +4295,7 @@ bool CMainDialog::IsIOReadScene()
FILE* file;
char filename[100];
sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], 0);
sprintf(filename, "%s/%s/save%c%.3d/data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], 0);
file = fopen(filename, "r");
if ( file == NULL ) return false;
fclose(file);
@ -4379,7 +4379,7 @@ void CMainDialog::IOReadList()
for ( j=0 ; j<999 ; j++ )
{
sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j);
sprintf(filename, "%s/%s/save%c%.3d/data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j);
file = fopen(filename, "r");
if ( file == NULL ) break;
@ -4440,7 +4440,7 @@ void CMainDialog::IOUpdateList()
sel = pl->GetSelect();
max = pl->GetTotal();
sprintf(filename, "%s\\%s\\save%c%.3d\\screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filename, "%s/%s/save%c%.3d/screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
if ( m_phase == PHASE_WRITE ||
m_phase == PHASE_WRITEs )
@ -4492,7 +4492,7 @@ void CMainDialog::IODeleteScene()
/* TODO: remove files
// Deletes all the contents of the file.
sprintf(dir, "%s\\%s\\save%c%.3d\\*", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(dir, "%s/%s/save%c%.3d/*", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
hFile = _findfirst(dir, &fBuffer);
if ( hFile != -1 )
{
@ -4500,14 +4500,14 @@ void CMainDialog::IODeleteScene()
{
if ( fBuffer.name[0] != '.' )
{
sprintf(dir, "%s\\%s\\save%c%.3d\\%s", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel, fBuffer.name);
sprintf(dir, "%s/%s/save%c%.3d/%s", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel, fBuffer.name);
remove(dir);
}
}
while ( _findnext(hFile, &fBuffer) == 0 );
}
sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(dir, "%s/%s/save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
if ( _rmdir(dir) != 0 )
{
m_sound->Play(SOUND_TZOING);
@ -4518,8 +4518,8 @@ void CMainDialog::IODeleteScene()
max = pl->GetTotal();
for ( i=sel+1 ; i<max ; i++ )
{
sprintf(old, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i);
sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i-1);
sprintf(old, "%s/%s/save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i);
sprintf(dir, "%s/%s/save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i-1);
rename(old, dir);
}*/
IOReadList();
@ -4548,18 +4548,18 @@ bool CMainDialog::IOWriteScene()
if ( sel == -1 ) return false;
// TODO: _mkdir("Savegame"); // if doesn't exist yet!
sprintf(filename, "%s\\%s", m_savegameDir, m_main->GetGamerName());
sprintf(filename, "%s/%s", m_savegameDir, m_main->GetGamerName());
// TODO: _mkdir(filename);
sprintf(filename, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filename, "%s/%s/save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
// TODO: _mkdir(filename);
sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filename, "%s/%s/save%c%.3d/data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filecbot, "%s/%s/save%c%.3d/cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
pe->GetText(info, 100);
m_main->IOWriteScene(filename, filecbot, info);
m_shotDelay = 3;
sprintf(m_shotName, "%s\\%s\\save%c%.3d\\screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(m_shotName, "%s/%s/save%c%.3d/screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
return true;
}
@ -4585,8 +4585,8 @@ bool CMainDialog::IOReadScene()
sel = pl->GetSelect();
if ( sel == -1 ) return false;
sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filename, "%s/%s/save%c%.3d/data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
sprintf(filecbot, "%s/%s/save%c%.3d/cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
file = fopen(filename, "r");
if ( file == NULL ) return false;
@ -4690,6 +4690,10 @@ void CMainDialog::UpdateSceneChap(int &chap)
int i, j;
bool bPassed, bDo;
memset(op, 0, 100);
memset(line, 0, 500);
memset(name, 0, 100);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP));
@ -4701,7 +4705,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
{
j = 0;
/* TODO: list files
hFile = _findfirst("user\\*", &fileBuffer);
hFile = _findfirst("user/*", &fileBuffer);
if ( hFile != -1 )
{
do
@ -4860,6 +4864,10 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
int i, j;
bool bPassed;
memset(op, 0, 100);
memset(line, 0, 500);
memset(name, 0, 100);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST));
@ -6643,7 +6651,7 @@ void CMainDialog::WriteGamerPerso(char *gamer)
char filename[100];
char line[100];
sprintf(filename, "%s\\%s\\face.gam", m_savegameDir, gamer);
sprintf(filename, "%s/%s/face.gam", m_savegameDir, gamer);
file = fopen(filename, "w");
if ( file == NULL ) return;
@ -6672,7 +6680,7 @@ void CMainDialog::ReadGamerPerso(char *gamer)
m_perso.face = 0;
DefPerso();
sprintf(filename, "%s\\%s\\face.gam", m_savegameDir, gamer);
sprintf(filename, "%s/%s/face.gam", m_savegameDir, gamer);
file = fopen(filename, "r");
if ( file == NULL ) return;
@ -6777,7 +6785,7 @@ bool CMainDialog::ReadGamerInfo()
m_sceneInfo[i].bPassed = false;
}
sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName);
sprintf(line, "%s/%s/%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName);
file = fopen(line, "r");
if ( file == NULL ) return false;
@ -6813,7 +6821,7 @@ bool CMainDialog::WriteGamerInfo()
char line[100];
int i;
sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName);
sprintf(line, "%s/%s/%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName);
file = fopen(line, "w");
if ( file == NULL ) return false;