Several UI fixes (#4484)

* Open the confirm dialog if exiting the grand prix editor with changes by escape key

* When launching the tutorial, use the last used device instead of the first keyboard

* When launching story mode, use the last used device instead of the first keyboard

* Make the kart color selection dialog more consistent with other dialogs

Includes:
* Add an icon button bar with containing actions to apply changes or to cancel them
* The kart only shows its straight frame, without animation; it is slightly smaller
* Adjust the vertical space between widgets, to try keeping the kart size larger

* Use a button bar for the video settings and custom camera settings dialog
This commit is contained in:
Richard Qian 2021-02-11 12:01:11 -06:00 committed by GitHub
parent b43b5c6201
commit a3b34e6823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 211 additions and 158 deletions

View File

@ -86,15 +86,14 @@
<spacer height="4%" width="100%" /> <spacer height="4%" width="100%" />
<div layout="horizontal-row" width="100%" proportion="1"> <buttonbar id="buttons" height="20%" width="40%" align="center">
<spacer width="25%" height="100%" /> <icon-button id="apply" width="128" height="128" icon="gui/icons/green_check.png"
<div layout="horizontal-row" proportion="1" height="fit"> I18N="In the ui/camera screen" text="Apply" align="center"/>
<button id="close" text="Apply" align="center"/> <icon-button id="reset" width="128" height="128" icon="gui/icons/restart.png"
</div> I18N="In the ui/camera screen" text="Reset" align="center"/>
<div layout="horizontal-row" proportion="1" height="fit"> <icon-button id="cancel" width="128" height="128" icon="gui/icons/main_quit.png"
<button id="reset" text="Reset" align="center"/> I18N="In the ui/camera screen" text="Cancel" align="center"/>
</div> </buttonbar>
</div>
</div> </div>
</div> </div>
</stkgui> </stkgui>

View File

@ -171,8 +171,13 @@
<label text="* Restart STK to apply new settings" width="100%" text_align="center" I18N="Video settings"/> <label text="* Restart STK to apply new settings" width="100%" text_align="center" I18N="Video settings"/>
<spacer proportion="1"/> <spacer height="4" width="10"/>
<button id="close" text="Apply" align="center"/> <buttonbar id="buttons" height="15%" width="30%" align="center">
<icon-button id="apply" width="128" height="128" icon="gui/icons/green_check.png"
I18N="Video settings" text="Apply" align="center"/>
<icon-button id="cancel" width="128" height="128" icon="gui/icons/main_quit.png"
I18N="Video settings" text="Cancel" align="center"/>
</buttonbar>
</div> </div>
</stkgui> </stkgui>

View File

@ -1,20 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<stkgui> <stkgui>
<div x="2%" y="0%" width="96%" height="95%" layout="vertical-row"> <div x="2%" y="0%" width="96%" height="95%" layout="vertical-row">
<spacer height="20" width="10"/>
<div id="kart-screen" layout="horizontal-row" width="100%" proportion="1" align="center"> <div id="kart-screen" layout="horizontal-row" width="100%" proportion="1" align="center">
<model id="model" width="100%" layout="horizontal-row" height="100%"> <model id="model" width="100%" layout="horizontal-row" height="100%">
</model> </model>
</div> </div>
<div width="100%" height="fit" text-align="left" layout="horizontal-row" > <div width="100%" height="fit" text-align="left" layout="horizontal-row" >
<spacer height="30" width="15%"/> <spacer height="10" width="15%"/>
<spinner id="toggle-slider" width="70%" min_value="0" max_value="1" wrap_around="true"/> <spinner id="toggle-slider" width="70%" min_value="0" max_value="1" wrap_around="true"/>
<spacer height="30" width="15%"/> <spacer height="20" width="15%"/>
</div> </div>
<spacer height="30" width="10"/> <spacer height="20" width="10"/>
<div height="fit" width="100%" layout="horizontal-row"> <div height="fit" width="100%" layout="horizontal-row">
<gauge id="color-slider" min_value="1" max_value="100" proportion="1" wrap_around="true"/> <gauge id="color-slider" min_value="1" max_value="100" proportion="1" wrap_around="true"/>
</div> </div>
<spacer height="30" width="10"/> <spacer height="10" width="10"/>
<button id="close" text="Apply" align="center"/> <buttonbar id="buttons" height="20%" width="30%" align="center">
<icon-button id="apply" width="128" height="128" icon="gui/icons/green_check.png"
I18N="In the kart color slider dialog" text="Apply" align="center"/>
<icon-button id="cancel" width="128" height="128" icon="gui/icons/main_quit.png"
I18N="In the kart color slider dialog" text="Cancel" align="center"/>
</buttonbar>
</div> </div>
</stkgui> </stkgui>

View File

@ -75,8 +75,8 @@ void OverWorld::enterOverWorld()
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_BEST); RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_BEST);
} }
// Use keyboard 0 by default (FIXME: let player choose?) // Use the last used device
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0); InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
// Create player and associate player with keyboard // Create player and associate player with keyboard
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(),

View File

@ -20,8 +20,10 @@
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "guiengine/widgets/check_box_widget.hpp" #include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp" #include "guiengine/widgets/spinner_widget.hpp"
#include "states_screens/options/options_screen_ui.hpp" #include "states_screens/options/options_screen_ui.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
@ -115,61 +117,72 @@ void CustomCameraSettingsDialog::beforeAddingWidgets()
GUIEngine::EventPropagation CustomCameraSettingsDialog::processEvent(const std::string& eventSource) GUIEngine::EventPropagation CustomCameraSettingsDialog::processEvent(const std::string& eventSource)
{ {
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
if (eventSource == "close") if (eventSource == "buttons")
{ {
UserConfigParams::m_camera_forward_smoothing = getWidget<CheckBoxWidget>("camera_smoothing")->getState(); const std::string& selection = getWidget<RibbonWidget>("buttons")->
UserConfigParams::m_reverse_look_use_soccer_cam = getWidget<CheckBoxWidget>("use_soccer_camera")->getState(); getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (UserConfigParams::m_camera_present == 1) // Standard camera, only smoothing and follow soccer is customizable
{
UserConfigParams::m_saved_camera_forward_smoothing = UserConfigParams::m_camera_forward_smoothing;
UserConfigParams::m_standard_reverse_look_use_soccer_cam = UserConfigParams::m_reverse_look_use_soccer_cam;
} if (selection == "apply")
else if (UserConfigParams::m_camera_present == 2) // Drone chase camera, only smoothing and follow soccer is customizable
{ {
UserConfigParams::m_drone_camera_forward_smoothing = UserConfigParams::m_camera_forward_smoothing; UserConfigParams::m_camera_forward_smoothing = getWidget<CheckBoxWidget>("camera_smoothing")->getState();
UserConfigParams::m_drone_reverse_look_use_soccer_cam = UserConfigParams::m_reverse_look_use_soccer_cam; UserConfigParams::m_reverse_look_use_soccer_cam = getWidget<CheckBoxWidget>("use_soccer_camera")->getState();
if (UserConfigParams::m_camera_present == 1) // Standard camera, only smoothing and follow soccer is customizable
{
UserConfigParams::m_saved_camera_forward_smoothing = UserConfigParams::m_camera_forward_smoothing;
UserConfigParams::m_standard_reverse_look_use_soccer_cam = UserConfigParams::m_reverse_look_use_soccer_cam;
}
else if (UserConfigParams::m_camera_present == 2) // Drone chase camera, only smoothing and follow soccer is customizable
{
UserConfigParams::m_drone_camera_forward_smoothing = UserConfigParams::m_camera_forward_smoothing;
UserConfigParams::m_drone_reverse_look_use_soccer_cam = UserConfigParams::m_reverse_look_use_soccer_cam;
}
else // Custom camera, everything is customizable
{
UserConfigParams::m_camera_fov = getWidget<SpinnerWidget>("fov")->getValue();
UserConfigParams::m_camera_distance = getWidget<SpinnerWidget>("camera_distance")->getFloatValue();
UserConfigParams::m_camera_forward_up_angle = getWidget<SpinnerWidget>("camera_angle")->getValue();
UserConfigParams::m_camera_backward_distance = getWidget<SpinnerWidget>("backward_camera_distance")->getFloatValue();
UserConfigParams::m_camera_backward_up_angle = getWidget<SpinnerWidget>("backward_camera_angle")->getValue();
UserConfigParams::m_saved_camera_fov = UserConfigParams::m_camera_fov;
UserConfigParams::m_saved_camera_distance = UserConfigParams::m_camera_distance;
UserConfigParams::m_saved_camera_forward_up_angle = UserConfigParams::m_camera_forward_up_angle;
UserConfigParams::m_saved_camera_forward_smoothing = UserConfigParams::m_camera_forward_smoothing;
UserConfigParams::m_saved_camera_backward_distance = UserConfigParams::m_camera_backward_distance;
UserConfigParams::m_saved_camera_backward_up_angle = UserConfigParams::m_camera_backward_up_angle;
UserConfigParams::m_saved_reverse_look_use_soccer_cam = UserConfigParams::m_reverse_look_use_soccer_cam;
}
OptionsScreenUI::getInstance()->updateCameraPresetSpinner();
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
} }
else // Custom camera, everything is customizable else if (selection == "reset") // discard all the changes
{ {
UserConfigParams::m_camera_fov = getWidget<SpinnerWidget>("fov")->getValue(); if (UserConfigParams::m_camera_present == 1) // Standard camera
UserConfigParams::m_camera_distance = getWidget<SpinnerWidget>("camera_distance")->getFloatValue(); {
UserConfigParams::m_camera_forward_up_angle = getWidget<SpinnerWidget>("camera_angle")->getValue(); getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_standard_camera_forward_smoothing);
UserConfigParams::m_camera_backward_distance = getWidget<SpinnerWidget>("backward_camera_distance")->getFloatValue(); getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_standard_reverse_look_use_soccer_cam);
UserConfigParams::m_camera_backward_up_angle = getWidget<SpinnerWidget>("backward_camera_angle")->getValue(); }
UserConfigParams::m_saved_camera_fov = UserConfigParams::m_camera_fov; else if (UserConfigParams::m_camera_present == 2) // Drone chase camera
UserConfigParams::m_saved_camera_distance = UserConfigParams::m_camera_distance; {
UserConfigParams::m_saved_camera_forward_up_angle = UserConfigParams::m_camera_forward_up_angle; getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_drone_camera_forward_smoothing);
UserConfigParams::m_saved_camera_forward_smoothing = UserConfigParams::m_camera_forward_smoothing; getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_drone_reverse_look_use_soccer_cam);
UserConfigParams::m_saved_camera_backward_distance = UserConfigParams::m_camera_backward_distance; }
UserConfigParams::m_saved_camera_backward_up_angle = UserConfigParams::m_camera_backward_up_angle; else // Custom camera
UserConfigParams::m_saved_reverse_look_use_soccer_cam = UserConfigParams::m_reverse_look_use_soccer_cam; {
getWidget<SpinnerWidget>("fov")->setValue(UserConfigParams::m_saved_camera_fov);
getWidget<SpinnerWidget>("camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_distance);
getWidget<SpinnerWidget>("camera_angle")->setValue(UserConfigParams::m_saved_camera_forward_up_angle);
getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_saved_camera_forward_smoothing);
getWidget<SpinnerWidget>("backward_camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_backward_distance);
getWidget<SpinnerWidget>("backward_camera_angle")->setValue(UserConfigParams::m_saved_camera_backward_up_angle);
getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_saved_reverse_look_use_soccer_cam);
}
} }
OptionsScreenUI::getInstance()->updateCameraPresetSpinner(); else if (selection == "cancel")
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "reset") // discard all the changes
{
if (UserConfigParams::m_camera_present == 1) // Standard camera
{ {
getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_standard_camera_forward_smoothing); ModalDialog::dismiss();
getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_standard_reverse_look_use_soccer_cam); return GUIEngine::EVENT_BLOCK;
}
else if (UserConfigParams::m_camera_present == 2) // Drone chase camera
{
getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_drone_camera_forward_smoothing);
getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_drone_reverse_look_use_soccer_cam);
}
else // Custom camera
{
getWidget<SpinnerWidget>("fov")->setValue(UserConfigParams::m_saved_camera_fov);
getWidget<SpinnerWidget>("camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_distance);
getWidget<SpinnerWidget>("camera_angle")->setValue(UserConfigParams::m_saved_camera_forward_up_angle);
getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_saved_camera_forward_smoothing);
getWidget<SpinnerWidget>("backward_camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_backward_distance);
getWidget<SpinnerWidget>("backward_camera_angle")->setValue(UserConfigParams::m_saved_camera_backward_up_angle);
getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_saved_reverse_look_use_soccer_cam);
} }
} }
#endif #endif

View File

@ -19,8 +19,10 @@
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "guiengine/widgets/check_box_widget.hpp" #include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp" #include "guiengine/widgets/spinner_widget.hpp"
#include "states_screens/options/options_screen_video.hpp" #include "states_screens/options/options_screen_video.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
@ -116,70 +118,81 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::string& eventSource) GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::string& eventSource)
{ {
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
if (eventSource == "close") if (eventSource == "buttons")
{ {
bool advanced_pipeline = getWidget<CheckBoxWidget>("dynamiclight")->getState(); const std::string& selection = getWidget<RibbonWidget>("buttons")->
UserConfigParams::m_dynamic_lights = advanced_pipeline; getSelectionIDString(PLAYER_ID_GAME_MASTER);
UserConfigParams::m_dof = if (selection == "apply")
advanced_pipeline && getWidget<CheckBoxWidget>("dof")->getState();
UserConfigParams::m_motionblur =
advanced_pipeline && getWidget<CheckBoxWidget>("motionblur")->getState();
if (advanced_pipeline)
{ {
UserConfigParams::m_shadows_resolution = bool advanced_pipeline = getWidget<CheckBoxWidget>("dynamiclight")->getState();
getWidget<SpinnerWidget>("shadows")->getValue() * 512; UserConfigParams::m_dynamic_lights = advanced_pipeline;
UserConfigParams::m_dof =
advanced_pipeline && getWidget<CheckBoxWidget>("dof")->getState();
UserConfigParams::m_motionblur =
advanced_pipeline && getWidget<CheckBoxWidget>("motionblur")->getState();
if (advanced_pipeline)
{
UserConfigParams::m_shadows_resolution =
getWidget<SpinnerWidget>("shadows")->getValue() * 512;
}
else
{
UserConfigParams::m_shadows_resolution = 0;
}
UserConfigParams::m_mlaa =
advanced_pipeline && getWidget<CheckBoxWidget>("mlaa")->getState();
UserConfigParams::m_ssao =
advanced_pipeline && getWidget<CheckBoxWidget>("ssao")->getState();
UserConfigParams::m_light_shaft =
advanced_pipeline && getWidget<CheckBoxWidget>("lightshaft")->getState();
UserConfigParams::m_degraded_IBL =
!advanced_pipeline || !getWidget<CheckBoxWidget>("ibl")->getState();
UserConfigParams::m_glow =
advanced_pipeline && getWidget<CheckBoxWidget>("glow")->getState();
UserConfigParams::m_bloom =
advanced_pipeline && getWidget<CheckBoxWidget>("bloom")->getState();
UserConfigParams::m_light_scatter =
advanced_pipeline && getWidget<CheckBoxWidget>("lightscattering")->getState();
UserConfigParams::m_texture_compression =
getWidget<CheckBoxWidget>("texture_compression")->getState();
UserConfigParams::m_particles_effects =
getWidget<SpinnerWidget>("particles_effects")->getValue();
UserConfigParams::m_animated_characters =
getWidget<CheckBoxWidget>("animated_characters")->getState();
const int val =
getWidget<SpinnerWidget>("geometry_detail")->getValue();
UserConfigParams::m_geometry_level = val == 2 ? 0 : val == 0 ? 2 : 1;
OptionsScreenVideo::setImageQuality(getWidget<SpinnerWidget>
("image_quality")->getValue());
user_config->saveConfig();
ModalDialog::dismiss();
OptionsScreenVideo::getInstance()->updateGfxSlider();
OptionsScreenVideo::getInstance()->updateBlurSlider();
return GUIEngine::EVENT_BLOCK;
} }
else else if (selection == "cancel")
{ {
UserConfigParams::m_shadows_resolution = 0; ModalDialog::dismiss();
return GUIEngine::EVENT_BLOCK;
} }
UserConfigParams::m_mlaa =
advanced_pipeline && getWidget<CheckBoxWidget>("mlaa")->getState();
UserConfigParams::m_ssao =
advanced_pipeline && getWidget<CheckBoxWidget>("ssao")->getState();
UserConfigParams::m_light_shaft =
advanced_pipeline && getWidget<CheckBoxWidget>("lightshaft")->getState();
UserConfigParams::m_degraded_IBL =
!advanced_pipeline || !getWidget<CheckBoxWidget>("ibl")->getState();
UserConfigParams::m_glow =
advanced_pipeline && getWidget<CheckBoxWidget>("glow")->getState();
UserConfigParams::m_bloom =
advanced_pipeline && getWidget<CheckBoxWidget>("bloom")->getState();
UserConfigParams::m_light_scatter =
advanced_pipeline && getWidget<CheckBoxWidget>("lightscattering")->getState();
UserConfigParams::m_texture_compression =
getWidget<CheckBoxWidget>("texture_compression")->getState();
UserConfigParams::m_particles_effects =
getWidget<SpinnerWidget>("particles_effects")->getValue();
UserConfigParams::m_animated_characters =
getWidget<CheckBoxWidget>("animated_characters")->getState();
const int val =
getWidget<SpinnerWidget>("geometry_detail")->getValue();
UserConfigParams::m_geometry_level = val == 2 ? 0 : val == 0 ? 2 : 1;
OptionsScreenVideo::setImageQuality(getWidget<SpinnerWidget>
("image_quality")->getValue());
user_config->saveConfig();
ModalDialog::dismiss();
OptionsScreenVideo::getInstance()->updateGfxSlider();
OptionsScreenVideo::getInstance()->updateBlurSlider();
return GUIEngine::EVENT_BLOCK;
} }
else if (eventSource == "dynamiclight") else if (eventSource == "dynamiclight")
{ {

View File

@ -28,6 +28,7 @@
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/model_view_widget.hpp" #include "guiengine/widgets/model_view_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp" #include "guiengine/widgets/spinner_widget.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
@ -51,6 +52,8 @@ KartColorSliderDialog::KartColorSliderDialog(PlayerProfile* pp)
m_toggle_slider->addLabel(original_color); m_toggle_slider->addLabel(original_color);
m_toggle_slider->addLabel(choose_color); m_toggle_slider->addLabel(choose_color);
m_buttons_widget = getWidget<RibbonWidget>("buttons");
if (m_player_profile->getDefaultKartColor() != 0.0f) if (m_player_profile->getDefaultKartColor() != 0.0f)
{ {
m_toggle_slider->setValue(1); m_toggle_slider->setValue(1);
@ -111,26 +114,8 @@ void KartColorSliderDialog::beforeAddingWidgets()
model_location.setScale(core::vector3df(scale, scale, scale)); model_location.setScale(core::vector3df(scale, scale, scale));
// Add the kart model (including wheels and speed weight objects) // Add the kart model (including wheels and speed weight objects)
const bool has_win_anime =
(((kart_model.getFrame(KartModel::AF_WIN_LOOP_START) > -1 ||
kart_model.getFrame(KartModel::AF_WIN_START) > -1) &&
kart_model.getFrame(KartModel::AF_WIN_END) > -1) ||
(kart_model.getFrame(KartModel::AF_SELECTION_START) > -1 &&
kart_model.getFrame(KartModel::AF_SELECTION_END) > -1));
m_model_view->addModel(kart_model.getModel(), model_location, m_model_view->addModel(kart_model.getModel(), model_location,
has_win_anime ? kart_model.getBaseFrame(), kart_model.getBaseFrame());
kart_model.getFrame(KartModel::AF_SELECTION_START) > -1 ?
kart_model.getFrame(KartModel::AF_SELECTION_START) :
kart_model.getFrame(KartModel::AF_WIN_LOOP_START) > -1 ?
kart_model.getFrame(KartModel::AF_WIN_LOOP_START) :
kart_model.getFrame(KartModel::AF_WIN_START) :
kart_model.getBaseFrame(),
has_win_anime ?
kart_model.getFrame(KartModel::AF_SELECTION_END) > -1 ?
kart_model.getFrame(KartModel::AF_SELECTION_END) :
kart_model.getFrame(KartModel::AF_WIN_END) :
kart_model.getBaseFrame(),
kart_model.getAnimationSpeed());
model_location.setScale(core::vector3df(1.0f, 1.0f, 1.0f)); model_location.setScale(core::vector3df(1.0f, 1.0f, 1.0f));
for (unsigned i = 0; i < 4; i++) for (unsigned i = 0; i < 4; i++)
@ -191,14 +176,25 @@ GUIEngine::EventPropagation
m_model_view->getModelViewRenderInfo()->setHue(float( m_model_view->getModelViewRenderInfo()->setHue(float(
m_color_slider->getValue()) / 100.0f); m_color_slider->getValue()) / 100.0f);
} }
else if (eventSource == "close") else if (eventSource == "buttons")
{ {
float color = 0.0f; const std::string& selection = m_buttons_widget->
if (m_toggle_slider->getValue() == 1) getSelectionIDString(PLAYER_ID_GAME_MASTER);
color = float(m_color_slider->getValue()) / 100.0f;
m_player_profile->setDefaultKartColor(color); if (selection == "apply")
ModalDialog::dismiss(); {
return GUIEngine::EVENT_BLOCK; float color = 0.0f;
if (m_toggle_slider->getValue() == 1)
color = float(m_color_slider->getValue()) / 100.0f;
m_player_profile->setDefaultKartColor(color);
ModalDialog::dismiss();
return GUIEngine::EVENT_BLOCK;
}
else if (selection == "cancel")
{
ModalDialog::dismiss();
return GUIEngine::EVENT_BLOCK;
}
} }
return GUIEngine::EVENT_LET; return GUIEngine::EVENT_LET;
} // processEvent } // processEvent

View File

@ -27,6 +27,7 @@ namespace GUIEngine
{ {
class CheckBoxWidget; class CheckBoxWidget;
class ModelViewWidget; class ModelViewWidget;
class RibbonWidget;
class SpinnerWidget; class SpinnerWidget;
} }
@ -44,6 +45,8 @@ private:
GUIEngine::SpinnerWidget* m_color_slider; GUIEngine::SpinnerWidget* m_color_slider;
GUIEngine::RibbonWidget* m_buttons_widget;
void toggleSlider(); void toggleSlider();
public: public:
KartColorSliderDialog(PlayerProfile* pp); KartColorSliderDialog(PlayerProfile* pp);

View File

@ -372,3 +372,20 @@ void EditGPScreen::enableButtons()
edit_button->setActive(m_selected >= 0); edit_button->setActive(m_selected >= 0);
remove_button->setActive(m_selected >= 0); remove_button->setActive(m_selected >= 0);
} // enableButtons } // enableButtons
bool EditGPScreen::onEscapePressed()
{
if (m_modified)
{
m_action = "back";
new MessageDialog(
_("Do you want to save your changes?"),
MessageDialog::MESSAGE_DIALOG_CONFIRM,
this, false);
}
else
{
back();
}
return false;
}

View File

@ -79,7 +79,10 @@ public:
/** \brief implement callback from parent class GUIEngine::Screen */ /** \brief implement callback from parent class GUIEngine::Screen */
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
const int playerID) OVERRIDE; const int playerID) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual bool onEscapePressed() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */ /** \brief implement callback from parent class GUIEngine::Screen */
virtual void beforeAddingWidget() OVERRIDE; virtual void beforeAddingWidget() OVERRIDE;

View File

@ -277,12 +277,11 @@ void MainMenuScreen::startTutorial()
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY); RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
RaceManager::get()->setReverseTrack(false); RaceManager::get()->setReverseTrack(false);
// Use keyboard 0 by default (FIXME: let player choose?) // Use the last used device
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0); InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
// Create player and associate player with keyboard // Create player and associate player with device
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), device);
device);
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL) if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
{ {
@ -292,8 +291,7 @@ void MainMenuScreen::startTutorial()
} }
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart); RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices // ASSIGN should make sure that only input from assigned devices is read
// is read.
input_manager->getDeviceManager()->setAssignMode(ASSIGN); input_manager->getDeviceManager()->setAssignMode(ASSIGN);
input_manager->getDeviceManager() input_manager->getDeviceManager()
->setSinglePlayer( StateManager::get()->getActivePlayer(0) ); ->setSinglePlayer( StateManager::get()->getActivePlayer(0) );