From 56a170391f944f7a042b81fe7e6817a0c28fb005 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Dec 2012 13:22:58 +0100 Subject: Split gtest and gmock, fixed using system packages - split the bundled gtest and gmock libraries - allowed the use of system gmock - refactoring in CMakeLists --- src/ui/test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt index 9e11e14..7562a04 100644 --- a/src/ui/test/CMakeLists.txt +++ b/src/ui/test/CMakeLists.txt @@ -7,7 +7,8 @@ include_directories( . ../.. ../../.. -${GTEST_DIR}/include +${GTEST_INCLUDE_DIR} +${GMOCK_INCLUDE_DIR} ) -- cgit v1.2.3-1-g7c22 From 3c976c040b48caa9f3e75d12a6502e39193ce9a6 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Wed, 19 Dec 2012 16:52:11 +0100 Subject: Don't enforce CMake build type on users. Only set CMAKE_BUILD_TYPE to Debug when no value is provided. --- src/ui/test/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt index 7562a04..ca976b7 100644 --- a/src/ui/test/CMakeLists.txt +++ b/src/ui/test/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 2.8) -set(CMAKE_BUILD_TYPE debug) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE debug) +endif(NOT CMAKE_BUILD_TYPE) set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x") include_directories( -- cgit v1.2.3-1-g7c22 From 7e9ef0c042fd14373a129ca8a5ac94e9679daee9 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Wed, 19 Dec 2012 16:54:58 +0100 Subject: Put common CXX flags in common variables CMAKE_CXX_FLAGS is taken into account in all builds; build-type-specific flags are appended to it. --- src/ui/test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt index ca976b7..e411067 100644 --- a/src/ui/test/CMakeLists.txt +++ b/src/ui/test/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 2.8) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE debug) endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x") +set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") include_directories( . -- cgit v1.2.3-1-g7c22 From c793d2d4c67a5556e39300988f42a630fc51e68d Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 25 Dec 2012 21:36:50 +0100 Subject: * Changed Ret to Get methods in sound module * Added video settings to profile * Resolution change is now posibble but restart is required --- src/ui/maindialog.cpp | 132 +++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 76 deletions(-) (limited to 'src/ui') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 5136a41..ebf7d10 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -1164,43 +1164,22 @@ pb->SetState(STATE_SHADOW); if ( m_phase == PHASE_SETUPd || // setup/display ? m_phase == PHASE_SETUPds ) { - -// TODO: device settings -#if 0 - pos.x = ox+sx*3; pos.y = oy+sy*9; ddim.x = dim.x*6; ddim.y = dim.y*1; - GetResource(RES_TEXT, RT_SETUP_DEVICE, name); - pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); - pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); - - pos.x = ox+sx*3; - pos.y = oy+sy*5.2f; - ddim.x = dim.x*6; - ddim.y = dim.y*4.5f; - pli = pw->CreateList(pos, ddim, 0, EVENT_LIST1); - pli->SetState(STATE_SHADOW); - UpdateDisplayDevice(); - - pos.x = ox+sx*10; - pos.y = oy+sy*9; - ddim.x = dim.x*6; - ddim.y = dim.y*1; GetResource(RES_TEXT, RT_SETUP_MODE, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name); pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); m_setupFull = m_app->GetVideoConfig().fullScreen; - pos.x = ox+sx*10; + pos.x = ox+sx*3; pos.y = oy+sy*5.2f; ddim.x = dim.x*6; ddim.y = dim.y*4.5f; pli = pw->CreateList(pos, ddim, 0, EVENT_LIST2); pli->SetState(STATE_SHADOW); UpdateDisplayMode(); - pli->SetState(STATE_ENABLE, m_setupFull); ddim.x = dim.x*4; ddim.y = dim.y*0.5f; @@ -1209,7 +1188,6 @@ pb->SetState(STATE_SHADOW); pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_FULL); pc->SetState(STATE_SHADOW); pc->SetState(STATE_CHECK, m_setupFull); -#endif ddim.x = dim.x*6; ddim.y = dim.y*1; @@ -2610,19 +2588,16 @@ 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; - pl = static_cast(pw->SearchControl(EVENT_LIST2)); - if ( pl == 0 ) break; - if ( pc->TestState(STATE_CHECK) ) - { - pc->ClearState(STATE_CHECK); // window - pl->ClearState(STATE_ENABLE); - } - else - { - pc->SetState(STATE_CHECK); // fullscreen - pl->SetState(STATE_ENABLE); - } + 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; @@ -2633,7 +2608,8 @@ bool CMainDialog::EventProcess(const Event &event) if ( pb == 0 ) break; pb->ClearState(STATE_PRESS); pb->ClearState(STATE_HILIGHT); - ChangeDisplay(); + // TODO: uncomment when changing display is implemented + //ChangeDisplay(); UpdateApply(); break; @@ -2909,12 +2885,12 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_SILENT: m_sound->SetAudioVolume(0); - //TODO: m_sound->SetMidiVolume(0); + m_sound->SetMusicVolume(0); UpdateSetupButtons(); break; case EVENT_INTERFACE_NOISY: m_sound->SetAudioVolume(MAXVOLUME); - //TODO: m_sound->SetMidiVolume(MAXVOLUME*3/4); + m_sound->SetMusicVolume(MAXVOLUME*3/4); UpdateSetupButtons(); break; @@ -5076,9 +5052,6 @@ void CMainDialog::UpdateDisplayMode() { CWindow* pw; CList* pl; - char bufDevices[1000]; - char bufModes[5000]; - int i, j, totalDevices, selectDevices, totalModes, selectModes; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; @@ -5086,25 +5059,18 @@ void CMainDialog::UpdateDisplayMode() if ( pl == 0 ) return; pl->Flush(); - bufModes[0] = 0; - /* TODO: remove device choice - m_engine->EnumDevices(bufDevices, 1000, - bufModes, 5000, - totalDevices, selectDevices, - totalModes, selectModes);*/ - - i = 0; - j = 0; - while ( bufModes[i] != 0 ) - { - pl->SetName(j++, bufModes+i); - while ( bufModes[i++] != 0 ); + std::vector modes; + m_app->GetVideoResolutionList(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->SetName(i++, mode_text.str().c_str()); } - pl->SetSelect(selectModes); + pl->SetSelect(m_setupSelMode); pl->ShowSelect(false); - - m_setupSelMode = selectModes; } // Change the graphics mode. @@ -5392,9 +5358,8 @@ void CMainDialog::UpdateSetupButtons() ps = static_cast(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC)); if ( ps != 0 ) { - /* TODO: midi volume - value = (float)m_sound->GetMidiVolume(); - ps->SetVisibleValue(value);*/ + value = static_cast(m_sound->GetMusicVolume()); + ps->SetVisibleValue(value); } pc = static_cast(pw->SearchControl(EVENT_INTERFACE_SOUND3D)); @@ -5474,10 +5439,6 @@ void CMainDialog::ChangeSetupButtons() void CMainDialog::SetupMemorize() { - float fValue; - int iValue, i, j; - char num[10]; - GetProfile().SetLocalProfileString("Directory", "scene", m_sceneDir); GetProfile().SetLocalProfileString("Directory", "savegame", m_savegameDir); GetProfile().SetLocalProfileString("Directory", "public", m_publicDir); @@ -5508,15 +5469,27 @@ void CMainDialog::SetupMemorize() GetProfile().SetLocalProfileInt("Setup", "TextureQuality", m_engine->GetTextureQuality()); GetProfile().SetLocalProfileInt("Setup", "TotoMode", m_engine->GetTotoMode()); GetProfile().SetLocalProfileInt("Setup", "AudioVolume", m_sound->GetAudioVolume()); + GetProfile().SetLocalProfileInt("Setup", "MusicVolume", m_sound->GetMusicVolume()); GetProfile().SetLocalProfileInt("Setup", "Sound3D", m_sound->GetSound3D()); GetProfile().SetLocalProfileInt("Setup", "EditIndentMode", m_engine->GetEditIndentMode()); GetProfile().SetLocalProfileInt("Setup", "EditIndentValue", m_engine->GetEditIndentValue()); - - - // GetProfile()->SetLocalProfileInt("Setup", "NiceMouse", m_engine->GetNiceMouse()); - // GetProfile()->SetLocalProfileInt("Setup", "UseJoystick", m_engine->GetJoystick()); - // GetProfile()->SetLocalProfileInt("Setup", "MidiVolume", m_sound->GetMidiVolume()); - + + /* screen setup */ + if (m_setupFull) + GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1); + else + 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()); + } + } + std::stringstream key; for (int i = 0; i < INPUT_SLOT_MAX; i++) { @@ -5724,11 +5697,10 @@ void CMainDialog::SetupRecall() m_sound->SetAudioVolume(iValue); } - // TODO - // if ( GetLocalProfileInt("Setup", "MidiVolume", iValue) ) - // { - // m_sound->SetMidiVolume(iValue); - // } + if ( GetProfile().GetLocalProfileInt("Setup", "MusicVolume", iValue) ) + { + m_sound->SetMusicVolume(iValue); + } if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentMode", iValue) ) { @@ -5772,6 +5744,14 @@ void CMainDialog::SetupRecall() { m_bDeleteGamer = iValue; } + + if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) { + m_setupSelMode = iValue; + } + + if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) { + m_setupFull = (iValue == 1); + } } -- cgit v1.2.3-1-g7c22 From 1b4208cdc5143cfc8f46da063a1a991795d7f307 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 28 Dec 2012 23:06:12 +0100 Subject: Implement language Char for level files This currently lacks fallback to an existing entry for non-translated entries --- 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 ebf7d10..68e7854 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -4305,8 +4305,8 @@ void CMainDialog::IOReadName() } } - // TODO: language letters - sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/ ); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar() ); if ( Cmd(line, op) ) { OpString(line, "resume", resume); @@ -4701,8 +4701,8 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - /* TODO: language letters */ - sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4748,8 +4748,8 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - // TODO: language letters - sprintf(op, "Title.%c", 'E'/*GetLanguageLetter()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4851,8 +4851,8 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) } } - // TODO: language letters - sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4996,8 +4996,8 @@ void CMainDialog::UpdateSceneResume(int rank) } } - // TODO: language letters - sprintf(op, "Resume.%c", 'E' /*MAX_FNAME()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Resume.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); -- cgit v1.2.3-1-g7c22 From ea3e97b26db558e003897f8aa1646af32a4f2418 Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 29 Dec 2012 13:32:11 +0100 Subject: * Fixed problem with scrolling down text fields with mouse scroll * Fixed problem with scroll bar not updating position properly in text fields --- src/ui/edit.cpp | 60 +++++++++++++++++++++++++++++++-------------------------- src/ui/edit.h | 2 ++ 2 files changed, 35 insertions(+), 27 deletions(-) (limited to 'src/ui') diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index e14b19d..639215a 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -243,7 +243,7 @@ bool CEdit::EventProcess(const Event &event) Scroll(m_lineFirst-3, true); return true; } - if (event.type == EVENT_KEY_DOWN && + if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mousePos) ) { @@ -282,7 +282,7 @@ bool CEdit::EventProcess(const Event &event) } } - if ( m_scroll != 0 && !m_bGeneric ) + if ( m_scroll != nullptr && !m_bGeneric ) { m_scroll->EventProcess(event); @@ -1248,7 +1248,7 @@ void CEdit::SetText(const char *text, bool bNew) { int i, j, font; bool bBOL; - + if ( !bNew ) UndoMemorize(OPERUNDO_SPEC); m_len = strlen(text); @@ -2172,11 +2172,11 @@ void CEdit::Scroll() { float value; - if ( m_scroll != 0 ) + if ( m_scroll != nullptr ) { value = m_scroll->GetVisibleValue(); - value *= m_lineTotal-m_lineVisible; - Scroll(static_cast(value+0.5f), true); + value *= m_lineTotal - m_lineVisible; + Scroll(static_cast(value + 0.5f), true); } } @@ -3048,7 +3048,7 @@ bool CEdit::MinMaj(bool bMaj) void CEdit::Justif() { - float width, value, size, indentLength; + float width, size, indentLength; int i, j, line, indent; bool bDual, bString, bRem; @@ -3176,26 +3176,7 @@ void CEdit::Justif() m_lineFirst = 0; } - if ( m_scroll != 0 ) - { - if ( m_lineTotal <= m_lineVisible ) - { - m_scroll->SetVisibleRatio(1.0f); - m_scroll->SetVisibleValue(0.0f); - m_scroll->SetArrowStep(0.0f); - } - else - { - value = static_cast(m_lineVisible/m_lineTotal); - m_scroll->SetVisibleRatio(value); - - value = static_cast(m_lineFirst/(m_lineTotal-m_lineVisible)); - m_scroll->SetVisibleValue(value); - - value = static_cast(1.0f/(m_lineTotal-m_lineVisible)); - m_scroll->SetArrowStep(value); - } - } + UpdateScroll(); m_timeBlink = 0.0f; // lights the cursor immediately } @@ -3326,5 +3307,30 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format) return true; } +void CEdit::UpdateScroll() +{ + float value; + + if ( m_scroll != nullptr ) + { + if ( m_lineTotal <= m_lineVisible ) + { + m_scroll->SetVisibleRatio(1.0f); + m_scroll->SetVisibleValue(0.0f); + m_scroll->SetArrowStep(0.0f); + } + else + { + value = static_cast(m_lineVisible) / m_lineTotal; + m_scroll->SetVisibleRatio(value); + + value = static_cast(m_lineFirst) / (m_lineTotal - m_lineVisible); + m_scroll->SetVisibleValue(value); + + value = 1.0f / (m_lineTotal - m_lineVisible); + m_scroll->SetArrowStep(value); + } + } +} } diff --git a/src/ui/edit.h b/src/ui/edit.h index 35d8b2c..7247181 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -234,6 +234,8 @@ protected: void UndoFlush(); void UndoMemorize(OperUndo oper); bool UndoRecall(); + + void UpdateScroll(); protected: CScroll* m_scroll; // vertical scrollbar on the right -- cgit v1.2.3-1-g7c22