From 3a246bdf2fd02b8e7bf978ee33ff30257b98395d Mon Sep 17 00:00:00 2001 From: snipercup <50166150+snipercup@users.noreply.github.com> Date: Sat, 12 Oct 2024 10:03:31 +0200 Subject: [PATCH 1/2] Move overmap visualization to editor --- .../Custom_Editors/OvermapAreaEditor.tscn | 96 +++++++++++-------- .../Scripts/OvermapAreaEditor.gd | 6 +- .../OtherTools/overmap_area_visualization.gd | 31 +++--- .../overmap_area_visualization.tscn | 14 +-- .../ContentManager/Scripts/contentmanager.gd | 4 - Scenes/ContentManager/Scripts/othertools.gd | 18 ---- Scenes/ContentManager/contentmanager.tscn | 6 -- Scenes/ContentManager/othertools.tscn | 39 -------- 8 files changed, 71 insertions(+), 143 deletions(-) delete mode 100644 Scenes/ContentManager/Scripts/othertools.gd delete mode 100644 Scenes/ContentManager/othertools.tscn diff --git a/Scenes/ContentManager/Custom_Editors/OvermapAreaEditor.tscn b/Scenes/ContentManager/Custom_Editors/OvermapAreaEditor.tscn index be94e5c0..c1bfc645 100644 --- a/Scenes/ContentManager/Custom_Editors/OvermapAreaEditor.tscn +++ b/Scenes/ContentManager/Custom_Editors/OvermapAreaEditor.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=3 format=3 uid="uid://b3ggaal1e2obk"] +[gd_scene load_steps=4 format=3 uid="uid://b3ggaal1e2obk"] [ext_resource type="Script" path="res://Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd" id="1_g1n4r"] [ext_resource type="PackedScene" uid="uid://2kp6gjwaextr" path="res://Scenes/ContentManager/Custom_Widgets/Overmap_Area_Region_editor.tscn" id="2_jtxai"] +[ext_resource type="PackedScene" uid="uid://neuhnehifngf" path="res://Scenes/ContentManager/OtherTools/overmap_area_visualization.tscn" id="3_y3jo3"] -[node name="OvermapAreaEditor" type="Control" node_paths=PackedStringArray("IDTextLabel", "NameTextEdit", "DescriptionTextEdit", "min_width_spin_box", "min_height_spin_box", "max_width_spin_box", "max_height_spin_box", "region_name_text_edit", "region_v_box_container")] +[node name="OvermapAreaEditor" type="Control" node_paths=PackedStringArray("IDTextLabel", "NameTextEdit", "DescriptionTextEdit", "min_width_spin_box", "min_height_spin_box", "max_width_spin_box", "max_height_spin_box", "region_name_text_edit", "region_v_box_container", "overmap_area_visualization")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -11,56 +12,63 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_g1n4r") -IDTextLabel = NodePath("VBoxContainer/FormGrid/IDTextLabel") -NameTextEdit = NodePath("VBoxContainer/FormGrid/NameTextEdit") -DescriptionTextEdit = NodePath("VBoxContainer/FormGrid/DescriptionTextEdit") -min_width_spin_box = NodePath("VBoxContainer/FormGrid/DimensionsHBoxContainer/MinWidthSpinBox") -min_height_spin_box = NodePath("VBoxContainer/FormGrid/DimensionsHBoxContainer/MinHeightSpinBox") -max_width_spin_box = NodePath("VBoxContainer/FormGrid/DimensionsHBoxContainer/MaxWidthSpinBox") -max_height_spin_box = NodePath("VBoxContainer/FormGrid/DimensionsHBoxContainer/MaxHeightSpinBox") -region_name_text_edit = NodePath("VBoxContainer/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer/RegionNameTextEdit") -region_v_box_container = NodePath("VBoxContainer/FormGrid/RegionsVBoxContainer/RegionVBoxContainer") +IDTextLabel = NodePath("TabContainer/General/FormGrid/IDTextLabel") +NameTextEdit = NodePath("TabContainer/General/FormGrid/NameTextEdit") +DescriptionTextEdit = NodePath("TabContainer/General/FormGrid/DescriptionTextEdit") +min_width_spin_box = NodePath("TabContainer/General/FormGrid/DimensionsHBoxContainer/MinWidthSpinBox") +min_height_spin_box = NodePath("TabContainer/General/FormGrid/DimensionsHBoxContainer/MinHeightSpinBox") +max_width_spin_box = NodePath("TabContainer/General/FormGrid/DimensionsHBoxContainer/MaxWidthSpinBox") +max_height_spin_box = NodePath("TabContainer/General/FormGrid/DimensionsHBoxContainer/MaxHeightSpinBox") +region_name_text_edit = NodePath("TabContainer/General/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer/RegionNameTextEdit") +region_v_box_container = NodePath("TabContainer/General/FormGrid/RegionsVBoxContainer/RegionVBoxContainer") overmap_area_region_editor = ExtResource("2_jtxai") +overmap_area_visualization = NodePath("TabContainer/Generate") -[node name="VBoxContainer" type="VBoxContainer" parent="."] +[node name="TabContainer" type="TabContainer" parent="."] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +current_tab = 1 -[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +[node name="General" type="VBoxContainer" parent="TabContainer"] +visible = false layout_mode = 2 +metadata/_tab_index = 0 -[node name="CloseButton" type="Button" parent="VBoxContainer/HBoxContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/General"] +layout_mode = 2 + +[node name="CloseButton" type="Button" parent="TabContainer/General/HBoxContainer"] layout_mode = 2 text = "Close" -[node name="SaveButton" type="Button" parent="VBoxContainer/HBoxContainer"] +[node name="SaveButton" type="Button" parent="TabContainer/General/HBoxContainer"] layout_mode = 2 text = "Save" -[node name="FormGrid" type="GridContainer" parent="VBoxContainer"] +[node name="FormGrid" type="GridContainer" parent="TabContainer/General"] layout_mode = 2 size_flags_vertical = 3 columns = 2 -[node name="IDLabel" type="Label" parent="VBoxContainer/FormGrid"] +[node name="IDLabel" type="Label" parent="TabContainer/General/FormGrid"] layout_mode = 2 text = "ID:" -[node name="IDTextLabel" type="Label" parent="VBoxContainer/FormGrid"] +[node name="IDTextLabel" type="Label" parent="TabContainer/General/FormGrid"] custom_minimum_size = Vector2(0, 30) layout_mode = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 0.1 -[node name="NameLabel" type="Label" parent="VBoxContainer/FormGrid"] +[node name="NameLabel" type="Label" parent="TabContainer/General/FormGrid"] layout_mode = 2 text = "Name" -[node name="NameTextEdit" type="TextEdit" parent="VBoxContainer/FormGrid"] +[node name="NameTextEdit" type="TextEdit" parent="TabContainer/General/FormGrid"] custom_minimum_size = Vector2(0, 30) layout_mode = 2 size_flags_horizontal = 3 @@ -68,11 +76,11 @@ size_flags_stretch_ratio = 0.1 focus_next = NodePath("../DescriptionTextEdit") placeholder_text = "City" -[node name="DescriptionLabel" type="Label" parent="VBoxContainer/FormGrid"] +[node name="DescriptionLabel" type="Label" parent="TabContainer/General/FormGrid"] layout_mode = 2 text = "Description" -[node name="DescriptionTextEdit" type="TextEdit" parent="VBoxContainer/FormGrid"] +[node name="DescriptionTextEdit" type="TextEdit" parent="TabContainer/General/FormGrid"] layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 @@ -81,76 +89,80 @@ focus_previous = NodePath("../NameTextEdit") placeholder_text = "Creates a bunch of shops and houses representing a city" wrap_mode = 1 -[node name="DimensionsLabel" type="Label" parent="VBoxContainer/FormGrid"] +[node name="DimensionsLabel" type="Label" parent="TabContainer/General/FormGrid"] layout_mode = 2 text = "Dimensions" -[node name="DimensionsHBoxContainer" type="HBoxContainer" parent="VBoxContainer/FormGrid"] +[node name="DimensionsHBoxContainer" type="HBoxContainer" parent="TabContainer/General/FormGrid"] layout_mode = 2 -[node name="MinWidthLabel" type="Label" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MinWidthLabel" type="Label" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 text = "Min width:" -[node name="MinWidthSpinBox" type="SpinBox" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MinWidthSpinBox" type="SpinBox" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 step = 4.0 value = 4.0 -[node name="MinHeightLabel" type="Label" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MinHeightLabel" type="Label" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 text = "Min height:" -[node name="MinHeightSpinBox" type="SpinBox" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MinHeightSpinBox" type="SpinBox" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 step = 4.0 value = 4.0 -[node name="MaxWidthLabel" type="Label" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MaxWidthLabel" type="Label" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 text = "Max width" -[node name="MaxWidthSpinBox" type="SpinBox" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MaxWidthSpinBox" type="SpinBox" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 step = 4.0 value = 16.0 -[node name="MaxHeightLabel" type="Label" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MaxHeightLabel" type="Label" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 text = "Max height:" -[node name="MaxHeightSpinBox" type="SpinBox" parent="VBoxContainer/FormGrid/DimensionsHBoxContainer"] +[node name="MaxHeightSpinBox" type="SpinBox" parent="TabContainer/General/FormGrid/DimensionsHBoxContainer"] layout_mode = 2 step = 4.0 value = 16.0 -[node name="RegionsLabel" type="Label" parent="VBoxContainer/FormGrid"] +[node name="RegionsLabel" type="Label" parent="TabContainer/General/FormGrid"] layout_mode = 2 text = "Regions:" -[node name="RegionsVBoxContainer" type="VBoxContainer" parent="VBoxContainer/FormGrid"] +[node name="RegionsVBoxContainer" type="VBoxContainer" parent="TabContainer/General/FormGrid"] layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="RegionAddControlsHBoxContainer" type="HBoxContainer" parent="VBoxContainer/FormGrid/RegionsVBoxContainer"] +[node name="RegionAddControlsHBoxContainer" type="HBoxContainer" parent="TabContainer/General/FormGrid/RegionsVBoxContainer"] layout_mode = 2 -[node name="RegionNameLabel" type="Label" parent="VBoxContainer/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer"] +[node name="RegionNameLabel" type="Label" parent="TabContainer/General/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer"] layout_mode = 2 text = "Region name:" -[node name="RegionNameTextEdit" type="TextEdit" parent="VBoxContainer/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer"] +[node name="RegionNameTextEdit" type="TextEdit" parent="TabContainer/General/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer"] custom_minimum_size = Vector2(160, 30) layout_mode = 2 -[node name="RegionAddButton" type="Button" parent="VBoxContainer/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer"] +[node name="RegionAddButton" type="Button" parent="TabContainer/General/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer"] layout_mode = 2 text = "Add" -[node name="RegionVBoxContainer" type="VBoxContainer" parent="VBoxContainer/FormGrid/RegionsVBoxContainer"] +[node name="RegionVBoxContainer" type="VBoxContainer" parent="TabContainer/General/FormGrid/RegionsVBoxContainer"] +layout_mode = 2 + +[node name="Generate" parent="TabContainer" instance=ExtResource("3_y3jo3")] layout_mode = 2 +metadata/_tab_index = 1 -[connection signal="button_up" from="VBoxContainer/HBoxContainer/CloseButton" to="." method="_on_close_button_button_up"] -[connection signal="button_up" from="VBoxContainer/HBoxContainer/SaveButton" to="." method="_on_save_button_button_up"] -[connection signal="button_up" from="VBoxContainer/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer/RegionAddButton" to="." method="_on_region_add_button_button_up"] +[connection signal="button_up" from="TabContainer/General/HBoxContainer/CloseButton" to="." method="_on_close_button_button_up"] +[connection signal="button_up" from="TabContainer/General/HBoxContainer/SaveButton" to="." method="_on_save_button_button_up"] +[connection signal="button_up" from="TabContainer/General/FormGrid/RegionsVBoxContainer/RegionAddControlsHBoxContainer/RegionAddButton" to="." method="_on_region_add_button_button_up"] diff --git a/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd b/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd index 83210b11..b94e362f 100644 --- a/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd +++ b/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd @@ -92,11 +92,11 @@ extends Control @export var max_height_spin_box: SpinBox = null # The maximum height of the area in tiles @export var region_name_text_edit: TextEdit = null # Allows the user to enter a new region name @export var region_v_box_container: VBoxContainer = null # Contains region editing controls -@export var overmap_area_region_editor: PackedScene = null +@export var overmap_area_region_editor: PackedScene = null # Sub-scene for editing a region +@export var overmap_area_visualization: Control = null # Sub-scene for area visualization # This signal will be emitted when the user presses the save button -# This signal should alert Gamedata that the overmaparea data array should be saved to disk signal data_changed() var olddata: DOvermaparea # Remember what the value of the data was before editing @@ -142,6 +142,8 @@ func load_overmaparea_data() -> void: # Set the region name and values for the region editor region_editor.set_region_name(region_key) region_editor.set_values(region_instance.get_data()) # Using get_data() to get the region's dictionary representation + + overmap_area_visualization.set_area_name(dovermaparea.id) # The editor is closed, destroy the instance diff --git a/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd b/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd index 1b821b4d..32ccba13 100644 --- a/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd +++ b/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd @@ -5,22 +5,10 @@ extends Control @export var width_spin_box: SpinBox = null @export var height_spin_box: SpinBox = null @export var max_iterations_spin_box: SpinBox = null -@export var area_option_button: OptionButton = null -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - # Refresh the area_option_button by clearing any existing items - area_option_button.clear() - - # Add all overmap area keys to the area_option_button as options - var area_keys = Gamedata.overmapareas.get_all().keys() - for area_key in area_keys: - area_option_button.add_item(area_key) - - -func _on_back_button_button_up() -> void: - get_tree().change_scene_to_file("res://Scenes/ContentManager/othertools.tscn") +# Variable to store the area name +var area_name: String = "" func _on_generate_button_button_up() -> void: @@ -31,10 +19,9 @@ func _on_generate_button_button_up() -> void: func generate_grid(): visual_grid.set("theme_override_constants/h_separation", 0) visual_grid.set("theme_override_constants/v_separation", 0) - var mymaxiterations: int = max_iterations_spin_box.value + var mymaxiterations: int = int(max_iterations_spin_box.value) # Define the dimensions of the grid as 20x20 units - var myareaname: String = area_option_button.get_item_text(area_option_button.selected) - var myovermaparea: DOvermaparea = Gamedata.overmapareas.by_id(myareaname) + var myovermaparea: DOvermaparea = Gamedata.overmapareas.by_id(area_name) var mydimensions = set_area_dimensions(myovermaparea) # Create a new instance of OvermapAreaGenerator and generate the area grid @@ -70,8 +57,8 @@ func generate_grid(): # Function to set the dimensions for the area generator based on the dovermaparea data func set_area_dimensions(dovermaparea: DOvermaparea) -> Vector2: - var mywidth: int = width_spin_box.value - var myheight: int = height_spin_box.value + var mywidth: int = int(width_spin_box.value) + var myheight: int = int(height_spin_box.value) # Check if the dimensions are already set to a non-default value if not mywidth == 0 and not myheight == 0: return Vector2(mywidth,myheight) # Terminate if no dimensions are set @@ -85,3 +72,9 @@ func set_area_dimensions(dovermaparea: DOvermaparea) -> Vector2: var random_width = randi() % (dovermaparea.max_width - dovermaparea.min_width + 1) + dovermaparea.min_width var random_height = randi() % (dovermaparea.max_height - dovermaparea.min_height + 1) + dovermaparea.min_height return Vector2(random_width, random_height) + + + +# Setter method to update the selected area +func set_area_name(newarea_name: String) -> void: + area_name = newarea_name diff --git a/Scenes/ContentManager/OtherTools/overmap_area_visualization.tscn b/Scenes/ContentManager/OtherTools/overmap_area_visualization.tscn index 439da2bd..0a2abd1f 100644 --- a/Scenes/ContentManager/OtherTools/overmap_area_visualization.tscn +++ b/Scenes/ContentManager/OtherTools/overmap_area_visualization.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://Scenes/ContentManager/OtherTools/overmap_area_visualization.gd" id="1_8wpup"] [ext_resource type="PackedScene" uid="uid://budsoodfdkaea" path="res://Scenes/Overmap/OvermapTile.tscn" id="2_3b74b"] -[node name="OvermapAreaVisualization" type="Control" node_paths=PackedStringArray("visual_grid", "width_spin_box", "height_spin_box", "max_iterations_spin_box", "area_option_button")] +[node name="OvermapAreaVisualization" type="Control" node_paths=PackedStringArray("visual_grid", "width_spin_box", "height_spin_box", "max_iterations_spin_box")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -16,7 +16,6 @@ tileScene = ExtResource("2_3b74b") width_spin_box = NodePath("VBoxContainer/HBoxContainer/WidthSpinBox") height_spin_box = NodePath("VBoxContainer/HBoxContainer/HeightSpinBox") max_iterations_spin_box = NodePath("VBoxContainer/HBoxContainer/MaxIterationsSpinBox") -area_option_button = NodePath("VBoxContainer/HBoxContainer/AreaOptionButton") [node name="VBoxContainer" type="VBoxContainer" parent="."] layout_mode = 1 @@ -26,19 +25,9 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="BackButton" type="Button" parent="VBoxContainer"] -layout_mode = 2 -text = "Back" - [node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 -[node name="AreaOptionButton" type="OptionButton" parent="VBoxContainer/HBoxContainer"] -layout_mode = 2 -selected = 0 -item_count = 1 -popup/item_0/text = "city" - [node name="WidthLabel" type="Label" parent="VBoxContainer/HBoxContainer"] layout_mode = 2 text = "Width:" @@ -72,5 +61,4 @@ layout_mode = 2 size_flags_horizontal = 0 columns = 20 -[connection signal="button_up" from="VBoxContainer/BackButton" to="." method="_on_back_button_button_up"] [connection signal="button_up" from="VBoxContainer/HBoxContainer/GenerateButton" to="." method="_on_generate_button_button_up"] diff --git a/Scenes/ContentManager/Scripts/contentmanager.gd b/Scenes/ContentManager/Scripts/contentmanager.gd index b80aa40c..3137748a 100644 --- a/Scenes/ContentManager/Scripts/contentmanager.gd +++ b/Scenes/ContentManager/Scripts/contentmanager.gd @@ -11,7 +11,3 @@ func _on_content_editor_button_button_up(): func _on_mod_manager_button_button_up(): get_tree().change_scene_to_file("res://Scenes/ContentManager/modmanager.tscn") - - -func _on_other_tools_button_button_up() -> void: - get_tree().change_scene_to_file("res://Scenes/ContentManager/othertools.tscn") diff --git a/Scenes/ContentManager/Scripts/othertools.gd b/Scenes/ContentManager/Scripts/othertools.gd deleted file mode 100644 index deb846df..00000000 --- a/Scenes/ContentManager/Scripts/othertools.gd +++ /dev/null @@ -1,18 +0,0 @@ -extends Control - - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - -func _on_back_button_button_up() -> void: - get_tree().change_scene_to_file("res://Scenes/ContentManager/contentmanager.tscn") - - -func _on_overmap_area_button_button_up() -> void: - get_tree().change_scene_to_file("res://Scenes/ContentManager/OtherTools/overmap_area_visualization.tscn") diff --git a/Scenes/ContentManager/contentmanager.tscn b/Scenes/ContentManager/contentmanager.tscn index 174aee01..d85e3b5d 100644 --- a/Scenes/ContentManager/contentmanager.tscn +++ b/Scenes/ContentManager/contentmanager.tscn @@ -35,11 +35,6 @@ layout_mode = 2 theme_override_font_sizes/font_size = 36 text = "Content editor" -[node name="OtherToolsButton" type="Button" parent="VBoxContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 36 -text = "Other tools" - [node name="BackButton" type="Button" parent="VBoxContainer"] layout_mode = 2 theme_override_font_sizes/font_size = 36 @@ -47,5 +42,4 @@ text = "Back" [connection signal="button_up" from="VBoxContainer/ModManagerButton" to="." method="_on_mod_manager_button_button_up"] [connection signal="button_up" from="VBoxContainer/ContentEditorButton" to="." method="_on_content_editor_button_button_up"] -[connection signal="button_up" from="VBoxContainer/OtherToolsButton" to="." method="_on_other_tools_button_button_up"] [connection signal="button_up" from="VBoxContainer/BackButton" to="." method="_on_back_button_button_up"] diff --git a/Scenes/ContentManager/othertools.tscn b/Scenes/ContentManager/othertools.tscn deleted file mode 100644 index a5da3f1d..00000000 --- a/Scenes/ContentManager/othertools.tscn +++ /dev/null @@ -1,39 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cobhadqjhrudc"] - -[ext_resource type="Script" path="res://Scenes/ContentManager/Scripts/othertools.gd" id="1_yp8wy"] - -[node name="OtherTools" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_yp8wy") - -[node name="VBoxContainer" type="VBoxContainer" parent="."] -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -60.5 -offset_top = -33.0 -offset_right = 60.5 -offset_bottom = 33.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="OvermapAreaButton" type="Button" parent="VBoxContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 36 -text = "Overmap area generator" - -[node name="BackButton" type="Button" parent="VBoxContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 36 -text = "Back" - -[connection signal="button_up" from="VBoxContainer/OvermapAreaButton" to="." method="_on_overmap_area_button_button_up"] -[connection signal="button_up" from="VBoxContainer/BackButton" to="." method="_on_back_button_button_up"] From 6188c87f989503f185b083a0f45234b5c34475a3 Mon Sep 17 00:00:00 2001 From: snipercup <50166150+snipercup@users.noreply.github.com> Date: Sat, 12 Oct 2024 10:10:33 +0200 Subject: [PATCH 2/2] Set overmaparea --- .../Custom_Editors/Scripts/OvermapAreaEditor.gd | 3 ++- .../OtherTools/overmap_area_visualization.gd | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd b/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd index b94e362f..eb54b0a8 100644 --- a/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd +++ b/Scenes/ContentManager/Custom_Editors/Scripts/OvermapAreaEditor.gd @@ -143,7 +143,7 @@ func load_overmaparea_data() -> void: region_editor.set_region_name(region_key) region_editor.set_values(region_instance.get_data()) # Using get_data() to get the region's dictionary representation - overmap_area_visualization.set_area_name(dovermaparea.id) + overmap_area_visualization.set_area(dovermaparea) # The editor is closed, destroy the instance @@ -151,6 +151,7 @@ func load_overmaparea_data() -> void: func _on_close_button_button_up() -> void: queue_free() + # This function takes all data from the form elements and stores them in the DOvermaparea instance # Since dovermaparea is a reference to an item in Gamedata.overmapareas # the central array for overmaparea data is updated with the changes as well diff --git a/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd b/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd index 32ccba13..4347ff4b 100644 --- a/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd +++ b/Scenes/ContentManager/OtherTools/overmap_area_visualization.gd @@ -7,8 +7,8 @@ extends Control @export var max_iterations_spin_box: SpinBox = null -# Variable to store the area name -var area_name: String = "" +# Variable to store the area +var myovermaparea: DOvermaparea func _on_generate_button_button_up() -> void: @@ -20,8 +20,6 @@ func generate_grid(): visual_grid.set("theme_override_constants/h_separation", 0) visual_grid.set("theme_override_constants/v_separation", 0) var mymaxiterations: int = int(max_iterations_spin_box.value) - # Define the dimensions of the grid as 20x20 units - var myovermaparea: DOvermaparea = Gamedata.overmapareas.by_id(area_name) var mydimensions = set_area_dimensions(myovermaparea) # Create a new instance of OvermapAreaGenerator and generate the area grid @@ -76,5 +74,5 @@ func set_area_dimensions(dovermaparea: DOvermaparea) -> Vector2: # Setter method to update the selected area -func set_area_name(newarea_name: String) -> void: - area_name = newarea_name +func set_area(newarea: DOvermaparea) -> void: + myovermaparea = newarea