feat: Save slots#692
Conversation
Quenty
left a comment
There was a problem hiding this comment.
Looks good overall. Left a ton of comments.
| ]=] | ||
| function HasSaveSlotsClient.PromiseSetSlotMetadata( | ||
| self: HasSaveSlotsClient, | ||
| slotId: string, |
There was a problem hiding this comment.
Typically I'd type slotId to make future refactors safer but it's ok as-is too.
| Gets the last active slot ID | ||
| ]=] | ||
| function HasSaveSlotsClient.PromiseLastActiveSlotId(self: HasSaveSlotsClient): Promise.Promise<string?> | ||
| return self._remoting.PromiseLastActiveSlotId:PromiseInvokeServer() |
There was a problem hiding this comment.
Might be worth some fancier cache management, potentially internally a Boolean attribute for loaded and an attribute for the slot id, so that we're effectively cached on the client instead of requesting server a lot.
This will happen on initial game load, potentially many systems may promise the slot id.
| Refreshes the active slot summary | ||
| ]=] | ||
| function HasSaveSlotsClient.PromiseRefreshActiveSlotSummary(self: HasSaveSlotsClient): Promise.Promise<any> | ||
| return self._remoting.PromiseRefreshActiveSlotSummary:PromiseInvokeServer() |
There was a problem hiding this comment.
Preferably we don't have to leak this state externally but it's ok as-is and I don't see a clean way right now to avoid this.
| type SaveSlotStruct = { | ||
| folder: Folder, | ||
| attributes: any, | ||
| maid: Maid.Maid, |
There was a problem hiding this comment.
This is a tad risky given it's not a fully managed object, we could forget to cleanup this maid structurally.
Safest option? Store the maid in a parallel structure and make this pure data.
| local data = { | ||
| SlotId = slotId, | ||
| SlotIndex = slotIndex, | ||
| SlotName = (metadata and metadata.SlotName) or `Slot {slotIndex}`, |
There was a problem hiding this comment.
Should maybe rename to UnfilteredSlotName so we remember to filter the text.
Maybe not a big deal though.
| slotId: string, | ||
| data: SaveSlotData.SaveSlotMetadata | ||
| ): Promise.Promise<any> | ||
| if data.SlotId and (data.SlotId ~= slotId) then |
There was a problem hiding this comment.
Just use SaveSlotData:IsStrictData() call here to fully check and get a good error message.
| end) | ||
| end | ||
|
|
||
| function HasSaveSlots._refreshActiveSlotSummary(self: HasSaveSlots): () |
There was a problem hiding this comment.
It would definitely be nicer if this was just managed using Rx for the user. More guaranteed safety.
| end) | ||
|
|
||
| self._cmdrService:RegisterCommand({ | ||
| Name = "active-save-slot", |
There was a problem hiding this comment.
Maybe should prefix with get? Also fine as-is. I wish our command scheme was better named.
PlayerDataStoreService wrapper for save slots.
Provides an interface for creating, manipulating, and observing slots such that consumers can seamlessly react to slot switching.