No commits in common. 'pre_alpha_1' and 'master' have entirely different histories.
pre_alpha_
...
master
77 changed files with 3955 additions and 135756 deletions
-
2.gitignore
-
BINassets/blender/loop.blend
-
BINassets/blender/loop.blend1
-
137356assets/road/roadLoop.obj
-
51ext/server.py
-
45project.godot
-
145resources/ui/i18n.csv
-
BINresources/ui/i18n.de.translation
-
BINresources/ui/i18n.en.translation
-
9resources/ui/theme.tres
-
15scenes/menus/BaseMenu.tscn
-
75scenes/menus/DirectHostMenu.tscn
-
3scenes/menus/DirectJoinMenu.tscn
-
20scenes/menus/IngameMenu.tscn
-
8scenes/menus/LobbyMenu.tscn
-
58scenes/menus/LocalGameMenu.tscn
-
53scenes/menus/MainMenu.tscn
-
24scenes/menus/MultiplayerMenu.tscn
-
34scenes/menus/ServerCreateGameMenu.tscn
-
36scenes/menus/SettingsControlsMenu.tscn
-
53scenes/menus/SettingsGameMenu.tscn
-
44scenes/menus/SettingsGraphicsMenu.tscn
-
151scenes/menus/SettingsMenu.tscn
-
12scenes/menus/SettingsPlayerMenu.tscn
-
62scenes/menus/SettingsSystemMenu.tscn
-
7scenes/player/BotPlayer.tscn
-
74scenes/player/HumanPlayer.tscn
-
1scenes/player/Player.tscn
-
2scenes/road/roadCornerLarge.tscn
-
4scenes/road/roadCornerLargeFlipped.tscn
-
4scenes/road/roadCornerLarger.tscn
-
4scenes/road/roadCornerLargerFlipped.tscn
-
6scenes/road/roadCornerSmall.tscn
-
6scenes/road/roadCornerSmallFlipped.tscn
-
2scenes/road/roadRamp.tscn
-
2scenes/road/roadRampFlipped.tscn
-
4scenes/road/roadRampLong.tscn
-
2scenes/road/roadRampLongCurved.tscn
-
2scenes/road/roadRampLongFlipped.tscn
-
12scripts/Util.gd
-
27scripts/game/config.gd
-
63scripts/game/config_apply.gd
-
19scripts/game/game.gd
-
13scripts/game/gamestate.gd
-
58scripts/game/local_storage.gd
-
25scripts/game/route.gd
-
12scripts/menus/direct_host_menu.gd
-
0scripts/menus/direct_join_menu.gd
-
25scripts/menus/ingame.gd
-
21scripts/menus/ingame_menu.gd
-
2scripts/menus/lobby_menu.gd
-
12scripts/menus/local_game.gd
-
7scripts/menus/main_menu.gd
-
18scripts/menus/server_create_menu.gd
-
2scripts/menus/server_menu.gd
-
67scripts/menus/settings.gd
-
89scripts/menus/settings_controls.gd
-
128scripts/menus/settings_controls_menu.gd
-
17scripts/menus/settings_game_menu.gd
-
24scripts/menus/settings_graphics_menu.gd
-
46scripts/menus/settings_menu.gd
-
14scripts/menus/settings_player.gd
-
14scripts/menus/settings_player_menu.gd
-
55scripts/menus/settings_system_menu.gd
-
31scripts/networking/game_server.gd
-
8scripts/networking/game_server_requests.gd
-
30scripts/networking/server.gd
-
18scripts/player/base_inventory.gd
-
77scripts/player/bot_controls.gd
-
3scripts/player/bot_inventory.gd
-
27scripts/player/human_controls.gd
-
10scripts/player/human_inventory.gd
-
2scripts/player/inventory_preview.gd
-
55scripts/player/player.gd
-
19scripts/road/road.gd
-
53scripts/screen_capture.gd
-
36scripts/util.gd
137356
assets/road/roadLoop.obj
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,53 @@ |
|||||
|
[gd_scene load_steps=3 format=2] |
||||
|
|
||||
|
[ext_resource path="res://scripts/menus/settings_game_menu.gd" type="Script" id=1] |
||||
|
[ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=2] |
||||
|
|
||||
|
[node name="settings_game_menu" type="Tabs"] |
||||
|
anchor_right = 1.0 |
||||
|
anchor_bottom = 1.0 |
||||
|
margin_left = 4.0 |
||||
|
margin_top = 45.0 |
||||
|
margin_right = -4.0 |
||||
|
margin_bottom = -4.0 |
||||
|
focus_neighbour_right = NodePath("../controls") |
||||
|
focus_neighbour_bottom = NodePath("GridContainer/settings_player/VBoxContainer/name") |
||||
|
focus_mode = 2 |
||||
|
script = ExtResource( 1 ) |
||||
|
|
||||
|
[node name="GridContainer" type="GridContainer" parent="."] |
||||
|
margin_left = 9.0 |
||||
|
margin_top = 10.0 |
||||
|
margin_right = 416.0 |
||||
|
margin_bottom = 202.0 |
||||
|
|
||||
|
[node name="settings_player" parent="GridContainer" instance=ExtResource( 2 )] |
||||
|
margin_left = 0.0 |
||||
|
margin_top = 0.0 |
||||
|
margin_right = 407.0 |
||||
|
margin_bottom = 148.0 |
||||
|
|
||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="GridContainer"] |
||||
|
margin_top = 152.0 |
||||
|
margin_right = 407.0 |
||||
|
margin_bottom = 192.0 |
||||
|
|
||||
|
[node name="bots" type="CheckButton" parent="GridContainer/HBoxContainer"] |
||||
|
margin_right = 109.0 |
||||
|
margin_bottom = 40.0 |
||||
|
focus_neighbour_top = NodePath("../settings_player/VBoxContainer/color") |
||||
|
focus_neighbour_bottom = NodePath("../../../../HBoxContainer/apply") |
||||
|
size_flags_horizontal = 0 |
||||
|
size_flags_vertical = 0 |
||||
|
text = "Bots" |
||||
|
|
||||
|
[node name="bot_difficulty" type="HSlider" parent="GridContainer/HBoxContainer"] |
||||
|
margin_left = 113.0 |
||||
|
margin_right = 407.0 |
||||
|
margin_bottom = 40.0 |
||||
|
size_flags_horizontal = 3 |
||||
|
size_flags_vertical = 1 |
||||
|
max_value = 1.0 |
||||
|
step = 0.1 |
||||
|
tick_count = 11 |
||||
|
ticks_on_borders = true |
@ -0,0 +1,44 @@ |
|||||
|
[gd_scene load_steps=2 format=2] |
||||
|
|
||||
|
[ext_resource path="res://scripts/menus/settings_graphics_menu.gd" type="Script" id=1] |
||||
|
|
||||
|
[node name="settings_graphics_menu" type="Tabs"] |
||||
|
anchor_right = 1.0 |
||||
|
anchor_bottom = 1.0 |
||||
|
margin_left = 4.0 |
||||
|
margin_top = 45.0 |
||||
|
margin_right = -4.0 |
||||
|
margin_bottom = -4.0 |
||||
|
focus_neighbour_left = NodePath("../controls") |
||||
|
focus_neighbour_right = NodePath("../system") |
||||
|
focus_mode = 2 |
||||
|
script = ExtResource( 1 ) |
||||
|
|
||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."] |
||||
|
margin_right = 40.0 |
||||
|
margin_bottom = 40.0 |
||||
|
|
||||
|
[node name="resolution" type="OptionButton" parent="VBoxContainer"] |
||||
|
margin_right = 192.0 |
||||
|
margin_bottom = 20.0 |
||||
|
|
||||
|
[node name="fullscreen" type="CheckButton" parent="VBoxContainer"] |
||||
|
margin_top = 24.0 |
||||
|
margin_right = 192.0 |
||||
|
margin_bottom = 64.0 |
||||
|
pressed = true |
||||
|
text = "FULLSCREEN" |
||||
|
|
||||
|
[node name="light" type="CheckButton" parent="VBoxContainer"] |
||||
|
margin_top = 68.0 |
||||
|
margin_right = 192.0 |
||||
|
margin_bottom = 108.0 |
||||
|
text = "LIGHT" |
||||
|
|
||||
|
[node name="shadows" type="CheckButton" parent="VBoxContainer"] |
||||
|
margin_top = 112.0 |
||||
|
margin_right = 192.0 |
||||
|
margin_bottom = 152.0 |
||||
|
disabled = true |
||||
|
text = "SHADOWS" |
||||
|
[connection signal="toggled" from="VBoxContainer/light" to="." method="_on_light_toggled"] |
@ -0,0 +1,62 @@ |
|||||
|
[gd_scene load_steps=2 format=2] |
||||
|
|
||||
|
[ext_resource path="res://scripts/menus/settings_system_menu.gd" type="Script" id=1] |
||||
|
|
||||
|
[node name="system_settings_menu" type="Tabs"] |
||||
|
anchor_right = 1.0 |
||||
|
anchor_bottom = 1.0 |
||||
|
margin_left = 4.0 |
||||
|
margin_top = 45.0 |
||||
|
margin_right = -4.0 |
||||
|
margin_bottom = -4.0 |
||||
|
focus_neighbour_left = NodePath("../graphics") |
||||
|
focus_mode = 2 |
||||
|
script = ExtResource( 1 ) |
||||
|
|
||||
|
[node name="GridContainer" type="GridContainer" parent="."] |
||||
|
margin_left = 12.0 |
||||
|
margin_top = 8.0 |
||||
|
margin_right = 907.0 |
||||
|
margin_bottom = 124.0 |
||||
|
columns = 2 |
||||
|
|
||||
|
[node name="locale_label" type="Label" parent="GridContainer"] |
||||
|
margin_right = 88.0 |
||||
|
margin_bottom = 14.0 |
||||
|
text = "LOCALE" |
||||
|
valign = 1 |
||||
|
|
||||
|
[node name="locales" type="ItemList" parent="GridContainer"] |
||||
|
margin_left = 92.0 |
||||
|
margin_right = 895.0 |
||||
|
margin_bottom = 14.0 |
||||
|
size_flags_horizontal = 3 |
||||
|
auto_height = true |
||||
|
|
||||
|
[node name="server_addr_label" type="Label" parent="GridContainer"] |
||||
|
margin_top = 23.0 |
||||
|
margin_right = 88.0 |
||||
|
margin_bottom = 37.0 |
||||
|
text = "SERVER_ADDR" |
||||
|
valign = 1 |
||||
|
|
||||
|
[node name="server_addr" type="LineEdit" parent="GridContainer"] |
||||
|
margin_left = 92.0 |
||||
|
margin_top = 18.0 |
||||
|
margin_right = 895.0 |
||||
|
margin_bottom = 42.0 |
||||
|
|
||||
|
[node name="api_addr_label" type="Label" parent="GridContainer"] |
||||
|
margin_top = 51.0 |
||||
|
margin_right = 88.0 |
||||
|
margin_bottom = 65.0 |
||||
|
text = "API_ADDR" |
||||
|
valign = 1 |
||||
|
|
||||
|
[node name="api_addr" type="LineEdit" parent="GridContainer"] |
||||
|
margin_left = 92.0 |
||||
|
margin_top = 46.0 |
||||
|
margin_right = 895.0 |
||||
|
margin_bottom = 70.0 |
||||
|
[connection signal="tree_exiting" from="." to="." method="_on_system_settings_menu_tree_exiting"] |
||||
|
[connection signal="item_selected" from="GridContainer/locales" to="." method="_on_locales_item_selected"] |
@ -1,12 +0,0 @@ |
|||||
extends Node |
|
||||
|
|
||||
class_name Util |
|
||||
|
|
||||
|
|
||||
static func clear_node(node:Node): |
|
||||
for idx in range(node.get_child_count()): |
|
||||
node.remove_child(node.get_child(0)) |
|
||||
|
|
||||
|
|
||||
static func curve_get_last_point(curve:Curve3D): |
|
||||
return curve.get_point_position(curve.get_point_count() - 1) |
|
@ -0,0 +1,27 @@ |
|||||
|
extends Node |
||||
|
|
||||
|
const FILE_PATH = "user://local_storage" |
||||
|
|
||||
|
const RESOLUTIONS = [Vector2(1920,1080),Vector2(1600,900),Vector2(1366,758),Vector2(1280,720),Vector2(1136,640),Vector2(1024,576)] |
||||
|
|
||||
|
const CONTROL_ACTIONS = ["controls_thrust", "controls_break", "controls_add_road", "controls_next_road_type", "controls_prev_road_type", "controls_next_road_variant", "controls_prev_road_variant", "controls_reset", "controls_menu", "controls_capture"] |
||||
|
|
||||
|
const INPUT_UI_MAPPING = {"ui_accept" : "controls_add_road", "ui_select" : "controls_add_road", "ui_up" : "controls_next_road_variant", "ui_down" : "controls_prev_road_variant", "ui_left" : "controls_prev_road_type", "ui_right" : "controls_next_road_type"} |
||||
|
|
||||
|
var config_file:ConfigFile = ConfigFile.new() |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
config_file.load(FILE_PATH) |
||||
|
|
||||
|
|
||||
|
func save(): |
||||
|
config_file.save(FILE_PATH) |
||||
|
|
||||
|
|
||||
|
func get_value(section:String, key:String, default = null): |
||||
|
return config_file.get_value(section,key,default) |
||||
|
|
||||
|
|
||||
|
func set_value(section:String, key:String, value): |
||||
|
config_file.set_value(section,key,value) |
@ -0,0 +1,63 @@ |
|||||
|
extends Node |
||||
|
|
||||
|
const FILE_PATH = "user://local_storage" |
||||
|
|
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
apply_settings() |
||||
|
|
||||
|
|
||||
|
func apply_settings(): |
||||
|
apply_locale() |
||||
|
apply_game_server() |
||||
|
apply_resolution() |
||||
|
apply_controls() |
||||
|
|
||||
|
|
||||
|
func apply_locale(): |
||||
|
TranslationServer.set_locale(config.get_value("system","locale","en")) |
||||
|
|
||||
|
|
||||
|
func apply_game_server(): |
||||
|
var server_addr = config.get_value("system", "server_addr") |
||||
|
if server_addr != null && not server_addr.empty(): |
||||
|
game_server.set_server_addr(server_addr) |
||||
|
var api_addr = config.get_value("system","api_addr") |
||||
|
if api_addr != null && not api_addr.empty(): |
||||
|
game_server.set_api_addr(api_addr) |
||||
|
|
||||
|
|
||||
|
func apply_resolution(): |
||||
|
var view_port = get_tree().get_root() |
||||
|
OS.set_window_fullscreen(config.get_value("graphics","fullscreen", true)) |
||||
|
|
||||
|
var resolution = config.get_value("graphics","resolution",config.RESOLUTIONS[0]) |
||||
|
if OS.is_window_fullscreen(): |
||||
|
var base_size = Vector2(1920, 1080) |
||||
|
var scale= base_size.x / resolution.x |
||||
|
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_2D,SceneTree.STRETCH_ASPECT_EXPAND,base_size,scale) |
||||
|
else: |
||||
|
OS.set_window_size(resolution) |
||||
|
OS.set_window_position(Vector2((OS.get_screen_size().x - resolution.x) / 2, (OS.get_screen_size().y - resolution.y) / 2)) # center screen |
||||
|
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_IGNORE,OS.get_window_size(),1) |
||||
|
|
||||
|
|
||||
|
func apply_controls(): |
||||
|
InputMap.load_from_globals() |
||||
|
var control_map = config.get_value("controls","mapping",{}) |
||||
|
for action in InputMap.get_actions(): |
||||
|
if control_map.has(action): |
||||
|
for event in InputMap.get_action_list(action): |
||||
|
if event is InputEventKey && control_map[action].has("key"): |
||||
|
InputMap.action_erase_event(action, event) |
||||
|
event.set_scancode(OS.find_scancode_from_string(control_map[action]["key"])) |
||||
|
InputMap.action_add_event(action,event) |
||||
|
elif event is InputEventJoypadButton && control_map[action].has("joypad"): |
||||
|
InputMap.action_erase_event(action, event) |
||||
|
event.set_button_index(control_map[action]["joypad"]) |
||||
|
InputMap.action_add_event(action,event) |
||||
|
|
||||
|
for ui_mapping in config.INPUT_UI_MAPPING: |
||||
|
for event in InputMap.get_action_list(config.INPUT_UI_MAPPING[ui_mapping]): |
||||
|
InputMap.action_add_event(ui_mapping, event) |
@ -1,58 +0,0 @@ |
|||||
extends Node |
|
||||
|
|
||||
const FILE_PATH = "user://local_storage" |
|
||||
|
|
||||
|
|
||||
func _ready(): |
|
||||
TranslationServer.set_locale(read_value("locale","en")) |
|
||||
|
|
||||
|
|
||||
func read_content(): |
|
||||
var f = File.new() |
|
||||
var err = f.open(FILE_PATH, File.READ) |
|
||||
var content = {} |
|
||||
if err == OK: |
|
||||
content = parse_json(f.get_as_text()) |
|
||||
f.close() |
|
||||
if content == null: |
|
||||
content = {} |
|
||||
return content |
|
||||
|
|
||||
|
|
||||
func write_content(content:Dictionary): |
|
||||
var f = File.new() |
|
||||
var err = f.open(FILE_PATH, File.WRITE) |
|
||||
#var err = f.open_encrypted_with_pass(FILE_PATH, File.WRITE, OS.get_unique_id()) |
|
||||
f.store_string(to_json(content)) |
|
||||
f.close() |
|
||||
|
|
||||
|
|
||||
func write_value(key:String, value): |
|
||||
var content = read_content() |
|
||||
content[key] = value |
|
||||
write_content(content) |
|
||||
|
|
||||
|
|
||||
func read_value(key:String, default = null): |
|
||||
var content = read_content() |
|
||||
if content.has(key) && content.get(key) != null: |
|
||||
return content.get(key) |
|
||||
else: |
|
||||
return default |
|
||||
|
|
||||
|
|
||||
func delete_value(key:String): |
|
||||
var content = read_content() |
|
||||
content.erase(key) |
|
||||
write_content(content) |
|
||||
|
|
||||
|
|
||||
func write_values(new_content:Dictionary): |
|
||||
var content = read_content() |
|
||||
for key in new_content: |
|
||||
content[key] = new_content[key] |
|
||||
write_content(content) |
|
||||
|
|
||||
|
|
||||
func read_values(): |
|
||||
return read_content() |
|
@ -1,25 +0,0 @@ |
|||||
extends Control |
|
||||
|
|
||||
|
|
||||
func _draw(): |
|
||||
find_node("resume").grab_focus() |
|
||||
|
|
||||
|
|
||||
func _physics_process(delta): |
|
||||
if Input.is_action_just_pressed("ui_cancel"): |
|
||||
if is_visible_in_tree(): |
|
||||
hide() |
|
||||
else: |
|
||||
show() |
|
||||
|
|
||||
|
|
||||
func _on_resume_pressed(): |
|
||||
hide() |
|
||||
|
|
||||
|
|
||||
func _on_settings_pressed(): |
|
||||
pass |
|
||||
|
|
||||
|
|
||||
func _on_end_pressed(): |
|
||||
gamestate.quit_game() |
|
@ -0,0 +1,21 @@ |
|||||
|
extends Control |
||||
|
|
||||
|
var SettingsMenu = preload("res://scenes/menus/SettingsMenu.tscn") |
||||
|
|
||||
|
|
||||
|
func _draw(): |
||||
|
find_node("resume").grab_focus() |
||||
|
|
||||
|
|
||||
|
func _on_resume_pressed(): |
||||
|
hide() |
||||
|
|
||||
|
|
||||
|
func _on_settings_pressed(): |
||||
|
var settings_menu = SettingsMenu.instance() |
||||
|
get_parent().add_child(settings_menu) |
||||
|
hide() |
||||
|
|
||||
|
|
||||
|
func _on_end_pressed(): |
||||
|
gamestate.quit_game() |
@ -1,67 +0,0 @@ |
|||||
extends Control |
|
||||
|
|
||||
onready var player_settings = find_node("settings_player") |
|
||||
onready var game_tab = find_node("game") |
|
||||
onready var controls_tab = find_node("controls") |
|
||||
onready var graphics_tab = find_node("graphics") |
|
||||
onready var system_tab = find_node("system") |
|
||||
|
|
||||
var locale |
|
||||
|
|
||||
|
|
||||
func _ready(): |
|
||||
get_node("menu/back").connect("pressed",self,"_on_back_pressed") |
|
||||
find_node("bots").set_pressed(local_storage.read_value("bots", true)) |
|
||||
game_tab.set_name(tr("GAME")) |
|
||||
controls_tab.set_name(tr("CONTROLS")) |
|
||||
graphics_tab.set_name(tr("GRAPHICS")) |
|
||||
system_tab.set_name(tr("SYSTEM")) |
|
||||
|
|
||||
|
|
||||
func _on_back_pressed(): |
|
||||
queue_free() |
|
||||
get_tree().get_root().get_node("main_menu").show() |
|
||||
|
|
||||
|
|
||||
func _on_locales_item_selected(index): |
|
||||
match index: |
|
||||
0: |
|
||||
locale = "en" |
|
||||
1: |
|
||||
locale = "de" |
|
||||
_: |
|
||||
locale = "en" |
|
||||
TranslationServer.set_locale(locale) |
|
||||
game_tab.set_name(tr("GAME")) |
|
||||
controls_tab.set_name(tr("CONTROLS")) |
|
||||
graphics_tab.set_name(tr("GRAPHICS")) |
|
||||
system_tab.set_name(tr("SYSTEM")) |
|
||||
|
|
||||
|
|
||||
func _init_locales(): |
|
||||
var locales = find_node("locales") |
|
||||
locales.clear() |
|
||||
locales.add_item(tr("LOCALE_EN")) |
|
||||
locales.add_item(tr("LOCALE_DE")) |
|
||||
locale = local_storage.read_value("locale","en") |
|
||||
match locale: |
|
||||
"en": |
|
||||
locales.select(0) |
|
||||
_on_locales_item_selected(0) |
|
||||
"de": |
|
||||
locales.select(1) |
|
||||
_on_locales_item_selected(1) |
|
||||
|
|
||||
|
|
||||
func _on_locales_tree_exiting(): |
|
||||
TranslationServer.set_locale(local_storage.read_value("locale","en")) |
|
||||
|
|
||||
|
|
||||
func _on_save_pressed(): |
|
||||
var values = {} |
|
||||
values['player_name'] = player_settings.get_name_node().text |
|
||||
values['player_color'] = player_settings.get_color_node().color.to_html() |
|
||||
values['bots'] = find_node("bots").is_pressed() |
|
||||
values['locale'] = locale |
|
||||
local_storage.write_values(values) |
|
||||
_on_back_pressed() |
|
@ -1,89 +0,0 @@ |
|||||
tool |
|
||||
|
|
||||
extends Control |
|
||||
|
|
||||
onready var grid = find_node("grid") |
|
||||
onready var key_dialog = get_node("key_dialog") |
|
||||
|
|
||||
const INPUT_TYPE_KEY = 0 |
|
||||
const INPUT_TYPE_JOYPAD = 1 |
|
||||
|
|
||||
var last_action:String |
|
||||
var last_event:InputEvent |
|
||||
|
|
||||
var new_inputs = {} |
|
||||
|
|
||||
func _ready(): |
|
||||
init_mapping() |
|
||||
|
|
||||
|
|
||||
func init_mapping(): |
|
||||
new_inputs = {} |
|
||||
for action in InputMap.get_actions(): |
|
||||
if action.begins_with("controls_"): |
|
||||
var action_label = Label.new() |
|
||||
action_label.set_name(action + "_label") |
|
||||
action_label.set_text(action) |
|
||||
grid.add_child(action_label) |
|
||||
|
|
||||
var key_action_button = Button.new() |
|
||||
key_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
|
||||
key_action_button.set_flat(true) |
|
||||
key_action_button.set_meta("action",action) |
|
||||
key_action_button.set_button_icon(get_node("icons/key").get_button_icon()) |
|
||||
|
|
||||
var joypad_action_button = Button.new() |
|
||||
joypad_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
|
||||
joypad_action_button.set_flat(true) |
|
||||
joypad_action_button.set_meta("action",action) |
|
||||
|
|
||||
for mapping in InputMap.get_action_list(action): |
|
||||
if mapping is InputEventKey: |
|
||||
key_action_button.set_text(mapping.as_text()) |
|
||||
key_action_button.set_tooltip(mapping.as_text()) |
|
||||
elif mapping is InputEventJoypadButton: |
|
||||
joypad_action_button.set_tooltip(str(mapping.button_index)) |
|
||||
if has_node("icons/joypad/" + str(mapping.button_index)): |
|
||||
joypad_action_button.set_button_icon(get_node("icons/joypad/" + str(mapping.button_index)).get_button_icon()) |
|
||||
else: |
|
||||
joypad_action_button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
|
||||
joypad_action_button.set_text(str(mapping.button_index)) |
|
||||
|
|
||||
grid.add_child(key_action_button) |
|
||||
key_action_button.connect("pressed",self,"_on_button_pressed",[action, INPUT_TYPE_KEY]) |
|
||||
|
|
||||
grid.add_child(joypad_action_button) |
|
||||
joypad_action_button.connect("pressed",self,"_on_button_pressed",[action, INPUT_TYPE_JOYPAD]) |
|
||||
|
|
||||
func _unhandled_input(event): |
|
||||
if key_dialog.is_visible_in_tree(): |
|
||||
if key_dialog.get_meta("type") == INPUT_TYPE_KEY && event is InputEventKey: |
|
||||
last_event = event |
|
||||
key_dialog.set_text(tr(last_event.as_text())) |
|
||||
key_dialog.get_ok().set_disabled(false) |
|
||||
elif key_dialog.get_meta("type") == INPUT_TYPE_JOYPAD && event is InputEventJoypadButton: |
|
||||
last_event = event |
|
||||
key_dialog.set_text(last_event.as_text()) |
|
||||
key_dialog.get_ok().set_disabled(false) |
|
||||
|
|
||||
|
|
||||
func _on_button_pressed(action, type): |
|
||||
last_action = action |
|
||||
last_event = null |
|
||||
key_dialog.set_text(tr("PRESS_KEY")) |
|
||||
key_dialog.set_meta("type", type) |
|
||||
key_dialog.connect("confirmed",self,"_on_dialog_confirmed") |
|
||||
key_dialog.get_ok().set_disabled(true) |
|
||||
key_dialog.popup_centered() |
|
||||
|
|
||||
|
|
||||
func _on_dialog_confirmed(type): |
|
||||
if not new_inputs.has(last_action): |
|
||||
new_inputs[last_action] = {} |
|
||||
match key_dialog.get_meta("type"): |
|
||||
INPUT_TYPE_KEY: |
|
||||
if last_event is InputEventKey: |
|
||||
new_inputs[last_action]["key"] = OS.get_scancode_string(last_event.scancode) |
|
||||
INPUT_TYPE_JOYPAD: |
|
||||
if last_event is InputEventJoypadButton: |
|
||||
new_inputs[last_action]["joypad"] = last_event.button_index |
|
@ -0,0 +1,128 @@ |
|||||
|
extends Control |
||||
|
|
||||
|
onready var grid = find_node("grid") |
||||
|
onready var key_dialog = get_node("key_dialog") |
||||
|
|
||||
|
const INPUT_TYPE_KEY = 0 |
||||
|
const INPUT_TYPE_JOYPAD = 1 |
||||
|
|
||||
|
var last_action:String |
||||
|
var last_event:InputEvent |
||||
|
|
||||
|
var new_inputs = {} |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
init_mapping() |
||||
|
|
||||
|
|
||||
|
func apply(): |
||||
|
config.set_value("controls","mapping",new_inputs) |
||||
|
|
||||
|
|
||||
|
func init_mapping(): |
||||
|
new_inputs = {} |
||||
|
for action in config.CONTROL_ACTIONS: |
||||
|
var action_label = Label.new() |
||||
|
action_label.set_name(action + "_label") |
||||
|
action_label.set_text(action) |
||||
|
grid.add_child(action_label) |
||||
|
|
||||
|
var key_action_button = Button.new() |
||||
|
key_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
||||
|
key_action_button.set_flat(true) |
||||
|
key_action_button.set_meta("action",action) |
||||
|
key_action_button.set_button_icon(get_node("icons/key").get_button_icon()) |
||||
|
|
||||
|
var joypad_action_button = Button.new() |
||||
|
joypad_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
||||
|
joypad_action_button.set_flat(true) |
||||
|
joypad_action_button.set_meta("action",action) |
||||
|
|
||||
|
for event in InputMap.get_action_list(action): |
||||
|
if event is InputEventKey: |
||||
|
key_action_button.set_text(event.as_text()) |
||||
|
key_action_button.set_tooltip(event.as_text()) |
||||
|
elif event is InputEventJoypadButton: |
||||
|
joypad_action_button.set_tooltip(str(event.button_index)) |
||||
|
if has_node("icons/joypad/" + str(event.button_index)): |
||||
|
joypad_action_button.set_button_icon(get_node("icons/joypad/" + str(event.button_index)).get_button_icon()) |
||||
|
else: |
||||
|
joypad_action_button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
||||
|
joypad_action_button.set_text(str(event.button_index)) |
||||
|
|
||||
|
grid.add_child(key_action_button) |
||||
|
key_action_button.connect("pressed",self,"_on_button_pressed",[key_action_button, INPUT_TYPE_KEY]) |
||||
|
|
||||
|
grid.add_child(joypad_action_button) |
||||
|
joypad_action_button.connect("pressed",self,"_on_button_pressed",[joypad_action_button, INPUT_TYPE_JOYPAD]) |
||||
|
|
||||
|
|
||||
|
func _unhandled_input(event): |
||||
|
if key_dialog.is_visible_in_tree(): |
||||
|
var action_button = key_dialog.find_node("action_button") |
||||
|
var check_usage = false |
||||
|
if key_dialog.get_meta("type") == INPUT_TYPE_KEY && event is InputEventKey: |
||||
|
check_usage = true |
||||
|
last_event = event |
||||
|
action_button.set_button_icon(get_node("icons/key").get_button_icon()) |
||||
|
action_button.set_text(event.as_text()) |
||||
|
action_button.set_tooltip(event.as_text()) |
||||
|
elif key_dialog.get_meta("type") == INPUT_TYPE_JOYPAD && event is InputEventJoypadButton: |
||||
|
check_usage = true |
||||
|
last_event = event |
||||
|
action_button.set_tooltip(str(event.button_index)) |
||||
|
if has_node("icons/joypad/" + str(event.button_index)): |
||||
|
action_button.set_text("") |
||||
|
action_button.set_button_icon(get_node("icons/joypad/" + str(event.button_index)).get_button_icon()) |
||||
|
else: |
||||
|
action_button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
||||
|
action_button.set_text(str(event.button_index)) |
||||
|
|
||||
|
if check_usage: |
||||
|
var has_event = "" |
||||
|
for action in config.CONTROL_ACTIONS: |
||||
|
if InputMap.event_is_action(event, action): |
||||
|
has_event = action |
||||
|
|
||||
|
if not has_event == "" && not has_event == last_action: |
||||
|
key_dialog.set_text(tr("KEY_ALREADY_TAKEN") + '\n\'' + tr(has_event) + '\'') |
||||
|
key_dialog.get_ok().set_disabled(true) |
||||
|
else: |
||||
|
key_dialog.set_text(tr("PRESS_KEY")) |
||||
|
key_dialog.get_ok().set_disabled(false) |
||||
|
|
||||
|
|
||||
|
func _on_button_pressed(button, type): |
||||
|
last_action = button.get_meta("action") |
||||
|
last_event = null |
||||
|
|
||||
|
var action_button = key_dialog.find_node("action_button") |
||||
|
action_button.set_text("") |
||||
|
action_button.set_button_icon(null) |
||||
|
key_dialog.set_text(tr("PRESS_KEY")) |
||||
|
key_dialog.set_meta("type", type) |
||||
|
key_dialog.connect("confirmed",self,"_on_dialog_confirmed",[button]) |
||||
|
key_dialog.get_ok().set_disabled(true) |
||||
|
key_dialog.get_label().set_align(HALIGN_CENTER) |
||||
|
key_dialog.popup_centered() |
||||
|
|
||||
|
|
||||
|
func _on_dialog_confirmed(button): |
||||
|
if not new_inputs.has(last_action): |
||||
|
new_inputs[last_action] = {} |
||||
|
match key_dialog.get_meta("type"): |
||||
|
INPUT_TYPE_KEY: |
||||
|
if last_event is InputEventKey: |
||||
|
new_inputs[last_action]["key"] = OS.get_scancode_string(last_event.scancode) |
||||
|
button.set_text(last_event.as_text()) |
||||
|
button.set_tooltip(last_event.as_text()) |
||||
|
INPUT_TYPE_JOYPAD: |
||||
|
if last_event is InputEventJoypadButton: |
||||
|
new_inputs[last_action]["joypad"] = last_event.button_index |
||||
|
button.set_tooltip(str(last_event.button_index)) |
||||
|
if has_node("icons/joypad/" + str(last_event.button_index)): |
||||
|
button.set_button_icon(get_node("icons/joypad/" + str(last_event.button_index)).get_button_icon()) |
||||
|
else: |
||||
|
button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
||||
|
button.set_text(str(last_event.button_index)) |
@ -0,0 +1,17 @@ |
|||||
|
extends Tabs |
||||
|
|
||||
|
onready var player_settings = find_node("settings_player") |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
# game |
||||
|
find_node("bots").set_pressed(config.get_value("game","bots", true)) |
||||
|
find_node("bot_difficulty").set_value(config.get_value("game","bot_difficulty", gamestate.DEFAULT_BOT_DIFFICULTY)) |
||||
|
find_node("bot_difficulty").set_tooltip(tr("BOT_DIFFICULTY")) |
||||
|
|
||||
|
|
||||
|
func apply(): |
||||
|
config.set_value("game","player_name",player_settings.get_name_node().get_text()) |
||||
|
config.set_value("game","player_color",player_settings.get_color_node().color) |
||||
|
config.set_value("game","bots",find_node("bots").is_pressed()) |
||||
|
config.set_value("game","bot_difficulty",find_node("bot_difficulty").get_value()) |
@ -0,0 +1,24 @@ |
|||||
|
extends Tabs |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
find_node("fullscreen").set_pressed(config.get_value("graphics","fullscreen", true)) |
||||
|
find_node("light").set_pressed(config.get_value("graphics","light", false)) |
||||
|
find_node("shadows").set_pressed(config.get_value("graphics","shadows", false)) |
||||
|
find_node("shadows").set_disabled(not find_node("light").is_pressed()) |
||||
|
|
||||
|
for resolution in config.RESOLUTIONS: |
||||
|
find_node("resolution").add_item(str(resolution.x) + " * " + str(resolution.y)) |
||||
|
|
||||
|
find_node("resolution").select(config.RESOLUTIONS.find(config.get_value("graphics","resolution", config.RESOLUTIONS[0]))) |
||||
|
|
||||
|
|
||||
|
func apply(): |
||||
|
config.set_value("graphics","resolution",config.RESOLUTIONS[find_node("resolution").get_selected()]) |
||||
|
config.set_value("graphics","fullscreen",find_node("fullscreen").is_pressed()) |
||||
|
config.set_value("graphics","light",find_node("light").is_pressed()) |
||||
|
config.set_value("graphics","shadows",find_node("shadows").is_pressed()) |
||||
|
|
||||
|
|
||||
|
func _on_light_toggled(button_pressed): |
||||
|
find_node("shadows").set_disabled(not button_pressed) |
@ -0,0 +1,46 @@ |
|||||
|
extends Control |
||||
|
|
||||
|
onready var game_tab = find_node("game") |
||||
|
onready var controls_tab = find_node("controls") |
||||
|
onready var graphics_tab = find_node("graphics") |
||||
|
onready var system_tab = find_node("system") |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
get_node("menu/back").connect("pressed",self,"_on_back_pressed") |
||||
|
system_tab.connect("locale_changed", self, "on_locale_changed") |
||||
|
|
||||
|
|
||||
|
func _draw(): |
||||
|
game_tab.grab_focus() |
||||
|
|
||||
|
|
||||
|
func _on_back_pressed(): |
||||
|
queue_free() |
||||
|
if get_parent().has_node("ingame_menu"): |
||||
|
get_parent().get_node("ingame_menu").show() |
||||
|
get_tree().get_root().get_node("main_menu").hide() |
||||
|
elif get_tree().get_root().has_node("main_menu"): |
||||
|
get_tree().get_root().get_node("main_menu").show() |
||||
|
|
||||
|
|
||||
|
func on_locale_changed(): |
||||
|
game_tab.set_name(tr("GAME")) |
||||
|
controls_tab.set_name(tr("CONTROLS")) |
||||
|
graphics_tab.set_name(tr("GRAPHICS")) |
||||
|
system_tab.set_name(tr("SYSTEM")) |
||||
|
|
||||
|
|
||||
|
func _on_save_pressed(): |
||||
|
_on_apply_pressed() |
||||
|
_on_back_pressed() |
||||
|
|
||||
|
|
||||
|
func _on_apply_pressed(): |
||||
|
game_tab.apply() |
||||
|
graphics_tab.apply() |
||||
|
controls_tab.apply() |
||||
|
system_tab.apply() |
||||
|
|
||||
|
config.save() |
||||
|
config_apply.apply_settings() |
@ -1,14 +0,0 @@ |
|||||
extends Control |
|
||||
|
|
||||
|
|
||||
func _ready(): |
|
||||
get_name_node().set_text(local_storage.read_value("player_name", "Player")) |
|
||||
get_color_node().set_pick_color(Color(local_storage.read_value("player_color", "#000000"))) |
|
||||
|
|
||||
|
|
||||
func get_name_node(): |
|
||||
return find_node("name") |
|
||||
|
|
||||
|
|
||||
func get_color_node(): |
|
||||
return find_node("color") |
|
@ -0,0 +1,14 @@ |
|||||
|
extends Control |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
get_name_node().set_text(config.get_value("game","player_name", "Player")) |
||||
|
get_color_node().set_pick_color(config.get_value("game","player_color", Color.black)) |
||||
|
|
||||
|
|
||||
|
func get_name_node(): |
||||
|
return find_node("name") |
||||
|
|
||||
|
|
||||
|
func get_color_node(): |
||||
|
return find_node("color") |
@ -0,0 +1,55 @@ |
|||||
|
extends Tabs |
||||
|
|
||||
|
var locale |
||||
|
|
||||
|
signal locale_changed() |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
find_node("server_addr").set_text(game_server.get_server_addr()) |
||||
|
find_node("api_addr").set_text(game_server.get_api_addr()) |
||||
|
_init_locales() |
||||
|
|
||||
|
|
||||
|
func apply(): |
||||
|
config.set_value("system","locale",locale) |
||||
|
var server_addr = find_node("server_addr").get_text() |
||||
|
if server_addr.empty(): |
||||
|
server_addr = game_server.SERVER_ADDR |
||||
|
config.set_value("system","server_addr",server_addr) |
||||
|
|
||||
|
var api_addr = find_node("api_addr").get_text() |
||||
|
if api_addr.empty(): |
||||
|
api_addr = game_server.API_ADDR |
||||
|
config.set_value("system","api_addr",api_addr) |
||||
|
|
||||
|
|
||||
|
func _on_locales_item_selected(index): |
||||
|
match index: |
||||
|
0: |
||||
|
locale = "en" |
||||
|
1: |
||||
|
locale = "de" |
||||
|
_: |
||||
|
locale = "en" |
||||
|
TranslationServer.set_locale(locale) |
||||
|
emit_signal("locale_changed") |
||||
|
|
||||
|
|
||||
|
func _init_locales(): |
||||
|
var locales = find_node("locales") |
||||
|
locales.clear() |
||||
|
locales.add_item(tr("LOCALE_EN")) |
||||
|
locales.add_item(tr("LOCALE_DE")) |
||||
|
locale = config.get_value("system","locale","en") |
||||
|
match locale: |
||||
|
"en": |
||||
|
locales.select(0) |
||||
|
_on_locales_item_selected(0) |
||||
|
"de": |
||||
|
locales.select(1) |
||||
|
_on_locales_item_selected(1) |
||||
|
|
||||
|
|
||||
|
func _on_system_settings_menu_tree_exiting(): |
||||
|
config_apply.apply_locale() |
@ -0,0 +1,53 @@ |
|||||
|
extends Node |
||||
|
|
||||
|
export(float) var frames_per_second = 5.0 |
||||
|
|
||||
|
var is_active:bool = false |
||||
|
var is_saving:bool = false |
||||
|
|
||||
|
var _frametick = 1.0/frames_per_second |
||||
|
var _thread:Thread |
||||
|
|
||||
|
var images = [] |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
_thread = Thread.new() |
||||
|
|
||||
|
|
||||
|
func _process(delta): |
||||
|
if Input.is_action_just_pressed("controls_capture") && not is_saving: |
||||
|
is_active = not is_active |
||||
|
find_node("recording").set_visible(is_active) |
||||
|
if not is_active: |
||||
|
is_saving = true |
||||
|
find_node("saving").set_visible(true) |
||||
|
_thread.start(self, "save_images") |
||||
|
if is_active: |
||||
|
_frametick += delta |
||||
|
if (_frametick > 1.0/frames_per_second): |
||||
|
get_viewport().set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME) |
||||
|
var img = get_viewport().get_texture().get_data() |
||||
|
img.flip_y() |
||||
|
images.append(img) |
||||
|
|
||||
|
|
||||
|
func save_images(userdata): |
||||
|
var dir = Directory.new() |
||||
|
var timestamp = OS.get_unix_time() |
||||
|
if dir.open("user://capture/") != OK: |
||||
|
dir.open("user://") |
||||
|
dir.make_dir("capture") |
||||
|
|
||||
|
dir.open("user://capture/") |
||||
|
dir.make_dir(str(timestamp)) |
||||
|
|
||||
|
for img in images: |
||||
|
img.save_png("user://capture/" + str(timestamp) + "/" + str(img) + ".png") |
||||
|
|
||||
|
images = [] |
||||
|
is_saving = false |
||||
|
find_node("saving").set_visible(false) |
||||
|
|
||||
|
if(_thread.is_active()): |
||||
|
_thread.wait_to_finish() |
@ -0,0 +1,36 @@ |
|||||
|
extends Node |
||||
|
|
||||
|
var random_number_generator:RandomNumberGenerator = RandomNumberGenerator.new() |
||||
|
|
||||
|
|
||||
|
func _ready(): |
||||
|
random_number_generator.randomize() |
||||
|
|
||||
|
|
||||
|
func randf(): |
||||
|
return random_number_generator.randf() |
||||
|
|
||||
|
|
||||
|
func randf_range (from:float, to:float ): |
||||
|
return random_number_generator.randf_range(from,to) |
||||
|
|
||||
|
|
||||
|
func randfn (mean:float=0.0, deviation:float=1.0 ): |
||||
|
return random_number_generator.randfn(mean, deviation) |
||||
|
|
||||
|
|
||||
|
func randi(): |
||||
|
return random_number_generator.randi() |
||||
|
|
||||
|
|
||||
|
func randi_range ( from:int, to:int ): |
||||
|
return random_number_generator.randi_range( from, to) |
||||
|
|
||||
|
|
||||
|
func clear_node(node:Node): |
||||
|
for idx in range(node.get_child_count()): |
||||
|
node.remove_child(node.get_child(0)) |
||||
|
|
||||
|
|
||||
|
func curve_get_last_point(curve:Curve3D): |
||||
|
return curve.get_point_position(curve.get_point_count() - 1) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue