Added Glitch Room Source code to Gitty
This commit is contained in:
commit
1ac9eb5644
505 files changed
+28504
No files matched your search
@@ -0,0 +1,182 @@
|
||||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
const WORKSPACE_SCENE := preload(
|
||||
"res://editor/workspace/EscapeRoomWorkspace.tscn"
|
||||
)
|
||||
|
||||
const DATABASE_SETTING := (
|
||||
"arcade_escape/project_database"
|
||||
)
|
||||
|
||||
const ROOM_SETTING := (
|
||||
"arcade_escape/default_room"
|
||||
)
|
||||
|
||||
|
||||
var workspace: EscapeRoomWorkspace
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
_ensure_project_settings()
|
||||
_create_workspace()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
_destroy_workspace()
|
||||
|
||||
|
||||
func _has_main_screen() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func _make_visible(visible: bool) -> void:
|
||||
if workspace != null:
|
||||
workspace.visible = visible
|
||||
|
||||
|
||||
func _get_plugin_name() -> String:
|
||||
return "Escape Room"
|
||||
|
||||
|
||||
func _get_plugin_icon() -> Texture2D:
|
||||
return EditorInterface.get_editor_theme().get_icon(
|
||||
"Node2D",
|
||||
"EditorIcons"
|
||||
)
|
||||
|
||||
|
||||
func _create_workspace() -> void:
|
||||
|
||||
if workspace != null:
|
||||
return
|
||||
|
||||
var database := _load_project_database()
|
||||
var room := _load_default_room()
|
||||
|
||||
if database == null:
|
||||
return
|
||||
|
||||
if room == null:
|
||||
return
|
||||
|
||||
workspace = WORKSPACE_SCENE.instantiate()
|
||||
|
||||
workspace.set_undo_redo_manager(
|
||||
get_undo_redo()
|
||||
)
|
||||
|
||||
EditorInterface.get_editor_main_screen().add_child(
|
||||
workspace
|
||||
)
|
||||
|
||||
workspace.set_anchors_and_offsets_preset(
|
||||
Control.PRESET_FULL_RECT
|
||||
)
|
||||
|
||||
if not workspace.configure(
|
||||
database,
|
||||
room
|
||||
):
|
||||
push_error(
|
||||
"Arcade Escape editor workspace failed to configure."
|
||||
)
|
||||
|
||||
_make_visible(false)
|
||||
|
||||
|
||||
func _destroy_workspace() -> void:
|
||||
if workspace == null:
|
||||
return
|
||||
|
||||
if is_instance_valid(workspace):
|
||||
workspace.queue_free()
|
||||
|
||||
workspace = null
|
||||
|
||||
func _ensure_project_settings() -> void:
|
||||
|
||||
if not ProjectSettings.has_setting(
|
||||
DATABASE_SETTING
|
||||
):
|
||||
ProjectSettings.set_setting(
|
||||
DATABASE_SETTING,
|
||||
"res://data/project_database.tres"
|
||||
)
|
||||
|
||||
ProjectSettings.set_initial_value(
|
||||
DATABASE_SETTING,
|
||||
"res://data/project_database.tres"
|
||||
)
|
||||
|
||||
if not ProjectSettings.has_setting(
|
||||
ROOM_SETTING
|
||||
):
|
||||
ProjectSettings.set_setting(
|
||||
ROOM_SETTING,
|
||||
"res://data/rooms/arcade_room.tres"
|
||||
)
|
||||
|
||||
ProjectSettings.set_initial_value(
|
||||
ROOM_SETTING,
|
||||
"res://data/rooms/arcade_room.tres"
|
||||
)
|
||||
|
||||
ProjectSettings.save()
|
||||
|
||||
func _load_project_database() -> ProjectDatabase:
|
||||
|
||||
var path := String(
|
||||
ProjectSettings.get_setting(
|
||||
DATABASE_SETTING,
|
||||
""
|
||||
)
|
||||
)
|
||||
|
||||
if path.is_empty():
|
||||
push_error(
|
||||
"Arcade Escape project database path is empty."
|
||||
)
|
||||
return null
|
||||
|
||||
var resource := ResourceLoader.load(
|
||||
path
|
||||
)
|
||||
|
||||
if not resource is ProjectDatabase:
|
||||
push_error(
|
||||
"Arcade Escape expected ProjectDatabase at '%s'."
|
||||
% path
|
||||
)
|
||||
return null
|
||||
|
||||
return resource as ProjectDatabase
|
||||
|
||||
func _load_default_room() -> RoomDefinition:
|
||||
|
||||
var path := String(
|
||||
ProjectSettings.get_setting(
|
||||
ROOM_SETTING,
|
||||
""
|
||||
)
|
||||
)
|
||||
|
||||
if path.is_empty():
|
||||
push_error(
|
||||
"Arcade Escape default room path is empty."
|
||||
)
|
||||
return null
|
||||
|
||||
var resource := ResourceLoader.load(
|
||||
path
|
||||
)
|
||||
|
||||
if not resource is RoomDefinition:
|
||||
push_error(
|
||||
"Arcade Escape expected RoomDefinition at '%s'."
|
||||
% path
|
||||
)
|
||||
return null
|
||||
|
||||
return resource as RoomDefinition
|
||||
@@ -0,0 +1 @@
|
||||
uid://dey5xa25bteww
|
||||
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Escape Room"
|
||||
description="Escape room authoring tools."
|
||||
author="Escape Gallery"
|
||||
version="0.1.0"
|
||||
script="escape_room_plugin.gd"
|
||||
Reference in new issue
Block a user