Get/Set merch and refs by shop id

Also, rename placeholder to activator. Some MCM UI improvements.
This commit is contained in:
Tyler Hallada 2020-10-25 03:21:08 -04:00
parent 40350de32e
commit 69b87517ec
7 changed files with 19 additions and 13 deletions

Binary file not shown.

View File

@ -83,6 +83,7 @@ endState
state START_MOD
event OnSelectST()
if BR.StartMod()
SetOptionFlagsST(OPTION_FLAG_DISABLED)
int attempts = 0
while BR.ShopId == 0 && !BR.StartModFailed && attempts < 100
attempts += 1
@ -123,7 +124,9 @@ endState
state LOAD_REFS
event OnSelectST()
SetTextOptionValueST("Loading...")
BR.LoadInteriorRefs()
SetTextOptionValueST("")
endEvent
event OnHighlightST()

View File

@ -1,4 +1,4 @@
scriptname BRMerchPlaceholderScript extends ObjectReference
scriptname BRMerchActivatorScript extends ObjectReference
Actor Property PlayerRef Auto

View File

@ -3,10 +3,11 @@ scriptname BRMerchNextPageScript extends ObjectReference
Keyword property BRLinkMerchShelf auto
Keyword property BRLinkMerchChest auto
Keyword property BRLinkItemRef auto
Keyword property BRLinkActivatorRef auto
Keyword property BRLinkMerchToggle auto
Keyword property BRLinkMerchNext auto
Keyword property BRLinkMerchPrev auto
Activator property PlaceholderStatic auto
Activator property ActivatorStatic auto
Actor property PlayerRef auto
Quest Property BRQuest Auto
@ -14,7 +15,7 @@ event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerRef
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
BRQuestScript BRScript = BRQuest as BRQuestScript
bool result = BRMerchandiseList.NextPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.MerchandiseListId, MerchantShelf, PlaceholderStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
bool result = BRMerchandiseList.NextPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
Debug.Trace("BRMerchandiseList.NextPage result: " + result)
if !result
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)

View File

@ -3,10 +3,11 @@ scriptname BRMerchPrevPageScript extends ObjectReference
Keyword property BRLinkMerchShelf auto
Keyword property BRLinkMerchChest auto
Keyword property BRLinkItemRef auto
Keyword property BRLinkActivatorRef auto
Keyword property BRLinkMerchToggle auto
Keyword property BRLinkMerchNext auto
Keyword property BRLinkMerchPrev auto
Activator property PlaceholderStatic auto
Activator property ActivatorStatic auto
Actor property PlayerRef auto
Quest Property BRQuest Auto
@ -14,7 +15,7 @@ event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerRef
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
BRQuestScript BRScript = BRQuest as BRQuestScript
bool result = BRMerchandiseList.PrevPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.MerchandiseListId, MerchantShelf, PlaceholderStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
bool result = BRMerchandiseList.PrevPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
Debug.Trace("BRMerchandiseList.PrevPage result: " + result)
if !result
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)

View File

@ -3,10 +3,11 @@ scriptname BRMerchToggleScript extends ObjectReference
Keyword property BRLinkMerchShelf auto
Keyword property BRLinkMerchChest auto
Keyword property BRLinkItemRef auto
Keyword property BRLinkActivatorRef auto
Keyword property BRLinkMerchToggle auto
Keyword property BRLinkMerchNext auto
Keyword property BRLinkMerchPrev auto
Activator property PlaceholderStatic auto
Activator property ActivatorStatic auto
Actor property PlayerRef auto
Quest Property BRQuest Auto
@ -14,7 +15,7 @@ event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerRef
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
BRQuestScript BRScript = BRQuest as BRQuestScript
bool result = BRMerchandiseList.Toggle(BRScript.ApiUrl, BRScript.ApiKey, BRScript.MerchandiseListId, MerchantShelf, PlaceholderStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
bool result = BRMerchandiseList.Toggle(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
Debug.Trace("BRMerchandiseList.Toggle result: " + result)
if !result
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
@ -25,7 +26,7 @@ endEvent
event OnLoadMerchandiseSuccess(bool result)
Debug.Trace("BRMerchToggleScript OnLoadMerchandiseSuccess result: " + result)
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
while !BRMerchandiseList.Replace3D(MerchantShelf, PlaceholderStatic, BRLinkMerchShelf, BRLinkItemRef)
while !BRMerchandiseList.Replace3D(MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkItemRef)
Debug.Trace("BRMerchandiseList.Replace3D returned false, waiting and trying again")
Utility.Wait(0.05)
endWhile

View File

@ -1,12 +1,12 @@
scriptname BRMerchandiseList
; TODO: a save function that saves the merch to the server, load should load from server
bool function Toggle(string apiUrl, string apiKey, int merchandise_list_id, ObjectReference merchantShelf, Form placeholderStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
bool function NextPage(string apiUrl, string apiKey, int merchandise_list_id, ObjectReference merchantShelf, Form placeholderStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
bool function PrevPage(string apiUrl, string apiKey, int merchandise_list_id, ObjectReference merchantShelf, Form placeholderStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
bool function Toggle(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
bool function NextPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
bool function PrevPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
bool function Replace3D(ObjectReference merchantShelf, Form placeholderStatic, Keyword shelfKeyword, Keyword itemKeyword) global native
bool function Replace3D(ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword itemKeyword) global native
Form function Buy(ObjectReference merchandisePlaceholder) global native
Form function Buy(ObjectReference merchandiseActivator) global native
bool function Create(string apiUrl, string apiKey, int shopId, ObjectReference merchantChest) global native