From 926126d5adf457dbc5c92fd83c7231415ea22d04 Mon Sep 17 00:00:00 2001 From: erihel Date: Mon, 1 Apr 2013 18:24:12 +0200 Subject: * Changed loading of scene and player info (there's problem with locales using , as comma separator). Issue #137 * Changed way of saving files. Now it's not based on slot (from 000 to 999) but it uses save name as a base. * Changed way of displaying saved games. Listing directory instead of checking from 000 to 999. Issue #138 --- src/ui/maindialog.cpp | 254 +++++++++++++++++++++++++------------------------- src/ui/maindialog.h | 4 + 2 files changed, 130 insertions(+), 128 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 9060e8b..75db2a6 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -4256,14 +4256,18 @@ void CMainDialog::DefPerso() bool CMainDialog::IsIOReadScene() { - FILE* file; - std::string filename; - - filename = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + "000/data.sav"; - file = fopen(filename.c_str(), "r"); - if ( file == NULL ) return false; - fclose(file); - return true; + fs::directory_iterator end_iter; + + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); + if (fs::exists(saveDir) && fs::is_directory(saveDir)) { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { + return true; + } + } + } + + return false; } // Builds the file name by default. @@ -4283,9 +4287,9 @@ void CMainDialog::IOReadName() int i; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return; + if ( pw == nullptr ) return; pe = static_cast(pw->SearchControl(EVENT_INTERFACE_IONAME)); - if ( pe == 0 ) return; + if ( pe == nullptr ) return; sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1); BuildSceneName(filename, m_sceneName, (m_chap[m_index]+1)*100); @@ -4337,7 +4341,8 @@ void CMainDialog::IOReadList() CList* pl; char line[500]; char name[100]; - int i, j; + int i; + fs::directory_iterator end_iter; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; @@ -4345,50 +4350,46 @@ void CMainDialog::IOReadList() if ( pl == 0 ) return; pl->Flush(); + + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); + m_saveList.clear(); + + if (fs::exists(saveDir) && fs::is_directory(saveDir)) { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { + + file = fopen((dir_iter->path() / "data.sav").make_preferred().string().c_str(), "r"); + if ( file == NULL ) continue; + + while ( fgets(line, 500, file) != NULL ) { + for ( i=0 ; i<500 ; i++ ) { + if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space + if ( line[i] == '/' && line[i+1] == '/' ) { + line[i] = 0; + break; + } + } - for ( j=0 ; j<999 ; j++ ) - { - std::string filename; - std::ostringstream rankStream; - rankStream << std::setfill('0') << std::setw(3) << j; - filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/data.sav"; - - // sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j); - file = fopen(fs::path(filename).make_preferred().string().c_str(), "r"); - if ( file == NULL ) break; - - while ( fgets(line, 500, file) != NULL ) - { - for ( i=0 ; i<500 ; i++ ) - { - if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) - { - line[i] = 0; - break; + if ( Cmd(line, "Title") ) { + OpString(line, "text", name); + break; + } } - } + fclose(file); - if ( Cmd(line, "Title") ) - { - OpString(line, "text", name); - break; + pl->SetName(m_saveList.size(), name); + m_saveList.push_back(dir_iter->path()); } } - fclose(file); - - pl->SetName(j, name); } - - if ( m_phase == PHASE_WRITE || - m_phase == PHASE_WRITEs ) - { + + // zly indeks + if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { GetResource(RES_TEXT, RT_IO_NEW, name); - pl->SetName(j, name); - j ++; + pl->SetName(m_saveList.size(), name); } - pl->SetSelect(j-1); + pl->SetSelect(m_saveList.size()); pl->ShowSelect(false); // shows the selected columns } @@ -4403,35 +4404,31 @@ void CMainDialog::IOUpdateList() int sel, max; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return; + if ( pw == nullptr ) return; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_IOLIST)); - if ( pl == 0 ) return; + if ( pl == nullptr ) return; pi = static_cast(pw->SearchControl(EVENT_INTERFACE_IOIMAGE)); - if ( pi == 0 ) return; + if ( pi == nullptr ) return; sel = pl->GetSelect(); max = pl->GetTotal(); - std::string filename; - std::ostringstream rankStream; - rankStream << std::setfill('0') << std::setw(3) << sel; - filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/screen.png"; - - if ( m_phase == PHASE_WRITE || - m_phase == PHASE_WRITEs ) + if (m_saveList.size() <= static_cast(sel)) { + return; + } + + std::string filename = (m_saveList.at(sel) / "screen.png").make_preferred().string(); + if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { - if ( sel < max-1 ) - { + if ( sel < max-1 ) { pi->SetFilenameImage(filename.c_str()); } - else - { + else { pi->SetFilenameImage(""); } pb = static_cast(pw->SearchControl(EVENT_INTERFACE_IODELETE)); - if ( pb != 0 ) - { + if ( pb != nullptr ) { pb->SetState(STATE_ENABLE, sel < max-1); } } @@ -4455,34 +4452,40 @@ void CMainDialog::IODeleteScene() if ( pl == 0 ) return; sel = pl->GetSelect(); - if ( sel == -1 ) + if ( sel == -1 || m_saveList.size() <= static_cast(sel)) { m_sound->Play(SOUND_TZOING); return; } - - std::ostringstream rankStream; - std::string fileName; - rankStream << std::setfill('0') << std::setw(3) << sel; - fileName = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str(); try { - if (fs::exists(fileName) && fs::is_directory(fileName)) - { - fs::remove_all(fileName); + if (fs::exists(m_saveList.at(sel)) && fs::is_directory(m_saveList.at(sel))) { + fs::remove_all(m_saveList.at(sel)); } } - catch (std::exception & e) - { - GetLogger()->Error("Error on removing directory %s : %s\n", e.what()); + catch (std::exception & e) { + GetLogger()->Error("Error removing save %s : %s\n", pl->GetName(sel), e.what()); } IOReadList(); } -// Writes the scene. +// clears filename only to leave letter or numbers +std::string clearName(char *name) +{ + std::string ret; + int len = strlen(name); + for (int i = 0; i < len; i++) { + if (isalnum(name[i])) { + ret += name[i]; + } + } + return ret; +} + +// Writes the scene. bool CMainDialog::IOWriteScene() { CWindow* pw; @@ -4492,36 +4495,35 @@ bool CMainDialog::IOWriteScene() int sel; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return false; + if ( pw == nullptr ) return false; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_IOLIST)); - if ( pl == 0 ) return false; + if ( pl == nullptr ) return false; pe = static_cast(pw->SearchControl(EVENT_INTERFACE_IONAME)); - if ( pe == 0 ) return false; + if ( pe == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 ) return false; - - std::string directoryName; - std::string fileName; - std::string fileCBot; - std::ostringstream selectStream; - - //TODO: Change this to point user dir according to operating system - GetLogger()->Debug("Creating save directory\n"); - selectStream << std::setfill('0') << std::setw(3) << sel; - directoryName = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + selectStream.str(); - if (!fs::exists(directoryName)) - { - fs::create_directories(directoryName); + if ( sel == -1 ) { + return false; } - - fileName = directoryName + "/data.sav"; - fileCBot = directoryName + "/cbot.run"; + + fs::path dir; pe->GetText(info, 100); + if (static_cast(sel) >= m_saveList.size()) { + dir = fs::path(m_savegameDir) / m_main->GetGamerName() / ("save" + clearName(info)); + } else { + dir = m_saveList.at(sel); + } + + if (!fs::exists(dir)) { + fs::create_directories(dir); + } + + std::string fileName = (dir / "data.sav").make_preferred().string(); + std::string fileCBot = (dir / "cbot.run").make_preferred().string(); m_main->IOWriteScene(fileName.c_str(), fileCBot.c_str(), info); m_shotDelay = 3; - m_shotName = directoryName + "/screen.png"; + m_shotName = (dir / "screen.png").make_preferred().string(); return true; } @@ -4538,58 +4540,46 @@ bool CMainDialog::IOReadScene() int sel, i; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return false; + if ( pw == nullptr ) return false; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_IOLIST)); - if ( pl == 0 ) return false; + if ( pl == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 ) return false; - - //TODO: Change this to point user dir according to operating system - std::string fileName; - std::string fileCbot; - std::string directoryName; - std::ostringstream selectStream; - selectStream << std::setfill('0') << std::setw(3) << sel; - directoryName = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + selectStream.str(); + if ( sel == -1 || m_saveList.size() <= static_cast(sel) ) { + return false; + } - fileName = directoryName + "/data.sav"; - fileCbot = directoryName + "/cbot.run"; + std::string fileName = (m_saveList.at(sel) / "data.sav").make_preferred().string(); + std::string fileCbot = (m_saveList.at(sel) / "cbot.run").make_preferred().string(); file = fopen(fileName.c_str(), "r"); - if ( file == NULL ) return false; + if ( file == NULL ) { + return false; + } - while ( fgets(line, 500, file) != NULL ) - { - for ( i=0 ; i<500 ; i++ ) - { + while ( fgets(line, 500, file) != NULL ) { + for ( i=0 ; i<500 ; i++ ) { if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) - { + if ( line[i] == '/' && line[i+1] == '/' ) { line[i] = 0; break; } } - if ( Cmd(line, "Mission") ) - { + if ( Cmd(line, "Mission") ) { OpString(line, "base", m_sceneName); m_sceneRank = OpInt(line, "rank", 0); - if ( strcmp(m_sceneName, "user") == 0 ) - { + if ( strcmp(m_sceneName, "user") == 0 ) { m_sceneRank = m_sceneRank%100; OpString(line, "dir", dir); - for ( i=0 ; iSetNumericLocale(); + sprintf(line, "Head face=%d glasses=%d hair=%.2f;%.2f;%.2f;%.2f\n", m_perso.face, m_perso.glasses, m_perso.colorHair.r, m_perso.colorHair.g, m_perso.colorHair.b, m_perso.colorHair.a); @@ -6553,6 +6545,8 @@ void CMainDialog::WriteGamerPerso(char *gamer) fputs(line, file); fclose(file); + + m_main->RestoreNumericLocale(); } // Reads the personalized player. @@ -6570,6 +6564,8 @@ void CMainDialog::ReadGamerPerso(char *gamer) sprintf(filename, "%s/%s/face.gam", m_savegameDir.c_str(), gamer); file = fopen(filename, "r"); if ( file == NULL ) return; + + m_main->SetNumericLocale(); while ( fgets(line, 100, file) != NULL ) { @@ -6602,6 +6598,8 @@ void CMainDialog::ReadGamerPerso(char *gamer) } fclose(file); + + m_main->RestoreNumericLocale(); } // Specifies the face of the player. diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index a79b95e..afdf94f 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -26,6 +26,8 @@ #include #include +#include + namespace fs = boost::filesystem; @@ -260,6 +262,8 @@ protected: Math::Point m_partiPos[10]; SceneInfo m_sceneInfo[MAXSCENE]; + + std::vector m_saveList; }; } // namespace Ui -- cgit v1.2.3-1-g7c22 From 7146cf8ee65d35dcc8b1bfa55bc7b25b3ca73d2d Mon Sep 17 00:00:00 2001 From: erihel Date: Mon, 8 Apr 2013 12:58:00 +0200 Subject: * Issue #60: Fix for "(null)" instead of time on windows platform --- src/ui/studio.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 29dfebf..3010d5a 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1511,8 +1511,8 @@ void CStudio::UpdateDialogList() fs::path path; int i = 0; char time[100]; - char temp[100]; - + std::ostringstream temp; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); @@ -1525,9 +1525,8 @@ void CStudio::UpdateDialogList() for( fs::directory_iterator file(path); file != end_iter; file++) { if (fs::is_regular_file(file->status()) ) { TimeToAscii(fs::last_write_time(file->path()), time); - sprintf(temp, "%s\t%lu \t%s", file->path().filename().string().c_str(), fs::file_size(file->path()), time); - - pl->SetName(i++, temp); + temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; + pl->SetName(i++, temp.str().c_str()); } } } -- cgit v1.2.3-1-g7c22 From a66abd4990c6c415bafe3ce879bc67d7539a2901 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 9 Apr 2013 12:20:40 +0200 Subject: * Loading 3D sound settings from profile --- src/ui/maindialog.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 75db2a6..b75fab6 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -5719,6 +5719,11 @@ void CMainDialog::SetupRecall() { m_sound->SetMusicVolume(iValue); } + + if ( GetProfile().GetLocalProfileInt("Setup", "Sound3D", iValue) ) + { + m_sound->SetSound3D(iValue == 1); + } if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentMode", iValue) ) { -- cgit v1.2.3-1-g7c22 From 01309c8bd0a9ac4476952ec5063499ec980a7b12 Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 11 Apr 2013 13:37:15 +0200 Subject: * Added clipboard support (issue #60) * Fixed keyboard shortcuts while code editing in game --- src/ui/edit.cpp | 238 +++++++++++++++++--------------------------------------- src/ui/edit.h | 2 +- 2 files changed, 72 insertions(+), 168 deletions(-) (limited to 'src/ui') diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index e60a040..7e657c8 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -20,6 +20,8 @@ #include "app/app.h" +#include "clipboard/clipboard.h" + #include namespace Ui { @@ -298,55 +300,53 @@ bool CEdit::EventProcess(const Event &event) bShift = ( (event.kmodState & KEY_MOD(SHIFT) ) != 0 ); bControl = ( (event.kmodState & KEY_MOD(CTRL) ) != 0); - if ( (event.key.unicode == 'X' && !bShift && bControl) || - ((event.kmodState & KEY_MOD(CTRL)) != 0 && bShift && !bControl) ) + if ( (event.key.key == KEY(x) && !bShift && bControl) || + (event.key.key == KEY(DELETE) && bShift && !bControl) ) { Cut(); return true; } - if ( (event.key.unicode == 'C' && !bShift && bControl) || - ((event.kmodState & KEY_MOD(CTRL)) != 0 && !bShift && bControl) ) + if ( (event.key.key == KEY(c) && !bShift && bControl) || + (event.key.key == KEY(INSERT) && !bShift && bControl) ) { Copy(); return true; } - if ( (event.key.unicode == 'V' && !bShift && bControl) || - ((event.kmodState & KEY_MOD(CTRL)) != 0 && bShift && !bControl) ) + if ( (event.key.key == KEY(v) && !bShift && bControl) || + (event.key.key == KEY(INSERT) && bShift && !bControl) ) { Paste(); return true; } - if ( event.key.unicode == 'A' && !bShift && bControl ) + if ( event.key.key == KEY(a) && !bShift && bControl ) { SetCursor(999999, 0); return true; } - if ( event.key.unicode == 'O' && !bShift && bControl ) + if ( event.key.key == KEY(o) && !bShift && bControl ) { Event newEvent(EVENT_STUDIO_OPEN); -// m_event->NewEvent(newEvent, EVENT_STUDIO_OPEN); m_event->AddEvent(newEvent); } - if ( event.key.unicode == 'S' && !bShift && bControl ) + if ( event.key.key == KEY(s) && !bShift && bControl ) { Event newEvent( EVENT_STUDIO_SAVE ); -// m_event->MakeEvent(newEvent, EVENT_STUDIO_SAVE); m_event->AddEvent(newEvent); } - if ( event.key.unicode == 'Z' && !bShift && bControl ) + if ( event.key.key == KEY(z) && !bShift && bControl ) { Undo(); return true; } - if ( event.key.unicode == 'U' && !bShift && bControl ) + if ( event.key.key == KEY(u) && !bShift && bControl ) { if ( MinMaj(false) ) return true; } - if ( event.key.unicode == 'U' && bShift && bControl ) + if ( event.key.key == KEY(u) && bShift && bControl ) { if ( MinMaj(true) ) return true; } @@ -2501,200 +2501,100 @@ void CEdit::ColumnFix() // Cut the selected characters or entire line. -bool CEdit::Cut() // TODO MS Windows allocations +bool CEdit::Cut() { - /* HGLOBAL hg; - char* text; - char c; - int c1, c2, start, len, i, j; - - if ( !m_bEdit ) return false; - - c1 = m_cursor1; - c2 = m_cursor2; - if ( c1 > c2 ) Math::Swap(c1, c2); // always c1 <= c2 - - if ( c1 == c2 ) - { - while ( c1 > 0 ) - { - if ( m_text[c1-1] == '\n' ) break; - c1 --; - } - while ( c2 < m_len ) - { - c2 ++; - if ( m_text[c2-1] == '\n' ) break; - } - } - - if ( c1 == c2 ) return false; - - start = c1; - len = c2-c1; - - if ( !(hg = GlobalAlloc(GMEM_DDESHARE, len*2+1)) ) - { - return false; - } - if ( !(text = (char*)GlobalLock(hg)) ) - { - GlobalFree(hg); - return false; - } - - j = 0; - for ( i=start ; i c2 ) Math::Swap(c1, c2); // always c1 <= c2 + if ( c1 > c2 ) { + Math::Swap(c1, c2); // always c1 <= c2 + } - if ( c1 == c2 ) - { - while ( c1 > 0 ) - { - if ( m_text[c1-1] == '\n' ) break; - c1 --; + if ( c1 == c2 ) { + while ( c1 > 0 ) { + if ( m_text[c1 - 1] == '\n' ) { + break; + } + c1--; } - while ( c2 < m_len ) - { - c2 ++; - if ( m_text[c2-1] == '\n' ) break; + while ( c2 < m_len ) { + c2++; + if ( m_text[c2 - 1] == '\n' ) { + break; + } } } - if ( c1 == c2 ) return false; - - start = c1; - len = c2-c1; - - if ( !(hg = GlobalAlloc(GMEM_DDESHARE, len*2+1)) ) - { - return false; - } - if ( !(text = (char*)GlobalLock(hg)) ) - { - GlobalFree(hg); + if ( c1 == c2 ) { return false; } - j = 0; - for ( i=start ; i Date: Thu, 11 Apr 2013 21:37:19 +0200 Subject: * Fix for bad file listing (issue #60) --- src/ui/studio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 3010d5a..1cedabb 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1511,7 +1511,6 @@ void CStudio::UpdateDialogList() fs::path path; int i = 0; char time[100]; - std::ostringstream temp; pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; @@ -1524,6 +1523,7 @@ void CStudio::UpdateDialogList() if ( fs::exists(path) && fs::is_directory(path) ) { for( fs::directory_iterator file(path); file != end_iter; file++) { if (fs::is_regular_file(file->status()) ) { + std::ostringstream temp; TimeToAscii(fs::last_write_time(file->path()), time); temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; pl->SetName(i++, temp.str().c_str()); -- cgit v1.2.3-1-g7c22 From b8d2ce2e4ef355fa82a3dded6d4b7dd9732f4358 Mon Sep 17 00:00:00 2001 From: XienDev Date: Thu, 25 Apr 2013 22:05:27 +0300 Subject: Welcome screen blinking fix --- src/ui/maindialog.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index b75fab6..092903d 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -63,7 +63,7 @@ const int KEY_VISIBLE = 6; // number of visible keys redefinable const int KEY_TOTAL = 21; // total number of keys redefinable -const float WELCOME_LENGTH = 2.0f; +const float WELCOME_LENGTH = 3.0f; const int MAX_FNAME = 255; // TODO: remove after rewrite to std::string @@ -1769,7 +1769,7 @@ pos.y -= 0.048f; ddim.y = 0.0f; pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5); - m_engine->SetOverColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok? + m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_WHITE); // TODO: color ok? m_engine->SetOverFront(true); m_engine->SetBackground("colobot.png", @@ -2006,28 +2006,35 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_WELCOME3 ) { float intensity; - int mode = Gfx::ENG_RSTATE_TCOLOR_BLACK; + int mode = Gfx::ENG_RSTATE_TCOLOR_WHITE; - if ( m_phaseTime < 1.5f ) + // 1/4 of display time is animating + float animatingTime = welcomeLength / 4.0f; + + if ( m_phaseTime < animatingTime ) { - intensity = 1.0f-(m_phaseTime-0.5f); + //appearing + intensity = m_phaseTime / animatingTime; } - else if ( m_phaseTime < welcomeLength-1.0f ) + else if ( m_phaseTime < welcomeLength - animatingTime ) { - intensity = 0.0f; + //showing + intensity = 1.0f; } else { - intensity = m_phaseTime-(welcomeLength-1.0f); + //hiding + intensity = (welcomeLength - m_phaseTime) / animatingTime; } + if ( intensity < 0.0f ) intensity = 0.0f; if ( intensity > 1.0f ) intensity = 1.0f; - if ( (m_phase == PHASE_WELCOME2 && m_phaseTime > welcomeLength/2.0f) || - m_phase == PHASE_WELCOME3 ) + //white first, others -> black fadding + if ( (m_phase == PHASE_WELCOME1) && ( m_phaseTime < welcomeLength/2.0f)) { - intensity = 1.0f-intensity; - mode = Gfx::ENG_RSTATE_TCOLOR_WHITE; + intensity = 1.0f - intensity; + mode = Gfx::ENG_RSTATE_TCOLOR_BLACK; } m_engine->SetOverColor(Gfx::Color(intensity, intensity, intensity, intensity), mode); // TODO: color ok? -- cgit v1.2.3-1-g7c22 From 02cb9a699352d4cc4cbb0e396d40c0571301fd64 Mon Sep 17 00:00:00 2001 From: XienDev Date: Thu, 25 Apr 2013 22:11:36 +0300 Subject: Fixes programs list size --- src/ui/interface.cpp | 3 +++ src/ui/list.cpp | 17 ++++++++++++++--- src/ui/window.cpp | 3 +++ 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 24d2626..893cd05 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -197,6 +197,9 @@ CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, Ev } // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 84aa8ca..fae7af9 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -68,6 +68,9 @@ CList::~CList() // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { @@ -109,14 +112,22 @@ bool CList::MoveAdjust() idim.x = m_dim.x - marging * 2.0f / 640.f; idim.y = m_dim.y - marging * 2.0f / 480.f; - h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * m_expand; - + //If m_expand is less then zero, then try to apply it's absolute value + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * ((m_expand < 0) ? -m_expand : m_expand); m_displayLine = static_cast(idim.y / h); + if (m_displayLine == 0) return false; if (m_displayLine > LISTMAXDISPLAY) m_displayLine = LISTMAXDISPLAY; - idim.y = h * m_displayLine; + + // Stretch lines to fill whole area of a list, if needed + if (m_expand < 0 && (idim.y - (h * m_displayLine) < h)) + { + h = idim.y / m_displayLine; + } + + idim.y = h * m_displayLine; //Here cuts list size if height of shown elements is less then designed height m_dim.y = idim.y + marging * 2.0f / 480.f; ppos.x = ipos.x; diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 6013d37..69ef857 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -355,6 +355,9 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event } // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) -- cgit v1.2.3-1-g7c22 From c2932f4ee3c65aa5546a8b2fd605af9043aba72a Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 29 Apr 2013 15:33:28 +0200 Subject: Added new Intro music (by PiXeL) --- src/ui/maindialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 092903d..699cb7b 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -747,7 +747,7 @@ pb->SetState(STATE_SHADOW); m_phase == PHASE_PROTO ) { if (!m_sound->IsPlayingMusic()) { - m_sound->PlayMusic(11, true); + m_sound->PlayMusic("Intro.ogg", false); } if ( m_phase == PHASE_TRAINER ) m_index = 0; @@ -1742,7 +1742,7 @@ pos.y -= 0.048f; if ( m_phase == PHASE_WELCOME1 ) { m_sound->StopMusic(); - m_sound->PlayMusic(11, false); + m_sound->PlayMusic("Intro.ogg", false); pos.x = 0.0f; pos.y = 0.0f; -- cgit v1.2.3-1-g7c22 From 9e1870f6bdb24e278c06929b8bd13225a7fdf8d3 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 13:19:10 +0200 Subject: Removed some warnings + fix for previous commit --- src/ui/edit.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index 7e657c8..c9831dd 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -688,7 +688,7 @@ void CEdit::MouseMove(Math::Point mouse) int CEdit::MouseDetect(Math::Point mouse) { Math::Point pos; - float indentLength, offset, size; + float indentLength = 0.0f, offset, size; int i, len, c; bool bTitle; @@ -886,7 +886,7 @@ bool CEdit::HyperGo(EventType event) void CEdit::Draw() { Math::Point pos, ppos, dim, start, end; - float size, indentLength; + float size = 0.0f, indentLength = 0.0f; int i, j, beg, len, c1, c2, o1, o2, eol, iIndex, line; if ( (m_state & STATE_VISIBLE) == 0 ) return; @@ -1877,7 +1877,7 @@ bool CEdit::WriteText(std::string filename) FILE* file; char buffer[1000+20]; int i, j, k, n; - float iDim; + float iDim = 0.0f; if ( filename[0] == 0 ) return false; file = fopen(filename.c_str(), "wb"); @@ -2397,7 +2397,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) void CEdit::MoveLine(int move, bool bWord, bool bSelect) { - float column, indentLength; + float column, indentLength = 0.0f; int i, line, c; if ( move == 0 ) return; @@ -2956,7 +2956,7 @@ bool CEdit::MinMaj(bool bMaj) void CEdit::Justif() { - float width, size, indentLength; + float width, size, indentLength = 0.0f; int i, j, line, indent; bool bDual, bString, bRem; -- cgit v1.2.3-1-g7c22 From 23e3e552f3a93b382e494d0a60ab22c266d1dcd1 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 19:44:55 +0200 Subject: Made colobot.ini & savegame dir location depended on build type For Debug, it's current dir For Release it's like it was before Made on @CoLoRaptor's request :) --- src/ui/maindialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 699cb7b..2a8bb42 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -174,7 +174,11 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; + #ifdef NDEBUG m_savegameDir = GetSystemUtils()->savegameDirectoryLocation(); + #else + m_savegameDir = "savegame"; + #endif m_publicDir = "program"; m_userDir = "user"; m_filesDir = "files"; -- cgit v1.2.3-1-g7c22 From 07374db2a34448f961c31f2ae617d73f46eac0f6 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 21:32:40 +0200 Subject: Increased maximum font size --- src/ui/displayinfo.cpp | 10 +++++----- src/ui/studio.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index fcc77db..f83ff5a 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -154,28 +154,28 @@ bool CDisplayInfo::EventProcess(const Event &event) { m_main->SetFontSize(9.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } if ( event.type == EVENT_HYPER_SIZE2 ) // size 2? { m_main->SetFontSize(10.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } if ( event.type == EVENT_HYPER_SIZE3 ) // size 3? { m_main->SetFontSize(12.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } if ( event.type == EVENT_HYPER_SIZE4 ) // size 4? { m_main->SetFontSize(15.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } @@ -183,7 +183,7 @@ bool CDisplayInfo::EventProcess(const Event &event) { slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider == 0 ) return false; - m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f); + m_main->SetFontSize(9.0f+slider->GetVisibleValue()*12.0f); ViewDisplayInfo(); } diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 1cedabb..52a0ddc 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -167,7 +167,7 @@ bool CStudio::EventProcess(const Event &event) { slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider == nullptr ) return false; - m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f); + m_main->SetFontSize(9.0f+slider->GetVisibleValue()*12.0f); ViewEditScript(); } -- cgit v1.2.3-1-g7c22 From c1db140ad36402271914be8d993413aa5f4676bc Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 10:44:07 +0200 Subject: Updated Main Mnu music For now only code - we need to wait for PiXeL to give us new music :) --- src/ui/maindialog.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 2a8bb42..050f87a 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -751,7 +751,7 @@ pb->SetState(STATE_SHADOW); m_phase == PHASE_PROTO ) { if (!m_sound->IsPlayingMusic()) { - m_sound->PlayMusic("Intro.ogg", false); + m_sound->PlayMusic("Intro1.ogg", false); } if ( m_phase == PHASE_TRAINER ) m_index = 0; @@ -1746,7 +1746,7 @@ pos.y -= 0.048f; if ( m_phase == PHASE_WELCOME1 ) { m_sound->StopMusic(); - m_sound->PlayMusic("Intro.ogg", false); + m_sound->PlayMusic("Intro1.ogg", false); pos.x = 0.0f; pos.y = 0.0f; @@ -2005,6 +2005,23 @@ bool CMainDialog::EventProcess(const Event &event) //? else welcomeLength = WELCOME_LENGTH; welcomeLength = WELCOME_LENGTH; + if ( m_phase != PHASE_SIMUL && + m_phase != PHASE_WIN && + m_phase != PHASE_LOST && + m_phase != PHASE_WRITE && + m_phase != PHASE_READs && + m_phase != PHASE_WRITEs && + m_phase != PHASE_SETUPds && + m_phase != PHASE_SETUPgs && + m_phase != PHASE_SETUPps && + m_phase != PHASE_SETUPcs && + m_phase != PHASE_SETUPss ) + { + if (!m_sound->IsPlayingMusic()) { + m_sound->PlayMusic("Intro2.ogg", true); + } + } + if ( m_phase == PHASE_WELCOME1 || m_phase == PHASE_WELCOME2 || m_phase == PHASE_WELCOME3 ) -- cgit v1.2.3-1-g7c22 From 56709f0e5630a2874ccd133d08604a99f6095157 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 10:58:38 +0200 Subject: Small changes to looping main menu music --- src/ui/maindialog.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 050f87a..0b0b848 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -742,6 +742,23 @@ pb->SetState(STATE_SHADOW); CameraPerso(); } + if ( m_phase != PHASE_SIMUL && + m_phase != PHASE_WIN && + m_phase != PHASE_LOST && + m_phase != PHASE_WRITE && + m_phase != PHASE_READs && + m_phase != PHASE_WRITEs && + m_phase != PHASE_SETUPds && + m_phase != PHASE_SETUPgs && + m_phase != PHASE_SETUPps && + m_phase != PHASE_SETUPcs && + m_phase != PHASE_SETUPss ) + { + if (!m_sound->IsPlayingMusic()) { + m_sound->PlayMusic("Intro1.ogg", false); + } + } + if ( m_phase == PHASE_TRAINER || m_phase == PHASE_DEFI || m_phase == PHASE_MISSION || @@ -750,10 +767,6 @@ pb->SetState(STATE_SHADOW); m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { - if (!m_sound->IsPlayingMusic()) { - m_sound->PlayMusic("Intro1.ogg", false); - } - if ( m_phase == PHASE_TRAINER ) m_index = 0; if ( m_phase == PHASE_DEFI ) m_index = 1; if ( m_phase == PHASE_MISSION ) m_index = 2; @@ -1745,9 +1758,6 @@ pos.y -= 0.048f; if ( m_phase == PHASE_WELCOME1 ) { - m_sound->StopMusic(); - m_sound->PlayMusic("Intro1.ogg", false); - pos.x = 0.0f; pos.y = 0.0f; ddim.x = 0.0f; -- cgit v1.2.3-1-g7c22 From 6333d2d38e9801f67925cae194b07abcf8f1260e Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 4 May 2013 11:56:03 +0200 Subject: Removed most of "No such node" messages --- src/ui/maindialog.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 0b0b848..1b87a04 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -5509,6 +5509,7 @@ void CMainDialog::SetupMemorize() GetProfile().SetLocalProfileInt("Setup", "HimselfDamage", m_bHimselfDamage); GetProfile().SetLocalProfileInt("Setup", "CameraScroll", m_bCameraScroll); GetProfile().SetLocalProfileInt("Setup", "CameraInvertX", m_bCameraInvertX); + GetProfile().SetLocalProfileInt("Setup", "CameraInvertY", m_bCameraInvertY); GetProfile().SetLocalProfileInt("Setup", "InterfaceEffect", m_bEffect); GetProfile().SetLocalProfileInt("Setup", "GroundShadow", m_engine->GetShadow()); GetProfile().SetLocalProfileInt("Setup", "GroundSpot", m_engine->GetGroundSpot()); @@ -5544,6 +5545,8 @@ void CMainDialog::SetupMemorize() if ( pl != 0 ) { GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect()); } + } else { + // TODO: Default value } std::stringstream key; -- cgit v1.2.3-1-g7c22 From 9549359b4649efd4bd0b6f085d8277f6d12d0ecb Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 4 May 2013 20:12:15 +0200 Subject: Fix for saving wrong Fullscreen value --- src/ui/maindialog.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 1b87a04..2dede28 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -183,6 +183,8 @@ CMainDialog::CMainDialog() m_userDir = "user"; m_filesDir = "files"; + m_setupFull = m_app->GetVideoConfig().fullScreen; + m_bDialog = false; } -- cgit v1.2.3-1-g7c22 From cec406ea31c3ccb22ab676ce3fd52d4cd0dfcb0d Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 11 May 2013 23:05:20 +0200 Subject: Non-power-of-2 padding for background images * added padding options * removed old hardcoded image sizes --- src/ui/maindialog.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 2dede28..985e00e 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -389,7 +389,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } @@ -509,7 +509,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } @@ -978,7 +978,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } @@ -1177,7 +1177,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } } @@ -1702,7 +1702,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } } @@ -1752,7 +1752,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); m_loadingCounter = 1; // enough time to display! @@ -1774,7 +1774,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(861.0f / 1024.0f, 646.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } if ( m_phase == PHASE_WELCOME2 ) @@ -1793,7 +1793,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f)); + true); m_engine->SetBackForce(true); } if ( m_phase == PHASE_WELCOME3 ) @@ -1812,7 +1812,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f)); + true); m_engine->SetBackForce(true); } @@ -1948,7 +1948,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } -- cgit v1.2.3-1-g7c22 From c25b6ab472e372f2b6c0ec2bc10a5a7a4632b503 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 12 May 2013 15:23:26 +0200 Subject: Fix for #192 --- src/ui/maindialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 985e00e..30538f3 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -181,7 +181,7 @@ CMainDialog::CMainDialog() #endif m_publicDir = "program"; m_userDir = "user"; - m_filesDir = "files"; + m_filesDir = m_savegameDir; m_setupFull = m_app->GetVideoConfig().fullScreen; -- cgit v1.2.3-1-g7c22 From b41957f2f95d8f62817705a1c82322d9463d28a2 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 11:34:53 +0200 Subject: Corrected some valgrind issues * fixed several uninitialized variable issues * fixed possible memory corruption in CEngine --- src/ui/maindialog.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 30538f3..14c1e82 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -5046,6 +5046,9 @@ void CMainDialog::UpdateSceneResume(int rank) { for ( i=0 ; i<500 ; i++ ) { + if (line[i] == 0) + break; + if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space if ( line[i] == '/' && line[i+1] == '/' ) { -- cgit v1.2.3-1-g7c22 From 538745a731d07facd7a1574c04a5d34d23ce3bfa Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 17:45:15 +0200 Subject: Fixed some compilation warnings * fixed warnings about hiding virtual functions and several others --- src/ui/list.cpp | 14 +++++++++++--- src/ui/list.h | 11 +++++++---- src/ui/maindialog.cpp | 36 ++++++++++++++++++------------------ src/ui/studio.cpp | 4 ++-- src/ui/window.cpp | 4 ++-- src/ui/window.h | 2 +- 6 files changed, 41 insertions(+), 30 deletions(-) (limited to 'src/ui') diff --git a/src/ui/list.cpp b/src/ui/list.cpp index fae7af9..7593582 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -88,6 +88,14 @@ bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMs return MoveAdjust(); } +// Should never be called +bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) +{ + assert(false); + return false; +} + + // Adjusted after a change of dimensions. bool CList::MoveAdjust() @@ -611,7 +619,7 @@ bool CList::GetBlink() // Specifies the text of a line. -void CList::SetName(int i, const char* name) +void CList::SetItemName(int i, const char* name) { if ( i < 0 || i >= LISTMAXTOTAL ) return; @@ -630,7 +638,7 @@ void CList::SetName(int i, const char* name) // Returns the text of a line. -char* CList::GetName(int i) +char* CList::GetItemName(int i) { if ( i < 0 || i >= m_totalLine ) return 0; @@ -808,4 +816,4 @@ void CList::MoveScroll() } -} +} // namespace Ui diff --git a/src/ui/list.h b/src/ui/list.h index 97bd48c..3d2e517 100644 --- a/src/ui/list.h +++ b/src/ui/list.h @@ -69,8 +69,8 @@ class CList : public CControl void SetBlink(bool bEnable); bool GetBlink(); - void SetName(int i, const char* name); - char* GetName(int i); + void SetItemName(int i, const char* name); + char* GetItemName(int i); void SetCheck(int i, bool bMode); bool GetCheck(int i); @@ -93,6 +93,10 @@ class CList : public CControl void MoveScroll(); void DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif); + private: + // Overridden to avoid warning about hiding the virtual function + virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) override; + protected: CButton* m_button[LISTMAXDISPLAY]; CScroll* m_scroll; @@ -117,5 +121,4 @@ class CList : public CControl }; -} - +} // namespace Ui diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 14c1e82..696c156 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -199,7 +199,7 @@ CMainDialog::~CMainDialog() void CMainDialog::ChangePhase(Phase phase) { - CWindow* pw; + CWindow* pw = nullptr; CEdit* pe; CEditValue* pv; CLabel* pl; @@ -2310,7 +2310,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( pw == 0 ) break; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) break; - StartDeleteGame(pl->GetName(pl->GetSelect())); + StartDeleteGame(pl->GetItemName(pl->GetSelect())); break; default: @@ -3688,7 +3688,7 @@ void CMainDialog::ReadNameList() for (size_t i=0 ; iSetName(i, fileNames.at(i).c_str()); + pl->SetItemName(i, fileNames.at(i).c_str()); } } @@ -3764,7 +3764,7 @@ void CMainDialog::UpdateNameList() for ( i=0 ; iGetName(i)) == 0 ) + if ( strcmp(name, pl->GetItemName(i)) == 0 ) { pl->SetSelect(i); pl->ShowSelect(false); @@ -3800,7 +3800,7 @@ void CMainDialog::UpdateNameEdit() } else { - name = pl->GetName(sel); + name = pl->GetItemName(sel); pe->SetText(name); pe->SetCursor(strlen(name), 0); } @@ -3824,7 +3824,7 @@ void CMainDialog::UpdateNameFace() sel = pl->GetSelect(); if ( sel == -1 ) return; - name = pl->GetName(sel); + name = pl->GetItemName(sel); ReadGamerPerso(name); } @@ -3855,7 +3855,7 @@ void CMainDialog::NameSelect() } else { - m_main->SetGamerName(pl->GetName(sel)); + m_main->SetGamerName(pl->GetItemName(sel)); m_main->ChangePhase(PHASE_INIT); } @@ -3982,7 +3982,7 @@ void CMainDialog::NameDelete() m_sound->Play(SOUND_TZOING); return; } - gamer = pl->GetName(sel); + gamer = pl->GetItemName(sel); // Deletes all the contents of the file. sprintf(dir, "%s/%s", m_savegameDir.c_str(), gamer); @@ -4417,7 +4417,7 @@ void CMainDialog::IOReadList() } fclose(file); - pl->SetName(m_saveList.size(), name); + pl->SetItemName(m_saveList.size(), name); m_saveList.push_back(dir_iter->path()); } } @@ -4426,7 +4426,7 @@ void CMainDialog::IOReadList() // zly indeks if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { GetResource(RES_TEXT, RT_IO_NEW, name); - pl->SetName(m_saveList.size(), name); + pl->SetItemName(m_saveList.size(), name); } pl->SetSelect(m_saveList.size()); @@ -4505,7 +4505,7 @@ void CMainDialog::IODeleteScene() } } catch (std::exception & e) { - GetLogger()->Error("Error removing save %s : %s\n", pl->GetName(sel), e.what()); + GetLogger()->Error("Error removing save %s : %s\n", pl->GetItemName(sel), e.what()); } IOReadList(); @@ -4754,7 +4754,7 @@ void CMainDialog::UpdateSceneChap(int &chap) fclose(file); } - pl->SetName(j, name); + pl->SetItemName(j, name); pl->SetEnable(j, true); } } @@ -4807,7 +4807,7 @@ void CMainDialog::UpdateSceneChap(int &chap) bPassed = GetGamerInfoPassed((j+1)*100); sprintf(line, "%d: %s", j+1, name); - pl->SetName(j, line); + pl->SetItemName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); @@ -4917,7 +4917,7 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) bPassed = GetGamerInfoPassed((chap+1)*100+(j+1)); sprintf(line, "%d: %s", j+1, name); - pl->SetName(j, line); + pl->SetItemName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); @@ -5099,7 +5099,7 @@ void CMainDialog::UpdateDisplayDevice() j = 0; while ( bufDevices[i] != 0 ) { - pl->SetName(j++, bufDevices+i); + pl->SetItemName(j++, bufDevices+i); while ( bufDevices[i++] != 0 ); } @@ -5129,7 +5129,7 @@ void CMainDialog::UpdateDisplayMode() for (Math::IntPoint mode : modes) { mode_text.str(""); mode_text << mode.x << "x" << mode.y; - pl->SetName(i++, mode_text.str().c_str()); + pl->SetItemName(i++, mode_text.str().c_str()); } pl->SetSelect(m_setupSelMode); @@ -5153,12 +5153,12 @@ void CMainDialog::ChangeDisplay() pl = static_cast(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; m_setupSelDevice = pl->GetSelect(); - //device = pl->GetName(m_setupSelDevice); + //device = pl->GetItemName(m_setupSelDevice); pl = static_cast(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; m_setupSelMode = pl->GetSelect(); - //mode = pl->GetName(m_setupSelMode); + //mode = pl->GetItemName(m_setupSelMode); pc = static_cast(pw->SearchControl(EVENT_INTERFACE_FULL)); if ( pc == 0 ) return; diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 52a0ddc..5027924 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1397,7 +1397,7 @@ void CStudio::UpdateChangeList() pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe == nullptr ) return; - strcpy(name, pl->GetName(pl->GetSelect())); + strcpy(name, pl->GetItemName(pl->GetSelect())); name[pe->GetMaxChar()] = 0; // truncates according lg max editable p = strchr(name, '\t'); // seeks first tab if ( p != 0 ) *p = 0; @@ -1526,7 +1526,7 @@ void CStudio::UpdateDialogList() std::ostringstream temp; TimeToAscii(fs::last_write_time(file->path()), time); temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; - pl->SetName(i++, temp.str().c_str()); + pl->SetItemName(i++, temp.str().c_str()); } } } diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 69ef857..1820642 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -576,12 +576,12 @@ bool CWindow::GetTooltip(Math::Point pos, std::string &name) // Specifies the name for the title bar. -void CWindow::SetName(std::string name) +void CWindow::SetName(std::string name, bool tooltip) { CButton* pc; bool bAdjust; - CControl::SetName(name); + CControl::SetName(name, tooltip); if ( m_buttonReduce != 0 ) { diff --git a/src/ui/window.h b/src/ui/window.h index e39b8a9..6cb6e5d 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -83,7 +83,7 @@ public: EventType GetEventTypeFull(); EventType GetEventTypeClose(); - void SetName(std::string name); + virtual void SetName(std::string name, bool tooltip = true) override; void SetTrashEvent(bool bTrash); bool GetTrashEvent(); -- cgit v1.2.3-1-g7c22 From 8765d58b02c9afd00186bae4a0045dff32f7d102 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 17:47:54 +0200 Subject: Fixed code formatting * moved braces to new lines * fixed some function/variable names * fixed whitespace issues --- src/ui/README.txt | 1 + src/ui/button.cpp | 1 + src/ui/button.h | 1 + src/ui/check.cpp | 1 + src/ui/color.cpp | 1 + src/ui/color.h | 1 + src/ui/compass.cpp | 1 + src/ui/compass.h | 1 + src/ui/control.cpp | 17 ++-- src/ui/control.h | 1 + src/ui/displayinfo.cpp | 1 + src/ui/displayinfo.h | 1 + src/ui/displaytext.cpp | 1 + src/ui/edit.cpp | 108 +++++++++++++++--------- src/ui/edit.h | 3 +- src/ui/editvalue.cpp | 1 + src/ui/editvalue.h | 1 + src/ui/gauge.cpp | 1 + src/ui/gauge.h | 23 +++-- src/ui/group.cpp | 1 + src/ui/group.h | 1 + src/ui/image.cpp | 1 + src/ui/image.h | 1 + src/ui/interface.cpp | 30 ++++--- src/ui/interface.h | 83 ++++++++++--------- src/ui/key.cpp | 1 + src/ui/label.cpp | 4 +- src/ui/label.h | 13 +-- src/ui/list.cpp | 164 ++++++++++++++++++++++++------------ src/ui/list.h | 1 + src/ui/maindialog.cpp | 221 ++++++++++++++++++++++++++++++------------------- src/ui/maindialog.h | 2 +- src/ui/mainmap.cpp | 17 ++-- src/ui/mainmap.h | 62 +++++++------- src/ui/mainshort.h | 47 ++++++----- src/ui/map.cpp | 45 ++++++---- src/ui/map.h | 143 ++++++++++++++++---------------- src/ui/scroll.cpp | 1 + src/ui/scroll.h | 65 ++++++++------- src/ui/shortcut.cpp | 1 + src/ui/shortcut.h | 21 ++--- src/ui/slider.cpp | 1 + src/ui/slider.h | 69 +++++++-------- src/ui/studio.cpp | 28 ++++--- src/ui/target.cpp | 1 + src/ui/target.h | 19 +++-- src/ui/window.cpp | 1 + src/ui/window.h | 1 + 48 files changed, 715 insertions(+), 496 deletions(-) (limited to 'src/ui') diff --git a/src/ui/README.txt b/src/ui/README.txt index a159ed5..05f72a1 100644 --- a/src/ui/README.txt +++ b/src/ui/README.txt @@ -2,3 +2,4 @@ * \dir src/ui * \brief 2D user interface controls */ + diff --git a/src/ui/button.cpp b/src/ui/button.cpp index a68b34d..348382d 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -245,3 +245,4 @@ bool CButton::GetRepeat() } } + diff --git a/src/ui/button.h b/src/ui/button.h index a9aa020..b71ef4a 100644 --- a/src/ui/button.h +++ b/src/ui/button.h @@ -51,3 +51,4 @@ protected: }; } + diff --git a/src/ui/check.cpp b/src/ui/check.cpp index 761264d..362c930 100644 --- a/src/ui/check.cpp +++ b/src/ui/check.cpp @@ -163,3 +163,4 @@ void CCheck::Draw() } } + diff --git a/src/ui/color.cpp b/src/ui/color.cpp index fd05bd9..623ff89 100644 --- a/src/ui/color.cpp +++ b/src/ui/color.cpp @@ -223,3 +223,4 @@ Gfx::Color CColor::GetColor() } + diff --git a/src/ui/color.h b/src/ui/color.h index ec2c537..fe96b87 100644 --- a/src/ui/color.h +++ b/src/ui/color.h @@ -54,3 +54,4 @@ protected: }; } + diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp index ac97cb8..d0fe96f 100644 --- a/src/ui/compass.cpp +++ b/src/ui/compass.cpp @@ -171,3 +171,4 @@ float CCompass::GetDirection() } + diff --git a/src/ui/compass.h b/src/ui/compass.h index 18546e5..956631a 100644 --- a/src/ui/compass.h +++ b/src/ui/compass.h @@ -49,3 +49,4 @@ protected: } + diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 6dc92cd..7c77c95 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -75,10 +75,13 @@ bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType even GetResource(RES_EVENT, m_eventType, text); str_text = std::string(text); auto p = str_text.find("\\"); - if ( p == std::string::npos ) { + if ( p == std::string::npos ) + { if ( icon != -1 ) m_tooltip = str_text; - } else { + } + else + { m_tooltip = str_text.substr(p + 1); } @@ -174,15 +177,18 @@ int CControl::GetIcon() void CControl::SetName(std::string name, bool bTooltip) { - if ( bTooltip ) { + if ( bTooltip ) + { auto p = name.find("\\"); if ( p == std::string::npos ) m_name = name; - else { + else + { m_tooltip = name.substr(p + 1); m_name = name.substr(0, p); } - } else + } + else m_name = name; } @@ -832,3 +838,4 @@ bool CControl::Detect(Math::Point pos) } } + diff --git a/src/ui/control.h b/src/ui/control.h index 7f5077d..aee7d1c 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -141,3 +141,4 @@ protected: }; } // namespace Ui + diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index f83ff5a..3aa3d73 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -1214,3 +1214,4 @@ void CDisplayInfo::CreateObjectsFile() } + diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h index ab42d62..eea50b7 100644 --- a/src/ui/displayinfo.h +++ b/src/ui/displayinfo.h @@ -95,3 +95,4 @@ protected: } // namespace Ui + diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp index 630b385..d88674a 100644 --- a/src/ui/displaytext.cpp +++ b/src/ui/displaytext.cpp @@ -606,3 +606,4 @@ CObject* CDisplayText::SearchToto() } } + diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index c9831dd..6fd1735 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -263,7 +263,7 @@ bool CEdit::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_MOVE ) { - if ( Detect(event.mousePos) && + if ( Detect(event.mousePos) && event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) { if ( m_bEdit ) @@ -782,13 +782,16 @@ void CEdit::HyperJump(std::string name, std::string marker) sMarker = marker; //? sprintf(filename, "help\\%s.txt", name); - - if ( name[0] == '%' ) { + + if ( name[0] == '%' ) + { filename = GetProfile().GetUserBasedPath(name, "") + ".txt"; - } else { + } + else + { filename = std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + "/" + name + std::string(".txt"); } - + if ( ReadText(filename) ) { Justif(); @@ -1249,7 +1252,7 @@ void CEdit::SetText(const char *text, bool bNew) { int i, j, font; bool bBOL; - + if ( !bNew ) UndoMemorize(OPERUNDO_SPEC); m_len = strlen(text); @@ -1387,10 +1390,11 @@ int CEdit::GetTextLength() std::string GetNameParam(std::string cmd, int rank) { - std::vector results; + std::vector results; boost::split(results, cmd, boost::is_any_of(" ;")); - - if (results.size() > static_cast(rank)) { + + if (results.size() > static_cast(rank)) + { return results.at(rank); } @@ -1402,11 +1406,12 @@ std::string GetNameParam(std::string cmd, int rank) int GetValueParam(std::string cmd, int rank) { - std::vector results; + std::vector results; boost::split(results, cmd, boost::is_any_of(" ;")); int return_value = 0; - - if (results.size() > static_cast(rank)) { + + if (results.size() > static_cast(rank)) + { return_value = atoi(results.at(rank).c_str()); } @@ -1419,7 +1424,8 @@ void CEdit::FreeImage() { std::string filename; - for (int i = 0 ; i < m_imageTotal; i++ ) { + for (int i = 0 ; i < m_imageTotal; i++ ) + { filename = GetProfile().GetUserBasedPath(m_image[i].name, "diagram") + ".png"; m_engine->DeleteTexture(filename); } @@ -1448,12 +1454,14 @@ bool CEdit::ReadText(std::string filename, int addSize) bool bInSoluce, bBOL; if ( filename[0] == 0 ) return false; + boost::replace_all(filename, "\\", "/"); - + /* This is ugly but doesn't require many changes in code. If file doesn't exists it's posible filename is absolute not full path */ std::string path = filename; - if (!fs::exists(path)) { + if (!fs::exists(path)) + { path = CApplication::GetInstancePointer()->GetDataDirPath() + "/" + filename; } @@ -1484,10 +1492,11 @@ bool CEdit::ReadText(std::string filename, int addSize) m_format.clear(); m_format.reserve(m_maxChar+1); - for (i = 0; i <= m_maxChar+1; i++) { + for (i = 0; i <= m_maxChar+1; i++) + { m_format.push_back(0); } - + fclose(file); bInSoluce = false; @@ -1951,7 +1960,8 @@ void CEdit::SetMaxChar(int max) m_format.clear(); m_format.reserve(m_maxChar+1); - for (int i = 0; i <= m_maxChar+1; i++) { + for (int i = 0; i <= m_maxChar+1; i++) + { m_format.push_back(0); } @@ -2142,10 +2152,12 @@ bool CEdit::GetDisplaySpec() void CEdit::SetMultiFont(bool bMulti) { m_format.clear(); - - if (bMulti) { + + if (bMulti) + { m_format.reserve(m_maxChar+1); - for (int i = 0; i <= m_maxChar+1; i++) { + for (int i = 0; i <= m_maxChar+1; i++) + { m_format.push_back(0); } } @@ -2522,26 +2534,33 @@ bool CEdit::Copy(bool memorize_cursor) c1 = m_cursor1; c2 = m_cursor2; - if ( c1 > c2 ) { + if ( c1 > c2 ) + { Math::Swap(c1, c2); // always c1 <= c2 } - if ( c1 == c2 ) { - while ( c1 > 0 ) { - if ( m_text[c1 - 1] == '\n' ) { + if ( c1 == c2 ) + { + while ( c1 > 0 ) + { + if ( m_text[c1 - 1] == '\n' ) + { break; } c1--; } - while ( c2 < m_len ) { + while ( c2 < m_len ) + { c2++; - if ( m_text[c2 - 1] == '\n' ) { + if ( m_text[c2 - 1] == '\n' ) + { break; } } } - if ( c1 == c2 ) { + if ( c1 == c2 ) + { return false; } @@ -2553,8 +2572,9 @@ bool CEdit::Copy(bool memorize_cursor) text[len] = 0; widgetSetClipboardText(text); delete []text; - - if (memorize_cursor) { + + if (memorize_cursor) + { m_cursor1 = c1; m_cursor2 = c2; } @@ -2569,28 +2589,33 @@ bool CEdit::Paste() char c; char* text; - if ( !m_bEdit ) { + if ( !m_bEdit ) + { return false; } text = widgetGetClipboardText(); - - if ( text == nullptr ) { + + if ( text == nullptr ) + { return false; } UndoMemorize(OPERUNDO_SPEC); - for ( unsigned int i = 0; i < strlen(text); i++ ) { + for ( unsigned int i = 0; i < strlen(text); i++ ) + { c = text[i]; - if ( c == '\r' ) { + if ( c == '\r' ) + { continue; } - if ( c == '\t' && m_bAutoIndent ) { + if ( c == '\t' && m_bAutoIndent ) + { continue; } InsertOne(c); } - + free(text); Justif(); ColumnFix(); @@ -2603,7 +2628,8 @@ bool CEdit::Paste() bool CEdit::Undo() { - if ( !m_bEdit ) { + if ( !m_bEdit ) + { return false; } @@ -2617,7 +2643,8 @@ void CEdit::Insert(char character) { int i, level, tab; - if ( !m_bEdit ) { + if ( !m_bEdit ) + { return; } @@ -3219,7 +3246,7 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format) void CEdit::UpdateScroll() { float value; - + if ( m_scroll != nullptr ) { if ( m_lineTotal <= m_lineVisible ) @@ -3243,3 +3270,4 @@ void CEdit::UpdateScroll() } } + diff --git a/src/ui/edit.h b/src/ui/edit.h index df4f143..acdf72c 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -239,7 +239,7 @@ protected: void UndoFlush(); void UndoMemorize(OperUndo oper); bool UndoRecall(); - + void UpdateScroll(); protected: @@ -294,3 +294,4 @@ protected: } + diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 6397a73..3fb9b79 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -369,3 +369,4 @@ float CEditValue::GetMaxValue() } } + diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h index 5d6e643..2734847 100644 --- a/src/ui/editvalue.h +++ b/src/ui/editvalue.h @@ -85,3 +85,4 @@ protected: } + diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index c98e3b6..a8ee41c 100644 --- a/src/ui/gauge.cpp +++ b/src/ui/gauge.cpp @@ -144,3 +144,4 @@ float CGauge::GetLevel() } + diff --git a/src/ui/gauge.h b/src/ui/gauge.h index a2b689a..3dbeef8 100644 --- a/src/ui/gauge.h +++ b/src/ui/gauge.h @@ -31,24 +31,23 @@ namespace Ui { class CGauge : public CControl { - public: - CGauge(); - virtual ~CGauge(); +public: + CGauge(); + virtual ~CGauge(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - bool EventProcess(const Event &event); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); - void SetLevel(float level); - float GetLevel(); + void SetLevel(float level); + float GetLevel(); - protected: - - protected: - float m_level; +protected: + float m_level; }; } + diff --git a/src/ui/group.cpp b/src/ui/group.cpp index c3c7028..908ac19 100644 --- a/src/ui/group.cpp +++ b/src/ui/group.cpp @@ -639,3 +639,4 @@ void CGroup::Draw() } + diff --git a/src/ui/group.h b/src/ui/group.h index fd31716..89996cc 100644 --- a/src/ui/group.h +++ b/src/ui/group.h @@ -46,3 +46,4 @@ protected: } + diff --git a/src/ui/image.cpp b/src/ui/image.cpp index 94b9586..9a14789 100644 --- a/src/ui/image.cpp +++ b/src/ui/image.cpp @@ -151,3 +151,4 @@ void CImage::Draw() } + diff --git a/src/ui/image.h b/src/ui/image.h index c40828c..fd71e33 100644 --- a/src/ui/image.h +++ b/src/ui/image.h @@ -52,3 +52,4 @@ protected: } + diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 893cd05..845579e 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -47,8 +47,10 @@ CInterface::~CInterface() void CInterface::Flush() { - for (int i = 0; i < MAXCONTROL; i++ ) { - if ( m_table[i] != nullptr ) { + for (int i = 0; i < MAXCONTROL; i++ ) + { + if ( m_table[i] != nullptr ) + { delete m_table[i]; m_table[i] = nullptr; } @@ -58,7 +60,8 @@ void CInterface::Flush() int CInterface::GetNextFreeControl() { - for (int i = 10; i < MAXCONTROL-1; i++) { + for (int i = 10; i < MAXCONTROL-1; i++) + { if (m_table[i] == nullptr) return i; } @@ -92,7 +95,8 @@ CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, E if (eventMsg == EVENT_NULL) eventMsg = GetUniqueEventType(); - switch (eventMsg) { + switch (eventMsg) + { case EVENT_WINDOW0: index = 0; break; case EVENT_WINDOW1: index = 1; break; case EVENT_WINDOW2: index = 2; break; @@ -249,9 +253,12 @@ CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventTyp bool CInterface::DeleteControl(EventType eventMsg) { - for (int i = 0; i < MAXCONTROL; i++) { - if ( m_table[i] != nullptr ) { - if (eventMsg == m_table[i]->GetEventType()) { + for (int i = 0; i < MAXCONTROL; i++) + { + if ( m_table[i] != nullptr ) + { + if (eventMsg == m_table[i]->GetEventType()) + { delete m_table[i]; m_table[i] = nullptr; return true; @@ -265,8 +272,10 @@ bool CInterface::DeleteControl(EventType eventMsg) CControl* CInterface::SearchControl(EventType eventMsg) { - for (int i = 0; i < MAXCONTROL; i++) { - if (m_table[i] != nullptr) { + for (int i = 0; i < MAXCONTROL; i++) + { + if (m_table[i] != nullptr) + { if (eventMsg == m_table[i]->GetEventType()) return m_table[i]; } @@ -326,4 +335,5 @@ void CInterface::Draw() } } -} +} // namespace Ui + diff --git a/src/ui/interface.h b/src/ui/interface.h index ebc80e7..d5734f0 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -55,48 +55,49 @@ const int MAXCONTROL = 100; class CInterface { - public: - CInterface(); - ~CInterface(); - - bool EventProcess(const Event &event); - bool GetTooltip(Math::Point pos, std::string &name); - - void Flush(); - CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - - CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f); - CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name); - - bool DeleteControl(EventType eventMsg); - CControl* SearchControl(EventType eventMsg); - - void Draw(); - - protected: - int GetNextFreeControl(); - template inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - - CEventQueue* m_event; - Gfx::CEngine* m_engine; - Gfx::CCamera* m_camera; - - CControl* m_table[MAXCONTROL]; +public: + CInterface(); + ~CInterface(); + + bool EventProcess(const Event &event); + bool GetTooltip(Math::Point pos, std::string &name); + + void Flush(); + CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + + CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f); + CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name); + + bool DeleteControl(EventType eventMsg); + CControl* SearchControl(EventType eventMsg); + + void Draw(); + +protected: + int GetNextFreeControl(); + template inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + + CEventQueue* m_event; + Gfx::CEngine* m_engine; + Gfx::CCamera* m_camera; + + CControl* m_table[MAXCONTROL]; }; } + diff --git a/src/ui/key.cpp b/src/ui/key.cpp index b181f70..1f8cff5 100644 --- a/src/ui/key.cpp +++ b/src/ui/key.cpp @@ -214,3 +214,4 @@ InputBinding CKey::GetBinding() } // namespace Ui + diff --git a/src/ui/label.cpp b/src/ui/label.cpp index b5195b5..76a95f2 100644 --- a/src/ui/label.cpp +++ b/src/ui/label.cpp @@ -66,7 +66,8 @@ void CLabel::Draw() pos.y = m_pos.y + m_dim.y / 2.0f; - switch (m_textAlign) { + switch (m_textAlign) + { case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x; break; case Gfx::TEXT_ALIGN_CENTER: pos.x = m_pos.x + m_dim.x / 2.0f; break; case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x + m_dim.x; break; @@ -76,3 +77,4 @@ void CLabel::Draw() } } + diff --git a/src/ui/label.h b/src/ui/label.h index c9e1050..305aca2 100644 --- a/src/ui/label.h +++ b/src/ui/label.h @@ -29,15 +29,16 @@ namespace Ui { class CLabel : public CControl { - public: - CLabel(); - virtual ~CLabel(); +public: + CLabel(); + virtual ~CLabel(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - bool EventProcess(const Event &event); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); }; } + diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 7593582..f6c3ed9 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -33,13 +33,15 @@ CList::CList() : CControl() m_button[i] = nullptr; m_scroll = nullptr; - for (int i = 0; i < LISTMAXTOTAL; i++) { + for (int i = 0; i < LISTMAXTOTAL; i++) + { m_text[i][0] = 0; m_check[i] = false; m_enable[i] = true; } - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) + { m_tabs[i] = 0.0f; m_justifs[i] = Gfx::TEXT_ALIGN_LEFT; } @@ -57,7 +59,8 @@ CList::CList() : CControl() CList::~CList() { - for (int i = 0; i < LISTMAXDISPLAY; i++) { + for (int i = 0; i < LISTMAXDISPLAY; i++) + { if (m_button[i] != nullptr) delete m_button[i]; } @@ -103,8 +106,10 @@ bool CList::MoveAdjust() Math::Point ipos, idim, ppos, ddim; float marging, h; - for (int i = 0; i < LISTMAXDISPLAY; i++) { - if (m_button[i] != nullptr) { + for (int i = 0; i < LISTMAXDISPLAY; i++) + { + if (m_button[i] != nullptr) + { delete m_button[i]; m_button[i] = nullptr; } @@ -142,7 +147,8 @@ bool CList::MoveAdjust() ppos.y = ipos.y + idim.y - h; ddim.x = idim.x - SCROLL_WIDTH; ddim.y = h; - for (int i = 0; i < m_displayLine; i++) { + for (int i = 0; i < m_displayLine; i++) + { m_button[i] = new CButton(); m_button[i]->Create(ppos, ddim, -1, EVENT_NULL); m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); @@ -154,7 +160,8 @@ bool CList::MoveAdjust() m_eventButton[i] = m_button[i]->GetEventType(); } - if ( m_scroll != nullptr ) { + if ( m_scroll != nullptr ) + { ppos.x = ipos.x + idim.x - SCROLL_WIDTH; ppos.y = ipos.y; ddim.x = SCROLL_WIDTH; @@ -206,8 +213,10 @@ void CList::SetDim(Math::Point dim) bool CList::SetState(int state, bool bState) { - if (state & STATE_ENABLE) { - for (int i = 0; i < m_displayLine; i++) { + if (state & STATE_ENABLE) + { + for (int i = 0; i < m_displayLine; i++) + { if (m_button[i] != nullptr) m_button[i]->SetState(state, bState); } @@ -221,8 +230,10 @@ bool CList::SetState(int state, bool bState) bool CList::SetState(int state) { - if (state & STATE_ENABLE) { - for (int i = 0; i < m_displayLine; i++) { + if (state & STATE_ENABLE) + { + for (int i = 0; i < m_displayLine; i++) + { if (m_button[i] != nullptr) m_button[i]->SetState(state); } @@ -236,8 +247,10 @@ bool CList::SetState(int state) bool CList::ClearState(int state) { - if (state & STATE_ENABLE) { - for (int i = 0; i < m_displayLine; i++) { + if (state & STATE_ENABLE) + { + for (int i = 0; i < m_displayLine; i++) + { if (m_button[i] != nullptr) m_button[i]->ClearState(state); } @@ -254,15 +267,20 @@ bool CList::ClearState(int state) bool CList::EventProcess(const Event &event) { int i; - if (m_bBlink && event.type == EVENT_FRAME) { + if (m_bBlink && event.type == EVENT_FRAME) + { i = m_selectLine-m_firstLine; - if (i >= 0 && i < 4 && m_button[i] != nullptr) { + if (i >= 0 && i < 4 && m_button[i] != nullptr) + { m_blinkTime += event.rTime; - if (Math::Mod(m_blinkTime, 0.7f) < 0.3f) { + if (Math::Mod(m_blinkTime, 0.7f) < 0.3f) + { m_button[i]->ClearState(STATE_ENABLE); m_button[i]->ClearState(STATE_CHECK); - } else { + } + else + { m_button[i]->SetState(STATE_ENABLE); m_button[i]->SetState(STATE_CHECK); } @@ -274,7 +292,8 @@ bool CList::EventProcess(const Event &event) if ((m_state & STATE_ENABLE) == 0) return true; - if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mousePos)) { + if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mousePos)) + { if (m_firstLine > 0) m_firstLine--; UpdateScroll(); @@ -282,7 +301,8 @@ bool CList::EventProcess(const Event &event) return true; } - if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mousePos)) { + if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mousePos)) + { if (m_firstLine < m_totalLine - m_displayLine) m_firstLine++; UpdateScroll(); @@ -292,9 +312,11 @@ bool CList::EventProcess(const Event &event) CControl::EventProcess(event); - if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos)) { + if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos)) + { m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); - for (i = 0; i < m_displayLine; i++) { + for (i = 0; i < m_displayLine; i++) + { if (i + m_firstLine >= m_totalLine) break; if (m_button[i] != nullptr) @@ -302,16 +324,20 @@ bool CList::EventProcess(const Event &event) } } - if (m_bSelectCap) { - for (i = 0; i < m_displayLine; i++) { + if (m_bSelectCap) + { + for (i = 0; i < m_displayLine; i++) + { if (i + m_firstLine >= m_totalLine) break; - if (m_button[i] != nullptr) { + if (m_button[i] != nullptr) + { if (!m_button[i]->EventProcess(event)) return false; - if (event.type == m_eventButton[i]) { + if (event.type == m_eventButton[i]) + { SetSelect(m_firstLine + i); Event newEvent = event; @@ -322,11 +348,13 @@ bool CList::EventProcess(const Event &event) } } - if (m_scroll != nullptr) { + if (m_scroll != nullptr) + { if (!m_scroll->EventProcess(event)) return false; - if (event.type == m_eventScroll) { + if (event.type == m_eventScroll) + { MoveScroll(); UpdateButton(); } @@ -354,10 +382,12 @@ void CList::Draw() dp = 0.5f / 256.0f; - if (m_icon != -1) { + if (m_icon != -1) + { dim = m_dim; - if (m_icon == 0) { + if (m_icon == 0) + { m_engine->SetTexture("button2.png"); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); @@ -365,7 +395,9 @@ void CList::Draw() uv1.y = 64.0f / 256.0f; // u-v texture uv2.x = 160.0f / 256.0f; uv2.y = 96.0f / 256.0f; - } else { + } + else + { m_engine->SetTexture("button2.png"); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); @@ -374,7 +406,8 @@ void CList::Draw() uv2.x = 156.0f / 256.0f; uv2.y = 92.0f / 256.0f; - if (m_button[0] != nullptr) { + if (m_button[0] != nullptr) + { dim = m_button[0]->GetDim(); dim.y *= m_displayLine; // background sounds spot behind } @@ -390,9 +423,11 @@ void CList::Draw() DrawIcon(m_pos, dim, uv1, uv2, corner, 8.0f / 256.0f); } - if ( m_totalLine < m_displayLine ) { // no buttons to the bottom? + if ( m_totalLine < m_displayLine ) // no buttons to the bottom? + { i = m_totalLine; - if ( m_button[i] != 0 ) { + if ( m_button[i] != 0 ) + { pos = m_button[i]->GetPos(); dim = m_button[i]->GetDim(); pos.y += dim.y * 1.1f; @@ -413,11 +448,13 @@ void CList::Draw() } } - for (i = 0; i < m_displayLine; i++) { + for (i = 0; i < m_displayLine; i++) + { if ( i + m_firstLine >= m_totalLine ) break; - if ( m_button[i] != nullptr ) { + if ( m_button[i] != nullptr ) + { if ( !m_bBlink && i + m_firstLine < m_totalLine ) m_button[i]->SetState(STATE_ENABLE, m_enable[i+m_firstLine] && (m_state & STATE_ENABLE) ); @@ -426,22 +463,27 @@ void CList::Draw() // draws text in the box pos = m_button[i]->GetPos(); dim = m_button[i]->GetDim(); - if ( m_tabs[0] == 0.0f ) { + if ( m_tabs[0] == 0.0f ) + { ppos.x = pos.x + dim.y * 0.5f; ppos.y = pos.y + dim.y * 0.5f; ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; ddim.x = dim.x-dim.y; DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_LEFT); - } else { + } + else + { ppos.x = pos.x + dim.y * 0.5f; ppos.y = pos.y + dim.y * 0.5f; ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; pb = m_text[i + m_firstLine]; - for (int j = 0; j < 10; j++) { + for (int j = 0; j < 10; j++) + { pe = strchr(pb, '\t'); if ( pe == 0 ) strcpy(text, pb); - else { + else + { strncpy(text, pb, pe - pb); text[pe - pb] = 0; } @@ -454,7 +496,8 @@ void CList::Draw() } } - if ( (m_state & STATE_EXTEND) && i < m_totalLine) { + if ( (m_state & STATE_EXTEND) && i < m_totalLine) + { pos = m_button[i]->GetPos(); dim = m_button[i]->GetDim(); pos.x += dim.x - dim.y * 0.75f; @@ -464,7 +507,8 @@ void CList::Draw() dim.x -= 4.0f / 640.0f; dim.y -= 4.0f / 480.0f; - if ( m_check[i + m_firstLine] ) { + if ( m_check[i + m_firstLine] ) + { m_engine->SetTexture("button1.png"); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 64.0f / 256.0f; @@ -487,15 +531,20 @@ void CList::Draw() uv2.x -= dp; uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); // draws v - } else { + } + else + { m_engine->SetTexture("button1.png"); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw - if ( i + m_firstLine == m_selectLine ) { + if ( i + m_firstLine == m_selectLine ) + { uv1.x =224.0f / 256.0f; // < uv1.y =192.0f / 256.0f; uv2.x =256.0f / 256.0f; uv2.y =224.0f / 256.0f; - } else { + } + else + { uv1.x = 96.0f / 256.0f; // x uv1.y = 32.0f / 256.0f; uv2.x =128.0f / 256.0f; @@ -560,7 +609,8 @@ void CList::SetSelect(int i) { if ( m_bSelectCap ) m_selectLine = i; - else { + else + { m_firstLine = i; UpdateScroll(); } @@ -603,8 +653,10 @@ void CList::SetBlink(bool bEnable) i = m_selectLine-m_firstLine; - if (i >= 0 && i < 4 && m_button[i] != nullptr) { - if ( !bEnable ) { + if (i >= 0 && i < 4 && m_button[i] != nullptr) + { + if ( !bEnable ) + { m_button[i]->SetState(STATE_CHECK); m_button[i]->ClearState(STATE_ENABLE); } @@ -744,17 +796,21 @@ void CList::UpdateButton() state = CControl::GetState(); j = m_firstLine; - for (i = 0; i < m_displayLine; i++) { + for (i = 0; i < m_displayLine; i++) + { if (m_button[i] == nullptr) continue; m_button[i]->SetState(STATE_CHECK, (j == m_selectLine)); - if ( j < m_totalLine ) { + if ( j < m_totalLine ) + { //? m_button[i]->SetName(m_text[j]); m_button[i]->SetName(" "); // blank button m_button[i]->SetState(STATE_ENABLE, (state & STATE_ENABLE)); - } else { + } + else + { m_button[i]->SetName(" "); // blank button m_button[i]->ClearState(STATE_ENABLE); } @@ -771,11 +827,14 @@ void CList::UpdateScroll() if (m_scroll == nullptr) return; - if (m_totalLine <= m_displayLine) { + if (m_totalLine <= m_displayLine) + { ratio = 1.0f; value = 0.0f; step = 0.0f; - } else { + } + else + { ratio = static_cast(m_displayLine) / m_totalLine; if ( ratio > 1.0f ) ratio = 1.0f; @@ -817,3 +876,4 @@ void CList::MoveScroll() } // namespace Ui + diff --git a/src/ui/list.h b/src/ui/list.h index 3d2e517..a2e033f 100644 --- a/src/ui/list.h +++ b/src/ui/list.h @@ -122,3 +122,4 @@ class CList : public CControl } // namespace Ui + diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 696c156..dfc2d52 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -174,8 +174,10 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; + + // TODO: replace NDEBUG with something like BUILD_TYPE == "DEBUG"/"RELEASE" #ifdef NDEBUG - m_savegameDir = GetSystemUtils()->savegameDirectoryLocation(); + m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); #else m_savegameDir = "savegame"; #endif @@ -756,7 +758,8 @@ pb->SetState(STATE_SHADOW); m_phase != PHASE_SETUPcs && m_phase != PHASE_SETUPss ) { - if (!m_sound->IsPlayingMusic()) { + if (!m_sound->IsPlayingMusic()) + { m_sound->PlayMusic("Intro1.ogg", false); } } @@ -1623,7 +1626,7 @@ pos.y -= 0.048f; } if ( m_phase == PHASE_READ || - m_phase == PHASE_READs ) + m_phase == PHASE_READs ) { pos.x = 0.10f; pos.y = 0.10f; @@ -2029,14 +2032,15 @@ bool CMainDialog::EventProcess(const Event &event) m_phase != PHASE_SETUPcs && m_phase != PHASE_SETUPss ) { - if (!m_sound->IsPlayingMusic()) { + if (!m_sound->IsPlayingMusic()) + { m_sound->PlayMusic("Intro2.ogg", true); } } if ( m_phase == PHASE_WELCOME1 || - m_phase == PHASE_WELCOME2 || - m_phase == PHASE_WELCOME3 ) + m_phase == PHASE_WELCOME2 || + m_phase == PHASE_WELCOME3 ) { float intensity; int mode = Gfx::ENG_RSTATE_TCOLOR_WHITE; @@ -2627,15 +2631,18 @@ bool CMainDialog::EventProcess(const Event &event) pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; pc = static_cast(pw->SearchControl(EVENT_INTERFACE_FULL)); - if ( pc == 0 ) break; - - if ( pc->TestState(STATE_CHECK) ) { - m_setupFull = false; - pc->ClearState(STATE_CHECK); - } else { - m_setupFull = true; - pc->SetState(STATE_CHECK); - } + if ( pc == 0 ) break; + + if ( pc->TestState(STATE_CHECK) ) + { + m_setupFull = false; + pc->ClearState(STATE_CHECK); + } + else + { + m_setupFull = true; + pc->SetState(STATE_CHECK); + } UpdateApply(); break; @@ -2647,7 +2654,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( pb == 0 ) break; pb->ClearState(STATE_PRESS); pb->ClearState(STATE_HILIGHT); - // TODO: uncomment when changing display is implemented + // TODO: uncomment when changing display is implemented //ChangeDisplay(); UpdateApply(); break; @@ -4297,16 +4304,19 @@ void CMainDialog::DefPerso() bool CMainDialog::IsIOReadScene() { fs::directory_iterator end_iter; - + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); - if (fs::exists(saveDir) && fs::is_directory(saveDir)) { - for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { - if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { + if (fs::exists(saveDir) && fs::is_directory(saveDir)) + { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) + { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) + { return true; } } } - + return false; } @@ -4390,27 +4400,34 @@ void CMainDialog::IOReadList() if ( pl == 0 ) return; pl->Flush(); - + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); m_saveList.clear(); - - if (fs::exists(saveDir) && fs::is_directory(saveDir)) { - for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { - if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { - + + if (fs::exists(saveDir) && fs::is_directory(saveDir)) + { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) + { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) + { + file = fopen((dir_iter->path() / "data.sav").make_preferred().string().c_str(), "r"); if ( file == NULL ) continue; - while ( fgets(line, 500, file) != NULL ) { - for ( i=0 ; i<500 ; i++ ) { + while ( fgets(line, 500, file) != NULL ) + { + for ( i=0 ; i<500 ; i++ ) + { if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) { + if ( line[i] == '/' && line[i+1] == '/' ) + { line[i] = 0; break; } } - if ( Cmd(line, "Title") ) { + if ( Cmd(line, "Title") ) + { OpString(line, "text", name); break; } @@ -4422,9 +4439,10 @@ void CMainDialog::IOReadList() } } } - - // zly indeks - if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { + + // invalid index + if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) + { GetResource(RES_TEXT, RT_IO_NEW, name); pl->SetItemName(m_saveList.size(), name); } @@ -4453,22 +4471,24 @@ void CMainDialog::IOUpdateList() sel = pl->GetSelect(); max = pl->GetTotal(); - if (m_saveList.size() <= static_cast(sel)) { + if (m_saveList.size() <= static_cast(sel)) return; - } - + std::string filename = (m_saveList.at(sel) / "screen.png").make_preferred().string(); if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { - if ( sel < max-1 ) { + if ( sel < max-1 ) + { pi->SetFilenameImage(filename.c_str()); } - else { + else + { pi->SetFilenameImage(""); } pb = static_cast(pw->SearchControl(EVENT_INTERFACE_IODELETE)); - if ( pb != nullptr ) { + if ( pb != nullptr ) + { pb->SetState(STATE_ENABLE, sel < max-1); } } @@ -4500,11 +4520,13 @@ void CMainDialog::IODeleteScene() try { - if (fs::exists(m_saveList.at(sel)) && fs::is_directory(m_saveList.at(sel))) { + if (fs::exists(m_saveList.at(sel)) && fs::is_directory(m_saveList.at(sel))) + { fs::remove_all(m_saveList.at(sel)); } } - catch (std::exception & e) { + catch (std::exception & e) + { GetLogger()->Error("Error removing save %s : %s\n", pl->GetItemName(sel), e.what()); } @@ -4516,8 +4538,10 @@ std::string clearName(char *name) { std::string ret; int len = strlen(name); - for (int i = 0; i < len; i++) { - if (isalnum(name[i])) { + for (int i = 0; i < len; i++) + { + if (isalnum(name[i])) + { ret += name[i]; } } @@ -4542,19 +4566,24 @@ bool CMainDialog::IOWriteScene() if ( pe == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 ) { + if ( sel == -1 ) + { return false; } - + fs::path dir; pe->GetText(info, 100); - if (static_cast(sel) >= m_saveList.size()) { + if (static_cast(sel) >= m_saveList.size()) + { dir = fs::path(m_savegameDir) / m_main->GetGamerName() / ("save" + clearName(info)); - } else { + } + else + { dir = m_saveList.at(sel); - } - - if (!fs::exists(dir)) { + } + + if (!fs::exists(dir)) + { fs::create_directories(dir); } @@ -4585,7 +4614,8 @@ bool CMainDialog::IOReadScene() if ( pl == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 || m_saveList.size() <= static_cast(sel) ) { + if ( sel == -1 || m_saveList.size() <= static_cast(sel) ) + { return false; } @@ -4593,33 +4623,42 @@ bool CMainDialog::IOReadScene() std::string fileCbot = (m_saveList.at(sel) / "cbot.run").make_preferred().string(); file = fopen(fileName.c_str(), "r"); - if ( file == NULL ) { + if ( file == NULL ) + { return false; } - while ( fgets(line, 500, file) != NULL ) { - for ( i=0 ; i<500 ; i++ ) { + while ( fgets(line, 500, file) != NULL ) + { + for ( i=0 ; i<500 ; i++ ) + { if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) { + if ( line[i] == '/' && line[i+1] == '/' ) + { line[i] = 0; break; } } - if ( Cmd(line, "Mission") ) { + if ( Cmd(line, "Mission") ) + { OpString(line, "base", m_sceneName); m_sceneRank = OpInt(line, "rank", 0); - if ( strcmp(m_sceneName, "user") == 0 ) { + if ( strcmp(m_sceneName, "user") == 0 ) + { m_sceneRank = m_sceneRank%100; OpString(line, "dir", dir); - for ( i=0 ; iGetVideoResolutionList(modes, true, true); int i = 0; std::stringstream mode_text; - for (Math::IntPoint mode : modes) { - mode_text.str(""); - mode_text << mode.x << "x" << mode.y; - pl->SetItemName(i++, mode_text.str().c_str()); + for (Math::IntPoint mode : modes) + { + mode_text.str(""); + mode_text << mode.x << "x" << mode.y; + pl->SetItemName(i++, mode_text.str().c_str()); } pl->SetSelect(m_setupSelMode); @@ -5535,25 +5575,29 @@ void CMainDialog::SetupMemorize() GetProfile().SetLocalProfileInt("Setup", "Sound3D", m_sound->GetSound3D()); GetProfile().SetLocalProfileInt("Setup", "EditIndentMode", m_engine->GetEditIndentMode()); GetProfile().SetLocalProfileInt("Setup", "EditIndentValue", m_engine->GetEditIndentValue()); - + /* screen setup */ if (m_setupFull) - GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1); + GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1); else - GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 0); - + GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 0); + CList *pl; CWindow *pw; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw != 0 ) { - pl = static_cast(pw->SearchControl(EVENT_LIST2)); - if ( pl != 0 ) { - GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect()); - } - } else { + if ( pw != 0 ) + { + pl = static_cast(pw->SearchControl(EVENT_LIST2)); + if ( pl != 0 ) + { + GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect()); + } + } + else + { // TODO: Default value } - + std::stringstream key; for (int i = 0; i < INPUT_SLOT_MAX; i++) { @@ -5765,7 +5809,7 @@ void CMainDialog::SetupRecall() { m_sound->SetMusicVolume(iValue); } - + if ( GetProfile().GetLocalProfileInt("Setup", "Sound3D", iValue) ) { m_sound->SetSound3D(iValue == 1); @@ -5813,13 +5857,15 @@ void CMainDialog::SetupRecall() { m_bDeleteGamer = iValue; } - - if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) { - m_setupSelMode = iValue; + + if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) + { + m_setupSelMode = iValue; } - - if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) { - m_setupFull = (iValue == 1); + + if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) + { + m_setupFull = (iValue == 1); } } @@ -6584,7 +6630,7 @@ void CMainDialog::WriteGamerPerso(char *gamer) if ( file == NULL ) return; m_main->SetNumericLocale(); - + sprintf(line, "Head face=%d glasses=%d hair=%.2f;%.2f;%.2f;%.2f\n", m_perso.face, m_perso.glasses, m_perso.colorHair.r, m_perso.colorHair.g, m_perso.colorHair.b, m_perso.colorHair.a); @@ -6596,7 +6642,7 @@ void CMainDialog::WriteGamerPerso(char *gamer) fputs(line, file); fclose(file); - + m_main->RestoreNumericLocale(); } @@ -6615,7 +6661,7 @@ void CMainDialog::ReadGamerPerso(char *gamer) sprintf(filename, "%s/%s/face.gam", m_savegameDir.c_str(), gamer); file = fopen(filename, "r"); if ( file == NULL ) return; - + m_main->SetNumericLocale(); while ( fgets(line, 100, file) != NULL ) @@ -6649,7 +6695,7 @@ void CMainDialog::ReadGamerPerso(char *gamer) } fclose(file); - + m_main->RestoreNumericLocale(); } @@ -6836,3 +6882,4 @@ bool CMainDialog::NextMission() } // namespace Ui + diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index afdf94f..96aff2a 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -262,7 +262,7 @@ protected: Math::Point m_partiPos[10]; SceneInfo m_sceneInfo[MAXSCENE]; - + std::vector m_saveList; }; diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp index 1143a77..8c81160 100644 --- a/src/ui/mainmap.cpp +++ b/src/ui/mainmap.cpp @@ -55,7 +55,8 @@ void CMainMap::CreateMap() Math::Point pos, dim; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW1)); - if (pw == nullptr) { + if (pw == nullptr) + { pos.x = 0.0f; pos.y = 0.0f; dim.x = 0.0f; @@ -106,7 +107,8 @@ void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water) return; pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); - if (pm != nullptr) { + if (pm != nullptr) + { pm->SetFloorColor(floor); pm->SetWaterColor(water); } @@ -124,9 +126,12 @@ void CMainMap::ShowMap(bool bShow) if (pw == nullptr) return; - if (bShow) { + if (bShow) + { DimMap(); - } else { + } + else + { pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->ClearState(STATE_VISIBLE); @@ -164,7 +169,8 @@ void CMainMap::DimMap() pm->SetDim(dim); ps = static_cast(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); - if (ps != nullptr) { + if (ps != nullptr) + { ps->SetState(STATE_VISIBLE, (m_mapMode != 0)); dim.x = SCROLL_WIDTH; @@ -392,3 +398,4 @@ void CMainMap::SetHighlight(CObject* pObj) } + diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h index 9d0d72f..9b20548 100644 --- a/src/ui/mainmap.h +++ b/src/ui/mainmap.h @@ -34,37 +34,37 @@ namespace Ui { class CMainMap { - public: - CMainMap(); - ~CMainMap(); - - void UpdateMap(); - void CreateMap(); - void SetFixImage(const char *filename); - void FloorColorMap(Gfx::Color floor, Gfx::Color water); - void ShowMap(bool bShow); - void DimMap(); - float GetZoomMap(); - void ZoomMap(float zoom); - void ZoomMap(); - void MapEnable(bool bEnable); - bool GetShowMap(); - bool GetFixImage(); - CObject* DetectMap(Math::Point pos, bool &bInMap); - void SetHighlight(CObject* pObj); - void SetToy(bool bToy); - void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug); - - protected: - void CenterMap(); - - protected: - CEventQueue* m_event; - Gfx::CEngine* m_engine; - CInterface* m_interface; - - int m_mapMode; - bool m_bFixImage; +public: + CMainMap(); + ~CMainMap(); + + void UpdateMap(); + void CreateMap(); + void SetFixImage(const char *filename); + void FloorColorMap(Gfx::Color floor, Gfx::Color water); + void ShowMap(bool bShow); + void DimMap(); + float GetZoomMap(); + void ZoomMap(float zoom); + void ZoomMap(); + void MapEnable(bool bEnable); + bool GetShowMap(); + bool GetFixImage(); + CObject* DetectMap(Math::Point pos, bool &bInMap); + void SetHighlight(CObject* pObj); + void SetToy(bool bToy); + void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug); + +protected: + void CenterMap(); + +protected: + CEventQueue* m_event; + Gfx::CEngine* m_engine; + CInterface* m_interface; + + int m_mapMode; + bool m_bFixImage; }; } diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h index d679eb0..b185aed 100644 --- a/src/ui/mainshort.h +++ b/src/ui/mainshort.h @@ -34,29 +34,30 @@ namespace Ui { class CMainShort { - public: - CMainShort(); - ~CMainShort(); - - void SetMode(bool bBuilding); - void FlushShortcuts(); - bool CreateShortcuts(); - bool UpdateShortcuts(); - void SelectShortcut(EventType event); - void SelectNext(); - CObject* DetectShort(Math::Point pos); - void SetHighlight(CObject* pObj); - - protected: - - protected: - CEventQueue* m_event; - Gfx::CEngine* m_engine; - CInterface* m_interface; - CRobotMain* m_main; - - CObject* m_shortcuts[20]; - bool m_bBuilding; +public: + CMainShort(); + ~CMainShort(); + + void SetMode(bool bBuilding); + void FlushShortcuts(); + bool CreateShortcuts(); + bool UpdateShortcuts(); + void SelectShortcut(EventType event); + void SelectNext(); + CObject* DetectShort(Math::Point pos); + void SetHighlight(CObject* pObj); + +protected: + +protected: + CEventQueue* m_event; + Gfx::CEngine* m_engine; + CInterface* m_interface; + CRobotMain* m_main; + + CObject* m_shortcuts[20]; + bool m_bBuilding; }; } + diff --git a/src/ui/map.cpp b/src/ui/map.cpp index 33d0fb1..c5f0062 100644 --- a/src/ui/map.cpp +++ b/src/ui/map.cpp @@ -187,14 +187,17 @@ bool CMap::EventProcess(const Event &event) if ( event.type == EVENT_FRAME ) m_time += event.rTime; - if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) ) { + if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) ) + { m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); if ( DetectObject(event.mousePos, bInMap) != 0 ) m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); } - if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT ) { - if ( CControl::Detect(event.mousePos) ) { + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT ) + { + if ( CControl::Detect(event.mousePos) ) + { SelectObject(event.mousePos); return false; } @@ -228,11 +231,13 @@ void CMap::SetHighlight(CObject* pObj) if ( pObj == nullptr ) return; - for (int i = 0; i < MAPMAXOBJECT; i++) { + for (int i = 0; i < MAPMAXOBJECT; i++) + { if ( !m_map[i].bUsed ) continue; - if ( m_map[i].object == pObj ) { + if ( m_map[i].object == pObj ) + { m_highlightRank = i; break; } @@ -262,7 +267,8 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap) min = 10000.0f; best = -1; - for (int i = MAPMAXOBJECT - 1; i >= 0; i--) { + for (int i = MAPMAXOBJECT - 1; i >= 0; i--) + { if ( !m_map[i].bUsed ) continue; if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar ) @@ -273,7 +279,8 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap) dist = Math::Point(m_map[i].pos.x - pos.x, m_map[i].pos.y - pos.y).Length(); if ( dist > m_half / m_zoom * 8.0f / 100.0f ) continue; // too far? - if ( dist < min ) { + if ( dist < min ) + { min = dist; best = i; } @@ -337,13 +344,15 @@ void CMap::Draw() if ( m_map[i].bUsed ) // selection: DrawFocus(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color); - for ( i=0 ; im_totalMove ; i-- ) { // moving objects: + for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) // moving objects: + { if ( i == m_highlightRank ) continue; DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false); @@ -353,7 +362,8 @@ void CMap::Draw() if ( m_map[i].bUsed && i != m_highlightRank ) // selection: DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, true, false); - if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) { + if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) + { i = m_highlightRank; DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, true); DrawHighlight(m_map[i].pos); @@ -375,23 +385,27 @@ Math::Point CMap::MapInter(Math::Point pos, float dir) p1.y -= pos.y; limit = m_mapPos.x + m_mapDim.x - pos.x; - if ( p1.x > limit ) { // exceeds the right? + if ( p1.x > limit ) // exceeds the right? + { p1.y = limit*p1.y/p1.x; p1.x = limit; } limit = m_mapPos.y * 0.75f + m_mapDim.y * 0.75f - pos.y; - if ( p1.y > limit ) { // exceeds the top? + if ( p1.y > limit ) // exceeds the top? + { p1.x = limit * p1.x / p1.y; p1.y = limit; } limit = m_mapPos.x - pos.x; - if ( p1.x < limit ) { // exceeds the left? + if ( p1.x < limit ) // exceeds the left? + { p1.y = limit * p1.y / p1.x; p1.x = limit; } limit = m_mapPos.y * 0.75f - pos.y; - if ( p1.y < limit ) { // exceeds the bottom? + if ( p1.y < limit ) // exceeds the bottom? + { p1.x = limit * p1.x / p1.y; p1.y = limit; } @@ -1152,7 +1166,7 @@ void CMap::UpdateObject(CObject* pObj) pos.z = ppos.y; dir += m_angle; } - + color = MAPCOLOR_NULL; if ( type == OBJECT_BASE ) { @@ -1303,3 +1317,4 @@ void CMap::UpdateObject(CObject* pObj) } } + diff --git a/src/ui/map.h b/src/ui/map.h index 258dcdf..4ebe688 100644 --- a/src/ui/map.h +++ b/src/ui/map.h @@ -69,78 +69,79 @@ struct MapObject class CMap : public CControl { - public: - CMap(); - ~CMap(); - - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - bool EventProcess(const Event &event); - void Draw(); - - void UpdateTerrain(); - void UpdateTerrain(int bx, int by, int ex, int ey); - - void SetFixImage(const char *filename); - bool GetFixImage(); - - void SetOffset(float ox, float oy); - void SetAngle(float angle); - void SetMode(int mode); - void SetToy(bool bToy); - void SetDebug(bool bDebug); - - void SetZoom(float value); - float GetZoom(); - - void SetEnable(bool bEnable); - bool GetEnable(); - - void SetFloorColor(Gfx::Color color); - void SetWaterColor(Gfx::Color color); - - void FlushObject(); - void UpdateObject(CObject* pObj); - - CObject* DetectObject(Math::Point pos, bool &bInMap); - void SetHighlight(CObject* pObj); - - protected: - Math::Point AdjustOffset(Math::Point offset); - void SelectObject(Math::Point pos); - Math::Point MapInter(Math::Point pos, float dir); - void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color); - void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite); - void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite); - void DrawHighlight(Math::Point pos); - void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2); - void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2); - void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom); - - protected: - Gfx::CTerrain* m_terrain; - Gfx::CWater* m_water; - CRobotMain* m_main; - - bool m_bEnable; - float m_time; - float m_half; - float m_zoom; - Math::Point m_offset; - float m_angle; - Gfx::Color m_floorColor; - Gfx::Color m_waterColor; - MapObject m_map[MAPMAXOBJECT]; - int m_totalFix; - int m_totalMove; - int m_highlightRank; - Math::Point m_mapPos; - Math::Point m_mapDim; - bool m_bRadar; - char m_fixImage[100]; - int m_mode; - bool m_bToy; - bool m_bDebug; +public: + CMap(); + ~CMap(); + + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool EventProcess(const Event &event); + void Draw(); + + void UpdateTerrain(); + void UpdateTerrain(int bx, int by, int ex, int ey); + + void SetFixImage(const char *filename); + bool GetFixImage(); + + void SetOffset(float ox, float oy); + void SetAngle(float angle); + void SetMode(int mode); + void SetToy(bool bToy); + void SetDebug(bool bDebug); + + void SetZoom(float value); + float GetZoom(); + + void SetEnable(bool bEnable); + bool GetEnable(); + + void SetFloorColor(Gfx::Color color); + void SetWaterColor(Gfx::Color color); + + void FlushObject(); + void UpdateObject(CObject* pObj); + + CObject* DetectObject(Math::Point pos, bool &bInMap); + void SetHighlight(CObject* pObj); + +protected: + Math::Point AdjustOffset(Math::Point offset); + void SelectObject(Math::Point pos); + Math::Point MapInter(Math::Point pos, float dir); + void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color); + void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite); + void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite); + void DrawHighlight(Math::Point pos); + void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2); + void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2); + void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom); + +protected: + Gfx::CTerrain* m_terrain; + Gfx::CWater* m_water; + CRobotMain* m_main; + + bool m_bEnable; + float m_time; + float m_half; + float m_zoom; + Math::Point m_offset; + float m_angle; + Gfx::Color m_floorColor; + Gfx::Color m_waterColor; + MapObject m_map[MAPMAXOBJECT]; + int m_totalFix; + int m_totalMove; + int m_highlightRank; + Math::Point m_mapPos; + Math::Point m_mapDim; + bool m_bRadar; + char m_fixImage[100]; + int m_mode; + bool m_bToy; + bool m_bDebug; }; } + diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index ff7451d..b3422ec 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -467,3 +467,4 @@ float CScroll::GetArrowStep() } } + diff --git a/src/ui/scroll.h b/src/ui/scroll.h index 57d6f8f..c115aa4 100644 --- a/src/ui/scroll.h +++ b/src/ui/scroll.h @@ -34,51 +34,52 @@ const float SCROLL_WIDTH = (15.0f/640.0f); class CScroll : public CControl { - public: - CScroll(); - ~CScroll(); +public: + CScroll(); + ~CScroll(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - void SetPos(Math::Point pos); - void SetDim(Math::Point dim); + void SetPos(Math::Point pos); + void SetDim(Math::Point dim); - bool SetState(int state, bool bState); - bool SetState(int state); - bool ClearState(int state); + bool SetState(int state, bool bState); + bool SetState(int state); + bool ClearState(int state); - bool EventProcess(const Event &event); - void Draw(); + bool EventProcess(const Event &event); + void Draw(); - void SetVisibleValue(float value); - float GetVisibleValue(); + void SetVisibleValue(float value); + float GetVisibleValue(); - void SetVisibleRatio(float value); - float GetVisibleRatio(); + void SetVisibleRatio(float value); + float GetVisibleRatio(); - void SetArrowStep(float step); - float GetArrowStep(); + void SetArrowStep(float step); + float GetArrowStep(); - protected: - void MoveAdjust(); - void AdjustGlint(); - void DrawVertex(Math::Point pos, Math::Point dim, int icon); +protected: + void MoveAdjust(); + void AdjustGlint(); + void DrawVertex(Math::Point pos, Math::Point dim, int icon); - protected: - CButton* m_buttonUp; - CButton* m_buttonDown; +protected: + CButton* m_buttonUp; + CButton* m_buttonDown; - float m_visibleValue; - float m_visibleRatio; - float m_step; + float m_visibleValue; + float m_visibleRatio; + float m_step; - bool m_bCapture; - Math::Point m_pressPos; - float m_pressValue; + bool m_bCapture; + Math::Point m_pressPos; + float m_pressValue; - EventType m_eventUp; - EventType m_eventDown; + EventType m_eventUp; + EventType m_eventDown; }; } + diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index 4462140..7231d5d 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -237,3 +237,4 @@ void CShortcut::DrawVertex(int icon, float zoom) } } + diff --git a/src/ui/shortcut.h b/src/ui/shortcut.h index 7e7899e..6495ba0 100644 --- a/src/ui/shortcut.h +++ b/src/ui/shortcut.h @@ -27,22 +27,23 @@ namespace Ui { class CShortcut : public CControl { - public: - CShortcut(); - ~CShortcut(); +public: + CShortcut(); + ~CShortcut(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - bool EventProcess(const Event &event); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); - protected: - void DrawVertex(int icon, float zoom); +protected: + void DrawVertex(int icon, float zoom); - protected: - float m_time; +protected: + float m_time; }; } + diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index f516e70..33293d1 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -581,3 +581,4 @@ float CSlider::GetArrowStep() } + diff --git a/src/ui/slider.h b/src/ui/slider.h index 4912453..bc38aec 100644 --- a/src/ui/slider.h +++ b/src/ui/slider.h @@ -29,54 +29,55 @@ class CButton; class CSlider : public CControl { - public: - CSlider(); - ~CSlider(); +public: + CSlider(); + ~CSlider(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - void SetPos(Math::Point pos); - void SetDim(Math::Point dim); + void SetPos(Math::Point pos); + void SetDim(Math::Point dim); - bool SetState(int state, bool bState); - bool SetState(int state); - bool ClearState(int state); + bool SetState(int state, bool bState); + bool SetState(int state); + bool ClearState(int state); - bool EventProcess(const Event &event); - void Draw(); + bool EventProcess(const Event &event); + void Draw(); - void SetLimit(float min, float max); + void SetLimit(float min, float max); - void SetVisibleValue(float value); - float GetVisibleValue(); + void SetVisibleValue(float value); + float GetVisibleValue(); - void SetArrowStep(float step); - float GetArrowStep(); + void SetArrowStep(float step); + float GetArrowStep(); - protected: - void MoveAdjust(); - void AdjustGlint(); - void DrawVertex(Math::Point pos, Math::Point dim, int icon); +protected: + void MoveAdjust(); + void AdjustGlint(); + void DrawVertex(Math::Point pos, Math::Point dim, int icon); - protected: - CButton* m_buttonLeft; - CButton* m_buttonRight; +protected: + CButton* m_buttonLeft; + CButton* m_buttonRight; - float m_min; - float m_max; - float m_visibleValue; - float m_step; + float m_min; + float m_max; + float m_visibleValue; + float m_step; - bool m_bHoriz; - float m_marginButton; + bool m_bHoriz; + float m_marginButton; - bool m_bCapture; - Math::Point m_pressPos; - float m_pressValue; + bool m_bCapture; + Math::Point m_pressPos; + float m_pressValue; - EventType m_eventUp; - EventType m_eventDown; + EventType m_eventUp; + EventType m_eventDown; }; } + diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 5027924..24a64c4 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1511,7 +1511,7 @@ void CStudio::UpdateDialogList() fs::path path; int i = 0; char time[100]; - + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); @@ -1520,12 +1520,15 @@ void CStudio::UpdateDialogList() path = fs::path(SearchDirectory(false)); fs::directory_iterator end_iter; - if ( fs::exists(path) && fs::is_directory(path) ) { - for( fs::directory_iterator file(path); file != end_iter; file++) { - if (fs::is_regular_file(file->status()) ) { + if ( fs::exists(path) && fs::is_directory(path) ) + { + for( fs::directory_iterator file(path); file != end_iter; file++) + { + if (fs::is_regular_file(file->status()) ) + { std::ostringstream temp; TimeToAscii(fs::last_write_time(file->path()), time); - temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; + temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; pl->SetItemName(i++, temp.str().c_str()); } } @@ -1538,15 +1541,19 @@ void CStudio::UpdateDialogList() std::string CStudio::SearchDirectory(bool bCreate) { char dir[MAX_FNAME]; - if ( m_main->GetIOPublic() ) { + if ( m_main->GetIOPublic() ) + { sprintf(dir, "%s/", m_main->GetPublicDir()); - } else { + } + else + { sprintf(dir, "%s/%s/Program/", m_main->GetSavegameDir(), m_main->GetGamerName()); } - + fs::path path = fs::path(dir); - - if ( bCreate ) { + + if ( bCreate ) + { fs::create_directory(path); } @@ -1629,3 +1636,4 @@ bool CStudio::WriteProgram() } } + diff --git a/src/ui/target.cpp b/src/ui/target.cpp index cc74750..455c530 100644 --- a/src/ui/target.cpp +++ b/src/ui/target.cpp @@ -272,3 +272,4 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) } } + diff --git a/src/ui/target.h b/src/ui/target.h index 054524b..2344e59 100644 --- a/src/ui/target.h +++ b/src/ui/target.h @@ -36,19 +36,20 @@ namespace Ui { class CTarget : public CControl { - public: - CTarget(); - ~CTarget(); +public: + CTarget(); + ~CTarget(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - bool EventProcess(const Event &event); - void Draw(); - bool GetTooltip(Math::Point pos, std::string &name); + bool EventProcess(const Event &event); + void Draw(); + bool GetTooltip(Math::Point pos, std::string &name); - protected: - CObject* DetectFriendObject(Math::Point pos); +protected: + CObject* DetectFriendObject(Math::Point pos); }; } + diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 1820642..8005939 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -1579,3 +1579,4 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim) } } + diff --git a/src/ui/window.h b/src/ui/window.h index 6cb6e5d..87805e2 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -151,3 +151,4 @@ protected: } + -- cgit v1.2.3-1-g7c22 From 12313fecf5a0ccad45f88575a24582b8363bd5a7 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 27 May 2013 20:59:50 +0200 Subject: Fixed some memory issues * invalid pointer, uninitialized buffer --- src/ui/studio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 24a64c4..e44a465 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -904,7 +904,7 @@ void CStudio::SetInfoText(std::string text, bool bClickable) if ( list == 0 ) return; list->Flush(); // just text - list->SetName(0, text.c_str()); + list->SetItemName(0, text.c_str()); if ( text[0] == 0 ) bClickable = false; list->SetSelectCap(bClickable); -- cgit v1.2.3-1-g7c22 From b22d852b4c4aa89e0394397a703ecfa442b0a928 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 27 May 2013 22:26:44 +0200 Subject: Fixed variable shadowing warnings * fixed -Wshadow warnings * refactored some constructors --- src/ui/maindialog.cpp | 6 ++++-- src/ui/shortcut.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index dfc2d52..8f5b936 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -3677,8 +3677,9 @@ void CMainDialog::ReadNameList() { fs::directory_iterator dirIt(m_savegameDir), dirEndIt; - BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt)) + for (; dirIt != dirEndIt; ++dirIt) { + const fs::path& p = *dirIt; if (fs::is_directory(p)) { fileNames.push_back(p.leaf().string()); @@ -4745,8 +4746,9 @@ void CMainDialog::UpdateSceneChap(int &chap) fs::directory_iterator dirIt(m_savegameDir), dirEndIt; m_userList.clear(); - BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt)) + for (; dirIt != dirEndIt; ++dirIt) { + const fs::path& p = *dirIt; if (fs::is_directory(p)) { m_userList.push_back(p.leaf().string()); diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index 7231d5d..a01864a 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -128,7 +128,7 @@ void CShortcut::Draw() if ( m_state & STATE_FRAME ) { Math::Point p1, p2, c, uv1, uv2; - float zoom, dp; + float dp; m_engine->SetTexture("button2.png"); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); -- cgit v1.2.3-1-g7c22 From 7874aca10ce6da823f88e8aabe4a0ea6431cc480 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Jun 2013 21:39:21 +0200 Subject: Enhanced logging, option to auto-start mission * added logging of application events * changed debug mode flag to independent debug modes * added option to auto-start mission (load a mission immediately after startup) * removed "enum value out of range" prints * some refactoring --- src/ui/maindialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 8f5b936..3a31883 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -366,7 +366,8 @@ pb->SetState(STATE_SHADOW); } // #endif - if ( m_app->GetDebugMode() ) + // TODO: remove? + if (m_app->GetProtoMode()) { pos.x = 139.0f/640.0f; pos.y = 313.0f/480.0f; -- cgit v1.2.3-1-g7c22 From bfcce26f8949f4ba42cc1bd8203dff51884aa0da Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 22 Jun 2013 01:11:37 +0200 Subject: Changes in build organization * targets are now created in top-level build directory * more things are now configured through CMake options * changed debug build detection from NDEBUG to DEV_BUILD * moved po and desktop directories * moved last unit test out of src directory --- src/ui/maindialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 3a31883..defff84 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -175,12 +175,12 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; - // TODO: replace NDEBUG with something like BUILD_TYPE == "DEBUG"/"RELEASE" - #ifdef NDEBUG - m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); - #else + #if DEV_BUILD m_savegameDir = "savegame"; + #else + m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); #endif + m_publicDir = "program"; m_userDir = "user"; m_filesDir = m_savegameDir; -- cgit v1.2.3-1-g7c22