Scriptname zbfBondageConfig extends SKI_ConfigBase

GlobalVariable Property zbfSettingSpeedMult Auto
GlobalVariable Property zbfSettingUpdateInterval Auto
GlobalVariable Property zbfSettingDisableEffects Auto

Int iOptUpdate
Int iOptMoveSpeed
Int iOptDisableEffects

Float Property fSpeedMult
	Function set(Float afValue)
		zbfSettingSpeedMult.SetValue(afValue)
		SetSliderOptionValue(iOptMoveSpeed, afValue, "{1}")
	EndFunction
	Float Function get()
		Return zbfSettingSpeedMult.GetValue()
	EndFunction
EndProperty

Float Property fUpdateInterval
	Function set(Float afValue)
		zbfSettingUpdateInterval.SetValue(afValue)
		SetSliderOptionValue(iOptUpdate, afValue, "{1}")
	EndFunction
	Float Function get()
		Return zbfSettingUpdateInterval.GetValue()
	EndFunction
EndProperty

Bool Property bDisableEffects
	Function set(Bool abValue)
		If abValue
			zbfSettingDisableEffects.SetValue(1)
		Else
			zbfSettingDisableEffects.SetValue(0)
		EndIf
		SetToggleOptionValue(iOptDisableEffects, (zbfSettingDisableEffects.GetValue() > 0))
	EndFunction
	Bool Function get()
		Return (zbfSettingDisableEffects.GetValue() > 0)
	EndFunction
EndProperty

Event OnPageReset(String asPage)
	SetCursorFillMode(TOP_TO_BOTTOM)
	SetCursorPosition(0) ; Can be removed because it starts at 0 anyway

	; Left side
	AddHeaderOption("General")
	iOptDisableEffects = AddToggleOption("Disable all", zbfSettingDisableEffects.GetValue() > 0)
	AddEmptyOption()
	
	SetCursorPosition(1)

	; Right side
	AddHeaderOption("Update interval")
	iOptUpdate = AddSliderOption("Update interval", fUpdateInterval, "{1}")
	AddEmptyOption()

	AddHeaderOption("Movement speed")
	iOptMoveSpeed = AddSliderOption("Shackled movement speed", fSpeedMult, "{1}")
EndEvent

Event OnOptionSliderOpen(Int aiOption)
	; Either of update interval sliders
	If aiOption == iOptUpdate
		SetSliderDialogDefaultValue(0)
		SetSliderDialogRange(0.1, 5.0)
		SetSliderDialogInterval(0.1)
		SetSliderDialogStartValue(fUpdateInterval)
	EndIf

	; Speed mult
	If aiOption == iOptMoveSpeed
		SetSliderDialogDefaultValue(70.0)
		SetSliderDialogRange(10.0, 100.0)
		SetSliderDialogInterval(1)
		SetSliderDialogStartValue(zbfSettingSpeedMult.GetValue())
	EndIf
EndEvent

Event OnOptionSliderAccept(Int aiOption, Float afValue)
	If aiOption == iOptUpdate
		fUpdateInterval = afValue
	EndIf
	
	If aiOption == iOptMoveSpeed
		fSpeedMult = afValue
	EndIf
EndEvent

Event OnOptionSelect(Int aiOption)
	If aiOption == iOptDisableEffects
		bDisableEffects = !bDisableEffects
	EndIf
EndEvent

Event OnOptionDefault(Int aiOption)
	If aiOption == iOptDisableEffects
		bDisableEffects = False
	EndIf

	If aiOption == iOptUpdate
		fUpdateInterval = 0.5
	EndIf
	
	If aiOption == iOptMoveSpeed
		fSpeedMult = 70.0
	EndIf
EndEvent

Event OnOptionHighlight(Int aiOption)
	If aiOption == iOptUpdate
		SetInfoText("Effect update interval when items automatically refresh themselves.\nDefault is 0.5")
	ElseIf aiOption == iOptMoveSpeed
		SetInfoText("Forced movement speed when shackled. Default is 70.")
	ElseIf aiOption == iOptDisableEffects
		SetInfoText("Disables all animations, movement speed, control changes, etc.")
	EndIf
EndEvent
