Skip to content

Commit

Permalink
IMPROVEMENT: Refined touchscreen GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
roalyr committed Mar 24, 2022
1 parent e9b15b7 commit c0eaf0d
Show file tree
Hide file tree
Showing 22 changed files with 28,381 additions and 126 deletions.
Binary file modified Assets/Images/Progress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,810 changes: 3,810 additions & 0 deletions Assets/UI_images/Source files/accel.dxf

Large diffs are not rendered by default.

3,810 changes: 3,810 additions & 0 deletions Assets/UI_images/Source files/deccel.dxf

Large diffs are not rendered by default.

3,750 changes: 3,750 additions & 0 deletions Assets/UI_images/Source files/ekill.dxf

Large diffs are not rendered by default.

5,682 changes: 5,682 additions & 0 deletions Assets/UI_images/Source files/options.dxf

Large diffs are not rendered by default.

3,536 changes: 3,536 additions & 0 deletions Assets/UI_images/Source files/stick.dxf

Large diffs are not rendered by default.

3,944 changes: 3,944 additions & 0 deletions Assets/UI_images/Source files/turret.dxf

Large diffs are not rendered by default.

3,746 changes: 3,746 additions & 0 deletions Assets/UI_images/Source files/ui_opacity.dxf

Large diffs are not rendered by default.

Binary file modified Assets/UI_images/accel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/UI_images/deccel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/UI_images/ekill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assets/UI_images/hide_ui.png
Binary file not shown.
Binary file modified Assets/UI_images/options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/UI_images/stick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/UI_images/turret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/UI_images/ui_opacity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

importer="texture"
type="StreamTexture"
path="res://.import/hide_ui.png-135331f4064ca62cd5e71be4c0e4c3f4.stex"
path="res://.import/ui_opacity.png-5ab9c77aecd3b1dbb4ed901a96a715ca.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Assets/UI_images/hide_ui.png"
dest_files=[ "res://.import/hide_ui.png-135331f4064ca62cd5e71be4c0e4c3f4.stex" ]
source_file="res://Assets/UI_images/ui_opacity.png"
dest_files=[ "res://.import/ui_opacity.png-5ab9c77aecd3b1dbb4ed901a96a715ca.stex" ]

[params]

Expand Down
6 changes: 1 addition & 5 deletions Assets/UI_styles/Themes/Touchscreen/Theme1/pad.tres
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.501961, 0.501961, 0.501961, 0.513726 )
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
border_color = Color( 0.501961, 0.501961, 0.501961, 1 )
1 change: 0 additions & 1 deletion Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ script = ExtResource( 6 )
[node name="Ship_state" parent="." instance=ExtResource( 9 )]

[node name="UI" parent="." instance=ExtResource( 3 )]
visible = false

[node name="View" type="Viewport" parent="."]
size = Vector2( 1980, 1020 )
Expand Down
125 changes: 43 additions & 82 deletions Scenes/UI/UI.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=2]
[gd_scene load_steps=18 format=2]

[ext_resource path="res://Scripts/UI.gd" type="Script" id=1]
[ext_resource path="res://Assets/UI_styles/Button_red/Red_hover_focus.tres" type="StyleBox" id=2]
Expand All @@ -12,7 +12,7 @@
[ext_resource path="res://Assets/UI_styles/Themes/Touchscreen/Theme1.tres" type="Theme" id=10]
[ext_resource path="res://Assets/UI_images/turret.png" type="Texture" id=11]
[ext_resource path="res://Assets/UI_images/deccel.png" type="Texture" id=12]
[ext_resource path="res://Assets/UI_images/hide_ui.png" type="Texture" id=13]
[ext_resource path="res://Assets/UI_images/ui_opacity.png" type="Texture" id=13]
[ext_resource path="res://Assets/UI_images/options.png" type="Texture" id=14]

[sub_resource type="ShaderMaterial" id=2]
Expand All @@ -23,19 +23,6 @@ font_data = ExtResource( 5 )

[sub_resource type="CanvasItemMaterial" id=3]

[sub_resource type="StyleBoxFlat" id=5]
bg_color = Color( 0.341176, 0.341176, 0.341176, 0.192157 )
border_width_left = 17
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.435294, 0.435294, 0.435294, 0.215686 )

[sub_resource type="StyleBoxFlat" id=7]
bg_color = Color( 0.109804, 0.109804, 0.109804, 0.341176 )
border_width_right = 83
border_color = Color( 0.447059, 0.447059, 0.447059, 0.54902 )

[node name="UI" type="CanvasLayer"]
script = ExtResource( 1 )

Expand Down Expand Up @@ -314,9 +301,6 @@ text = "0000"
align = 2
valign = 1
clip_text = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Apparent_velocity_units" type="Label" parent="Main3D"]
anchor_left = 0.5
Expand Down Expand Up @@ -347,9 +331,6 @@ margin_bottom = -9.0
custom_colors/font_color = Color( 0.498039, 0.498039, 0.498039, 1 )
custom_fonts/font = SubResource( 4 )
text = "Accel. ticks: 0"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Controls" type="Control" parent="."]
visible = false
Expand Down Expand Up @@ -646,57 +627,57 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="Slider_zoom" type="VSlider" parent="Controls_touchscreen/Main_controls"]
anchor_left = 1.0
[node name="_Margin" type="ColorRect" parent="Controls_touchscreen/Main_controls"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 64.0
margin_top = 64.0
margin_right = -64.0
margin_bottom = -68.0
__meta__ = {
"_edit_lock_": true
}

[node name="Slider_zoom" type="HSlider" parent="Controls_touchscreen/Main_controls"]
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -88.0
margin_top = 120.0
margin_right = -24.0
margin_bottom = -56.0
margin_left = 536.0
margin_top = -164.0
margin_right = -540.0
margin_bottom = -68.0
focus_mode = 0
theme = ExtResource( 10 )
custom_styles/slider = SubResource( 5 )
custom_styles/grabber_area = SubResource( 7 )
max_value = 500.0
tick_count = 5
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Button_turret" type="Button" parent="Controls_touchscreen/Main_controls"]
visible = false
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -208.0
margin_top = -480.0
margin_right = -96.0
margin_bottom = -380.0
margin_left = -168.0
margin_top = 64.0
margin_right = -64.0
margin_bottom = 168.0
focus_mode = 0
theme = ExtResource( 10 )
toggle_mode = true
keep_pressed_outside = true
text = "Turret"
icon = ExtResource( 11 )
flat = true
icon_align = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Button_options" type="Button" parent="Controls_touchscreen/Main_controls"]
margin_left = 216.0
margin_top = 24.0
margin_right = 320.0
margin_bottom = 124.0
margin_left = 200.0
margin_top = 64.0
margin_right = 304.0
margin_bottom = 168.0
focus_mode = 0
theme = ExtResource( 10 )
keep_pressed_outside = true
icon = ExtResource( 14 )
flat = true
__meta__ = {
"_edit_use_anchors_": false
}
icon_align = 1

[node name="Button_accel_plus" type="Button" parent="Controls_touchscreen/Main_controls"]
visible = false
Expand Down Expand Up @@ -754,29 +735,24 @@ __meta__ = {
}

[node name="Button_hide_ui" type="Button" parent="Controls_touchscreen/Main_controls"]
margin_left = 72.0
margin_top = 24.0
margin_right = 176.0
margin_bottom = 124.0
margin_left = 64.0
margin_top = 64.0
margin_right = 168.0
margin_bottom = 168.0
theme = ExtResource( 10 )
keep_pressed_outside = true
icon = ExtResource( 13 )
flat = true
__meta__ = {
"_edit_use_anchors_": false
}
icon_align = 1

[node name="Pad_base" type="Panel" parent="Controls_touchscreen/Main_controls"]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 72.0
margin_top = -464.0
margin_right = 472.0
margin_bottom = -64.0
margin_left = 64.0
margin_top = -468.0
margin_right = 464.0
margin_bottom = -68.0
custom_styles/panel = ExtResource( 7 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Stick" type="TouchScreenButton" parent="Controls_touchscreen/Main_controls/Pad_base"]
position = Vector2( 105, 105 )
Expand All @@ -788,33 +764,19 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -340.0
margin_top = -804.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Touch_ekill" type="TouchScreenButton" parent="Controls_touchscreen/Main_controls/Touch_buttons_container"]
position = Vector2( 16, 544 )
scale = Vector2( 1.66667, 2 )
position = Vector2( -476, -372 )
normal = ExtResource( 9 )
pressed = ExtResource( 9 )

[node name="Touch_turret" type="TouchScreenButton" parent="Controls_touchscreen/Main_controls/Touch_buttons_container"]
position = Vector2( 16, -144 )
scale = Vector2( 2, 2 )
normal = ExtResource( 11 )
pressed = ExtResource( 11 )

[node name="Touch_accel_minus" type="TouchScreenButton" parent="Controls_touchscreen/Main_controls/Touch_buttons_container"]
position = Vector2( 16, 328 )
scale = Vector2( 2, 2 )
position = Vector2( -268, -268 )
normal = ExtResource( 12 )
pressed = ExtResource( 12 )

[node name="Touch_accel_plus" type="TouchScreenButton" parent="Controls_touchscreen/Main_controls/Touch_buttons_container"]
position = Vector2( 16, 96 )
scale = Vector2( 2, 2 )
position = Vector2( -268, -476 )
normal = ExtResource( 8 )
pressed = ExtResource( 8 )

Expand Down Expand Up @@ -849,6 +811,5 @@ pressed = ExtResource( 8 )
[connection signal="pressed" from="Controls_touchscreen/Main_controls/Pad_base/Stick" to="." method="_on_Stick_pressed"]
[connection signal="released" from="Controls_touchscreen/Main_controls/Pad_base/Stick" to="." method="_on_Stick_released"]
[connection signal="pressed" from="Controls_touchscreen/Main_controls/Touch_buttons_container/Touch_ekill" to="." method="_on_Touch_ekill_pressed"]
[connection signal="pressed" from="Controls_touchscreen/Main_controls/Touch_buttons_container/Touch_turret" to="." method="_on_Touch_turret_pressed"]
[connection signal="pressed" from="Controls_touchscreen/Main_controls/Touch_buttons_container/Touch_accel_minus" to="." method="_on_Touch_accel_minus_pressed"]
[connection signal="pressed" from="Controls_touchscreen/Main_controls/Touch_buttons_container/Touch_accel_plus" to="." method="_on_Touch_accel_plus_pressed"]
43 changes: 11 additions & 32 deletions Scripts/UI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ extends CanvasLayer

# Flags.
var stick_held = false
var touchscreen_mode = false
var turret_view = false
var touchscreen_mode = false
var update_debug_text_on = false
var ui_hidden = false
var ui_alpha = 1.0
var viewport_size = Vector2(1,1)


Expand Down Expand Up @@ -66,14 +67,14 @@ func _process(_delta):
# Process virtual stick input.
if touchscreen_mode:
if stick_held:
stick.position.x = p.input.pad_x_abs-90
stick.position.y = p.input.pad_y_abs-90
stick.position.x = p.input.pad_x_abs-100
stick.position.y = p.input.pad_y_abs-100
else:
# Recenter stick.
if stick.position != Vector2(70,70):
stick.position = Vector2(
pad_base.rect_size.x/2-90,
pad_base.rect_size.y/2-90
pad_base.rect_size.x/2-100,
pad_base.rect_size.y/2-100
)
# Reset stick input coords to prevent jumping.
p.input.pad_x_abs = pad_base.rect_size.x/2
Expand Down Expand Up @@ -268,33 +269,11 @@ func _on_Touch_ekill_pressed():
p.signals.emit_signal("sig_engine_kill", true)


func _on_Touch_turret_pressed():
if not turret_view:
turret_view = true
p.signals.emit_signal("sig_turret_mode_on", true)
# Show slider in Touch GUI.
if controls_touchscreen.visible:
controls_touchscreen.get_node("Main_controls/Slider_zoom").show()
else:
turret_view = false
p.signals.emit_signal("sig_turret_mode_on", false)
# Hide slider in Touch GUI.
if controls_touchscreen.visible:
controls_touchscreen.get_node("Main_controls/Slider_zoom").hide()


func _on_Button_hide_ui_pressed():
if not ui_hidden:
ui_hidden = true
pad_base.hide()
touchscreen_buttons.hide()
main3d.hide()
# Dim buttons
touchscreen_main.modulate.a = 0.3
else:
ui_hidden = false
pad_base.show()
touchscreen_buttons.show()
main3d.show()
# Dim buttons
touchscreen_main.modulate.a = 1
touchscreen_main.modulate.a = ui_alpha
main3d.modulate.a = ui_alpha
ui_alpha -= 0.25
if ui_alpha < 0.0:
ui_alpha = 1.0
48 changes: 45 additions & 3 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ keystore/release_user=""
keystore/release_password=""
one_click_deploy/clear_previous_install=false
version/code=1
version/name="1.0"
version/name=""
version/min_sdk=19
version/target_sdk=30
package/unique_name="org.godotengine.$genname"
Expand Down Expand Up @@ -218,12 +218,54 @@ script_encryption_key=""

[preset.1.options]

custom_template/debug="/home/roalyr/Software-archive/apps/Godot3/godot-for-3d-open-worlds/bin/godot.x11.opt.64"
custom_template/release="/home/roalyr/Software-archive/apps/Godot3/godot-for-3d-open-worlds/bin/godot.x11.opt.64"
custom_template/debug="/home/roalyr/Software-archive/apps/Godot3/godot-for-3d-open-worlds/bin/godot.x11.opt.debug.64"
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=true
texture_format/bptc=false
texture_format/s3tc=false
texture_format/etc=false
texture_format/etc2=true
texture_format/no_bptc_fallbacks=true

[preset.2]

name="Windows Desktop"
platform="Windows Desktop"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../../../../Dropbox/Shared/GDTLancer/GDTLancer.exe"
script_export_mode=1
script_encryption_key=""

[preset.2.options]

custom_template/debug="/home/roalyr/Software-archive/apps/Godot3/godot-for-3d-open-worlds/bin/godot.windows.opt.debug.64.exe"
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=true
texture_format/bptc=false
texture_format/s3tc=false
texture_format/etc=false
texture_format/etc2=true
texture_format/no_bptc_fallbacks=true
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/icon="res://Assets/Images/Icon.ico"
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""

0 comments on commit c0eaf0d

Please sign in to comment.