impr: Add button to reset ClickGUI positions

Closes #2104

Signed-off-by: lv <~@l1v.in>
This commit is contained in:
lv 2021-03-30 01:53:28 -04:00
parent 8ba37378ed
commit de48fe9a29
No known key found for this signature in database
GPG Key ID: AF236A45B0255DA8
2 changed files with 22 additions and 4 deletions

View File

@ -31,14 +31,18 @@ open class Component(
protected val dockingHSetting = setting("Docking H", HAlign.LEFT)
protected val dockingVSetting = setting("Docking V", VAlign.TOP)
var width by setting("Width", widthIn, 0.0f..69420.911f, 0.1f, { false }, { _, it -> it.coerceIn(minWidth, max(scaledDisplayWidth, minWidth)) })
var height by setting("Height", heightIn, 0.0f..69420.911f, 0.1f, { false }, { _, it -> it.coerceIn(minHeight, max(scaledDisplayHeight, minHeight)) })
private var widthSetting = setting("Width", widthIn, 0.0f..69420.911f, 0.1f, { false }, { _, it -> it.coerceIn(minWidth, max(scaledDisplayWidth, minWidth)) })
private var heightSetting = setting("Height", heightIn, 0.0f..69420.911f, 0.1f, { false }, { _, it -> it.coerceIn(minHeight, max(scaledDisplayHeight, minHeight)) })
protected var relativePosX by setting("Pos X", posXIn, -69420.911f..69420.911f, 0.1f, { false },
private var relativePosXSetting = setting("Pos X", posXIn, -69420.911f..69420.911f, 0.1f, { false },
{ _, it -> if (this is WindowComponent && KamiMod.ready) absToRelativeX(relativeToAbsX(it).coerceIn(1.0f, max(scaledDisplayWidth - width - 1.0f, 1.0f))) else it })
protected var relativePosY by setting("Pos Y", posYIn, -69420.911f..69420.911f, 0.1f, { false },
private var relativePosYSetting = setting("Pos Y", posYIn, -69420.911f..69420.911f, 0.1f, { false },
{ _, it -> if (this is WindowComponent && KamiMod.ready) absToRelativeY(relativeToAbsY(it).coerceIn(1.0f, max(scaledDisplayHeight - height - 1.0f, 1.0f))) else it })
var width by widthSetting
var height by heightSetting
var relativePosX by relativePosXSetting
var relativePosY by relativePosYSetting
var dockingH by dockingHSetting
var dockingV by dockingVSetting
@ -131,4 +135,11 @@ open class Component(
HUD_GUI("hud_gui")
}
fun resetPosition() {
widthSetting.resetValue()
heightSetting.resetValue()
relativePosXSetting.resetValue()
relativePosYSetting.resetValue()
}
}

View File

@ -24,6 +24,7 @@ internal object ClickGUI : Module(
val fadeInTime by setting("Fade In Time", 0.25f, 0.0f..1.0f, 0.05f)
val fadeOutTime by setting("Fade Out Time", 0.1f, 0.0f..1.0f, 0.05f)
val showModifiedInBold by setting("Show Modified In Bold", false, description = "Display modified settings in a bold font")
private val resetComponents = setting("Reset Positions", false)
val sortBy = setting("Sort By", SortByOptions.ALPHABETICALLY)
private var prevScale = scaleSetting.value / 100.0f
@ -62,6 +63,12 @@ internal object ClickGUI : Module(
}
sortBy.listeners.add { KamiClickGui.reorderModules() }
resetComponents.listeners.add {
KamiClickGui.windowList.forEach {
it.resetPosition()
}
}
}
private fun getRoundedScale(): Float {