aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/project.godot1
-rw-r--r--game/src/ArgumentParser.tscn24
-rw-r--r--game/src/Autoload/Arguments/ArgumentOption.gd (renamed from game/src/ArgumentOption.gd)0
-rw-r--r--game/src/Autoload/Arguments/ArgumentParser.gd (renamed from game/src/ArgumentParser.gd)22
-rw-r--r--game/src/Autoload/Arguments/ArgumentParser.tscn32
-rw-r--r--game/src/Autoload/Events.gd19
-rw-r--r--game/src/GameStart.tscn5
-rw-r--r--game/src/MusicConductor/SongInfo.gd2
8 files changed, 62 insertions, 43 deletions
diff --git a/game/project.godot b/game/project.godot
index 441001d..3bb2438 100644
--- a/game/project.godot
+++ b/game/project.godot
@@ -21,6 +21,7 @@ config/project_settings_override.template="user://settings.cfg"
[autoload]
+ArgumentParser="*res://src/Autoload/Arguments/ArgumentParser.tscn"
Events="*res://src/Autoload/Events.gd"
Resolution="*res://src/Autoload/Resolution.gd"
SoundManager="*res://src/Autoload/SoundManager.gd"
diff --git a/game/src/ArgumentParser.tscn b/game/src/ArgumentParser.tscn
deleted file mode 100644
index 964c19e..0000000
--- a/game/src/ArgumentParser.tscn
+++ /dev/null
@@ -1,24 +0,0 @@
-[gd_scene load_steps=5 format=3 uid="uid://dayjmgc34tqo6"]
-
-[ext_resource type="Script" path="res://src/ArgumentParser.gd" id="1_8e7gi"]
-[ext_resource type="Script" path="res://src/ArgumentOption.gd" id="2_f3c26"]
-
-[sub_resource type="Resource" id="Resource_tq3y4"]
-script = ExtResource("2_f3c26")
-name = &"help"
-aliases = Array[StringName]([&"h"])
-type = 1
-description = "Displays help and quits."
-default_value = false
-
-[sub_resource type="Resource" id="Resource_j1to4"]
-script = ExtResource("2_f3c26")
-name = &"game-debug"
-aliases = Array[StringName]([&"d", &"-debug", &"-debug-mode"])
-type = 1
-description = "Start in debug mode."
-default_value = false
-
-[node name="ArgumentParser" type="Node"]
-script = ExtResource("1_8e7gi")
-option_array = Array[ExtResource("2_f3c26")]([SubResource("Resource_tq3y4"), SubResource("Resource_j1to4")])
diff --git a/game/src/ArgumentOption.gd b/game/src/Autoload/Arguments/ArgumentOption.gd
index f14cef0..f14cef0 100644
--- a/game/src/ArgumentOption.gd
+++ b/game/src/Autoload/Arguments/ArgumentOption.gd
diff --git a/game/src/ArgumentParser.gd b/game/src/Autoload/Arguments/ArgumentParser.gd
index f1ee371..ce89dd8 100644
--- a/game/src/ArgumentParser.gd
+++ b/game/src/Autoload/Arguments/ArgumentParser.gd
@@ -53,11 +53,18 @@ func _parse_value(arg_name : StringName, value_string : String, type : Variant.T
return true
if value_string == "false" or value_string == "f" or value_string == "no" or value_string == "n":
return false
- return true
+ push_error("'%s' must be a valid boolean, '%s' is an invalid value." % [arg_name, value_string])
+ return null
TYPE_INT:
- return value_string.to_int()
+ if value_string.is_valid_int():
+ return value_string.to_int()
+ push_error("'%s' must be a valid integer, '%s' is an invalid value." % [arg_name, value_string])
+ return null
TYPE_FLOAT:
- return value_string.to_float()
+ if value_string.is_valid_float():
+ return value_string.to_float()
+ push_error("'%s' must be a valid float, '%s' is an invalid value." % [arg_name, value_string])
+ return null
TYPE_STRING, TYPE_STRING_NAME:
return value_string
TYPE_COLOR:
@@ -204,10 +211,11 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray)
continue
current_key = key
- var arg_result = _parse_value(key, value, current_option.type)
- if arg_result != null:
- dictionary[current_option.name] = arg_result
- current_option = null
+ if first_equal > -1:
+ var arg_result = _parse_value(key, value, current_option.type)
+ if arg_result != null:
+ dictionary[current_option.name] = arg_result
+ current_option = null
return dictionary
diff --git a/game/src/Autoload/Arguments/ArgumentParser.tscn b/game/src/Autoload/Arguments/ArgumentParser.tscn
new file mode 100644
index 0000000..8fda8f1
--- /dev/null
+++ b/game/src/Autoload/Arguments/ArgumentParser.tscn
@@ -0,0 +1,32 @@
+[gd_scene load_steps=6 format=3 uid="uid://dayjmgc34tqo6"]
+
+[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentParser.gd" id="1_pc7xr"]
+[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentOption.gd" id="2_4hguj"]
+
+[sub_resource type="Resource" id="Resource_tq3y4"]
+script = ExtResource("2_4hguj")
+name = &"help"
+aliases = Array[StringName]([&"h"])
+type = 1
+description = "Displays help and quits."
+default_value = false
+
+[sub_resource type="Resource" id="Resource_j1to4"]
+script = ExtResource("2_4hguj")
+name = &"game-debug"
+aliases = Array[StringName]([&"d", &"-debug", &"-debug-mode"])
+type = 1
+description = "Start in debug mode."
+default_value = false
+
+[sub_resource type="Resource" id="Resource_tiax1"]
+script = ExtResource("2_4hguj")
+name = &"compatibility-mode"
+aliases = Array[StringName]([&"-compat"])
+type = 4
+description = "Load Victoria 2 assets from this path."
+default_value = ""
+
+[node name="ArgumentParser" type="Node"]
+script = ExtResource("1_pc7xr")
+option_array = Array[ExtResource("2_4hguj")]([SubResource("Resource_tq3y4"), SubResource("Resource_j1to4"), SubResource("Resource_tiax1")])
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd
index 8800041..4387cc7 100644
--- a/game/src/Autoload/Events.gd
+++ b/game/src/Autoload/Events.gd
@@ -17,20 +17,25 @@ var _define_filepaths_dict : Dictionary = {
GameSingleton.get_good_icons_dir_key(): "res://art/economy/goods"
}
-# Set this to your Vic2 install dir or a mod's dir to enable compatibility mode
-# (this won't work for mods which rely on vanilla map assets, copy missing assets
-# into the mod's dir for a temporary fix)
-const _compatibility_mode_path : String = ""
-
# REQUIREMENTS
# * FS-333, FS-334, FS-335, FS-341
func _ready():
GameSingleton.setup_logger()
+ # Set this to your Vic2 install dir or a mod's dir to enable compatibility mode
+ # (this won't work for mods which rely on vanilla map assets, copy missing assets
+ # into the mod's dir for a temporary fix)
+ # Usage: OpenVic --compatibility-mode <path>
+
+ var compatibility_mode_path : String
+ if ProjectSettings.has_setting(ArgumentParser.argument_setting_path):
+ var arg_dictionary : Dictionary = ProjectSettings.get_setting(ArgumentParser.argument_setting_path)
+ compatibility_mode_path = arg_dictionary.get(&"compatibility-mode", compatibility_mode_path)
+
var start := Time.get_ticks_usec()
- if _compatibility_mode_path:
- if GameSingleton.load_defines_compatibility_mode(_compatibility_mode_path) != OK:
+ if compatibility_mode_path:
+ if GameSingleton.load_defines_compatibility_mode(compatibility_mode_path) != OK:
push_error("Errors loading game defines!")
else:
if GameSingleton.load_defines(_define_filepaths_dict) != OK:
diff --git a/game/src/GameStart.tscn b/game/src/GameStart.tscn
index d5f9d45..2046bb5 100644
--- a/game/src/GameStart.tscn
+++ b/game/src/GameStart.tscn
@@ -1,6 +1,5 @@
-[gd_scene load_steps=7 format=3 uid="uid://1udsn4mggep2"]
+[gd_scene load_steps=6 format=3 uid="uid://1udsn4mggep2"]
-[ext_resource type="PackedScene" uid="uid://dayjmgc34tqo6" path="res://src/ArgumentParser.tscn" id="1_oe61r"]
[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/GameMenu.tscn" id="1_wlojq"]
[ext_resource type="Script" path="res://src/SplashContainer.gd" id="2_xmcgv"]
[ext_resource type="Texture2D" uid="uid://deef5hufq0j61" path="res://splash_assets/splash_end.png" id="3_qfv12"]
@@ -15,8 +14,6 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
-[node name="ArgumentParser" parent="." instance=ExtResource("1_oe61r")]
-
[node name="GameMenu" parent="." instance=ExtResource("1_wlojq")]
visible = false
layout_mode = 1
diff --git a/game/src/MusicConductor/SongInfo.gd b/game/src/MusicConductor/SongInfo.gd
index f7343c0..1ee9adc 100644
--- a/game/src/MusicConductor/SongInfo.gd
+++ b/game/src/MusicConductor/SongInfo.gd
@@ -1,4 +1,4 @@
-extends Node
+extends Resource
class_name SongInfo
var song_path : String = ""