No commits in common. '86a12fd6fd7df13d16b2f1527e26cbb70077a9ae' and 'cafd838dfccbc6f0a3de27c4b0eec0aadaaabee8' have entirely different histories.

  1. 2
      .gitignore
  2. 42
      ext/server.py
  3. 33
      project.godot
  4. 138
      resources/ui/i18n.csv
  5. BIN
      resources/ui/i18n.de.translation
  6. BIN
      resources/ui/i18n.en.translation
  7. 9
      resources/ui/theme.tres
  8. 15
      scenes/menus/BaseMenu.tscn
  9. 12
      scenes/menus/DirectHostMenu.tscn
  10. 3
      scenes/menus/DirectJoinMenu.tscn
  11. 20
      scenes/menus/IngameMenu.tscn
  12. 8
      scenes/menus/LobbyMenu.tscn
  13. 22
      scenes/menus/LocalGameMenu.tscn
  14. 38
      scenes/menus/MainMenu.tscn
  15. 24
      scenes/menus/MultiplayerMenu.tscn
  16. 11
      scenes/menus/ServerCreateGameMenu.tscn
  17. 34
      scenes/menus/SettingsControlsMenu.tscn
  18. 163
      scenes/menus/SettingsMenu.tscn
  19. 13
      scenes/menus/SettingsPlayerMenu.tscn
  20. 47
      scenes/menus/SettingsSystemMenu.tscn
  21. 24
      scenes/player/HumanPlayer.tscn
  22. 1
      scenes/player/Player.tscn
  23. 2
      scenes/road/roadCornerLarge.tscn
  24. 4
      scenes/road/roadCornerLargeFlipped.tscn
  25. 4
      scenes/road/roadCornerLarger.tscn
  26. 4
      scenes/road/roadCornerLargerFlipped.tscn
  27. 6
      scenes/road/roadCornerSmall.tscn
  28. 6
      scenes/road/roadCornerSmallFlipped.tscn
  29. 2
      scenes/road/roadRamp.tscn
  30. 2
      scenes/road/roadRampFlipped.tscn
  31. 4
      scenes/road/roadRampLong.tscn
  32. 2
      scenes/road/roadRampLongCurved.tscn
  33. 2
      scenes/road/roadRampLongFlipped.tscn
  34. 30
      scripts/Util.gd
  35. 28
      scripts/game/config.gd
  36. 62
      scripts/game/config_apply.gd
  37. 3
      scripts/game/game.gd
  38. 28
      scripts/game/gamestate.gd
  39. 58
      scripts/game/local_storage.gd
  40. 13
      scripts/game/route.gd
  41. 10
      scripts/menus/direct_host_menu.gd
  42. 4
      scripts/menus/direct_join_menu.gd
  43. 10
      scripts/menus/ingame_menu.gd
  44. 14
      scripts/menus/lobby_menu.gd
  45. 2
      scripts/menus/local_game.gd
  46. 2
      scripts/menus/main_menu.gd
  47. 10
      scripts/menus/server_create_menu.gd
  48. 2
      scripts/menus/server_menu.gd
  49. 67
      scripts/menus/settings.gd
  50. 89
      scripts/menus/settings_controls.gd
  51. 124
      scripts/menus/settings_controls_menu.gd
  52. 116
      scripts/menus/settings_menu.gd
  53. 14
      scripts/menus/settings_player.gd
  54. 14
      scripts/menus/settings_player_menu.gd
  55. 33
      scripts/networking/game_server.gd
  56. 8
      scripts/networking/game_server_requests.gd
  57. 21
      scripts/networking/server.gd
  58. 18
      scripts/player/base_inventory.gd
  59. 61
      scripts/player/bot_controls.gd
  60. 27
      scripts/player/human_controls.gd
  61. 8
      scripts/player/human_inventory.gd
  62. 51
      scripts/player/player.gd
  63. 25
      scripts/road/road.gd

2
.gitignore

@ -5,6 +5,7 @@ export_presets.cfg
dist/ dist/
*.import *.import
*.translation
# Mono-specific ignores # Mono-specific ignores
.mono/ .mono/
@ -12,3 +13,4 @@ dist/
# System/tool-specific ignores # System/tool-specific ignores
.directory .directory
*~ *~
.~lock*

42
ext/server.py

@ -5,13 +5,18 @@ import secrets
from flask import Flask, abort, request, jsonify from flask import Flask, abort, request, jsonify
START_PORT = 8128 START_PORT = 8128
GAME_EXEC = '/opt/godot/Godot_v3.1.1-stable_linux_server.64'
MAX_GAMES = 10
GAME_EXEC = 'godot_server'
GAME_EXEC_ARG_PACK = '--main-pack' GAME_EXEC_ARG_PACK = '--main-pack'
GAME_EXEC_ARG_PACK_PATH = '/opt/godot/Muffrace Pre Alpha.pck'
GAME_EXEC_ARG_PACK_PATH = '/opt/godot/MUR.pck'
GAME_EXEC_ARG_PORT = '--port={0}' GAME_EXEC_ARG_PORT = '--port={0}'
GAME_EXEC_ARG_ID = '--server-id={0}' GAME_EXEC_ARG_ID = '--server-id={0}'
GAME_EXEC_ARG_SECRET = '--secret={0}' GAME_EXEC_ARG_SECRET = '--secret={0}'
GAME_EXEC_ARG_BOTS = '--bots={0}' GAME_EXEC_ARG_BOTS = '--bots={0}'
GAME_EXEC_ARG_SERVER_ADDR = '--server-addr={0}'
GAME_EXEC_ARG_API_ADDR = '--api-addr={0}'
games = {} games = {}
try: try:
@ -41,6 +46,7 @@ def create_game():
if 'bots' in request.json: if 'bots' in request.json:
bots = request.json.get('bots') bots = request.json.get('bots')
game_count = 0
try: try:
with sqlite3.connect("database.db") as con: with sqlite3.connect("database.db") as con:
# check free port # check free port
@ -50,9 +56,13 @@ def create_game():
rows = cur.fetchall() rows = cur.fetchall()
while rows: while rows:
port += 1 port += 1
game_count += 1
cur.execute("SELECT * FROM games WHERE port=?", (port,)) cur.execute("SELECT * FROM games WHERE port=?", (port,))
rows = cur.fetchall() rows = cur.fetchall()
if game_count >= MAX_GAMES:
return
# check duplicate name # check duplicate name
base_name = name base_name = name
base_name_count = 1 base_name_count = 1
@ -66,20 +76,38 @@ def create_game():
# gen secret # gen secret
secret = secrets.token_hex(32) secret = secrets.token_hex(32)
cur.execute("INSERT INTO games (name,secret,ip,port,bots,running) VALUES (?,?,?,?,?,0)",
(name, secret, request.remote_addr, port, bots))
remote_addr = request.remote_addr
if 'X-Forwarded-For' in request.headers:
remote_addr = request.headers.getlist(
"X-Forwarded-For")[0].rpartition(' ')[-1]
cur.execute("INSERT INTO games (name,secret,ip,port,bots,player_count,running) VALUES (?,?,?,?,?,0,0)",
(name, secret, remote_addr, port, bots))
con.commit() con.commit()
cur.execute("SELECT id FROM games WHERE secret=?", cur.execute("SELECT id FROM games WHERE secret=?",
(secret,)) (secret,))
result = cur.fetchone() result = cur.fetchone()
if result[0]: if result[0]:
games[result[0]] = subprocess.Popen([GAME_EXEC, GAME_EXEC_ARG_PACK, GAME_EXEC_ARG_PACK_PATH, GAME_EXEC_ARG_ID.format(int(result[0])), GAME_EXEC_ARG_PORT.format(
port), GAME_EXEC_ARG_SECRET.format(secret), GAME_EXEC_ARG_BOTS.format(int(bots))])
games[result[0]] = subprocess.Popen([GAME_EXEC,
GAME_EXEC_ARG_PACK, GAME_EXEC_ARG_PACK_PATH,
GAME_EXEC_ARG_ID.format(
int(result[0])),
GAME_EXEC_ARG_PORT.format(
port),
GAME_EXEC_ARG_SECRET.format(
secret),
GAME_EXEC_ARG_BOTS.format(
int(bots)),
GAME_EXEC_ARG_SERVER_ADDR.format(
'127.0.0.1'), # localhost
GAME_EXEC_ARG_API_ADDR.format('http://127.0.0.1:5000/')])
except: except:
con.rollback() con.rollback()
abort(500) abort(500)
finally: finally:
con.close() con.close()
if game_count >= MAX_GAMES:
abort(403)
return jsonify({'name': name, 'port': port}) return jsonify({'name': name, 'port': port})
@ -168,4 +196,4 @@ def close_game():
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True)
app.run(debug=True, host='0.0.0.0', port=5000)

33
project.godot

@ -53,11 +53,6 @@ _global_script_classes=[ {
"class": "TracksFactory", "class": "TracksFactory",
"language": "GDScript", "language": "GDScript",
"path": "res://scripts/road/roads_factory.gd" "path": "res://scripts/road/roads_factory.gd"
}, {
"base": "Node",
"class": "Util",
"language": "GDScript",
"path": "res://scripts/Util.gd"
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"BaseInventory": "", "BaseInventory": "",
@ -68,13 +63,12 @@ _global_script_class_icons={
"Preview": "", "Preview": "",
"Road": "", "Road": "",
"Route": "", "Route": "",
"TracksFactory": "",
"Util": ""
"TracksFactory": ""
} }
[application] [application]
config/name="MUR (public)"
config/name="MUR_pre_alpha"
run/main_scene="res://scenes/menus/MainMenu.tscn" run/main_scene="res://scenes/menus/MainMenu.tscn"
boot_splash/fullsize=false boot_splash/fullsize=false
config/icon="res://icon.png" config/icon="res://icon.png"
@ -86,8 +80,17 @@ client="*res://scripts/networking/client.gd"
server="*res://scripts/networking/server.gd" server="*res://scripts/networking/server.gd"
game_server="*res://scripts/networking/game_server.gd" game_server="*res://scripts/networking/game_server.gd"
roads_factory="*res://scripts/road/roads_factory.gd" roads_factory="*res://scripts/road/roads_factory.gd"
local_storage="*res://scripts/game/local_storage.gd"
Util="*res://scripts/Util.gd"
config="*res://scripts/game/config.gd"
config_apply="*res://scripts/game/config_apply.gd"
util="*res://scripts/Util.gd"
[display]
window/size/width=1920
window/size/height=1080
window/size/resizable=false
window/stretch/mode="2d"
window/stretch/aspect="expand"
[input] [input]
@ -112,7 +115,7 @@ controls_break={
controls_add_road={ controls_add_road={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":5,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":4,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
controls_next_road_type={ controls_next_road_type={
@ -142,7 +145,7 @@ controls_prev_road_variant={
controls_reset={ controls_reset={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":4,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
debug_camera_1={ debug_camera_1={
@ -165,6 +168,12 @@ debug_camera_4={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":52,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":52,"unicode":0,"echo":false,"script":null)
] ]
} }
controls_menu={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
]
}
[layer_names] [layer_names]

138
resources/ui/i18n.csv

@ -1,45 +1,52 @@
,en,de ,en,de
BACK,back,Zurück
MULTIPLAYER,multiplayer,Multiplayer
PRACTISE,practise,Training
SETTINGS,settings,Einstellungen
DEBUG,debug EN,Debug DE
HOST,host,Host
JOIN,join,Beitreten
QUIT,quit,Beenden
DIRECT_HOST,direct host,Direkt hosten
DIRECT_JOIN,direct join,Direkt beitreten
OPEN_GAMES_ONLY,open games only,Nur offene Spiele
REFRESH,refresh,Aktualisieren
CREATE_GAME,create game,Spiel erstellen
PLAYER_NAME,name,Name
PLAYER_COLOR,color,Farbe
BOTS,bots,Bots
GAME,game,Spiel
PORT,port,Port
IP,IP,IP
RESUME,resume,Fortsetzen
END_GAME,end game,Spiel beenden
START_GAME,start game,Spiel starten
GAME_NAME,name,Name
READY,ready,Bereit
BACK,Back,Zurück
MULTIPLAYER,Multiplayer,Multiplayer
PRACTISE,Practise,Training
SETTINGS,Settings,Einstellungen
DEBUG,Debug en,Debug DE
HOST,Host,Host
JOIN,Join,Beitreten
QUIT,Quit,Beenden
DIRECT_HOST,Direct host,Direkt hosten
DIRECT_JOIN,Direct join,Direkt beitreten
OPEN_GAMES_ONLY,Open games only,Nur offene Spiele
REFRESH,Refresh,Aktualisieren
CREATE_GAME,Create game,Spiel erstellen
PLAYER_NAME,Name,Name
PLAYER_COLOR,Color,Farbe
BOTS,Bots,Bots
GAME,Game,Spiel
PORT,Port,Port
IP,Ip,IP
RESUME,Resume,Fortsetzen
END_GAME,End game,Spiel beenden
START_GAME,Start game,Spiel starten
GAME_NAME,Name,Name
READY,Ready,Bereit
ALERT,Alert!,Fehler! ALERT,Alert!,Fehler!
CONTROLS,controls,Steuerung
RESET,reset,Zurücksetzen
CONTROLS,Controls,Steuerung
RESET,Reset,Zurücksetzen
PRESS_KEY,Press any key...,Taste drücken… PRESS_KEY,Press any key...,Taste drücken…
ERROR_SERVER_CREATION,Cannot create Server!,Server konnte nicht erstellt werden!
INVALID_IP4,Invalid IPv4 address!,Ungültige IPv4 Adresse!
KEY_ALREADY_TAKEN,Key already in use:,Taste wird bereits verwendet:
ERROR_SERVER_CREATION,Cannot create server!,Server konnte nicht erstellt werden!
ERROR_GAME_CREATION,"Cannot create game!
(Server full or blocked?)","Spiel konnte nicht erstellt werden!
(Server voll oder blockiert?)"
INVALID_IP4,Invalid ipv4 address!,Ungültige IPv4 Adresse!
SERVER_DISCONNECTED,Server disconnected!,Serververbindung getrennt! SERVER_DISCONNECTED,Server disconnected!,Serververbindung getrennt!
SERVER_NO_CONNECTION,No connection to server!,Keine Verbindung zu Server! SERVER_NO_CONNECTION,No connection to server!,Keine Verbindung zu Server!
CONNECTION_FAILED,Connection failed!,Verbindung fehlgeschlagen! CONNECTION_FAILED,Connection failed!,Verbindung fehlgeschlagen!
SYSTEM,system,System
LOCALE,language,Sprache
LOCALE_EN,english,Englisch (english)
LOCALE_DE,german (Deutsch),Deutsch
GRAPHICS,graphics,Grafik
SAVE,save,Speichern
KEYBOARD,keyboard,Tastatur
JOYPAD,joypad,Joypad
SYSTEM,System,System
LOCALE,Language,Sprache
LOCALE_EN,English,Englisch (english)
LOCALE_DE,German (deutsch),Deutsch
GRAPHICS,Graphics,Grafik
SAVE,Save,Speichern
APPLY,Apply,Übernehmen
KEYBOARD,Keyboard,Tastatur
JOYPAD,Joypad,Joypad
SERVER_ADDR,Server address,Server Adresse
API_ADDR,API adress,API Adresse
Up,,Hoch Up,,Hoch
Down,,Runter Down,,Runter
Left,,Links Left,,Links
@ -53,33 +60,34 @@ Delete,,Entf
Home,,Pos 1 Home,,Pos 1
End,,Ende End,,Ende
,, ,,
StraightLong,straight,Gerade
Straight,short straight,kurze Gerade
CornerLarge,right corner,Rechtskurve
CornerLargeFlipped,left corner,Linkskurve
CornerLarger,long right corner,lange Rechtskurve
CornerLargerFlipped,long left corner,lange Linkskurve
CornerSmall,short right corner,kurze Rechtskurve
CornerSmallFlipped,short left corner,kurze Linkskurve
StraightLongBump,bump,Bodenwelle
Bump,small bump,kurze Bodenwelle
StraightSkew,right skew,rechte Schräge
StraightSkewFlipped,left skew,linke Schräge
RampLong,ramp up,Rampe hoch
RampLongFlipped,ramp down,Rampe runter
RampLongCurved,curved ramp up,Rundung hoch
RampLongCurvedFlipped,curved ramp down,Rundung runter
Ramp,short ramp up,kurze Rampe hoch
RampFlipped,short ramp down,kurze Rampe runter
CurvedFlipped,shicane right,Schikane rechts
Curved,shicane left,Schikane links
Loop,looping,Looping
StraightLong,Straight,Gerade
Straight,Short straight,kurze Gerade
CornerLarge,Right corner,Rechtskurve
CornerLargeFlipped,Left corner,Linkskurve
CornerLarger,Long right corner,lange Rechtskurve
CornerLargerFlipped,Long left corner,lange Linkskurve
CornerSmall,Short right corner,kurze Rechtskurve
CornerSmallFlipped,Short left corner,kurze Linkskurve
StraightLongBump,Bump,Bodenwelle
Bump,Small bump,kurze Bodenwelle
StraightSkew,Right skew,rechte Schräge
StraightSkewFlipped,Left skew,linke Schräge
RampLong,Ramp up,Rampe hoch
RampLongFlipped,Ramp down,Rampe runter
RampLongCurved,Curved ramp up,Rundung hoch
RampLongCurvedFlipped,Curved ramp down,Rundung runter
Ramp,Short ramp up,kurze Rampe hoch
RampFlipped,Short ramp down,kurze Rampe runter
CurvedFlipped,Shicane right,Schikane rechts
Curved,Shicane left,Schikane links
Loop,Looping,Looping
,, ,,
controls_thrust,thrust,Beschleunigen
controls_break,break,Bremsen
controls_add_road,add,Setzen
controls_next_road_type,next type,Nächste Kategorie
controls_prev_road_type,previous type,Vorherige Kategorie
controls_next_road_variant,next variant,Nächste Variante
controls_prev_road_variant,previous variant,Vorherige Variante
controls_reset,reset,Zurücksetzen
controls_thrust,Thrust,Beschleunigen
controls_break,Break,Bremsen
controls_add_road,Add,Setzen
controls_next_road_type,Next type,Nächste Kategorie
controls_prev_road_type,Previous type,Vorherige Kategorie
controls_next_road_variant,Next variant,Nächste Variante
controls_prev_road_variant,Previous variant,Vorherige Variante
controls_reset,Reset,Zurücksetzen
controls_menu,Menu,Menu

BIN
resources/ui/i18n.de.translation

BIN
resources/ui/i18n.en.translation

9
resources/ui/theme.tres

@ -1,7 +1,10 @@
[gd_resource type="Theme" load_steps=2 format=2]
[gd_resource type="Theme" load_steps=3 format=2]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=1] [ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=1]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.184314, 0.188235, 0.211765, 1 )
[resource] [resource]
default_font = ExtResource( 1 ) default_font = ExtResource( 1 )
Button/colors/font_color = Color( 0.878431, 0.878431, 0.878431, 1 ) Button/colors/font_color = Color( 0.878431, 0.878431, 0.878431, 1 )
@ -15,6 +18,8 @@ Button/styles/focus = null
Button/styles/hover = null Button/styles/hover = null
Button/styles/normal = null Button/styles/normal = null
Button/styles/pressed = null Button/styles/pressed = null
Icons/icons/close = null
Icons/icons/logo = null
ItemList/colors/font_color = Color( 0.627451, 0.627451, 0.627451, 1 ) ItemList/colors/font_color = Color( 0.627451, 0.627451, 0.627451, 1 )
ItemList/colors/font_color_selected = Color( 1, 1, 1, 1 ) ItemList/colors/font_color_selected = Color( 1, 1, 1, 1 )
ItemList/colors/guide_color = Color( 0, 0, 0, 0.1 ) ItemList/colors/guide_color = Color( 0, 0, 0, 0.1 )
@ -29,6 +34,6 @@ ItemList/styles/cursor = null
ItemList/styles/cursor_unfocused = null ItemList/styles/cursor_unfocused = null
ItemList/styles/selected = null ItemList/styles/selected = null
ItemList/styles/selected_focus = null ItemList/styles/selected_focus = null
Panel/styles/panel = null
Panel/styles/panel = SubResource( 1 )
Panel/styles/panelf = null Panel/styles/panelf = null
Panel/styles/panelnc = null Panel/styles/panelnc = null

15
scenes/menus/BaseMenu.tscn

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=1]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=2]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=3]
[node name="menu" type="Panel"] [node name="menu" type="Panel"]
anchor_left = 0.5 anchor_left = 0.5
@ -17,13 +18,17 @@ grow_vertical = 2
rect_clip_content = true rect_clip_content = true
size_flags_horizontal = 6 size_flags_horizontal = 6
size_flags_vertical = 6 size_flags_vertical = 6
theme = ExtResource( 1 )
[node name="back" type="Button" parent="."] [node name="back" type="Button" parent="."]
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_top = -56.0 margin_top = -56.0
margin_right = 132.0 margin_right = 132.0
custom_fonts/font = ExtResource( 1 )
size_flags_horizontal = 6
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "BACK" text = "BACK"
icon = ExtResource( 2 )
icon = ExtResource( 3 )
flat = true flat = true
align = 0

12
scenes/menus/DirectHostMenu.tscn

@ -1,11 +1,12 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/direct_host.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/direct_host_menu.gd" type="Script" id=2]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3] [ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3]
[ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4] [ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=5] [ext_resource path="res://assets/icons/return.png" type="Texture" id=5]
[node name="direct_host_menu" type="Control"] [node name="direct_host_menu" type="Control"]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
@ -30,20 +31,19 @@ margin_bottom = 53.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="GridContainer" type="GridContainer" parent="menu"]
[node name="HBoxContainer" type="HBoxContainer" parent="menu"]
margin_left = 16.0 margin_left = 16.0
margin_top = 12.0 margin_top = 12.0
margin_right = 429.0 margin_right = 429.0
margin_bottom = 52.0 margin_bottom = 52.0
columns = 3
[node name="port_label" type="Label" parent="menu/GridContainer"]
[node name="port_label" type="Label" parent="menu/HBoxContainer"]
margin_top = 6.0 margin_top = 6.0
margin_right = 65.0 margin_right = 65.0
margin_bottom = 33.0 margin_bottom = 33.0
text = "PORT" text = "PORT"
[node name="port" type="SpinBox" parent="menu/GridContainer"]
[node name="port" type="SpinBox" parent="menu/HBoxContainer"]
margin_left = 69.0 margin_left = 69.0
margin_right = 266.0 margin_right = 266.0
margin_bottom = 40.0 margin_bottom = 40.0
@ -54,7 +54,7 @@ max_value = 65535.0
value = 8128.0 value = 8128.0
align = 2 align = 2
[node name="bots" type="CheckButton" parent="menu/GridContainer"]
[node name="bots" type="CheckButton" parent="menu/HBoxContainer"]
margin_left = 270.0 margin_left = 270.0
margin_right = 413.0 margin_right = 413.0
margin_bottom = 40.0 margin_bottom = 40.0

3
scenes/menus/DirectJoinMenu.tscn

@ -1,11 +1,12 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/direct_join.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/direct_join_menu.gd" type="Script" id=2]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3] [ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3]
[ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4] [ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=5] [ext_resource path="res://assets/icons/return.png" type="Texture" id=5]
[node name="direct_join_menu" type="Control"] [node name="direct_join_menu" type="Control"]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5

20
scenes/menus/IngameMenu.tscn

@ -1,7 +1,7 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/ingame.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/ingame_menu.gd" type="Script" id=2]
[ext_resource path="res://assets/icons/open.png" type="Texture" id=3] [ext_resource path="res://assets/icons/open.png" type="Texture" id=3]
[ext_resource path="res://assets/icons/wrench.png" type="Texture" id=4] [ext_resource path="res://assets/icons/wrench.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/arrowLeft.png" type="Texture" id=5] [ext_resource path="res://assets/icons/arrowLeft.png" type="Texture" id=5]
@ -26,11 +26,11 @@ margin_bottom = 100.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="GridContainer" type="GridContainer" parent="menu"]
[node name="VBoxContainer" type="VBoxContainer" parent="menu"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
[node name="resume" type="Button" parent="menu/GridContainer"]
[node name="resume" type="Button" parent="menu/VBoxContainer"]
margin_right = 310.0 margin_right = 310.0
margin_bottom = 64.0 margin_bottom = 64.0
focus_neighbour_top = NodePath("../end") focus_neighbour_top = NodePath("../end")
@ -41,7 +41,7 @@ text = "RESUME"
icon = ExtResource( 3 ) icon = ExtResource( 3 )
flat = true flat = true
[node name="settings" type="Button" parent="menu/GridContainer"]
[node name="settings" type="Button" parent="menu/VBoxContainer"]
margin_top = 68.0 margin_top = 68.0
margin_right = 310.0 margin_right = 310.0
margin_bottom = 132.0 margin_bottom = 132.0
@ -53,17 +53,17 @@ text = "SETTINGS"
icon = ExtResource( 4 ) icon = ExtResource( 4 )
flat = true flat = true
[node name="end" type="Button" parent="menu/GridContainer"]
[node name="end" type="Button" parent="menu/VBoxContainer"]
margin_top = 136.0 margin_top = 136.0
margin_right = 310.0 margin_right = 310.0
margin_bottom = 200.0
margin_bottom = 201.0
focus_neighbour_top = NodePath("../settings") focus_neighbour_top = NodePath("../settings")
focus_neighbour_bottom = NodePath(".")
focus_neighbour_bottom = NodePath("../resume")
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
text = "END_GAME" text = "END_GAME"
icon = ExtResource( 5 ) icon = ExtResource( 5 )
flat = true flat = true
[connection signal="pressed" from="menu/GridContainer/resume" to="." method="_on_resume_pressed"]
[connection signal="pressed" from="menu/GridContainer/settings" to="." method="_on_settings_pressed"]
[connection signal="pressed" from="menu/GridContainer/end" to="." method="_on_end_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/resume" to="." method="_on_resume_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/settings" to="." method="_on_settings_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/end" to="." method="_on_end_pressed"]

8
scenes/menus/LobbyMenu.tscn

@ -1,13 +1,14 @@
[gd_scene load_steps=9 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/lobby.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/lobby_menu.gd" type="Script" id=2]
[ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3] [ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/icons/checkmark.png" type="Texture" id=4] [ext_resource path="res://assets/icons/checkmark.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/question.png" type="Texture" id=5] [ext_resource path="res://assets/icons/question.png" type="Texture" id=5]
[ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=6] [ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=6]
[ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=7] [ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=7]
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 100 size = 100
font_data = ExtResource( 7 ) font_data = ExtResource( 7 )
@ -27,12 +28,11 @@ script = ExtResource( 2 )
[node name="back" parent="menu" index="0"] [node name="back" parent="menu" index="0"]
focus_neighbour_right = NodePath("../ready") focus_neighbour_right = NodePath("../ready")
[node name="top_bar" type="GridContainer" parent="menu"]
[node name="top_bar" type="HBoxContainer" parent="menu"]
margin_left = 14.0 margin_left = 14.0
margin_top = 12.0 margin_top = 12.0
margin_right = 940.0 margin_right = 940.0
margin_bottom = 52.0 margin_bottom = 52.0
columns = 2
[node name="server_name" type="Label" parent="menu/top_bar"] [node name="server_name" type="Label" parent="menu/top_bar"]
margin_right = 779.0 margin_right = 779.0
@ -59,6 +59,7 @@ margin_bottom = 397.0
columns = 3 columns = 3
[node name="players" type="ItemList" parent="menu/mid"] [node name="players" type="ItemList" parent="menu/mid"]
editor/display_folded = true
margin_right = 456.0 margin_right = 456.0
margin_bottom = 340.0 margin_bottom = 340.0
size_flags_horizontal = 3 size_flags_horizontal = 3
@ -81,6 +82,7 @@ margin_right = 464.0
margin_bottom = 340.0 margin_bottom = 340.0
[node name="player_settings" parent="menu/mid" instance=ExtResource( 6 )] [node name="player_settings" parent="menu/mid" instance=ExtResource( 6 )]
editor/display_folded = true
margin_left = 468.0 margin_left = 468.0
margin_top = 0.0 margin_top = 0.0
margin_right = 924.0 margin_right = 924.0

22
scenes/menus/LocalGameMenu.tscn

@ -29,45 +29,45 @@ margin_bottom = 130.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="GridContainer" type="GridContainer" parent="menu"]
[node name="VBoxContainer" type="VBoxContainer" parent="menu"]
margin_left = 19.0 margin_left = 19.0
margin_top = 21.0 margin_top = 21.0
margin_right = 418.0 margin_right = 418.0
margin_bottom = 197.0 margin_bottom = 197.0
[node name="player_settings" parent="menu/GridContainer" instance=ExtResource( 3 )]
[node name="player_settings" parent="menu/VBoxContainer" instance=ExtResource( 3 )]
margin_left = 0.0 margin_left = 0.0
margin_top = 0.0 margin_top = 0.0
margin_right = 399.0 margin_right = 399.0
margin_bottom = 132.0 margin_bottom = 132.0
[node name="name_label" parent="menu/GridContainer/player_settings/GridContainer" index="0"]
[node name="name_label" parent="menu/VBoxContainer/player_settings/VBoxContainer" index="0"]
margin_right = 399.0 margin_right = 399.0
margin_bottom = 27.0 margin_bottom = 27.0
[node name="name" parent="menu/GridContainer/player_settings/GridContainer" index="1"]
[node name="name" parent="menu/VBoxContainer/player_settings/VBoxContainer" index="1"]
margin_top = 31.0 margin_top = 31.0
margin_right = 399.0 margin_right = 399.0
margin_bottom = 68.0 margin_bottom = 68.0
focus_neighbour_bottom = NodePath("../color") focus_neighbour_bottom = NodePath("../color")
[node name="color_label" parent="menu/GridContainer/player_settings/GridContainer" index="2"]
[node name="color_label" parent="menu/VBoxContainer/player_settings/VBoxContainer" index="2"]
margin_top = 72.0 margin_top = 72.0
margin_right = 399.0 margin_right = 399.0
margin_bottom = 99.0 margin_bottom = 99.0
[node name="color" parent="menu/GridContainer/player_settings/GridContainer" index="3"]
[node name="color" parent="menu/VBoxContainer/player_settings/VBoxContainer" index="3"]
margin_top = 103.0 margin_top = 103.0
margin_right = 399.0 margin_right = 399.0
margin_bottom = 136.0 margin_bottom = 136.0
focus_neighbour_top = NodePath("../name") focus_neighbour_top = NodePath("../name")
focus_neighbour_bottom = NodePath("../../../bots") focus_neighbour_bottom = NodePath("../../../bots")
[node name="bots" type="CheckButton" parent="menu/GridContainer"]
[node name="bots" type="CheckButton" parent="menu/VBoxContainer"]
margin_top = 136.0 margin_top = 136.0
margin_right = 143.0 margin_right = 143.0
margin_bottom = 176.0 margin_bottom = 176.0
focus_neighbour_top = NodePath("../player_settings/GridContainer/color")
focus_neighbour_top = NodePath("../player_settings/VBoxContainer/color")
focus_neighbour_bottom = NodePath("../../start") focus_neighbour_bottom = NodePath("../../start")
size_flags_horizontal = 0 size_flags_horizontal = 0
pressed = true pressed = true
@ -84,7 +84,7 @@ margin_top = -56.0
grow_horizontal = 0 grow_horizontal = 0
rect_pivot_offset = Vector2( 1.89856, 0.845154 ) rect_pivot_offset = Vector2( 1.89856, 0.845154 )
focus_neighbour_left = NodePath("../back") focus_neighbour_left = NodePath("../back")
focus_neighbour_top = NodePath("../GridContainer/bots")
focus_neighbour_top = NodePath("../VBoxContainer/bots")
custom_fonts/font = ExtResource( 4 ) custom_fonts/font = ExtResource( 4 )
text = "START_GAME" text = "START_GAME"
icon = ExtResource( 5 ) icon = ExtResource( 5 )
@ -96,7 +96,7 @@ anchor_bottom = 1.0
margin_top = -56.0 margin_top = -56.0
margin_right = 132.0 margin_right = 132.0
rect_pivot_offset = Vector2( 0.606262, -0.447205 ) rect_pivot_offset = Vector2( 0.606262, -0.447205 )
focus_neighbour_top = NodePath("../GridContainer/bots")
focus_neighbour_top = NodePath("../VBoxContainer/bots")
focus_neighbour_right = NodePath("../start") focus_neighbour_right = NodePath("../start")
custom_fonts/font = ExtResource( 4 ) custom_fonts/font = ExtResource( 4 )
text = "BACK" text = "BACK"
@ -105,4 +105,4 @@ flat = true
[connection signal="pressed" from="menu/start" to="." method="_on_start_pressed"] [connection signal="pressed" from="menu/start" to="." method="_on_start_pressed"]
[connection signal="pressed" from="menu/back" to="." method="_on_back_pressed"] [connection signal="pressed" from="menu/back" to="." method="_on_back_pressed"]
[editable path="menu/GridContainer/player_settings"]
[editable path="menu/VBoxContainer/player_settings"]

38
scenes/menus/MainMenu.tscn

@ -1,11 +1,13 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/main.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/main_menu.gd" type="Script" id=2]
[ext_resource path="res://assets/icons/massiveMultiplayer.png" type="Texture" id=3] [ext_resource path="res://assets/icons/massiveMultiplayer.png" type="Texture" id=3]
[ext_resource path="res://assets/icons/singleplayer.png" type="Texture" id=4] [ext_resource path="res://assets/icons/singleplayer.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/wrench.png" type="Texture" id=5] [ext_resource path="res://assets/icons/wrench.png" type="Texture" id=5]
[ext_resource path="res://assets/icons/power.png" type="Texture" id=6] [ext_resource path="res://assets/icons/power.png" type="Texture" id=6]
[ext_resource path="res://assets/icons/question.png" type="Texture" id=7]
[node name="main_menu" type="Control"] [node name="main_menu" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -27,11 +29,11 @@ margin_bottom = 132.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="GridContainer" type="GridContainer" parent="menu"]
[node name="VBoxContainer" type="VBoxContainer" parent="menu"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
[node name="multiplayer" type="Button" parent="menu/GridContainer"]
[node name="multiplayer" type="Button" parent="menu/VBoxContainer"]
margin_right = 310.0 margin_right = 310.0
margin_bottom = 63.0 margin_bottom = 63.0
focus_neighbour_top = NodePath("../quit") focus_neighbour_top = NodePath("../quit")
@ -42,7 +44,7 @@ text = "MULTIPLAYER"
icon = ExtResource( 3 ) icon = ExtResource( 3 )
flat = true flat = true
[node name="practice" type="Button" parent="menu/GridContainer"]
[node name="practice" type="Button" parent="menu/VBoxContainer"]
margin_top = 67.0 margin_top = 67.0
margin_right = 310.0 margin_right = 310.0
margin_bottom = 130.0 margin_bottom = 130.0
@ -54,7 +56,7 @@ text = "PRACTISE"
icon = ExtResource( 4 ) icon = ExtResource( 4 )
flat = true flat = true
[node name="settings" type="Button" parent="menu/GridContainer"]
[node name="settings" type="Button" parent="menu/VBoxContainer"]
margin_top = 134.0 margin_top = 134.0
margin_right = 310.0 margin_right = 310.0
margin_bottom = 197.0 margin_bottom = 197.0
@ -66,10 +68,10 @@ text = "SETTINGS"
icon = ExtResource( 5 ) icon = ExtResource( 5 )
flat = true flat = true
[node name="quit" type="Button" parent="menu/GridContainer"]
[node name="quit" type="Button" parent="menu/VBoxContainer"]
margin_top = 201.0 margin_top = 201.0
margin_right = 310.0 margin_right = 310.0
margin_bottom = 264.0
margin_bottom = 265.0
focus_neighbour_top = NodePath("../settings") focus_neighbour_top = NodePath("../settings")
focus_neighbour_bottom = NodePath("../multiplayer") focus_neighbour_bottom = NodePath("../multiplayer")
size_flags_horizontal = 3 size_flags_horizontal = 3
@ -83,8 +85,18 @@ margin_right = 138.0
margin_bottom = 84.0 margin_bottom = 84.0
window_title = "ALERT" window_title = "ALERT"
dialog_text = "Server disconnected!" dialog_text = "Server disconnected!"
[connection signal="pressed" from="menu/GridContainer/multiplayer" to="." method="_on_multiplayer_pressed"]
[connection signal="pressed" from="menu/GridContainer/multiplayer" to="." method="_on_online_pressed"]
[connection signal="pressed" from="menu/GridContainer/practice" to="." method="_on_practice_pressed"]
[connection signal="pressed" from="menu/GridContainer/settings" to="." method="_on_settings_pressed"]
[connection signal="pressed" from="menu/GridContainer/quit" to="." method="_on_quit_pressed"]
[node name="Button" type="Button" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -62.0
margin_top = -56.0
icon = ExtResource( 7 )
flat = true
[connection signal="pressed" from="menu/VBoxContainer/multiplayer" to="." method="_on_multiplayer_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/multiplayer" to="." method="_on_online_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/practice" to="." method="_on_practice_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/settings" to="." method="_on_settings_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/quit" to="." method="_on_quit_pressed"]

24
scenes/menus/MultiplayerMenu.tscn

@ -1,7 +1,7 @@
[gd_scene load_steps=11 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/server.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/server_menu.gd" type="Script" id=2]
[ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3] [ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/icons/cpu.png" type="Texture" id=4] [ext_resource path="res://assets/icons/cpu.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=5] [ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=5]
@ -11,6 +11,7 @@
[ext_resource path="res://assets/icons/massiveMultiplayer.png" type="Texture" id=9] [ext_resource path="res://assets/icons/massiveMultiplayer.png" type="Texture" id=9]
[ext_resource path="res://assets/icons/fistPlus.png" type="Texture" id=10] [ext_resource path="res://assets/icons/fistPlus.png" type="Texture" id=10]
[node name="multiplayer_menu" type="Control"] [node name="multiplayer_menu" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -27,12 +28,11 @@ script = ExtResource( 2 )
focus_neighbour_top = NodePath("../games") focus_neighbour_top = NodePath("../games")
focus_neighbour_right = NodePath("../bottom_bar/refresh") focus_neighbour_right = NodePath("../bottom_bar/refresh")
[node name="top_bar" type="GridContainer" parent="menu"]
[node name="HBoxContainer" type="HBoxContainer" parent="menu"]
anchor_right = 1.0 anchor_right = 1.0
margin_bottom = 56.0 margin_bottom = 56.0
columns = 3
[node name="direct_host" type="Button" parent="menu/top_bar"]
[node name="direct_host" type="Button" parent="menu/HBoxContainer"]
margin_right = 239.0 margin_right = 239.0
margin_bottom = 56.0 margin_bottom = 56.0
focus_neighbour_right = NodePath("../direct_join") focus_neighbour_right = NodePath("../direct_join")
@ -41,7 +41,7 @@ text = "DIRECT_HOST"
icon = ExtResource( 4 ) icon = ExtResource( 4 )
flat = true flat = true
[node name="direct_join" type="Button" parent="menu/top_bar"]
[node name="direct_join" type="Button" parent="menu/HBoxContainer"]
margin_left = 243.0 margin_left = 243.0
margin_right = 473.0 margin_right = 473.0
margin_bottom = 56.0 margin_bottom = 56.0
@ -52,7 +52,7 @@ text = "DIRECT_JOIN"
icon = ExtResource( 5 ) icon = ExtResource( 5 )
flat = true flat = true
[node name="open" type="CheckButton" parent="menu/top_bar"]
[node name="open" type="CheckButton" parent="menu/HBoxContainer"]
margin_left = 477.0 margin_left = 477.0
margin_right = 945.0 margin_right = 945.0
margin_bottom = 56.0 margin_bottom = 56.0
@ -90,14 +90,16 @@ margin_right = 12.0
margin_bottom = 33.0 margin_bottom = 33.0
icon = ExtResource( 8 ) icon = ExtResource( 8 )
[node name="bottom_bar" type="GridContainer" parent="menu"]
[node name="bottom_bar" type="HBoxContainer" parent="menu"]
anchor_top = 1.0 anchor_top = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = 380.0 margin_left = 380.0
margin_top = -56.0 margin_top = -56.0
grow_horizontal = 0 grow_horizontal = 0
columns = 3
size_flags_horizontal = 6
size_flags_vertical = 6
alignment = 2
[node name="refresh" type="Button" parent="menu/bottom_bar"] [node name="refresh" type="Button" parent="menu/bottom_bar"]
margin_right = 183.0 margin_right = 183.0
@ -146,9 +148,9 @@ wait_time = 5.0
autostart = true autostart = true
[connection signal="draw" from="." to="." method="_on_multiplayer_menu_draw"] [connection signal="draw" from="." to="." method="_on_multiplayer_menu_draw"]
[connection signal="hide" from="." to="." method="_on_multiplayer_menu_hide"] [connection signal="hide" from="." to="." method="_on_multiplayer_menu_hide"]
[connection signal="pressed" from="menu/top_bar/direct_host" to="." method="_on_direct_host_pressed"]
[connection signal="pressed" from="menu/top_bar/direct_join" to="." method="_on_direct_join_pressed"]
[connection signal="toggled" from="menu/top_bar/open" to="." method="_on_open_toggled"]
[connection signal="pressed" from="menu/HBoxContainer/direct_host" to="." method="_on_direct_host_pressed"]
[connection signal="pressed" from="menu/HBoxContainer/direct_join" to="." method="_on_direct_join_pressed"]
[connection signal="toggled" from="menu/HBoxContainer/open" to="." method="_on_open_toggled"]
[connection signal="item_selected" from="menu/games" to="." method="_on_games_item_selected"] [connection signal="item_selected" from="menu/games" to="." method="_on_games_item_selected"]
[connection signal="nothing_selected" from="menu/games" to="." method="_on_games_nothing_selected"] [connection signal="nothing_selected" from="menu/games" to="." method="_on_games_nothing_selected"]
[connection signal="pressed" from="menu/bottom_bar/refresh" to="." method="_on_refresh_pressed"] [connection signal="pressed" from="menu/bottom_bar/refresh" to="." method="_on_refresh_pressed"]

11
scenes/menus/ServerCreateGameMenu.tscn

@ -1,11 +1,12 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/server_create.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/server_create_menu.gd" type="Script" id=2]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3] [ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3]
[ext_resource path="res://assets/icons/fistPlus.png" type="Texture" id=4] [ext_resource path="res://assets/icons/fistPlus.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=5] [ext_resource path="res://assets/icons/return.png" type="Texture" id=5]
[node name="server_create_menu" type="Control"] [node name="server_create_menu" type="Control"]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
@ -23,9 +24,9 @@ anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
margin_left = -217.5
margin_left = -296.5
margin_top = -68.5 margin_top = -68.5
margin_right = 217.5
margin_right = 296.5
margin_bottom = 68.5 margin_bottom = 68.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
@ -33,7 +34,7 @@ grow_vertical = 2
[node name="GridContainer" type="GridContainer" parent="menu"] [node name="GridContainer" type="GridContainer" parent="menu"]
margin_left = 12.0 margin_left = 12.0
margin_top = 11.0 margin_top = 11.0
margin_right = 427.0
margin_right = 584.0
margin_bottom = 92.0 margin_bottom = 92.0
columns = 2 columns = 2
@ -45,7 +46,7 @@ text = "GAME_NAME"
[node name="name" type="LineEdit" parent="menu/GridContainer"] [node name="name" type="LineEdit" parent="menu/GridContainer"]
margin_left = 166.0 margin_left = 166.0
margin_right = 415.0
margin_right = 572.0
margin_bottom = 37.0 margin_bottom = 37.0
focus_neighbour_left = NodePath("../../back") focus_neighbour_left = NodePath("../../back")
focus_neighbour_right = NodePath("../../create") focus_neighbour_right = NodePath("../../create")

34
scenes/menus/SettingsControlsMenu.tscn

@ -1,6 +1,6 @@
[gd_scene load_steps=20 format=2] [gd_scene load_steps=20 format=2]
[ext_resource path="res://scripts/menus/settings_controls.gd" type="Script" id=1]
[ext_resource path="res://scripts/menus/settings_controls_menu.gd" type="Script" id=1]
[ext_resource path="res://assets/icons/keySmall_3d.png" type="Texture" id=2] [ext_resource path="res://assets/icons/keySmall_3d.png" type="Texture" id=2]
[ext_resource path="res://assets/icons/buttonA.png" type="Texture" id=3] [ext_resource path="res://assets/icons/buttonA.png" type="Texture" id=3]
[ext_resource path="res://assets/icons/buttonB.png" type="Texture" id=4] [ext_resource path="res://assets/icons/buttonB.png" type="Texture" id=4]
@ -27,17 +27,7 @@ margin_right = 858.0
margin_bottom = 335.0 margin_bottom = 335.0
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="key_dialog" type="ConfirmationDialog" parent="."]
margin_left = 18.0
margin_top = 16.0
margin_right = 311.0
margin_bottom = 100.0
popup_exclusive = true
window_title = ""
dialog_text = "Press any key..."
[node name="ScrollContainer" type="ScrollContainer" parent="."] [node name="ScrollContainer" type="ScrollContainer" parent="."]
editor/display_folded = true
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -70,6 +60,7 @@ align = 1
valign = 1 valign = 1
[node name="icons" type="GridContainer" parent="."] [node name="icons" type="GridContainer" parent="."]
editor/display_folded = true
visible = false visible = false
margin_right = 40.0 margin_right = 40.0
margin_bottom = 40.0 margin_bottom = 40.0
@ -187,3 +178,24 @@ margin_top = 960.0
margin_right = 62.0 margin_right = 62.0
margin_bottom = 1016.0 margin_bottom = 1016.0
icon = ExtResource( 19 ) icon = ExtResource( 19 )
[node name="key_dialog" type="ConfirmationDialog" parent="."]
margin_left = 57.9108
margin_top = 57.5398
margin_right = 367.911
margin_bottom = 216.54
popup_exclusive = true
window_title = ""
[node name="action_button" type="Button" parent="key_dialog"]
margin_left = 8.0
margin_top = 8.0
margin_right = 302.0
margin_bottom = 123.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 12
size_flags_vertical = 12
flat = true
clip_text = true
align = 0

163
scenes/menus/SettingsMenu.tscn

@ -1,11 +1,12 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/settings.gd" type="Script" id=2]
[ext_resource path="res://scripts/menus/settings_menu.gd" type="Script" id=2]
[ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3] [ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=4] [ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/menus/SettingsControlsMenu.tscn" type="PackedScene" id=5] [ext_resource path="res://scenes/menus/SettingsControlsMenu.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/icons/save.png" type="Texture" id=6]
[ext_resource path="res://assets/icons/checkmark.png" type="Texture" id=6]
[ext_resource path="res://assets/icons/save.png" type="Texture" id=7]
[node name="settings_menu" type="Control"] [node name="settings_menu" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -19,6 +20,10 @@ script = ExtResource( 2 )
[node name="menu" parent="." instance=ExtResource( 3 )] [node name="menu" parent="." instance=ExtResource( 3 )]
[node name="back" parent="menu" index="0"]
focus_neighbour_top = NodePath("../tabs/game")
focus_neighbour_right = NodePath("../HBoxContainer/apply")
[node name="tabs" type="TabContainer" parent="menu"] [node name="tabs" type="TabContainer" parent="menu"]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
@ -30,17 +35,22 @@ margin_right = 459.5
margin_bottom = 177.5 margin_bottom = 177.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
focus_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
tab_align = 0 tab_align = 0
[node name="game" type="Tabs" parent="menu/tabs"] [node name="game" type="Tabs" parent="menu/tabs"]
editor/display_folded = true
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = 4.0 margin_left = 4.0
margin_top = 45.0 margin_top = 45.0
margin_right = -4.0 margin_right = -4.0
margin_bottom = -4.0 margin_bottom = -4.0
focus_neighbour_right = NodePath("../controls")
focus_neighbour_bottom = NodePath("GridContainer/settings_player/VBoxContainer/name")
focus_mode = 2
[node name="GridContainer" type="GridContainer" parent="menu/tabs/game"] [node name="GridContainer" type="GridContainer" parent="menu/tabs/game"]
margin_left = 9.0 margin_left = 9.0
@ -54,34 +64,41 @@ margin_top = 0.0
margin_right = 407.0 margin_right = 407.0
margin_bottom = 146.0 margin_bottom = 146.0
[node name="name_label" parent="menu/tabs/game/GridContainer/settings_player/GridContainer" index="0"]
[node name="name_label" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="0"]
margin_right = 407.0 margin_right = 407.0
margin_bottom = 27.0 margin_bottom = 27.0
[node name="name" parent="menu/tabs/game/GridContainer/settings_player/GridContainer" index="1"]
[node name="name" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="1"]
margin_top = 31.0 margin_top = 31.0
margin_right = 407.0 margin_right = 407.0
margin_bottom = 68.0 margin_bottom = 68.0
focus_neighbour_top = NodePath("../../../..")
focus_neighbour_bottom = NodePath("../color")
[node name="color_label" parent="menu/tabs/game/GridContainer/settings_player/GridContainer" index="2"]
[node name="color_label" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="2"]
margin_top = 72.0 margin_top = 72.0
margin_right = 407.0 margin_right = 407.0
margin_bottom = 99.0 margin_bottom = 99.0
[node name="color" parent="menu/tabs/game/GridContainer/settings_player/GridContainer" index="3"]
[node name="color" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="3"]
margin_top = 103.0 margin_top = 103.0
margin_right = 407.0 margin_right = 407.0
margin_bottom = 136.0 margin_bottom = 136.0
focus_neighbour_top = NodePath("../name")
focus_neighbour_bottom = NodePath("../../../bots")
[node name="bots" type="CheckButton" parent="menu/tabs/game/GridContainer"] [node name="bots" type="CheckButton" parent="menu/tabs/game/GridContainer"]
margin_top = 150.0 margin_top = 150.0
margin_right = 143.0 margin_right = 143.0
margin_bottom = 190.0 margin_bottom = 190.0
focus_neighbour_top = NodePath("../settings_player/VBoxContainer/color")
focus_neighbour_bottom = NodePath("../../../../HBoxContainer/apply")
size_flags_horizontal = 0 size_flags_horizontal = 0
size_flags_vertical = 0 size_flags_vertical = 0
text = "Bots" text = "Bots"
[node name="controls" type="Tabs" parent="menu/tabs"] [node name="controls" type="Tabs" parent="menu/tabs"]
editor/display_folded = true
visible = false visible = false
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -89,9 +106,25 @@ margin_left = 4.0
margin_top = 45.0 margin_top = 45.0
margin_right = -4.0 margin_right = -4.0
margin_bottom = -4.0 margin_bottom = -4.0
focus_neighbour_left = NodePath("../game")
focus_neighbour_right = NodePath("../graphics")
focus_mode = 2
[node name="settings_controls" parent="menu/tabs/controls" instance=ExtResource( 5 )] [node name="settings_controls" parent="menu/tabs/controls" instance=ExtResource( 5 )]
[node name="empty" parent="menu/tabs/controls/settings_controls/ScrollContainer/grid" index="0"]
margin_bottom = 27.0
[node name="keyboard_label" parent="menu/tabs/controls/settings_controls/ScrollContainer/grid" index="1"]
margin_bottom = 27.0
[node name="joypad_label" parent="menu/tabs/controls/settings_controls/ScrollContainer/grid" index="2"]
margin_bottom = 27.0
[node name="action_button" parent="menu/tabs/controls/settings_controls/key_dialog" index="3"]
margin_right = 302.0
margin_bottom = 110.0
[node name="graphics" type="Tabs" parent="menu/tabs"] [node name="graphics" type="Tabs" parent="menu/tabs"]
visible = false visible = false
anchor_right = 1.0 anchor_right = 1.0
@ -100,8 +133,40 @@ margin_left = 4.0
margin_top = 45.0 margin_top = 45.0
margin_right = -4.0 margin_right = -4.0
margin_bottom = -4.0 margin_bottom = -4.0
focus_neighbour_left = NodePath("../controls")
focus_neighbour_right = NodePath("../system")
focus_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="menu/tabs/graphics"]
margin_right = 40.0
margin_bottom = 40.0
[node name="resolution" type="OptionButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_right = 248.0
margin_bottom = 33.0
[node name="fullscreen" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_top = 37.0
margin_right = 248.0
margin_bottom = 77.0
pressed = true
text = "FULLSCREEN"
[node name="light" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_top = 81.0
margin_right = 248.0
margin_bottom = 121.0
text = "LIGHT"
[node name="shadows" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_top = 125.0
margin_right = 248.0
margin_bottom = 165.0
disabled = true
text = "SHADOWS"
[node name="system" type="Tabs" parent="menu/tabs"] [node name="system" type="Tabs" parent="menu/tabs"]
editor/display_folded = true
visible = false visible = false
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -109,45 +174,103 @@ margin_left = 4.0
margin_top = 45.0 margin_top = 45.0
margin_right = -4.0 margin_right = -4.0
margin_bottom = -4.0 margin_bottom = -4.0
focus_neighbour_left = NodePath("../graphics")
focus_mode = 2
[node name="GridContainer" type="GridContainer" parent="menu/tabs/system"] [node name="GridContainer" type="GridContainer" parent="menu/tabs/system"]
margin_left = 12.0 margin_left = 12.0
margin_top = 8.0 margin_top = 8.0
margin_right = 476.0
margin_right = 907.0
margin_bottom = 124.0 margin_bottom = 124.0
columns = 2 columns = 2
[node name="locale_label" type="Label" parent="menu/tabs/system/GridContainer"] [node name="locale_label" type="Label" parent="menu/tabs/system/GridContainer"]
margin_right = 102.0
margin_bottom = 27.0
margin_right = 88.0
margin_bottom = 14.0
text = "LOCALE" text = "LOCALE"
valign = 1 valign = 1
[node name="locales" type="ItemList" parent="menu/tabs/system/GridContainer"] [node name="locales" type="ItemList" parent="menu/tabs/system/GridContainer"]
margin_left = 106.0
margin_right = 464.0
margin_bottom = 27.0
margin_left = 92.0
margin_right = 895.0
margin_bottom = 14.0
size_flags_horizontal = 3 size_flags_horizontal = 3
auto_height = true auto_height = true
[node name="save" type="Button" parent="menu"]
[node name="server_addr_label" type="Label" parent="menu/tabs/system/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="menu/tabs/system/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="menu/tabs/system/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="menu/tabs/system/GridContainer"]
margin_left = 92.0
margin_top = 46.0
margin_right = 895.0
margin_bottom = 70.0
[node name="HBoxContainer" type="HBoxContainer" parent="menu"]
editor/display_folded = true
anchor_left = 1.0 anchor_left = 1.0
anchor_top = 1.0 anchor_top = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = -147.0
margin_left = -286.0
margin_top = -56.0 margin_top = -56.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "SAVE"
size_flags_horizontal = 8
size_flags_vertical = 8
alignment = 2
[node name="apply" type="Button" parent="menu/HBoxContainer"]
margin_right = 150.0
margin_bottom = 56.0
grow_horizontal = 0
grow_vertical = 0
focus_neighbour_left = NodePath("../../back")
focus_neighbour_top = NodePath("../../tabs/game")
focus_neighbour_right = NodePath("../save")
size_flags_horizontal = 10
size_flags_vertical = 10
text = "APPLY"
icon = ExtResource( 6 ) icon = ExtResource( 6 )
flat = true flat = true
align = 0
[node name="save" type="Button" parent="menu/HBoxContainer"]
margin_left = 154.0
margin_right = 286.0
margin_bottom = 56.0
grow_horizontal = 0
grow_vertical = 0
focus_neighbour_left = NodePath("../apply")
focus_neighbour_top = NodePath("../../tabs/game")
size_flags_horizontal = 10
size_flags_vertical = 10
text = "SAVE"
icon = ExtResource( 7 )
flat = true
align = 0
[connection signal="toggled" from="menu/tabs/graphics/VBoxContainer/light" to="." method="_on_light_toggled"]
[connection signal="item_selected" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_item_selected"] [connection signal="item_selected" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_item_selected"]
[connection signal="tree_exiting" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_tree_exiting"] [connection signal="tree_exiting" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_tree_exiting"]
[connection signal="visibility_changed" from="menu/tabs/system/GridContainer/locales" to="." method="_init_locales"]
[connection signal="pressed" from="menu/save" to="." method="_on_save_pressed"]
[connection signal="pressed" from="menu/HBoxContainer/apply" to="." method="_on_apply_pressed"]
[connection signal="pressed" from="menu/HBoxContainer/save" to="." method="_on_save_pressed"]
[editable path="menu"] [editable path="menu"]

13
scenes/menus/SettingsPlayerMenu.tscn

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=2 format=2]
[ext_resource path="res://scripts/menus/settings_player.gd" type="Script" id=1]
[ext_resource path="res://scripts/menus/settings_player_menu.gd" type="Script" id=1]
[node name="settings_player_menu" type="Control"] [node name="settings_player_menu" type="Control"]
margin_left = 513.0 margin_left = 513.0
@ -11,28 +12,28 @@ size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="GridContainer" type="GridContainer" parent="."]
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
[node name="name_label" type="Label" parent="GridContainer"]
[node name="name_label" type="Label" parent="VBoxContainer"]
margin_right = 365.0 margin_right = 365.0
margin_bottom = 14.0 margin_bottom = 14.0
text = "PLAYER_NAME" text = "PLAYER_NAME"
[node name="name" type="LineEdit" parent="GridContainer"]
[node name="name" type="LineEdit" parent="VBoxContainer"]
margin_top = 18.0 margin_top = 18.0
margin_right = 365.0 margin_right = 365.0
margin_bottom = 42.0 margin_bottom = 42.0
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="color_label" type="Label" parent="GridContainer"]
[node name="color_label" type="Label" parent="VBoxContainer"]
margin_top = 46.0 margin_top = 46.0
margin_right = 365.0 margin_right = 365.0
margin_bottom = 60.0 margin_bottom = 60.0
text = "PLAYER_COLOR" text = "PLAYER_COLOR"
[node name="color" type="ColorPickerButton" parent="GridContainer"]
[node name="color" type="ColorPickerButton" parent="VBoxContainer"]
margin_top = 64.0 margin_top = 64.0
margin_right = 365.0 margin_right = 365.0
margin_bottom = 84.0 margin_bottom = 84.0

47
scenes/menus/SettingsSystemMenu.tscn

@ -0,0 +1,47 @@
[gd_scene format=2]
[node name="GridContainer" type="GridContainer"]
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="."]
margin_right = 88.0
margin_bottom = 14.0
text = "LOCALE"
valign = 1
[node name="locales" type="ItemList" parent="."]
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="."]
margin_top = 23.0
margin_right = 88.0
margin_bottom = 37.0
text = "SERVER_ADDR"
valign = 1
[node name="server_addr" type="LineEdit" parent="."]
margin_left = 92.0
margin_top = 18.0
margin_right = 895.0
margin_bottom = 42.0
[node name="api_addr_label" type="Label" parent="."]
margin_top = 51.0
margin_right = 88.0
margin_bottom = 65.0
text = "API_ADDR"
valign = 1
[node name="api_addr" type="LineEdit" parent="."]
margin_left = 92.0
margin_top = 46.0
margin_right = 895.0
margin_bottom = 70.0

24
scenes/player/HumanPlayer.tscn

@ -1,8 +1,8 @@
[gd_scene load_steps=11 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://scripts/player/human_controls.gd" type="Script" id=1] [ext_resource path="res://scripts/player/human_controls.gd" type="Script" id=1]
[ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=3]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=2]
[ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=3]
[ext_resource path="res://scenes/menus/IngameMenu.tscn" type="PackedScene" id=4] [ext_resource path="res://scenes/menus/IngameMenu.tscn" type="PackedScene" id=4]
[ext_resource path="res://scripts/player/human_inventory.gd" type="Script" id=5] [ext_resource path="res://scripts/player/human_inventory.gd" type="Script" id=5]
[ext_resource path="res://scenes/road/roadStraightLong.tscn" type="PackedScene" id=6] [ext_resource path="res://scenes/road/roadStraightLong.tscn" type="PackedScene" id=6]
@ -13,11 +13,11 @@ viewport_path = NodePath("inventory/viewport")
[sub_resource type="DynamicFont" id=2] [sub_resource type="DynamicFont" id=2]
size = 14 size = 14
font_data = ExtResource( 2 )
font_data = ExtResource( 3 )
[sub_resource type="DynamicFont" id=3] [sub_resource type="DynamicFont" id=3]
size = 85 size = 85
font_data = ExtResource( 2 )
font_data = ExtResource( 3 )
[node name="HumanPlayer" type="Spatial"] [node name="HumanPlayer" type="Spatial"]
script = ExtResource( 1 ) script = ExtResource( 1 )
@ -27,15 +27,16 @@ script = ExtResource( 1 )
[node name="inventory" type="Control" parent="hud"] [node name="inventory" type="Control" parent="hud"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 2 )
[node name="background" type="ColorRect" parent="hud/inventory"]
[node name="track_container" type="Panel" parent="hud/inventory"]
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -75.0 margin_left = -75.0
margin_right = 75.0 margin_right = 75.0
margin_bottom = 150.0 margin_bottom = 150.0
[node name="track" type="TextureRect" parent="hud/inventory"]
[node name="track" type="TextureRect" parent="hud/inventory/track_container"]
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -75.0 margin_left = -75.0
@ -43,7 +44,7 @@ margin_right = 75.0
margin_bottom = 150.0 margin_bottom = 150.0
texture = SubResource( 1 ) texture = SubResource( 1 )
[node name="type" type="Label" parent="hud/inventory"]
[node name="type" type="Label" parent="hud/inventory/track_container"]
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -74.0 margin_left = -74.0
@ -52,10 +53,15 @@ margin_bottom = 58.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
custom_fonts/font = SubResource( 2 ) custom_fonts/font = SubResource( 2 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
align = 1 align = 1
valign = 1 valign = 1
[node name="speed_slider" type="VSlider" parent="hud"]
anchor_bottom = 1.0
margin_right = 16.0
max_value = 250.0
step = 0.5
[node name="speed" type="Label" parent="hud"] [node name="speed" type="Label" parent="hud"]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 1.0 anchor_top = 1.0
@ -66,7 +72,7 @@ margin_top = -39.0
margin_right = 77.0 margin_right = 77.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource( 3 )
theme = ExtResource( 2 )
align = 1 align = 1
valign = 1 valign = 1

1
scenes/player/Player.tscn

@ -31,7 +31,6 @@ rotation_mode = 4
loop = false loop = false
[node name="raceCar" type="KinematicBody" parent="Path/PathFollow"] [node name="raceCar" type="KinematicBody" parent="Path/PathFollow"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
collision_layer = 31 collision_layer = 31
collision_mask = 31 collision_mask = 31
script = ExtResource( 2 ) script = ExtResource( 2 )

2
scenes/road/roadCornerLarge.tscn

@ -13,7 +13,7 @@ script = ExtResource( 2 )
end_rotation = Vector3( 0, -1.571, 0 ) end_rotation = Vector3( 0, -1.571, 0 )
speed_constrains = PoolVector3Array( 0.2, 0.6, 0.13, 0.6, 1.5, 0.1, 1.5, 2.36, 0.13 ) speed_constrains = PoolVector3Array( 0.2, 0.6, 0.13, 0.6, 1.5, 0.1, 1.5, 2.36, 0.13 )
force_penalties = PoolVector3Array( 2, 0, 8 ) force_penalties = PoolVector3Array( 2, 0, 8 )
torque_penalties = PoolVector3Array( 0.5, 0.1, 0.1 )
torque_penalties = PoolVector3Array( 0.1, 0.1, -0.5 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]
curve = ExtResource( 3 ) curve = ExtResource( 3 )

4
scenes/road/roadCornerLargeFlipped.tscn

@ -12,8 +12,8 @@ material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
end_rotation = Vector3( 0, 1.571, 0 ) end_rotation = Vector3( 0, 1.571, 0 )
speed_constrains = PoolVector3Array( 0.2, 0.6, 0.13, 0.6, 1.5, 0.1, 1.5, 2.36, 0.13 ) speed_constrains = PoolVector3Array( 0.2, 0.6, 0.13, 0.6, 1.5, 0.1, 1.5, 2.36, 0.13 )
force_penalties = PoolVector3Array( 1, 0, 5 )
torque_penalties = PoolVector3Array( 0, 1, 1.5 )
force_penalties = PoolVector3Array( 2, 0, 8 )
torque_penalties = PoolVector3Array( 0.1, 0.1, 0.5 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]
curve = ExtResource( 3 ) curve = ExtResource( 3 )

4
scenes/road/roadCornerLarger.tscn

@ -12,8 +12,8 @@ material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
end_rotation = Vector3( 0, -1.571, 0 ) end_rotation = Vector3( 0, -1.571, 0 )
speed_constrains = PoolVector3Array( 0.3, 1, 0.16, 1, 2.7, 0.13, 2.7, 3.93, 0.16 ) speed_constrains = PoolVector3Array( 0.3, 1, 0.16, 1, 2.7, 0.13, 2.7, 3.93, 0.16 )
force_penalties = PoolVector3Array( 0, 0, 5 )
torque_penalties = PoolVector3Array( 0, 0, 1 )
force_penalties = PoolVector3Array( 2, 0, 8 )
torque_penalties = PoolVector3Array( 0.1, 0.1, -0.5 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]
curve = ExtResource( 3 ) curve = ExtResource( 3 )

4
scenes/road/roadCornerLargerFlipped.tscn

@ -12,8 +12,8 @@ material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
end_rotation = Vector3( 0, 1.571, 0 ) end_rotation = Vector3( 0, 1.571, 0 )
speed_constrains = PoolVector3Array( 0.3, 1, 0.16, 1, 2.7, 0.13, 2.7, 3.93, 0.16 ) speed_constrains = PoolVector3Array( 0.3, 1, 0.16, 1, 2.7, 0.13, 2.7, 3.93, 0.16 )
force_penalties = PoolVector3Array( 0, 0, 5 )
torque_penalties = PoolVector3Array( 0, 0, -1 )
force_penalties = PoolVector3Array( 2, 0, 8 )
torque_penalties = PoolVector3Array( 0.1, 0.1, 0.5 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]
curve = ExtResource( 3 ) curve = ExtResource( 3 )

6
scenes/road/roadCornerSmall.tscn

@ -11,9 +11,9 @@ material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
end_rotation = Vector3( 0, -1.571, 0 ) end_rotation = Vector3( 0, -1.571, 0 )
speed_constrains = PoolVector3Array( 0.1, 0.79, 0.08 )
force_penalties = PoolVector3Array( 0, 0, 5 )
torque_penalties = PoolVector3Array( 0, 0, 1 )
speed_constrains = PoolVector3Array( 0.1, 0.6, 0.08 )
force_penalties = PoolVector3Array( 2, 0, 8 )
torque_penalties = PoolVector3Array( 0.1, 0.1, -0.5 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]
curve = ExtResource( 3 ) curve = ExtResource( 3 )

6
scenes/road/roadCornerSmallFlipped.tscn

@ -11,9 +11,9 @@ material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
end_rotation = Vector3( 0, 1.571, 0 ) end_rotation = Vector3( 0, 1.571, 0 )
speed_constrains = PoolVector3Array( 0.1, 0.79, 0.08 )
force_penalties = PoolVector3Array( 0, 0, 5 )
torque_penalties = PoolVector3Array( 0, 0, -1 )
speed_constrains = PoolVector3Array( 0.1, 0.6, 0.08 )
force_penalties = PoolVector3Array( 2, 0, 8 )
torque_penalties = PoolVector3Array( 0.1, 0.1, 0.5 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]
curve = ExtResource( 3 ) curve = ExtResource( 3 )

2
scenes/road/roadRamp.tscn

@ -11,7 +11,7 @@ material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
reset_index = 1 reset_index = 1
speed_constrains = PoolVector3Array( 0, 1, -0.05 )
speed_constrains = PoolVector3Array( 0.5, 0.9, -0.025 )
path_penalties = [ 1.0 ] path_penalties = [ 1.0 ]
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]

2
scenes/road/roadRampFlipped.tscn

@ -10,7 +10,7 @@ material/0 = null
material/1 = null material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
speed_constrains = PoolVector3Array( 0, 0.3, 0.12 )
speed_constrains = PoolVector3Array( 0, 0.1, 0.12 )
force_penalties = PoolVector3Array( 0, 0, 4 ) force_penalties = PoolVector3Array( 0, 0, 4 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]

4
scenes/road/roadRampLong.tscn

@ -11,8 +11,10 @@ material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
reset_index = 1 reset_index = 1
speed_constrains = PoolVector3Array( 0, 2, -0.05 )
speed_constrains = PoolVector3Array( 0.7, 1.9, -0.03 )
path_penalties = [ 2.0 ] path_penalties = [ 2.0 ]
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]
curve = ExtResource( 3 ) curve = ExtResource( 3 )
[node name="PathFollow" type="PathFollow" parent="Path"]

2
scenes/road/roadRampLongCurved.tscn

@ -11,7 +11,7 @@ material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
reset_index = 1 reset_index = 1
speed_constrains = PoolVector3Array( 0.25, 1.5, -0.05 )
speed_constrains = PoolVector3Array( 0.7, 1.5, -0.03 )
path_penalties = [ 1.25 ] path_penalties = [ 1.25 ]
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]

2
scenes/road/roadRampLongFlipped.tscn

@ -10,7 +10,7 @@ material/0 = null
material/1 = null material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
speed_constrains = PoolVector3Array( 0, 0.1, 0.12 )
speed_constrains = PoolVector3Array( 0.1, 0.3, 0.12 )
force_penalties = PoolVector3Array( 0, 0, 4 ) force_penalties = PoolVector3Array( 0, 0, 4 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]

30
scripts/Util.gd

@ -1,12 +1,36 @@
extends Node extends Node
class_name Util
var random_number_generator:RandomNumberGenerator = RandomNumberGenerator.new()
static func clear_node(node:Node):
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()): for idx in range(node.get_child_count()):
node.remove_child(node.get_child(0)) node.remove_child(node.get_child(0))
static func curve_get_last_point(curve:Curve3D):
func curve_get_last_point(curve:Curve3D):
return curve.get_point_position(curve.get_point_count() - 1) return curve.get_point_position(curve.get_point_count() - 1)

28
scripts/game/config.gd

@ -0,0 +1,28 @@
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"]
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)

62
scripts/game/config_apply.gd

@ -0,0 +1,62 @@
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("game_server", "server_addr")
if server_addr != null && not server_addr.empty():
game_server.set_server_addr(server_addr)
var api_addr = config.get_value("game_server","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)
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)

3
scripts/game/game.gd

@ -12,6 +12,9 @@ const REMOVE_LAST = 2
func _ready(): func _ready():
route = get_node("route") route = get_node("route")
find_node("sun").set_visible(config.get_value("graphics","light", false))
if find_node("sun").is_visible_in_tree():
find_node("sun").set_shadow(config.get_value("graphics","shadows", false))
if is_network_master(): if is_network_master():
route.rpc("add_road",roads_factory.START, -1) route.rpc("add_road",roads_factory.START, -1)

28
scripts/game/gamestate.gd

@ -24,11 +24,11 @@ signal game_ended()
remote func set_player(id, new_name:String = " ", new_color:Color = Color.black, new_ready:bool = false): remote func set_player(id, new_name:String = " ", new_color:Color = Color.black, new_ready:bool = false):
players[id] = {"name" : new_name, "color" : new_color, "ready" : new_ready, "prepared" : false} players[id] = {"name" : new_name, "color" : new_color, "ready" : new_ready, "prepared" : false}
emit_signal("players_changed", players) emit_signal("players_changed", players)
if get_tree().is_network_server(): if get_tree().is_network_server():
var all_ready = true var all_ready = true
for p_id in players:
rpc_id(id, "set_player", p_id, players[p_id].name, players[p_id].color, players[p_id].ready)
for p_id in players:
rpc_id(id, "set_player", p_id, players[p_id].name, players[p_id].color, players[p_id].ready)
rpc_id(p_id, "set_player", id, new_name, new_color, new_ready) rpc_id(p_id, "set_player", id, new_name, new_color, new_ready)
all_ready = all_ready && players[p_id].ready all_ready = all_ready && players[p_id].ready
rpc("game_ready", all_ready) rpc("game_ready", all_ready)
@ -43,12 +43,12 @@ func update_player(new_name:String = " ", new_color:Color = Color.black, new_rea
remotesync func remove_player(id): remotesync func remove_player(id):
players.erase(id) players.erase(id)
if game != null: if game != null:
var game_players = game.get_node("players") var game_players = game.get_node("players")
if game_players.has_node(str(id)): if game_players.has_node(str(id)):
game_players.remove_child(game_players.get_node(str(id))) game_players.remove_child(game_players.get_node(str(id)))
emit_signal("players_changed", players) emit_signal("players_changed", players)
@ -63,32 +63,32 @@ remotesync func game_ready(all_ready:bool):
remotesync func prepare_game(): remotesync func prepare_game():
get_tree().set_pause(true) get_tree().set_pause(true)
game = Game.instance() game = Game.instance()
get_tree().get_root().add_child(game) get_tree().get_root().add_child(game)
get_tree().get_root().get_node("main_menu").hide() get_tree().get_root().get_node("main_menu").hide()
for p_id in players: for p_id in players:
var controls var controls
var player = players[p_id] var player = players[p_id]
var player_scene = Player.instance() var player_scene = Player.instance()
player_scene.set_network_master(p_id) player_scene.set_network_master(p_id)
player_scene.set_name(str(p_id)) player_scene.set_name(str(p_id))
game.get_node("players").add_child(player_scene) game.get_node("players").add_child(player_scene)
player_scene.set_player_name(player.name) player_scene.set_player_name(player.name)
player_scene.set_player_color(player.color) player_scene.set_player_color(player.color)
if p_id == get_tree().get_network_unique_id(): if p_id == get_tree().get_network_unique_id():
controls = HumanPlayer.instance() controls = HumanPlayer.instance()
controls.set_name("HumanControl_" + str(p_id)) controls.set_name("HumanControl_" + str(p_id))
game.add_child(controls) game.add_child(controls)
controls.set_player(player_scene.get_path()) controls.set_player(player_scene.get_path())
controls.set_network_master(p_id) controls.set_network_master(p_id)
player_scene.set_start(player_scene.get_index()) player_scene.set_start(player_scene.get_index())
if bots: if bots:
for index in range(MAX_PEERS-players.size()): for index in range(MAX_PEERS-players.size()):
var bot_index = players.size() + index var bot_index = players.size() + index
@ -119,7 +119,7 @@ remotesync func player_prepared(id):
if get_tree().is_network_server(): if get_tree().is_network_server():
players[id].prepared = true players[id].prepared = true
var all_prepared = true var all_prepared = true
for p_id in players:
for p_id in players:
all_prepared = all_prepared && players[p_id].prepared all_prepared = all_prepared && players[p_id].prepared
if all_prepared: if all_prepared:
rpc("post_start_game") rpc("post_start_game")
@ -135,7 +135,7 @@ remotesync func set_bots(has_bots:bool):
func quit_game(): func quit_game():
if game != null:
if game != null:
game.queue_free() game.queue_free()
game = null game = null
@ -148,5 +148,5 @@ func quit_game():
game_running = false game_running = false
bots = false bots = false
game_name = "" game_name = ""
emit_signal("game_ended") emit_signal("game_ended")

58
scripts/game/local_storage.gd

@ -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()

13
scripts/game/route.gd

@ -14,7 +14,10 @@ func get_last_road():
func get_road(road_index): func get_road(road_index):
return get_child(road_index)
if get_child_count() > road_index:
return get_child(road_index)
else:
return null
remotesync func add_road(type, creator): remotesync func add_road(type, creator):
@ -26,19 +29,19 @@ remotesync func add_road(type, creator):
transform = transform.translated(curve.get_point_position(curve.get_point_count() - 1)) transform = transform.translated(curve.get_point_position(curve.get_point_count() - 1))
if last_road.get_end_rotation().length() != 0: if last_road.get_end_rotation().length() != 0:
transform.basis = transform.basis.rotated(last_road.get_end_rotation().normalized(), last_road.get_end_rotation().length()) transform.basis = transform.basis.rotated(last_road.get_end_rotation().normalized(), last_road.get_end_rotation().length())
var new_road = roads_factory.get_road_instance(type) var new_road = roads_factory.get_road_instance(type)
new_road.set_global_transform(transform) new_road.set_global_transform(transform)
new_road.set_preview(false) new_road.set_preview(false)
new_road.set_creator(creator) new_road.set_creator(creator)
if creator > 0: if creator > 0:
var player = gamestate.game.get_node(str(creator)) var player = gamestate.game.get_node(str(creator))
if player != null: if player != null:
new_road.set_color(player.get_player_color()) new_road.set_color(player.get_player_color())
add_child(new_road) add_child(new_road)
emit_signal("road_added", new_road) emit_signal("road_added", new_road)

10
scripts/menus/direct_host.gd → scripts/menus/direct_host_menu.gd

@ -4,7 +4,7 @@ var LobbyMenu = preload("res://scenes/menus/LobbyMenu.tscn")
func _ready(): func _ready():
find_node("bots").set_pressed(local_storage.read_value("bots", true))
find_node("bots").set_pressed(config.get_value("game","bots", true))
func _draw(): func _draw():
@ -15,13 +15,13 @@ func _on_host_pressed():
var port = find_node("port").get_value() var port = find_node("port").get_value()
var bots = find_node("bots").is_pressed() var bots = find_node("bots").is_pressed()
var err = server.host_game(int(port), bots) var err = server.host_game(int(port), bots)
if err == OK: if err == OK:
var lobby_menu = LobbyMenu.instance() var lobby_menu = LobbyMenu.instance()
get_tree().get_root().add_child(lobby_menu) get_tree().get_root().add_child(lobby_menu)
gamestate.set_player(get_tree().get_network_unique_id()) gamestate.set_player(get_tree().get_network_unique_id())
queue_free() queue_free()
else: else:
_on_back_pressed() _on_back_pressed()
@ -30,4 +30,4 @@ func _on_host_pressed():
func _on_back_pressed(): func _on_back_pressed():
queue_free() queue_free()
get_tree().get_root().get_node("multiplayer_menu").show()
get_tree().get_root().get_node("multiplayer_menu").show()

4
scripts/menus/direct_join.gd → scripts/menus/direct_join_menu.gd

@ -6,8 +6,8 @@ func _draw():
func _on_join_pressed(): func _on_join_pressed():
var ip = find_node("ip").text
var port = find_node("port").get_value()
var ip = find_node("ip").text
var port = find_node("port").get_value()
client.join_game(ip, int(port)) client.join_game(ip, int(port))
queue_free() queue_free()

10
scripts/menus/ingame.gd → scripts/menus/ingame_menu.gd

@ -5,14 +5,6 @@ func _draw():
find_node("resume").grab_focus() 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(): func _on_resume_pressed():
hide() hide()
@ -22,4 +14,4 @@ func _on_settings_pressed():
func _on_end_pressed(): func _on_end_pressed():
gamestate.quit_game()
gamestate.quit_game()

14
scripts/menus/lobby.gd → scripts/menus/lobby_menu.gd

@ -10,21 +10,21 @@ func _ready():
get_tree().get_root().get_node("multiplayer_menu").hide() get_tree().get_root().get_node("multiplayer_menu").hide()
if get_tree().get_root().has_node("main_menu"): if get_tree().get_root().has_node("main_menu"):
get_tree().get_root().get_node("main_menu").hide() get_tree().get_root().get_node("main_menu").hide()
get_node("menu/back").connect("pressed",self,"_on_back_pressed") get_node("menu/back").connect("pressed",self,"_on_back_pressed")
gamestate.connect("players_changed", self, "_players_changed") gamestate.connect("players_changed", self, "_players_changed")
gamestate.connect("game_ready", self, "_game_ready") gamestate.connect("game_ready", self, "_game_ready")
gamestate.connect("game_started", self, "_game_started") gamestate.connect("game_started", self, "_game_started")
client.connect("server_disconnected", self, "_server_disconnected") client.connect("server_disconnected", self, "_server_disconnected")
player_settings.get_name_node().connect("text_changed",self,"_on_name_text_changed") player_settings.get_name_node().connect("text_changed",self,"_on_name_text_changed")
player_settings.get_color_node().connect("color_changed",self,"_on_color_color_changed") player_settings.get_color_node().connect("color_changed",self,"_on_color_color_changed")
player_settings.get_color_node().connect("draw",self,"_on_player_changed") player_settings.get_color_node().connect("draw",self,"_on_player_changed")
countdown_timer.set_wait_time(server.LOBBY_READY_WAIT_TIME) countdown_timer.set_wait_time(server.LOBBY_READY_WAIT_TIME)
if gamestate.game_name:
if gamestate.game_name:
find_node("server_name").set_text(gamestate.game_name) find_node("server_name").set_text(gamestate.game_name)
find_node("server_name").set_tooltip(gamestate.game_name) find_node("server_name").set_tooltip(gamestate.game_name)
@ -61,7 +61,7 @@ func _game_ready(all_ready):
else: else:
countdown_timer.stop() countdown_timer.stop()
get_node("countdown").hide() get_node("countdown").hide()
func _game_started(): func _game_started():
queue_free() queue_free()

2
scripts/menus/local_game.gd

@ -4,7 +4,7 @@ onready var player_settings = find_node("player_settings")
func _ready(): func _ready():
find_node("bots").set_pressed(local_storage.read_value("bots", true))
find_node("bots").set_pressed(config.get_value("game","bots", true))
func _draw(): func _draw():

2
scripts/menus/main.gd → scripts/menus/main_menu.gd

@ -8,9 +8,11 @@ var SettingsMenu = preload("res://scenes/menus/SettingsMenu.tscn")
func _ready(): func _ready():
gamestate.connect("server_disconnected", self, "_server_disconnected") gamestate.connect("server_disconnected", self, "_server_disconnected")
func _draw(): func _draw():
find_node("multiplayer").grab_focus() find_node("multiplayer").grab_focus()
func _on_multiplayer_pressed(): func _on_multiplayer_pressed():
var multiplayer_menu = MultiplayerMenu.instance() var multiplayer_menu = MultiplayerMenu.instance()
get_tree().get_root().add_child(multiplayer_menu) get_tree().get_root().add_child(multiplayer_menu)

10
scripts/menus/server_create.gd → scripts/menus/server_create_menu.gd

@ -2,12 +2,12 @@ extends Control
func _ready(): func _ready():
var player_name = local_storage.read_value("player_name", false)
var player_name = config.get_value("game","player_name", false)
var game_title = "New Game" var game_title = "New Game"
if player_name: if player_name:
game_title += " by " + player_name game_title += " by " + player_name
find_node("name").set_text(game_title) find_node("name").set_text(game_title)
find_node("bots").set_pressed(local_storage.read_value("bots", true))
find_node("bots").set_pressed(config.get_value("game","bots", true))
func _draw(): func _draw():
@ -21,14 +21,16 @@ func _on_create_pressed():
var bots = 0 var bots = 0
if find_node("bots").is_pressed(): if find_node("bots").is_pressed():
bots = 1 bots = 1
req.post_request('client/game/create', to_json({'name' : server_name, 'bots' : bots}))
req.post_request('client/game/create', to_json({'name' : server_name, 'bots' : bots}))
func _on_game_created(result, response_code, headers, body): func _on_game_created(result, response_code, headers, body):
if result == OK && response_code == HTTPClient.RESPONSE_OK: if result == OK && response_code == HTTPClient.RESPONSE_OK:
var json = JSON.parse(body.get_string_from_utf8()) var json = JSON.parse(body.get_string_from_utf8())
gamestate.game_name = json.result['name'] gamestate.game_name = json.result['name']
client.join_game(game_server.SERVER_ADDR, int(json.result['port']))
client.join_game(game_server.get_server_addr(), int(json.result['port']))
else:
get_tree().get_root().get_node("multiplayer_menu").show_error_dialog(tr("ERROR_GAME_CREATION"))
queue_free() queue_free()

2
scripts/menus/server.gd → scripts/menus/server_menu.gd

@ -116,7 +116,7 @@ func _on_create_pressed():
func _on_join_pressed(): func _on_join_pressed():
client.join_game(game_server.SERVER_ADDR, int(selected_game['port']))
client.join_game(game_server.get_server_addr(), int(selected_game['port']))
func _connection_succeeded(): func _connection_succeeded():

67
scripts/menus/settings.gd

@ -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()

89
scripts/menus/settings_controls.gd

@ -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

124
scripts/menus/settings_controls_menu.gd

@ -0,0 +1,124 @@
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 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))

116
scripts/menus/settings_menu.gd

@ -0,0 +1,116 @@
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")
# game
find_node("bots").set_pressed(config.get_value("game","bots", true))
# graphics
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])))
# system
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 _draw():
game_tab.grab_focus()
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 = 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_locales_tree_exiting():
config_apply.apply_locale()
func _on_save_pressed():
_on_apply_pressed()
_on_back_pressed()
func _on_apply_pressed():
# game
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())
# graphics
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())
# controls
config.set_value("controls","mapping",find_node("settings_controls").new_inputs)
# system
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)
config.save()
config_apply.apply_settings()
func _on_light_toggled(button_pressed):
find_node("shadows").set_disabled(not button_pressed)

14
scripts/menus/settings_player.gd

@ -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")

14
scripts/menus/settings_player_menu.gd

@ -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")

33
scripts/networking/game_server.gd

@ -7,8 +7,39 @@ const API_ADDR = "https://" + SERVER_ADDR + "/"
const HEADERS = ["Content-Type: application/json"] const HEADERS = ["Content-Type: application/json"]
const SSL = false const SSL = false
var server_addr:String = SERVER_ADDR
var api_addr:String = API_ADDR
var headers:Array = HEADERS
var ssl:bool = SSL
func http(): func http():
var game_server_requests = GameServerRequests.new() var game_server_requests = GameServerRequests.new()
add_child(game_server_requests) add_child(game_server_requests)
return game_server_requests
return game_server_requests
func get_server_addr():
return server_addr
func set_server_addr(new_server_addr:String):
server_addr = new_server_addr
func get_api_addr():
return api_addr
func set_api_addr(new_api_addr:String):
if not new_api_addr.ends_with("/"):
new_api_addr += "/"
api_addr = new_api_addr
func get_headers():
return headers
func get_ssl():
return ssl

8
scripts/networking/game_server_requests.gd

@ -16,19 +16,19 @@ func connect_http(node,function):
func get_request(path:String): func get_request(path:String):
http.request(game_server.API_ADDR + path, game_server.HEADERS, game_server.SSL, HTTPClient.METHOD_GET)
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_GET)
func post_request(path:String, data:String = ""): func post_request(path:String, data:String = ""):
http.request(game_server.API_ADDR + path, game_server.HEADERS, game_server.SSL, HTTPClient.METHOD_POST, data)
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_POST, data)
func put_request(path:String, data:String = ""): func put_request(path:String, data:String = ""):
http.request(game_server.API_ADDR + path, game_server.HEADERS, game_server.SSL, HTTPClient.METHOD_PUT, data)
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_PUT, data)
func delete_request(path:String, data:String = ""): func delete_request(path:String, data:String = ""):
http.request(game_server.API_ADDR + path, game_server.HEADERS, game_server.SSL, HTTPClient.METHOD_DELETE, data)
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_DELETE, data)
func _self_destroy(result, response_code, headers, body): func _self_destroy(result, response_code, headers, body):

21
scripts/networking/server.gd

@ -3,6 +3,7 @@ extends Node
const MAX_PEERS = 4 const MAX_PEERS = 4
const LOBBY_READY_WAIT_TIME = 3 const LOBBY_READY_WAIT_TIME = 3
const EMPTY_WAIT_TIME = 30 const EMPTY_WAIT_TIME = 30
const EMPTY_CLOSING_TIME = 60
var port:int = -1 var port:int = -1
var dedicated_server:bool = false var dedicated_server:bool = false
@ -25,13 +26,21 @@ func _ready():
server_secret=argument.split("=")[1] server_secret=argument.split("=")[1]
if argument.split("=")[0] == "--bots": if argument.split("=")[0] == "--bots":
gamestate.set_bots(bool(int(argument.split("=")[1]))) gamestate.set_bots(bool(int(argument.split("=")[1])))
if argument.split("=")[0] == "--server-addr":
game_server.set_server_addr(str(argument.split("=")[1]))
if argument.split("=")[0] == "--api-addr":
game_server.set_api_addr(str(argument.split("=")[1]))
if dedicated_server: if dedicated_server:
var err = host_game(port) var err = host_game(port)
if err == OK: if err == OK:
print(server_id + "New game hosted: port=" + str(port) + " secret=" + str(server_secret) + " bots=" + str(gamestate.bots))
print(server_id + "New game hosted: port=" + str(port) + " secret=" + str(server_secret) + " bots=" + str(gamestate.bots) + " server-addr=" + game_server.get_server_addr() + " api-addr=" + game_server.get_api_addr())
print(server_id + "Waiting for connection, closing server in " + str(EMPTY_CLOSING_TIME) + " seconds")
timer.set_wait_time(EMPTY_CLOSING_TIME)
timer.connect("timeout",self,"quit_server",[true])
timer.start()
else: else:
print(server_id + "Could not create Server! (port=" + str(port) + " secret=" + str(server_secret) + ")")
push_error(server_id + "Could not create Server! (port=" + str(port) + " secret=" + str(server_secret) + " server-addr=" + game_server.get_server_addr() + " api-addr=" + game_server.get_api_addr() + ")")
quit_server() quit_server()
@ -76,8 +85,12 @@ func local_game(name:String, color:Color, bots:bool):
func update_server_data(): func update_server_data():
var req = game_server.http() var req = game_server.http()
req.put_request("game",to_json({'secret' : server_secret, 'player_count' : gamestate.players.size(), 'running' : gamestate.game_running}))
var player_count = 0
if gamestate.players != null:
player_count = gamestate.players.size()
req.put_request("game",to_json({'secret' : server_secret, 'player_count' : player_count, 'running' : gamestate.game_running}))
func _client_connected(id): func _client_connected(id):
if get_tree().is_network_server(): if get_tree().is_network_server():
if dedicated_server: if dedicated_server:

18
scripts/player/base_inventory.gd

@ -9,14 +9,6 @@ var road_straights = [
roads_factory.STRAIGHT_SMALL, roads_factory.STRAIGHT_SMALL,
] ]
var roads_left = [
roads_factory.CURVE_LEFT,
roads_factory.CURVE_LARGE_LEFT,
roads_factory.CURVE_SMALL_LEFT,
roads_factory.SKEW_LEFT,
roads_factory.CURVED_LEFT,
]
var roads_right = [ var roads_right = [
roads_factory.CURVE_RIGHT, roads_factory.CURVE_RIGHT,
roads_factory.CURVE_LARGE_RIGHT, roads_factory.CURVE_LARGE_RIGHT,
@ -25,6 +17,14 @@ var roads_right = [
roads_factory.CURVED_RIGHT, roads_factory.CURVED_RIGHT,
] ]
var roads_left = [
roads_factory.CURVE_LEFT,
roads_factory.CURVE_LARGE_LEFT,
roads_factory.CURVE_SMALL_LEFT,
roads_factory.SKEW_LEFT,
roads_factory.CURVED_LEFT,
]
var roads_up = [ var roads_up = [
roads_factory.RAMP_UP, roads_factory.RAMP_UP,
roads_factory.RAMP_CURVED_UP, roads_factory.RAMP_CURVED_UP,
@ -41,7 +41,7 @@ var roads_special = [
roads_factory.LOOP, roads_factory.LOOP,
] ]
var roads = [ road_straights, roads_left, roads_right, roads_up, roads_down, roads_special ]
var roads = [ road_straights, roads_right, roads_left, roads_up, roads_down, roads_special ]
var player:Player var player:Player
var route:Route var route:Route

61
scripts/player/bot_controls.gd

@ -2,13 +2,13 @@ extends Spatial
var player:Player var player:Player
const MAX_ROAD_INDEX = 1
var error_rate:float = 0.00
var underspeed_rate:float = 0.00
const MAX_OFFSET = 8.0
const OFFSET_STEPS = 0.01
var break_constrain = 0.0
func _ready():
randomize()
export var overspeed_rate:float = 0.3
export var underspeed_rate:float = 0.1
func _physics_process(delta): func _physics_process(delta):
@ -18,27 +18,36 @@ func _physics_process(delta):
player.reset() player.reset()
else: else:
if player.get_road() != null: if player.get_road() != null:
var rate = randf()
var road = player.get_road() var road = player.get_road()
var road_index = 0
var speed_constrain = 0.0
while road != null && road_index < MAX_ROAD_INDEX:
for index in range(road.speed_constrains.size()):
var constrain = road.speed_constrains[index]
if constrain.z > 0:
speed_constrain = max(speed_constrain, constrain.z)
elif constrain.z < 0:
speed_constrain = min(speed_constrain, constrain.z)
road = player.route.get_road(road.get_index() + 1)
road_index += 1
var rate = util.randf()
var speed = player.current_speed var speed = player.current_speed
if speed_constrain < 0:
player.thrust = 1
elif speed_constrain > 0 && speed > speed_constrain:
var offset = 0
var distance = player.follow.get_offset()
var tmp_break_constrain = 0.0
break_constrain = 0.0
while tmp_break_constrain == 0.0 and offset < MAX_OFFSET && road != null:
var constrain_index = road.get_constrain_index(distance)
var road_length = road.get_lane_curve(player.lane).get_baked_length()
if constrain_index >= 0:
tmp_break_constrain = road.speed_constrains[constrain_index].z
if tmp_break_constrain > break_constrain:
break_constrain = tmp_break_constrain
distance += OFFSET_STEPS
offset += OFFSET_STEPS
if distance >= road_length:
distance = 0
road = gamestate.game.route.get_road(road.get_index()+1)
if break_constrain > 0 && speed > break_constrain - 0.04 && rate > overspeed_rate:
player.thrust = -1 player.thrust = -1
elif rate > underspeed_rate:
player.thrust = 1
elif speed - 0.08 < break_constrain && rate > underspeed_rate:
player.thrust = 1
elif break_constrain == 0 && rate > underspeed_rate:
player.thrust = 1
else: else:
player.thrust = 0 player.thrust = 0
@ -48,9 +57,9 @@ func set_player(path:String):
get_node("inventory").set_player(player) get_node("inventory").set_player(player)
func set_error_rate(new_error_rate:float):
error_rate = new_error_rate
func set_overspeed_rate(new_overspeed_rate:float):
overspeed_rate = new_overspeed_rate
func set_underspeed_rate(new_underspeed_rate:float): func set_underspeed_rate(new_underspeed_rate:float):
underspeed_rate = new_underspeed_rate
underspeed_rate = new_underspeed_rate

27
scripts/player/human_controls.gd

@ -2,38 +2,41 @@ extends Spatial
var player:Player var player:Player
onready var camera:InterpolatedCamera = get_node("camera") onready var camera:InterpolatedCamera = get_node("camera")
onready var ingame_menu:Spatial = find_node("ingame_menu")
func _physics_process(delta): func _physics_process(delta):
if is_network_master() && player != null: if is_network_master() && player != null:
if Input.is_action_just_pressed("controls_menu"):
ingame_menu.set_visible(not ingame_menu.is_visible_in_tree())
if player.is_out: if player.is_out:
camera.set_speed(0.1) camera.set_speed(0.1)
if player.timer.get_time_left() > 0: if player.timer.get_time_left() > 0:
get_node("hud/reset").set_text(str(int(player.timer.get_time_left()) + 1)) get_node("hud/reset").set_text(str(int(player.timer.get_time_left()) + 1))
else: else:
get_node("hud/reset").set_text(tr("RESET"))
get_node("hud/reset").set_text(tr("RESET"))
if Input.is_action_pressed("controls_reset"): if Input.is_action_pressed("controls_reset"):
if player.reset(): if player.reset():
camera.set_speed(10) camera.set_speed(10)
get_node("hud/reset").set_text("")
else:
get_node("hud/reset").set_text("")
elif not ingame_menu.is_visible_in_tree():
if Input.is_action_pressed("controls_thrust"): if Input.is_action_pressed("controls_thrust"):
player.thrust = 1 player.thrust = 1
elif Input.is_action_pressed("controls_break"): elif Input.is_action_pressed("controls_break"):
player.thrust = -1 player.thrust = -1
else: else:
player.thrust = 0 player.thrust = 0
get_node("hud/speed").set_text(str(player.current_speed))
get_node("hud/speed_slider").set_value(player.current_speed * 1000)
if Input.is_action_pressed("debug_camera_1"): if Input.is_action_pressed("debug_camera_1"):
set_debug_camera(0)
set_debug_camera(0)
elif Input.is_action_pressed("debug_camera_2"): elif Input.is_action_pressed("debug_camera_2"):
set_debug_camera(1)
set_debug_camera(1)
elif Input.is_action_pressed("debug_camera_3"): elif Input.is_action_pressed("debug_camera_3"):
set_debug_camera(2)
set_debug_camera(2)
elif Input.is_action_pressed("debug_camera_4"): elif Input.is_action_pressed("debug_camera_4"):
set_debug_camera(3)
set_debug_camera(3)
func set_player(path:String): func set_player(path:String):
@ -45,5 +48,5 @@ func set_player(path:String):
func set_debug_camera(idx): func set_debug_camera(idx):
if idx < gamestate.game.players.get_child_count():
camera.set_target_path(gamestate.game.players.get_child(idx).find_node("CameraTarget").get_path())
if idx < gamestate.game.get_node("players").get_child_count():
camera.set_target_path(gamestate.game.get_node("players").get_child(idx).find_node("CameraTarget").get_path())

8
scripts/player/human_inventory.gd

@ -7,7 +7,7 @@ var preview:Spatial
func _ready(): func _ready():
view = get_node("view") view = get_node("view")
preview = get_node("preview") preview = get_node("preview")
var hud_track = get_node("../hud/inventory/track")
var hud_track = get_node("../hud/inventory/track_container/track")
hud_track.get_texture().set_viewport_path_in_scene(str(get_path()) + "/viewport") hud_track.get_texture().set_viewport_path_in_scene(str(get_path()) + "/viewport")
connect("item_changed",self,"_on_item_changed") connect("item_changed",self,"_on_item_changed")
connect("item_changed",preview,"_on_inventory_item_changed") connect("item_changed",preview,"_on_inventory_item_changed")
@ -56,7 +56,7 @@ func _on_item_changed(road_identifier, player):
if is_network_master(): if is_network_master():
if view.get_child_count() > 0: if view.get_child_count() > 0:
view.remove_child(view.get_child(0)) view.remove_child(view.get_child(0))
view.add_child(item) view.add_child(item)
get_node("../hud/inventory/type").set_text(tr(road_identifier))
get_node("../hud/inventory/track_container/type").set_text(tr(road_identifier))

51
scripts/player/player.gd

@ -53,39 +53,38 @@ func _physics_process(delta):
if is_network_master(): if is_network_master():
if not is_out: if not is_out:
var max_speed = MAX_SPEED var max_speed = MAX_SPEED
if get_road() != null: if get_road() != null:
var road = get_road() var road = get_road()
if is_in_group("first"): if is_in_group("first"):
max_speed *= road.get_first_speed_factor() max_speed *= road.get_first_speed_factor()
if road.get_creator() == get_index():
elif road.get_creator() == get_index():
max_speed *= road.get_creator_speed_factor() max_speed *= road.get_creator_speed_factor()
else: else:
max_speed *= road.get_chasers_speed_factor() max_speed *= road.get_chasers_speed_factor()
if thrust == 1: if thrust == 1:
current_speed += speed_factor current_speed += speed_factor
elif thrust == -1: elif thrust == -1:
current_speed -= speed_factor * brake_factor current_speed -= speed_factor * brake_factor
else: else:
current_speed -= speed_factor * friction_brake_factor current_speed -= speed_factor * friction_brake_factor
if current_speed >= max_speed: if current_speed >= max_speed:
current_speed = max_speed current_speed = max_speed
elif current_speed < 0: elif current_speed < 0:
current_speed = 0 current_speed = 0
follow.set_offset(follow.get_offset() + current_speed) follow.set_offset(follow.get_offset() + current_speed)
if follow.get_offset() < 0: if follow.get_offset() < 0:
follow.set_offset(0) follow.set_offset(0)
if has_next && (path.curve.get_point_count() == 0 || follow.get_unit_offset() >= 1.0): if has_next && (path.curve.get_point_count() == 0 || follow.get_unit_offset() >= 1.0):
has_next = false has_next = false
if path.curve.get_point_count() > 0: if path.curve.get_point_count() > 0:
path.curve.clear_points() path.curve.clear_points()
path.curve.set_bake_interval(0.05) path.curve.set_bake_interval(0.05)
for i in range(buffered_curve.get_point_count()): for i in range(buffered_curve.get_point_count()):
var _pos = buffered_curve.get_point_position(i) var _pos = buffered_curve.get_point_position(i)
@ -105,7 +104,7 @@ func _physics_process(delta):
if get_road() != null: if get_road() != null:
var road = get_road() var road = get_road()
var penalty_index = road.penalty_index(follow.get_offset(), current_speed) var penalty_index = road.penalty_index(follow.get_offset(), current_speed)
if penalty_index >= 0: if penalty_index >= 0:
torque_penalty = road.get_torque_penalty(penalty_index) torque_penalty = road.get_torque_penalty(penalty_index)
force_penalty = road.get_force_penalty(penalty_index) force_penalty = road.get_force_penalty(penalty_index)
@ -113,9 +112,10 @@ func _physics_process(delta):
is_out = true is_out = true
is_resetable = false is_resetable = false
timer.start() timer.start()
check_position() check_position()
else: else:
var road = get_road()
race_car.get_node("ray").set_enabled(false) race_car.get_node("ray").set_enabled(false)
if force_penalty.length() != 0: if force_penalty.length() != 0:
race_car.move_and_slide(force_penalty * current_speed + Vector3(0,-0.5,0)) race_car.move_and_slide(force_penalty * current_speed + Vector3(0,-0.5,0))
@ -136,21 +136,21 @@ func get_road():
func _on_raceCar_road_entered(road): func _on_raceCar_road_entered(road):
var prev_road = route.get_road(road.get_index()-1) var prev_road = route.get_road(road.get_index()-1)
if prev_road != null: if prev_road != null:
prev_road.body.set_collision_layer_bit(get_index(),0) prev_road.body.set_collision_layer_bit(get_index(),0)
buffered_curve = road.get_lane_curve(lane) buffered_curve = road.get_lane_curve(lane)
buffered_rotation = last_rotation buffered_rotation = last_rotation
if path.curve.get_point_count() > 0: if path.curve.get_point_count() > 0:
buffered_translate = Util.curve_get_last_point(path.curve)
buffered_translate = util.curve_get_last_point(path.curve)
if road.get_end_rotation().length() != 0: if road.get_end_rotation().length() != 0:
last_rotation += road.get_end_rotation() last_rotation += road.get_end_rotation()
has_next = true has_next = true
@ -189,31 +189,30 @@ master func reset():
if is_resetable: if is_resetable:
has_next = false has_next = false
current_speed = 0 current_speed = 0
var road = race_car.road var road = race_car.road
road.body.set_collision_layer_bit(get_index(),1) road.body.set_collision_layer_bit(get_index(),1)
while road.reset_index != 0: while road.reset_index != 0:
road = route.get_road(road.get_index() - road.reset_index) road = route.get_road(road.get_index() - road.reset_index)
road.body.set_collision_layer_bit(get_index(),1) road.body.set_collision_layer_bit(get_index(),1)
path.curve.clear_points() path.curve.clear_points()
force_penalty = Vector3(0,0,0) force_penalty = Vector3(0,0,0)
torque_penalty = Vector3(0,0,0) torque_penalty = Vector3(0,0,0)
buffered_translate = road.get_translation() buffered_translate = road.get_translation()
last_rotation = road.get_rotation() last_rotation = road.get_rotation()
race_car.road_index = road.get_index() race_car.road_index = road.get_index()
race_car.road = null race_car.road = null
race_car.collider = null race_car.collider = null
race_car.transform = Transform() race_car.transform = Transform()
race_car.get_node("ray").set_enabled(true) race_car.get_node("ray").set_enabled(true)
follow.set_transform(road.get_transform()) follow.set_transform(road.get_transform())
is_out = false is_out = false
is_resetable = false is_resetable = false
return true return true

25
scripts/road/road.gd

@ -85,12 +85,20 @@ func get_next_lane(lane):
return lane return lane
func penalty_index(distance:float, speed:float):
func get_constrain_index(distance:float):
for index in range(speed_constrains.size()): for index in range(speed_constrains.size()):
var constrain = speed_constrains[index] var constrain = speed_constrains[index]
if constrain.x <= distance && constrain.y >= distance: if constrain.x <= distance && constrain.y >= distance:
if constrain.z < 0 && speed < constrain.z * -1 || constrain.z > 0 && speed > constrain.z:
return index
return index
return -1
func penalty_index(distance:float, speed:float):
var constrain_index = get_constrain_index(distance)
if constrain_index >= 0:
var constrain = speed_constrains[constrain_index]
if constrain.z < 0 && speed < constrain.z * -1 || constrain.z > 0 && speed > constrain.z:
return constrain_index
return -1 return -1
@ -98,10 +106,7 @@ func get_torque_penalty(index:int):
if index >= 0: if index >= 0:
if torque_penalties.size() < (index + 1): if torque_penalties.size() < (index + 1):
return get_torque_penalty(index - 1) return get_torque_penalty(index - 1)
if get_rotation().length() != 0:
return torque_penalties[index].rotated(get_rotation().normalized(), get_rotation().length())
else:
return torque_penalties[index]
return torque_penalties[index]
return Vector3(0,0,0) return Vector3(0,0,0)
@ -113,7 +118,7 @@ func get_force_penalty(index:int):
return force_penalties[index].rotated(get_rotation().normalized(), get_rotation().length()) return force_penalties[index].rotated(get_rotation().normalized(), get_rotation().length())
else: else:
return force_penalties[index] return force_penalties[index]
return Vector3(0,0,0) return Vector3(0,0,0)
@ -121,9 +126,9 @@ func get_path_penalty(index:int):
if index >= 0: if index >= 0:
if path_penalties.size() < (index + 1): if path_penalties.size() < (index + 1):
return get_path_penalty(index - 1) return get_path_penalty(index - 1)
return path_penalties[index] return path_penalties[index]
return 0.0 return 0.0

Loading…
Cancel
Save