Allow saving custom camera settings
This commit is contained in:
parent
0a273d8882
commit
8eb318675d
@ -64,17 +64,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="2%" width="100%" />
|
||||
|
||||
<div width="100%" height="fit" layout="horizontal-row">
|
||||
<spacer width="3%" height="100%" />
|
||||
<div proportion="1" height="fit" layout="horizontal-row" >
|
||||
<checkbox id="use_soccer_camera"/>
|
||||
<spacer width="1%" height="100%" />
|
||||
<label height="100%" text_align="left" I18N="In the ui/camera screen" text="Follow ball in soccer mode"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer width="100%" height="2%"/>
|
||||
<button id="close" text="Apply" align="center"/>
|
||||
<spacer width="100%" height="1%"/>
|
||||
|
@ -33,28 +33,28 @@
|
||||
<!-- ************ SKIN CHOICE ************ -->
|
||||
<div width="100%" height="fit" layout="horizontal-row">
|
||||
<spinner id="skinchoice" width="10f" align="center" />
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Skin" align="left"/>
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Skin"/>
|
||||
</div>
|
||||
|
||||
<spacer width="5" height="2%"/>
|
||||
|
||||
<div width="100%" height="fit" layout="horizontal-row">
|
||||
<spinner id="minimap" width="10f" align="center" />
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Minimap" align="left"/>
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Minimap"/>
|
||||
</div>
|
||||
|
||||
<spacer width="5" height="2%"/>
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<spinner id="splitscreen_method" width="10f" align="center" />
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Splitscreen Multiplayer layout" align="left"/>
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Splitscreen Multiplayer layout"/>
|
||||
</div>
|
||||
|
||||
<spacer width="5" height="2%"/>
|
||||
|
||||
<div width="100%" height="fit" layout="horizontal-row">
|
||||
<gauge id="font_size" width="10f" align="center" />
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Font size" align="left"/>
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Font size"/>
|
||||
</div>
|
||||
|
||||
<spacer width="5" height="2%"/>
|
||||
@ -62,13 +62,21 @@
|
||||
<!-- ************ GRAPHICAL EFFECTS SETTINGS ************ -->
|
||||
<div width="100%" height="fit" layout="horizontal-row">
|
||||
<spinner id="camera_preset" width="10f" align="center" />
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Camera" align="left"/>
|
||||
<label height="100%" x="0" y="0" I18N="In the ui settings" text="Camera"/>
|
||||
<spacer width="2%" height="100%" />
|
||||
<button id="custom_camera" text="Custom..." I18N="In the ui settings" align="center"/>
|
||||
</div>
|
||||
|
||||
<spacer width="5" height="2%"/>
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="follow_ball_backward_camera"/>
|
||||
<spacer width="1%" height="100%" />
|
||||
<label height="100%" I18N="In the ui settings" text="Follow ball in soccer mode for backward camera" word_wrap="true"/>
|
||||
</div>
|
||||
|
||||
<spacer width="5" height="2%"/>
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="showfps"/>
|
||||
<spacer width="1%" height="100%" />
|
||||
|
@ -963,6 +963,37 @@ namespace UserConfigParams
|
||||
&m_camera_normal,
|
||||
"Focal distance (single player)"));
|
||||
|
||||
// ---- Saved custom camera settings
|
||||
PARAM_PREFIX GroupUserConfigParam m_saved_camera_settings
|
||||
PARAM_DEFAULT( GroupUserConfigParam(
|
||||
"saved-camera-settings",
|
||||
"Saved custom camera settings for player.") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_saved_camera_distance
|
||||
PARAM_DEFAULT( FloatUserConfigParam(1.0, "distance",
|
||||
&m_saved_camera_settings,
|
||||
"Distance between kart and camera"));
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_saved_camera_forward_up_angle
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0, "forward-up-angle",
|
||||
&m_saved_camera_settings,
|
||||
"Angle between camera and plane of kart (pitch) when the camera is pointing forward"));
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_saved_camera_forward_smoothing
|
||||
PARAM_DEFAULT( BoolUserConfigParam(true, "forward-smoothing",
|
||||
&m_saved_camera_settings,
|
||||
"if true, use smoothing (forward-up-angle become relative to speed) when pointing forward"));
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_saved_camera_backward_up_angle
|
||||
PARAM_DEFAULT( FloatUserConfigParam(5, "backward-up-angle",
|
||||
&m_saved_camera_settings,
|
||||
"Angle between camera and plane of kart (pitch) when the camera is pointing backwards. This is usually larger than the forward-up-angle, since the kart itself otherwise obstricts too much of the view"));
|
||||
|
||||
PARAM_PREFIX IntUserConfigParam m_saved_camera_fov
|
||||
PARAM_DEFAULT( IntUserConfigParam(80, "fov",
|
||||
&m_saved_camera_settings,
|
||||
"Focal distance (single player)"));
|
||||
|
||||
|
||||
// camera in artist mode
|
||||
PARAM_PREFIX GroupUserConfigParam m_camera
|
||||
|
@ -42,12 +42,6 @@ CustomCameraSettingsDialog::CustomCameraSettingsDialog(const float w, const floa
|
||||
{
|
||||
m_self_destroy = false;
|
||||
loadFromFile("custom_camera_settings.stkgui");
|
||||
getWidget<SpinnerWidget>("fov")->setValue(UserConfigParams::m_camera_fov);
|
||||
getWidget<SpinnerWidget>("camera_distance")->setFloatValue(UserConfigParams::m_camera_distance);
|
||||
getWidget<SpinnerWidget>("camera_angle")->setValue(UserConfigParams::m_camera_forward_up_angle);
|
||||
getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_camera_forward_smoothing);
|
||||
getWidget<SpinnerWidget>("backward_camera_angle")->setValue(UserConfigParams::m_camera_backward_up_angle);
|
||||
// updateActivation();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -63,15 +57,14 @@ void CustomCameraSettingsDialog::beforeAddingWidgets()
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
getWidget<SpinnerWidget>("fov")->setRange(75, 115);
|
||||
getWidget<SpinnerWidget>("fov")->setValue(UserConfigParams::m_camera_fov);
|
||||
getWidget<SpinnerWidget>("fov")->setValue(UserConfigParams::m_saved_camera_fov);
|
||||
getWidget<SpinnerWidget>("camera_distance")->setRange(0 , 20, 0.1);
|
||||
getWidget<SpinnerWidget>("camera_distance")->setFloatValue(UserConfigParams::m_camera_distance);
|
||||
getWidget<SpinnerWidget>("camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_distance);
|
||||
getWidget<SpinnerWidget>("camera_angle")->setRange(0 , 45);
|
||||
getWidget<SpinnerWidget>("camera_angle")->setValue(UserConfigParams::m_camera_forward_up_angle);
|
||||
getWidget<CheckBoxWidget>("camera_smoothing")->setState(UserConfigParams::m_camera_forward_smoothing);
|
||||
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_angle")->setRange(0 , 45);
|
||||
getWidget<SpinnerWidget>("backward_camera_angle")->setValue(UserConfigParams::m_camera_backward_up_angle);
|
||||
getWidget<CheckBoxWidget>("use_soccer_camera")->setState(UserConfigParams::m_reverse_look_use_soccer_cam);
|
||||
getWidget<SpinnerWidget>("backward_camera_angle")->setValue(UserConfigParams::m_saved_camera_backward_up_angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -87,7 +80,11 @@ GUIEngine::EventPropagation CustomCameraSettingsDialog::processEvent(const std::
|
||||
UserConfigParams::m_camera_forward_up_angle = getWidget<SpinnerWidget>("camera_angle")->getValue();
|
||||
UserConfigParams::m_camera_forward_smoothing = getWidget<CheckBoxWidget>("camera_smoothing")->getState();
|
||||
UserConfigParams::m_camera_backward_up_angle = getWidget<SpinnerWidget>("backward_camera_angle")->getValue();
|
||||
UserConfigParams::m_reverse_look_use_soccer_cam = getWidget<CheckBoxWidget>("use_soccer_camera")->getState();
|
||||
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_up_angle = UserConfigParams::m_camera_backward_up_angle;
|
||||
OptionsScreenUI::getInstance()->updateCameraPresetSpinner();
|
||||
m_self_destroy = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
|
@ -310,6 +310,7 @@ void OptionsScreenUI::init()
|
||||
}
|
||||
speedrun_timer->setState( UserConfigParams::m_speedrun_mode );
|
||||
|
||||
getWidget<CheckBoxWidget>("follow_ball_backward_camera")->setState(UserConfigParams::m_reverse_look_use_soccer_cam);
|
||||
// --- select the right skin in the spinner
|
||||
bool currSkinFound = false;
|
||||
const std::string& user_skin = UserConfigParams::m_skin_file;
|
||||
@ -406,9 +407,12 @@ void OptionsScreenUI::updateCameraPresetSpinner()
|
||||
|
||||
if (!found)
|
||||
{
|
||||
getWidget("custom_camera")->setActive(true);
|
||||
camera_preset->setValue(0);
|
||||
camera_preset->m_properties[GUIEngine::PROP_MIN_VALUE] = std::to_string(0);
|
||||
}
|
||||
else
|
||||
getWidget("custom_camera")->setActive(false);
|
||||
updateCamera();
|
||||
|
||||
} // updateCameraPresetSpinner
|
||||
@ -546,15 +550,30 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
|
||||
GUIEngine::SpinnerWidget* camera_preset = getWidget<GUIEngine::SpinnerWidget>("camera_preset");
|
||||
assert( camera_preset != NULL );
|
||||
unsigned int i = camera_preset->getValue();
|
||||
if (i != 0) {
|
||||
if (i != 0)
|
||||
{
|
||||
UserConfigParams::m_camera_fov = m_camera_presets[i-1].fov;
|
||||
UserConfigParams::m_camera_distance = m_camera_presets[i-1].distance;
|
||||
UserConfigParams::m_camera_forward_up_angle = m_camera_presets[i-1].angle;
|
||||
UserConfigParams::m_camera_forward_smoothing = m_camera_presets[i-1].smoothing;
|
||||
UserConfigParams::m_camera_backward_up_angle = m_camera_presets[i-1].backward_angle;
|
||||
getWidget("custom_camera")->setActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
UserConfigParams::m_camera_fov = UserConfigParams::m_saved_camera_fov;
|
||||
UserConfigParams::m_camera_distance = UserConfigParams::m_saved_camera_distance;
|
||||
UserConfigParams::m_camera_forward_up_angle = UserConfigParams::m_saved_camera_forward_up_angle;
|
||||
UserConfigParams::m_camera_forward_smoothing = UserConfigParams::m_saved_camera_forward_smoothing;
|
||||
UserConfigParams::m_camera_backward_up_angle = UserConfigParams::m_saved_camera_backward_up_angle;
|
||||
getWidget("custom_camera")->setActive(true);
|
||||
}
|
||||
updateCamera();
|
||||
}
|
||||
else if (name == "follow_ball_backward_camera")
|
||||
{
|
||||
UserConfigParams::m_reverse_look_use_soccer_cam = getWidget<CheckBoxWidget>("follow_ball_backward_camera")->getState();
|
||||
}
|
||||
else if(name == "custom_camera")
|
||||
{
|
||||
new CustomCameraSettingsDialog(0.8f, 0.9f);
|
||||
|
Loading…
Reference in New Issue
Block a user