summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/edit.cpp60
-rw-r--r--src/ui/edit.h2
-rw-r--r--src/ui/maindialog.cpp152
-rw-r--r--src/ui/test/CMakeLists.txt10
4 files changed, 108 insertions, 116 deletions
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<int>(value+0.5f), true);
+ value *= m_lineTotal - m_lineVisible;
+ Scroll(static_cast<int>(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<float>(m_lineVisible/m_lineTotal);
- m_scroll->SetVisibleRatio(value);
-
- value = static_cast<float>(m_lineFirst/(m_lineTotal-m_lineVisible));
- m_scroll->SetVisibleValue(value);
-
- value = static_cast<float>(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<float>(m_lineVisible) / m_lineTotal;
+ m_scroll->SetVisibleRatio(value);
+
+ value = static_cast<float>(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
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 5136a41..68e7854 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<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
- if ( pc == 0 ) break;
- pl = static_cast<CList*>(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;
@@ -4329,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);
@@ -4725,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);
@@ -4772,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);
@@ -4875,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);
@@ -5020,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);
@@ -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<CWindow*>(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<Math::IntPoint> 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<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
if ( ps != 0 )
{
- /* TODO: midi volume
- value = (float)m_sound->GetMidiVolume();
- ps->SetVisibleValue(value);*/
+ value = static_cast<float>(m_sound->GetMusicVolume());
+ ps->SetVisibleValue(value);
}
pc = static_cast<CCheck*>(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<CWindow *>(m_interface->SearchControl(EVENT_WINDOW5));
+ if ( pw != 0 ) {
+ pl = static_cast<CList *>(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);
+ }
}
diff --git a/src/ui/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt
index 9e11e14..e411067 100644
--- a/src/ui/test/CMakeLists.txt
+++ b/src/ui/test/CMakeLists.txt
@@ -1,13 +1,17 @@
cmake_minimum_required(VERSION 2.8)
-set(CMAKE_BUILD_TYPE debug)
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE debug)
+endif(NOT CMAKE_BUILD_TYPE)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
+set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
include_directories(
.
../..
../../..
-${GTEST_DIR}/include
+${GTEST_INCLUDE_DIR}
+${GMOCK_INCLUDE_DIR}
)