Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scriptname SKEMenuInstallerScript extends Quest
- Group SKEVanillaWorkshopMenuCache
- FormList Property WorkshopMenuMain auto const
- {Add to the WorkshopMenuMain - Main Menu}
- FormList Property WorkshopMenu01Build auto const
- {Add to the WorkshopMenu01Build - Structures}
- FormList Property WorkshopMenu01Furniture auto const
- {Add to the WorkshopMenu01Furniture - Furniture}
- FormList Property WorkshopMenu01Decor auto const
- {Add to the WorkshopMenu01Decor - Decorations}
- FormList Property WorkshopMenu01Power auto const
- {Add to the WorkshopMenu01Power - Power}
- FormList Property WorkshopMenu01Resource02Defense auto const
- {Add to the WorkshopMenu01Resource02Defense - Defense}
- FormList Property WorkshopMenu01Resource auto const
- {Add to the WorkshopMenu01Resource - Resource Production}
- FormList Property WorkshopMenu01Vendors auto const
- {Add to the WorkshopMenu01Vendors - Vendors}
- FormList Property WorkshopMenu01Cages auto const
- {Add to the WorkshopMenu01Cages - Cages}
- FormList Property WorkshopMenu01Raider auto const
- {Add to the WorkshopMenu01Raider - Raider}
- EndGroup
- Group SKECustomWorkshopMenuCache
- FormList Property SKE_CustomMainMenu_Form auto const
- {Add the SKE_CustomMainMenu_Form for Single Menu}
- FormList Property SKE_Structures_MultiForm auto const
- {Add the SKE_Structures_MultiForm}
- FormList Property SKE_Furniture_MultiForm auto const
- {Add the SKE_Furniture_MultiForm}
- FormList Property SKE_Decorations_MultiForm auto const
- {Add the SKE_Decorations_MultiForm}
- FormList Property SKE_Decorations_OCDecorator_Form auto const
- {Add the SKE_Decorations_OCDecorator_Form}
- FormList Property SKE_Electricity_MultiForm auto const
- {Add the SKE_Electricity_MultiForm}
- FormList Property SKE_Defense_MultiForm auto const
- {Add the SKE_Defense_MultiForm}
- FormList Property SKE_Resources_MultiForm auto const
- {Add the SKE_Resources_MultiForm}
- FormList Property SKE_Vendors_MultiForm auto const
- {Add the SKE_Vendors_MultiForm}
- FormList Property SKE_Workbenches_MultiForm auto const
- {Add the SKE_Workbenches_MultiForm}
- FormList Property SKE_Cages_MultiForm auto const
- {Add the SKE_Cages_MultiForm}
- FormList Property SKE_Landscaping_MultiForm auto const
- {Add the SKE_Landscaping_MultiForm}
- FormList Property SKE_SettlerManagement_Form auto const
- {Add the SKE_SettlerManagement_Form}
- FormList Property SKE_MainHomemakerMenu_Form auto const
- {Add the SKE_MainHomemakerMenu_Form}
- FormList Property SKE_DDProductions_Form auto const
- {Add the SKE_DDProductions_Form}
- FormList Property SKE_CustomScript_Form auto const
- {Add the SKE_CustomScript_Form}
- FormList Property SKE_ExtraSettlementItems_Form auto const
- {Add the SKE_ExtraSettlementItems_Form}
- EndGroup
- ;TODO - remove if you dont want to use a while loop
- bool uninstallCheckRunning = false
- bool usingMultiMenu = false
- ;====================================================================================================================
- ; Quest and Register Events
- ;====================================================================================================================
- Event OnQuestInit()
- install_menu()
- RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerLoadGame")
- ;TODO - remove if you dont want to use a while loop
- checkForUninstall()
- RegisterForRemoteEvent(Game.GetPlayer(), "OnDifficultyChanged")
- EndEvent
- ;====================================================================================================================
- ; OnPlayerLoadGame and OnDifficultyChanged
- ;====================================================================================================================
- Event Actor.OnPlayerLoadGame(Actor actorref)
- install_menu()
- ;TODO - remove if you dont want to use a while loop
- checkForUninstall()
- EndEvent
- Event Actor.OnDifficultyChanged(Actor actorref, int aOldDifficulty, int aNewDifficulty)
- install_menu()
- ;TODO - remove if you dont want to use a while loop
- checkForUninstall()
- EndEvent
- ;====================================================================================================================
- ; Install and Uninstall deciders
- ;====================================================================================================================
- Function install_menu()
- if (!usingMultiMenu)
- single_install()
- else
- multimenu_install()
- endif
- EndFunction
- Function uninstall_menu()
- if (!usingMultiMenu)
- single_uninstall()
- else
- multimenu_uninstall()
- endif
- EndFunction
- ;====================================================================================================================
- ; Single Menu Install and Restore
- ;====================================================================================================================
- Function single_install()
- ; Change to false for Single Menu Install
- usingMultiMenu = false
- WorkshopMenuMain.addForm(SKE_CustomMainMenu_Form)
- Debug.notification("Settlement Keywords Single Menu Layout installed!")
- EndFunction
- Function single_uninstall()
- WorkshopMenuMain.RemoveAddedForm(SKE_CustomMainMenu_Form)
- Debug.notification("Settlement Keywords Single Menu Layout uninstalled!")
- EndFunction
- ;====================================================================================================================
- ; Multi Menu Install and Restore
- ;====================================================================================================================
- ;This function adds your new menus or categories to the vanilla formlists
- Function multimenu_install()
- ; Change to True for Multi Menu Install
- usingMultiMenu = true
- WorkshopMenu01Build.addForm(SKE_Structures_MultiForm)
- WorkshopMenu01Furniture.addForm(SKE_Furniture_MultiForm)
- WorkshopMenu01Decor.addForm(SKE_Decorations_MultiForm)
- WorkshopMenu01Decor.addForm(SKE_Decorations_OCDecorator_Form)
- WorkshopMenu01Power.addForm(SKE_Electricity_MultiForm)
- WorkshopMenu01Resource02Defense.addForm(SKE_Defense_MultiForm)
- WorkshopMenu01Resource.addForm(SKE_Resources_MultiForm)
- WorkshopMenu01Vendors.addForm(SKE_Vendors_MultiForm)
- WorkshopMenuMain.addForm(SKE_Workbenches_MultiForm)
- WorkshopMenu01Cages.addForm(SKE_Cages_MultiForm)
- WorkshopMenu01Decor.addForm(SKE_Landscaping_MultiForm)
- WorkshopMenuMain.addForm(SKE_SettlerManagement_Form)
- WorkshopMenuMain.addForm(SKE_MainHomemakerMenu_Form)
- WorkshopMenuMain.addForm(SKE_DDProductions_Form)
- WorkshopMenuMain.addForm(SKE_CustomScript_Form)
- WorkshopMenuMain.addForm(SKE_ExtraSettlementItems_Form)
- Debug.notification("Settlement Keywords Multi Menu Layout installed!")
- EndFunction
- Function multimenu_uninstall()
- WorkshopMenu01Build.RemoveAddedForm(SKE_Structures_MultiForm)
- WorkshopMenu01Furniture.RemoveAddedForm(SKE_Furniture_MultiForm)
- WorkshopMenu01Decor.RemoveAddedForm(SKE_Decorations_MultiForm)
- WorkshopMenu01Decor.RemoveAddedForm(SKE_Decorations_OCDecorator_Form)
- WorkshopMenu01Power.RemoveAddedForm(SKE_Electricity_MultiForm)
- WorkshopMenu01Resource02Defense.RemoveAddedForm(SKE_Defense_MultiForm)
- WorkshopMenu01Resource.RemoveAddedForm(SKE_Resources_MultiForm)
- WorkshopMenu01Vendors.RemoveAddedForm(SKE_Vendors_MultiForm)
- WorkshopMenuMain.RemoveAddedForm(SKE_Workbenches_MultiForm)
- WorkshopMenu01Cages.RemoveAddedForm(SKE_Cages_MultiForm)
- WorkshopMenu01Decor.RemoveAddedForm(SKE_Landscaping_MultiForm)
- WorkshopMenuMain.RemoveAddedForm(SKE_SettlerManagement_Form)
- WorkshopMenuMain.RemoveAddedForm(SKE_MainHomemakerMenu_Form)
- WorkshopMenuMain.RemoveAddedForm(SKE_DDProductions_Form)
- WorkshopMenuMain.RemoveAddedForm(SKE_CustomScript_Form)
- WorkshopMenuMain.RemoveAddedForm(SKE_ExtraSettlementItems_Form)
- Debug.notification("Settlement Keywords Multi Menu Layout uninstalled!")
- EndFunction
- ;====================================================================================================================
- ; Check For Uninstall
- ;====================================================================================================================
- ;Checks if your plugin is still active. If not removes every none value from the vanilla formlists.
- Function checkForUninstall()
- ;we only want the loop once
- if (!uninstallCheckRunning)
- uninstallCheckRunning = true
- ;TODO - replace YourMod.esp with the name of your esp
- while (Game.IsPluginInstalled("SettlementKeywords.esm"))
- Utility.wait(60) ;waits 60 seconds until the condition is checked again
- endwhile
- ;The plugin is no longer active. Now we have to remove every none value from the edited formlists.
- ;TODO - Do this with every vanilla menu you edited
- removeNoneValues(WorkshopMenuMain)
- removeNoneValues(WorkshopMenu01Build)
- removeNoneValues(WorkshopMenu01Furniture)
- removeNoneValues(WorkshopMenu01Decor)
- removeNoneValues(WorkshopMenu01Power)
- removeNoneValues(WorkshopMenu01Resource02Defense)
- removeNoneValues(WorkshopMenu01Resource)
- removeNoneValues(WorkshopMenu01Vendors)
- removeNoneValues(WorkshopMenu01Cages)
- ;...
- uninstallCheckRunning = false
- endif
- EndFunction
- ;====================================================================================================================
- ; Remove invalid Forms
- ;====================================================================================================================
- Function removeNoneValues(Formlist akCurList)
- Int iSize = akCurList.GetSize()
- ;Check the size of akCurList to see if it has anything in it
- If iSize > 0
- ;Copy the Form List
- Int i
- Form[] tmp = New Form[iSize]
- While i < iSize
- tmp[i] = akCurList.GetAt(i)
- i += 1
- EndWhile
- ;Revert the Form List
- akCurList.Revert()
- ;Restore the Form List
- i = 0
- While i < iSize
- If tmp[i] != None
- akCurList.AddForm(tmp[i])
- EndIf
- i += 1
- EndWhile
- tmp.Clear()
- EndIf
- EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement