Scriptname zbfBondageConfig extends SKI_ConfigBase

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

Int iOptNpcUpdate
Int iOptPcUpdate
Int iOptMoveSpeed
Int iOptDisableEffects

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")
	iOptNpcUpdate = AddSliderOption("Npc update interval", zbfSettingNpcUpdateInterval.GetValue(), "{1}")
	iOptPcUpdate = AddSliderOption("Player update interval", zbfSettingUpdateInterval.GetValue(), "{1}")
	AddEmptyOption()

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

Event OnOptionSliderOpen(Int aiOption)
	; Either of update interval sliders
	If aiOption == iOptNpcUpdate || aiOption == iOptPcUpdate
		SetSliderDialogDefaultValue(0)
		SetSliderDialogRange(0, 5.0)
		SetSliderDialogInterval(0.1)
	EndIf
	
	If aiOption == iOptNpcUpdate
		SetSliderDialogStartValue(zbfSettingNpcUpdateInterval.GetValue())
	EndIf
	If aiOption == iOptPcUpdate
		SetSliderDialogStartValue(zbfSettingUpdateInterval.GetValue())
	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 aiValue)
	If aiOption == iOptNpcUpdate
		zbfSettingNpcUpdateInterval.SetValue(aiValue)
		SetSliderOptionValue(aiOption, zbfSettingNpcUpdateInterval.GetValue(), "{1}")
	EndIf
	
	If aiOption == iOptPcUpdate
		zbfSettingUpdateInterval.SetValue(aiValue)
		SetSliderOptionValue(aiOption, zbfSettingUpdateInterval.GetValue(), "{1}")
	EndIf
	
	If aiOption == iOptMoveSpeed
		zbfSettingSpeedMult.SetValue(aiValue)
		SetSliderOptionValue(aiOption, zbfSettingSpeedMult.GetValue(), "{1}")
	EndIf
EndEvent

Event OnOptionSelect(Int aiOption)
	If aiOption == iOptDisableEffects
		If zbfSettingDisableEffects.GetValue() > 0
			zbfSettingDisableEffects.SetValue(0)
		Else
			zbfSettingDisableEffects.SetValue(1.0)
		EndIf
		SetToggleOptionValue(aiOption, zbfSettingDisableEffects.GetValue() > 0)
	EndIf
EndEvent

Event OnOptionDefault(Int aiOption)
	If aiOption == iOptDisableEffects
		zbfSettingDisableEffects.SetValue(0)
		SetToggleOptionValue(aiOption, zbfSettingDisableEffects.GetValue() > 0)
	EndIf

	If aiOption == iOptNpcUpdate
		zbfSettingNpcUpdateInterval.SetValue(0)
		SetSliderOptionValue(aiOption, zbfSettingNpcUpdateInterval.GetValue(), "{1}")
	EndIf
	
	If aiOption == iOptPcUpdate
		zbfSettingUpdateInterval.SetValue(0)
		SetSliderOptionValue(aiOption, zbfSettingUpdateInterval.GetValue(), "{1}")
	EndIf
	
	If aiOption == iOptMoveSpeed
		zbfSettingSpeedMult.SetValue(70.0)
		SetSliderOptionValue(aiOption, zbfSettingSpeedMult.GetValue(), "{1}")
	EndIf
EndEvent

Event OnOptionHighlight(Int aiOption)
	If aiOption == iOptPcUpdate
		SetInfoText("Effect update interval for pcs.\nSet to 0 to disable periodic updates. Default is 0.")
	ElseIf aiOption == iOptNpcUpdate
		SetInfoText("Effect update interval for npcs.\nSet to 0 to disable periodic updates. Default is 0.")
	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
