update swim and select theme

This commit is contained in:
AleaJactaEst 2022-02-15 23:21:57 +01:00
parent 2c54b63c0e
commit 472e975138
23 changed files with 345 additions and 197 deletions

Binary file not shown.

View file

@ -23,15 +23,23 @@ msgstr "Languages"
msgid "Language"
msgstr "Language"
msgid "Select Language"
msgid "Select language"
msgstr "Select your language"
msgid "Quit"
msgstr "Exit"
msgid "Edit control"
msgstr ""
msgid "Sort by input"
msgstr "Sort by input"
msgid "Reload system config"
msgstr "Reload system config"
msgid "Select theme"
msgstr "Select theme"
msgid "Themes"
msgstr "Theme"

View file

@ -29,9 +29,17 @@ msgstr "Sélectionner votre langue"
msgid "Quit"
msgstr "Sortir"
msgid "Edit control"
msgstr ""
msgid "Sort by input"
msgstr "Trié par contrôle"
msgid "Reload system config"
msgstr "Recharger la configuration de base"
msgid "Select theme"
msgstr "Sélectionner le thème"
msgid "Themes"
msgstr "Thème"

Binary file not shown.

View file

@ -28,3 +28,9 @@ msgstr ""
msgid "Reload system config"
msgstr ""
msgid "Select theme"
msgstr ""
msgid "Themes"
msgstr ""

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -85,7 +85,8 @@ var player_automove:bool = false
var state_player:StatePlayer = StatePlayer.WALK
var level_water:float
var heigh_underwater = 1.0
var heigh_underwater_swim = 0.2
var heigh_underwater_walk = 1.0
var stop_move:bool = false
var max_collided_speed = 0.0
@onready var camera_fps:Camera3D = $camera_root/Camera3D_FPS_WALK
@ -356,7 +357,7 @@ func _physics_process_player(delta):
return
match state_player:
StatePlayer.WALK_WATER:
if get_position().y > level_water - heigh_underwater:
if get_position().y > level_water - heigh_underwater_walk:
_physics_process_walk_water(delta)
else:
switch_state(StatePlayer.SWIM)
@ -909,7 +910,7 @@ func _physics_process_swim(delta):
var tmp = get_position()
tmp.y = level_water
set_position(tmp)
elif col == true and get_position().y >= level_water - heigh_underwater:
elif col == true and get_position().y >= level_water - heigh_underwater_swim:
switch_state(StatePlayer.WALK_WATER)

View file

@ -15,6 +15,10 @@ run/main_scene="res://scenes/main/main.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0", "Vulkan Clustered")
[autoload]
Themes="*res://scripts/themes.gd"
[input]
ui_left={

View file

@ -1,6 +1,18 @@
extends Control
func _ready():
# .connect("mute_pressed", self, "_on_signal_mute_pressed")
$MenuTheme.connect("update_theme", update_theme.bind())
func update_theme():
var select_theme = load(Themes.THEMES_CONTROL[Themes.current_theme])
#$Control.set_theme(Themes.THEMES_CONTROL[Themes.current_theme])
print($Control)
self.set_theme(select_theme)
func _input(_event):
if Input.is_action_just_pressed("ui_menu"):
$Menu.visible = ! $Menu.visible
@ -29,3 +41,8 @@ func _on_keys_pressed():
#$MenuControl/Window.popup_centered()
#$MenuControl/Window.visible = true
pass
func _on_themes_pressed():
$MenuTheme/Window.popup_centered()
$MenuTheme/Window.visible = true

View file

@ -1,12 +1,15 @@
[gd_scene load_steps=4 format=3 uid="uid://cdyi1a858p7em"]
[gd_scene load_steps=6 format=3 uid="uid://cdyi1a858p7em"]
[ext_resource type="Theme" uid="uid://bi1js53ni6ehd" path="res://UI/themes/khanat/khanat.theme" id="1_iq3fo"]
[ext_resource type="Script" path="res://scenes/hud/hud.gd" id="1_s6f6d"]
[ext_resource type="PackedScene" uid="uid://dpvequp5fv27k" path="res://scenes/languages/languages.tscn" id="2_um8fw"]
[ext_resource type="PackedScene" uid="uid://cl8xk8w3jmta0" path="res://scenes/controls/controls.tscn" id="3_08xl7"]
[ext_resource type="PackedScene" uid="uid://cb0gfweooxdsl" path="res://scenes/themes/themes.tscn" id="4_1poje"]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( "1_iq3fo" )
script = ExtResource( "1_s6f6d" )
__meta__ = {
"_edit_use_anchors_": false
@ -22,9 +25,9 @@ __meta__ = {
}
[node name="Label" type="Label" parent="Message"]
offset_left = 917.0
offset_left = 918.0
offset_right = 1024.0
offset_bottom = 26.0
offset_bottom = 27.0
size_flags_vertical = 1
text = "Echap = Menu"
__meta__ = {
@ -47,6 +50,11 @@ offset_right = 554.0
offset_bottom = 40.0
text = "Keys"
[node name="Themes" type="Button" parent="Menu"]
offset_right = 8.0
offset_bottom = 31.0
text = "Themes"
[node name="Languages" type="Button" parent="Menu"]
offset_left = 492.0
offset_right = 574.0
@ -72,7 +80,11 @@ visible = false
[node name="MenuControl" parent="." instance=ExtResource( "3_08xl7" )]
[node name="MenuTheme" parent="." instance=ExtResource( "4_1poje" )]
visible = false
[connection signal="pressed" from="Menu/Keys" to="." method="_on_keys_pressed"]
[connection signal="pressed" from="Menu/Themes" to="." method="_on_themes_pressed"]
[connection signal="pressed" from="Menu/Languages" to="." method="_on_languages_pressed"]
[connection signal="pressed" from="Menu/Quit" to="." method="_on_quit_pressed"]
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

49
scenes/themes/themes.gd Normal file
View file

@ -0,0 +1,49 @@
extends Control
signal update_theme
# Called when the node enters the scene tree for the first time.
func _ready():
$Window/VBoxContainer/Select.clear()
var id = 0
var selected = -1
var near_selected = -1
var current_locale = Themes.current_theme
var root_language = current_locale.split('_')[0]
for key in Themes.THEMES_CONTROL:
if key == current_locale:
selected = id
else:
var tmp = key.split("_")
# print("tmp:" + tmp[0])
if tmp[0] == root_language:
if tmp.size() == 1:
near_selected = id
elif near_selected == -1:
near_selected = id
$Window/VBoxContainer/Select.add_item( key, id )
id += 1
if selected == -1 and near_selected != -1:
selected = near_selected
if selected == -1:
# Your language not exist, create it just for the form
var key = current_locale
$Window/VBoxContainer/Select.add_item( key, id)
selected = id
$Window/VBoxContainer/Select.select(selected)
func _on_quit_pressed():
$Window.visible = false
func _on_select_item_selected(index):
var pos = 0
for key in Themes.THEMES_CONTROL:
if pos == $Window/VBoxContainer/Select.get_selected():
Themes.current_theme = key
emit_signal( "update_theme" )
return
pos += 1

38
scenes/themes/themes.tscn Normal file
View file

@ -0,0 +1,38 @@
[gd_scene load_steps=2 format=3 uid="uid://cb0gfweooxdsl"]
[ext_resource type="Script" path="res://scenes/themes/themes.gd" id="1_a1yak"]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( "1_a1yak" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Window" type="Window" parent="."]
visible = false
[node name="VBoxContainer" type="VBoxContainer" parent="Window"]
offset_right = 40.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/VBoxContainer"]
offset_right = 98.0
offset_bottom = 26.0
text = "Select theme"
[node name="Select" type="OptionButton" parent="Window/VBoxContainer"]
offset_top = 30.0
offset_right = 98.0
offset_bottom = 61.0
[node name="Quit" type="Button" parent="Window/VBoxContainer"]
offset_top = 65.0
offset_right = 98.0
offset_bottom = 96.0
text = "Quit"
[connection signal="close_requested" from="Window" to="." method="_on_quit_pressed"]
[connection signal="item_selected" from="Window/VBoxContainer/Select" to="." method="_on_select_item_selected"]
[connection signal="pressed" from="Window/VBoxContainer/Quit" to="." method="_on_quit_pressed"]

8
scripts/themes.gd Normal file
View file

@ -0,0 +1,8 @@
extends Node
const THEMES_CONTROL = {
"khanat": "res://UI/themes/khanat/khanat.theme",
"zbasu": "res://UI/themes/zbasu/zbasu.theme"
}
var current_theme = "khanat"