Jump to content

Greying out options in mcm menu


Recommended Posts

I don't seem to have the hang of this, I've tried to follow the example shown in https://github.com/schlangster/skyui/blob/master/dist/Data/Scripts/Source/SKI_ConfigMenu.psc

for SetOptionFlagsST()

 

and I can get a toggle that will grey/ungrey other toggles, but

a) upon entry into the menu the toggle to ungrey the items is off but the toggles can be checked

b) upon exit and reentry, if the options were greyed out they are now ungreyed,

 

I don't know how to get the greying out 'OPTION_FLAG_DISABLED' to stick

 

the relevant part of my mcm menu is here:

 

 

 

State player_slot_choice

Event OnSelectST()

  _toggle_player_slot_choice = !_toggle_player_slot_choice      ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_player_slot_choice)        ;show the new state of the toggle

  If _toggle_player_slot_choice == True           ;if toggle is on

  playerchoice = OPTION_FLAG_NONE

  ShowMessage("$individual_slot_choice_text",False)        ;display warning message

  SetOptionFlagsST(playerchoice,False,"slot31option")       ;ungrey slot option

  SetOptionFlagsST(playerchoice,False,"slot41option")       ;ungrey slot option

  SetOptionFlagsST(playerchoice,False,"slot42option")       ;ungrey slot option

  ElseIf _toggle_player_slot_choice == False          ;if toggle is off

  playerchoice = OPTION_FLAG_DISABLED

  SetToggleOptionValueST(False,False,"slot31option")         ;unset slot option

  ignorehair = False                ;ensure variable is set to false

  SetOptionFlagsST(OPTION_FLAG_DISABLED,False,"slot31option")      ;grey  out slot option

  SetToggleOptionValueST(False,False,"slot41option")         ;unset slot option

  ignorelonghair = False               ;ensure variable is set to false

  SetOptionFlagsST(OPTION_FLAG_DISABLED,False,"slot41option")      ;grey out slot option

  SetToggleOptionValueST(False,False,"slot42option")         ;unset slot option

  ignorecirclet = False               ;ensure variable is set to false

  SetOptionFlagsST(OPTION_FLAG_DISABLED,False,"slot42option")      ;grey out slot option

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_player_slot_choice = False            ;default is off

  playerchoice = OPTION_FLAG_DISABLED

  SetOptionFlagsST(playerchoice,True,"slot31option")      ;default is greyed out

  SetOptionFlagsST(playerchoice,True,"slot41option")      ;default is greyed out

  SetOptionFlagsST(playerchoice,True,"slot42option")      ;default is greyed out

  SetToggleOptionValueST(_toggle_player_slot_choice)        ;set the toggle to the default (off)

EndEvent



Event OnHighlightST()

  SetInfoText("$player_slot_text")          ;show the text replaced for $player_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState

 

 

 

and the whole menu is here:

 

 

Scriptname dz_undress_menu Extends SKI_ConfigBase 
;SCRIPT VERSION

Int Function GetVersion()

Return 2                   ;version number increased to 2

EndFunction
;variables for use by trigger activator scripts

Bool Property disrobes   Auto           ;externally accessible variable for player disrobng status

Bool Property third_person  Auto           ;externally accessible variable for if player changes to third person

Bool Property ignoreCombat  Auto           ;externally accessible variable for if player ignore combat status
;;properties for version 2

Bool Property ignorehair   Auto           ;externally accessible variable for not unequipping the player's hair slot

Bool Property ignorelonghair  Auto           ;externally accessible variable for not unequpping the player's longhair slot

Bool Property ignorecirclet  Auto           ;externally accessible variable for not unequipping the player's circlet slot

Bool Property ignorenpcCombat  Auto           ;externally accessible variable for if NPCs ignore combat status

Bool Property ignorenpchair  Auto           ;externally accessible variable for not unequipping NPCs hair slots

Bool Property ignorenpclonghair Auto           ;externally accessible variable for not unequipping NPCs long hair slots

Bool Property ignorenpccirclet Auto           ;externally accessible variable for not unequipping NPVs circlet slots
Bool _toggle_State1                 ;toggle for allowPlayerSetting

Bool _toggle_State2                 ;toggle for thirdPersonSetting

Bool _toggle_State3                 ;toggle for combatSetting
;;variables for version 2

Bool _toggle_hair                 ;toggle got hair/slot31 setting

Bool _toggle_longhair                ;toggle for longhair/slot41 setting

Bool _toggle_circlet                 ;toggle for circlet/slot42 setting

Bool _toggle_npc_hair

Bool _toggle_npc_longhair

Bool _toggle_npc_circlet

Bool _toggle_npc_combat

Bool _toggle_player_slot_choice

Bool _toggle_npc_slot_choice
Int  playerchoice
Event OnConfigInit()



EndEvent


Event OnVersionUpdate(Int a_version)

; a_version is the new version, CurrentVersion is the old version

If (a_version >= 2 && CurrentVersion < 2)

  Debug.Trace(self + ": Updating script to version 2")

  Debug.Notification("Diziet's Undressing MCM menu updating")

EndIf

EndEvent
 
Event OnPageReset(String page)

{Called when a new page is selected, including the initial empty page}

SetCursorFillMode(TOP_TO_BOTTOM)

;;;;;;;;;;;player options on left side of menu;;;;;;;;;;;;

AddHeaderOption("$Player_Disrobing_Options")

AddEmptyOption()

AddToggleOptionST("allowPlayerSetting","$Player_Undresses", _toggle_State1)
AddToggleOptionST("thirdPersonSetting","$Force_Third_Person", _toggle_State2)
AddToggleOptionST("combatSetting","$Disable_In_Combat_Check", _toggle_State3)
AddEmptyOption()

AddEmptyOption()

AddHeaderOption("$individual_slot_choice_text")

AddToggleOptionST("player_slot_choice","$player_slot_choice_text",_toggle_player_slot_choice)

AddEmptyOption()

AddToggleOptionST("slot31option","$Do_not_unequip_the_hair _slot", _toggle_hair)

AddToggleOptionST("slot41option","$Do_not_unequip_the_longhair_slot", _toggle_longhair)

AddToggleOptionST("slot42option","$Do_not_unequip_the_circlet_slot", _toggle_circlet)
;;;;;;;;;NPC options on right side of menu;;;;;;;;;;;;;;

SetCursorPosition(1)

AddHeaderOption("$NPC_Disrobing_Options")
SetCursorPosition(9)

AddToggleOptionST("npc_combat","$npc_disable_in_combat_check",_toggle_npc_combat)

AddEmptyOption()

AddEmptyOption()

AddHeaderOption("$individual_npc_slot_choice_text")

AddToggleOptionST("npc_slot_choice","$npc_slot_choice_text",_toggle_npc_slot_choice)

AddEmptyOption()

;SetCursorPosition(13)

AddToggleOptionST("npc_slot31option","$Do_not_unequip_the_npc_hair _slot", _toggle_npc_hair)

;SetCursorPosition(15)

AddToggleOptionST("npc_slot41option","$Do_not_unequip_the_npc_longhair_slot", _toggle_npc_longhair)

;SetCursorPosition(17)

AddToggleOptionST("npc_slot42option","$Do_not_unequip_the_npc_circlet_slot", _toggle_npc_circlet)

EndEvent
State allowPlayerSetting                ;toggle settings for allowPlayerSetting

Event OnSelectST()

  _toggle_State1 = !_toggle_State1            ;swap the current state of the toggle

SetToggleOptionValueST(_toggle_State1)            ;show the new state of the toggle

;debug.messagebox("toggle1 happened")

  If (_toggle_State1 == true)              ;if new toggle is on

  Disrobes = true                 ;then player disrobing will happen

  ElseIf (_toggle_State1 == false)            ;if new toggle is off

  Disrobes = false                ;then player disrobing will not happen

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_State1 = true               ;default is on

  Disrobes = true                 ;default is player undressing

  SetToggleOptionValueST(_toggle_State1)           ;set the toggle to the default (on)

EndEvent
Event OnHighlightST()                ;text shown on mouse hover over this toggle

  SetInfoText("$highlight_allow_player_setting_text")

EndEvent

EndState
 
State thirdPersonSetting                ;toggle settings for thirdPersonSetting

Event OnSelectST()

  _toggle_State2 = !_toggle_State2            ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_State2)           ;show the new state of the toggle

  If (_toggle_State2 == true)              ;if new toggle is on

  third_person = true                ;player view becomes third person

  ElseIf (_toggle_State2 == false)            ;if new toggle is off

  third_person = false               ; player view stays as is

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_State2 = true               ;default is on

  third_person = true                ;default is change to third person

  SetToggleOptionValueST(_toggle_State2)           ;set the toggle to the default (on)

EndEvent
Event OnHighlightST()                ;text shown on mouse hover over this toggle

  SetInfoText("$highlight_third_person_setting")

EndEvent

EndState
State combatSetting                 ;toggle settings for combatSetting

Event OnSelectST()

  _toggle_State3 = !_toggle_State3            ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_State3)           ;show the new state of the toggle

  If (_toggle_State3 == true)              ;if new toggle is on

  ignoreCombat = true                ;ignore combat status

  ElseIf (_toggle_State3 == false)            ;if new toggle is off

  ignoreCombat = false               ;do not ignore combat status

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_State3 = true               ;default is on

  ignoreCombat = true                ;default is ignore combat status

  SetToggleOptionValueST(_toggle_State3)           ;set the toggle to the default (on)

EndEvent



Event OnHighlightST()                ;text shown on mouse hover over this toggle

  SetInfoText("$highlight_combat_info_text")          ;show the text replaced for $highlight_combat_info_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State slot31option                 ;toggle settings for combatSetting

Event OnSelectST()

  _toggle_hair = !_toggle_hair             ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_hair)           ;show the new state of the toggle

  If _toggle_hair == True               ;if new toggle is on

  ignorehair = True                ;do not unequip hair slot

  ElseIf _toggle_hair == False             ;if new toggle is off

  ignorehair = False                ;unequip hair slot

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_hair = False               ;default is off

  ignorehair = False                ;default is unequip hair slot

  SetToggleOptionValueST(_toggle_hair)           ;set the toggle to the default (off)

EndEvent



Event OnHighlightST()

  SetInfoText("$highlight_hair_slot_text")          ;show the text replaced for $highlight_hair_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State slot41option

Event OnSelectST()

  _toggle_longhair = !_toggle_longhair           ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_longhair)          ;show the new state of the toggle

  If _toggle_longhair == True              ;if new toggle is on

  ignorelonghair = True               ;do not unequip thelong hair slot

  ElseIf _toggle_longhair == False            ;if new toggle is off

  ignorelonghair = False               ;unequip the long hair slot

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_longhair = False              ;default is off

  ignorelonghair = False               ;default is unequip the long hair slot

  SetToggleOptionValueST(_toggle_longhair)          ;set the toggle to the default (off)

EndEvent



Event OnHighlightST()

  SetInfoText("$highlight_long_hair_slot_text")         ;show the text replaced for $highlight_long_hair_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State slot42option

Event OnSelectST()

  _toggle_circlet = !_toggle_circlet            ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_circlet)           ;show the new state of the toggle

  If _toggle_circlet == True              ;if new toggle is on

  ignorecirclet = True               ;do not unequip the circlet slot

  ElseIf _toggle_circlet == False             ;if new toggle is off

  ignorecirclet = False               ;unequip the circlet slot

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_circlet = False               ;default is off

  ignorecirclet = False               ;default is unequip the circlet slot

  SetToggleOptionValueST(_toggle_circlet)           ;set the toggle to the default (off)

EndEvent



Event OnHighlightST()

  SetInfoText("$highlight_circlet_slot_text")          ;show the text replaced for $highlight_circlet_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State npc_combat                  ;toggle settings for npc_combat

Event OnSelectST()

  _toggle_npc_combat = !_toggle_npc_combat          ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_npc_combat)          ;show the new state of the toggle

  If (_toggle_npc_combat == true)             ;if new toggle is on

  ignorenpcCombat = true               ;ignore npc combat status

  ElseIf (_toggle_npc_combat == false)           ;if new toggle is off

  ignorenpcCombat = false               ;do not ignore npc combat status

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_npc_combat = true              ;default is on

  ignorenpcCombat = true               ;default is ignore npc combat status

  SetToggleOptionValueST(_toggle_npc_combat)          ;set the toggle to the default (on)

EndEvent



Event OnHighlightST()                ;text shown on mouse hover over this toggle

  SetInfoText("$highlight_npc_combat_info_text")         ;show the text replaced for $highlight_npc_combat_info_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State npc_slot31option                ;toggle settings for combatSetting

Event OnSelectST()

  _toggle_npc_hair = !_toggle_npc_hair           ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_npc_hair)          ;show the new state of the toggle

  If _toggle_npc_hair == True              ;if new toggle is on

  ignorenpchair = True               ;do not unequip NPCs hair slots

  ElseIf _toggle_npc_hair == False            ;if new toggle is off

  ignorenpchair = False               ;unequip NPCs hair slots

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_hair = False               ;default is off

  ignorenpchair = False               ;default is unequip NPCs hair slots

  SetToggleOptionValueST(_toggle_hair)           ;set the toggle to the default (off)

  SetOptionFlagsST(playerchoice)

EndEvent



Event OnHighlightST()

  SetInfoText("$highlight_hair_slot_text")          ;show the text replaced for $highlight_hair_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State npc_slot41option

Event OnSelectST()

  _toggle_npc_longhair = !_toggle_npc_longhair         ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_npc_longhair)         ;show the new state of the toggle

  If _toggle_npc_longhair == True             ;if new toggle is on

  ignorenpclonghair = True              ;do not unequip the NPCs long hair slot

  ElseIf _toggle_npc_longhair == False           ;if new toggle is off

  ignorenpclonghair = False              ;unequip NPCs long hair slots

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_npc_longhair = False             ;default is off

  ignorenpclonghair = False              ;default is unequip the NPCs long hair slots

  SetToggleOptionValueST(_toggle_npc_longhair)         ;set the toggle to the default (off)

EndEvent



Event OnHighlightST()

  SetInfoText("$highlight_long_hair_slot_text")         ;show the text replaced for $highlight_long_hair_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State npc_slot42option

Event OnSelectST()

  _toggle_npc_circlet = !_toggle_npc_circlet          ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_npc_circlet)          ;show the new state of the toggle

  If _toggle_npc_circlet == True             ;if new toggle is on

  ignorenpccirclet = True               ;do not unequip NPCs circlet slots

  ElseIf _toggle_npc_circlet == False            ;if new toggle is off

  ignorenpccirclet = False              ;unequip NPCs circlet slots

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_npc_circlet = False              ;default is off

  ignorenpccirclet = False              ;default is unequip NPCs circlet slots

  SetToggleOptionValueST(_toggle_npc_circlet)          ;set the toggle to the default (off)

EndEvent



Event OnHighlightST()

  SetInfoText("$highlight_circlet_slot_text")          ;show the text replaced for $highlight_circlet_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState
State player_slot_choice

Event OnSelectST()

  _toggle_player_slot_choice = !_toggle_player_slot_choice      ;swap the current state of the toggle

  SetToggleOptionValueST(_toggle_player_slot_choice)        ;show the new state of the toggle

  If _toggle_player_slot_choice == True           ;if toggle is on

  playerchoice = OPTION_FLAG_NONE

  ShowMessage("$individual_slot_choice_text",False)        ;display warning message

  SetOptionFlagsST(playerchoice,False,"slot31option")       ;ungrey slot option

  SetOptionFlagsST(playerchoice,False,"slot41option")       ;ungrey slot option

  SetOptionFlagsST(playerchoice,False,"slot42option")       ;ungrey slot option

  ElseIf _toggle_player_slot_choice == False          ;if toggle is off

  playerchoice = OPTION_FLAG_DISABLED

  SetToggleOptionValueST(False,False,"slot31option")         ;unset slot option

  ignorehair = False                ;ensure variable is set to false

  SetOptionFlagsST(OPTION_FLAG_DISABLED,False,"slot31option")      ;grey  out slot option

  SetToggleOptionValueST(False,False,"slot41option")         ;unset slot option

  ignorelonghair = False               ;ensure variable is set to false

  SetOptionFlagsST(OPTION_FLAG_DISABLED,False,"slot41option")      ;grey out slot option

  SetToggleOptionValueST(False,False,"slot42option")         ;unset slot option

  ignorecirclet = False               ;ensure variable is set to false

  SetOptionFlagsST(OPTION_FLAG_DISABLED,False,"slot42option")      ;grey out slot option

  EndIf

EndEvent



Event OnDefaultST()                 ;what is the default setting for this toggle

  _toggle_player_slot_choice = False            ;default is off

  playerchoice = OPTION_FLAG_DISABLED

  SetOptionFlagsST(playerchoice,True,"slot31option")      ;default is greyed out

  SetOptionFlagsST(playerchoice,True,"slot41option")      ;default is greyed out

  SetOptionFlagsST(playerchoice,True,"slot42option")      ;default is greyed out

  SetToggleOptionValueST(_toggle_player_slot_choice)        ;set the toggle to the default (off)

EndEvent



Event OnHighlightST()

  SetInfoText("$player_slot_text")          ;show the text replaced for $player_slot_text from the data/interface/translations/*LANG.txt

EndEvent

EndState

 

 

 

The documentation is a little sparse, I would have expected that the OnPageReset event would have a reference to the option flags but here:

https://github.com/schlangster/skyui/wiki/MCM-API-Reference#SetOptionFlags

the context is apparently only the state definition; and indeed the example above only seems to set the option flag in the state definition.

 

help would be appreciated

 

 

diziet

Link to comment
Share on other sites

Working examples seem to be best in cases like these...

Taken from my Inventory Management System mod for SSE:

 

A snippet from the OnPageReset event

    If  page == Pages[4]
        SetCursorFillMode(TOP_TO_BOTTOM)
        AddHeaderOption("$Key Ring")
        AddTextOptionST("ToggleState"+7,"$Use Key Ring",ComponentBehave[cbc7])
        If ComponentChoice[7] == 0
            AddTextOptionST("AutoSortState"+7,"$Auto-Store", AutoStoreBehave[asc7],OPTION_FLAG_DISABLED)
            AddToggleOptionST("Weightless"+7,"$Weightless", WeightlesActive[7],OPTION_FLAG_DISABLED)
            AddToggleOptionST("MerchExcl"+7,"$MerchExcl", MerchExclActive[7],OPTION_FLAG_DISABLED)
        Else
            AddTextOptionST("AutoSortState"+7,"$Auto-Store", AutoStoreBehave[asc7],OPTION_FLAG_NONE)
            AddToggleOptionST("Weightless"+7,"$Weightless", WeightlesActive[7],OPTION_FLAG_NONE)
            AddToggleOptionST("MerchExcl"+7,"$MerchExcl", MerchExclActive[7],OPTION_FLAG_NONE)
        EndIf

The above demonstrates how a set of options will either be disabled or enabled depending upon the status of a particular variable when the page resets.

 

 

 

 

 

The state block for the option that controls the status of the sub-options.

;=============================
;====   KEYRING STATES    ====
;=============================
State ToggleState7
    Event OnSelectST()
        Int index = 7
        If (cbc7 < ComponentBehave.length - 1)
            cbc7 += 1
        Else
            cbc7 = 0
        EndIf
        ComponentChoice[index] = cbc7
        SetTextOptionValueST(ComponentBehave[cbc7])
        If ComponentChoice[index] != 0
            SetOptionFlagsST(OPTION_FLAG_NONE, false, "AutoSortState"+index)
            SetOptionFlagsST(OPTION_FLAG_NONE, false, "Weightless"+index)
            SetOptionFlagsST(OPTION_FLAG_NONE, false, "MerchExcl"+index)
        Else
            AutoStoreChoice[index] = 0
            SetTextOptionValueST(AutoStoreBehave[0], false, "AutoSortState"+index)
            SetOptionFlagsST(OPTION_FLAG_DISABLED, false, "AutoSortState"+index)

            WeightlesActive[index] = true
            SetToggleOptionValueST(WeightlesActive[index],false,"Weightless"+index)
            SetOptionFlagsST(OPTION_FLAG_DISABLED, false, "Weightless"+index)

            MerchExclActive[index] = true
            SetToggleOptionValueST(MerchExclActive[index],false,"MerchExcl"+index)
            SetOptionFlagsST(OPTION_FLAG_DISABLED, false, "MerchExcl"+index)

        EndIf
    EndEvent
    Event OnDefaultST()
        Int index = 7
        ComponentChoice[index] = 0
        SetTextOptionValueST(ComponentBehave[0])

        AutoStoreChoice[index] = 0
        SetTextOptionValueST(AutoStoreBehave[0], false, "AutoSortState"+index)
        SetOptionFlagsST(OPTION_FLAG_DISABLED, false, "AutoSortState"+index)

        WeightlesActive[index] = true
        SetToggleOptionValueST(WeightlesActive[index],false,"Weightless"+index)
        SetOptionFlagsST(OPTION_FLAG_DISABLED, false, "Weightless"+index)

        MerchExclActive[index] = true
        SetToggleOptionValueST(MerchExclActive[index],false,"MerchExcl"+index)
        SetOptionFlagsST(OPTION_FLAG_DISABLED, false, "MerchExcl"+index)

    EndEvent
    Event OnHighlightST()
        SetInfoText("$KeyRingToggleInfo")
    EndEvent
EndState

This demonstrates that when a non-zero selection is made the other options become available. Otherwise the options are disabled and also given the default values (which in my mod's case ensures that nothing unwanted gets used accidentally)

 

 

I hope this helps....

Link to comment
Share on other sites

Related to this mcm menu so I'll post here as I've already posted the menu itself; I've been using such lines as:

If (_toggle_State3 == true)              ;if new toggle is on
  ignoreCombat = true                ;ignore combat status

and then referencing the 'ignoreCombat' variable from another script, works fine. But looking at it, I can't see why I couldn't just reference the _toogle_State3 directly (in this example). The two directly track each other, would this be good practice? Or is there a reason to do it as I have been?

 

 

diziet

Link to comment
Share on other sites

It is okay to reference the MCM script to obtain variable values, but it is still smart to keep separate the variables for the MCM and the variables for the actual mod.

 

So let the MCM toggle the option with its variable while you use that status to set the variable specific to the rest of the mod.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...