Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Save Slot Controllers to work more with Save Slot Views #1014

Open
wants to merge 81 commits into
base: CG-Tespy-CGTFungusSaveSystem
Choose a base branch
from

Conversation

CG-Tespy
Copy link
Collaborator

Description

It's a refactor.

I've noticed that the source for the new SaveSlotController class has yet to be fully adapted to the new SlotView system. I figured I might as well take a crack at making it so, even writing unit tests to make sure things are as intended. At the time of this writing, I've only managed to confirm that the slots do indeed have their base views registered as intended.

Later on, I'd like to make changes such as removing the old nameText, descText, and timeStampText fields; the new view system renders them unnecessary.

I hope to later on also help clean up other UI-related parts of the save system, though that's for another time.

Important Notes

  • At the time of this writing, there aren't any real behavior changes
  • My changes require modifications or additions to documentation
  • Added a GetView function to SaveSlotController so that other objects can access particular views of any particular slot. Certainly helped with unit-testing.
  • Please see the changes to SaveSlotController's Start function
  • My change adds unit tests under the Tests folder.
  • I've also added a Resources folder to help manage testing-only resources such as the

@CG-Tespy CG-Tespy changed the title [Incomplete] Refactoring Save Slot Controllers to work more with Save Slot Views Refactoring Save Slot Controllers to work more with Save Slot Views Jul 13, 2021
@CG-Tespy
Copy link
Collaborator Author

@stevehalliwell Finished. Removed some legacy fields and added tests to ensure that the slots do their thing right on their own. I've added to the view classes as well, based on the things the unit tests needed to check for.

@stevehalliwell stevehalliwell added this to the 3.14 milestone Aug 21, 2021
Added an Encode func to NumericVarSaveEncoder that can take an IList of vars, returning an IList of said vars encoded. I know that Fungus would normally return just a regular List, but I felt it'd be better to go with IList here due to how it's good practice to code more to interfaces than to concrete implementations.

Especially in this case. If the client really wants a regular List of the encoded results, they can easily make their own by passing said results to the regular List's constructor.
One that lets subclasses decide which var types they can support. This should cut down on boilerplate code we'd otherwise make when working on other var encoders.
Also deleted the sound tests, since we're quite a ways off from testing that stuff
FlowchartSavingTests was getting a bit big, and I felt that testing other var type encodings would take similar amounts of code. Hence, I made FlowchartSavingTests an abstract class for various suites that each focus on certain var types or groups.

Hence the new FlowchartNumSavingTests suite.
To cut down on code duplication, I created a testing extensions script. I may have to do something about the code duplication in the string var tests as they are now...
Will need to add back in the tests that check to make sure that invalid inputs get rejected
That test suite was set up only for var-encoding, so naming it "FlowchartSavingTests" was a bit misleading
As jsons don't work with all var types, I refactored the encoders to be more flexible about whether their values get encoded as json strings or regular strings
Renamed a couple flowcharts to reduce confusion, too
I can't save the state of the Say Commands' execution counts when they're inaccessible from outside code, so I changed it into an auto-property
This definitely matters for the Menu Command's HideIfVisited field, since that there depends on block execution counts
Hide If Visited procs based on the blocks' execution counts, and as making sure that is saved should depend on the Block-specific unit tests...
What with how different Commands' states may need to be saved in different ways.
Before, it didn't properly check the block state before deciding whether the test was successful. And to make sure that the test passed, I had to alter the Block and Say Savers so they... well, properly had the command indexes saved.
Since the stuff for saving the state of say commands should be in CommandSavingTests. And that stuff for checking the execution counts of blocks should be in BlockSavingTests
Since they can potentially hold thousands of bytes (the GameSaveData and UISaveData most likely will), which is too much for a struct
Any client code can also set the typenames in case there's any need to differentiate instances beyond just their class, like with VariableSaveUnit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants