Add shop name & desc update, better error handling
This commit is contained in:
parent
2e0a283ce5
commit
cd9d11edfd
@ -22,20 +22,31 @@ event OnPageReset(string page)
|
||||
if modStarted
|
||||
AddTextOptionST("API_KEY", "Reveal API key", "")
|
||||
endif
|
||||
SetCursorPosition(7)
|
||||
|
||||
SetCursorPosition(5)
|
||||
if modStarted
|
||||
AddToggleOptionST("START_MOD", "Mod Started", modStarted, OPTION_FLAG_DISABLED)
|
||||
else
|
||||
AddToggleOptionST("START_MOD", "Start Mod", modStarted)
|
||||
endif
|
||||
|
||||
AddHeaderOption("Shop Actions")
|
||||
SetCursorPosition(10)
|
||||
AddTextOptionST("SAVE_REFS", "Save current shop state", "")
|
||||
AddTextOptionST("LOAD_REFS", "Load saved shop state", "")
|
||||
AddTextOptionST("LIST_MERCH", "Show shop merchandise", "")
|
||||
AddTextOptionST("LOAD_MERCH", "Load shop merchandise", "")
|
||||
|
||||
SetCursorPosition(8)
|
||||
if modStarted
|
||||
AddHeaderOption("Shop Config")
|
||||
SetCursorPosition(10)
|
||||
AddTextOptionST("SHOP_NAME_LABEL", "Shop name: ", "", OPTION_FLAG_DISABLED)
|
||||
AddInputOptionST("SHOP_NAME", "", BR.ShopName)
|
||||
AddTextOptionST("SHOP_DESC_LABEL", "Shop description: ", "", OPTION_FLAG_DISABLED)
|
||||
AddInputOptionST("SHOP_DESC", "", BR.ShopDescription)
|
||||
AddTextOptionST("LOAD_SHOP_CONFIG", "Load shop config from server", "")
|
||||
|
||||
SetCursorPosition(18)
|
||||
AddHeaderOption("Shop Actions")
|
||||
SetCursorPosition(20)
|
||||
AddTextOptionST("SAVE_REFS", "Save current shop state", "")
|
||||
AddTextOptionST("LOAD_REFS", "Load saved shop state", "")
|
||||
endif
|
||||
endEvent
|
||||
|
||||
state SERVER_URL_VALUE
|
||||
@ -119,22 +130,114 @@ state LOAD_REFS
|
||||
endEvent
|
||||
endState
|
||||
|
||||
state LIST_MERCH
|
||||
event OnSelectST()
|
||||
BR.ListMerchandise()
|
||||
state SHOP_NAME
|
||||
event OnInputOpenST()
|
||||
SetInputDialogStartText(BR.ShopName)
|
||||
endEvent
|
||||
|
||||
event OnInputAcceptST(string textInput)
|
||||
Debug.Trace("BRMCMConfigMenu BRQuest properties: ShopId: " + BR.ShopId + " ShopName: " + BR.ShopName + " ShopDescription: " + BR.ShopDescription)
|
||||
SetInputOptionValueST("Updating...")
|
||||
BR.UpdateShop(BR.ShopId, textInput, BR.ShopDescription)
|
||||
|
||||
int attempts = 0
|
||||
while !BR.UpdateShopComplete && attempts < 100
|
||||
attempts += 1
|
||||
Utility.WaitMenuMode(0.1)
|
||||
endWhile
|
||||
|
||||
if attempts >= 100
|
||||
Debug.Trace("BRMCMConfigMenu BR.UpdateShop failed. BR.UpdateShopComplete still unset after 100 polls (10 seconds)")
|
||||
endif
|
||||
|
||||
SetInputOptionValueST(BR.ShopName)
|
||||
endEvent
|
||||
|
||||
event OnHighlightST()
|
||||
SetInfoText("Open a list of every item currently up for sale in your shop's merchandise inventory.")
|
||||
SetInfoText("The name of your shop. This is displayed to other players in the shop menu.")
|
||||
endEvent
|
||||
|
||||
event OnDefaultST()
|
||||
SetInputOptionValueST("Updating...")
|
||||
BR.UpdateShop(BR.ShopId, Game.GetPlayer().GetBaseObject().GetName() + "'s Shop", BR.ShopDescription)
|
||||
|
||||
int attempts = 0
|
||||
while !BR.UpdateShopComplete && attempts < 100
|
||||
attempts += 1
|
||||
Utility.WaitMenuMode(0.1)
|
||||
endWhile
|
||||
|
||||
if attempts >= 100
|
||||
Debug.Trace("BRMCMConfigMenu BR.UpdateShop failed. BR.UpdateShopComplete still unset after 100 polls (10 seconds)")
|
||||
endif
|
||||
|
||||
SetInputOptionValueST(BR.ShopName)
|
||||
endEvent
|
||||
endState
|
||||
|
||||
state LOAD_MERCH
|
||||
event OnSelectST()
|
||||
BR.LoadMerchandise()
|
||||
state SHOP_DESC
|
||||
event OnInputOpenST()
|
||||
SetInputDialogStartText(BR.ShopDescription)
|
||||
endEvent
|
||||
|
||||
event OnInputAcceptST(string textInput)
|
||||
SetInputOptionValueST("Updating...")
|
||||
BR.UpdateShop(BR.ShopId, BR.ShopName, textInput)
|
||||
|
||||
int attempts = 0
|
||||
while !BR.UpdateShopComplete && attempts < 100
|
||||
attempts += 1
|
||||
Utility.WaitMenuMode(0.1)
|
||||
endWhile
|
||||
|
||||
if attempts >= 100
|
||||
Debug.Trace("BRMCMConfigMenu BR.UpdateShop failed. BR.UpdateShopComplete still unset after 100 polls (10 seconds)")
|
||||
endif
|
||||
|
||||
SetInputOptionValueST(BR.ShopDescription)
|
||||
endEvent
|
||||
|
||||
event OnHighlightST()
|
||||
SetInfoText("Load shop merchandise onto the merchant shelf of the shop.")
|
||||
SetInfoText("The description of your shop. This is displayed to other players in the shop menu. This is a useful place to advertise what your shop sells.")
|
||||
endEvent
|
||||
|
||||
event OnDefaultST()
|
||||
SetInputOptionValueST("Updating...")
|
||||
BR.UpdateShop(BR.ShopId, BR.ShopName, "")
|
||||
|
||||
int attempts = 0
|
||||
while !BR.UpdateShopComplete && attempts < 100
|
||||
attempts += 1
|
||||
Utility.WaitMenuMode(0.1)
|
||||
endWhile
|
||||
|
||||
if attempts >= 100
|
||||
Debug.Trace("BRMCMConfigMenu BR.UpdateShop failed. BR.UpdateShopComplete still unset after 100 polls (10 seconds)")
|
||||
endif
|
||||
|
||||
SetInputOptionValueST(BR.ShopDescription)
|
||||
endEvent
|
||||
endState
|
||||
|
||||
state LOAD_SHOP_CONFIG
|
||||
event OnSelectST()
|
||||
SetTextOptionValueST("Fetching...")
|
||||
BR.GetShop(BR.ShopId)
|
||||
|
||||
int attempts = 0
|
||||
while !BR.GetShopComplete && attempts < 100
|
||||
attempts += 1
|
||||
Utility.WaitMenuMode(0.1)
|
||||
endWhile
|
||||
|
||||
if attempts >= 100
|
||||
Debug.Trace("BRMCMConfigMenu BR.GetShop failed. BR.GetShopComplete still unset after 100 polls (10 seconds)")
|
||||
endif
|
||||
|
||||
ForcePageReset()
|
||||
endEvent
|
||||
|
||||
event OnHighlightST()
|
||||
SetInfoText("Overwrites the shop name and description with values saved on the server. Run this after updating any of your shop config values on the website.")
|
||||
endEvent
|
||||
endState
|
@ -1,3 +1,4 @@
|
||||
scriptname BROwner
|
||||
|
||||
bool function Create(string apiUrl, string apiKey, string name, int modVersion, quest quest) global native
|
||||
bool function Update(string apiUrl, string apiKey, int id, string name, int modVersion, quest quest) global native
|
@ -7,11 +7,15 @@ actor property PlayerRef auto
|
||||
int property OwnerId auto
|
||||
; TODO: need to be able to create multiple shops
|
||||
int property ShopId auto
|
||||
string property ShopName auto
|
||||
string property ShopDescription auto
|
||||
; TODO: loop up interior refs by shop id instead of saving this
|
||||
int property InteriorRefListId = 29 auto ; TODO: temp fixing to id 20
|
||||
int property MerchandiseListId = 2 auto ; TODO: temp fixing to id 2
|
||||
ObjectReference property ShopXMarker auto
|
||||
bool property StartModFailed = false auto
|
||||
bool property UpdateShopComplete = false auto
|
||||
bool property GetShopComplete = false auto
|
||||
UILIB_1 property UILib auto
|
||||
|
||||
int function GetVersion()
|
||||
@ -82,15 +86,18 @@ event OnCreateOwner(int result)
|
||||
endif
|
||||
endEvent
|
||||
|
||||
event OnCreateShop(int result)
|
||||
Debug.Trace("BRQuestScript OnCreateShop result: " + result)
|
||||
if result > -1
|
||||
ShopId = result
|
||||
Debug.Notification("Initialized Bazaar Realm client")
|
||||
else
|
||||
Debug.MessageBox("Failed to initialize Bazaar Realm client. Please submit a bug on Nexus Mods with the contents of BazaarRealmPlugin.log and BazaarRealmClient.log usually located in C:\\Users\\<your user>\\Documents\\My Games\\Skyrim Special Edition\\SKSE.")
|
||||
StartModFailed = true
|
||||
endif
|
||||
event OnCreateShopSuccess(int id, string name, string description)
|
||||
Debug.Trace("BRQuestScript OnCreateShopSucess id: " + id + " name: " + name + " description: " + description)
|
||||
ShopId = id
|
||||
ShopName = name
|
||||
ShopDescription = description
|
||||
Debug.Notification("Initialized Bazaar Realm client")
|
||||
endEvent
|
||||
|
||||
event OnCreateShopFail(string error)
|
||||
Debug.Trace("BRQuestScript OnCreateShopFail error: " + error)
|
||||
Debug.MessageBox("Failed to initialize Bazaar Realm client.\n\n" + error + "\n\nPlease submit a bug on Nexus Mods with the contents of BazaarRealmPlugin.log and BazaarRealmClient.log usually located in C:\\Users\\<your user>\\Documents\\My Games\\Skyrim Special Edition\\SKSE.")
|
||||
StartModFailed = true
|
||||
endEvent
|
||||
|
||||
bool function SaveInteriorRefs()
|
||||
@ -152,6 +159,50 @@ int function ListMerchandise()
|
||||
UILib.ShowNotification("Chose " + options[selectedIndex], "#74C56D")
|
||||
endFunction
|
||||
|
||||
bool function LoadMerchandise()
|
||||
Debug.MessageBox("This no longer does anything, sorry.")
|
||||
function UpdateShop(int id, string name, string description)
|
||||
Debug.Trace("BRQuestScript UpdateShop id: " + id + " name: " + name + " description: " + description)
|
||||
UpdateShopComplete = false
|
||||
bool result = BRShop.Update(ApiUrl, ApiKey, id, name, description, self)
|
||||
if !result
|
||||
Debug.MessageBox("Failed to update shop. Please submit a bug on Nexus Mods with the contents of BazaarRealmPlugin.log and BazaarRealmClient.log usually located in C:\\Users\\<your user>\\Documents\\My Games\\Skyrim Special Edition\\SKSE.")
|
||||
UpdateShopComplete = true
|
||||
endif
|
||||
endFunction
|
||||
|
||||
event OnUpdateShopSuccess(int id, string name, string description)
|
||||
Debug.Trace("BRQuestScript OnUpdateShopSucess id: " + id + " name: " + name + " description: " + description)
|
||||
ShopId = id
|
||||
ShopName = name
|
||||
ShopDescription = description
|
||||
UpdateShopComplete = true
|
||||
endEvent
|
||||
|
||||
event OnUpdateShopFail(string error)
|
||||
Debug.Trace("BRQuestScript OnUpdateShopFail error: " + error)
|
||||
Debug.MessageBox("Failed to update shop.\n\n" + error + "\n\nPlease submit a bug on Nexus Mods with the contents of BazaarRealmPlugin.log and BazaarRealmClient.log usually located in C:\\Users\\<your user>\\Documents\\My Games\\Skyrim Special Edition\\SKSE.")
|
||||
UpdateShopComplete = true
|
||||
endEvent
|
||||
|
||||
function GetShop(int id)
|
||||
Debug.Trace("BRQuestScript GetShop id: " + id)
|
||||
GetShopComplete = false
|
||||
bool result = BRShop.Get(ApiUrl, ApiKey, id, self)
|
||||
if !result
|
||||
Debug.MessageBox("Failed to get shop. Please submit a bug on Nexus Mods with the contents of BazaarRealmPlugin.log and BazaarRealmClient.log usually located in C:\\Users\\<your user>\\Documents\\My Games\\Skyrim Special Edition\\SKSE.")
|
||||
GetShopComplete = true
|
||||
endif
|
||||
endFunction
|
||||
|
||||
event OnGetShopSuccess(int id, string name, string description)
|
||||
Debug.Trace("BRQuestScript OnGetShopSucess id: " + id + " name: " + name + " description: " + description)
|
||||
ShopId = id
|
||||
ShopName = name
|
||||
ShopDescription = description
|
||||
GetShopComplete = true
|
||||
endEvent
|
||||
|
||||
event OnGetShopFail(string error)
|
||||
Debug.Trace("BRQuestScript OnGetShopFail error: " + error)
|
||||
Debug.MessageBox("Failed to get shop.\n\n" + error + "\n\nPlease submit a bug on Nexus Mods with the contents of BazaarRealmPlugin.log and BazaarRealmClient.log usually located in C:\\Users\\<your user>\\Documents\\My Games\\Skyrim Special Edition\\SKSE.")
|
||||
GetShopComplete = true
|
||||
endEvent
|
@ -1,3 +1,5 @@
|
||||
scriptname BRShop
|
||||
|
||||
bool function Create(string apiUrl, string apiKey, string name, string description = "", quest quest) global native
|
||||
bool function Update(string apiUrl, string apiKey, int id, string name, string description = "", quest quest) global native
|
||||
bool function Get(string apiUrl, string apiKey, int id, quest quest) global native
|
Loading…
Reference in New Issue
Block a user