Scriptname JR_MCMQuestScript extends ski_configbase  

GlobalVariable Property JR_Enabled Auto
GlobalVariable Property JR_IntervalKickBodyCheck Auto
GlobalVariable Property JR_ChanceBodyCheck Auto
GlobalVariable Property JR_ChanceStolenGoodsFound Auto
GlobalVariable Property JR_BountyResistBodyCheck Auto
GlobalVariable Property JR_BountyStolenGoods Auto
Quest Property JR_BodyCheckQuest Auto
JR_KickBodyCheckPlayerScript Property kbcps Auto

int enabledOID_B
int headerBodyCheckOID
int intervalKickBodyCheckOID_S
int chanceBodyCheckOID_S
int chanceStolenGoodsFoundOID_S
int bountyResistBodyCheckOID_S
int bountyStolenGoodsOID_S

Event OnPageReset(string page)
	SetCursorFillMode(TOP_TO_BOTTOM)

	bool enabled = JR_Enabled.GetValue() as bool
	enabledOID_B = AddToggleOption("Mod Enabled", enabled)

	int flag
	if enabled
		flag = OPTION_FLAG_NONE
	else
		flag = OPTION_FLAG_HIDDEN
	endif

	headerBodyCheckOID = AddHeaderOption("Body Check Settings", flag)
	intervalKickBodyCheckOID_S = AddSliderOption("Kick Quest Interval: ", JR_IntervalKickBodyCheck.GetValueInt(), "{0}sec", flag)
	chanceBodyCheckOID_S = AddSliderOption("Body Check Chance: ", JR_ChanceBodyCheck.GetValueInt(), "{0}%", flag)
	chanceStolenGoodsFoundOID_S = AddSliderOption("Stolen Goods Found Chance: ", JR_ChanceStolenGoodsFound.GetValueInt(), "{0}%", flag)
	bountyResistBodyCheckOID_S = AddSliderOption("Bounty Resist Body Check: ", JR_BountyResistBodyCheck.GetValueInt(), "{0} Gold", flag)
	bountyStolenGoodsOID_S = AddSliderOption("Bounty Stolen Goods: ", JR_BountyStolenGoods.GetValueInt(), "{0} Gold", flag)
endEvent

int Function GetVersion()
	return 1
endFunction

Event OnConfigClose()
	bool enabled = JR_Enabled.GetValue() as bool
	if enabled
		kbcps.Kick()
	else
		JR_BodyCheckQuest.Stop()
	endif
endEvent

Event OnOptionSelect(int option)
	if (option == enabledOID_B)
		bool enabled = !(JR_Enabled.GetValue() as bool)
		SetToggleOptionValue(enabledOID_B, enabled)
		JR_Enabled.SetValue(enabled as float)
		SetEnabled(enabled)

	endif
endEvent

Event OnOptionSliderOpen(int option)
	if (option == intervalKickBodyCheckOID_S)
		SetSliderDialogStartValue(JR_IntervalKickBodyCheck.GetValueInt())
		SetSliderDialogDefaultValue(10)
		SetSliderDialogRange(5, 60)
		SetSliderDialogInterval(1)

	elseif (option == chanceBodyCheckOID_S)
		SetSliderDialogStartValue(JR_ChanceBodyCheck.GetValueInt())
		SetSliderDialogDefaultValue(20)
		SetSliderDialogRange(0, 100)
		SetSliderDialogInterval(1)

	elseif (option == chanceStolenGoodsFoundOID_S)
		SetSliderDialogStartValue(JR_ChanceStolenGoodsFound.GetValueInt())
		SetSliderDialogDefaultValue(50)
		SetSliderDialogRange(0, 100)
		SetSliderDialogInterval(1)

	elseif (option == bountyResistBodyCheckOID_S)
		SetSliderDialogStartValue(JR_BountyResistBodyCheck.GetValueInt())
		SetSliderDialogDefaultValue(500)
		SetSliderDialogRange(0, 1000)
		SetSliderDialogInterval(10)

	elseif (option == bountyStolenGoodsOID_S)
		SetSliderDialogStartValue(JR_BountyStolenGoods.GetValueInt())
		SetSliderDialogDefaultValue(500)
		SetSliderDialogRange(0, 1000)
		SetSliderDialogInterval(10)

	endif
endEvent

Event OnOptionSliderAccept(int option, float value)
	if (option == intervalKickBodyCheckOID_S)
		JR_IntervalKickBodyCheck.SetValue(value)
		SetSliderOptionValue(intervalKickBodyCheckOID_S, value, "{0}sec")

	elseif (option == chanceBodyCheckOID_S)
		JR_ChanceBodyCheck.SetValue(value)
		SetSliderOptionValue(chanceBodyCheckOID_S, value, "{0}%")

	elseif (option == chanceStolenGoodsFoundOID_S)
		JR_ChanceStolenGoodsFound.SetValue(value)
		SetSliderOptionValue(chanceStolenGoodsFoundOID_S, value, "{0}%")

	elseif (option == bountyResistBodyCheckOID_S)
		JR_BountyResistBodyCheck.SetValue(value)
		SetSliderOptionValue(bountyResistBodyCheckOID_S, value, "{0} Gold")

	elseif (option == bountyStolenGoodsOID_S)
		JR_BountyStolenGoods.SetValue(value)
		SetSliderOptionValue(bountyStolenGoodsOID_S, value, "{0} Gold")

	endif
endEvent

Function SetEnabled(bool enabled)
	int flag
	if enabled
		flag = OPTION_FLAG_NONE
	else
		flag = OPTION_FLAG_HIDDEN
	endif

	SetOptionFlags(headerBodyCheckOID, flag)
	SetOptionFlags(intervalKickBodyCheckOID_S, flag)
	SetOptionFlags(chanceBodyCheckOID_S, flag)
	SetOptionFlags(chanceStolenGoodsFoundOID_S, flag)
	SetOptionFlags(bountyResistBodyCheckOID_S, flag)
	SetOptionFlags(bountyStolenGoodsOID_S, flag)
endFunction

