Skip to content

Commit

Permalink
Add more menu options
Browse files Browse the repository at this point in the history
  • Loading branch information
Giwayume committed Oct 13, 2021
1 parent 6c3afdd commit 281d542
Show file tree
Hide file tree
Showing 19 changed files with 1,654 additions and 2,128 deletions.
2,752 changes: 1,376 additions & 1,376 deletions EditorTheme/MainTheme.tres

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ An WORK IN PROGRESS level editor for Bloodstained: Ritual of the Night.

Target functionality:
- [ ] Add/Remove enemies from any room
- [ ] Edit the placement of any 3D static mesh in any room or remove them
- [x] Edit the placement of any 3D static mesh in any room or remove them
- [x] Undo/redo history
- [x] Visual transform cursor
- [x] Translate meshes
Expand All @@ -13,10 +13,10 @@ Target functionality:
- [ ] Uniform scaling shortcut
- [x] Rotate meshes
- [ ] Snapping to unit increments
- [ ] Inspector
- [ ] Edit transform numbers directly
- [x] Inspector
- [x] Edit transform numbers directly
- [ ] Load textures/materials as best as we can
- [ ] Remove meshes
- [x] Remove meshes
- [ ] Add any existing 3D model in the game to any room as a static mesh
- [ ] Add/edit/remove lights
- [ ] Support "Splines" (used in many levels for the basic level geometry, especially the underground levels)
Expand Down
3 changes: 2 additions & 1 deletion SceneComponents/Inspector/MeshInfoPanel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[sub_resource type="StyleBoxEmpty" id=1]
content_margin_left = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0

[node name="MeshInfoPanel" type="VBoxContainer"]
anchor_right = 1.0
Expand All @@ -30,7 +31,7 @@ align = 0
[node name="ExpandSection" type="PanelContainer" parent="."]
margin_top = 22.0
margin_right = 1024.0
margin_bottom = 114.0
margin_bottom = 118.0
custom_styles/panel = SubResource( 1 )

[node name="VBoxContainer" type="VBoxContainer" parent="ExpandSection"]
Expand Down
3 changes: 2 additions & 1 deletion SceneComponents/Inspector/TransformPanel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[sub_resource type="StyleBoxEmpty" id=1]
content_margin_left = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0

[node name="TransformPanel" type="VBoxContainer"]
anchor_right = 1.0
Expand All @@ -34,7 +35,7 @@ align = 0
[node name="ExpandSection" type="PanelContainer" parent="."]
margin_top = 22.0
margin_right = 1024.0
margin_bottom = 160.0
margin_bottom = 164.0
custom_styles/panel = SubResource( 1 )

[node name="VBoxContainer" type="VBoxContainer" parent="ExpandSection"]
Expand Down
44 changes: 35 additions & 9 deletions SceneComponents/RoomEditMenuBar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,45 @@ signal popup_visibility_changed
var editor: Node

var menu_button_package: MenuButton
var menu_button_package_popup: PopupMenu
var menu_button_edit: MenuButton
var menu_button_edit_popup: PopupMenu

var is_any_menu_popup_visible: bool = false
var is_control_modifier_pressed: bool = false
var is_shift_modifier_pressed: bool = false

enum {
POPUP_ITEM_TEST_PACKAGE,
POPUP_ITEM_OPEN_PACKAGE_FOLDER,
POPUP_ITEM_OPEN_MAP,
POPUP_ITEM_EXIT_PACKAGE,
POPUP_ITEM_EDIT_UNDO,
POPUP_ITEM_EDIT_REDO
}

func _ready():
editor = get_node("/root/Editor");

menu_button_package = find_node("PackageMenuButton", true, true)
menu_button_edit = find_node("EditMenuButton", true, true)
menu_button_package_popup = menu_button_package.get_popup()
menu_button_edit_popup = menu_button_edit.get_popup()

menu_button_package_popup.add_item("Test In-Game", POPUP_ITEM_TEST_PACKAGE)
menu_button_package_popup.add_item("Open Package Folder", POPUP_ITEM_OPEN_PACKAGE_FOLDER)
menu_button_package_popup.add_separator()
menu_button_package_popup.add_item("View Map", POPUP_ITEM_OPEN_MAP)
menu_button_package_popup.add_separator()
menu_button_package_popup.add_item("Exit", POPUP_ITEM_EXIT_PACKAGE)

menu_button_edit_popup.add_item("Undo", POPUP_ITEM_EDIT_UNDO)
menu_button_edit_popup.add_item("Redo", POPUP_ITEM_EDIT_REDO)

menu_button_package.get_popup().connect("id_pressed", self, "on_menu_popup_package_pressed")
menu_button_package.get_popup().connect("visibility_changed", self, "on_any_menu_popup_visibility_changed")
menu_button_edit.get_popup().connect("id_pressed", self, "on_menu_popup_edit_pressed")
menu_button_edit.get_popup().connect("visibility_changed", self, "on_any_menu_popup_visibility_changed")
menu_button_package_popup.connect("id_pressed", self, "on_menu_popup_package_pressed")
menu_button_package_popup.connect("visibility_changed", self, "on_any_menu_popup_visibility_changed")
menu_button_edit_popup.connect("id_pressed", self, "on_menu_popup_edit_pressed")
menu_button_edit_popup.connect("visibility_changed", self, "on_any_menu_popup_visibility_changed")

func _input(event):
if event is InputEventKey:
Expand All @@ -36,17 +59,20 @@ func _input(event):
editor.redo_action()

func on_menu_popup_package_pressed(id: int):
if id == 0:
if id == POPUP_ITEM_TEST_PACKAGE:
editor.package_and_install()
elif id == 1:
elif id == POPUP_ITEM_OPEN_PACKAGE_FOLDER:
var open_path = str("file://", ProjectSettings.globalize_path("user://UserPackages/" + editor.selected_package))
OS.shell_open(open_path)
elif id == POPUP_ITEM_OPEN_MAP:
get_tree().change_scene("res://Scenes/MapEdit.tscn")
elif id == 3:
elif id == POPUP_ITEM_EXIT_PACKAGE:
get_tree().change_scene("res://Scenes/SelectPackage.tscn")

func on_menu_popup_edit_pressed(id: int):
if id == 0:
if id == POPUP_ITEM_EDIT_UNDO:
editor.undo_action()
elif id == 1:
elif id == POPUP_ITEM_EDIT_REDO:
editor.redo_action()

func on_any_menu_popup_visibility_changed():
Expand Down
2 changes: 0 additions & 2 deletions SceneComponents/RoomEditMenuBar.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ margin_right = 63.0
margin_bottom = 22.0
focus_mode = 2
text = "Package"
items = [ "Test In-Game", null, 0, false, false, 0, 0, null, "", false, "View Map", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, 2, 0, null, "", true, "Exit", null, 0, false, false, 3, 0, null, "", false ]
switch_on_hover = true

[node name="EditMenuButton" type="MenuButton" parent="."]
Expand All @@ -26,5 +25,4 @@ margin_right = 103.0
margin_bottom = 22.0
focus_mode = 2
text = "Edit"
items = [ "Undo", null, 0, false, false, 0, 0, null, "", false, "Redo", null, 0, false, false, 1, 0, null, "", false ]
switch_on_hover = true
22 changes: 22 additions & 0 deletions SceneComponents/UiComponents/Toast.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extends CenterContainer

var label: Label
var show_timeout: float = 3
var fade_timeout: float = .5
var fade_timeout_max: float = .5

# Called when the node enters the scene tree for the first time.
func _ready():
label = find_node("Label", true, true)

func set_text(text: String):
label.text = text

func _process(delta):
if show_timeout > 0:
show_timeout -= delta
elif fade_timeout > 0:
fade_timeout -= delta
modulate.a = fade_timeout / fade_timeout_max
else:
queue_free()
37 changes: 37 additions & 0 deletions SceneComponents/UiComponents/Toast.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://SceneComponents/UiComponents/Toast.gd" type="Script" id=1]

[sub_resource type="StyleBoxFlat" id=1]
content_margin_left = 8.0
content_margin_right = 8.0
content_margin_top = 8.0
content_margin_bottom = 8.0
bg_color = Color( 0, 0, 0, 0.882353 )
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color( 1, 1, 1, 0.623529 )

[node name="Toast" type="CenterContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PanelContainer" type="PanelContainer" parent="."]
margin_left = 457.0
margin_top = 281.0
margin_right = 566.0
margin_bottom = 319.0
custom_styles/panel = SubResource( 1 )

[node name="Label" type="Label" parent="PanelContainer"]
margin_left = 8.0
margin_top = 8.0
margin_right = 101.0
margin_bottom = 30.0
text = "Example Text"
27 changes: 18 additions & 9 deletions Scenes/Editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Control

signal history_changed

var toast_scene = preload("res://SceneComponents/UiComponents/Toast.tscn")
var loading_screen_scene = preload("res://Scenes/LoadingScreen.tscn")

var package_and_install_thread: Thread
Expand Down Expand Up @@ -163,28 +164,36 @@ func remove_room_edit_export_prop(asset_type: String, export_index, prop_name: S
# PACKAGING #
#############

func package_and_install(package_name: String = ""):
func package_and_install(package_name: String = "", is_run_game: bool = true, install_finish_callback_target: Object = null, install_finish_callback_method: String = ""):
save_room_edits()
if package_name == "":
package_name = selected_package
start_package_and_install_thread(package_name)
start_package_and_install_thread(package_name, is_run_game, install_finish_callback_target, install_finish_callback_method)

func start_package_and_install_thread(package_name: String):
func start_package_and_install_thread(package_name: String, is_run_game: bool, install_finish_callback_target: Object, install_finish_callback_method: String):
loading_screen = loading_screen_scene.instance()
get_tree().get_root().add_child(loading_screen)
loading_screen.set_status_text("Packaging Project...")
package_and_install_thread = Thread.new()
package_and_install_thread.start(self, "package_and_install_thread_function", package_name)
package_and_install_thread.start(self, "package_and_install_thread_function", [package_name, is_run_game, install_finish_callback_target, install_finish_callback_method])

func package_and_install_thread_function(package_name: String):
func package_and_install_thread_function(thread_data: Array):
var uasset_parser = get_node("/root/UAssetParser")
var package_name: String = thread_data[0]
uasset_parser.PackageAndInstallMod(package_name)
call_deferred("end_package_and_install_thread")
call_deferred("end_package_and_install_thread", thread_data[1], thread_data[2], thread_data[3])

func end_package_and_install_thread():
func end_package_and_install_thread(is_run_game: bool, install_finish_callback_target: Object, install_finish_callback_method: String):
package_and_install_thread.wait_to_finish()
get_tree().get_root().remove_child(loading_screen)
loading_screen = null

var game_directory = EditorConfig.read_config()["game_directory"]
# OS.execute(game_directory + "/BloodstainedRotN/Binaries/Win64/BloodstainedRotN-Win64-Shipping.exe", [], false)
if is_run_game:
var game_directory = EditorConfig.read_config()["game_directory"]
OS.execute(game_directory + "/BloodstainedRotN/Binaries/Win64/BloodstainedRotN-Win64-Shipping.exe", [], false)
var toast = toast_scene.instance()
get_tree().get_root().add_child(toast)
toast.set_text("The game will launch momentarily...")

if install_finish_callback_target != null:
install_finish_callback_target.call_deferred(install_finish_callback_method)
5 changes: 4 additions & 1 deletion Scenes/MapEdit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ func on_map_level_activated(level_name_to_activate: String):
func on_menu_popup_package_pressed(id: int):
if id == 0:
editor.package_and_install()
elif id == 2:
if id == 1:
var open_path = str("file://", ProjectSettings.globalize_path("user://UserPackages/" + editor.selected_package))
OS.shell_open(open_path)
elif id == 3:
get_tree().change_scene("res://Scenes/SelectPackage.tscn")

func on_search_level_name_changed(search_text: String):
Expand Down
2 changes: 1 addition & 1 deletion Scenes/MapEdit.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ margin_bottom = 22.0
margin_right = 63.0
margin_bottom = 22.0
text = "Package"
items = [ "Test In-Game", null, 0, false, false, 0, 0, null, "", false, "", null, 0, false, false, 1, 0, null, "", true, "Exit", null, 0, false, false, 2, 0, null, "", false ]
items = [ "Test In-Game", null, 0, false, false, 0, 0, null, "", false, "Open Package Folder", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, 2, 0, null, "", true, "Exit", null, 0, false, false, 3, 0, null, "", false ]

[node name="EditMenuButton" type="MenuButton" parent="RoomSelectContainer/VBoxContainer/PanelContainer/HBoxContainer"]
margin_left = 67.0
Expand Down
Loading

0 comments on commit 281d542

Please sign in to comment.