Proper SkyUI 5.2 scripts source code, forwarded from SkyUI VR

This commit is contained in:
Eddoursul 2021-11-30 00:43:45 +01:00
parent 9d417d5915
commit 6c2a191ff7
10 changed files with 167 additions and 45 deletions

Binary file not shown.

Binary file not shown.

BIN
scripts/ski_configmenu.pex Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -10,6 +10,7 @@ int property STATE_RESET = 1 autoReadonly
int property STATE_SLIDER = 2 autoReadonly
int property STATE_MENU = 3 autoReadonly
int property STATE_COLOR = 4 autoReadonly
int property STATE_INPUT = 5 autoReadonly
int property OPTION_TYPE_EMPTY = 0x00 autoReadonly
int property OPTION_TYPE_HEADER = 0x01 autoReadonly
@ -19,6 +20,7 @@ int property OPTION_TYPE_SLIDER = 0x04 autoReadonly
int property OPTION_TYPE_MENU = 0x05 autoReadonly
int property OPTION_TYPE_COLOR = 0x06 autoReadonly
int property OPTION_TYPE_KEYMAP = 0x07 autoReadonly
int property OPTION_TYPE_INPUT = 0x08 autoReadonly
int property OPTION_FLAG_NONE = 0x00 autoReadonly
int property OPTION_FLAG_DISABLED = 0x01 autoReadonly
@ -56,6 +58,7 @@ int[] _colorParams
int _activeOption = -1
string _infoText
string _inputStartText
bool _messageResult = false
bool _waitForMessage = false
@ -741,7 +744,7 @@ bool function ShowMessage(string a_message, bool a_withCancel = true, string a_a
endWhile
UnregisterForModEvent("SKICP_messageDialogClosed")
return _messageResult
endFunction
@ -765,7 +768,7 @@ function OpenConfig()
endFunction
function CloseConfig()
OnConfigClose()
OnConfigClose()
ClearOptionBuffers()
_waitForMessage = false
@ -780,14 +783,14 @@ endFunction
function SetPage(string a_page, int a_index)
_currentPage = a_page
_currentPageNum = 1+a_index
; Set default title, can be overridden in OnPageReset
if (a_page != "")
SetTitleText(a_page)
else
SetTitleText(ModName)
endIf
ClearOptionBuffers()
_state = STATE_RESET
OnPageReset(a_page)
@ -805,18 +808,18 @@ int function AddOption(int a_optionType, string a_text, string a_strValue, float
if (pos == -1)
return -1 ; invalid
endIf
_optionFlagsBuf[pos] = a_optionType + a_flags * 0x100
_textBuf[pos] = a_text
_strValueBuf[pos] = a_strValue
_numValueBuf[pos] = a_numValue
; Just use numerical value of fill mode
_cursorPosition += _cursorFillMode
if (_cursorPosition >= 128)
_cursorPosition = -1
endIf
; byte 1 - position
; byte 2 - page
return pos + _currentPageNum * 0x100
@ -827,7 +830,7 @@ function AddOptionST(string a_stateName, int a_optionType, string a_text, string
Error("State option name " + a_stateName + " is already in use")
return
endIf
int index = AddOption(a_optionType, a_text, a_strValue, a_numValue, a_flags) % 0x100
if (index < 0)
return
@ -868,7 +871,7 @@ function WriteOptionBuffers()
endif
i += 1
endWhile
UI.InvokeIntA(menu, root + ".setOptionFlagsBuffer", _optionFlagsBuf)
UI.InvokeStringA(menu, root + ".setOptionTextBuffer", _textBuf)
UI.InvokeStringA(menu, root + ".setOptionStrValueBuffer", _strValueBuf)
@ -1114,3 +1117,89 @@ function RemapKey(int a_index, int a_keyCode, string a_conflictControl, string a
OnOptionKeyMapChange(option, a_keyCode, a_conflictControl, a_conflictName)
endIf
endFunction
function OnOptionInputOpen(Int a_option)
{Called when a text input option has been selected}
endFunction
function OnInputOpenST()
{Called when a text input state option has been selected}
endFunction
function OnOptionInputAccept(Int a_option, String a_input)
{Called when a new text input has been accepted}
endFunction
function OnInputAcceptST(String a_input)
{Called when a new text input has been accepted for this state option}
endFunction
function SetInputOptionValue(Int a_option, String a_value, Bool a_noUpdate)
Int index = a_option % 256
Int type = _optionFlagsBuf[index] % 256
if type != self.OPTION_TYPE_INPUT
Int pageIdx = a_option / 256 - 1
if pageIdx != -1
self.Error("Option type mismatch. Expected input option, page \"" + Pages[pageIdx] + "\", index " + index as String)
else
self.Error("Option type mismatch. Expected input option, page \"\", index " + index as String)
endIf
return
endIf
self.SetOptionStrValue(index, a_value, a_noUpdate)
endFunction
function SetInputOptionValueST(String a_value, Bool a_noUpdate, String a_stateName)
Int index = self.GetStateOptionIndex(a_stateName)
if index < 0
self.Error("Cannot use SetInputOptionValueST outside a valid option state")
return
endIf
self.SetInputOptionValue(index, a_value, a_noUpdate)
endFunction
function RequestInputDialogData(Int a_index)
_activeOption = a_index + _currentPageNum * 256
_inputStartText = ""
_state = self.STATE_INPUT
String optionState = _stateOptionMap[a_index]
if optionState != ""
String oldState = self.GetState()
self.GotoState(optionState)
self.OnInputOpenST()
self.GotoState(oldState)
else
self.OnOptionInputOpen(_activeOption)
endIf
_state = self.STATE_DEFAULT
ui.InvokeString(self.JOURNAL_MENU, self.MENU_ROOT + ".setInputDialogParams", _inputStartText)
endFunction
Int function AddInputOption(String a_text, String a_value, Int a_flags)
return self.AddOption(self.OPTION_TYPE_INPUT, a_text, a_value, 0 as Float, a_flags)
endFunction
function AddInputOptionST(String a_stateName, String a_text, String a_value, Int a_flags)
self.AddOptionST(a_stateName, self.OPTION_TYPE_INPUT, a_text, a_value, 0 as Float, a_flags)
endFunction
function SetInputDialogStartText(String a_text)
if _state != self.STATE_INPUT
self.Error("Cannot set input dialog params while outside OnOptionInputOpen()")
return
endIf
_inputStartText = a_text
endFunction
function SetInputText(String a_text)
String optionState = _stateOptionMap[_activeOption % 256]
if optionState != ""
String oldState = self.GetState()
self.GotoState(optionState)
self.OnInputAcceptST(a_text)
self.GotoState(oldState)
else
self.OnOptionInputAccept(_activeOption, a_text)
endIf
_activeOption = -1
endFunction

View File

@ -70,6 +70,8 @@ event OnGameReload()
RegisterForModEvent("SKICP_menuAccepted", "OnMenuAccept")
RegisterForModEvent("SKICP_colorSelected", "OnColorSelect")
RegisterForModEvent("SKICP_colorAccepted", "OnColorAccept")
self.RegisterForModEvent("SKICP_inputSelected", "OnInputSelect")
self.RegisterForModEvent("SKICP_inputAccepted", "OnInputAccept")
RegisterForModEvent("SKICP_dialogCanceled", "OnDialogCancel")
RegisterForMenu(JOURNAL_MENU)
@ -357,6 +359,15 @@ function Log(string a_msg)
Debug.Trace(self + ": " + a_msg)
endFunction
function OnInputSelect(String a_eventName, String a_strArg, Float a_numArg, Form a_sender)
Int optionIndex = a_numArg as Int
_activeConfig.RequestInputDialogData(optionIndex)
endFunction
function OnInputAccept(String a_eventName, String a_strArg, Float a_numArg, Form a_sender)
_activeConfig.SetInputText(a_strArg)
ui.InvokeBool(self.JOURNAL_MENU, self.MENU_ROOT + ".unlock", true)
endFunction
; STATES ---------------------------------------------------------------------------------------

View File

@ -25,7 +25,7 @@ scriptname SKI_ConfigMenu extends SKI_ConfigBase
; 8: - Removed unsupported icon themes
int function GetVersion()
return 8
return 9
endFunction
@ -329,7 +329,24 @@ event OnVersionUpdate(int a_version)
SKI_SettingsManagerInstance.SetOverride("Appearance$icons$category$source", _categoryIconThemeValues[_categoryIconThemeIdx])
endIf
if a_version >= 9 && CurrentVersion < 9
debug.Trace(self as String + ": Updating to script version 9")
_categoryIconThemeShortNames = new String[4]
_categoryIconThemeShortNames[0] = "SKYUI V5"
_categoryIconThemeShortNames[1] = "CELTIC"
_categoryIconThemeShortNames[2] = "CURVED"
_categoryIconThemeShortNames[3] = "STRAIGHT"
_categoryIconThemeLongNames = new String[4]
_categoryIconThemeLongNames[0] = "SkyUI V5, by PsychoSteve"
_categoryIconThemeLongNames[1] = "Celtic, by GreatClone"
_categoryIconThemeLongNames[2] = "Curved, by T3T"
_categoryIconThemeLongNames[3] = "Straight, by T3T"
_categoryIconThemeValues = new String[4]
_categoryIconThemeValues[0] = "skyui\\icons_category_psychosteve.swf"
_categoryIconThemeValues[1] = "skyui\\icons_category_celtic.swf"
_categoryIconThemeValues[2] = "skyui\\icons_category_curved.swf"
_categoryIconThemeValues[3] = "skyui\\icons_category_straight.swf"
endIf
endEvent
@ -353,7 +370,7 @@ event OnPageReset(string a_page)
AddHeaderOption("$Item List")
AddTextOptionST("ITEMLIST_FONT_SIZE", "$Font Size", _sizes[_itemlistFontSizeIdx])
AddSliderOptionST("ITEMLIST_QUANTITY_MIN_COUNT", "$Quantity Menu Min. Count", _itemlistQuantityMinCount)
;AddMenuOptionST("ITEMLIST_CATEGORY_ICON_THEME", "$Category Icon Theme", _categoryIconThemeShortNames[_categoryIconThemeIdx])
AddMenuOptionST("ITEMLIST_CATEGORY_ICON_THEME", "$Category Icon Theme", _categoryIconThemeShortNames[_categoryIconThemeIdx])
AddToggleOptionST("ITEMLIST_NO_ICON_COLORS", "$Disable Icon Colors", _itemlistNoIconColors)
AddEmptyOption()
@ -376,7 +393,7 @@ event OnPageReset(string a_page)
AddHeaderOption("$Favorite Groups")
AddMenuOptionST("FAV_GROUP_SELECT", "", "$Group {" + (_favCurGroupIdx+1) + "}")
AddToggleOptionST("FAV_GROUP_UNEQUIP_ARMOR", "$Unequip Armor", SKI_FavoritesManagerInstance.GetGroupFlag(_favCurGroupIdx, ARMOR_FLAG))
AddToggleOptionST("FAV_GROUP_UNEQUIP_HANDS", "$Unequip Hands", SKI_FavoritesManagerInstance.GetGroupFlag(_favCurGroupIdx, HANDS_FLAG))
AddToggleOptionST("FAV_GROUP_UNEQUIP_HANDS", "$Unequip Hands", SKI_FavoritesManagerInstance.GetGroupFlag(_favCurGroupIdx, HANDS_FLAG))
; -------------------------------------------------------
elseIf (a_page == "$Controls")
@ -426,7 +443,7 @@ event OnPageReset(string a_page)
; -------------------------------------------------------
elseIf (a_page == "$Advanced")
SetCursorFillMode(TOP_TO_BOTTOM)
AddHeaderOption("$3D Item")
AddSliderOptionST("XD_ITEM_XOFFSET", "$Horizontal Offset", _3DItemXOffset, "{0}", _3DItemFlags)
AddSliderOptionST("XD_ITEM_YOFFSET", "$Vertical Offset", _3DItemYOffset, "{0}", _3DItemFlags)
@ -461,7 +478,7 @@ event OnPageReset(string a_page)
AddToggleOptionST("CHECK_CONTAINER_MENU", "Container Menu", SKI_MainInstance.ContainerMenuCheckEnabled)
AddToggleOptionST("CHECK_CRAFTING_MENU", "Crafting Menu", SKI_MainInstance.CraftingMenuCheckEnabled)
AddToggleOptionST("CHECK_GIFT_MENU", "Gift Menu", SKI_MainInstance.GiftMenuCheckEnabled)
endIf
endEvent
@ -480,7 +497,7 @@ state FAV_GROUP_ADD_KEY ; KEYMAP
endEvent
event OnDefaultST()
SKI_FavoritesManagerInstance.GroupAddKey = 33
SKI_FavoritesManagerInstance.GroupAddKey = 33
RefreshFavoriteHotkeys()
endEvent
@ -502,7 +519,7 @@ state FAV_GROUP_USE_KEY ; KEYMAP
endEvent
event OnDefaultST()
SKI_FavoritesManagerInstance.GroupUseKey = 19
SKI_FavoritesManagerInstance.GroupUseKey = 19
RefreshFavoriteHotkeys()
endEvent
@ -524,7 +541,7 @@ state FAV_SET_ICON_KEY ; KEYMAP
endEvent
event OnDefaultST()
SKI_FavoritesManagerInstance.SetIconKey = 56
SKI_FavoritesManagerInstance.SetIconKey = 56
RefreshFavoriteHotkeys()
endEvent
@ -546,7 +563,7 @@ state FAV_EQUIP_STATE_KEY ; KEYMAP
endEvent
event OnDefaultST()
SKI_FavoritesManagerInstance.SaveEquipStateKey = 20
SKI_FavoritesManagerInstance.SaveEquipStateKey = 20
RefreshFavoriteHotkeys()
endEvent
@ -568,7 +585,7 @@ state FAV_TOGGLE_FOCUS ; KEYMAP
endEvent
event OnDefaultST()
SKI_FavoritesManagerInstance.ToggleFocusKey = 57
SKI_FavoritesManagerInstance.ToggleFocusKey = 57
RefreshFavoriteHotkeys()
endEvent
@ -724,7 +741,7 @@ state FAV_MENU_HELP_ENABLED ; TOGGLE
event OnHighlightST()
SetInfoText("$SKI_INFO1{$On}")
endEvent
endState
state FAV_GROUP_SELECT ; MENU
@ -754,7 +771,7 @@ state FAV_GROUP_SELECT ; MENU
event OnHighlightST()
SetInfoText("$SKI_INFO6")
endEvent
endState
state FAV_GROUP_UNEQUIP_ARMOR ; TOGGLE
@ -779,7 +796,7 @@ state FAV_GROUP_UNEQUIP_ARMOR ; TOGGLE
event OnHighlightST()
SetInfoText("$SKI_INFO7{$Off}")
endEvent
endState
state FAV_GROUP_UNEQUIP_HANDS ; TOGGLE
@ -804,7 +821,7 @@ state FAV_GROUP_UNEQUIP_HANDS ; TOGGLE
event OnHighlightST()
SetInfoText("$SKI_INFO8{$Off}")
endEvent
endState
; -------------------------------------------------------
@ -830,7 +847,7 @@ state ITEMLIST_FONT_SIZE ; TEXT
event OnHighlightST()
SetInfoText("$SKI_INFO1{" + _sizes[1] + "}")
endEvent
endState
state ITEMLIST_QUANTITY_MIN_COUNT ; SLIDER
@ -857,7 +874,7 @@ state ITEMLIST_QUANTITY_MIN_COUNT ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO2{6}")
endEvent
endState
state ITEMLIST_CATEGORY_ICON_THEME ; MENU
@ -883,7 +900,7 @@ state ITEMLIST_CATEGORY_ICON_THEME ; MENU
event OnHighlightST()
SetInfoText("$SKI_INFO1{" + _categoryIconThemeShortNames[0] + "}")
endEvent
endState
state ITEMLIST_NO_ICON_COLORS ; TOGGLE
@ -903,7 +920,7 @@ state ITEMLIST_NO_ICON_COLORS ; TOGGLE
event OnHighlightST()
SetInfoText("$SKI_INFO1{$Off}")
endEvent
endState
; -------------------------------------------------------
@ -933,14 +950,14 @@ state EFFECT_WIDGET_ENABLED ; TOGGLE
SetOptionFlagsST(_effectWidgetFlags, true, "EFFECT_WIDGET_ICON_SIZE")
SetOptionFlagsST(_effectWidgetFlags, true, "EFFECT_WIDGET_MIN_TIME_LEFT")
SetToggleOptionValueST(true)
endEvent
event OnHighlightST()
SetInfoText("$SKI_INFO1{$On}")
endEvent
endState
state EFFECT_WIDGET_ICON_SIZE ; TEXT
@ -965,7 +982,7 @@ state EFFECT_WIDGET_ICON_SIZE ; TEXT
event OnHighlightST()
SetInfoText("$SKI_INFO1{" + _sizes[1] + "}")
endEvent
endState
state EFFECT_WIDGET_ORIENTATION ; TEXT
@ -976,7 +993,7 @@ state EFFECT_WIDGET_ORIENTATION ; TEXT
else
_effectWidgetOrientationIdx = 0
endIf
SKI_ActiveEffectsWidgetInstance.Orientation = _orientationValues[_effectWidgetOrientationIdx]
SetTextOptionValueST(_orientations[_effectWidgetOrientationIdx])
endEvent
@ -1553,7 +1570,7 @@ state CHECK_INVENTORY_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
state CHECK_MAGIC_MENU ; SLIDER
@ -1572,7 +1589,7 @@ state CHECK_MAGIC_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
state CHECK_BARTER_MENU ; SLIDER
@ -1591,7 +1608,7 @@ state CHECK_BARTER_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
state CHECK_CONTAINER_MENU ; SLIDER
@ -1610,7 +1627,7 @@ state CHECK_CONTAINER_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
state CHECK_GIFT_MENU ; SLIDER
@ -1629,7 +1646,7 @@ state CHECK_GIFT_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
state CHECK_MAP_MENU ; SLIDER
@ -1648,7 +1665,7 @@ state CHECK_MAP_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
state CHECK_FAVORITES_MENU ; SLIDER
@ -1667,7 +1684,7 @@ state CHECK_FAVORITES_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
state CHECK_CRAFTING_MENU ; SLIDER
@ -1686,7 +1703,7 @@ state CHECK_CRAFTING_MENU ; SLIDER
event OnHighlightST()
SetInfoText("$SKI_INFO3{$On}")
endEvent
endState
@ -1935,7 +1952,7 @@ endFunction
; REMOVED DATA -----------------------------------------------------------------------------------
; -- Version 1 -- ; (remove version)
; int _itemlistFontSizeOID_T ; (4)

View File

@ -964,6 +964,11 @@ bool function ProcessItem(Form a_item, int a_itemType, bool a_allowDeferring = t
endIf
return true
; MISC ------------
elseIf a_itemType == 32
PlayerREF.EquipItem(a_item, abSilent = True)
return true
endIf
return true

View File

@ -36,11 +36,11 @@ bool _craftingMenuCheckEnabled = true
; PROPERTIES --------------------------------------------------------------------------------------
int property MinSKSERelease = 44 autoReadonly
string property MinSKSEVersion = "1.6.16" autoReadonly
int property MinSKSERelease = 53 autoReadonly
string property MinSKSEVersion = "2.0.10" autoReadonly
int property ReqSWFRelease = 17 autoReadonly
string property ReqSWFVersion = "5.0" autoReadonly
int property ReqSWFRelease = 2018 autoReadonly
string property ReqSWFVersion = "5.2 SE" autoReadonly
bool property ErrorDetected = false auto