Updated the engine and the addons.

This commit is contained in:
Relintai 2022-12-02 19:05:46 +01:00
parent 32b6751619
commit b1a00b5c49
37 changed files with 956 additions and 229 deletions

2
HEADS
View File

@ -1 +1 @@
{"engine": {"3.2": "64a9e86c5c20bd4bd5833f0563457d0126617489", "3.x": "cdd4f2722a7c16d9e36521d7180cc80715591554"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3c334566ff05a74e913cd5c5ff38ae45aba5f5d2"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "thread_pool": {"master": "c401b7a027248158dae3fbce20d637d34eaaedb9"}, "mesh_data_resource": {"master": "2bf76b8d07c2821161886ea4ea6edc788ec2ee51"}, "mesh_utils": {"master": "902dae29797789d406faf256a22aa73b7f6d5261"}, "props": {"master": "2afd6eff45f9a921bdf4090ff3029def86df5cb5"}, "terraman_2d": {"master": "b547515ae3817b0088e2cf499af59c8f1dee7189"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "rtile_map": {"master": "389070cfef387b69902e23e6c4ac53997b69e42e"}, "pandemonium_engine": {"master": "54643bc1fc76248bc03d5ecdaaaa4c10616a2f61"}}
{"engine": {"3.2": "64a9e86c5c20bd4bd5833f0563457d0126617489", "3.x": "cdd4f2722a7c16d9e36521d7180cc80715591554"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3c334566ff05a74e913cd5c5ff38ae45aba5f5d2"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "thread_pool": {"master": "c401b7a027248158dae3fbce20d637d34eaaedb9"}, "mesh_data_resource": {"master": "2bf76b8d07c2821161886ea4ea6edc788ec2ee51"}, "mesh_utils": {"master": "902dae29797789d406faf256a22aa73b7f6d5261"}, "props": {"master": "2afd6eff45f9a921bdf4090ff3029def86df5cb5"}, "terraman_2d": {"master": "b547515ae3817b0088e2cf499af59c8f1dee7189"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "rtile_map": {"master": "389070cfef387b69902e23e6c4ac53997b69e42e"}, "pandemonium_engine": {"master": "47e2a193c4d1ef86028ea02cbe267d7e9fcac3bb"}}

View File

@ -2,9 +2,9 @@ tool
extends EditorPlugin
const DataManagerAddonSettings = preload("res://addons/data_manager/resources/data_manager_addon_settings.gd")
const _main_panel : PackedScene = preload("res://addons/data_manager/panels/MainPanel.tscn")
const _script_icon : Texture = preload("res://addons/data_manager/icons/icon_multi_line.png")
var _script_icon : Texture = null
var settings : DataManagerAddonSettings = null
@ -34,6 +34,9 @@ func make_visible(visible):
_main_panel_instance.hide()
func get_plugin_icon():
if !_script_icon:
_script_icon = get_editor_interface().get_base_control().get_theme_icon("ThemeSelectAll", "EditorIcons")
return _script_icon
func get_plugin_name():

View File

@ -17,6 +17,6 @@ container_path = NodePath("Viewport")
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 500, 500 )
own_world = true
own_world_3d = true
handle_input_locally = false
render_target_update_mode = 3

View File

@ -17,7 +17,7 @@ container_path = NodePath("Viewport")
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 500, 500 )
own_world = true
own_world_3d = true
handle_input_locally = false
render_target_update_mode = 3

View File

@ -17,7 +17,7 @@ container_path = NodePath("Viewport")
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 60, 60 )
size_override_stretch = true
own_world = true
own_world_3d = true
handle_input_locally = false
render_target_update_mode = 3

View File

@ -223,8 +223,9 @@ func save_to_project_settings() -> void:
ProjectSettings.set("addons/data_manager/folder_settings", get_as_json())
func load_from_project_settings() -> void:
var d : String = ProjectSettings.get("addons/data_manager/folder_settings")
if d != "":
set_from_json(d)
if ProjectSettings.has_setting("addons/data_manager/folder_settings"):
var d : String = ProjectSettings.get("addons/data_manager/folder_settings")
if d != "":
set_from_json(d)

View File

@ -52,7 +52,6 @@ func edit(object):
if object is WorldGenWorld:
var wgw : WorldGenWorld = object as WorldGenWorld
wgw.setup()
editor_scene.set_wgworld(wgw)
func make_visible(visible):

View File

@ -0,0 +1,32 @@
tool
extends Reference
class_name WorldGenRaycast
var current_index : int = -1
var base_resources : Array = Array()
var local_positions : PoolVector2Array = PoolVector2Array()
var local_uvs : PoolVector2Array = PoolVector2Array()
func get_local_position() -> Vector2:
return local_positions[current_index]
func get_local_uv() -> Vector2:
return local_uvs[current_index]
# WorldGenBaseResource (can't explicitly add -> cyclic dependency)
func get_resource():
return base_resources[current_index]
func next() -> bool:
current_index += 1
return base_resources.size() > current_index
func size() -> int:
return base_resources.size()
# base_resource -> WorldGenBaseResource
func add_data(base_resource, local_pos : Vector2, local_uv : Vector2) -> void:
base_resources.append(base_resource)
local_positions.append(local_pos)
local_uvs.append(local_uv)

View File

@ -25,7 +25,6 @@ func create_content(item_name : String = "") -> void:
func add_content(entry : WorldGenBaseResource) -> void:
zones.append(entry)
entry.set_parent_pos(get_parent_pos() + get_rect().position)
emit_changed()
func remove_content_entry(entry : WorldGenBaseResource) -> void:

View File

@ -0,0 +1,7 @@
tool
extends "res://addons/world_generator/resources/world_gen_base_resource.gd"
class_name SubZoneProp
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)

View File

@ -2,6 +2,37 @@ tool
extends "res://addons/world_generator/resources/world_gen_base_resource.gd"
class_name SubZone
export(Array) var subzone_props : Array
func get_content() -> Array:
return subzone_props
func set_content(arr : Array) -> void:
subzone_props = arr
func create_content(item_name : String = "") -> void:
var subzone_prop : SubZoneProp = SubZoneProp.new()
subzone_prop.resource_name = item_name
var r : Rect2 = get_rect()
r.position = Vector2()
r.size.x /= 10.0
r.size.y /= 10.0
subzone_prop.set_rect(r)
add_content(subzone_prop)
func add_content(entry : WorldGenBaseResource) -> void:
subzone_props.append(entry)
emit_changed()
func remove_content_entry(entry : WorldGenBaseResource) -> void:
for i in range(subzone_props.size()):
if subzone_props[i] == entry:
subzone_props.remove(i)
emit_changed()
return
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)

View File

@ -3,26 +3,33 @@ extends Resource
class_name WorldGenBaseResource
export(Rect2) var rect : Rect2 = Rect2(0, 0, 100, 100)
export(Vector2i) var min_size : Vector2i = Vector2i(1, 1)
export(Vector2i) var max_size : Vector2i = Vector2i(1000000, 1000000)
export(bool) var locked : bool = false
var _parent_pos : Vector2 = Vector2()
func setup() -> void:
_setup()
for c in get_content():
if c:
c.set_parent_pos(_parent_pos + get_rect().position)
c.setup()
func _setup() -> void:
pass
func get_rect() -> Rect2:
return rect
func set_rect(r : Rect2) -> void:
rect = r
rect.position = r.position
rect.size.x = max(min_size.x, r.size.x)
rect.size.y = max(min_size.y, r.size.y)
rect.size.x = min(max_size.x, rect.size.x)
rect.size.y = min(max_size.y, rect.size.y)
emit_changed()
func get_min_size() -> Vector2i:
return min_size
func set_min_size(r : Vector2i) -> void:
min_size = r
emit_changed()
func get_max_size() -> Vector2i:
return max_size
func set_max_size(r : Vector2i) -> void:
max_size = r
emit_changed()
func get_locked() -> bool:
@ -32,16 +39,6 @@ func set_locked(r : bool) -> void:
locked = r
emit_changed()
func get_parent_pos() -> Vector2:
return _parent_pos
func set_parent_pos(parent_pos : Vector2) -> void:
_parent_pos = parent_pos
for c in get_content():
if c:
c.set_parent_pos(_parent_pos + get_rect().position)
func get_content() -> Array:
return Array()
@ -57,6 +54,31 @@ func create_content(item_name : String = "") -> void:
func remove_content_entry(entry : WorldGenBaseResource) -> void:
pass
func is_spawner() -> bool:
return _is_spawner()
func _is_spawner() -> bool:
return false
func get_spawn_local_position() -> Vector2:
return _get_spawn_local_position()
func _get_spawn_local_position() -> Vector2:
return Vector2()
func get_spawn_positions(var parent_position : Vector2 = Vector2()) -> Array:
if is_spawner():
return [ [ resource_name, parent_position + rect.position + get_spawn_local_position() ] ]
var spawners : Array
var p : Vector2 = parent_position + rect.position
for c in get_content():
if c:
spawners.append_array(c.get_spawn_positions(p))
return spawners
func get_content_with_name(name : String) -> WorldGenBaseResource:
if resource_name == name:
return self
@ -91,33 +113,35 @@ func duplicate_content_entry(entry : WorldGenBaseResource, add : bool = true) ->
return de
func setup_terra_library(library, pseed : int) -> void:
func setup_terra_library(library : TerrainLibrary, pseed : int) -> void:
_setup_terra_library(library, pseed)
for c in get_content():
if c:
c.setup_terra_library(library, pseed)
func _setup_terra_library(library, pseed : int) -> void:
func _setup_terra_library(library : TerrainLibrary, pseed : int) -> void:
pass
func generate_terra_chunk(chunk, pseed : int, spawn_mobs: bool) -> void:
func generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
var p : Vector2 = Vector2(chunk.get_position_x(), chunk.get_position_z())
var stack : Array = get_hit_stack(p)
var raycast : WorldGenRaycast = get_hit_stack(p)
if stack.size() == 0:
if raycast.size() == 0:
_generate_terra_chunk_fallback(chunk, pseed, spawn_mobs)
return
for i in range(stack.size()):
stack[i]._generate_terra_chunk(chunk, pseed, spawn_mobs, stack, i)
while raycast.next():
raycast.get_resource()._generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
func _generate_terra_chunk(chunk, pseed : int, spawn_mobs: bool, stack : Array, stack_index : int) -> void:
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
pass
func _generate_terra_chunk_fallback(chunk, pseed : int, spawn_mobs: bool) -> void:
pass
func _generate_terra_chunk_fallback(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 1)
chunk.set_voxel(1, 0, 0, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
func generate_map(pseed : int) -> Image:
var img : Image = Image.new()
@ -128,31 +152,33 @@ func generate_map(pseed : int) -> Image:
return img
func add_to_map(var img : Image, pseed : int) -> void:
func add_to_map(img : Image, pseed : int) -> void:
_add_to_map(img, pseed)
for c in get_content():
if c:
c.add_to_map(img, pseed)
func _add_to_map(var img : Image, pseed : int) -> void:
func _add_to_map(img : Image, pseed : int) -> void:
pass
func get_hit_stack(var pos : Vector2) -> Array:
func get_hit_stack(pos : Vector2, raycast : WorldGenRaycast = null) -> WorldGenRaycast:
var r : Rect2 = get_rect()
var local_pos : Vector2 = pos - rect.position
r.position = Vector2()
var result : Array = Array()
if !raycast:
raycast = WorldGenRaycast.new()
if r.has_point(local_pos):
result.append(self)
var local_uv : Vector2 = local_pos / rect.size
raycast.add_data(self, local_pos, local_uv)
for c in get_content():
if c:
result.append_array(c.get_hit_stack(local_pos))
c.get_hit_stack(local_pos, raycast)
return result
return raycast
func get_editor_rect_border_color() -> Color:
return Color(1, 1, 1, 1)
@ -170,9 +196,24 @@ func get_editor_class() -> String:
return "WorldGenBaseResource"
func get_editor_additional_text() -> String:
return "WorldGenBaseResource"
return ""
func eitor_draw_additional(control : Control) -> void:
_eitor_draw_additional(control)
func _eitor_draw_additional(control : Control) -> void:
pass
func eitor_draw_additional_background(control : Control) -> void:
_eitor_draw_additional_background(control)
func _eitor_draw_additional_background(control : Control) -> void:
pass
func setup_property_inspector(inspector) -> void:
inspector.add_slot_line_edit("get_name", "set_name", "Name")
inspector.add_slot_rect2("get_rect", "set_rect", "Rect", 1)
inspector.add_slot_vector2i("get_min_size", "set_min_size", "Min Size", 1)
inspector.add_slot_vector2i("get_max_size", "set_max_size", "Max Size", 1)
inspector.add_slot_bool("get_locked", "set_locked", "Locked")

View File

@ -25,7 +25,6 @@ func add_content(entry : WorldGenBaseResource) -> void:
entry.set_rect(r)
continents.append(entry)
entry.set_parent_pos(get_parent_pos() + get_rect().position)
emit_changed()
func remove_content_entry(entry : WorldGenBaseResource) -> void:
@ -38,3 +37,26 @@ func remove_content_entry(entry : WorldGenBaseResource) -> void:
func setup_property_inspector(inspector) -> void:
.setup_property_inspector(inspector)
func generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
var p : Vector2 = Vector2(chunk.get_position_x(), chunk.get_position_z())
var raycast : WorldGenRaycast = get_hit_stack(p)
if raycast.size() == 0:
_generate_terra_chunk_fallback(chunk, pseed, spawn_mobs)
return
_generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
while raycast.next():
raycast.get_resource()._generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
pass
func _generate_terra_chunk_fallback(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 1)
chunk.set_voxel(1, 0, 0, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)

View File

@ -5,11 +5,13 @@ class_name WorldGeneratorSettings
export(PoolStringArray) var continent_class_folders : PoolStringArray
export(PoolStringArray) var zone_class_folders : PoolStringArray
export(PoolStringArray) var subzone_class_folders : PoolStringArray
export(PoolStringArray) var subzone_prop_class_folders : PoolStringArray
enum WorldGeneratorScriptType {
CONTINENT = 0,
ZONE = 1,
SUBZONE = 2,
SUBZONE_PROP = 3,
};
func evaluate_scripts(script_type : int, tree : Tree) -> void:
@ -19,6 +21,8 @@ func evaluate_scripts(script_type : int, tree : Tree) -> void:
evaluate_zone_scripts(tree)
elif (script_type == WorldGeneratorScriptType.SUBZONE):
evaluate_subzone_scripts(tree)
elif (script_type == WorldGeneratorScriptType.SUBZONE_PROP):
evaluate_subzone_prop_scripts(tree)
func evaluate_continent_scripts(tree : Tree) -> void:
tree.clear()
@ -56,6 +60,18 @@ func evaluate_subzone_scripts(tree : Tree) -> void:
root.select(0)
func evaluate_subzone_prop_scripts(tree : Tree) -> void:
tree.clear()
var root : TreeItem = tree.create_item()
root.set_text(0, "SubZoneProp")
root.set_meta("class_name", "SubZoneProp")
for s in subzone_prop_class_folders:
evaluate_folder(s, tree, root)
root.select(0)
func evaluate_folder(folder : String, tree : Tree, root : TreeItem) -> void:
var ti : TreeItem = null

View File

@ -25,7 +25,6 @@ func create_content(item_name : String = "") -> void:
func add_content(entry : WorldGenBaseResource) -> void:
subzones.append(entry)
entry.set_parent_pos(get_parent_pos() + get_rect().position)
emit_changed()
func remove_content_entry(entry : WorldGenBaseResource) -> void:

View File

@ -4,9 +4,9 @@
[ext_resource path="res://addons/world_generator/resources/continent.gd" type="Script" id=2]
[ext_resource path="res://addons/world_generator/resources/zone.gd" type="Script" id=3]
[ext_resource path="res://addons/world_generator/resources/subzone.gd" type="Script" id=4]
[ext_resource path="res://world_generator/continents/test_continent.gd" type="Script" id=5]
[ext_resource path="res://world_generator/zones/test_zone.gd" type="Script" id=6]
[ext_resource path="res://world_generator/subzones/test_subzone.gd" type="Script" id=7]
[ext_resource path="res://scripts/world_generator/continents/test_continent.gd" type="Script" id=5]
[ext_resource path="res://scripts/world_generator/zones/test_zone.gd" type="Script" id=6]
[ext_resource path="res://scripts/world_generator/subzones/test_subzone.gd" type="Script" id=7]
[sub_resource type="Resource" id=14]
resource_name = "qwe"

View File

@ -1,7 +1,7 @@
tool
extends Tree
export(int, "Continent,Zone,Sub Zone") var class_types : int = 0
export(int, "Continent,Zone,Sub Zone,Sub Zone Prop") var class_types : int = 0
var edited_resource : WorldGenBaseResource = null
var name_edited_resource : WorldGenBaseResource = null
@ -11,9 +11,15 @@ var _ignore_changed_event : bool = false
var _plugin : EditorPlugin = null
var _undo_redo : UndoRedo = null
func _init():
connect("item_activated", self, "on_item_activated")
signal request_item_edit(world_gen_base_resource)
func _init():
if !is_connected("item_edited", self, "on_item_edited"):
connect("item_edited", self, "on_item_edited")
if !is_connected("button_pressed", self, "on_tree_button_pressed"):
connect("button_pressed", self, "on_tree_button_pressed")
func set_plugin(plugin : EditorPlugin) -> void:
_plugin = plugin
_undo_redo = _plugin.get_undo_redo()
@ -49,6 +55,8 @@ func add_item(item_name : String = "") -> void:
e = Zone.new()
elif cn == "SubZone":
e = SubZone.new()
elif cn == "SubZoneProp":
e = SubZoneProp.new()
elif ti.has_meta("file"):
var cls = load(ti.get_meta("file"))
@ -61,6 +69,14 @@ func add_item(item_name : String = "") -> void:
e.resource_name = item_name
var r : Rect2 = edited_resource.get_rect()
var rs : Vector2 = r.size
r.size.x /= 5.0
r.size.y /= 5.0
r.position = rs / Vector2(2, 2)
r.position -= r.size / Vector2(2, 2)
e.set_rect(r)
#edited_resource.add_content(e)
#remove_content_entry
@ -90,6 +106,8 @@ func refresh() -> void:
item.set_text(0, n)
item.set_meta("res", d)
item.add_button(0, get_theme_icon("Edit", "EditorIcons"), -1, false, "Edit")
item.set_editable(0, true)
func set_edited_resource(res : WorldGenBaseResource)-> void:
if edited_resource:
@ -109,13 +127,6 @@ func add_button_pressed() -> void:
func name_dialog_ok_pressed() -> void:
add_item($NameDialog/VBoxContainer/LineEdit.text)
func name_edit_dialog_ok_pressed() -> void:
if name_edited_resource:
name_edited_resource.resource_name = $NameEditDialog/VBoxContainer/LineEdit.text
name_edited_resource.emit_changed()
name_edited_resource = null
on_resource_changed()
func delete_button_pressed() -> void:
var item : TreeItem = get_selected()
@ -160,8 +171,16 @@ func on_resource_changed() -> void:
call_deferred("refresh")
func on_item_activated() -> void:
var item : TreeItem = get_selected()
func on_tree_button_pressed(item: TreeItem, column: int, id: int) -> void:
var resource : WorldGenBaseResource = item.get_meta("res")
if !resource:
return
emit_signal("request_item_edit", resource)
func on_item_edited() -> void:
var item : TreeItem = get_edited()
if !item:
return
@ -171,5 +190,12 @@ func on_item_activated() -> void:
if !name_edited_resource:
return
$NameEditDialog/VBoxContainer/LineEdit.text = name_edited_resource.resource_name
$NameEditDialog.popup_centered()
_undo_redo.create_action("WE: Renamed Entry")
_undo_redo.add_do_method(name_edited_resource, "set_name", item.get_text(0))
_undo_redo.add_undo_method(name_edited_resource, "set_name", name_edited_resource.resource_name)
_undo_redo.commit_action()
# name_edited_resource.resource_name = item.get_text(0)
name_edited_resource.emit_changed()
name_edited_resource = null
on_resource_changed()

View File

@ -7,11 +7,10 @@ anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
allow_reselect = true
hide_folding = true
hide_root = true
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="NameDialog" type="ConfirmationDialog" parent="."]
margin_right = 329.0
@ -55,30 +54,4 @@ margin_top = 245.0
margin_right = 313.0
margin_bottom = 269.0
[node name="NameEditDialog" type="ConfirmationDialog" parent="."]
margin_right = 223.0
margin_bottom = 82.0
window_title = "Name"
resizable = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="NameEditDialog"]
margin_left = 8.0
margin_top = 8.0
margin_right = 215.0
margin_bottom = 50.0
[node name="Label" type="Label" parent="NameEditDialog/VBoxContainer"]
margin_right = 207.0
margin_bottom = 14.0
text = "Name"
[node name="LineEdit" type="LineEdit" parent="NameEditDialog/VBoxContainer"]
margin_top = 18.0
margin_right = 207.0
margin_bottom = 42.0
[connection signal="confirmed" from="NameDialog" to="." method="name_dialog_ok_pressed"]
[connection signal="confirmed" from="NameEditDialog" to="." method="name_edit_dialog_ok_pressed"]

View File

@ -3,19 +3,71 @@ extends PanelContainer
var edited_world
func _ready():
var world : Control = get_node("TabContainer/World")
if !world.is_connected("request_item_edit", self, "on_world_request_item_edit"):
world.connect("request_item_edit", self, "on_world_request_item_edit")
var continent : Control = get_node("TabContainer/Continent")
if !continent.is_connected("request_item_edit", self, "on_continent_request_item_edit"):
continent.connect("request_item_edit", self, "on_continent_request_item_edit")
var zone : Control = get_node("TabContainer/Zone")
if !zone.is_connected("request_item_edit", self, "on_zone_request_item_edit"):
zone.connect("request_item_edit", self, "on_zone_request_item_edit")
var subzone : Control = get_node("TabContainer/SubZone")
if !subzone.is_connected("request_item_edit", self, "on_subzone_request_item_edit"):
subzone.connect("request_item_edit", self, "on_subzone_request_item_edit")
func set_plugin(plugin : EditorPlugin) -> void:
$TabContainer/World.set_plugin(plugin)
$TabContainer/Continent.set_plugin(plugin)
$TabContainer/Zone.set_plugin(plugin)
$TabContainer/SubZone.set_plugin(plugin)
$TabContainer/SubZoneProp.set_plugin(plugin)
func refresh() -> void:
$TabContainer/World.set_wgworld(edited_world)
$TabContainer/Continent.set_wgworld(edited_world)
$TabContainer/Zone.set_wgworld(edited_world)
$TabContainer/SubZone.set_wgworld(edited_world)
$TabContainer/SubZoneProp.set_wgworld(edited_world)
func set_wgworld(wgw : WorldGenWorld) -> void:
edited_world = wgw
refresh()
func on_world_request_item_edit(resource : WorldGenBaseResource) -> void:
var cont : Control = get_node("TabContainer/Continent")
var tc : TabContainer = get_node("TabContainer")
tc.current_tab = cont.get_position_in_parent()
cont.switch_to(resource)
func on_continent_request_item_edit(continent : WorldGenBaseResource, resource : WorldGenBaseResource) -> void:
var zone : Control = get_node("TabContainer/Zone")
var tc : TabContainer = get_node("TabContainer")
tc.current_tab = zone.get_position_in_parent()
zone.switch_to(continent, resource)
func on_zone_request_item_edit(continent : WorldGenBaseResource, zone : WorldGenBaseResource, subzone : WorldGenBaseResource) -> void:
var sz : Control = get_node("TabContainer/SubZone")
var tc : TabContainer = get_node("TabContainer")
tc.current_tab = sz.get_position_in_parent()
sz.switch_to(continent, zone, subzone)
func on_subzone_request_item_edit(continent : WorldGenBaseResource, zone : WorldGenBaseResource, subzone : WorldGenBaseResource, subzone_prop : WorldGenBaseResource) -> void:
var sz : Control = get_node("TabContainer/SubZoneProp")
var tc : TabContainer = get_node("TabContainer")
tc.current_tab = sz.get_position_in_parent()
sz.switch_to(continent, zone, subzone, subzone_prop)

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://addons/world_generator/ui/MainScreen.gd" type="Script" id=1]
[ext_resource path="res://addons/world_generator/ui/tabs/World.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/world_generator/ui/tabs/Continent.tscn" type="PackedScene" id=3]
[ext_resource path="res://addons/world_generator/ui/tabs/Zone.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/world_generator/ui/tabs/SubZone.tscn" type="PackedScene" id=5]
[ext_resource path="res://addons/world_generator/ui/tabs/SubZoneProp.tscn" type="PackedScene" id=6]
[node name="WorldGenerator" type="PanelContainer"]
anchor_right = 1.0
@ -12,9 +13,6 @@ anchor_bottom = 1.0
rect_min_size = Vector2( 0, 200 )
size_flags_vertical = 3
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TabContainer" type="TabContainer" parent="."]
margin_left = 7.0
@ -41,7 +39,6 @@ margin_bottom = -4.0
[node name="SubZone" parent="TabContainer" instance=ExtResource( 5 )]
visible = false
margin_left = 4.0
margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
[node name="SubZoneProp" parent="TabContainer" instance=ExtResource( 6 )]
visible = false

View File

@ -1,12 +1,34 @@
tool
extends PanelContainer
func _init():
# Control/EditorZoomWidget
pass
var last_edited_res : WorldGenBaseResource = null
func set_plugin(plugin : EditorPlugin) -> void:
$ScrollContainer/MarginContainer/RectView.set_plugin(plugin)
get_node("ScrollContainer/MarginContainer/RectView").set_plugin(plugin)
func set_edited_resource(res : WorldGenBaseResource):
$ScrollContainer/MarginContainer/RectView.set_edited_resource(res)
get_node("ScrollContainer/MarginContainer/RectView").set_edited_resource(res)
if res && res != last_edited_res:
var r : Rect2 = res.get_rect()
last_edited_res = res
var axis : int = 0
if r.size.x > r.size.y:
axis = Vector2.AXIS_X
else:
axis = Vector2.AXIS_Y
if r.size[axis] > 0:
var rsx : float = get_node("ScrollContainer").rect_size[axis]
var scale : float = rsx / r.size[axis] * 0.5
get_node("Control/EditorZoomWidget").zoom = scale
get_node("ScrollContainer/MarginContainer/RectView").apply_zoom()
var sb : ScrollBar = get_node("ScrollContainer").get_h_scrollbar()
sb.ratio = 1
sb = get_node("ScrollContainer").get_v_scrollbar()
sb.ratio = 1

View File

@ -8,9 +8,6 @@
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScrollContainer" type="ScrollContainer" parent="."]
margin_left = 7.0
@ -49,6 +46,3 @@ anchor_bottom = 0.0
margin_right = 115.0
margin_bottom = 22.0
custom_constants/separation = -8
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -59,6 +59,29 @@ func on_zoom_changed(zoom : float) -> void:
func _draw():
draw_rect(Rect2(Vector2(), get_size()), Color(0.2, 0.2, 0.2, 1))
var rsh : float = clamp(_rect_scale / 2.0, 1, 5)
var c : Color = Color(0.4, 0.4, 0.4, 1)
# Indicators that show the size of a unit (1 chunk)
# Top left
draw_line(Vector2(_rect_scale, 0), Vector2(_rect_scale, rsh), c)
draw_line(Vector2(0, _rect_scale), Vector2(rsh, _rect_scale), c)
# Top right
draw_line(Vector2(get_size().x - _rect_scale, 0), Vector2(get_size().x - _rect_scale, rsh), c)
draw_line(Vector2(get_size().x - rsh, _rect_scale), Vector2(get_size().x, _rect_scale), c)
# Bottom left
draw_line(Vector2(_rect_scale, get_size().y - rsh), Vector2(_rect_scale, get_size().y), c)
draw_line(Vector2(0, get_size().y - _rect_scale), Vector2(rsh, get_size().y - _rect_scale), c)
# Bottom right
draw_line(Vector2(get_size().x - _rect_scale, get_size().y - rsh), Vector2(get_size().x - _rect_scale, get_size().y), c)
draw_line(Vector2(get_size().x - rsh, get_size().y - _rect_scale), Vector2(get_size().x, get_size().y - _rect_scale), c)
edited_resource.eitor_draw_additional_background(self)
func refresh() -> void:
clear()

View File

@ -38,7 +38,7 @@ func _draw():
draw_rect(Rect2(Vector2(), get_size()), _edited_resource_rect_color)
draw_rect(Rect2(Vector2(), get_size()), _edited_resource_rect_border_color, false, _editor_rect_border_size)
var font : Font = get_font("font")
var font : Font = get_theme_font("font")
var res_name : String = "NULL"
@ -51,10 +51,15 @@ func _draw():
res_cls = edited_resource.get_editor_class()
draw_string(font, Vector2(_editor_rect_border_size, font.get_height()), res_name, _edited_resource_font_color)
draw_string(font, Vector2(_editor_rect_border_size, font.get_height() * 2), _editor_additional_text, _edited_resource_font_color, get_rect().size.x)
if res_cls != "":
draw_string(font, Vector2(_editor_rect_border_size, font.get_height() * 3), res_cls, _edited_resource_font_color, get_rect().size.x)
draw_string(font, Vector2(_editor_rect_border_size, font.get_height() * 2), res_cls, _edited_resource_font_color, get_rect().size.x)
if _editor_additional_text != "":
draw_string(font, Vector2(_editor_rect_border_size, font.get_height() * 3), _editor_additional_text, _edited_resource_font_color, get_rect().size.x)
if edited_resource:
edited_resource.eitor_draw_additional(self)
func refresh() -> void:
if !edited_resource:

View File

@ -53,6 +53,7 @@ func add_slot_resource(getter : String, setter : String, slot_name : String, res
bc.add_child(l)
var r : Control = EditorResourceWidget.instance()
r.set_plugin(_plugin)
r.set_resource_type(resource_type)
r.set_resource(_edited_resource.call(getter))
r.set_h_size_flags(SIZE_EXPAND_FILL)
@ -110,16 +111,18 @@ func add_slot_enum(getter : String, setter : String, slot_name : String, values
return slot_idx
func add_slot_int(getter : String, setter : String, slot_name : String, prange : Vector2 = Vector2(-1000, 1000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
var bc : HBoxContainer = HBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
# l.size_flags_horizontal = SIZE_EXPAND_FILL
bc.add_child(l)
var sb : SpinBox = SpinBox.new()
sb.rounded = true
sb.min_value = prange.x
sb.max_value = prange.y
sb.set_h_size_flags(SIZE_EXPAND_FILL)
bc.add_child(sb)
var slot_idx : int = add_slot(getter, setter, bc)
@ -143,10 +146,11 @@ func add_slot_bool(getter : String, setter : String, slot_name : String) -> int:
return slot_idx
func add_slot_float(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
var bc : HBoxContainer = HBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
# l.size_flags_horizontal = SIZE_EXPAND_FILL
bc.add_child(l)
var sb : SpinBox = SpinBox.new()
@ -158,6 +162,7 @@ func add_slot_float(getter : String, setter : String, slot_name : String, step :
sb.min_value = prange.x
sb.max_value = prange.y
sb.value = _edited_resource.call(getter)
sb.set_h_size_flags(SIZE_EXPAND_FILL)
sb.connect("value_changed", self, "on_float_spinbox_value_changed", [ slot_idx ])
@ -195,7 +200,7 @@ func add_slot_vector2(getter : String, setter : String, slot_name : String, step
sby.connect("value_changed", self, "on_vector2_spinbox_value_changed", [ slot_idx, sbx, sby ])
return slot_idx
func add_slot_vector3(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
@ -303,20 +308,55 @@ func add_slot_rect2(getter : String, setter : String, slot_name : String, step :
return slot_idx
func add_slot_vector2i(getter : String, setter : String, slot_name : String, step : int = 1, prange : Vector2i = Vector2i(-1000000, 1000000)) -> int:
var bc : VBoxContainer = VBoxContainer.new()
var l : Label = Label.new()
l.text = slot_name
bc.add_child(l)
var sbx : SpinBox = SpinBox.new()
bc.add_child(sbx)
var sby : SpinBox = SpinBox.new()
bc.add_child(sby)
var slot_idx : int = add_slot(getter, setter, bc)
sbx.rounded = true
sby.rounded = true
sbx.step = step
sby.step = step
sbx.min_value = prange.x
sbx.max_value = prange.y
sby.min_value = prange.x
sby.max_value = prange.y
var val : Vector2 = _edited_resource.call(getter)
sbx.value = val.x
sby.value = val.y
sbx.connect("value_changed", self, "on_vector2i_spinbox_value_changed", [ slot_idx, sbx, sby ])
sby.connect("value_changed", self, "on_vector2i_spinbox_value_changed", [ slot_idx, sbx, sby ])
return slot_idx
func add_slot(getter : String, setter : String, control : Control) -> int:
var content_node = $MainContainer/Content
content_node.add_child(control)
var slot_idx : int = content_node.get_child_count() - 1
var child_idx : int = content_node.get_child_count() - 1
var arr : Array = Array()
arr.append(slot_idx)
arr.append(child_idx)
arr.append(getter)
arr.append(setter)
arr.append(control)
properties.append(arr)
var slot_idx : int = properties.size() - 1
return slot_idx
@ -398,6 +438,19 @@ func on_rect2_spinbox_value_changed(val : float, slot_idx, spinboxes) -> void:
_ignore_changed_evend = false
func on_vector2i_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y) -> void:
_ignore_changed_evend = true
var vv : Vector2i = Vector2i(spinbox_x.value, spinbox_y.value)
#_edited_resource.call(properties[slot_idx][2], vv)
_undo_redo.create_action("WE: Set Value")
_undo_redo.add_do_method(_edited_resource, properties[slot_idx][2], vv)
_undo_redo.add_undo_method(_edited_resource, properties[slot_idx][2], _edited_resource.call(properties[slot_idx][1]))
_undo_redo.commit_action()
_ignore_changed_evend = false
func on_slot_enum_item_selected(val : int, slot_idx : int) -> void:
_ignore_changed_evend = true
#_edited_resource.call(properties[slot_idx][2], val)

View File

@ -3,6 +3,13 @@ extends HBoxContainer
var edited_world
signal request_item_edit(world_gen_base_resource)
func _ready():
var dl : Control = get_node("VBoxContainer/DataList")
if !dl.is_connected("request_item_edit", self, "on_request_item_edit"):
dl.connect("request_item_edit", self, "on_request_item_edit")
func set_plugin(plugin : EditorPlugin) -> void:
$HSplitContainer/ResourcePropertyList.set_plugin(plugin)
$HSplitContainer/RectEditor.set_plugin(plugin)
@ -17,3 +24,6 @@ func set_wgworld(wgw : WorldGenWorld) -> void:
edited_world = wgw
refresh()
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", resource)

View File

@ -4,9 +4,16 @@ extends HBoxContainer
var edited_world : WorldGenWorld = null
var edited_continent : Continent = null
signal request_item_edit(continent, world_gen_base_resource)
func _ready():
var option_button : OptionButton = $HSplitContainer/VBoxContainer/OptionButton
option_button.connect("item_selected", self, "on_item_selected")
var dl : Control = get_node("HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList")
if !dl.is_connected("request_item_edit", self, "on_request_item_edit"):
dl.connect("request_item_edit", self, "on_request_item_edit")
func set_plugin(plugin : EditorPlugin) -> void:
$HSplitContainer/VBoxContainer/HBoxContainer2/ResourcePropertyList.set_plugin(plugin)
@ -45,6 +52,17 @@ func set_wgworld(wgw : WorldGenWorld) -> void:
refresh()
func switch_to(resource : WorldGenBaseResource) -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/OptionButton
for i in range(option_button.get_item_count()):
var continent : Continent = option_button.get_item_metadata(i)
if (continent == resource):
option_button.select(i)
set_continent(continent)
return
func set_continent(continent : Continent) -> void:
edited_continent = continent
@ -54,3 +72,7 @@ func on_item_selected(idx : int) -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/OptionButton
set_continent(option_button.get_item_metadata(idx))
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", edited_continent, resource)

View File

@ -6,24 +6,52 @@ var edited_continent : Continent = null
var edited_zone : Zone = null
var edited_sub_zone : SubZone = null
signal request_item_edit(continent, zone, subzone, subzone_prop)
func _ready():
var coption_button : OptionButton = $VBoxContainer/ContinentOptionButton
var coption_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
coption_button.connect("item_selected", self, "on_continent_item_selected")
var zoption_button : OptionButton = $VBoxContainer/ZoneOptionButton
var zoption_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
zoption_button.connect("item_selected", self, "on_zone_item_selected")
var szoption_button : OptionButton = $VBoxContainer/SubZoneOptionButton
var szoption_button : OptionButton = $HSplitContainer/VBoxContainer/SubZoneOptionButton
szoption_button.connect("item_selected", self, "on_sub_zone_item_selected")
var dl : Control = get_node("HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList")
if !dl.is_connected("request_item_edit", self, "on_request_item_edit"):
dl.connect("request_item_edit", self, "on_request_item_edit")
func set_plugin(plugin : EditorPlugin) -> void:
$VBoxContainer/HBoxContainer2/ResourcePropertyList.set_plugin(plugin)
$HSplitContainer/VBoxContainer/HBoxContainer2/ResourcePropertyList.set_plugin(plugin)
$HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList.set_plugin(plugin)
$HSplitContainer/RectEditor.set_plugin(plugin)
func refresh() -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
option_button.clear()
edited_continent = null
edited_zone = null
if !edited_world:
return
var content : Array = edited_world.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_continent:
edited_continent = c
continent_changed()
func continent_changed() -> void:
var option_button : OptionButton = $VBoxContainer/ZoneOptionButton
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
option_button.clear()
edited_zone = null
edited_sub_zone = null
if !edited_continent:
return
@ -37,11 +65,11 @@ func continent_changed() -> void:
if !edited_zone:
edited_zone = c
zone_changed()
func zone_changed() -> void:
var option_button : OptionButton = $VBoxContainer/SubZoneOptionButton
var option_button : OptionButton = $HSplitContainer/VBoxContainer/SubZoneOptionButton
option_button.clear()
edited_sub_zone = null
@ -62,34 +90,10 @@ func zone_changed() -> void:
func sub_zone_changed() -> void:
$VBoxContainer/HBoxContainer2/ResourcePropertyList.edit_resource(edited_sub_zone)
$HSplitContainer/VBoxContainer/HBoxContainer2/ResourcePropertyList.edit_resource(edited_sub_zone)
$HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList.set_edited_resource(edited_sub_zone)
$HSplitContainer/RectEditor.set_edited_resource(edited_sub_zone)
func refresh() -> void:
var option_button : OptionButton = $VBoxContainer/ContinentOptionButton
option_button.clear()
if !edited_world:
return
var content : Array = edited_world.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_continent:
edited_continent = c
continent_changed()
func set_wgworld(wgw : WorldGenWorld) -> void:
edited_world = wgw
edited_continent = null
edited_zone = null
refresh()
func set_continent(continent : Continent) -> void:
edited_continent = continent
edited_zone = null
@ -100,23 +104,65 @@ func set_zone(zone : Zone) -> void:
edited_zone = zone
zone_changed()
func set_sub_zone(sub_zone : SubZone) -> void:
edited_sub_zone = sub_zone
sub_zone_changed()
func set_wgworld(wgw : WorldGenWorld) -> void:
edited_world = wgw
edited_continent = null
edited_zone = null
refresh()
func switch_to(continent : WorldGenBaseResource, zone : WorldGenBaseResource, subzone : WorldGenBaseResource) -> void:
var contob : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
for i in range(contob.get_item_count()):
var ccont : Continent = contob.get_item_metadata(i)
if (ccont == continent):
contob.select(i)
set_continent(continent)
break
var zoneob : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
for i in range(zoneob.get_item_count()):
var czone : Zone = zoneob.get_item_metadata(i)
if (czone == zone):
zoneob.select(i)
set_zone(zone)
break
var subzoneob : OptionButton = $HSplitContainer/VBoxContainer/SubZoneOptionButton
for i in range(subzoneob.get_item_count()):
var cszone : SubZone = subzoneob.get_item_metadata(i)
if (cszone == subzone):
subzoneob.select(i)
set_sub_zone(subzone)
return
func on_continent_item_selected(idx : int) -> void:
var option_button : OptionButton = $VBoxContainer/ContinentOptionButton
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
set_continent(option_button.get_item_metadata(idx))
func on_zone_item_selected(idx : int) -> void:
var option_button : OptionButton = $VBoxContainer/ZoneOptionButton
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
set_zone(option_button.get_item_metadata(idx))
func on_sub_zone_item_selected(idx : int) -> void:
var option_button : OptionButton = $VBoxContainer/SubZoneOptionButton
var option_button : OptionButton = $HSplitContainer/VBoxContainer/SubZoneOptionButton
set_sub_zone(option_button.get_item_metadata(idx))
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", edited_continent, edited_zone, edited_sub_zone, resource)

View File

@ -1,7 +1,9 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/world_generator/ui/tabs/SubZone.gd" type="Script" id=1]
[ext_resource path="res://addons/world_generator/ui/ResourcePropertyList.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/world_generator/ui/DataList.tscn" type="PackedScene" id=3]
[ext_resource path="res://addons/world_generator/ui/RectEditor.tscn" type="PackedScene" id=4]
[node name="SubZone" type="HBoxContainer"]
anchor_right = 1.0
@ -9,41 +11,97 @@ anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
[node name="HSplitContainer" type="HSplitContainer" parent="."]
margin_right = 1024.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="ContinentOptionButton" type="OptionButton" parent="VBoxContainer"]
margin_right = 1024.0
margin_bottom = 20.0
[node name="ZoneOptionButton" type="OptionButton" parent="VBoxContainer"]
margin_top = 24.0
margin_right = 1024.0
margin_bottom = 44.0
[node name="SubZoneOptionButton" type="OptionButton" parent="VBoxContainer"]
margin_top = 48.0
margin_right = 1024.0
margin_bottom = 68.0
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 72.0
margin_right = 1024.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="ResourcePropertyList" parent="VBoxContainer/HBoxContainer2" instance=ExtResource( 2 )]
[node name="RectEditor" parent="HSplitContainer" instance=ExtResource( 4 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 735.0
margin_bottom = 600.0
size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer"]
margin_left = 747.0
margin_right = 1024.0
margin_bottom = 600.0
[node name="ContinentOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_right = 277.0
margin_bottom = 20.0
[node name="ZoneOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_top = 24.0
margin_right = 277.0
margin_bottom = 44.0
[node name="SubZoneOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer"]
margin_top = 48.0
margin_right = 277.0
margin_bottom = 68.0
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer"]
margin_top = 72.0
margin_right = 277.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="ResourcePropertyList" parent="HSplitContainer/VBoxContainer/HBoxContainer2" instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 100.0
margin_bottom = 528.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/HBoxContainer2"]
margin_left = 104.0
margin_right = 277.0
margin_bottom = 528.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
margin_right = 173.0
margin_bottom = 14.0
text = "Sub Zones"
align = 1
valign = 1
[node name="HBoxContainer" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
margin_top = 18.0
margin_right = 173.0
margin_bottom = 38.0
[node name="AddButton" type="Button" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer"]
margin_right = 37.0
margin_bottom = 20.0
text = "Add"
[node name="DeleteButton" type="Button" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer"]
margin_left = 41.0
margin_right = 96.0
margin_bottom = 20.0
text = "Delete"
[node name="Duplicate" type="Button" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer"]
margin_left = 100.0
margin_right = 173.0
margin_bottom = 20.0
text = "Duplicate"
[node name="DataList" parent="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer" instance=ExtResource( 3 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 42.0
margin_right = 173.0
margin_bottom = 528.0
class_types = 3
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/AddButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="add_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/DeleteButton" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="delete_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/Duplicate" to="HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList" method="duplicate_button_pressed"]

View File

@ -0,0 +1,204 @@
tool
extends HBoxContainer
var edited_world : WorldGenWorld = null
var edited_continent : Continent = null
var edited_zone : Zone = null
var edited_sub_zone : SubZone = null
var edited_sub_zone_prop : SubZoneProp = null
func _ready():
var coption_button : OptionButton = $VBoxContainer/ContinentOptionButton
coption_button.connect("item_selected", self, "on_continent_item_selected")
var zoption_button : OptionButton = $VBoxContainer/ZoneOptionButton
zoption_button.connect("item_selected", self, "on_zone_item_selected")
var szoption_button : OptionButton = $VBoxContainer/SubZoneOptionButton
szoption_button.connect("item_selected", self, "on_sub_zone_item_selected")
var szpoption_button : OptionButton = $VBoxContainer/SubZonePropOptionButton
szpoption_button.connect("item_selected", self, "on_sub_zone_prop_item_selected")
func set_plugin(plugin : EditorPlugin) -> void:
$VBoxContainer/HBoxContainer2/ResourcePropertyList.set_plugin(plugin)
func continent_changed() -> void:
var option_button : OptionButton = $VBoxContainer/ZoneOptionButton
option_button.clear()
edited_zone = null
edited_sub_zone = null
if !edited_continent:
return
var content : Array = edited_continent.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_zone:
edited_zone = c
zone_changed()
func zone_changed() -> void:
var option_button : OptionButton = $VBoxContainer/SubZoneOptionButton
option_button.clear()
edited_sub_zone = null
if !edited_zone:
return
var content : Array = edited_zone.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_sub_zone:
edited_sub_zone = c
sub_zone_changed()
func sub_zone_changed() -> void:
var option_button : OptionButton = $VBoxContainer/SubZonePropOptionButton
option_button.clear()
edited_sub_zone_prop = null
if !edited_sub_zone:
return
var content : Array = edited_sub_zone.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_sub_zone_prop:
edited_sub_zone_prop = c
sub_zone_prop_changed()
func sub_zone_prop_changed() -> void:
$VBoxContainer/HBoxContainer2/ResourcePropertyList.edit_resource(edited_sub_zone_prop)
func refresh() -> void:
var option_button : OptionButton = $VBoxContainer/ContinentOptionButton
option_button.clear()
if !edited_world:
return
var content : Array = edited_world.get_content()
for c in content:
if c:
option_button.add_item(c.resource_name)
option_button.set_item_metadata(option_button.get_item_count() - 1, c)
if !edited_continent:
edited_continent = c
continent_changed()
func set_wgworld(wgw : WorldGenWorld) -> void:
edited_world = wgw
edited_continent = null
edited_zone = null
edited_sub_zone = null
edited_sub_zone_prop = null
refresh()
func set_continent(continent : Continent) -> void:
edited_continent = continent
edited_zone = null
edited_sub_zone = null
edited_sub_zone_prop = null
continent_changed()
func set_zone(zone : Zone) -> void:
edited_zone = zone
edited_sub_zone = null
edited_sub_zone_prop = null
zone_changed()
func set_sub_zone(sub_zone : SubZone) -> void:
edited_sub_zone = sub_zone
edited_sub_zone_prop = null
sub_zone_changed()
func set_sub_zone_prop(sub_zone_prop : SubZoneProp) -> void:
edited_sub_zone_prop = sub_zone_prop
sub_zone_prop_changed()
func switch_to(continent : WorldGenBaseResource, zone : WorldGenBaseResource, subzone : WorldGenBaseResource, subzone_prop : WorldGenBaseResource) -> void:
var contob : OptionButton = $VBoxContainer/ContinentOptionButton
for i in range(contob.get_item_count()):
var ccont : Continent = contob.get_item_metadata(i)
if (ccont == continent):
contob.select(i)
set_continent(continent)
break
var zoneob : OptionButton = $VBoxContainer/ZoneOptionButton
for i in range(zoneob.get_item_count()):
var czone : Zone = zoneob.get_item_metadata(i)
if (czone == zone):
zoneob.select(i)
set_zone(zone)
break
var subzoneob : OptionButton = $VBoxContainer/SubZoneOptionButton
for i in range(subzoneob.get_item_count()):
var cszone : SubZone = subzoneob.get_item_metadata(i)
if (cszone == subzone):
subzoneob.select(i)
set_sub_zone(subzone)
break
var subzonepropob : OptionButton = $VBoxContainer/SubZonePropOptionButton
for i in range(subzonepropob.get_item_count()):
var cszoneprop : SubZoneProp = subzonepropob.get_item_metadata(i)
if (cszoneprop == subzone_prop):
subzonepropob.select(i)
set_sub_zone_prop(subzone_prop)
return
func on_continent_item_selected(idx : int) -> void:
var option_button : OptionButton = $VBoxContainer/ContinentOptionButton
set_continent(option_button.get_item_metadata(idx))
func on_zone_item_selected(idx : int) -> void:
var option_button : OptionButton = $VBoxContainer/ZoneOptionButton
set_zone(option_button.get_item_metadata(idx))
func on_sub_zone_item_selected(idx : int) -> void:
var option_button : OptionButton = $VBoxContainer/SubZoneOptionButton
set_sub_zone(option_button.get_item_metadata(idx))
func on_sub_zone_prop_item_selected(idx : int) -> void:
var option_button : OptionButton = $VBoxContainer/SubZonePropOptionButton
set_sub_zone_prop(option_button.get_item_metadata(idx))

View File

@ -0,0 +1,51 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/world_generator/ui/tabs/SubZoneProp.gd" type="Script" id=1]
[ext_resource path="res://addons/world_generator/ui/ResourcePropertyList.tscn" type="PackedScene" id=2]
[node name="SubZoneProp" type="HBoxContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_right = 1024.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="ContinentOptionButton" type="OptionButton" parent="VBoxContainer"]
margin_right = 1024.0
margin_bottom = 20.0
[node name="ZoneOptionButton" type="OptionButton" parent="VBoxContainer"]
margin_top = 24.0
margin_right = 1024.0
margin_bottom = 44.0
[node name="SubZoneOptionButton" type="OptionButton" parent="VBoxContainer"]
margin_top = 48.0
margin_right = 1024.0
margin_bottom = 68.0
[node name="SubZonePropOptionButton" type="OptionButton" parent="VBoxContainer"]
margin_top = 72.0
margin_right = 1024.0
margin_bottom = 92.0
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 96.0
margin_right = 1024.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="ResourcePropertyList" parent="VBoxContainer/HBoxContainer2" instance=ExtResource( 2 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 1024.0
margin_bottom = 504.0
size_flags_horizontal = 3
size_flags_vertical = 3

View File

@ -13,9 +13,6 @@ margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
script = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HSplitContainer" type="HSplitContainer" parent="."]
margin_right = 839.0

View File

@ -5,12 +5,18 @@ var edited_world : WorldGenWorld = null
var edited_continent : Continent = null
var edited_zone : Zone = null
signal request_item_edit(continent, zone, subzone)
func _ready():
var coption_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
coption_button.connect("item_selected", self, "on_continent_item_selected")
var zoption_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
zoption_button.connect("item_selected", self, "on_zone_item_selected")
var dl : Control = get_node("HSplitContainer/VBoxContainer/HBoxContainer2/VBoxContainer/DataList")
if !dl.is_connected("request_item_edit", self, "on_request_item_edit"):
dl.connect("request_item_edit", self, "on_request_item_edit")
func set_plugin(plugin : EditorPlugin) -> void:
$HSplitContainer/VBoxContainer/HBoxContainer2/ResourcePropertyList.set_plugin(plugin)
@ -80,6 +86,27 @@ func set_wgworld(wgw : WorldGenWorld) -> void:
edited_zone = null
refresh()
func switch_to(continent : WorldGenBaseResource, resource : WorldGenBaseResource) -> void:
var contob : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
for i in range(contob.get_item_count()):
var ccont : Continent = contob.get_item_metadata(i)
if (ccont == continent):
contob.select(i)
set_continent(continent)
break
var zoneob : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
for i in range(zoneob.get_item_count()):
var czone : Zone = zoneob.get_item_metadata(i)
if (czone == resource):
zoneob.select(i)
set_zone(czone)
return
func on_continent_item_selected(idx : int) -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ContinentOptionButton
@ -90,3 +117,6 @@ func on_zone_item_selected(idx : int) -> void:
var option_button : OptionButton = $HSplitContainer/VBoxContainer/ZoneOptionButton
set_zone(option_button.get_item_metadata(idx))
func on_request_item_edit(resource : WorldGenBaseResource) -> void:
emit_signal("request_item_edit", edited_continent, edited_zone, resource)

View File

@ -3,6 +3,7 @@ extends HBoxContainer
var _resource_type : String = "Resource"
var _resource : Resource = null
var _plugin : EditorPlugin = null
signal on_resource_changed(new_res)
@ -41,9 +42,8 @@ func on_clear_button_pressed() -> void:
set_resource(null)
func on_resource_button_pressed() -> void:
if _resource:
#todo
pass
if _resource && _plugin:
_plugin.get_editor_interface().inspect_object(_resource)
#examples
#{files:[res://modules/planets/test_planet/test_world.tres], from:@@4176:[Tree:9070], type:files}
@ -75,3 +75,6 @@ func get_drag_data_fw(position, from_control):
d["type"] = "resource"
return d
func set_plugin(plugin : EditorPlugin) -> void:
_plugin = plugin

View File

@ -6,9 +6,6 @@
margin_right = 376.0
margin_bottom = 40.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ResourceButton" type="Button" parent="."]
margin_right = 342.0

View File

@ -76,6 +76,8 @@ func set_zoom(p_zoom : float) -> void:
if (p_zoom > 0 && p_zoom != zoom):
zoom = p_zoom;
_update_zoom_label();
emit_signal("zoom_changed", zoom);
func set_zoom_by_increments(p_increment_count : int, p_integer_only : bool) -> void:
# Remove editor scale from the index computation.

View File

@ -139,6 +139,11 @@ _global_script_classes=[ {
"language": @"GDScript",
"path": "res://addons/world_generator/resources/subzone.gd"
}, {
"base": "Resource",
"class": @"SubZoneProp",
"language": @"GDScript",
"path": "res://addons/world_generator/resources/sub_zone_prop.gd"
}, {
"base": "GameModule",
"class": @"UIGuiChildModule",
"language": @"GDScript",
@ -154,6 +159,11 @@ _global_script_classes=[ {
"language": @"GDScript",
"path": "res://addons/world_generator/resources/world_gen_base_resource.gd"
}, {
"base": "Reference",
"class": @"WorldGenRaycast",
"language": @"GDScript",
"path": "res://addons/world_generator/raycast/world_gen_raycast.gd"
}, {
"base": "Resource",
"class": @"WorldGenWorld",
"language": @"GDScript",
@ -170,38 +180,40 @@ _global_script_classes=[ {
"path": "res://addons/world_generator/resources/zone.gd"
} ]
_global_script_class_icons={
@"CharacterAtlasEntry2D": "",
@"Continent": "",
@"EntityAIGD": "",
@"EntityDataGD": "",
@"WorldGenWorld": "",
@"ItemVisual2D": "",
@"MobGD": "",
@"PlayerMaster": "",
@"SpeedResource": "",
@"LayeredTextureMaker": "",
@"HumanoidCharacterBones2D": "",
@"CharacterAtlas2D": "",
@"CharacterSkeketonAttachPoint": "",
@"GameModule": "",
@"PlayerGD": "",
@"WorldGeneratorSettings": "",
@"LayeredTextureMaker": "",
@"HumanoidCharacterBones2D": "",
@"DisplayPlayerGD": "",
@"HealthResource": "",
@"ItemTemplateGD": "",
@"SubZone": "",
@"ItemVisual2D": "",
@"MobGD": "",
@"PlayerMaster": "",
@"SpeedResource": "",
@"WorldGenRaycast": "",
@"CharacterAtlasEntry2D": "",
@"Continent": "",
@"EntityAIGD": "",
@"EntityDataGD": "",
@"WorldGenWorld": "",
@"CharacterSkeleton2DGD": "",
@"ItemVisualEntry2D": "",
@"NetworkedPlayerGD": "",
@"SpellEffectVisualBasic": "",
@"SpellGD": "",
@"UIWindowModule": "",
@"Zone": "",
@"Main": "",
@"ManaResource": "",
@"Menu": "",
@"UIGuiChildModule": "",
@"WorldGenBaseResource": "",
@"UIWindowModule": "",
@"Zone": "",
@"CharacterSkeleton2DGD": "",
@"ItemVisualEntry2D": "",
@"NetworkedPlayerGD": "",
@"SpellEffectVisualBasic": "",
@"SpellGD": ""
@"DisplayPlayerGD": "",
@"HealthResource": "",
@"ItemTemplateGD": "",
@"SubZone": "",
@"SubZoneProp": ""
}
Node="input/actionbar_5_11"