Skip to content

Commit

Permalink
Merge pull request #100 from LainAmongYou/unique-name-for-add-mod-window
Browse files Browse the repository at this point in the history
Make Add Mod window usable while Mods window popped out
  • Loading branch information
ExpiredPopsicle authored Feb 23, 2025
2 parents 79047d3 + dd92b95 commit d4ef894
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
29 changes: 17 additions & 12 deletions Core/UI/BasicSubWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var embed_window_pos: Vector2 = Vector2(0, 0)
var embed_window_size: Vector2 = Vector2(0, 0)
var popout_window_pos: Vector2i = Vector2i(0, 0)
var popout_window_size: Vector2i = Vector2i(0, 0)
var popout_modal: bool = false

# Native window if popped out
var popout_window: Window = null
Expand Down Expand Up @@ -398,22 +399,25 @@ func _set_popped_out(pop_out: bool) -> void:
popped_out = pop_out

if pop_out:
var colorrect: ColorRect = null

# ---------------------------------------
# Create menu bar

var colorrect = ColorRect.new()
colorrect.color = Color.BLACK
colorrect.custom_minimum_size = Vector2(0, 32)
if !popout_modal:
colorrect = ColorRect.new()
colorrect.color = Color.BLACK
colorrect.custom_minimum_size = Vector2(0, 32)

var hboxcontainer = HBoxContainer.new()
var popin_button = Button.new()
popin_button.text = "Pop in"
popin_button.focus_mode = Control.FOCUS_NONE
popin_button.flat = true
popin_button.pressed.connect(_on_popin_button_pressed)
var hboxcontainer = HBoxContainer.new()
var popin_button = Button.new()
popin_button.text = "Pop in"
popin_button.focus_mode = Control.FOCUS_NONE
popin_button.flat = true
popin_button.pressed.connect(_on_popin_button_pressed)

hboxcontainer.add_child(popin_button)
colorrect.add_child(hboxcontainer)
hboxcontainer.add_child(popin_button)
colorrect.add_child(hboxcontainer)

# ---------------------------------------
# Create native window
Expand Down Expand Up @@ -465,7 +469,8 @@ func _set_popped_out(pop_out: bool) -> void:

var container = VBoxContainer.new()
container.set_anchors_preset(Control.PRESET_FULL_RECT)
container.add_child(colorrect)
if colorrect != null:
container.add_child(colorrect)
container.add_child(bare_control)

popout_window.add_child(container)
Expand Down
7 changes: 3 additions & 4 deletions Core/UI/ModAddWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var _mods_list = []

# Called when the node enters the scene tree for the first time.
func _ready() -> void:

popout_modal = true
_get_app_root()._load_mods()

var mod_scene_files : PackedStringArray
Expand Down Expand Up @@ -42,8 +42,7 @@ func _ready() -> void:
%Mods_List.add_item(mod_entry["name"])

func _get_mods_node():
# FIXME: Make a better way to get this data.
return get_node("../../../Mods")
return _get_app_root().get_node("%Mods")

func _on_button_add_mod_pressed() -> void:

Expand All @@ -56,7 +55,7 @@ func _on_button_add_mod_pressed() -> void:
%ModsWindow.update_mods_list()

func _on_button_cancel_pressed():
hide()
close_window()

func _on_mods_list_item_selected(_index: int) -> void:

Expand Down
11 changes: 9 additions & 2 deletions Core/UI/ModsWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,15 @@ func _on_button_remove_mod_pressed():
update_mods_list()

func _on_button_add_mod_pressed():
get_node("../ModAddWindow").show_window()

var add_window = _get_app_root().get_node("%UI_Root/%ModAddWindow")
add_window._save_current_window_state()
add_window.show_window()
add_window._set_popped_out(popped_out)
if popped_out:
var last_owner = add_window.owner
add_window.popout_window.reparent(self)
add_window.owner = last_owner
add_window.popout_window.exclusive = true

func _update_currently_selected_name():
var mods_list_node : ItemList = %ModsList
Expand Down
5 changes: 5 additions & 0 deletions Core/UI/UI_Root.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ title = "acsdcscsc"
size = Vector2i(145, 124)
item_count = 6
item_0/text = "Open VRM..."
item_0/id = 0
item_1/id = 5
item_1/separator = true
item_2/text = "Save settings..."
Expand All @@ -60,6 +61,7 @@ item_5/id = 1
size = Vector2i(176, 100)
item_count = 5
item_0/text = "General settings..."
item_0/id = 0
item_1/text = "Colliders..."
item_1/id = 1
item_2/text = "Sound..."
Expand All @@ -72,6 +74,7 @@ item_4/id = 4
[node name="Modules" type="PopupMenu" parent="ColorRect/HBoxContainer/MenuBar"]
item_count = 2
item_0/text = "Mod list..."
item_0/id = 0
item_1/text = "Channel Event Tester..."
item_1/id = 1

Expand All @@ -85,6 +88,7 @@ layout_mode = 2
[node name="Help" type="PopupMenu" parent="ColorRect/HBoxContainer/MenuBar2"]
item_count = 2
item_0/text = "Controls..."
item_0/id = 0
item_1/text = "About..."
item_1/id = 1

Expand Down Expand Up @@ -141,6 +145,7 @@ offset_bottom = 384.0
focus_mode = 0

[node name="ModAddWindow" parent="." instance=ExtResource("6_ohgoj")]
unique_name_in_owner = true
visible = false
offset_left = 363.0
offset_top = 255.0
Expand Down

0 comments on commit d4ef894

Please sign in to comment.