Skip to content

Commit

Permalink
Added mod command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
Hop311 committed Jan 13, 2024
1 parent dd008b3 commit 451f146
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,11 @@ bin/*
!game/common/map/*.obj

# JetBrains
.idea
.idea

# scons stuff
.cache
compile_commands.json

# ccls
.ccls-cache
2 changes: 1 addition & 1 deletion game/src/Game/Autoload/Argument/ArgumentOption.gd
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func _set(property : StringName, value : Variant) -> bool:
return false

func _get_property_list() -> Array[Dictionary]:
var properties := []
var properties := [] as Array[Dictionary]

properties.append({
"name": "default_value",
Expand Down
16 changes: 12 additions & 4 deletions game/src/Game/Autoload/Argument/ArgumentParser.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://dayjmgc34tqo6"]
[gd_scene load_steps=8 format=3 uid="uid://dayjmgc34tqo6"]

[ext_resource type="Script" path="res://src/Game/Autoload/Argument/ArgumentParser.gd" id="1_pc7xr"]
[ext_resource type="Script" path="res://src/Game/Autoload/Argument/ArgumentOption.gd" id="2_4hguj"]
Expand All @@ -22,20 +22,28 @@ default_value = false
[sub_resource type="Resource" id="Resource_tiax1"]
script = ExtResource("2_4hguj")
name = &"base-path"
aliases = Array[StringName]([])
aliases = Array[StringName]([&"b"])
type = 4
description = "Load Victoria 2 assets from this exact path."
default_value = ""

[sub_resource type="Resource" id="Resource_sh3m3"]
script = ExtResource("2_4hguj")
name = &"search-path"
aliases = Array[StringName]([])
aliases = Array[StringName]([&"s"])
type = 4
description = "Search for Victoria 2 assets at this path."
default_value = ""

[sub_resource type="Resource" id="Resource_8ab4j"]
script = ExtResource("2_4hguj")
name = &"mod"
aliases = Array[StringName]([&"m"])
type = 4
description = "Load Victoria 2 mod with this name"
default_value = ""

[node name="ArgumentParser" type="Node"]
editor_description = "SS-56"
script = ExtResource("1_pc7xr")
option_array = Array[ExtResource("2_4hguj")]([SubResource("Resource_tq3y4"), SubResource("Resource_j1to4"), SubResource("Resource_tiax1"), SubResource("Resource_sh3m3")])
option_array = Array[ExtResource("2_4hguj")]([SubResource("Resource_tq3y4"), SubResource("Resource_j1to4"), SubResource("Resource_tiax1"), SubResource("Resource_sh3m3"), SubResource("Resource_8ab4j")])
6 changes: 4 additions & 2 deletions game/src/Game/GameStart.gd
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ func _load_compatibility_mode() -> void:

var paths : PackedStringArray = [actual_base_path]

# Example for adding mod paths
#paths.push_back(actual_base_path + "/mod/TGC")
# Add mod paths
var settings_mod_name : String = ArgumentParser.get_argument(&"mod", "")
if settings_mod_name:
paths.push_back(actual_base_path + "/mod/" + settings_mod_name)

if GameSingleton.load_defines_compatibility_mode(paths) != OK:
push_error("Errors loading game defines!")
Expand Down

0 comments on commit 451f146

Please sign in to comment.