#5 - adding menu language & quit
This commit is contained in:
parent
b937f2bcdf
commit
e9a17934e7
14 changed files with 324 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=4 format=3]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cfld6w0cve6gw"]
|
||||
|
||||
[ext_resource type="Texture2D" path="res://UI/textures/marker.png" id="1_2jmfe"]
|
||||
[ext_resource type="Texture2D" uid="uid://buv7yoovo0sw" path="res://UI/textures/marker.png" id="1_2jmfe"]
|
||||
[ext_resource type="Script" path="res://UI/labels.gd" id="1_4t0l0"]
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_4fvmj"]
|
||||
|
|
31
locales/en.po
Normal file
31
locales/en.po
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Don't remove the two lines below, they're required for gettext to work correctly.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: khanat-client 1\n"
|
||||
"PO-Revision-Date: 1\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: en\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
msgid "Echap = Menu"
|
||||
msgstr "Echap to show menu"
|
||||
|
||||
msgid "Keys"
|
||||
msgstr "Control"
|
||||
|
||||
msgid "Languages"
|
||||
msgstr "Languages"
|
||||
|
||||
msgid "Language"
|
||||
msgstr "Language"
|
||||
|
||||
msgid "Select Language"
|
||||
msgstr "Select your language"
|
||||
|
||||
msgid "Quit"
|
||||
msgstr "Exit"
|
||||
|
31
locales/fr.po
Normal file
31
locales/fr.po
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Don't remove the two lines below, they're required for gettext to work correctly.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: khanat-client 1\n"
|
||||
"PO-Revision-Date: 1\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
msgid "Echap = Menu"
|
||||
msgstr "Appuyer sur Echap pour faire appaître le menu"
|
||||
|
||||
msgid "Keys"
|
||||
msgstr "Contrôles"
|
||||
|
||||
msgid "Languages"
|
||||
msgstr "Langues"
|
||||
|
||||
msgid "Language"
|
||||
msgstr "Langue"
|
||||
|
||||
msgid "Select language"
|
||||
msgstr "Sélectionner votre langue"
|
||||
|
||||
msgid "Quit"
|
||||
msgstr "Sortir"
|
||||
|
27
locales/locale.sh
Executable file
27
locales/locale.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
*#!/bin/bash
|
||||
WORKDIR="$(dirname $(readlink -f $0))"
|
||||
|
||||
function generate_locale()
|
||||
{
|
||||
echo "--- Begin : $1"
|
||||
if [ -f $1.po ]
|
||||
then
|
||||
msgmerge --update --backup=none $1.po messages.pot
|
||||
else
|
||||
msginit --no-translator --input=messages.pot --locale=$1
|
||||
fi
|
||||
echo "--- Check : $1"
|
||||
msgfmt $1.po --check
|
||||
echo "--- End : $1"
|
||||
}
|
||||
ORIGIN=$PWD
|
||||
cd $WORKDIR
|
||||
#######################
|
||||
# LIST LANGUAGE : START
|
||||
#######################
|
||||
generate_locale fr
|
||||
generate_locale en
|
||||
######################
|
||||
# LIST LANGUAGE : END
|
||||
######################
|
||||
cd $ORIGIN
|
BIN
locales/messages.mo
Normal file
BIN
locales/messages.mo
Normal file
Binary file not shown.
21
locales/messages.pot
Normal file
21
locales/messages.pot
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Don't remove the two lines below, they're required for gettext to work correctly.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgid "Echap = Menu"
|
||||
msgstr ""
|
||||
|
||||
msgid "Keys"
|
||||
msgstr ""
|
||||
|
||||
msgid "Languages"
|
||||
msgstr ""
|
||||
|
||||
msgid "Language"
|
||||
msgstr ""
|
||||
|
||||
msgid "Select language"
|
||||
msgstr ""
|
||||
|
||||
msgid "Quit"
|
||||
msgstr ""
|
11
main.tscn
11
main.tscn
|
@ -1,11 +0,0 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cem7wppuuoabv"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cvdmfc2hi172g" path="res://maps/basic_setup.tscn" id="1_s50i7"]
|
||||
[ext_resource type="PackedScene" uid="uid://dwxrvijqyym70" path="res://player/player.tscn" id="2_bge2k"]
|
||||
|
||||
[node name="main_scene" type="Node3D"]
|
||||
|
||||
[node name="player" parent="." instance=ExtResource( "2_bge2k" )]
|
||||
transform = Transform3D(0.750872, 0, -0.660447, 0, 1, 0, 0.660447, 0, 0.750872, -3.68624, 0, -17.6199)
|
||||
|
||||
[node name="terrain_basic_setup" parent="." instance=ExtResource( "1_s50i7" )]
|
|
@ -418,10 +418,10 @@ func _physics_process_walk(delta):
|
|||
|
||||
var collided = move_and_slide()
|
||||
|
||||
if is_on_floor():
|
||||
print("is_on_floor")
|
||||
else:
|
||||
print("not is_on_floor")
|
||||
# if is_on_floor():
|
||||
# print("iZs_on_floor")
|
||||
# else:
|
||||
# print("not is_on_floor")
|
||||
if collided and is_on_floor() and (input_x != 0.0 or input_y != 0.0) and $RayCastGround.is_colliding() and !$RayCastStep.is_colliding():
|
||||
var delta_1:Vector3 = get_position_delta()
|
||||
var areawalk = delta_1.x * delta_1.x + delta_1.z * delta_1.z
|
||||
|
|
|
@ -11,7 +11,7 @@ config_version=5
|
|||
[application]
|
||||
|
||||
config/name="Third Person basic scene"
|
||||
run/main_scene="res://main.tscn"
|
||||
run/main_scene="res://scenes/main/main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/features=PackedStringArray("4.0", "Vulkan Clustered")
|
||||
|
||||
|
@ -45,6 +45,12 @@ ui_down={
|
|||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
ui_menu={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777262,"physical_keycode":0,"unicode":16777262,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777217,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
ui_strafe={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null)
|
||||
|
@ -80,3 +86,7 @@ switch_state_player={
|
|||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":67,"physical_keycode":0,"unicode":99,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[internationalization]
|
||||
|
||||
locale/translations=PackedStringArray("res://locales/en.po", "res://locales/fr.po")
|
||||
|
|
27
scenes/hud/hud.gd
Normal file
27
scenes/hud/hud.gd
Normal file
|
@ -0,0 +1,27 @@
|
|||
extends Control
|
||||
|
||||
|
||||
func _input(event):
|
||||
if Input.is_action_pressed("ui_menu"):
|
||||
$Menu.visible = ! $Menu.visible
|
||||
|
||||
|
||||
func _on_timer_timeout():
|
||||
print("fin")
|
||||
$Message/Label.visible = false
|
||||
|
||||
|
||||
func _on_quit_pressed():
|
||||
#get_tree().quit()
|
||||
$ConfirmQuit.popup_centered()
|
||||
$ConfirmQuit.visible = true
|
||||
pass
|
||||
|
||||
|
||||
func _on_confirmation_dialog_confirmed():
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_languages_pressed():
|
||||
$MenuOption/Window.popup_centered()
|
||||
$MenuOption/Window.visible = true
|
75
scenes/hud/hud.tscn
Normal file
75
scenes/hud/hud.tscn
Normal file
|
@ -0,0 +1,75 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cdyi1a858p7em"]
|
||||
|
||||
[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"]
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( "1_s6f6d" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Message" type="HBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
alignment = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="Message"]
|
||||
offset_left = 917.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 26.0
|
||||
size_flags_vertical = 1
|
||||
text = "Echap = Menu"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Menu" type="HBoxContainer" parent="."]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Keys" type="Button" parent="Menu"]
|
||||
offset_left = 444.0
|
||||
offset_right = 488.0
|
||||
offset_bottom = 40.0
|
||||
text = "Keys"
|
||||
|
||||
[node name="Languages" type="Button" parent="Menu"]
|
||||
offset_left = 492.0
|
||||
offset_right = 574.0
|
||||
offset_bottom = 40.0
|
||||
text = "Languages"
|
||||
|
||||
[node name="Quit" type="Button" parent="Menu"]
|
||||
offset_left = 578.0
|
||||
offset_right = 619.0
|
||||
offset_bottom = 40.0
|
||||
text = "Quit"
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 10.0
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="ConfirmQuit" type="ConfirmationDialog" parent="."]
|
||||
dialog_text = "Do you want quit?"
|
||||
|
||||
[node name="MenuOption" parent="." instance=ExtResource( "2_um8fw" )]
|
||||
visible = false
|
||||
|
||||
[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"]
|
||||
[connection signal="confirmed" from="ConfirmQuit" to="." method="_on_confirmation_dialog_confirmed"]
|
44
scenes/languages/languages.gd
Normal file
44
scenes/languages/languages.gd
Normal file
|
@ -0,0 +1,44 @@
|
|||
extends Control
|
||||
|
||||
# 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 = TranslationServer.get_locale()
|
||||
var root_language = current_locale.split('_')[0]
|
||||
for key in TranslationServer.get_loaded_locales():
|
||||
if key == TranslationServer.get_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(TranslationServer.get_locale_name(key) + " [" + 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 = TranslationServer.get_locale()
|
||||
$Window/VBoxContainer/Select.add_item(TranslationServer.get_locale_name(key) + " (" + key + " !)", id)
|
||||
selected = id
|
||||
$Window/VBoxContainer/Select.select(selected)
|
||||
|
||||
|
||||
func _on_select_item_selected(index):
|
||||
var pos = 0
|
||||
for key in TranslationServer.get_loaded_locales():
|
||||
if pos == $Window/VBoxContainer/Select.get_selected():
|
||||
TranslationServer.set_locale(key)
|
||||
return
|
||||
pos += 1
|
||||
|
||||
|
||||
func _on_quit_pressed():
|
||||
$Window.visible = false
|
37
scenes/languages/languages.tscn
Normal file
37
scenes/languages/languages.tscn
Normal file
|
@ -0,0 +1,37 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://dpvequp5fv27k"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/languages/languages.gd" id="1_qc7c5"]
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
script = ExtResource( "1_qc7c5" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Window" type="Window" parent="."]
|
||||
title = "Language"
|
||||
visible = false
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Window"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Label" type="Label" parent="Window/VBoxContainer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "Select language"
|
||||
|
||||
[node name="Select" type="OptionButton" parent="Window/VBoxContainer"]
|
||||
offset_right = 43.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="Quit" type="Button" parent="Window/VBoxContainer"]
|
||||
offset_top = 35.0
|
||||
offset_right = 43.0
|
||||
offset_bottom = 66.0
|
||||
text = "Quit"
|
||||
|
||||
[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"]
|
14
scenes/main/main.tscn
Normal file
14
scenes/main/main.tscn
Normal file
|
@ -0,0 +1,14 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cem7wppuuoabv"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dwxrvijqyym70" path="res://player/player.tscn" id="1_btdsd"]
|
||||
[ext_resource type="PackedScene" uid="uid://cvdmfc2hi172g" path="res://maps/basic_setup.tscn" id="2_jj4oa"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdyi1a858p7em" path="res://scenes/hud/hud.tscn" id="3_5vcj4"]
|
||||
|
||||
[node name="main_scene" type="Node3D"]
|
||||
|
||||
[node name="player" parent="." instance=ExtResource( "1_btdsd" )]
|
||||
transform = Transform3D(0.750872, 0, -0.660447, 0, 1, 0, 0.660447, 0, 0.750872, -3.68624, 0, -17.6199)
|
||||
|
||||
[node name="terrain_basic_setup" parent="." instance=ExtResource( "2_jj4oa" )]
|
||||
|
||||
[node name="Control" parent="." instance=ExtResource( "3_5vcj4" )]
|
Loading…
Reference in a new issue