mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Added a ui_scale, and ui_scale_touch setting. The default for ui_scale is 1.3, which makes every ui element smaller when not in touchscreen mode.
This commit is contained in:
parent
b05eec6bf0
commit
e5fc8314f5
@ -190,6 +190,8 @@ window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
mouse_cursor/sensitivity=0.9
|
||||
window/size/viewport_scale=100
|
||||
window/size/ui_scale=1.2
|
||||
window/size/ui_scale_touch=1.0
|
||||
|
||||
[ess]
|
||||
|
||||
|
@ -41,6 +41,8 @@ var _settings : Dictionary = {
|
||||
},
|
||||
"ui" : {
|
||||
"touchscreen_mode" : OS.has_touchscreen_ui_hint(),
|
||||
"ui_scale" : ProjectSettings.get("display/window/size/ui_scale"),
|
||||
"ui_scale_touch" : ProjectSettings.get("display/window/size/ui_scale_touch"),
|
||||
},
|
||||
"debug" : {
|
||||
"debug_info" : false
|
||||
@ -65,6 +67,8 @@ func _ready():
|
||||
InputMap.action_erase_event(action, a)
|
||||
InputMap.action_add_event(action, nie)
|
||||
|
||||
set_stretch()
|
||||
|
||||
|
||||
func set_value(section, key, value) -> void:
|
||||
_settings[section][key] = value
|
||||
@ -140,4 +144,50 @@ func set_rendering_vsync_via_compositor(value : bool) -> void:
|
||||
ProjectSettings.set("display/window/vsync/vsync_via_compositor", value)
|
||||
|
||||
OS.vsync_via_compositor = value
|
||||
|
||||
func set_ui_touchscreen_mode(value : bool) -> void:
|
||||
set_stretch()
|
||||
|
||||
func set_ui_ui_scale(value : float) -> void:
|
||||
ProjectSettings.set("rendering/window/size/ui_scale", value)
|
||||
set_stretch()
|
||||
|
||||
func set_ui_ui_scale_touch(value : float) -> void:
|
||||
ProjectSettings.set("rendering/window/size/ui_scale_touch", value)
|
||||
set_stretch()
|
||||
|
||||
func set_stretch():
|
||||
if !loaded:
|
||||
return
|
||||
|
||||
var stretch_mode : String = ProjectSettings.get("display/window/stretch/mode")
|
||||
var stretch_aspect : String = ProjectSettings.get("display/window/stretch/aspect")
|
||||
var stretch_size : Vector2 = Vector2(ProjectSettings.get("display/window/size/width"), ProjectSettings.get("display/window/size/height"))
|
||||
var stretch_shrink : float = ProjectSettings.get("display/window/stretch/shrink")
|
||||
|
||||
var uiscale : float = 1
|
||||
|
||||
if !get_value("ui", "touchscreen_mode"):
|
||||
uiscale = get_value("ui", "ui_scale")
|
||||
else:
|
||||
uiscale = get_value("ui", "ui_scale_touch")
|
||||
|
||||
stretch_size *= uiscale
|
||||
|
||||
var sml_sm = SceneTree.STRETCH_MODE_DISABLED;
|
||||
if (stretch_mode == "2d"):
|
||||
sml_sm = SceneTree.STRETCH_MODE_2D;
|
||||
elif (stretch_mode == "viewport"):
|
||||
sml_sm = SceneTree.STRETCH_MODE_VIEWPORT;
|
||||
|
||||
var sml_aspect = SceneTree.STRETCH_ASPECT_IGNORE;
|
||||
if (stretch_aspect == "keep"):
|
||||
sml_aspect = SceneTree.STRETCH_ASPECT_KEEP;
|
||||
elif (stretch_aspect == "keep_width"):
|
||||
sml_aspect = SceneTree.STRETCH_ASPECT_KEEP_WIDTH;
|
||||
elif (stretch_aspect == "keep_height"):
|
||||
sml_aspect = SceneTree.STRETCH_ASPECT_KEEP_HEIGHT;
|
||||
elif (stretch_aspect == "expand"):
|
||||
sml_aspect = SceneTree.STRETCH_ASPECT_EXPAND;
|
||||
|
||||
get_tree().set_screen_stretch(sml_sm, sml_aspect, stretch_size, stretch_shrink)
|
||||
|
@ -2,6 +2,5 @@
|
||||
|
||||
[ext_resource path="res://ui/autoload/SettingsManager.gd" type="Script" id=1]
|
||||
|
||||
|
||||
[node name="SettingsManager" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
@ -68,10 +68,8 @@ margin_bottom = 70.0
|
||||
property_category = "rendering"
|
||||
property_name = "viewport_scale"
|
||||
property_label = "Viewport Scale"
|
||||
min_value = 20
|
||||
max_value = 100
|
||||
step = 5
|
||||
prefix = ""
|
||||
min_value = 20.0
|
||||
step = 5.0
|
||||
suffix = "%"
|
||||
|
||||
[node name="Borderless" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )]
|
||||
@ -141,6 +139,28 @@ property_category = "ui"
|
||||
property_name = "touchscreen_mode"
|
||||
property_label = "Touchscreen Mode"
|
||||
|
||||
[node name="OptionsSpinboxRow" parent="PanelContainer/VBoxContainer/TabContainer/Interface" instance=ExtResource( 8 )]
|
||||
margin_top = 58.0
|
||||
margin_bottom = 82.0
|
||||
property_category = "ui"
|
||||
property_name = "ui_scale"
|
||||
property_label = "UI Scale"
|
||||
min_value = 0.2
|
||||
max_value = 2.4
|
||||
step = 0.01
|
||||
rounded = false
|
||||
|
||||
[node name="OptionsSpinboxRow2" parent="PanelContainer/VBoxContainer/TabContainer/Interface" instance=ExtResource( 8 )]
|
||||
margin_top = 90.0
|
||||
margin_bottom = 114.0
|
||||
property_category = "ui"
|
||||
property_name = "ui_scale_touch"
|
||||
property_label = "UI Scale Touch"
|
||||
min_value = 0.2
|
||||
max_value = 2.4
|
||||
step = 0.01
|
||||
rounded = false
|
||||
|
||||
[node name="Debug" type="VBoxContainer" parent="PanelContainer/VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
|
@ -26,9 +26,10 @@ export(String) var property_name : String
|
||||
|
||||
export(String) var property_label : String
|
||||
|
||||
export(int) var min_value : int = 0
|
||||
export(int) var max_value : int = 100
|
||||
export(int) var step : int = 1
|
||||
export(float) var min_value : float = 0
|
||||
export(float) var max_value : float = 100
|
||||
export(float) var step : float = 1
|
||||
export(bool) var rounded : bool = true
|
||||
|
||||
export(String) var prefix : String = ""
|
||||
export(String) var suffix : String = ""
|
||||
@ -47,6 +48,8 @@ func _ready():
|
||||
_sb.prefix = prefix
|
||||
_sb.suffix = suffix
|
||||
|
||||
_sb.rounded = rounded
|
||||
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
|
||||
|
@ -11,7 +11,7 @@ script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
step = 0
|
||||
step = 0.0
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
margin_top = 5.0
|
||||
@ -25,5 +25,6 @@ margin_right = 527.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
step = 0.0
|
||||
rounded = true
|
||||
align = 1
|
||||
|
Loading…
Reference in New Issue
Block a user