Skip to content

Commit

Permalink
Added 'Config files' to 'View' menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed May 27, 2024
1 parent 782a150 commit 76ecffc
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 17 deletions.
51 changes: 37 additions & 14 deletions Scenes/CfgLoader.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends Node
onready var oGame = Nodelist.list["oGame"]
onready var oMessage = Nodelist.list["oMessage"]
onready var oConfigFilesListWindow = Nodelist.list["oConfigFilesListWindow"]


# These are dictionaries containing dictionaries.
Expand All @@ -13,6 +14,8 @@ onready var oMessage = Nodelist.list["oMessage"]
#var creature_cfg : Dictionary
#var trapdoor_cfg : Dictionary

var paths_loaded = {}
const files_to_load = ["objects.cfg", "creature.cfg", "trapdoor.cfg", "terrain.cfg", "cubes.cfg", "slabset.toml", "columnset.toml"]

enum {
LOAD_CFG_FXDATA,
Expand All @@ -30,36 +33,56 @@ func start(mapPath):
Cube.clear_all_cube_data()

var campaign_cfg = load_campaign_data(mapPath)

paths_loaded = {
LOAD_CFG_FXDATA: [],
LOAD_CFG_CAMPAIGN: [],
LOAD_CFG_CURRENT_MAP: []
}
var config_dirs = {
LOAD_CFG_FXDATA: oGame.DK_FXDATA_DIRECTORY,
LOAD_CFG_CAMPAIGN: oGame.GAME_DIRECTORY.plus_file(campaign_cfg.get("common", {}).get("CONFIGS_LOCATION", "")),
LOAD_CFG_CURRENT_MAP: mapPath.get_basename()
}
for cfg_type in [LOAD_CFG_FXDATA, LOAD_CFG_CAMPAIGN, LOAD_CFG_CURRENT_MAP]:
var cfg_dir = config_dirs[cfg_type]
for file_name in ["objects.cfg", "creature.cfg", "trapdoor.cfg", "terrain.cfg", "cubes.cfg", "slabset.toml", "columnset.toml"]:
for i in files_to_load.size():
var file_name = files_to_load[i]
var file_path = cfg_dir.plus_file(file_name)
if cfg_type == LOAD_CFG_CURRENT_MAP:
file_path = cfg_dir + "." + file_name

if File.new().file_exists(file_path):
match file_name:
"objects.cfg": load_objects_data(file_path)
"creature.cfg": load_creatures_data(file_path)
"trapdoor.cfg": load_trapdoor_data(file_path)
"terrain.cfg": load_terrain_data(file_path)
"cubes.cfg": load_cubes_data(file_path)
"slabset.toml": load_slabset_data(file_path)
"columnset.toml": load_columnset_data(file_path)
"objects.cfg":
load_objects_data(file_path)
"creature.cfg":
load_creatures_data(file_path)
"trapdoor.cfg":
load_trapdoor_data(file_path)
"terrain.cfg":
load_terrain_data(file_path)
"cubes.cfg":
load_cubes_data(file_path)
"slabset.toml":
load_slabset_data(file_path)
"columnset.toml":
load_columnset_data(file_path)

paths_loaded[cfg_type].resize(files_to_load.size())
paths_loaded[cfg_type][i] = file_path
else:
if cfg_type == LOAD_CFG_FXDATA:
match file_name:
"cubes.cfg": Cube.load_dk_original_cubes()
"slabset.toml": Slabset.load_default_original_slabset() # Load slabs.dat and slabs.tng files
"columnset.toml": Columnset.load_default_original_columnset() # Load slabs.clm file

"cubes.cfg":
Cube.load_dk_original_cubes()
"slabset.toml":
Slabset.load_default_original_slabset()
"columnset.toml":
Columnset.load_default_original_columnset()

print('Loaded all .cfg and .toml files: ' + str(OS.get_ticks_msec() - CODETIME_LOADCFG_START) + 'ms')
if oConfigFilesListWindow.visible == true:
Utils.popup_centered(oConfigFilesListWindow)

func load_objects_data(path): # 10ms
var objects_cfg = Utils.read_dkcfg_file(path)
Expand Down
45 changes: 45 additions & 0 deletions Scenes/ConfigFilesListWindow.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
extends WindowDialog
onready var oCfgLoader = Nodelist.list["oCfgLoader"]
onready var oFileListGridA = Nodelist.list["oFileListGridA"]
onready var oFileListGridB = Nodelist.list["oFileListGridB"]
onready var oFileListGridC = Nodelist.list["oFileListGridC"]


func _on_ConfigFilesListWindow_about_to_show():
update_everything()

func update_everything():
print("update_everything")
for gridParent in [oFileListGridA, oFileListGridB, oFileListGridC]:
for child in gridParent.get_children():
child.queue_free()

print(oCfgLoader.paths_loaded)

for cfg_type in [oCfgLoader.LOAD_CFG_FXDATA, oCfgLoader.LOAD_CFG_CAMPAIGN, oCfgLoader.LOAD_CFG_CURRENT_MAP]:
if oCfgLoader.paths_loaded.has(cfg_type) == false:
continue

var addToGrid

match cfg_type:
oCfgLoader.LOAD_CFG_FXDATA:
addToGrid = oFileListGridA
oCfgLoader.LOAD_CFG_CAMPAIGN:
addToGrid = oFileListGridB
oCfgLoader.LOAD_CFG_CURRENT_MAP:
addToGrid = oFileListGridC

for path in oCfgLoader.paths_loaded[cfg_type]:
if path:
add_linkbutton(path, addToGrid)

func add_linkbutton(path, addToGrid):
var id = LinkButton.new()
id.connect("pressed", self, "_on_linkbutton_pressed", [path])
id.underline = LinkButton.UNDERLINE_MODE_ON_HOVER
id.text = path
addToGrid.add_child(id)

func _on_linkbutton_pressed(path):
OS.shell_open(path)
138 changes: 135 additions & 3 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=190 format=2]
[gd_scene load_steps=191 format=2]

[ext_resource path="res://Scenes/SlabStyle.gd" type="Script" id=1]
[ext_resource path="res://Scenes/SlabPlacement.gd" type="Script" id=2]
Expand Down Expand Up @@ -46,6 +46,7 @@
[ext_resource path="res://Scenes/DataLif.gd" type="Script" id=44]
[ext_resource path="res://Scenes/PickThingWindow.gd" type="Script" id=45]
[ext_resource path="res://Scenes/CurrentTextures.gd" type="Script" id=46]
[ext_resource path="res://Scenes/ConfigFilesListWindow.gd" type="Script" id=47]
[ext_resource path="res://Scenes/Player.gd" type="Script" id=48]
[ext_resource path="res://Scenes/GenerateTerrain.gd" type="Script" id=49]
[ext_resource path="res://Scenes/View3D.gd" type="Script" id=50]
Expand Down Expand Up @@ -1700,7 +1701,7 @@ custom_colors/font_color_hover = Color( 1, 0.65098, 0.556863, 1 )
custom_colors/font_color_pressed = Color( 0.333333, 0.607843, 1, 1 )
text = "View"
align = 0
items = [ "Map folder", null, 0, false, false, 0, 0, null, "", false, "Script file", null, 0, false, false, 1, 0, null, "", false, "Log file", null, 0, false, false, 2, 0, null, "", false, "", null, 0, false, true, -1, 0, null, "", true, "3D: 1st person", null, 0, false, false, 3, 0, null, "", false, "", null, 0, false, true, -1, 0, null, "", true, "Action points", null, 0, false, false, 4, 0, null, "", false, "Grid data", null, 0, false, false, 5, 0, null, "", false, "Creature Stats", null, 0, false, false, 6, 0, null, "", false ]
items = [ "Map folder", null, 0, false, false, 0, 0, null, "", false, "Script file", null, 0, false, false, 1, 0, null, "", false, "Log file", null, 0, false, false, 2, 0, null, "", false, "", null, 0, false, true, -1, 0, null, "", true, "3D: 1st person", null, 0, false, false, 3, 0, null, "", false, "", null, 0, false, true, -1, 0, null, "", true, "Action points", null, 0, false, false, 4, 0, null, "", false, "Grid data", null, 0, false, false, 5, 0, null, "", false, "Config files", null, 0, false, false, 6, 0, null, "", false, "Creature stats", null, 0, false, false, 7, 0, null, "", false ]
switch_on_hover = true
__meta__ = {
"_edit_use_anchors_": false
Expand Down Expand Up @@ -6717,7 +6718,7 @@ margin_right = 2053.0
margin_bottom = -886.0
rect_min_size = Vector2( 281, 296 )
mouse_filter = 1
window_title = "Creature Stat Comparison"
window_title = "Creature stat comparison"
resizable = true
script = ExtResource( 170 )

Expand Down Expand Up @@ -6805,6 +6806,136 @@ texture_hover = ExtResource( 128 )
expand = true
stretch_mode = 4

[node name="ConfigFilesListWindow" type="WindowDialog" parent="Ui/UiSystem"]
visible = true
margin_left = 2184.0
margin_top = -1832.0
margin_right = 2885.0
margin_bottom = -1226.0
rect_min_size = Vector2( 281, 296 )
mouse_filter = 1
window_title = "Config files"
resizable = true
script = ExtResource( 47 )

[node name="MarginContainer" type="MarginContainer" parent="Ui/UiSystem/ConfigFilesListWindow"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 1
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20

[node name="ScrollContainer" type="ScrollContainer" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer"]
margin_left = 20.0
margin_top = 20.0
margin_right = 681.0
margin_bottom = 586.0
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="VBoxContainer" type="VBoxContainer" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer"]
margin_right = 661.0
margin_bottom = 566.0
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="Label" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_right = 661.0
margin_bottom = 21.0
text = "This is a list of the extra files that were loaded when you opened this map."
autowrap = true

[node name="Spacing3" type="Control" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 25.0
margin_right = 661.0
margin_bottom = 45.0
rect_min_size = Vector2( 20, 20 )

[node name="Label2" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 49.0
margin_right = 661.0
margin_bottom = 70.0
custom_colors/font_color = Color( 0.4, 0.4, 0.4, 1 )
text = "/fxdata/ config files"

[node name="FileListGridA" type="GridContainer" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 74.0
margin_right = 661.0
margin_bottom = 120.0

[node name="Label5" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer/FileListGridA"]
margin_right = 13.0
margin_bottom = 21.0
text = "A"

[node name="Label6" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer/FileListGridA"]
margin_top = 25.0
margin_right = 13.0
margin_bottom = 46.0
text = "B"

[node name="Spacing2" type="Control" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 124.0
margin_right = 661.0
margin_bottom = 144.0
rect_min_size = Vector2( 20, 20 )

[node name="Label3" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 148.0
margin_right = 661.0
margin_bottom = 169.0
custom_colors/font_color = Color( 0.4, 0.4, 0.4, 1 )
text = "Campaign config files"

[node name="FileListGridB" type="GridContainer" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 173.0
margin_right = 661.0
margin_bottom = 219.0

[node name="Label5" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer/FileListGridB"]
margin_right = 13.0
margin_bottom = 21.0
text = "A"

[node name="Label6" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer/FileListGridB"]
margin_top = 25.0
margin_right = 13.0
margin_bottom = 46.0
text = "B"

[node name="Spacing" type="Control" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 223.0
margin_right = 661.0
margin_bottom = 243.0
rect_min_size = Vector2( 20, 20 )

[node name="Label4" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 247.0
margin_right = 661.0
margin_bottom = 268.0
custom_colors/font_color = Color( 0.4, 0.4, 0.4, 1 )
text = "Local Map config files"

[node name="FileListGridC" type="GridContainer" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer"]
margin_top = 272.0
margin_right = 661.0
margin_bottom = 318.0

[node name="Label5" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer/FileListGridC"]
margin_right = 13.0
margin_bottom = 21.0
text = "A"

[node name="Label6" type="Label" parent="Ui/UiSystem/ConfigFilesListWindow/MarginContainer/ScrollContainer/VBoxContainer/FileListGridC"]
margin_top = 25.0
margin_right = 13.0
margin_bottom = 46.0
text = "B"

[node name="MapCoordinatesWindow" type="WindowDialog" parent="Ui/UiSystem"]
visible = true
margin_left = -1480.0
Expand Down Expand Up @@ -7560,6 +7691,7 @@ script = SubResource( 20 )
[connection signal="pressed" from="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer/RightStatsButton" to="Ui/UiSystem/SortCreatureStats" method="_on_RightStatsButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer2/NameStatsButton" to="Ui/UiSystem/SortCreatureStats" method="_on_NameStatsButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer2/CCStatsHelpButton" to="Ui/UiSystem/SortCreatureStats" method="_on_CCStatsHelpButton_pressed"]
[connection signal="about_to_show" from="Ui/UiSystem/ConfigFilesListWindow" to="Ui/UiSystem/ConfigFilesListWindow" method="_on_ConfigFilesListWindow_about_to_show"]
[connection signal="visibility_changed" from="Ui/UiSystem/MapCoordinatesWindow" to="Ui/UiSystem/MapCoordinatesWindow" method="_on_MapCoordinatesWindow_visibility_changed"]
[connection signal="gui_input" from="Ui/UiSystem/MapCoordinatesWindow/MarginContainer/VBoxContainer/LandviewAspectRatioContainer/LandviewImage" to="Ui/UiSystem/MapCoordinatesWindow" method="_on_LandviewImage_gui_input"]
[connection signal="resized" from="Ui/UiSystem/MapCoordinatesWindow/MarginContainer/VBoxContainer/LandviewAspectRatioContainer/LandviewImage" to="Ui/UiSystem/MapCoordinatesWindow" method="_on_LandviewImage_resized"]
Expand Down
3 changes: 3 additions & 0 deletions Scenes/Menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ onready var oCamera2D = Nodelist.list["oCamera2D"]
onready var oActionPointListWindow = Nodelist.list["oActionPointListWindow"]
onready var oUndoStates = Nodelist.list["oUndoStates"]
onready var oSortCreatureStats = Nodelist.list["oSortCreatureStats"]
onready var oConfigFilesListWindow = Nodelist.list["oConfigFilesListWindow"]

var recentlyOpened = []
var recentlyOpenedPopupMenu = PopupMenu.new()
Expand Down Expand Up @@ -292,6 +293,8 @@ func _on_ViewSubmenu_Pressed(pressedID):
5:
Utils.popup_centered(oGridDataWindow)
6:
Utils.popup_centered(oConfigFilesListWindow)
7:
Utils.popup_centered(oSortCreatureStats)
# 4:
# if oEditor.currentView == oEditor.VIEW_2D:
Expand Down

0 comments on commit 76ecffc

Please sign in to comment.