touch screen toggle, always options !

fullscreen & borderless option simplified
splash drawn on top of touch controls
save options for view and touch controls
This commit is contained in:
Harmony Honey Monroe 2025-03-03 15:30:35 -05:00
parent d5259f7ad9
commit bddb9123e8
8 changed files with 198 additions and 238 deletions

View file

@ -80,6 +80,7 @@ var last_palette = -1
var time_elapsed := 0
var auto_save_clock := 0
var auto_save_time := 1800
var window_option := 0 setget set_window_option
func _ready():
print("Shared._ready(): ")
@ -94,7 +95,7 @@ func _ready():
# scale window
window_scale = floor(OS.get_screen_size().x / get_viewport().size.x)
window_scale = max(1, floor(window_scale * 0.9))
set_window_scale()
#set_window_scale()
# lower volume
for i in [1, 2]:
@ -317,11 +318,23 @@ func load_keys(path := keys_path):
for e in r.dict[a]:
InputMap.action_add_event(a, e)
func set_window_option(arg := window_option):
window_option = clamp(arg, 0, 4)
OS.window_borderless = window_option == 1 or window_option == 2
OS.window_fullscreen = window_option == 3
if window_option == 2:
OS.window_size = OS.get_screen_size()
OS.set_window_position(Vector2.ZERO if window_option == 2 else (OS.get_screen_size() * 0.5 - OS.get_window_size() * 0.5))
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE if window_option < 3 else Input.MOUSE_MODE_HIDDEN
func save_options(path := options_path):
var data = {}
data["sfx"] = bus_volume[1]
data["music"] = bus_volume[2]
data["fullscreen"] = int(OS.window_fullscreen)
data["ost"] = bus_volume[2]
data["touch"] = int(TouchScreen.is_stay)
data["full"] = int(OS.window_fullscreen)
data["view"] = int(window_option)
data["time"] = time_elapsed
print("save_options, path: ", path, " time: ", time_elapsed)
@ -337,12 +350,16 @@ func load_options(path := options_path):
var v = int(dict["sfx"])
bus_volume[1] = v
set_bus_volume(1, v)
if dict.has("music"):
var v = int(dict["music"])
if dict.has("ost"):
var v = int(dict["ost"])
bus_volume[2] = v
set_bus_volume(2, v)
if dict.has("fullscreen"):
set_fullscreen(bool(dict["fullscreen"]))
if dict.has("full"):
set_fullscreen(bool(dict["full"]))
if dict.has("touch"):
TouchScreen.is_stay = bool(dict["touch"])
if dict.has("view"):
self.window_option = int(dict["view"])
if dict.has("time"):
time_elapsed = abs(int(dict["time"]))

View file

@ -9,18 +9,19 @@ onready var buttons := [$Control/HBoxRight/C/Control/Button, $Control/HBoxRight/
onready var btns := $Control/DPad/Buttons.get_children()
onready var actions := InputMap.get_actions()
export var is_stay := false
func _ready():
connect("visibility_changed", self, "vis")
yield(get_tree(), "idle_frame")
visible = (OS.has_touchscreen_ui_hint() and OS.get_name() == "HTML5") or OS.get_name() == "Android"
vis()
func _input(event):
if event is InputEventScreenTouch or event is InputEventScreenDrag:
visible = true
elif event is InputEventKey or event is InputEventJoypadButton or event is InputEventJoypadMotion:
visible = false
visible = is_stay
func vis():
if is_instance_valid(UI.keys_node):

View file

@ -56,7 +56,7 @@ func make_list(arg):
list_node = arg
list = []
for i in arg.get_children():
if !i.is_in_group("no_item"):
if !i.is_in_group("no_item") and i.visible:
list.append(i)
func menu_input(event):

View file

@ -1,20 +0,0 @@
extends CanvasItem
onready var fill = $Box/Fill
var is_selected = false
func _ready():
fill.visible = OS.window_borderless
func select():
is_selected = true
func deselect():
is_selected = false
func _input(event):
if is_selected and event.is_action_pressed("ui_yes"):
var is_full = OS.window_borderless
OS.window_borderless = !is_full
Audio.play("menu_delete", 0.5, 1.5)
fill.visible = !is_full

View file

@ -1,27 +1,19 @@
extends CanvasItem
onready var fill = $Box/Fill
var is_selected = false
onready var label := $Label2
var cursor = 0
var text = ["windowed", "win no border", "full no border", "fullscreen"]
func _ready():
fill.visible = OS.window_fullscreen
yield(get_tree(), "idle_frame")
cursor = Shared.window_option
label.text = text[cursor]
func select():
is_selected = true
func act():
scroll()
func deselect():
is_selected = false
# HTML5 fullscreen fix
func _input(event):
if is_selected and event.is_action_pressed("ui_yes"):
var is_full = OS.window_fullscreen
Shared.set_fullscreen(!is_full)
#OS.window_fullscreen = !is_full
Shared.set_window_scale()
Audio.play("menu_pause", 0.7, 1.3)
fill.visible = !is_full
if !is_full:
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
func scroll(arg := 1):
cursor = wrapi(cursor + arg, 0, 4)
label.text = text[cursor]
Shared.window_option = cursor
Audio.play("menu_pause", 0.7, 1.3)

View file

@ -7,7 +7,7 @@
[ext_resource path="res://media/audio/sfx/btn0.wav" type="AudioStream" id=5]
[ext_resource path="res://media/font/QuinqueFive.ttf" type="DynamicFontData" id=6]
[ext_resource path="res://media/font/ThaleahFat.ttf" type="DynamicFontData" id=7]
[ext_resource path="res://src/menu/options/Borderless.gd" type="Script" id=8]
[ext_resource path="res://media/image/tinyArrow.png" type="Texture" id=9]
[ext_resource path="res://src/menu/options/Fullscreen.gd" type="Script" id=20]
[ext_resource path="res://src/menu/options/WindowSize.gd" type="Script" id=21]
[ext_resource path="res://src/menu/options/Touch.gd" type="Script" id=22]
@ -30,7 +30,7 @@ pause_mode = 2
layer = 30
script = ExtResource( 1 )
parent_path = NodePath(".")
list_path = NodePath("Center/Control/MenuItems")
list_path = NodePath("Center/Control/CenterContainer/MenuItems")
cursor_path = NodePath("Center/Control/Cursor")
cursor_expand = Vector2( 4, 4 )
is_audio_scroll = true
@ -63,178 +63,190 @@ margin_bottom = 35.0
script = ExtResource( 4 )
color_blink = PoolColorArray( 0, 0, 1, 1, 0, 0.482353, 1, 1 )
[node name="Header" type="Label" parent="Center/Control"]
margin_top = 7.0
margin_right = 228.0
margin_bottom = 20.0
[node name="CenterContainer" type="CenterContainer" parent="Center/Control"]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="MenuItems" type="VBoxContainer" parent="Center/Control/CenterContainer"]
margin_left = 53.0
margin_top = 11.0
margin_right = 175.0
margin_bottom = 116.0
rect_min_size = Vector2( 122, 0 )
alignment = 1
[node name="Header" type="Label" parent="Center/Control/CenterContainer/MenuItems" groups=["no_item"]]
margin_right = 122.0
margin_bottom = 12.0
rect_min_size = Vector2( 0, 12 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_as_outline = 1
custom_fonts/font = SubResource( 4 )
text = "OPTIONS"
align = 1
[node name="MenuItems" type="VBoxContainer" parent="Center/Control"]
margin_left = 58.0
margin_top = 21.0
margin_right = 174.0
margin_bottom = 113.0
alignment = 1
[node name="Keyboard" type="HBoxContainer" parent="Center/Control/MenuItems"]
margin_right = 116.0
margin_bottom = 8.0
[node name="Keyboard" type="HBoxContainer" parent="Center/Control/CenterContainer/MenuItems"]
margin_top = 16.0
margin_right = 122.0
margin_bottom = 24.0
rect_min_size = Vector2( 0, 8 )
script = ExtResource( 3 )
[node name="Label" type="Label" parent="Center/Control/MenuItems/Keyboard"]
[node name="Label" type="Label" parent="Center/Control/CenterContainer/MenuItems/Keyboard"]
margin_top = 1.0
margin_right = 84.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "Keyboard Setup"
[node name="Spacer" type="Control" parent="Center/Control/MenuItems/Keyboard"]
[node name="Spacer" type="Control" parent="Center/Control/CenterContainer/MenuItems/Keyboard"]
margin_left = 88.0
margin_right = 104.0
margin_right = 110.0
margin_bottom = 8.0
size_flags_horizontal = 3
[node name="Spacer2" type="Control" parent="Center/Control/MenuItems/Keyboard"]
margin_left = 108.0
margin_right = 116.0
[node name="Spacer2" type="Control" parent="Center/Control/CenterContainer/MenuItems/Keyboard"]
margin_left = 114.0
margin_right = 122.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 0 )
[node name="Gamepad" type="HBoxContainer" parent="Center/Control/MenuItems"]
margin_top = 12.0
margin_right = 116.0
margin_bottom = 20.0
[node name="Gamepad" type="HBoxContainer" parent="Center/Control/CenterContainer/MenuItems"]
margin_top = 28.0
margin_right = 122.0
margin_bottom = 36.0
rect_min_size = Vector2( 0, 8 )
script = ExtResource( 3 )
is_gamepad = true
[node name="Label" type="Label" parent="Center/Control/MenuItems/Gamepad"]
[node name="Label" type="Label" parent="Center/Control/CenterContainer/MenuItems/Gamepad"]
margin_top = 1.0
margin_right = 78.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "gamepad Setup"
[node name="Spacer" type="Control" parent="Center/Control/MenuItems/Gamepad"]
[node name="Spacer" type="Control" parent="Center/Control/CenterContainer/MenuItems/Gamepad"]
margin_left = 82.0
margin_right = 104.0
margin_right = 110.0
margin_bottom = 8.0
size_flags_horizontal = 3
[node name="Spacer2" type="Control" parent="Center/Control/MenuItems/Gamepad"]
margin_left = 108.0
margin_right = 116.0
[node name="Spacer2" type="Control" parent="Center/Control/CenterContainer/MenuItems/Gamepad"]
margin_left = 114.0
margin_right = 122.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 0 )
[node name="Sounds" parent="Center/Control/MenuItems" instance=ExtResource( 2 )]
margin_top = 24.0
margin_right = 116.0
margin_bottom = 32.0
[node name="Sounds" parent="Center/Control/CenterContainer/MenuItems" instance=ExtResource( 2 )]
margin_top = 40.0
margin_right = 122.0
margin_bottom = 48.0
[node name="Music" parent="Center/Control/MenuItems" instance=ExtResource( 2 )]
margin_top = 36.0
margin_right = 116.0
margin_bottom = 44.0
[node name="Music" parent="Center/Control/CenterContainer/MenuItems" instance=ExtResource( 2 )]
margin_top = 52.0
margin_right = 122.0
margin_bottom = 60.0
bus = 2
[node name="Label" parent="Center/Control/MenuItems/Music" index="0"]
[node name="Label" parent="Center/Control/CenterContainer/MenuItems/Music" index="0"]
margin_right = 30.0
text = "Music"
[node name="Spacer" parent="Center/Control/MenuItems/Music" index="1"]
[node name="Spacer" parent="Center/Control/CenterContainer/MenuItems/Music" index="1"]
margin_left = 32.0
margin_right = 65.0
margin_right = 71.0
[node name="Arrow" parent="Center/Control/MenuItems/Music" index="2"]
margin_left = 67.0
margin_right = 70.0
[node name="Arrow" parent="Center/Control/CenterContainer/MenuItems/Music" index="2"]
margin_left = 73.0
margin_right = 76.0
[node name="Meter" parent="Center/Control/MenuItems/Music" index="3"]
margin_left = 72.0
margin_right = 111.0
[node name="Meter" parent="Center/Control/CenterContainer/MenuItems/Music" index="3"]
margin_left = 78.0
margin_right = 117.0
[node name="Arrow2" parent="Center/Control/MenuItems/Music" index="4"]
margin_left = 113.0
margin_right = 116.0
[node name="Arrow2" parent="Center/Control/CenterContainer/MenuItems/Music" index="4"]
margin_left = 119.0
margin_right = 122.0
[node name="AudioStreamPlayer" parent="Center/Control/MenuItems/Music" index="5"]
[node name="AudioStreamPlayer" parent="Center/Control/CenterContainer/MenuItems/Music" index="5"]
stream = ExtResource( 5 )
bus = "Music"
[node name="Fullscreen" type="HBoxContainer" parent="Center/Control/MenuItems"]
margin_top = 48.0
margin_right = 116.0
margin_bottom = 56.0
[node name="View" type="HBoxContainer" parent="Center/Control/CenterContainer/MenuItems"]
margin_top = 64.0
margin_right = 122.0
margin_bottom = 72.0
rect_min_size = Vector2( 116, 8 )
custom_constants/separation = 2
script = ExtResource( 20 )
[node name="Label" type="Label" parent="Center/Control/MenuItems/Fullscreen"]
[node name="Label" type="Label" parent="Center/Control/CenterContainer/MenuItems/View"]
margin_top = 1.0
margin_right = 60.0
margin_right = 24.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "Fullscreen"
text = "view"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Spacer" type="Control" parent="Center/Control/MenuItems/Fullscreen"]
margin_left = 64.0
margin_right = 92.0
[node name="Spacer" type="Control" parent="Center/Control/CenterContainer/MenuItems/View"]
margin_left = 26.0
margin_right = 26.0
margin_bottom = 8.0
size_flags_horizontal = 3
[node name="Box" type="ColorRect" parent="Center/Control/MenuItems/Fullscreen"]
margin_left = 96.0
margin_right = 104.0
[node name="Arrow" type="Control" parent="Center/Control/CenterContainer/MenuItems/View"]
margin_left = 28.0
margin_right = 31.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 8 )
rect_min_size = Vector2( 3, 0 )
[node name="Back" type="ColorRect" parent="Center/Control/MenuItems/Fullscreen/Box"]
margin_left = 1.0
[node name="Sprite" type="Sprite" parent="Center/Control/CenterContainer/MenuItems/View/Arrow"]
position = Vector2( 2, 4 )
texture = ExtResource( 9 )
[node name="Label2" type="Label" parent="Center/Control/CenterContainer/MenuItems/View"]
margin_left = 33.0
margin_top = 1.0
margin_right = 7.0
margin_bottom = 7.0
color = Color( 0, 0, 0, 1 )
[node name="Fill" type="ColorRect" parent="Center/Control/MenuItems/Fullscreen/Box"]
margin_left = 2.0
margin_top = 2.0
margin_right = 6.0
margin_right = 117.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "full no border"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Spacer2" type="Control" parent="Center/Control/MenuItems/Fullscreen"]
margin_left = 108.0
margin_right = 116.0
[node name="Arrow2" type="Control" parent="Center/Control/CenterContainer/MenuItems/View"]
margin_left = 119.0
margin_right = 122.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 0 )
rect_min_size = Vector2( 3, 0 )
[node name="WindowSize" type="HBoxContainer" parent="Center/Control/MenuItems"]
margin_top = 60.0
margin_right = 116.0
margin_bottom = 68.0
[node name="Sprite" type="Sprite" parent="Center/Control/CenterContainer/MenuItems/View/Arrow2"]
position = Vector2( 1, 4 )
texture = ExtResource( 9 )
flip_h = true
[node name="WindowSize" type="HBoxContainer" parent="Center/Control/CenterContainer/MenuItems"]
margin_top = 76.0
margin_right = 122.0
margin_bottom = 84.0
rect_min_size = Vector2( 0, 8 )
script = ExtResource( 21 )
[node name="Label" type="Label" parent="Center/Control/MenuItems/WindowSize"]
[node name="Label" type="Label" parent="Center/Control/CenterContainer/MenuItems/WindowSize"]
margin_top = 1.0
margin_right = 36.0
margin_right = 24.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "Window"
text = "Size"
[node name="Scale" type="Label" parent="Center/Control/MenuItems/WindowSize"]
margin_left = 40.0
[node name="Scale" type="Label" parent="Center/Control/CenterContainer/MenuItems/WindowSize"]
margin_left = 28.0
margin_top = 1.0
margin_right = 58.0
margin_right = 64.0
margin_bottom = 6.0
size_flags_horizontal = 3
custom_fonts/font = SubResource( 2 )
@ -244,121 +256,77 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Resolution" type="Label" parent="Center/Control/MenuItems/WindowSize"]
margin_left = 62.0
[node name="Resolution" type="Label" parent="Center/Control/CenterContainer/MenuItems/WindowSize"]
margin_left = 68.0
margin_top = 1.0
margin_right = 116.0
margin_right = 122.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "228 x 128"
align = 1
[node name="Borderless" type="HBoxContainer" parent="Center/Control/MenuItems"]
margin_top = 72.0
margin_right = 116.0
margin_bottom = 80.0
script = ExtResource( 8 )
[node name="Label" type="Label" parent="Center/Control/MenuItems/Borderless"]
margin_top = 1.0
margin_right = 60.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "Borderless"
[node name="Spacer" type="Control" parent="Center/Control/MenuItems/Borderless"]
margin_left = 64.0
margin_right = 92.0
margin_bottom = 8.0
size_flags_horizontal = 3
[node name="Box" type="ColorRect" parent="Center/Control/MenuItems/Borderless"]
margin_left = 96.0
margin_right = 104.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 8 )
[node name="Back" type="ColorRect" parent="Center/Control/MenuItems/Borderless/Box"]
margin_left = 1.0
margin_top = 1.0
margin_right = 7.0
margin_bottom = 7.0
color = Color( 0, 0, 0, 1 )
[node name="Fill" type="ColorRect" parent="Center/Control/MenuItems/Borderless/Box"]
margin_left = 2.0
margin_top = 2.0
margin_right = 6.0
margin_bottom = 6.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Spacer2" type="Control" parent="Center/Control/MenuItems/Borderless"]
margin_left = 108.0
margin_right = 116.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 0 )
[node name="TouchControls" type="HBoxContainer" parent="Center/Control/MenuItems"]
margin_top = 84.0
margin_right = 116.0
margin_bottom = 92.0
[node name="Touch" type="HBoxContainer" parent="Center/Control/CenterContainer/MenuItems"]
margin_top = 88.0
margin_right = 122.0
margin_bottom = 96.0
rect_min_size = Vector2( 0, 8 )
custom_constants/separation = 2
script = ExtResource( 22 )
[node name="Label" type="Label" parent="Center/Control/MenuItems/TouchControls"]
[node name="Label" type="Label" parent="Center/Control/CenterContainer/MenuItems/Touch"]
margin_top = 1.0
margin_right = 84.0
margin_right = 72.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 2 )
text = "Touch Controls"
text = "Touch screen"
[node name="Spacer" type="Control" parent="Center/Control/MenuItems/TouchControls"]
margin_left = 88.0
margin_right = 92.0
[node name="Spacer" type="Control" parent="Center/Control/CenterContainer/MenuItems/Touch"]
margin_left = 74.0
margin_right = 74.0
margin_bottom = 8.0
size_flags_horizontal = 3
[node name="Box" type="ColorRect" parent="Center/Control/MenuItems/TouchControls"]
margin_left = 96.0
margin_right = 104.0
[node name="Arrow" type="Control" parent="Center/Control/CenterContainer/MenuItems/Touch"]
margin_left = 76.0
margin_right = 79.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 8 )
rect_min_size = Vector2( 3, 0 )
[node name="Back" type="ColorRect" parent="Center/Control/MenuItems/TouchControls/Box"]
margin_left = 1.0
[node name="Sprite" type="Sprite" parent="Center/Control/CenterContainer/MenuItems/Touch/Arrow"]
position = Vector2( 2, 4 )
texture = ExtResource( 9 )
[node name="Label2" type="Label" parent="Center/Control/CenterContainer/MenuItems/Touch"]
margin_left = 81.0
margin_top = 1.0
margin_right = 7.0
margin_bottom = 7.0
color = Color( 0, 0, 0, 1 )
[node name="Fill" type="ColorRect" parent="Center/Control/MenuItems/TouchControls/Box"]
margin_left = 2.0
margin_top = 2.0
margin_right = 6.0
margin_right = 117.0
margin_bottom = 6.0
__meta__ = {
"_edit_use_anchors_": false
}
custom_fonts/font = SubResource( 2 )
text = "always"
[node name="Spacer2" type="Control" parent="Center/Control/MenuItems/TouchControls"]
margin_left = 108.0
margin_right = 116.0
[node name="Arrow2" type="Control" parent="Center/Control/CenterContainer/MenuItems/Touch"]
margin_left = 119.0
margin_right = 122.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 0 )
rect_min_size = Vector2( 3, 0 )
[node name="Time" type="HBoxContainer" parent="Center/Control/MenuItems" groups=["no_item"]]
margin_top = 96.0
margin_right = 116.0
margin_bottom = 101.0
[node name="Sprite" type="Sprite" parent="Center/Control/CenterContainer/MenuItems/Touch/Arrow2"]
position = Vector2( 1, 4 )
texture = ExtResource( 9 )
flip_h = true
[node name="TimeLabel" type="Label" parent="Center/Control/MenuItems/Time"]
[node name="Time" type="HBoxContainer" parent="Center/Control/CenterContainer/MenuItems" groups=["no_item"]]
margin_top = 100.0
margin_right = 122.0
margin_bottom = 105.0
[node name="TimeLabel" type="Label" parent="Center/Control/CenterContainer/MenuItems/Time"]
unique_name_in_owner = true
margin_right = 116.0
margin_right = 122.0
margin_bottom = 5.0
size_flags_horizontal = 3
custom_fonts/font = SubResource( 2 )
text = "Touch Controls"
text = "01:23"
align = 1
[editable path="Center/Control/MenuItems/Music"]
[editable path="Center/Control/CenterContainer/MenuItems/Music"]

View file

@ -1,14 +1,16 @@
extends CanvasItem
onready var fill = $Box/Fill
var is_selected = false
onready var label := $Label2
var text = ["toggle", "always"]
func _ready():
yield(get_tree(), "idle_frame")
fill.visible = TouchScreen.visible
label.text = text[int(TouchScreen.is_stay)]
func scroll(arg := 1):
act()
func act():
var is_touch = !TouchScreen.visible
TouchScreen.visible = is_touch
fill.visible = is_touch
TouchScreen.is_stay = !TouchScreen.is_stay
label.text = text[int(TouchScreen.is_stay)]
Audio.play("menu_pause", 0.9, 1.1)

View file

@ -8,7 +8,7 @@
script = ExtResource( 3 )
[node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = 9
layer = 90
[node name="ColorRect" type="ColorRect" parent="CanvasLayer"]
anchor_right = 1.0