mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-10 08:42:11 +01:00
Added the multirun addon to the project. (Disabled by default)
This commit is contained in:
parent
a80f2a7591
commit
523d5e478b
2
game/addons/.gitignore
vendored
2
game/addons/.gitignore
vendored
@ -11,5 +11,7 @@
|
||||
!mesh_data_resource_editor/**
|
||||
!bone_editor
|
||||
!bone_editor/**
|
||||
!multirun
|
||||
!multirun/**
|
||||
!addon_versions
|
||||
|
||||
|
94
game/addons/multirun/Multirun.gd
Normal file
94
game/addons/multirun/Multirun.gd
Normal file
@ -0,0 +1,94 @@
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
var panel1
|
||||
var panel2
|
||||
var pids = []
|
||||
|
||||
func _enter_tree():
|
||||
var editor_node = get_tree().get_root().get_child(0)
|
||||
var gui_base = editor_node.get_gui_base()
|
||||
var icon_transition = gui_base.get_icon("TransitionSync", "EditorIcons") #ToolConnect
|
||||
var icon_transition_auto = gui_base.get_icon("TransitionSyncAuto", "EditorIcons")
|
||||
var icon_load = gui_base.get_icon("Load", "EditorIcons")
|
||||
|
||||
panel2 = _add_tooblar_button("_loaddir_pressed", icon_load, icon_load)
|
||||
panel1 = _add_tooblar_button("_multirun_pressed", icon_transition, icon_transition_auto)
|
||||
|
||||
_add_setting("debug/multirun/number_of_windows", TYPE_INT, 2)
|
||||
_add_setting("debug/multirun/window_distance", TYPE_INT, 1270)
|
||||
_add_setting("debug/multirun/add_custom_args", TYPE_BOOL, true)
|
||||
_add_setting("debug/multirun/first_window_args", TYPE_STRING, "listen")
|
||||
_add_setting("debug/multirun/other_window_args", TYPE_STRING, "join")
|
||||
|
||||
func _multirun_pressed():
|
||||
var window_count : int = ProjectSettings.get_setting("debug/multirun/number_of_windows")
|
||||
var window_dist : int = ProjectSettings.get_setting("debug/multirun/window_distance")
|
||||
var add_custom_args : bool = ProjectSettings.get_setting("debug/multirun/add_custom_args")
|
||||
var first_args : String = ProjectSettings.get_setting("debug/multirun/first_window_args")
|
||||
var other_args : String = ProjectSettings.get_setting("debug/multirun/other_window_args")
|
||||
var commands = ["--position", "50,10"]
|
||||
if first_args && add_custom_args:
|
||||
for arg in first_args.split(" "):
|
||||
commands.push_front(arg)
|
||||
|
||||
var main_run_args = ProjectSettings.get_setting("editor/main_run_args")
|
||||
if main_run_args != first_args:
|
||||
ProjectSettings.set_setting("editor/main_run_args", first_args)
|
||||
var interface = get_editor_interface()
|
||||
interface.play_main_scene()
|
||||
if main_run_args != first_args:
|
||||
ProjectSettings.set_setting("editor/main_run_args", main_run_args)
|
||||
|
||||
kill_pids()
|
||||
for i in range(window_count-1):
|
||||
commands = ["--position", str(50 + (i+1) * window_dist) + ",10"]
|
||||
if other_args && add_custom_args:
|
||||
for arg in other_args.split(" "):
|
||||
commands.push_front(arg)
|
||||
pids.append(OS.execute(OS.get_executable_path(), commands, false))
|
||||
|
||||
func _loaddir_pressed():
|
||||
OS.shell_open(OS.get_user_data_dir())
|
||||
|
||||
func _exit_tree():
|
||||
_remove_panels()
|
||||
kill_pids()
|
||||
|
||||
func kill_pids():
|
||||
for pid in pids:
|
||||
OS.kill(pid)
|
||||
pids = []
|
||||
|
||||
func _remove_panels():
|
||||
if panel1:
|
||||
remove_control_from_container(CONTAINER_TOOLBAR, panel1)
|
||||
panel1.free()
|
||||
if panel2:
|
||||
remove_control_from_container(CONTAINER_TOOLBAR, panel2)
|
||||
panel2.free()
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventKey:
|
||||
if event.pressed and event.scancode == KEY_F4:
|
||||
_multirun_pressed()
|
||||
|
||||
func _add_tooblar_button(action:String, icon_normal, icon_pressed):
|
||||
var panel = PanelContainer.new()
|
||||
var b = TextureButton.new();
|
||||
b.texture_normal = icon_normal
|
||||
b.texture_pressed = icon_pressed
|
||||
b.connect("pressed", self, action)
|
||||
panel.add_child(b)
|
||||
add_control_to_container(CONTAINER_TOOLBAR, panel)
|
||||
return panel
|
||||
|
||||
func _add_setting(name:String, type, value):
|
||||
if ProjectSettings.has_setting(name):
|
||||
return
|
||||
ProjectSettings.set(name, value)
|
||||
var property_info = {
|
||||
"name": name,
|
||||
"type": type
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
7
game/addons/multirun/plugin.cfg
Normal file
7
game/addons/multirun/plugin.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Multirun"
|
||||
description="Multirun allows to start multiple game instances at once."
|
||||
author="Jaanus Jaggo"
|
||||
version="1.1.0"
|
||||
script="Multirun.gd"
|
@ -273,6 +273,11 @@ gdscript/warnings/unused_argument=false
|
||||
gdscript/warnings/unused_signal=false
|
||||
gdscript/warnings/return_value_discarded=false
|
||||
gdscript/warnings/integer_division=false
|
||||
multirun/number_of_windows=2
|
||||
multirun/window_distance=1270
|
||||
multirun/add_custom_args=true
|
||||
multirun/first_window_args="listen"
|
||||
multirun/other_window_args="join"
|
||||
|
||||
[display]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user