extends VBoxContainer @onready var osd_dwell_time = $"OSD and UI/Controls/VBoxContainer/osd_dwell_time" @onready var osd_fade_time = $"OSD and UI/Controls/VBoxContainer/osd_fade_time" @onready var osd_opacity = $"OSD and UI/Controls/VBoxContainer/osd_opacity" @onready var menu_opacity = $"OSD and UI/Controls/VBoxContainer/menu_opacity" @onready var background_opacity = $"OSD and UI/Controls/VBoxContainer/background_opacity" @onready var tempo_default = $"Tempo/Controls/VBoxContainer/tempo_default" @onready var tempo_numerator = $"Tempo/Controls/VBoxContainer/tempo_numerator" @onready var spritesheet_image = $"Sprites/Controls/VBoxContainer/spritesheet_image" @onready var spritesheet_data = $"Sprites/Controls/VBoxContainer/spritesheet_data" @onready var spritesheet_anims = $"Sprites/Controls/VBoxContainer/spritesheet_anims" @onready var spritesheet_anchor = $"Sprites/Controls/VBoxContainer/spritesheet_anchor" @onready var sprite_scale = $"Sprites/Controls/VBoxContainer/sprite_scale" @onready var sprite_flip = $"Sprites/Controls/VBoxContainer/sprite_flip" @onready var spritesheet_default_opacity = $"Sprites/Controls/VBoxContainer/spritesheet_default_opacity" @onready var anims = $"Binds/Controls/VBoxContainer" @onready var matsymout = load("res://assets/fonts/MatSymOut.ttf") @onready var close_icon = load("res://assets/icons/close.png") @onready var add_icon = load("res://assets/icons/add.png") var temp_config = Config.new_clear() func _parse_form_values() -> void: pass # Called when the node enters the scene tree for the first time. func _ready() -> void: temp_config.clone_config(GlobalConfig) link_range_to_property(osd_dwell_time, "osd_dwell_time") link_range_to_property(osd_fade_time, "osd_fade_time") link_value_to_slider(osd_opacity) link_range_to_property(osd_opacity, "osd_opacity") link_value_to_slider(menu_opacity) link_range_to_property(menu_opacity, "menu_opacity") link_value_to_slider(background_opacity) link_range_to_property(background_opacity, "background_opacity") link_range_to_property(tempo_default, "tempo_default") link_range_to_property(tempo_numerator, "tempo_numerator") link_filebox_to_property(spritesheet_image, "spritesheet_image") link_filebox_to_property(spritesheet_data, "spritesheet_data") link_optionbutton_to_property(spritesheet_anchor, "spritesheet_anchor", Config.SpritesheetAnchor) link_range_to_property(sprite_scale, "sprite_scale") link_toggleable_to_property(sprite_flip, "sprite_flip") link_value_to_slider(spritesheet_default_opacity) link_range_to_property(spritesheet_default_opacity, "spritesheet_default_opacity") fuckwith_anims() fuckwith_spritesheet_anims() func _on_back_button_pressed() -> void: GlobalConfig.clone_config(temp_config) GlobalConfig.save_to_file() var unlock_func = null func _input(event:InputEvent) -> void: if unlock_func and event is InputEventKey: unlock_func.call(event.physical_keycode) func link_value_to_slider(obj:BoxContainer) -> void: var input:HSlider = obj.get_node("input") var value:Label = obj.get_node("value") input.value_changed.connect(func(va: float): value.text = str(va * 100) + "%") func link_range_to_property(obj:BoxContainer, property:String) -> void: var input:Range = obj.get_node("input") input.value = temp_config[property] input.value_changed.connect(func(va: float): temp_config[property] = va) func link_toggleable_to_property(obj:BoxContainer, property:String) -> void: var input:BaseButton = obj.get_node("input") input.button_pressed = temp_config[property] input.toggled.connect(func(toggled_on: bool): temp_config[property] = toggled_on) func link_textbox_to_property(obj:BoxContainer, property:String) -> void: var input:LineEdit = obj.get_node("value") input.text = temp_config[property] input.text_changed.connect(func(va: String): temp_config[property] = va) func link_filebox_to_property(obj:BoxContainer, property:String) -> void: var input:LineEdit = obj.get_node("value") input.text = temp_config[property] obj.file_changed.connect(func(va: String): temp_config[property] = va) func link_optionbutton_to_property(obj:BoxContainer, property:String, enu:Dictionary) -> void: var input:OptionButton = obj.get_node("input") input.select( Config.SpritesheetAnchorIndices.find( enu.find_key(temp_config[property]) ) ) input.item_selected.connect(func(index: int): temp_config[property] = enu[Config.SpritesheetAnchorIndices[index]]) func fuckwith_spritesheet_anims() -> void: var tree:Tree = spritesheet_anims.get_node("Tree") var add_new_name:LineEdit = spritesheet_anims.get_node("AddNew/name") var add_new_switch:Button = spritesheet_anims.get_node("AddNew/switch") var tree_anims:Tree = anims.get_node("Tree") tree.set_column_title(0, "Animation Name") tree.set_column_title(1, "Alias") tree.set_column_title(2, "Type") var tree_root = tree.create_item() var tree_anims_root = tree_anims.get_root() var tree_anims_root_anims = tree_anims.get_root().get_child(0) var tree_anims_root_functions = tree_anims.get_root().get_child(1) var keep_updated = func(): temp_config.spritesheet_anims = {} for child in tree_root.get_children(): var child_name = child.get_text(0) var child_alias = child.get_text(1) var child_type = child.get_range(2) temp_config.spritesheet_anims[child_name] = { alias = child_alias if child_alias.length() > 0 else null, type = child_type } var has_thing = false for alias in tree_anims_root_anims.get_children(): if child_alias.length() < 1 or alias.get_text(0) == child_alias: has_thing = true break if not has_thing: var anims_child = tree_anims.create_item(tree_anims_root_anims) anims_child.set_cell_mode(0, TreeItem.CELL_MODE_STRING) anims_child.set_editable(0, false) anims_child.set_text(0, child_alias) temp_config.anim_binds[child_alias] = [] anims_child.add_button(2, add_icon, 1) for alias in tree_anims_root_anims.get_children(): var has_thing = false for child in tree_root.get_children(): var child_alias = child.get_text(1) if child_alias.length() > 0 and alias.get_text(0) == child_alias: has_thing = true break if not has_thing: temp_config.anim_binds.erase(alias.get_text(0)) alias.free() spritesheet_data.file_changed.connect(func(path: String): var spritesheet_parser = SpritesheetParser.new() spritesheet_parser.parse_spritesheet(path) for animation in spritesheet_parser.spritesheet: for child in tree_root.get_children(): if child.get_text(0) == animation: return var child = tree.create_item(tree_root) child.set_cell_mode(0, TreeItem.CELL_MODE_STRING) child.set_editable(0, true) child.set_text(0, animation) child.set_cell_mode(1, TreeItem.CELL_MODE_STRING) child.set_editable(1, true) child.set_text(1, "") if animation.containsn("left"): child.set_text(1, "left") elif animation.containsn("down"): child.set_text(1, "down") elif animation.containsn("up"): child.set_text(1, "up") elif animation.containsn("right"): child.set_text(1, "right") child.set_cell_mode(2, TreeItem.CELL_MODE_RANGE) child.set_editable(2, true) child.set_text(2, "Default,Idle") child.add_button(2, close_icon) child.set_range(2, animation.containsn("idle")) keep_updated.call() ) tree.item_edited.connect(keep_updated) tree.button_clicked.connect(func(item:TreeItem, column:int, _id, _mbi): var item_name = item.get_text(0) if column == 2: item.free() keep_updated.call() ) for animation in temp_config.spritesheet_anims: var child = tree.create_item(tree_root) child.set_cell_mode(0, TreeItem.CELL_MODE_STRING) child.set_editable(0, true) child.set_text(0, animation) child.set_cell_mode(1, TreeItem.CELL_MODE_STRING) child.set_editable(1, true) var alias = temp_config.spritesheet_anims.get(animation).alias child.set_text(1, alias if alias else "") child.set_cell_mode(2, TreeItem.CELL_MODE_RANGE) child.set_editable(2, true) child.set_text(2, "Default,Idle") var type = temp_config.spritesheet_anims.get(animation).type child.set_range(2, type) child.add_button(2, close_icon) add_new_switch.pressed.connect(func(): if add_new_name.text.length() > 0: for child in tree_root.get_children(): if child.get_text(0) == add_new_name.text: return var child = tree.create_item(tree_root) child.set_cell_mode(0, TreeItem.CELL_MODE_STRING) child.set_editable(0, true) child.set_text(0, add_new_name.text) child.set_cell_mode(1, TreeItem.CELL_MODE_STRING) child.set_editable(1, true) child.set_text(1, "") child.set_cell_mode(2, TreeItem.CELL_MODE_RANGE) child.set_editable(2, true) child.set_text(2, "Default,Idle") child.add_button(2, close_icon) add_new_name.text = "" keep_updated.call() ) func fuckwith_anims() -> void: var tree:Tree = anims.get_node("Tree") tree.set_column_expand(1, false) tree.set_column_custom_minimum_width(1, 150) tree.set_column_expand(2, false) tree.set_column_custom_minimum_width(2, 150) var tree_root = tree.create_item() var anims_root = tree.create_item(tree_root) anims_root.set_cell_mode(0, TreeItem.CELL_MODE_STRING) anims_root.set_editable(0, false) anims_root.set_text(0, "Animation aliases") anims_root.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) anims_root.set_editable(1, true) anims_root.set_checked(1, temp_config.anim_is_global) anims_root.set_text(1, "Global capture") anims_root.set_tooltip_text(1, "If animation keypresses should be captured\noutside of the application.") anims_root.set_cell_mode(2, TreeItem.CELL_MODE_CHECK) anims_root.set_editable(2, true) anims_root.set_checked(2, temp_config.anim_needs_enable) anims_root.set_text(2, "Requires Enable") anims_root.set_tooltip_text(2, "If animation keypresses should be ignored\nunless (Modifier) Enable is pressed.") var functions_root = tree.create_item(tree_root) functions_root.set_cell_mode(0, TreeItem.CELL_MODE_STRING) functions_root.set_editable(0, false) functions_root.set_text(0, "Functions and modifiers") functions_root.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) functions_root.set_editable(1, true) functions_root.set_checked(1, temp_config.bpm_is_global) functions_root.set_text(1, "Global capture") functions_root.set_tooltip_text(1, "If function keypresses should be captured\noutside of the application.") functions_root.set_cell_mode(2, TreeItem.CELL_MODE_CHECK) functions_root.set_editable(2, true) functions_root.set_checked(2, temp_config.bpm_needs_enable) functions_root.set_text(2, "Requires Enable") functions_root.set_tooltip_text(2, "if function keypresses should be ignored\nunless (Modifier) Enable is pressed.\nModifiers are not affected.") var functions_index_to_key = {} var add_tree_item_for_function = func(key: String, label: String): var anims_child = tree.create_item(functions_root) anims_child.set_cell_mode(0, TreeItem.CELL_MODE_STRING) anims_child.set_editable(0, false) anims_child.set_text(0, label) anims_child.add_button(2, add_icon, 1) functions_index_to_key[anims_child.get_index()] = key for phykey in temp_config[key]: var child = tree.create_item(anims_child) child.set_cell_mode(0, TreeItem.CELL_MODE_CUSTOM) child.set_editable(0, false) child.set_text(0, OS.get_keycode_string(DisplayServer.keyboard_get_keycode_from_physical(phykey))) child.add_button(2, close_icon, 2) add_tree_item_for_function.call("bpm_increase", "Increase Tempo") add_tree_item_for_function.call("bpm_decrease", "Decrease Tempo") add_tree_item_for_function.call("bpm_tsincrease", "Increase Time Signature") add_tree_item_for_function.call("bpm_tsdecrease", "Decrease Time Signature") add_tree_item_for_function.call("bpm_opaincrease", "Increase Character Opacity") add_tree_item_for_function.call("bpm_opadecrease", "Decrease Character Opacity") add_tree_item_for_function.call("bpm_reset", "Sync Tempo") add_tree_item_for_function.call("mod_enable", "(Modifier) Enable") add_tree_item_for_function.call("mod_snap_coarse", "(Modifier) Snap Coarse") add_tree_item_for_function.call("mod_snap_fine", "(Modifier) Snap Fine") tree.item_edited.connect(func(): temp_config.anim_is_global = anims_root.is_checked(1) temp_config.anim_needs_enable = anims_root.is_checked(2) temp_config.bpm_is_global = functions_root.is_checked(1) temp_config.bpm_needs_enable = functions_root.is_checked(2) ) tree.item_activated.connect(func(): var selected = tree.get_selected() var level = 0 var last_parent = selected while last_parent != tree_root: last_parent = last_parent.get_parent() level += 1 if level == 3: var parent = selected.get_parent() if unlock_func: selected.set_text(0, "Double-click to set key") if parent.get_parent() == anims_root: temp_config.anim_binds[parent.get_text(0)][selected.get_index()] = -1 elif parent.get_parent() == functions_root: var key = functions_index_to_key[parent.get_index()] temp_config[key][selected.get_index()] = -1 unlock_func = null else: selected.set_text(0, "Press any key...") unlock_func = func(keycode: Key): selected.set_text(0, OS.get_keycode_string(DisplayServer.keyboard_get_keycode_from_physical(keycode))) if parent.get_parent() == anims_root: temp_config.anim_binds[parent.get_text(0)][selected.get_index()] = keycode elif parent.get_parent() == functions_root: var key = functions_index_to_key[parent.get_index()] temp_config[key][selected.get_index()] = keycode unlock_func = null ) for keybind in temp_config.anim_binds: var anims_child = tree.create_item(anims_root) anims_child.set_cell_mode(0, TreeItem.CELL_MODE_STRING) anims_child.set_editable(0, false) anims_child.set_text(0, keybind) anims_child.add_button(2, add_icon, 1) for key in temp_config.anim_binds.get(keybind): var child = tree.create_item(anims_child) child.set_cell_mode(0, TreeItem.CELL_MODE_CUSTOM) child.set_editable(0, false) child.set_text(0, OS.get_keycode_string(DisplayServer.keyboard_get_keycode_from_physical(key))) child.add_button(2, close_icon, 2) tree.button_clicked.connect(func(item:TreeItem, column:int, id:int, _mbi): if column == 2: var parent = item.get_parent() if id == 1: var child = tree.create_item(item) if parent == anims_root: temp_config.anim_binds[item.get_text(0)].insert(child.get_index(), -1) elif parent == functions_root: var key = functions_index_to_key[item.get_index()] temp_config[key].insert(child.get_index(), -1) child.set_cell_mode(0, TreeItem.CELL_MODE_CUSTOM) child.set_editable(0, false) child.set_text(0, "Double-click to set key") child.add_button(2, close_icon, 2) if id == 2: if parent.get_parent() == anims_root: temp_config.anim_binds[parent.get_text(0)].remove_at(item.get_index()) elif parent.get_parent() == functions_root: var key = functions_index_to_key[parent.get_index()] temp_config[key].remove_at(item.get_index()) item.free() )