Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
overdev 2021-10-11 18:36:19 +02:00
commit 38f443800f
17 changed files with 4695 additions and 2 deletions

2
.gitattributes vendored
View File

@ -26,3 +26,5 @@
*.props filter= diff= merge= text eol=crlf *.props filter= diff= merge= text eol=crlf
*.inl filter= diff= merge= text eol=crlf *.inl filter= diff= merge= text eol=crlf
*.flm filter= diff= merge= text eol=crlf *.flm filter= diff= merge= text eol=crlf
*.dlstrings filter= diff= merge= -text
translate_*.txt filter= diff= merge= -text

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,7 @@ fMapWorldYawRange=20.0000
fMapWorldMinPitch=90.0000 fMapWorldMinPitch=90.0000
fMapWorldMaxPitch=90.0000 fMapWorldMaxPitch=90.0000
sMapWorldDefaultWorldSpace=Vyn sMapWorldDefaultWorldSpace=Vyn
fMapTransitionSpeed=0.4
[Actor] [Actor]
; USSEP: Fixes bow engagement distance ; USSEP: Fixes bow engagement distance

Binary file not shown.

BIN
scripts/ski_configmenu.pex Normal file

Binary file not shown.

View File

@ -0,0 +1,158 @@
scriptname SKI_ActiveEffectsWidget extends SKI_WidgetBase
; SCRIPT VERSION ----------------------------------------------------------------------------------
;
; History
;
; 1: - Initial version
;
; 2: - Updated hudModes
;
; 3: - Added MinimumTimeLeft
int function GetVersion()
return 3
endFunction
; PRIVATE VARIABLES -------------------------------------------------------------------------------
; -- Version 1 --
; Make sure defaults match those in ConfigMenuInstance
bool _enabled = false
float _effectSize = 48.0
int _groupEffectCount = 8
string _orientation = "vertical"
; -- Version 3 --
int _minimumTimeLeft = 180
; PROPERTIES --------------------------------------------------------------------------------------
bool Property Enabled
{Whether the active effects are displayed or not}
bool function get()
return _enabled
endFunction
function set(bool a_val)
_enabled = a_val
if (Ready)
UI.InvokeBool(HUD_MENU, WidgetRoot + ".setEnabled", _enabled)
endIf
endFunction
endProperty
float property EffectSize
{Size of each effect icon in pixels at a resolution of 1280x720}
float function get()
return _effectSize
endFunction
function set(float a_val)
_effectSize = a_val
if (Ready)
UI.InvokeFloat(HUD_MENU, WidgetRoot + ".setEffectSize", _effectSize)
endIf
endFunction
endProperty
int property GroupEffectCount
{Maximum number of widgets displayed until a new group (column, or row) is created}
int function get()
return _groupEffectCount
endFunction
function set(int a_val)
_groupEffectCount = a_val
if (Ready)
UI.InvokeInt(HUD_MENU, WidgetRoot + ".setGroupEffectCount", _groupEffectCount)
endIf
endFunction
endProperty
string property Orientation
{The axis in which new effects will be added to after the total number of effects > GroupEffectCount}
string function get()
return _orientation
endFunction
function set(string a_val)
_orientation = a_val
if (Ready)
UI.InvokeString(HUD_MENU, WidgetRoot + ".setOrientation", _orientation)
endIf
endFunction
endProperty
int property MinimumTimeLeft
{The minimum time left for an effect to be displayed}
int function get()
return _minimumTimeLeft
endFunction
function set(int a_val)
_minimumTimeLeft = a_val
if (Ready)
UI.InvokeInt(HUD_MENU, WidgetRoot + ".setMinTimeLeft", _minimumTimeLeft)
endIf
endFunction
endProperty
; INITIALIZATION ----------------------------------------------------------------------------------
; @implements SKI_QuestBase
event OnVersionUpdate(int a_version)
; Version 2
if (a_version >= 2 && CurrentVersion < 2)
Debug.Trace(self + ": Updating to script version 2")
string[] hudModes = new string[6]
hudModes[0] = "All"
hudModes[1] = "StealthMode"
hudModes[2] = "Favor"
hudModes[3] = "Swimming"
hudModes[4] = "HorseMode"
hudModes[5] = "WarHorseMode"
Modes = hudModes
endIf
endEvent
; EVENTS ------------------------------------------------------------------------------------------
; @override SKI_WidgetBase
event OnWidgetReset()
parent.OnWidgetReset()
; Init numbers
float[] numberArgs = new float[4]
numberArgs[0] = _enabled as float
numberArgs[1] = _effectSize
numberArgs[2] = _groupEffectCount as float
numberArgs[3] = _minimumTimeLeft as float
UI.InvokeFloatA(HUD_MENU, WidgetRoot + ".initNumbers", numberArgs)
; Init strings
string[] stringArgs = new string[1]
stringArgs[0] = _orientation
UI.InvokeStringA(HUD_MENU, WidgetRoot + ".initStrings", stringArgs)
; Init commit
UI.Invoke(HUD_MENU, WidgetRoot + ".initCommit")
endEvent
; FUNCTIONS ---------------------------------------------------------------------------------------
; @overrides SKI_WidgetBase
string function GetWidgetSource()
return "skyui/activeeffects.swf"
endFunction
; @overrides SKI_WidgetBase
string function GetWidgetType()
return "SKI_ActiveEffectsWidget"
endFunction

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,377 @@
scriptname SKI_ConfigManager extends SKI_QuestBase hidden
; SCRIPT VERSION ----------------------------------------------------------------------------------
;
; History
;
; 1: - Initial version
;
; 2: - Added lock for API functions
;
; 3: - Removed lock again until I have time to test it properly
;
; 4: - Added redundancy for registration process
int function GetVersion()
return 4
endFunction
; CONSTANTS ---------------------------------------------------------------------------------------
string property JOURNAL_MENU = "Journal Menu" autoReadonly
string property MENU_ROOT = "_root.ConfigPanelFader.configPanel" autoReadonly
; PRIVATE VARIABLES -------------------------------------------------------------------------------
; -- Version 1 --
SKI_ConfigBase[] _modConfigs
string[] _modNames
int _curConfigID = 0
int _configCount = 0
SKI_ConfigBase _activeConfig
; -- Version 2 --
; keep those for now
bool _lockInit = false
bool _locked = false
; -- Version 4 --
bool _cleanupFlag = false
int _addCounter = 0
int _updateCounter = 0
; INITIALIZATION ----------------------------------------------------------------------------------
event OnInit()
_modConfigs = new SKI_ConfigBase[128]
_modNames = new string[128]
OnGameReload()
endEvent
; @implements SKI_QuestBase
event OnGameReload()
RegisterForModEvent("SKICP_modSelected", "OnModSelect")
RegisterForModEvent("SKICP_pageSelected", "OnPageSelect")
RegisterForModEvent("SKICP_optionHighlighted", "OnOptionHighlight")
RegisterForModEvent("SKICP_optionSelected", "OnOptionSelect")
RegisterForModEvent("SKICP_optionDefaulted", "OnOptionDefault")
RegisterForModEvent("SKICP_keymapChanged", "OnKeymapChange")
RegisterForModEvent("SKICP_sliderSelected", "OnSliderSelect")
RegisterForModEvent("SKICP_sliderAccepted", "OnSliderAccept")
RegisterForModEvent("SKICP_menuSelected", "OnMenuSelect")
RegisterForModEvent("SKICP_menuAccepted", "OnMenuAccept")
RegisterForModEvent("SKICP_colorSelected", "OnColorSelect")
RegisterForModEvent("SKICP_colorAccepted", "OnColorAccept")
RegisterForModEvent("SKICP_dialogCanceled", "OnDialogCancel")
RegisterForMenu(JOURNAL_MENU)
; no longer used but better safe than sorry
_lockInit = true
_cleanupFlag = true
CleanUp()
SendModEvent("SKICP_configManagerReady")
_updateCounter = 0
RegisterForSingleUpdate(5)
endEvent
; EVENTS ------------------------------------------------------------------------------------------
event OnUpdate()
if (_cleanupFlag)
CleanUp()
endIf
if (_addCounter > 0)
Debug.Notification("MCM: Registered " + _addCounter + " new menu(s).")
_addCounter = 0
endIf
SendModEvent("SKICP_configManagerReady")
if (_updateCounter < 6)
_updateCounter += 1
RegisterForSingleUpdate(5)
else
RegisterForSingleUpdate(30)
endIf
endEvent
event OnMenuOpen(string a_menuName)
GotoState("BUSY")
_activeConfig = none
UI.InvokeStringA(JOURNAL_MENU, MENU_ROOT + ".setModNames", _modNames);
endEvent
event OnMenuClose(string a_menuName)
GotoState("")
if (_activeConfig)
_activeConfig.CloseConfig()
endIf
_activeConfig = none
endEvent
event OnModSelect(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int configIndex = a_numArg as int
if (configIndex > -1)
; We can clean the buffers of the previous menu now
if (_activeConfig)
_activeConfig.CloseConfig()
endIf
_activeConfig = _modConfigs[configIndex]
_activeConfig.OpenConfig()
endIf
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnPageSelect(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
string page = a_strArg
int index = a_numArg as int
_activeConfig.SetPage(page, index)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnOptionHighlight(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int optionIndex = a_numArg as int
_activeConfig.HighlightOption(optionIndex)
endEvent
event OnOptionSelect(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int optionIndex = a_numArg as int
_activeConfig.SelectOption(optionIndex)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnOptionDefault(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int optionIndex = a_numArg as int
_activeConfig.ResetOption(optionIndex)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnKeymapChange(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int optionIndex = a_numArg as int
int keyCode = UI.GetInt(JOURNAL_MENU, MENU_ROOT + ".selectedKeyCode")
; First test vanilla controls
string conflictControl = Input.GetMappedControl(keyCode)
string conflictName = ""
; Then test mod controls
int i = 0
while (conflictControl == "" && i < _modConfigs.length)
if (_modConfigs[i] != none)
conflictControl = _modConfigs[i].GetCustomControl(keyCode)
if (conflictControl != "")
conflictName = _modNames[i]
endIf
endIf
i += 1
endWhile
_activeConfig.RemapKey(optionIndex, keyCode, conflictControl, conflictName)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnSliderSelect(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int optionIndex = a_numArg as int
_activeConfig.RequestSliderDialogData(optionIndex)
endEvent
event OnSliderAccept(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
float value = a_numArg
_activeConfig.SetSliderValue(value)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnMenuSelect(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int optionIndex = a_numArg as int
_activeConfig.RequestMenuDialogData(optionIndex)
endEvent
event OnMenuAccept(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int value = a_numArg as int
_activeConfig.SetMenuIndex(value)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnColorSelect(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int optionIndex = a_numArg as int
_activeConfig.RequestColorDialogData(optionIndex)
endEvent
event OnColorAccept(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
int color = a_numArg as int
_activeConfig.SetColorValue(color)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
event OnDialogCancel(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
UI.InvokeBool(JOURNAL_MENU, MENU_ROOT + ".unlock", true)
endEvent
; FUNCTIONS ---------------------------------------------------------------------------------------
; @interface
int function RegisterMod(SKI_ConfigBase a_menu, string a_modName)
GotoState("BUSY")
;Log("Registering config menu: " + a_menu + "(" + a_modName + ")")
if (_configCount >= 128)
GotoState("")
return -1
endIf
; Already registered?
int i = 0
while (i < _modConfigs.length)
if (_modConfigs[i] == a_menu)
GotoState("")
return i
endIf
i += 1
endWhile
; New registration
int configID = NextID()
if (configID == -1)
GotoState("")
return -1
endIf
_modConfigs[configID] = a_menu
_modNames[configID] = a_modName
_configCount += 1
; Track mods added in the current cycle so we don't have to display one message per mod
_addCounter += 1
GotoState("")
return configID
endFunction
; @interface
int function UnregisterMod(SKI_ConfigBase a_menu)
GotoState("BUSY")
;Log("Unregistering config menu: " + a_menu)
int i = 0
while (i < _modConfigs.length)
if (_modConfigs[i] == a_menu)
_modConfigs[i] = none
_modNames[i] = ""
_configCount -= 1
GotoState("")
return i
endIf
i += 1
endWhile
GotoState("")
return -1
endFunction
; @interface
function ForceReset()
Log("Forcing config manager reset...")
SendModEvent("SKICP_configManagerReset")
GotoState("BUSY")
int i = 0
while (i < _modConfigs.length)
_modConfigs[i] = none
_modNames[i] = ""
i += 1
endWhile
_curConfigID = 0
_configCount = 0
GotoState("")
SendModEvent("SKICP_configManagerReady")
endFunction
function CleanUp()
GotoState("BUSY")
_cleanupFlag = false
_configCount = 0
int i = 0
while (i < _modConfigs.length)
if (_modConfigs[i] == none || _modConfigs[i].GetFormID() == 0)
_modConfigs[i] = none
_modNames[i] = ""
else
_configCount += 1
endIf
i += 1
endWhile
GotoState("")
endFunction
int function NextID()
int startIdx = _curConfigID
while (_modConfigs[_curConfigID] != none)
_curConfigID += 1
if (_curConfigID >= 128)
_curConfigID = 0
endIf
if (_curConfigID == startIdx)
return -1 ; Just to be sure.
endIf
endWhile
return _curConfigID
endFunction
function Log(string a_msg)
Debug.Trace(self + ": " + a_msg)
endFunction
; STATES ---------------------------------------------------------------------------------------
state BUSY
int function RegisterMod(SKI_ConfigBase a_menu, string a_modName)
return -2
endFunction
int function UnregisterMod(SKI_ConfigBase a_menu)
return -2
endFunction
function ForceReset()
endFunction
function CleanUp()
endFunction
endState

File diff suppressed because it is too large Load Diff

336
source/scripts/ski_main.psc Normal file
View File

@ -0,0 +1,336 @@
scriptname SKI_Main extends SKI_QuestBase
; CONSTANTS ---------------------------------------------------------------------------------------
string property HUD_MENU = "HUD Menu" autoReadOnly
string property INVENTORY_MENU = "InventoryMenu" autoReadonly
string property MAGIC_MENU = "MagicMenu" autoReadonly
string property CONTAINER_MENU = "ContainerMenu" autoReadonly
string property BARTER_MENU = "BarterMenu" autoReadonly
string property GIFT_MENU = "GiftMenu" autoReadonly
string property JOURNAL_MENU = "Journal Menu" autoReadonly
string property MAP_MENU = "MapMenu" autoReadonly
string property FAVORITES_MENU = "FavoritesMenu" autoReadonly
string property CRAFTING_MENU = "Crafting Menu" autoReadonly
int property ERR_SKSE_MISSING = 1 autoReadonly
int property ERR_SKSE_VERSION_RT = 2 autoReadonly
int property ERR_SKSE_VERSION_SCPT = 3 autoReadonly
int property ERR_INI_PAPYRUS = 4 autoReadonly
int property ERR_SWF_INVALID = 5 autoReadonly
int property ERR_SWF_VERSION = 6 autoReadonly
int property ERR_SKSE_BROKEN = 7 autoReadonly
; PRIVATE VARIABLES -------------------------------------------------------------------------------
bool _inventoryMenuCheckEnabled = true
bool _magicMenuCheckEnabled = true
bool _barterMenuCheckEnabled = true
bool _containerMenuCheckEnabled = true
bool _giftMenuCheckEnabled = true
bool _mapMenuCheckEnabled = true
bool _favoritesMenuCheckEnabled = true
bool _craftingMenuCheckEnabled = true
; PROPERTIES --------------------------------------------------------------------------------------
int property MinSKSERelease = 44 autoReadonly
string property MinSKSEVersion = "1.6.16" autoReadonly
int property ReqSWFRelease = 17 autoReadonly
string property ReqSWFVersion = "5.0" autoReadonly
bool property ErrorDetected = false auto
bool property InventoryMenuCheckEnabled
bool function get()
return _inventoryMenuCheckEnabled
endFunction
function set(bool a_val)
_inventoryMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(INVENTORY_MENU)
else
UnregisterForMenu(INVENTORY_MENU)
endIf
endFunction
endProperty
bool property MagicMenuCheckEnabled
bool function get()
return _magicMenuCheckEnabled
endFunction
function set(bool a_val)
_magicMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(MAGIC_MENU)
else
UnregisterForMenu(MAGIC_MENU)
endIf
endFunction
endProperty
bool property BarterMenuCheckEnabled
bool function get()
return _barterMenuCheckEnabled
endFunction
function set(bool a_val)
_barterMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(BARTER_MENU)
else
UnregisterForMenu(BARTER_MENU)
endIf
endFunction
endProperty
bool property ContainerMenuCheckEnabled
bool function get()
return _containerMenuCheckEnabled
endFunction
function set(bool a_val)
_containerMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(CONTAINER_MENU)
else
UnregisterForMenu(CONTAINER_MENU)
endIf
endFunction
endProperty
bool property GiftMenuCheckEnabled
bool function get()
return _giftMenuCheckEnabled
endFunction
function set(bool a_val)
_giftMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(GIFT_MENU)
else
UnregisterForMenu(GIFT_MENU)
endIf
endFunction
endProperty
bool property MapMenuCheckEnabled
bool function get()
return _mapMenuCheckEnabled
endFunction
function set(bool a_val)
_mapMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(MAP_MENU)
else
UnregisterForMenu(MAP_MENU)
endIf
endFunction
endProperty
bool property FavoritesMenuCheckEnabled
bool function get()
return _favoritesMenuCheckEnabled
endFunction
function set(bool a_val)
_favoritesMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(FAVORITES_MENU)
else
UnregisterForMenu(FAVORITES_MENU)
endIf
endFunction
endProperty
bool property CraftingMenuCheckEnabled
bool function get()
return _craftingMenuCheckEnabled
endFunction
function set(bool a_val)
_craftingMenuCheckEnabled = a_val
if (a_val)
RegisterForMenu(CRAFTING_MENU)
else
UnregisterForMenu(CRAFTING_MENU)
endIf
endFunction
endProperty
; INITIALIZATION ----------------------------------------------------------------------------------
event OnInit()
OnGameReload()
endEvent
; @implements SKI_QuestBase
event OnGameReload()
ErrorDetected = false
if (SKSE.GetVersionRelease() == 0)
Error(ERR_SKSE_MISSING, "The Skyrim Script Extender (SKSE) is not running.\nSkyUI will not work correctly!\n\n" \
+ "This message may also appear if a new Skyrim Patch has been released. In this case, wait until SKSE has been updated, then install the new version.")
return
elseIf (GetType() == 0)
Error(ERR_SKSE_BROKEN, "The SKSE scripts have been overwritten or are not properly loaded.\nReinstalling SKSE might fix this.")
return
elseIf (SKSE.GetVersionRelease() < MinSKSERelease)
Error(ERR_SKSE_VERSION_RT, "SKSE is outdated.\nSkyUI will not work correctly!\n" \
+ "Required version: " + MinSKSEVersion + " or newer\n" \
+ "Detected version: " + SKSE.GetVersion() + "." + SKSE.GetVersionMinor() + "." + SKSE.GetVersionBeta())
return
elseIf (SKSE.GetScriptVersionRelease() < MinSKSERelease)
Error(ERR_SKSE_VERSION_SCPT, "SKSE scripts are outdated.\nYou probably forgot to install/update them with the rest of SKSE.\nSkyUI will not work correctly!")
return
endIf
if (Utility.GetINIInt("iMinMemoryPageSize:Papyrus") <= 0 || Utility.GetINIInt("iMaxMemoryPageSize:Papyrus") <= 0 || Utility.GetINIInt("iMaxAllocatedMemoryBytes:Papyrus") <= 0)
Error(ERR_INI_PAPYRUS, "Your Papyrus INI settings are invalid. Please fix this, otherwise SkyUI will stop working at some point.")
return
endIf
; Check menus, when they're opened
if (InventoryMenuCheckEnabled)
RegisterForMenu(INVENTORY_MENU)
endIf
if (MagicMenuCheckEnabled)
RegisterForMenu(MAGIC_MENU)
endIf
if (ContainerMenuCheckEnabled)
RegisterForMenu(CONTAINER_MENU)
endIf
if (BarterMenuCheckEnabled)
RegisterForMenu(BARTER_MENU)
endIf
if (GiftMenuCheckEnabled)
RegisterForMenu(GIFT_MENU)
endIf
if (MapMenuCheckEnabled)
RegisterForMenu(MAP_MENU)
endIf
if (FavoritesMenuCheckEnabled)
RegisterForMenu(FAVORITES_MENU)
endIf
if (CraftingMenuCheckEnabled)
RegisterForMenu(CRAFTING_MENU)
endIf
RegisterForMenu(JOURNAL_MENU)
endEvent
; EVENTS ------------------------------------------------------------------------------------------
event OnMenuOpen(string a_menuName)
if (a_menuName == INVENTORY_MENU)
if (CheckMenuVersion("inventorymenu.swf", a_menuName, "_global.InventoryMenu") && \
CheckItemMenuComponents(a_menuName))
; Only unregister if all checks have been performed (regardless of check result)
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == MAGIC_MENU)
if (CheckMenuVersion("magicmenu.swf", a_menuName, "_global.MagicMenu") && \
CheckItemMenuComponents(a_menuName))
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == CONTAINER_MENU)
if (CheckMenuVersion("containermenu.swf", a_menuName, "_global.ContainerMenu") && \
CheckItemMenuComponents(a_menuName))
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == BARTER_MENU)
if (CheckMenuVersion("bartermenu.swf", a_menuName, "_global.BarterMenu") && \
CheckItemMenuComponents(a_menuName))
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == GIFT_MENU)
if (CheckMenuVersion("giftmenu.swf", a_menuName, "_global.GiftMenu") && \
CheckItemMenuComponents(a_menuName))
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == JOURNAL_MENU)
if (CheckMenuVersion("quest_journal.swf", a_menuName, "_global.Quest_Journal") && \
CheckMenuVersion("skyui/configpanel.swf", a_menuName, "_global.ConfigPanel"))
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == MAP_MENU)
if (CheckMenuVersion("map.swf", a_menuName, "_global.Map.MapMenu"))
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == FAVORITES_MENU)
if (CheckMenuVersion("favoritesmenu.swf", a_menuName, "_global.FavoritesMenu"))
UnregisterForMenu(a_menuName)
endIf
elseIf (a_menuName == CRAFTING_MENU)
if (CheckMenuVersion("craftingmenu.swf", a_menuName, "_global.CraftingMenu"))
UnregisterForMenu(a_menuName)
endIf
endIf
endEvent
; FUNCTIONS ---------------------------------------------------------------------------------------
function Error(int a_errId, string a_msg)
Debug.MessageBox("SKYUI ERROR CODE " + a_errId + "\n\n" + a_msg + "\n\nFor more help, visit the SkyUI download site.")
ErrorDetected = true
endFunction
bool function CheckMenuVersion(string a_swfName, string a_menu, string a_class)
; Returns false if the menu is closed before UI.Get* receive their value
int releaseIdx = UI.GetInt(a_menu, a_class + ".SKYUI_RELEASE_IDX")
string version = UI.GetString(a_menu, a_class + ".SKYUI_VERSION_STRING")
if (!UI.IsMenuOpen(a_menu))
return false
endIf
if (releaseIdx == 0)
Error(ERR_SWF_INVALID, "Incompatible menu file (" + a_swfName + ").\nPlease make sure you installed everything correctly and no other mod has overwritten this file.\n" \
+ "If you were using an older SkyUI version, un-install it and re-install the latest version.")
elseIf (releaseIdx != ReqSWFRelease)
Error(ERR_SWF_VERSION, "Menu file version mismatch for " + a_swfName + ".\n" \
+ "Required version: " + ReqSWFVersion + "\n" \
+ "Detected version: " + version)
endIf
return true
endFunction
bool function CheckItemMenuComponents(string a_menu)
; Returns false if the menu is closed before all checks have finished
return CheckMenuVersion("skyui/itemcard.swf", a_menu, "_global.ItemCard") && \
CheckMenuVersion("skyui/bottombar.swf", a_menu, "_global.BottomBar") && \
CheckMenuVersion("skyui/inventorylists.swf", a_menu, "_global.InventoryLists")
endFunction

View File

@ -0,0 +1,7 @@
scriptname SKI_PlayerLoadGameAlias extends ReferenceAlias
; EVENTS -----------------------------------------------------------------------------------------
event OnPlayerLoadGame()
(GetOwningQuest() as SKI_QuestBase).OnGameReload()
endEvent

View File

@ -0,0 +1,22 @@
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname SKI_QF_ConfigManagerInstance Extends Quest Hidden
;BEGIN ALIAS PROPERTY PlayerRef
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_PlayerRef Auto
;END ALIAS PROPERTY
;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN AUTOCAST TYPE SKI_ConfigManager
Quest __temp = self as Quest
SKI_ConfigManager kmyQuest = __temp as SKI_ConfigManager
;END AUTOCAST
;BEGIN CODE
kmyQuest.ForceReset()
;END CODE
EndFunction
;END FRAGMENT
;END FRAGMENT CODE - Do not edit anything between this and the begin comment

View File

@ -0,0 +1,42 @@
scriptname SKI_QuestBase extends Quest hidden
; -------------------------------------------------------------------------------------------------
; Version Tracking
;
; Quest implements
; GetVersion, to return the static version number
; OnVersionUpdate to handle the updating
; Update process is triggered by calling CheckVersion()
int property CurrentVersion auto hidden
function CheckVersion()
int version = GetVersion()
if (CurrentVersion < version)
OnVersionUpdateBase(version)
OnVersionUpdate(version)
CurrentVersion = version
endIf
endFunction
int function GetVersion()
return 1
endFunction
event OnVersionUpdateBase(int a_version)
endEvent
event OnVersionUpdate(int a_version)
endEvent
; -------------------------------------------------------------------------------------------------
; Reload Events
;
; Helper to add reload event to quest script.
; 1. Create quest
; 2. Add player alias to quest
; 3. Attach SKI_PlayerLoadGameAlias to player alias
event OnGameReload()
endEvent

View File

@ -0,0 +1,145 @@
scriptname SKI_SettingsManager extends SKI_QuestBase
; CONSTANTS ---------------------------------------------------------------------------------------
string property MENU_ROOT = "_global.skyui.util.ConfigManager" autoReadonly
string property INVENTORY_MENU = "InventoryMenu" autoReadonly
string property MAGIC_MENU = "MagicMenu" autoReadonly
string property CONTAINER_MENU = "ContainerMenu" autoReadonly
string property BARTER_MENU = "BarterMenu" autoReadonly
string property GIFT_MENU = "GiftMenu" autoReadonly
string property CRAFTING_MENU = "Crafting Menu" autoReadonly
; PRIVATE VARIABLES -------------------------------------------------------------------------------
int _overrideCount = 0
string[] _overrideKeys
string[] _overrideValues
string _currentMenu
; INITIALIZATION ----------------------------------------------------------------------------------
event OnInit()
_overrideKeys = new string[128]
_overrideValues = new string[128]
int i = 0
while (i<128)
_overrideKeys[i] = ""
_overrideValues[i] = ""
i += 1
endWhile
OnGameReload()
endEvent
; @implements SKI_QuestBase
event OnGameReload()
RegisterForMenu(INVENTORY_MENU)
RegisterForMenu(MAGIC_MENU)
RegisterForMenu(CONTAINER_MENU)
RegisterForMenu(BARTER_MENU)
RegisterForMenu(GIFT_MENU)
RegisterForMenu(CRAFTING_MENU)
RegisterForModEvent("SKICO_setConfigOverride", "OnSetConfigOverride")
endEvent
; EVENTS ------------------------------------------------------------------------------------------
event OnMenuOpen(string a_menuName)
GotoState("LOCKED")
; Check if it's still open
if (UI.IsMenuOpen(a_menuName))
_currentMenu = a_menuName
UI.InvokeStringA(a_menuName, MENU_ROOT + ".setExternalOverrideKeys", _overrideKeys)
UI.InvokeStringA(a_menuName, MENU_ROOT + ".setExternalOverrideValues", _overrideValues)
endIf
GotoState("")
endEvent
event OnSetConfigOverride(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
string overrideKey = a_strArg
string overrideValue = UI.GetString(_currentMenu, MENU_ROOT + ".out_overrides." + overrideKey)
SetOverride(overrideKey, overrideValue)
endEvent
; ----------------------------------------------
state LOCKED
event OnMenuOpen(string a_menuName)
endEvent
endState
; FUNCTIONS ---------------------------------------------------------------------------------------
; @interface
bool function SetOverride(string a_key, string a_value)
if (a_key == "")
return false
endIf
; Existing override?
int index = _overrideKeys.Find(a_key)
if (index != -1)
_overrideValues[index] = a_value
return true
; New override
else
if (_overrideCount >= 128)
return false
endIf
index = NextFreeIndex()
if (index == -1)
return false
endIf
_overrideKeys[index] = a_key
_overrideValues[index] = a_value
_overrideCount += 1
return true
endIf
endFunction
; @interface
bool function ClearOverride(string a_key)
if (a_key == "")
return false
endIf
int index = _overrideKeys.Find(a_key)
if (index == -1)
return false
endIf
_overrideKeys[index] = ""
_overrideValues[index] = ""
_overrideCount -= 1
return true
endFunction
int function NextFreeIndex()
int i = 0
while (i < _overrideKeys.length)
if (_overrideKeys[i] == "")
return i
endIf
i += 1
endWhile
return -1
endFunction

View File

@ -0,0 +1,322 @@
scriptname SKI_WidgetBase extends SKI_QuestBase
; CONSTANTS ---------------------------------------------------------------------------------------
string property HUD_MENU = "HUD Menu" autoReadOnly
; PRIVATE VARIABLES -------------------------------------------------------------------------------
SKI_WidgetManager _widgetManager
bool _initialized = false
bool _ready = false
int _widgetID = -1
string _widgetRoot = ""
string[] _modes
string _hAnchor = "left"
string _vAnchor = "top"
float _x = 0.0
float _y = 0.0
float _alpha = 100.0
; PROPERTIES --------------------------------------------------------------------------------------
bool property RequireExtend = true auto
{Require extending the widget type instead of using it directly.}
; @interface
string property WidgetName = "I-forgot-to-set-the-widget name" auto
{Name of the widget. Used to identify it in the user interface.}
; @interface
int property WidgetID
{Unique ID of the widget. ReadOnly}
int function get()
return _widgetID
endFunction
endProperty
; @interface
bool property Ready
{True once the widget has registered. ReadOnly}
bool function get()
return _initialized
endFunction
endProperty
; @interface
string property WidgetRoot
{Path to the root of the widget from _root of HudMenu. ReadOnly}
string function get()
return _widgetRoot
endFunction
endProperty
string[] property Modes
{HUDModes in which the widget is visible, see readme for available modes}
string[] function get()
return _modes
endFunction
function set(string[] a_val)
_modes = a_val
if (Ready)
UpdateWidgetModes()
endIf
endFunction
endProperty
; @interface
string property HAnchor
{Horizontal anchor point of the widget ["left", "center", "right"]. Default: "left"}
string function get()
return _hAnchor
endFunction
function set(string a_val)
_hAnchor = a_val
if (Ready)
UpdateWidgetHAnchor()
endIf
endFunction
endProperty
; @interface
string property VAnchor
{Vertical anchor point of the widget ["top", "center", "bottom"]. Default: "top"}
string function get()
return _vAnchor
endFunction
function set(string a_val)
_vAnchor = a_val
if (Ready)
UpdateWidgetVAnchor()
endIf
endFunction
endProperty
; @interface
float property X
{Horizontal position of the widget in pixels at a resolution of 1280x720 [0.0, 1280.0]. Default: 0.0}
float function get()
return _x
endFunction
function set(float a_val)
_x = a_val
if (Ready)
UpdateWidgetPositionX()
endIf
endFunction
endProperty
; @interface
float property Y
{Vertical position of the widget in pixels at a resolution of 1280x720 [0.0, 720.0]. Default: 0.0}
float function get()
return _y
endFunction
function set(float a_val)
_y = a_val
if (Ready)
UpdateWidgetPositionY()
endIf
endFunction
endProperty
; @interface
float property Alpha
{Opacity of the widget [0.0, 100.0]. Default: 0.0}
float function get()
return _alpha
endFunction
function set(float a_val)
_alpha = a_val
if (Ready)
UpdateWidgetAlpha()
endIf
endFunction
endProperty
; INITIALIZATION ----------------------------------------------------------------------------------
event OnInit()
OnGameReload()
endEvent
; @implements SKI_QuestBase
event OnGameReload()
_ready = false
RegisterForModEvent("SKIWF_widgetManagerReady", "OnWidgetManagerReady")
if (!IsExtending() && RequireExtend)
Debug.MessageBox("WARNING!\n" + self as string + " must extend a base script type.")
endIf
if (!_initialized)
_initialized = true
; Default Modes if not set via property
if (!_modes)
_modes = new string[6]
_modes[0] = "All"
_modes[1] = "StealthMode"
_modes[2] = "Favor"
_modes[3] = "Swimming"
_modes[4] = "HorseMode"
_modes[5] = "WarHorseMode"
endIf
OnWidgetInit()
Debug.Trace(self + " INITIALIZED")
endIf
CheckVersion()
endEvent
event OnWidgetManagerReady(string a_eventName, string a_strArg, float a_numArg, Form a_sender)
SKI_WidgetManager newManager = a_sender as SKI_WidgetManager
; Already registered?
if (_widgetManager == newManager)
return
endIf
_widgetManager = newManager
_widgetID = _widgetManager.RequestWidgetID(self)
if (_widgetID != -1)
_widgetRoot = "_root.WidgetContainer." + _widgetID + ".widget"
_widgetManager.CreateWidget(_widgetID, GetWidgetSource())
else
Debug.Trace("WidgetWarning: " + self as string + ": could not be loaded, too many widgets. Max is 128")
endIf
endEvent
; EVENTS ------------------------------------------------------------------------------------------
; @interface
event OnWidgetInit()
{Handles any custom widget initialization}
endEvent
; Executed after each game reload by widget manager.
event OnWidgetLoad()
_ready = true
OnWidgetReset()
; Before that the widget was still hidden.
; Now that everything is done, set modes to show it eventually.
UpdateWidgetModes()
endEvent
event OnWidgetReset()
; Reset base properties except modes to prevent widget from being drawn too early.
UpdateWidgetClientInfo()
UpdateWidgetHAnchor()
UpdateWidgetVAnchor()
UpdateWidgetPositionX()
UpdateWidgetPositionY()
UpdateWidgetAlpha()
endEvent
; FUNCTIONS ---------------------------------------------------------------------------------------
; @interface
string function GetWidgetSource()
return ""
endFunction
; @interface
string function GetWidgetType()
; Must be the same as scriptname
return ""
endFunction
; @interface
float[] function GetDimensions()
{Return the dimensions of the widget (width,height).}
float[] dim = new float[2]
dim[0] = 0
dim[1] = 0
return dim
endFunction
; @interface
function TweenToX(float a_x, float a_duration)
{Moves the widget to a new x position over time}
TweenTo(a_x, _y, a_duration)
endFunction
; @interface
function TweenToY(float a_y, float a_duration)
{Moves the widget to a new y position over time}
TweenTo(_x, a_y, a_duration)
endFunction
; @interface
function TweenTo(float a_x, float a_y, float a_duration)
{Moves the widget to a new x, y position over time}
float[] args = new float[3]
args[0] = a_x
args[1] = a_y
args[2] = a_duration
UI.InvokeFloatA(HUD_MENU, _widgetRoot + ".tweenTo", args)
endFunction
; @interface
function FadeTo(float a_alpha, float a_duration)
{Fades the widget to a new alpha over time}
float[] args = new float[2]
args[0] = a_alpha
args[1] = a_duration
UI.InvokeFloatA(HUD_MENU, _widgetRoot + ".fadeTo", args)
endFunction
bool function IsExtending()
string s = self as string
string sn = GetWidgetType() + " "
s = StringUtil.Substring(s, 1, StringUtil.GetLength(sn))
if (s == sn)
return false
endIf
return true
endFunction
function UpdateWidgetClientInfo()
UI.InvokeString(HUD_MENU, _widgetRoot + ".setClientInfo", self as string)
endFunction
function UpdateWidgetAlpha()
UI.InvokeFloat(HUD_MENU, _widgetRoot + ".setAlpha", Alpha)
endFunction
function UpdateWidgetHAnchor()
UI.InvokeString(HUD_MENU, _widgetRoot + ".setHAnchor", HAnchor)
endFunction
function UpdateWidgetVAnchor()
UI.InvokeString(HUD_MENU, _widgetRoot + ".setVAnchor", VAnchor)
endFunction
function UpdateWidgetPositionX()
UI.InvokeFloat(HUD_MENU, _widgetRoot + ".setPositionX", X)
endFunction
function UpdateWidgetPositionY()
UI.InvokeFloat(HUD_MENU, _widgetRoot + ".setPositionY", Y)
endFunction
function UpdateWidgetModes()
UI.InvokeStringA(HUD_MENU, _widgetRoot + ".setModes", Modes)
endFunction

View File

@ -0,0 +1,181 @@
scriptname SKI_WidgetManager extends SKI_QuestBase
; CONSTANTS ---------------------------------------------------------------------------------------
string property HUD_MENU = "HUD Menu" autoReadOnly
; PRIVATE VARIABLES -------------------------------------------------------------------------------
SKI_WidgetBase[] _widgets
string[] _widgetSources
int _curWidgetID = 0
int _widgetCount = 0
; INITIALIZATION ----------------------------------------------------------------------------------
event OnInit()
_widgets = new SKI_WidgetBase[128]
_widgetSources = new string[128]
; Wait until all widgets have registered their callbacks
Utility.Wait(0.5)
OnGameReload()
endEvent
event OnGameReload()
RegisterForModEvent("SKIWF_widgetLoaded", "OnWidgetLoad")
RegisterForModEvent("SKIWF_widgetError", "OnWidgetError")
CleanUp()
; Init now, or delay until hudmenu has been loaded
if (UI.IsMenuOpen(HUD_MENU))
InitWidgetLoader()
else
RegisterForMenu(HUD_MENU)
endIf
endEvent
event OnMenuOpen(string a_menuName)
if (a_menuName == HUD_MENU)
UnregisterForMenu(HUD_MENU)
InitWidgetLoader()
endIf
endEvent
function CleanUp()
_widgetCount = 0
int i = 0
while (i < _widgets.length)
if (_widgets[i] == none || _widgets[i].GetFormID() == 0)
; Widget no longer exists
_widgets[i] = none
_widgetSources[i] = ""
else
_widgetCount += 1
endIf
i += 1
endWhile
endFunction
function InitWidgetLoader()
Debug.Trace("InitWidgetLoader()")
int releaseIdx = UI.GetInt(HUD_MENU, "_global.WidgetLoader.SKYUI_RELEASE_IDX")
; Not injected yet
if (releaseIdx == 0)
; Interface/
string rootPath = ""
string[] args = new string[2]
args[0] = "widgetLoaderContainer"
args[1] = "-1000"
; Create empty container clip
UI.InvokeStringA(HUD_MENU, "_root.createEmptyMovieClip", args)
; Try to load from Interface/exported/hudmenu.gfx
UI.InvokeString(HUD_MENU, "_root.widgetLoaderContainer.loadMovie", "skyui/widgetloader.swf")
Utility.Wait(0.5)
releaseIdx = UI.GetInt(HUD_MENU, "_global.WidgetLoader.SKYUI_RELEASE_IDX")
; If failed, try to load from Interface/hudmenu.swf
if (releaseIdx == 0)
; Interface/exported
rootPath = "exported/"
UI.InvokeString(HUD_MENU, "_root.widgetLoaderContainer.loadMovie", "exported/skyui/widgetloader.swf")
Utility.Wait(0.5)
releaseIdx = UI.GetInt(HUD_MENU, "_global.WidgetLoader.SKYUI_RELEASE_IDX")
endIf
; Injection failed
if (releaseIdx == 0)
Debug.Trace("InitWidgetLoader(): load failed")
return
endIf
UI.InvokeString(HUD_MENU, "_root.widgetLoaderContainer.widgetLoader.setRootPath", rootPath)
endIf
; Load already registered widgets
UI.InvokeStringA(HUD_MENU, "_root.widgetLoaderContainer.widgetLoader.loadWidgets", _widgetSources)
SendModEvent("SKIWF_widgetManagerReady")
endFunction
; EVENTS ------------------------------------------------------------------------------------------
event OnWidgetLoad(string a_eventName, string a_strArg, float a_numArg, form a_sender)
int widgetID = a_strArg as int
SKI_WidgetBase client = _widgets[widgetID]
if (client != none)
client.OnWidgetLoad()
endIf
endEvent
event OnWidgetError(string a_eventName, string a_strArg, float a_numArg, form a_sender)
int widgetID = a_numArg as int
string errorType = a_strArg
Debug.Trace("WidgetError: " + (_widgets[widgetID] as string) + ": " + errorType)
endEvent
; FUNCTIONS ---------------------------------------------------------------------------------------
int function RequestWidgetID(SKI_WidgetBase a_client)
if (_widgetCount >= 128)
return -1
endIf
int widgetID = NextWidgetID()
_widgets[widgetID] = a_client
_widgetCount += 1
return widgetID
endFunction
int function NextWidgetID()
int startIdx = _curWidgetID
while (_widgets[_curWidgetID] != none)
_curWidgetID += 1
if (_curWidgetID >= 128)
_curWidgetID = 0
endIf
if (_curWidgetID == startIdx)
return -1 ; Should never happen because we have widgetCount. Just to be sure.
endIf
endWhile
return _curWidgetID
endFunction
function CreateWidget(int a_widgetID, string a_widgetSource)
_widgetSources[a_widgetID] = a_widgetSource
string[] args = new string[2]
args[0] = a_widgetID as string
args[1] = a_widgetSource
UI.InvokeStringA(HUD_MENU, "_root.widgetLoaderContainer.widgetLoader.loadWidget", args);
endFunction
SKI_WidgetBase[] function GetWidgets()
; Return a copy
SKI_WidgetBase[] widgetsCopy = new SKI_WidgetBase[128]
int i = 0
while (i < _widgets.length)
widgetsCopy[i] = _widgets[i]
i += 1
endWhile
return widgetsCopy
endFunction