Jump to content

Dynamic MCM content


Dooge

Recommended Posts

Posted

I can see it can be made, for example Sexlab animations toggle page is dynamic, but in the source I can not find the part of code that gets called when the state/toogle for a given animation is changed.

    int i
    while i < AnimToggles.Length
        if AnimToggles[i] && AnimToggles[i].Registered
            AddToggleOptionST("Animation_"+i, AnimToggles[i].Name, GetToggle(AnimToggles[i]))
        endIf
        i += 1
    endWhile

Where the "Animation_"+i is the state name, but nowhere can I find the handler.

 

For example for

	AddMenuOptionST("TAModeSelect", "$SSL_View", TAModes[ta])

There is state handler

state TAModeSelect
    event OnMenuOpenST()
        SetMenuDialogStartIndex(ta)
        SetMenuDialogDefaultIndex(0)
        SetMenuDialogOptions(TAModes)
    endEvent
    event OnMenuAcceptST(int i)
        ta = i
        TogglePage = 1
        SetMenuOptionValueST(TAModes[ta])
        ForcePageReset()
    endEvent
    event OnDefaultST()
        ta = 0
        TogglePage = 1
        SetMenuOptionValueST(TAModes[ta])
        ForcePageReset()
    endEvent
endState

So where is the "Animation_"+i handled? How does this work? What sort of magic is this?

Posted

Thanks,

 

I'm getting there. Just didnt know about states it was a bit confusing but I learn. I think I'll have it all working tonight. :D

Posted
Scriptname Menu extends SKI_ConfigBase  

Main Property MainScript Auto
ReferenceAlias Property MasterRef Auto  
Actor Property CrassHairActorRef auto hidden

import PapyrusUtil

string CrossHairName = "Undefined"
string MasterName = "Undefined"

event OnConfigInit()
    OnGameReload()
endEvent

event OnGameReload()
    parent.OnGameReload()
    Pages = new string[5]
    Pages[0] = "Configuration"
    Pages[1] = "Wardrobe"
    Pages[2] = "Statistics"
    Pages[3] = "Debug and Development"
    Pages[4] = "Credits"
endEvent

function SetActorRef()
    ObjectReference ref = Game.GetCurrentCrosshairRef()
    if ref
        if ref.GetVoiceType() != none
            CrassHairActorRef = ref as Actor
        endif   
    endif
endfunction

event OnPageReset(string page)
    SetActorRef()
    if CrassHairActorRef != none
        CrossHairName = CrassHairActorRef.GetLeveledActorBase().GetName()
    else
        CrossHairName = ""
    endif  

    if MasterRef.GetReference() != none
        MasterName = MasterRef.GetActorReference().GetBaseObject().GetName()
    endif      

    ; No page
    if (page == "")
    endif

    ; Configuration
    if (page == "Configuration")
        SetCursorFillMode(TOP_TO_BOTTOM)        
        SetCursorPosition(0)
            addHeaderOption("Configuration")   
    endif

    ; Wardrobe
    if (page == "Wardrobe")
        SetCursorPosition(0)
        addHeaderOption("Wardrobe")           
        string GarmentListName = MainScript.MasterGarmentListName() 
        string GarmentName = "Undefined"
        string NameofMod
        string GarmentID
        int Allowed
        int GarderobeCount = StorageUtil.StringListCount(none, "adcGarmentList")
        int i
        AddTextOption("Garments count", GarderobeCount)
        ;SetCursorPosition(2)
        ;SetCursorFillMode(TOP_TO_BOTTOM)         
        while (i < GarderobeCount )
           
            GarmentName = StorageUtil.StringListGet(none, "adcGarmentList", i)
            NameofMod = StorageUtil.StringListGet(none, "adcGarmentListModname", i)              
            GarmentID = StorageUtil.StringListGet(none, "adcGarmentListGarmentID", i)                        
            Allowed = StorageUtil.IntListGet(none, "adcGarmentListAllowed", i)  
            ;AddToggleOptionST("Garment_"+i+"_"+Game.GetModByName(NameofMod)*16777216+(GarmentID as int), GarmentName, Allowed)
            AddToggleOptionST("Garment_"+i, GarmentName, Allowed)
            i+=1             
        endWhile          
    endif    

    ; Statistics
    if (page == "Statistics")
        SetCursorFillMode(TOP_TO_BOTTOM)        
        SetCursorPosition(0)
            addHeaderOption("Statistics")
            AddTextOptionST("DrainedHealth", "Drained health", MainScript.DrainedHeath)  
    endif

    ;Debug and development
    if (page == "Debug and Development")
        SetCursorFillMode(TOP_TO_BOTTOM)        
        SetCursorPosition(0)
            addHeaderOption("Debug")   
            AddTextOptionST("MasterName", "Master", MasterName)
            AddTextOptionST("ActorInCrosshair","Actor in crosshair", CrossHairName)
            if CrossHairName !=""
                AddToggleOptionST("SetMaster", "Set "+CrossHairName+" as Master", false)
            endif
    endif

    ;Credits
    if (page == "Credits")
        SetCursorFillMode(TOP_TO_BOTTOM)        
        SetCursorPosition(0)        
            addHeaderOption("Credits") 
            AddTextOptionST("Dooge", "Dooge", "wow")  
    endif
endEvent

string[] function MapOptions()
    return StringSplit(GetState(), "_")
endFunction

event OnSelectST()
    string[] Options = MapOptions() 
    MainScript.D("State: "+GetState())     
    int Ind = Options[1] as int
    int Allowed = StorageUtil.IntListGet(none, "adcGarmentListAllowed", Ind)
    ;MainScript.D("1 Clicked item deemed allowed: "+Allowed)     
    if Allowed == 1 
        StorageUtil.IntListSet(none, "adcGarmentListAllowed", Ind, 0) 
        ;MainScript.D("Make "+Ind+" disabled") 
        Allowed = StorageUtil.IntListGet(none, "adcGarmentListAllowed", Ind)
        ;MainScript.D("Value readback: "+Allowed) 
    else
        StorageUtil.IntListSet(none, "adcGarmentListAllowed", Ind, 1) 
        ;MainScript.D("Make "+Ind+" allowed")             
        Allowed = StorageUtil.IntListGet(none, "adcGarmentListAllowed", Ind)
        ;MainScript.D("Value readback: "+Allowed) 
    endif
    ;Allowed = StorageUtil.IntListGet(none, "adcGarmentListAllowed", Ind)

    SetToggleOptionValueST(!Allowed)    
    ForcePageReset()
endEvent

event OnHighlightST()
    string[] Options = MapOptions()

    bool Enabled = StorageUtil.IntListGet(none, "adcGarmentListAllowed", (Options[1] as int)) != 0
    if Enabled
        SetInfoText("Disable this garment")
    else
        SetInfoText("Enable this garment") 
    endif       
endevent

state SetMaster
event OnSelectST()
    ; Master is selected through MCM
    MainScript.D("State: "+GetState())        
    ;MasterRef.ForceRefTo(CrassHairActorRef)
    MainScript.MasterRef.ForceRefTo(CrassHairActorRef)
    ;MasterRef.ForceRefTo(CrassHairActorRef)
    MainScript.SetMaster()
    ForcePageReset()
endEvent

event OnHighlightST()
    SetInfoText("Click to set "+CrossHairName+" as Master")      
endevent
endState

In the MCM, when I click the

 AddToggleOptionST("SetMaster", "Set "+CrossHairName+" as Master", false)

It does assign the master correctly, but the whole MCM freezes, and nothing reacts. Only way is to come out of it is with esc all the way back to the game. When I re-enter, it lists the assigned master as current master as it should. But I cannot figure out what makes it freeze.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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