Scriptname ALN_MCM extends SKI_ConfigBase  

GlobalVariable Property HungrySTR Auto
	Float Property HungrySTR_F Auto
GlobalVariable Property ThirstySTR Auto
	Float Property ThirstySTR_F Auto
GlobalVariable Property TiredSTR Auto
	Float Property TiredSTR_F Auto

GlobalVariable Property EnableStarvation Auto
		Spell Property HealthDecay Auto
		Spell Property Hungry Auto
		Float Property ES_Tog Auto
Actor Property PlayerRef Auto

GlobalVariable Property ThirstyStart Auto
	Float Property ThirstyS Auto
	GlobalVariable Property ThirstyV Auto

GlobalVariable Property HungryStart Auto
	Float Property HungryS Auto
	GlobalVariable Property HungryV Auto

GlobalVariable Property TiredStart Auto
	Float Property TiredS Auto
	GlobalVariable Property TiredV Auto

GlobalVariable Property Timescale Auto
	Float Property TimescaleF Auto

event OnPageReset(string page)
	if page == ""
		LoadCustomContent("sourceFile.dds", 0, 0) 
	else 
		UnloadCustomContent()
		SetTitleText("")
		SetCursorFillMode(TOP_TO_BOTTOM)
	endif 

	if page == "Settings"
		SetCursorPosition(0)
		AddHeaderOption("Hours for Hunger to set in")
		HungryS	= AddSliderOption(HungryStart.GetValueInt() + " Hours",	HungryStart.GetValueInt(),				"{0}")

		AddHeaderOption("Hours for Thirst to set in")
		ThirstyS	= AddSliderOption(ThirstyStart.GetValueInt() + " Hours",		ThirstyStart.GetValueInt(),	"{0}")
	
		AddHeaderOption("Hours for Tired to set in")
		TiredS	= AddSliderOption(TiredStart.GetValueInt() + " Hours",		TiredStart.GetValueInt(),	"{0}")		
		
		AddHeaderOption("<font color='#af1615'>" + HungryV.GetValueInt() + " hours passed since last meal.</font>")

		AddHeaderOption("<font color='#64a684'>" + ThirstyV.GetValueInt() + " hours passed since last drink.</font>")

		AddHeaderOption("<font color='#212590'>" + TiredV.GetValueInt() + " hours passed since waking up.</font>")


		SetCursorPosition(1)
		
		AddHeaderOption("Hunger Visual Effect Strength")
		HungrySTR_F	= AddSliderOption(HungrySTR.GetValue() + " Strength",	HungrySTR.GetValue(),				"{2}")

		AddHeaderOption("Thirsty Visual Effect Strength")
		ThirstySTR_F	= AddSliderOption(ThirstySTR.GetValue() + " Strength",	ThirstySTR.GetValue(),				"{2}")

		AddHeaderOption("Tired Visual Effect Strength")
		TiredSTR_F	= AddSliderOption(TiredSTR.GetValue() + " Strength",	TiredSTR.GetValue(),				"{2}")

		AddHeaderOption("Toggle Starvation On/Off")
			if EnableStarvation.GetValue() == 1
				ES_Tog = AddToggleOption("Starvation ON", EnableStarvation.GetValue())
			else
				ES_Tog = AddToggleOption("Starvation OFF", EnableStarvation.GetValue())
			endif

		AddHeaderOption("Timescale option")
		TimescaleF = AddSliderOption("Click to set", 		Timescale.GetValueInt(),		"{0}")
	endif

endEvent

Event OnOptionSelect(int option)

	if option == ES_TOG
		EnableStarvation.SetValue((!EnableStarvation.GetValue()) as Float)
		SetToggleOptionValue(option, EnableStarvation.GetValue())
		ForcePageReset()
			if PlayerRef.HasSpell(HealthDecay) == true
				PlayerRef.RemoveSpell(HealthDecay)
			elseif PlayerRef.HasSpell(Hungry) == true && PlayerRef.HasSpell(HealthDecay) == false
				PlayerRef.AddSpell(HealthDecay)
			endif
	endif

EndEvent


Event OnOptionSliderOpen(int option)
	if option == HungryS
		SetSliderDialogStartValue(HungryStart.GetValueInt())
		SetSliderDialogDefaultValue(6)
		SetSliderDialogRange(1, 168)
		SetSliderDialogInterval(1)
		ForcePageReset()
	elseif option == ThirstyS
		SetSliderDialogStartValue(ThirstyStart.GetValueInt())
		SetSliderDialogDefaultValue(4)
		SetSliderDialogRange(1, 168)
		SetSliderDialogInterval(1)
		ForcePageReset()
	elseif option == TiredS
		SetSliderDialogStartValue(TiredStart.GetValueInt())
		SetSliderDialogDefaultValue(16)
		SetSliderDialogRange(1, 168)
		SetSliderDialogInterval(1)
		ForcePageReset()
	elseif option == HungrySTR_F
		SetSliderDialogStartValue(HungrySTR.GetValue())
		SetSliderDialogDefaultValue(1.00)
		SetSliderDialogRange(0,1)
		SetSliderDialogInterval(0.01)
		ForcePageReset()
	elseif option == ThirstySTR_F
		SetSliderDialogStartValue(ThirstySTR.GetValue())
		SetSliderDialogDefaultValue(1.00)
		SetSliderDialogRange(0,1)
		SetSliderDialogInterval(0.01)
		ForcePageReset()
	elseif option == TiredSTR_F
		SetSliderDialogStartValue(TiredSTR.GetValueInt())
		SetSliderDialogDefaultValue(1.00)
		SetSliderDialogRange(0, 1)
		SetSliderDialogInterval(0.01)
		ForcePageReset()
	elseif option == TimescaleF
		SetSliderDialogStartValue(Timescale.GetValueInt())
		SetSliderDialogDefaultValue(1)
		SetSliderDialogRange(1, 99999)
		SetSliderDialogInterval(1)
		ForcePageReset()
	endif
endEvent

event OnOptionSliderAccept(int option, float value)
	if option == HungryS
		HungryStart.SetValue(value)
		SetSliderOptionValue(option, HungryStart.GetValue(), "{0}")
		ForcePageReset()
	elseif option == ThirstyS
		ThirstyStart.SetValue(value)
		SetSliderOptionValue(option, ThirstyStart.GetValue(), "{0}")
		ForcePageReset()
	elseif option == TiredS
		TiredStart.SetValue(value)
		SetSliderOptionValue(option, TiredStart.GetValue(), "{0}")
		ForcePageReset()
	elseif option == HungrySTR_F
		HungrySTR.SetValue(value)
		SetSliderOptionValue(option, HungrySTR.GetValue(), "{2}")
		ForcePageReset()
	elseif option == ThirstySTR_F
		ThirstySTR.SetValue(value)
		SetSliderOptionValue(option, ThirstySTR.GetValue(), "{2}")
		ForcePageReset()
	elseif option == TiredSTR_F
		TiredSTR.SetValue(value)
		SetSliderOptionValue(option, TiredSTR.GetValue(), "{2}")
		ForcePageReset()
	elseif option == TimescaleF
		Timescale.SetValue(value)
		SetSliderOptionValue(option, Timescale.GetValue(), "{0}")
		ForcePageReset()
	endif
endEvent

Event OnConfigInit()
	Pages = new string[1]
	Pages[0] = "Settings";
EndEvent

