LD56 is over. This is the game.
This commit is contained in:
21
addons/godot_debug_environments/data.gd
Normal file
21
addons/godot_debug_environments/data.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
class_name LinkData extends RefCounted
|
||||
|
||||
var links:Dictionary
|
||||
|
||||
func _init() -> void:
|
||||
load_scene_links()
|
||||
|
||||
func has_link(original_scene:String)->bool: return links.keys().has(original_scene)
|
||||
|
||||
func get_link(original_scene:String)->String: return links[original_scene] as String
|
||||
|
||||
func save_scene_link(original_scene:String, target_scene:String):
|
||||
links[original_scene] = target_scene
|
||||
var file = FileAccess.open("res://addons/godot_debug_environments/links.json", FileAccess.WRITE)
|
||||
file.store_string(JSON.stringify(links))
|
||||
file.close()
|
||||
|
||||
func load_scene_links():
|
||||
var file = FileAccess.open("res://addons/godot_debug_environments/links.json", FileAccess.READ)
|
||||
links = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
@@ -1,37 +0,0 @@
|
||||
@tool
|
||||
extends EditorInspectorPlugin
|
||||
|
||||
func _can_handle(object):
|
||||
return object is Node and object == EditorInterface.get_edited_scene_root()
|
||||
|
||||
func _parse_begin(object):
|
||||
add_custom_control(create_ui(object))
|
||||
|
||||
func create_ui(node: Node) -> Control:
|
||||
var path = DebugEnvironmentLib.get_debug_path(node)
|
||||
var button = Button.new()
|
||||
button.icon = load("res://addons/godot_debug_environments/flask.svg")
|
||||
if(FileAccess.file_exists(path)):
|
||||
button.text = "Edit testing environment"
|
||||
button.pressed.connect(func(): edit_env(path), CONNECT_DEFERRED)
|
||||
else:
|
||||
button.text = "Create testing environment"
|
||||
button.pressed.connect(func(): create_env(path), CONNECT_DEFERRED)
|
||||
return button
|
||||
|
||||
func edit_env(path: String):
|
||||
EditorInterface.open_scene_from_path(path)
|
||||
|
||||
func create_env(path: String):
|
||||
if !DirAccess.dir_exists_absolute(path.get_base_dir()):
|
||||
DirAccess.make_dir_recursive_absolute(path.get_base_dir())
|
||||
var env = Node.new()
|
||||
env.name = path.get_file().replace(".tscn", "")
|
||||
var target = Node.new()
|
||||
target.name = "$DEBUG_TARGET$"
|
||||
env.add_child(target)
|
||||
target.owner = env
|
||||
var scene = PackedScene.new()
|
||||
scene.pack(env)
|
||||
ResourceSaver.save(scene, path)
|
||||
edit_env(path)
|
||||
@@ -1,6 +0,0 @@
|
||||
class_name DebugEnvironmentLib extends Object
|
||||
|
||||
const debug_environment_path = "res://editor/debug_environments/debug_env_$SCENE$"
|
||||
|
||||
static func get_debug_path(node:Node) -> String:
|
||||
return debug_environment_path.replace("$SCENE$", node.scene_file_path.get_file())
|
||||
@@ -1,10 +0,0 @@
|
||||
extends Node
|
||||
|
||||
func _ready() -> void:
|
||||
# Get loaded scene
|
||||
var node = get_tree().current_scene
|
||||
# Check if debug environment is stored
|
||||
var path = DebugEnvironmentLib.get_debug_path(node)
|
||||
if not FileAccess.file_exists(path): return
|
||||
# Replace instance with debug environment
|
||||
get_tree().call_deferred("change_scene_to_file",path)
|
||||
38
addons/godot_debug_environments/inspector.gd
Normal file
38
addons/godot_debug_environments/inspector.gd
Normal file
@@ -0,0 +1,38 @@
|
||||
@tool
|
||||
class_name DebugEnvironmentInspector extends EditorInspectorPlugin
|
||||
|
||||
var current_scene:Node
|
||||
|
||||
func _can_handle(object:Object)->bool:
|
||||
return object is Node and object == EditorInterface.get_edited_scene_root()
|
||||
|
||||
func _parse_begin(object:Object)->void:
|
||||
current_scene = object as Node
|
||||
add_custom_control(create_ui(object as Node))
|
||||
|
||||
func create_ui(object:Node)->Control:
|
||||
var root := VBoxContainer.new()
|
||||
var header : = HBoxContainer.new()
|
||||
root.add_child(header)
|
||||
var icon := TextureRect.new()
|
||||
header.add_child(icon)
|
||||
icon.texture = load("res://addons/godot_debug_environments/flask.svg") as Texture2D
|
||||
var title := Label.new()
|
||||
header.add_child(title)
|
||||
title.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
title.text = "Select testing scene"
|
||||
var scene_picker := EditorResourcePicker.new()
|
||||
root.add_child(scene_picker)
|
||||
scene_picker.base_type = "PackedScene"
|
||||
var data := LinkData.new()
|
||||
if data.has_link(current_scene.scene_file_path):
|
||||
var scene_path := data.get_link(current_scene.scene_file_path)
|
||||
scene_picker.edited_resource = ResourceLoader.load(scene_path)
|
||||
scene_picker.connect("resource_changed",on_scene_selected)
|
||||
return root
|
||||
|
||||
func on_scene_selected(resource:Resource)->void:
|
||||
var current_scene_path := current_scene.scene_file_path
|
||||
var target_scene_path := resource.resource_path
|
||||
var data := LinkData.new()
|
||||
data.save_scene_link(current_scene_path, target_scene_path)
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
{
|
||||
"profiles": {
|
||||
"Godot Debug": {
|
||||
"commandName": "Executable",
|
||||
"executablePath": "$EDITOR$",
|
||||
"commandLineArgs": "--path . --verbose",
|
||||
"workingDirectory": ".",
|
||||
"nativeDebugging": true
|
||||
},
|
||||
"Godot Debug $NAME$": {
|
||||
"commandName": "Executable",
|
||||
"executablePath": "$EDITOR$",
|
||||
"commandLineArgs": "--upwards $PATH$ --verbose",
|
||||
"workingDirectory": ".",
|
||||
"nativeDebugging": true
|
||||
}
|
||||
}
|
||||
}
|
||||
1
addons/godot_debug_environments/links.json
Normal file
1
addons/godot_debug_environments/links.json
Normal file
@@ -0,0 +1 @@
|
||||
{"res://entities/faction/fog_of_war.tscn":"res://scenes/game.tscn","res://entities/faction/player/player.tscn":"res://scenes/game.tscn"}
|
||||
@@ -1,13 +1,17 @@
|
||||
@tool
|
||||
extends EditorPlugin
|
||||
class_name DebugEnvironmentPlugin extends EditorPlugin
|
||||
|
||||
var plugin
|
||||
static var instance:DebugEnvironmentPlugin
|
||||
|
||||
var inspector:DebugEnvironmentInspector
|
||||
|
||||
func _enter_tree():
|
||||
plugin = preload("res://addons/godot_debug_environments/debug_environment_editor_inspector.gd").new()
|
||||
add_autoload_singleton("DebugEnvironmentWatcher", "res://addons/godot_debug_environments/debug_environment_watcher.gd")
|
||||
add_inspector_plugin(plugin)
|
||||
instance = self
|
||||
var inspector_script := load("res://addons/godot_debug_environments/inspector.gd") as GDScript
|
||||
inspector = inspector_script.new()
|
||||
add_inspector_plugin(inspector)
|
||||
add_autoload_singleton("DebugEnvironmentWatcher", "res://addons/godot_debug_environments/watcher.gd")
|
||||
|
||||
func _exit_tree():
|
||||
remove_inspector_plugin(inspector)
|
||||
remove_autoload_singleton("DebugEnvironmentWatcher")
|
||||
remove_inspector_plugin(plugin)
|
||||
|
||||
8
addons/godot_debug_environments/watcher.gd
Normal file
8
addons/godot_debug_environments/watcher.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends Node
|
||||
|
||||
func _ready() -> void:
|
||||
var scene := get_tree().current_scene
|
||||
var data := LinkData.new()
|
||||
if not data.has_link(scene.scene_file_path): return
|
||||
var new_scene_path := data.get_link(scene.scene_file_path)
|
||||
get_tree().call_deferred("change_scene_to_file",new_scene_path)
|
||||
@@ -3,25 +3,26 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cqln7j6oifypf"
|
||||
path="res://.godot/imported/thumb_placeholder.svg-81a80a6d7c59edb9d7ce28b01f213c5c.ctex"
|
||||
path.s3tc="res://.godot/imported/thumb_placeholder.svg-81a80a6d7c59edb9d7ce28b01f213c5c.s3tc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/scene-library/icons/thumb_placeholder.svg"
|
||||
dest_files=["res://.godot/imported/thumb_placeholder.svg-81a80a6d7c59edb9d7ce28b01f213c5c.ctex"]
|
||||
dest_files=["res://.godot/imported/thumb_placeholder.svg-81a80a6d7c59edb9d7ce28b01f213c5c.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
@@ -31,7 +32,7 @@ process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
detect_3d/compress_to=0
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
|
||||
Reference in New Issue
Block a user