FunkPanion/scripts/Config.gd
2024-11-23 14:36:52 -06:00

190 lines
6.5 KiB
GDScript

class_name Config
extends Node
enum SpritesheetAnimType {
DEFAULT,
IDLE
}
static var SpritesheetAnchorIndices = [
"TOP_LEFT",
"TOP",
"TOP_RIGHT",
"LEFT",
"CENTER",
"RIGHT",
"BOTTOM_LEFT",
"BOTTOM",
"BOTTOM_RIGHT"
]
static var SpritesheetAnchor = {
TOP_LEFT = [BoxContainer.AlignmentMode.ALIGNMENT_BEGIN, BoxContainer.AlignmentMode.ALIGNMENT_BEGIN],
TOP = [BoxContainer.AlignmentMode.ALIGNMENT_CENTER, BoxContainer.AlignmentMode.ALIGNMENT_BEGIN],
TOP_RIGHT = [BoxContainer.AlignmentMode.ALIGNMENT_END, BoxContainer.AlignmentMode.ALIGNMENT_BEGIN],
LEFT = [BoxContainer.AlignmentMode.ALIGNMENT_BEGIN, BoxContainer.AlignmentMode.ALIGNMENT_CENTER],
CENTER = [BoxContainer.AlignmentMode.ALIGNMENT_CENTER, BoxContainer.AlignmentMode.ALIGNMENT_CENTER],
RIGHT = [BoxContainer.AlignmentMode.ALIGNMENT_END, BoxContainer.AlignmentMode.ALIGNMENT_CENTER],
BOTTOM_LEFT = [BoxContainer.AlignmentMode.ALIGNMENT_BEGIN, BoxContainer.AlignmentMode.ALIGNMENT_END],
BOTTOM = [BoxContainer.AlignmentMode.ALIGNMENT_CENTER, BoxContainer.AlignmentMode.ALIGNMENT_END],
BOTTOM_RIGHT = [BoxContainer.AlignmentMode.ALIGNMENT_END, BoxContainer.AlignmentMode.ALIGNMENT_END]
}
# OSD and UI
var osd_dwell_time = 2000
var osd_fade_time = 1000
var osd_opacity = 1.0
var menu_opacity = 1.0
var background_opacity = 0.1
# BPM snap
var coarse_bpm_snap = 10.0
var fine_bpm_snap = 0.5
# Tempo
var tempo_default = 120.0
var tempo_numerator = 4
# Sparrow spritesheet data
var spritesheet_data = "res://assets/BOYFRIEND.xml"
var spritesheet_image = "res://assets/BOYFRIEND.png"
var spritesheet_anims = {
"BF idle dance" = {
alias = null,
type = SpritesheetAnimType.IDLE
},
"BF NOTE LEFT" = {
alias = "left",
type = SpritesheetAnimType.DEFAULT
},
"BF NOTE DOWN" = {
alias = "down",
type = SpritesheetAnimType.DEFAULT
},
"BF NOTE UP" = {
alias = "up",
type = SpritesheetAnimType.DEFAULT
},
"BF NOTE RIGHT" = {
alias = "right",
type = SpritesheetAnimType.DEFAULT
},
"BF HEY!!" = {
alias = "special",
type = SpritesheetAnimType.DEFAULT
}
}
var spritesheet_anchor = SpritesheetAnchor.BOTTOM
var sprite_scale = 1.0
var sprite_flip = false
var spritesheet_default_opacity = 1.0
# Keybinds
# Bind change keys
var bpm_is_global = true
var bpm_needs_enable = true
var bpm_increase:Array[Key] = [ KEY_R ]
var bpm_decrease:Array[Key] = [ KEY_F ]
var bpm_tsincrease:Array[Key] = [ KEY_T ]
var bpm_tsdecrease:Array[Key] = [ KEY_G ]
var bpm_opaincrease:Array[Key] = [ KEY_BRACELEFT ]
var bpm_opadecrease:Array[Key] = [ KEY_BRACERIGHT ]
var bpm_reset:Array[Key] = [ KEY_V ]
# Bind modifiers
var mod_enable:Array[Key] = [ KEY_SHIFT ]
var mod_snap_fine:Array[Key] = [ KEY_TAB ]
var mod_snap_coarse:Array[Key] = [ KEY_CTRL ]
# Bind animations
var anim_is_global = true
var anim_needs_enable = false
var anim_binds = {
left = [ KEY_A, KEY_LEFT ],
down = [ KEY_S, KEY_DOWN ],
up = [ KEY_W, KEY_UP ],
right = [ KEY_D, KEY_RIGHT ],
special = [ KEY_Q ]
}
static func new_clear() -> Config:
var config:Config = Config.new()
config.spritesheet_anims = {}
config.bpm_increase = []
config.bpm_decrease = []
config.bpm_tsincrease = []
config.bpm_tsdecrease = []
config.bpm_opaincrease = []
config.bpm_opadecrease = []
config.bpm_reset = []
config.mod_enable = []
config.mod_snap_fine = []
config.mod_snap_coarse = []
config.anim_binds = {}
return config
func clone_config(config) -> void:
self.osd_dwell_time = config.osd_dwell_time
self.osd_fade_time = config.osd_fade_time
self.osd_opacity = config.osd_opacity
self.menu_opacity = config.menu_opacity
self.background_opacity = config.background_opacity
self.coarse_bpm_snap = config.coarse_bpm_snap
self.fine_bpm_snap = config.fine_bpm_snap
self.tempo_default = config.tempo_default
self.tempo_numerator = config.tempo_numerator
self.spritesheet_data = config.spritesheet_data
self.spritesheet_image = config.spritesheet_image
self.spritesheet_anims = config.spritesheet_anims.duplicate(true)
self.spritesheet_anchor = config.spritesheet_anchor
self.sprite_scale = config.sprite_scale
self.sprite_flip = config.sprite_flip
self.spritesheet_default_opacity = config.spritesheet_default_opacity
self.bpm_is_global = config.bpm_is_global
self.bpm_needs_enable = config.bpm_needs_enable
self.bpm_increase = config.bpm_increase.duplicate(true)
self.bpm_decrease = config.bpm_decrease.duplicate(true)
self.bpm_tsincrease = config.bpm_tsincrease.duplicate(true)
self.bpm_tsdecrease = config.bpm_tsdecrease.duplicate(true)
self.bpm_opaincrease = config.bpm_opaincrease.duplicate(true)
self.bpm_opadecrease = config.bpm_opadecrease.duplicate(true)
self.bpm_reset = config.bpm_reset.duplicate(true)
self.mod_enable = config.mod_enable.duplicate(true)
self.mod_snap_fine = config.mod_snap_fine.duplicate(true)
self.mod_snap_coarse = config.mod_snap_coarse.duplicate(true)
self.anim_is_global = config.anim_is_global
self.anim_needs_enable = config.anim_needs_enable
self.anim_binds = config.anim_binds.duplicate(true)
func format_config() -> Dictionary:
var dict = {}
dict.osd_dwell_time = self.osd_dwell_time
dict.osd_fade_time = self.osd_fade_time
dict.osd_opacity = self.osd_opacity
dict.menu_opacity = self.menu_opacity
dict.background_opacity = self.background_opacity
dict.coarse_bpm_snap = self.coarse_bpm_snap
dict.fine_bpm_snap = self.fine_bpm_snap
dict.tempo_default = self.tempo_default
dict.tempo_numerator = self.tempo_numerator
dict.spritesheet_data = self.spritesheet_data
dict.spritesheet_image = self.spritesheet_image
dict.spritesheet_anims = self.spritesheet_anims.duplicate(true)
dict.sprite_scale = self.sprite_scale
dict.sprite_flip = self.sprite_flip
dict.spritesheet_anchor = self.spritesheet_anchor
dict.spritesheet_default_opacity = self.spritesheet_default_opacity
dict.bpm_is_global = self.bpm_is_global
dict.bpm_needs_enable = self.bpm_needs_enable
dict.bpm_increase = self.bpm_increase.duplicate(true)
dict.bpm_decrease = self.bpm_decrease.duplicate(true)
dict.bpm_tsincrease = self.bpm_tsincrease.duplicate(true)
dict.bpm_tsdecrease = self.bpm_tsdecrease.duplicate(true)
dict.bpm_opaincrease = self.bpm_opaincrease.duplicate(true)
dict.bpm_opadecrease = self.bpm_opadecrease.duplicate(true)
dict.bpm_reset = self.bpm_reset.duplicate(true)
dict.mod_enable = self.mod_enable.duplicate(true)
dict.mod_snap_fine = self.mod_snap_fine.duplicate(true)
dict.mod_snap_coarse = self.mod_snap_coarse.duplicate(true)
dict.anim_is_global = self.anim_is_global
dict.anim_needs_enable = self.anim_needs_enable
dict.anim_binds = self.anim_binds.duplicate(true)
return dict