Few improvements of spinner and option UI ()

* few improvements of option UI

* small fix

* show the correct spinner text when not activated

* camera name for translation

* clean the code (loop camera spinner)
This commit is contained in:
riso 2020-12-25 13:29:56 -06:00 committed by GitHub
parent edcf9cb624
commit 5f6eb5e440
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 22 deletions

View File

@ -5,7 +5,7 @@
<spacer width="100%" height="3%"/>
<div width="100%" height="91%" layout="vertical-row" >
<label width="100%" I18N="In the ui/camera settings" text="Player camera"/>
<label id="camera_name" width="100%" I18N="In the ui/camera settings" text="Player camera"/>
<spacer width="5" height="1%"/>
<div width="100%" height="fit" layout="horizontal-row">

View File

@ -417,7 +417,7 @@ void SpinnerWidget::setValue(const int new_value)
std::string imagefile = file_manager->searchTexture(s);
((IGUIImage*)(m_children[1].m_element))->setImage(irr_driver->getTexture(imagefile));
}
else if (m_labels.size() > 0 && m_children.size() > 0 && !m_deactivated)
else if (m_labels.size() > 0 && m_children.size() > 0)
{
assert(new_value >= 0);
assert(new_value < (int)m_labels.size());
@ -502,15 +502,6 @@ void SpinnerWidget::setActive(bool active)
setCustomText(m_custom_text);
}
}
else
{
// Save it temporary because setValue(which is uses for update in
// this case) overwrites it
core::stringw custom_text = m_custom_text;
setText(L"-");
setValue(getValue()); // Update the display
m_custom_text = custom_text;
}
} // setActive
// -----------------------------------------------------------------------------

View File

@ -19,6 +19,7 @@
#include "config/user_config.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp"
#include "states_screens/options/options_screen_ui.hpp"
#include "utils/translation.hpp"
@ -62,6 +63,11 @@ void CustomCameraSettingsDialog::beforeAddingWidgets()
getWidget<SpinnerWidget>("backward_camera_angle")->setRange(0 , 45);
if (UserConfigParams::m_camera_present == 1) // Standard camera
{
getWidget<LabelWidget>("camera_name")->setText(_("Standard"), false);
getWidget<SpinnerWidget>("fov")->setValue(UserConfigParams::m_standard_camera_fov);
getWidget<SpinnerWidget>("camera_distance")->setFloatValue(UserConfigParams::m_standard_camera_distance);
getWidget<SpinnerWidget>("camera_angle")->setValue(UserConfigParams::m_standard_camera_forward_up_angle);
getWidget<SpinnerWidget>("backward_camera_angle")->setValue(UserConfigParams::m_standard_camera_backward_up_angle);
getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_standard_camera_forward_smoothing);
getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_standard_reverse_look_use_soccer_cam);
// Not allowed to change fov, distance, and angles. Only allow to change smoothing and follow soccer
@ -72,6 +78,11 @@ void CustomCameraSettingsDialog::beforeAddingWidgets()
}
else if (UserConfigParams::m_camera_present == 2) // Drone chase camera
{
getWidget<LabelWidget>("camera_name")->setText(_("Drone chase"), false);
getWidget<SpinnerWidget>("fov")->setValue(UserConfigParams::m_drone_camera_fov);
getWidget<SpinnerWidget>("camera_distance")->setFloatValue(UserConfigParams::m_drone_camera_distance);
getWidget<SpinnerWidget>("camera_angle")->setValue(UserConfigParams::m_drone_camera_forward_up_angle);
getWidget<SpinnerWidget>("backward_camera_angle")->setValue(UserConfigParams::m_drone_camera_backward_up_angle);
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);
// Not allowed to change fov, distance, and angles. Only allow to change smoothing and follow soccer
@ -82,6 +93,7 @@ void CustomCameraSettingsDialog::beforeAddingWidgets()
}
else // Custom camera
{
getWidget<LabelWidget>("camera_name")->setText(_("Custom"), false);
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);

View File

@ -83,6 +83,11 @@ void OptionsScreenAudio::init()
sfx->setState( UserConfigParams::m_sfx );
music->setState( UserConfigParams::m_music );
if(!UserConfigParams::m_sfx)
getWidget<SpinnerWidget>("sfx_volume")->setActive(false);
if(!UserConfigParams::m_music)
getWidget<SpinnerWidget>("music_volume")->setActive(false);
} // init
// -----------------------------------------------------------------------------
@ -155,9 +160,15 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name,
Log::info("OptionsScreenAudio", "Music is now %s", ((bool) UserConfigParams::m_music) ? "on" : "off");
if(w->getState() == false)
{
music_manager->stopMusic();
getWidget<SpinnerWidget>("music_volume")->setActive(false);
}
else
{
music_manager->startMusic();
getWidget<SpinnerWidget>("music_volume")->setActive(true);
}
}
else if(name == "sfx_enabled")
{
@ -169,6 +180,11 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name,
if (UserConfigParams::m_sfx)
{
SFXManager::get()->quickSound("horn");
getWidget<SpinnerWidget>("sfx_volume")->setActive(true);
}
else
{
getWidget<SpinnerWidget>("sfx_volume")->setActive(false);
}
}
} // eventCallback

View File

@ -150,6 +150,20 @@ void OptionsScreenUI::loadedFromFile()
font_size->m_properties[GUIEngine::PROP_MAX_VALUE] = "5";
}
// Setup camera spinner
GUIEngine::SpinnerWidget* camera_preset = getWidget<GUIEngine::SpinnerWidget>("camera_preset");
assert( camera_preset != NULL );
camera_preset->m_properties[PROP_WRAP_AROUND] = "true";
camera_preset->clearLabels();
//I18N: In the UI options, Camera setting: Custom
camera_preset->addLabel( core::stringw(_("Custom")));
//I18N: In the UI options, Camera setting: Standard
camera_preset->addLabel( core::stringw(_("Standard")));
//I18N: In the UI options, Camera setting: Drone chase
camera_preset->addLabel( core::stringw(_("Drone chase")));
camera_preset->m_properties[GUIEngine::PROP_MIN_VALUE] = "0";
camera_preset->m_properties[GUIEngine::PROP_MAX_VALUE] = "2";
updateCameraPresetSpinner();
font_size->setValueUpdatedCallback([this](SpinnerWidget* spinner)
@ -339,21 +353,11 @@ void OptionsScreenUI::init()
irr_driver->setMaxTextureSize();
}
// --- select the right camera in the spinner
GUIEngine::SpinnerWidget* camera_preset = getWidget<GUIEngine::SpinnerWidget>("camera_preset");
assert( camera_preset != NULL );
camera_preset->m_properties[PROP_WRAP_AROUND] = "true";
camera_preset->clearLabels();
//I18N: In the UI options, Camera setting: Custom
camera_preset->addLabel( core::stringw(_("Custom")));
//I18N: In the UI options, Camera setting: Standard
camera_preset->addLabel( core::stringw(_("Standard")));
//I18N: In the UI options, Camera setting: Drone chase
camera_preset->addLabel( core::stringw(_("Drone chase")));
camera_preset->m_properties[GUIEngine::PROP_MIN_VALUE] = "1";
camera_preset->m_properties[GUIEngine::PROP_MAX_VALUE] = "2";
camera_preset->setValue(UserConfigParams::m_camera_present); // use the saved camera
updateCameraPresetSpinner();
} // init