Add WIP config parser arg plus config file
This commit is contained in:
27
billiards.gd
27
billiards.gd
@@ -47,6 +47,8 @@ func _parse_args() -> void:
|
||||
match arg:
|
||||
"join_server":
|
||||
join_server(arg)
|
||||
"config":
|
||||
config(arg)
|
||||
"client":
|
||||
client(arg)
|
||||
"game":
|
||||
@@ -111,6 +113,31 @@ func join_server(_arg: String) -> void:
|
||||
|
||||
game_client.start_client(server_address, int(server_port))
|
||||
|
||||
func config(_arg: String) -> void:
|
||||
var config_entry = OS.get_cmdline_user_args()[-1]
|
||||
var config_file = ConfigFile.new()
|
||||
var err = config_file.load("res://configs/games.cfg")
|
||||
|
||||
if err != OK:
|
||||
push_error("Config file not loaded...")
|
||||
return
|
||||
|
||||
if not config_file.has_section(config_entry):
|
||||
push_error("Config entry doesn't exist: ", config_entry)
|
||||
return
|
||||
|
||||
var keys = config_file.get_section_keys(config_entry)
|
||||
for key in keys:
|
||||
match key:
|
||||
"server":
|
||||
var _server = config_file.get_value(config_entry, key)
|
||||
"client1":
|
||||
var _client1 = config_file.get_value(config_entry, key)
|
||||
"client2":
|
||||
var _client2 = config_file.get_value(config_entry, key)
|
||||
_:
|
||||
pass
|
||||
|
||||
func client(_arg: String) -> void:
|
||||
Globals.game_state.set_game_scene(
|
||||
"res://scenes/screens/lobby_screen/lobby.tscn"
|
||||
|
||||
Reference in New Issue
Block a user