Split CScreenSetup

master
krzys-h 2015-08-06 11:24:02 +02:00
parent 0c9cf51d81
commit a322f46f00
17 changed files with 2119 additions and 1492 deletions

View File

@ -215,8 +215,13 @@ set(BASE_SOURCES
ui/screen/screen_loading.cpp
ui/screen/screen_main_menu.cpp
ui/screen/screen_player_select.cpp
ui/screen/screen_setup.cpp
ui/screen/screen_quit.cpp
ui/screen/screen_setup.cpp
ui/screen/screen_setup_controls.cpp
ui/screen/screen_setup_display.cpp
ui/screen/screen_setup_game.cpp
ui/screen/screen_setup_graphics.cpp
ui/screen/screen_setup_sound.cpp
ui/screen/screen_welcome.cpp
ui/button.cpp
ui/check.cpp

View File

@ -55,7 +55,11 @@
#include "ui/screen/screen_loading.h"
#include "ui/screen/screen_main_menu.h"
#include "ui/screen/screen_player_select.h"
#include "ui/screen/screen_setup.h"
#include "ui/screen/screen_setup_controls.h"
#include "ui/screen/screen_setup_display.h"
#include "ui/screen/screen_setup_game.h"
#include "ui/screen/screen_setup_graphics.h"
#include "ui/screen/screen_setup_sound.h"
#include "ui/screen/screen_quit.h"
#include "ui/screen/screen_welcome.h"
@ -136,8 +140,12 @@ void CMainDialog::Create()
m_screenIORead = MakeUnique<CScreenIORead>(m_screenLevelList.get());
m_screenIOWrite = MakeUnique<CScreenIOWrite>(m_screenLevelList.get());
m_screenLoading = MakeUnique<CScreenLoading>();
m_screenSetup = MakeUnique<CScreenSetup>();
m_screenMainMenu = MakeUnique<CScreenMainMenu>(m_screenSetup.get());
m_screenSetupControls = MakeUnique<CScreenSetupControls>();
m_screenSetupDisplay = MakeUnique<CScreenSetupDisplay>();
m_screenSetupGame = MakeUnique<CScreenSetupGame>();
m_screenSetupGraphics = MakeUnique<CScreenSetupGraphics>();
m_screenSetupSound = MakeUnique<CScreenSetupSound>();
m_screenMainMenu = MakeUnique<CScreenMainMenu>();
m_screenPlayerSelect = MakeUnique<CScreenPlayerSelect>(this);
m_screenQuit = MakeUnique<CScreenQuit>();
m_screenWelcome = MakeUnique<CScreenWelcome>();
@ -152,6 +160,17 @@ CMainDialog::~CMainDialog()
// Changes phase.
CScreenSetup* CMainDialog::GetSetupScreen(Phase phase)
{
if(phase == PHASE_SETUPd) return m_screenSetupDisplay.get();
if(phase == PHASE_SETUPg) return m_screenSetupGraphics.get();
if(phase == PHASE_SETUPp) return m_screenSetupGame.get();
if(phase == PHASE_SETUPc) return m_screenSetupControls.get();
if(phase == PHASE_SETUPs) return m_screenSetupSound.get();
assert(false);
return nullptr;
}
void CMainDialog::ChangePhase(Phase phase)
{
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
@ -194,13 +213,17 @@ void CMainDialog::ChangePhase(Phase phase)
}
if (m_phase >= PHASE_SETUPd && m_phase <= PHASE_SETUPs)
{
m_screenSetup->SetTab(m_phase, false);
m_currentScreen = m_screenSetup.get();
CScreenSetup* screenSetup = GetSetupScreen(m_phase);
screenSetup->SetInSimulation(false);
screenSetup->SetActive();
m_currentScreen = screenSetup;
}
if (m_phase >= PHASE_SETUPds && m_phase <= PHASE_SETUPss)
{
m_screenSetup->SetTab(static_cast<Phase>(m_phase - PHASE_SETUPds + PHASE_SETUPd), true);
m_currentScreen = m_screenSetup.get();
CScreenSetup* screenSetup = GetSetupScreen(static_cast<Phase>(m_phase - PHASE_SETUPds + PHASE_SETUPd));
screenSetup->SetInSimulation(true);
screenSetup->SetActive();
m_currentScreen = screenSetup;
}
if (m_phase == PHASE_WRITEs)
{
@ -341,14 +364,14 @@ bool CMainDialog::EventProcess(const Event &event)
StopDialog();
m_main->StartSuspend();
#if PLATFORM_LINUX
if ( m_screenSetup->GetSetupTab() == PHASE_SETUPd ) m_main->ChangePhase(PHASE_SETUPds);
if ( CScreenSetup::GetTab() == PHASE_SETUPd ) m_main->ChangePhase(PHASE_SETUPds);
#else
if ( m_screenSetup->GetSetupTab() == PHASE_SETUPd ) m_main->ChangePhase(PHASE_SETUPgs);
if ( CScreenSetup::GetTab() == PHASE_SETUPd ) m_main->ChangePhase(PHASE_SETUPgs);
#endif
if ( m_screenSetup->GetSetupTab() == PHASE_SETUPg ) m_main->ChangePhase(PHASE_SETUPgs);
if ( m_screenSetup->GetSetupTab() == PHASE_SETUPp ) m_main->ChangePhase(PHASE_SETUPps);
if ( m_screenSetup->GetSetupTab() == PHASE_SETUPc ) m_main->ChangePhase(PHASE_SETUPcs);
if ( m_screenSetup->GetSetupTab() == PHASE_SETUPs ) m_main->ChangePhase(PHASE_SETUPss);
if ( CScreenSetup::GetTab() == PHASE_SETUPg ) m_main->ChangePhase(PHASE_SETUPgs);
if ( CScreenSetup::GetTab() == PHASE_SETUPp ) m_main->ChangePhase(PHASE_SETUPps);
if ( CScreenSetup::GetTab() == PHASE_SETUPc ) m_main->ChangePhase(PHASE_SETUPcs);
if ( CScreenSetup::GetTab() == PHASE_SETUPs ) m_main->ChangePhase(PHASE_SETUPss);
}
if ( event.type == EVENT_INTERFACE_AGAIN )
{

View File

@ -55,6 +55,11 @@ class CScreenMainMenu;
class CScreenPlayerSelect;
class CScreenQuit;
class CScreenSetup;
class CScreenSetupControls;
class CScreenSetupDisplay;
class CScreenSetupGame;
class CScreenSetupGraphics;
class CScreenSetupSound;
class CScreenWelcome;
@ -101,6 +106,8 @@ protected:
void FrameParticle(float rTime);
void NiceParticle(Math::Point mouse, bool bPress);
CScreenSetup* GetSetupScreen(Phase phase);
protected:
CApplication* m_app;
CRobotMain* m_main;
@ -122,7 +129,11 @@ protected:
std::unique_ptr<CScreenMainMenu> m_screenMainMenu;
std::unique_ptr<CScreenPlayerSelect> m_screenPlayerSelect;
std::unique_ptr<CScreenQuit> m_screenQuit;
std::unique_ptr<CScreenSetup> m_screenSetup;
std::unique_ptr<CScreenSetupControls> m_screenSetupControls;
std::unique_ptr<CScreenSetupDisplay> m_screenSetupDisplay;
std::unique_ptr<CScreenSetupGame> m_screenSetupGame;
std::unique_ptr<CScreenSetupGraphics> m_screenSetupGraphics;
std::unique_ptr<CScreenSetupSound> m_screenSetupSound;
std::unique_ptr<CScreenWelcome> m_screenWelcome;
Phase m_phase; // copy of CRobotMain

View File

@ -36,8 +36,7 @@
namespace Ui
{
CScreenMainMenu::CScreenMainMenu(CScreenSetup* screenSetup)
: m_screenSetup(screenSetup)
CScreenMainMenu::CScreenMainMenu()
{
}
@ -208,7 +207,7 @@ bool CScreenMainMenu::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_SETUP:
m_main->ChangePhase(m_screenSetup->GetSetupTab());
m_main->ChangePhase(CScreenSetup::GetTab());
break;
case EVENT_INTERFACE_NAME:

View File

@ -29,13 +29,10 @@ class CScreenSetup;
class CScreenMainMenu : public CScreen
{
public:
CScreenMainMenu(CScreenSetup* screenSetup);
CScreenMainMenu();
void CreateInterface() override;
bool EventProcess(const Event &event) override;
private:
CScreenSetup* m_screenSetup;
};
} // namespace Ui

File diff suppressed because it is too large Load Diff

View File

@ -38,32 +38,19 @@ class CScreenSetup : public CScreen
public:
CScreenSetup();
void SetTab(Phase tab, bool simulationSetup);
void SetInSimulation(bool simulationSetup);
virtual void SetActive() = 0;
static Phase GetTab();
void CreateInterface() override;
bool EventProcess(const Event &event) override;
Phase GetSetupTab();
protected:
void UpdateDisplayMode();
void ChangeDisplay();
void UpdateApply();
void UpdateSetupButtons();
void ChangeSetupButtons();
void ChangeSetupQuality(int quality);
void UpdateKey();
void ChangeKey(EventType event);
protected:
CSettings* m_settings;
Gfx::CCamera* m_camera;
Phase m_tab;
static Phase m_tab;
bool m_simulationSetup;
int m_setupSelMode;
bool m_setupFull;
};
} // namespace Ui

View File

@ -0,0 +1,223 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "ui/screen/screen_setup_controls.h"
#include "common/config.h"
#include "app/app.h"
#include "common/settings.h"
#include "common/stringutils.h"
#include "graphics/engine/camera.h"
#include "ui/button.h"
#include "ui/group.h"
#include "ui/interface.h"
#include "ui/key.h"
#include "ui/label.h"
#include "ui/scroll.h"
#include "ui/window.h"
namespace Ui
{
const int KEY_VISIBLE = 6; // number of visible keys redefinable
CScreenSetupControls::CScreenSetupControls()
{
}
void CScreenSetupControls::SetActive()
{
m_tab = PHASE_SETUPc;
}
void CScreenSetupControls::CreateInterface()
{
CWindow* pw;
CLabel* pl;
CCheck* pc;
CScroll* ps;
CButton* pb;
CGroup* pg;
Math::Point pos, ddim;
std::string name;
CScreenSetup::CreateInterface();
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pos.x = ox+sx*3;
pos.y = 320.0f/480.0f;
ddim.x = dim.x*15.0f;
ddim.y = 18.0f/480.0f;
GetResource(RES_TEXT, RT_SETUP_KEY1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_KINFO1, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*3;
pos.y = 302.0f/480.0f;
ddim.x = dim.x*15.0f;
ddim.y = 18.0f/480.0f;
GetResource(RES_TEXT, RT_SETUP_KEY2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_KINFO2, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
ddim.x = 428.0f/640.0f;
ddim.y = 128.0f/480.0f;
pos.x = 105.0f/640.0f;
pos.y = 164.0f/480.0f;
pg = pw->CreateGroup(pos, ddim, 0, EVENT_INTERFACE_KGROUP);
pg->ClearState(STATE_ENABLE);
pg->SetState(STATE_DEAD);
pg->SetState(STATE_SHADOW);
ddim.x = 18.0f/640.0f;
ddim.y = (20.0f/480.0f)*KEY_VISIBLE;
pos.x = 510.0f/640.0f;
pos.y = 168.0f/480.0f;
ps = pw->CreateScroll(pos, ddim, -1, EVENT_INTERFACE_KSCROLL);
ps->SetVisibleRatio(static_cast<float>(KEY_VISIBLE/INPUT_SLOT_MAX));
ps->SetArrowStep(1.0f/(static_cast<float>(INPUT_SLOT_MAX-KEY_VISIBLE)));
UpdateKey();
ddim.x = dim.x*6;
ddim.y = dim.y*0.5f;
pos.x = ox+sx*3;
pos.y = 130.0f/480.0f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_JOYSTICK);
pc->SetState(STATE_SHADOW);
ddim.x = dim.x*6;
ddim.y = dim.y*1;
pos.x = ox+sx*10;
pos.y = oy+sy*2;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_KDEF);
pb->SetState(STATE_SHADOW);
UpdateSetupButtons();
}
bool CScreenSetupControls::EventProcess(const Event &event)
{
if (!CScreenSetup::EventProcess(event)) return false;
switch( event.type )
{
case EVENT_INTERFACE_KSCROLL:
UpdateKey();
break;
case EVENT_INTERFACE_KDEF:
CInput::GetInstancePointer()->SetDefaultInputBindings();
UpdateKey();
break;
case EVENT_INTERFACE_JOYSTICK:
m_app->SetJoystickEnabled(!m_app->GetJoystickEnabled());
UpdateSetupButtons();
break;
default:
if (event.type >= EVENT_INTERFACE_KEY && event.type <= EVENT_INTERFACE_KEY_END)
{
ChangeKey(event.type);
UpdateKey();
break;
}
return true;
}
return false;
}
// Updates the buttons during the setup phase.
void CScreenSetupControls::UpdateSetupButtons()
{
CWindow* pw;
CCheck* pc;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_JOYSTICK));
if ( pc != 0 )
{
pc->SetState(STATE_ENABLE, m_app->GetJoystick().index >= 0);
pc->SetState(STATE_CHECK, m_app->GetJoystickEnabled());
}
}
// Updates the list of keys.
void CScreenSetupControls::UpdateKey()
{
CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if (pw == nullptr) return;
CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if (ps == nullptr) return;
int first = static_cast<int>(ps->GetVisibleValue()*(INPUT_SLOT_MAX-KEY_VISIBLE));
for (int i = 0; i < INPUT_SLOT_MAX; i++)
pw->DeleteControl(static_cast<EventType>(EVENT_INTERFACE_KEY+i));
Math::Point dim;
dim.x = 400.0f/640.0f;
dim.y = 20.0f/480.0f;
Math::Point pos;
pos.x = 110.0f/640.0f;
pos.y = 168.0f/480.0f + dim.y*(KEY_VISIBLE-1);
for (int i = 0; i < KEY_VISIBLE; i++)
{
pw->CreateKey(pos, dim, -1, static_cast<EventType>(EVENT_INTERFACE_KEY+first+i));
CKey* pk = static_cast<CKey*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_KEY+first+i)));
if (pk == nullptr) break;
pk->SetBinding(CInput::GetInstancePointer()->GetInputBinding(static_cast<InputSlot>(first+i)));
pos.y -= dim.y;
}
}
// Change a key.
void CScreenSetupControls::ChangeKey(EventType event)
{
CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if (pw == nullptr) return;
CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if (ps == nullptr) return;
for (int i = 0; i < INPUT_SLOT_MAX; i++)
{
if ( EVENT_INTERFACE_KEY+i == event )
{
CKey* pk = static_cast<CKey*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_KEY+i)));
if (pk == nullptr) break;
CInput::GetInstancePointer()->SetInputBinding(static_cast<InputSlot>(i), pk->GetBinding());
}
}
}
} // namespace Ui

View File

@ -0,0 +1,49 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "ui/screen/screen_setup.h"
class CSettings;
namespace Gfx
{
class CCamera;
}
namespace Ui
{
class CScreenSetupControls : public CScreenSetup
{
public:
CScreenSetupControls();
void SetActive() override;
void CreateInterface() override;
bool EventProcess(const Event &event) override;
protected:
void UpdateSetupButtons();
void UpdateKey();
void ChangeKey(EventType event);
};
} // namespace Ui

View File

@ -0,0 +1,284 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "ui/screen/screen_setup_display.h"
#include "common/config.h"
#include "app/app.h"
#include "common/settings.h"
#include "common/stringutils.h"
#include "graphics/engine/camera.h"
#include "ui/button.h"
#include "ui/check.h"
#include "ui/interface.h"
#include "ui/label.h"
#include "ui/list.h"
#include "ui/window.h"
namespace Ui
{
CScreenSetupDisplay::CScreenSetupDisplay()
: m_setupSelMode{0},
m_setupFull{false}
{
}
void CScreenSetupDisplay::SetActive()
{
m_tab = PHASE_SETUPd;
}
void CScreenSetupDisplay::CreateInterface()
{
CWindow* pw;
CLabel* pl;
CList* pli;
CCheck* pc;
CButton* pb;
Math::Point pos, ddim;
std::string name;
CScreenSetup::CreateInterface();
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
std::vector<Math::IntPoint> modes;
m_app->GetVideoResolutionList(modes, true, true);
for (auto it = modes.begin(); it != modes.end(); ++it)
{
if (it->x == m_app->GetVideoConfig().size.x && it->y == m_app->GetVideoConfig().size.y)
{
m_setupSelMode = it - modes.begin();
break;
}
}
m_setupFull = m_app->GetVideoConfig().fullScreen;
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_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*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();
ddim.x = dim.x*4;
ddim.y = dim.y*0.5f;
pos.x = ox+sx*3;
pos.y = oy+sy*4.1f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_FULL);
pc->SetState(STATE_SHADOW);
pc->SetState(STATE_CHECK, m_setupFull);
#if !PLATFORM_LINUX
ddim.x = 0.9f;
ddim.y = 0.1f;
pos.x = 0.05f;
pos.y = 0.20f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "The game will be restarted in order to apply changes. All unsaved progress will be lost.");
#endif
ddim.x = dim.x*6;
ddim.y = dim.y*1;
pos.x = ox+sx*10;
pos.y = oy+sy*2;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_APPLY);
pb->SetState(STATE_SHADOW);
UpdateApply();
}
bool CScreenSetupDisplay::EventProcess(const Event &event)
{
if (!CScreenSetup::EventProcess(event)) return false;
CWindow* pw;
CCheck* pc;
CButton* pb;
switch( event.type )
{
case EVENT_LIST2:
UpdateApply();
break;
case EVENT_INTERFACE_FULL:
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;
if ( pc->TestState(STATE_CHECK) )
{
pc->ClearState(STATE_CHECK);
}
else
{
pc->SetState(STATE_CHECK);
}
UpdateApply();
break;
case EVENT_INTERFACE_APPLY:
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY));
if ( pb == 0 ) break;
pb->ClearState(STATE_PRESS);
pb->ClearState(STATE_HILIGHT);
ChangeDisplay();
UpdateApply();
break;
default:
return true;
}
return false;
}
// Updates the list of modes.
int GCD(int a, int b)
{
return (b == 0) ? a : GCD(b, a%b);
}
Math::IntPoint AspectRatio(Math::IntPoint resolution)
{
int gcd = GCD(resolution.x, resolution.y);
return Math::IntPoint(static_cast<float>(resolution.x) / gcd, static_cast<float>(resolution.y) / gcd);
}
void CScreenSetupDisplay::UpdateDisplayMode()
{
CWindow* pw;
CList* pl;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) return;
pl->Flush();
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("");
Math::IntPoint aspect = AspectRatio(mode);
mode_text << mode.x << "x" << mode.y << " [" << aspect.x << ":" << aspect.y << "]";
pl->SetItemName(i++, mode_text.str().c_str());
}
pl->SetSelect(m_setupSelMode);
pl->ShowSelect(false);
}
// Change the graphics mode.
void CScreenSetupDisplay::ChangeDisplay()
{
CWindow* pw;
CList* pl;
CCheck* pc;
bool bFull;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) return;
m_setupSelMode = pl->GetSelect();
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
if ( pc == 0 ) return;
bFull = pc->TestState(STATE_CHECK);
m_setupFull = bFull;
std::vector<Math::IntPoint> modes;
m_app->GetVideoResolutionList(modes, true, true);
Gfx::DeviceConfig config = m_app->GetVideoConfig();
config.size = modes[m_setupSelMode];
config.fullScreen = bFull;
m_settings->SaveResolutionSettings(config);
#if !PLATFORM_LINUX
// Windows causes problems, so we'll restart the game
// Mac OS was not tested so let's restart just to be sure
m_app->Restart();
#else
m_app->ChangeVideoConfig(config);
#endif
}
// Updates the "apply" button.
void CScreenSetupDisplay::UpdateApply()
{
CWindow* pw;
CButton* pb;
CList* pl;
CCheck* pc;
int sel2;
bool bFull;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY));
pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) return;
sel2 = pl->GetSelect();
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
bFull = pc->TestState(STATE_CHECK);
if ( sel2 == m_setupSelMode &&
bFull == m_setupFull )
{
pb->ClearState(STATE_ENABLE);
}
else
{
pb->SetState(STATE_ENABLE);
}
}
} // namespace Ui

View File

@ -0,0 +1,53 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "ui/screen/screen_setup.h"
class CSettings;
namespace Gfx
{
class CCamera;
}
namespace Ui
{
class CScreenSetupDisplay : public CScreenSetup
{
public:
CScreenSetupDisplay();
void SetActive() override;
void CreateInterface() override;
bool EventProcess(const Event &event) override;
protected:
void UpdateDisplayMode();
void ChangeDisplay();
void UpdateApply();
protected:
int m_setupSelMode;
bool m_setupFull;
};
} // namespace Ui

View File

@ -0,0 +1,443 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "ui/screen/screen_setup_game.h"
#include "common/config.h"
#include "app/app.h"
#include "common/settings.h"
#include "common/stringutils.h"
#include "graphics/engine/camera.h"
#include "ui/button.h"
#include "ui/check.h"
#include "ui/interface.h"
#include "ui/label.h"
#include "ui/slider.h"
#include "ui/window.h"
namespace Ui
{
CScreenSetupGame::CScreenSetupGame()
{
}
void CScreenSetupGame::SetActive()
{
m_tab = PHASE_SETUPp;
}
void CScreenSetupGame::CreateInterface()
{
CWindow* pw;
CLabel* pl;
CCheck* pc;
CSlider* psl;
Math::Point pos, ddim;
std::string name;
CScreenSetup::CreateInterface();
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
ddim.x = dim.x*6;
ddim.y = dim.y*0.5f;
pos.x = ox+sx*3;
pos.y = 0.65f;
//? pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_TOTO);
//? pc->SetState(STATE_SHADOW);
//? pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOVIES);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SCROLL);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_INVERTX);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_INVERTY);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EFFECT);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_BLOOD);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_AUTOSAVE_ENABLE);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pos.y -= ddim.y;
ddim.x = dim.x*2.5f;
psl = pw->CreateSlider(pos, ddim, -1, EVENT_INTERFACE_AUTOSAVE_INTERVAL);
psl->SetState(STATE_SHADOW);
psl->SetLimit(1.0f, 30.0f);
psl->SetArrowStep(1.0f);
pos.y += ddim.y/2;
GetResource(RES_EVENT, EVENT_INTERFACE_AUTOSAVE_INTERVAL, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.y -= ddim.y/2;
pos.x = ox+sx*3+dim.x*3.5f;
psl = pw->CreateSlider(pos, ddim, -1, EVENT_INTERFACE_AUTOSAVE_SLOTS);
psl->SetState(STATE_SHADOW);
psl->SetLimit(1.0f, 10.0f);
psl->SetArrowStep(1.0f);
pos.y += ddim.y/2;
GetResource(RES_EVENT, EVENT_INTERFACE_AUTOSAVE_SLOTS, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.y -= ddim.y/2;
//? pos.y -= 0.048f;
//? pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_NICERST);
//? pc->SetState(STATE_SHADOW);
//? pos.y -= 0.048f;
//? pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_HIMSELF);
//? pc->SetState(STATE_SHADOW);
ddim.x = dim.x*6;
ddim.y = dim.y*0.5f;
pos.x = ox+sx*10;
pos.y = 0.65f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_TOOLTIP);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_GLINT);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_RAIN);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOUSE);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EDITMODE);
pc->SetState(STATE_SHADOW);
if ( m_simulationSetup )
{
pc->SetState(STATE_DEAD);
}
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EDITVALUE);
pc->SetState(STATE_SHADOW);
UpdateSetupButtons();
}
bool CScreenSetupGame::EventProcess(const Event &event)
{
if (!CScreenSetup::EventProcess(event)) return false;
switch( event.type )
{
case EVENT_INTERFACE_TOTO:
m_engine->SetTotoMode(!m_engine->GetTotoMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_TOOLTIP:
m_settings->SetTooltips(!m_settings->GetTooltips());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_GLINT:
m_settings->SetInterfaceGlint(!m_settings->GetInterfaceGlint());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_RAIN:
m_settings->SetInterfaceRain(!m_settings->GetInterfaceRain());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_MOUSE:
if (m_app->GetMouseMode() == MOUSE_SYSTEM)
m_app->SetMouseMode(MOUSE_ENGINE);
else
m_app->SetMouseMode(MOUSE_SYSTEM);
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_EDITMODE:
m_engine->SetEditIndentMode(!m_engine->GetEditIndentMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_EDITVALUE:
if ( m_engine->GetEditIndentValue() == 2 )
{
m_engine->SetEditIndentValue(4);
}
else
{
m_engine->SetEditIndentValue(2);
}
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_SOLUCE4:
m_settings->SetSoluce4(!m_settings->GetSoluce4());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_MOVIES:
m_settings->SetMovies(!m_settings->GetMovies());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_NICERST:
m_settings->SetNiceReset(!m_settings->GetNiceReset());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_HIMSELF:
m_settings->SetHimselfDamage(!m_settings->GetHimselfDamage());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_SCROLL:
m_camera->SetCameraScroll(!m_camera->GetCameraScroll());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_INVERTX:
m_camera->SetCameraInvertX(!m_camera->GetCameraInvertX());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_INVERTY:
m_camera->SetCameraInvertY(!m_camera->GetCameraInvertY());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_EFFECT:
m_camera->SetEffect(!m_camera->GetEffect());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_BLOOD:
m_camera->SetBlood(!m_camera->GetBlood());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_AUTOSAVE_ENABLE:
m_main->SetAutosave(!m_main->GetAutosave());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_AUTOSAVE_INTERVAL:
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_AUTOSAVE_SLOTS:
ChangeSetupButtons();
UpdateSetupButtons();
break;
default:
return true;
}
return false;
}
// Updates the buttons during the setup phase.
void CScreenSetupGame::UpdateSetupButtons()
{
CWindow* pw;
CCheck* pc;
CSlider* ps;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOTO));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetTotoMode());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOOLTIP));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_settings->GetTooltips());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GLINT));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_settings->GetInterfaceGlint());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_RAIN));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_settings->GetInterfaceRain());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOUSE));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_app->GetMouseMode() == MOUSE_SYSTEM);
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITMODE));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetEditIndentMode());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITVALUE));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetEditIndentValue()>2);
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE4));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_settings->GetSoluce4());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOVIES));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_settings->GetMovies());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_NICERST));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_settings->GetNiceReset());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_HIMSELF));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_settings->GetHimselfDamage());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SCROLL));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_camera->GetCameraScroll());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTX));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_camera->GetCameraInvertX());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTY));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_camera->GetCameraInvertY());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EFFECT));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_camera->GetEffect());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_BLOOD));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_camera->GetBlood());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_AUTOSAVE_ENABLE));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_main->GetAutosave());
}
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_AUTOSAVE_INTERVAL));
if ( ps != 0 )
{
ps->SetState(STATE_ENABLE, m_main->GetAutosave());
ps->SetVisibleValue(m_main->GetAutosaveInterval());
}
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_AUTOSAVE_SLOTS));
if ( ps != 0 )
{
ps->SetState(STATE_ENABLE, m_main->GetAutosave());
ps->SetVisibleValue(m_main->GetAutosaveSlots());
}
}
// Updates the engine function of the buttons after the setup phase.
void CScreenSetupGame::ChangeSetupButtons()
{
CWindow* pw;
CSlider* ps;
float value;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_AUTOSAVE_INTERVAL));
if ( ps != 0 )
{
value = ps->GetVisibleValue();
m_main->SetAutosaveInterval(static_cast<int>(round(value)));
}
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_AUTOSAVE_SLOTS));
if ( ps != 0 )
{
value = ps->GetVisibleValue();
m_main->SetAutosaveSlots(static_cast<int>(round(value)));
}
}
} // namespace Ui

View File

@ -0,0 +1,48 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "ui/screen/screen_setup.h"
class CSettings;
namespace Gfx
{
class CCamera;
}
namespace Ui
{
class CScreenSetupGame : public CScreenSetup
{
public:
CScreenSetupGame();
void SetActive() override;
void CreateInterface() override;
bool EventProcess(const Event &event) override;
protected:
void UpdateSetupButtons();
void ChangeSetupButtons();
};
} // namespace Ui

View File

@ -0,0 +1,672 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "ui/screen/screen_setup_graphics.h"
#include "common/config.h"
#include "app/app.h"
#include "common/settings.h"
#include "common/stringutils.h"
#include "graphics/engine/camera.h"
#include "ui/button.h"
#include "ui/check.h"
#include "ui/editvalue.h"
#include "ui/enumslider.h"
#include "ui/interface.h"
#include "ui/label.h"
#include "ui/window.h"
namespace Ui
{
CScreenSetupGraphics::CScreenSetupGraphics()
{
}
void CScreenSetupGraphics::SetActive()
{
m_tab = PHASE_SETUPg;
}
void CScreenSetupGraphics::CreateInterface()
{
CWindow* pw;
CEditValue* pv;
CLabel* pl;
CCheck* pc;
CEnumSlider* pes;
CButton* pb;
Math::Point pos, ddim;
std::string name;
CScreenSetup::CreateInterface();
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
ddim.x = dim.x*6;
ddim.y = dim.y*0.5f;
pos.x = ox+sx*3;
pos.y = 0.65f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SHADOW);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_GROUND);
pc->SetState(STATE_SHADOW);
if ( m_simulationSetup )
{
pc->SetState(STATE_DEAD);
}
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_DIRTY);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SKY);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_LENS);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_PLANET);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_FOG);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_LIGHT);
pc->SetState(STATE_SHADOW);
if ( m_simulationSetup )
{
pc->SetState(STATE_DEAD);
}
pos.x = ox+sx*3;
pos.y = 0.245f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_MSAA);
pes->SetState(STATE_SHADOW);
std::vector<float> msaaOptions;
for(int i = 1; i <= m_engine->GetDevice()->GetMaxSamples(); i *= 2)
msaaOptions.push_back(i);
pes->SetPossibleValues(msaaOptions);
if(m_engine->GetDevice()->GetMaxSamples() < 2)
pes->ClearState(STATE_ENABLE);
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_MSAA, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.65f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pv = pw->CreateEditValue(pos, ddim, 0, EVENT_INTERFACE_PARTI);
pv->SetState(STATE_SHADOW);
pv->SetMinValue(0.0f);
pv->SetMaxValue(2.0f);
pos.x += 0.13f;
pos.y -= 0.015f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_PARTI, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL10, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.59f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pv = pw->CreateEditValue(pos, ddim, 0, EVENT_INTERFACE_CLIP);
pv->SetState(STATE_SHADOW);
pv->SetMinValue(0.5f);
pv->SetMaxValue(2.0f);
pos.x += 0.13f;
pos.y -= 0.015f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_CLIP, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.53f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pv = pw->CreateEditValue(pos, ddim, 0, EVENT_INTERFACE_DETAIL);
pv->SetState(STATE_SHADOW);
pv->SetMinValue(0.0f);
pv->SetMaxValue(2.0f);
pos.x += 0.13f;
pos.y -= 0.015f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_DETAIL, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.47f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pv = pw->CreateEditValue(pos, ddim, 0, EVENT_INTERFACE_GADGET);
pv->SetState(STATE_SHADOW);
if ( m_simulationSetup )
{
pv->SetState(STATE_DEAD);
}
pv->SetMinValue(0.0f);
pv->SetMaxValue(1.0f);
pos.x += 0.13f;
pos.y -= 0.015f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_GADGET, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL13, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.385f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_FILTER);
pes->SetState(STATE_SHADOW);
pes->SetPossibleValues({
{ Gfx::TEX_FILTER_NEAREST, "Nearest" },
{ Gfx::TEX_FILTER_BILINEAR, "Bilinear" },
{ Gfx::TEX_FILTER_TRILINEAR, "Trilinear" }
});
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE_FILTER, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.315f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_MIPMAP);
pes->SetState(STATE_SHADOW);
pes->SetPossibleValues({1, 4, 8, 16});
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE_MIPMAP, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.245f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_ANISOTROPY);
pes->SetState(STATE_SHADOW);
std::vector<float> anisotropyOptions;
for(int i = 1; i <= m_engine->GetDevice()->GetMaxAnisotropyLevel(); i *= 2)
anisotropyOptions.push_back(i);
pes->SetPossibleValues(anisotropyOptions);
if(!m_engine->GetDevice()->IsAnisotropySupported())
pes->ClearState(STATE_ENABLE);
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE_ANISOTROPY, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*12.5;
pos.y = 0.385f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_SHADOW_MAPPING);
pes->SetState(STATE_SHADOW);
std::map<float, std::string> shadowOptions = {
{ -1, "Disabled" },
};
if (m_engine->GetDevice()->IsFramebufferSupported())
{
for(int i = 128; i <= m_engine->GetDevice()->GetMaxTextureSize(); i *= 2)
shadowOptions[i] = StrUtils::ToString<int>(i)+"x"+StrUtils::ToString<int>(i);
}
else
{
shadowOptions[0] = "Screen buffer"; // TODO: Is this the proper name for this?
}
pes->SetPossibleValues(shadowOptions);
if (!m_engine->GetDevice()->IsShadowMappingSupported())
{
pes->ClearState(STATE_ENABLE);
}
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_SHADOW_MAPPING, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*12.5;
pos.y = 0.315f;
ddim.x = dim.x*6;
ddim.y = dim.y*0.5f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SHADOW_MAPPING_QUALITY);
pc->SetState(STATE_SHADOW);
ddim.x = dim.x*2;
ddim.y = dim.y*1;
pos.x = ox+sx*10;
pos.y = oy+sy*2;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_MIN);
pb->SetState(STATE_SHADOW);
pos.x += ddim.x;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NORM);
pb->SetState(STATE_SHADOW);
pos.x += ddim.x;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_MAX);
pb->SetState(STATE_SHADOW);
UpdateSetupButtons();
}
bool CScreenSetupGraphics::EventProcess(const Event &event)
{
if (!CScreenSetup::EventProcess(event)) return false;
switch( event.type )
{
case EVENT_INTERFACE_SHADOW:
m_engine->SetShadow(!m_engine->GetShadow());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_GROUND:
m_engine->SetGroundSpot(!m_engine->GetGroundSpot());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_DIRTY:
m_engine->SetDirty(!m_engine->GetDirty());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_FOG:
m_engine->SetFog(!m_engine->GetFog());
m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok?
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_LENS:
m_engine->SetLensMode(!m_engine->GetLensMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_SKY:
m_engine->SetSkyMode(!m_engine->GetSkyMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_PLANET:
m_engine->SetPlanetMode(!m_engine->GetPlanetMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_LIGHT:
m_engine->SetLightMode(!m_engine->GetLightMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_PARTI:
case EVENT_INTERFACE_CLIP:
case EVENT_INTERFACE_DETAIL:
case EVENT_INTERFACE_GADGET:
ChangeSetupButtons();
break;
case EVENT_INTERFACE_TEXTURE_FILTER:
case EVENT_INTERFACE_TEXTURE_MIPMAP:
case EVENT_INTERFACE_TEXTURE_ANISOTROPY:
case EVENT_INTERFACE_MSAA:
case EVENT_INTERFACE_SHADOW_MAPPING:
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_SHADOW_MAPPING_QUALITY:
m_engine->SetShadowMappingQuality(!m_engine->GetShadowMappingQuality());
UpdateSetupButtons();
break;
case EVENT_INTERFACE_MIN:
ChangeSetupQuality(-1);
UpdateSetupButtons();
break;
case EVENT_INTERFACE_NORM:
ChangeSetupQuality(0);
UpdateSetupButtons();
break;
case EVENT_INTERFACE_MAX:
ChangeSetupQuality(1);
UpdateSetupButtons();
break;
default:
return true;
}
return false;
}
// Updates the buttons during the setup phase.
void CScreenSetupGraphics::UpdateSetupButtons()
{
CWindow* pw;
CCheck* pc;
CEditValue* pv;
CEnumSlider* pes;
float value;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_FILTER));
if ( pes != 0 )
{
pes->SetVisibleValue(m_engine->GetTextureFilterMode());
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP));
if ( pes != 0 )
{
pes->SetState(STATE_ENABLE, m_engine->GetTextureFilterMode() == Gfx::TEX_FILTER_TRILINEAR);
pes->SetVisibleValue(m_engine->GetTextureMipmapLevel());
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_ANISOTROPY));
if ( pes != 0 )
{
pes->SetVisibleValue(m_engine->GetTextureAnisotropyLevel());
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_MSAA));
if ( pes != 0 )
{
pes->SetVisibleValue(m_engine->GetMultiSample());
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_SHADOW_MAPPING));
if ( pes != 0 )
{
if (!m_engine->GetShadowMapping())
{
pes->SetVisibleValue(-1);
}
else if (!m_engine->GetShadowMappingOffscreen())
{
pes->SetVisibleValue(0);
}
else
{
pes->SetVisibleValue(m_engine->GetShadowMappingOffscreenResolution());
}
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SHADOW_MAPPING_QUALITY));
if ( pc != 0 )
{
pc->SetState(STATE_ENABLE, m_engine->GetShadowMapping());
pc->SetState(STATE_CHECK, m_engine->GetShadowMapping() && m_engine->GetShadowMappingQuality());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SHADOW));
if ( pc != 0 )
{
pc->SetState(STATE_ENABLE, !m_engine->GetShadowMapping());
pc->SetState(STATE_CHECK, !m_engine->GetShadowMapping() && m_engine->GetShadow());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GROUND));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetGroundSpot());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_DIRTY));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetDirty());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FOG));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetFog());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LENS));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetLensMode());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SKY));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetSkyMode());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_PLANET));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetPlanetMode());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LIGHT));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_engine->GetLightMode());
}
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI));
if ( pv != 0 )
{
value = m_engine->GetParticleDensity();
pv->SetValue(value);
}
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP));
if ( pv != 0 )
{
value = m_engine->GetClippingDistance();
pv->SetValue(value);
}
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL));
if ( pv != 0 )
{
value = m_engine->GetObjectDetail();
pv->SetValue(value);
}
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET));
if ( pv != 0 )
{
value = m_engine->GetGadgetQuantity();
pv->SetValue(value);
}
}
// Updates the engine function of the buttons after the setup phase.
void CScreenSetupGraphics::ChangeSetupButtons()
{
CWindow* pw;
CEditValue* pv;
CEnumSlider* pes;
float value;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI));
if ( pv != 0 )
{
value = pv->GetValue();
m_engine->SetParticleDensity(value);
}
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP));
if ( pv != 0 )
{
value = pv->GetValue();
m_engine->SetClippingDistance(value);
}
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL));
if ( pv != 0 )
{
value = pv->GetValue();
m_engine->SetObjectDetail(value);
}
pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET));
if ( pv != 0 )
{
value = pv->GetValue();
m_engine->SetGadgetQuantity(value);
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_FILTER));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
m_engine->SetTextureFilterMode(static_cast<Gfx::TexFilter>(value));
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
m_engine->SetTextureMipmapLevel(static_cast<int>(value));
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_ANISOTROPY));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
m_engine->SetTextureAnisotropyLevel(static_cast<int>(value));
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_MSAA));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
m_engine->SetMultiSample(static_cast<int>(value));
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_SHADOW_MAPPING));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
if(value == -1)
{
m_engine->SetShadowMapping(false);
}
else if(value == 0)
{
m_engine->SetShadowMapping(true);
m_engine->SetShadowMappingOffscreen(false);
}
else
{
m_engine->SetShadowMapping(true);
m_engine->SetShadowMappingOffscreen(true);
m_engine->SetShadowMappingOffscreenResolution(value);
}
}
}
// Changes the general level of quality.
void CScreenSetupGraphics::ChangeSetupQuality(int quality)
{
bool bEnable;
float value;
bEnable = true; //(quality >= 0);
m_engine->SetShadow(bEnable);
m_engine->SetGroundSpot(bEnable);
m_engine->SetDirty(bEnable);
m_engine->SetFog(bEnable);
m_engine->SetLensMode(bEnable);
m_engine->SetSkyMode(bEnable);
m_engine->SetPlanetMode(bEnable);
m_engine->SetLightMode(bEnable);
m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok?
if ( quality < 0 ) value = 0.0f;
if ( quality == 0 ) value = 1.0f;
if ( quality > 0 ) value = 2.0f;
m_engine->SetParticleDensity(value);
if ( quality < 0 ) value = 0.5f;
if ( quality == 0 ) value = 1.0f;
if ( quality > 0 ) value = 2.0f;
m_engine->SetClippingDistance(value);
if ( quality < 0 ) value = 0.0f;
if ( quality == 0 ) value = 1.0f;
if ( quality > 0 ) value = 2.0f;
m_engine->SetObjectDetail(value);
if ( quality < 0 ) value = 0.5f;
if ( quality == 0 ) value = 1.0f;
if ( quality > 0 ) value = 1.0f;
m_engine->SetGadgetQuantity(value);
if ( quality < 0 ) m_engine->SetMultiSample(1);
if ( quality == 0 ) m_engine->SetMultiSample(2);
if ( quality > 0 ) m_engine->SetMultiSample(4);
if ( quality < 0 ) { m_engine->SetTextureFilterMode(Gfx::TEX_FILTER_BILINEAR); }
if ( quality == 0 ) { m_engine->SetTextureFilterMode(Gfx::TEX_FILTER_TRILINEAR); m_engine->SetTextureMipmapLevel(4); m_engine->SetTextureAnisotropyLevel(4); }
if ( quality > 0 ) { m_engine->SetTextureFilterMode(Gfx::TEX_FILTER_TRILINEAR); m_engine->SetTextureMipmapLevel(8); m_engine->SetTextureAnisotropyLevel(8); }
if ( quality < 0 ) { m_engine->SetShadowMapping(false); m_engine->SetShadowMappingQuality(false); }
else { m_engine->SetShadowMapping(true); m_engine->SetShadowMappingQuality(true); m_engine->SetShadowMappingOffscreen(true); }
if ( quality == 0 ) m_engine->SetShadowMappingOffscreenResolution(1024);
if ( quality > 0 ) m_engine->SetShadowMappingOffscreenResolution(2048);
// TODO: first execute adapt?
//m_engine->FirstExecuteAdapt(false);
}
} // namespace Ui

View File

@ -0,0 +1,49 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "ui/screen/screen_setup.h"
class CSettings;
namespace Gfx
{
class CCamera;
}
namespace Ui
{
class CScreenSetupGraphics : public CScreenSetup
{
public:
CScreenSetupGraphics();
void SetActive() override;
void CreateInterface() override;
bool EventProcess(const Event &event) override;
protected:
void UpdateSetupButtons();
void ChangeSetupButtons();
void ChangeSetupQuality(int quality);
};
} // namespace Ui

View File

@ -0,0 +1,181 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "ui/screen/screen_setup_sound.h"
#include "common/config.h"
#include "app/app.h"
#include "common/settings.h"
#include "common/stringutils.h"
#include "graphics/engine/camera.h"
#include "ui/button.h"
#include "ui/interface.h"
#include "ui/label.h"
#include "ui/slider.h"
#include "ui/window.h"
namespace Ui
{
CScreenSetupSound::CScreenSetupSound()
{
}
void CScreenSetupSound::SetActive()
{
m_tab = PHASE_SETUPs;
}
void CScreenSetupSound::CreateInterface()
{
CWindow* pw;
CLabel* pl;
CSlider* psl;
CButton* pb;
Math::Point pos, ddim;
std::string name;
CScreenSetup::CreateInterface();
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
pos.x = ox+sx*3;
pos.y = 0.55f;
ddim.x = dim.x*4.0f;
ddim.y = 18.0f/480.0f;
psl = pw->CreateSlider(pos, ddim, 0, EVENT_INTERFACE_VOLSOUND);
psl->SetState(STATE_SHADOW);
psl->SetLimit(0.0f, MAXVOLUME);
psl->SetArrowStep(1.0f);
pos.y += ddim.y;
GetResource(RES_EVENT, EVENT_INTERFACE_VOLSOUND, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*3;
pos.y = 0.40f;
ddim.x = dim.x*4.0f;
ddim.y = 18.0f/480.0f;
psl = pw->CreateSlider(pos, ddim, 0, EVENT_INTERFACE_VOLMUSIC);
psl->SetState(STATE_SHADOW);
psl->SetLimit(0.0f, MAXVOLUME);
psl->SetArrowStep(1.0f);
pos.y += ddim.y;
GetResource(RES_EVENT, EVENT_INTERFACE_VOLMUSIC, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
ddim.x = dim.x*3;
ddim.y = dim.y*1;
pos.x = ox+sx*10;
pos.y = oy+sy*2;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_SILENT);
pb->SetState(STATE_SHADOW);
pos.x += ddim.x;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NOISY);
pb->SetState(STATE_SHADOW);
UpdateSetupButtons();
}
bool CScreenSetupSound::EventProcess(const Event &event)
{
if (!CScreenSetup::EventProcess(event)) return false;
switch( event.type )
{
case EVENT_INTERFACE_VOLSOUND:
case EVENT_INTERFACE_VOLMUSIC:
ChangeSetupButtons();
break;
case EVENT_INTERFACE_SILENT:
m_sound->SetAudioVolume(0);
m_sound->SetMusicVolume(0);
UpdateSetupButtons();
break;
case EVENT_INTERFACE_NOISY:
m_sound->SetAudioVolume(MAXVOLUME);
m_sound->SetMusicVolume(MAXVOLUME*3/4);
UpdateSetupButtons();
break;
default:
return true;
}
return false;
}
// Updates the buttons during the setup phase.
void CScreenSetupSound::UpdateSetupButtons()
{
CWindow* pw;
CSlider* ps;
float value;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND));
if ( ps != 0 )
{
value = static_cast<float>(m_sound->GetAudioVolume());
ps->SetVisibleValue(value);
}
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
if ( ps != 0 )
{
value = static_cast<float>(m_sound->GetMusicVolume());
ps->SetVisibleValue(value);
}
}
// Updates the engine function of the buttons after the setup phase.
void CScreenSetupSound::ChangeSetupButtons()
{
CWindow* pw;
CSlider* ps;
float value;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND));
if ( ps != 0 )
{
value = ps->GetVisibleValue();
m_sound->SetAudioVolume(static_cast<int>(value));
}
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
if ( ps != 0 )
{
value = ps->GetVisibleValue();
m_sound->SetMusicVolume(static_cast<int>(value));
}
}
} // namespace Ui

View File

@ -0,0 +1,48 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "ui/screen/screen_setup.h"
class CSettings;
namespace Gfx
{
class CCamera;
}
namespace Ui
{
class CScreenSetupSound : public CScreenSetup
{
public:
CScreenSetupSound();
void SetActive() override;
void CreateInterface() override;
bool EventProcess(const Event &event) override;
protected:
void UpdateSetupButtons();
void ChangeSetupButtons();
};
} // namespace Ui