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

Improve Backup System and add UI to Restore Backups #1824

Closed

Conversation

NinjaPedroX
Copy link
Contributor

@NinjaPedroX NinjaPedroX commented Jun 18, 2022

NOTE: This PR contains almost all of the original commits from the World Manager PR due to being created while dependent of that PR before it was merged, of which I have not been able to remove as I thought I would be able to.

  • Made the server back-up the save file every time the server starts up with that selected world
  • Added UI and functionality to allow the user to select and restore a backup from within the world settings
  • Changed the backups directory to the "Backups" folder within each save file
  • Allowed a maximum of only 5 backups
  • Changed the server error message for corrupted worlds to tell the user to restore a backup, and it now backs-up the corrupted save files so that devs can troubleshoot

TODO:

  • - Add a "backup" command to the server console so that the user can manually back up their save
  • - Fix backup system to be able to deal with save name changes (Changing the name of the world would invalidate the names of the already existing backups)
  • - Allow the save import system to import the save's backup folder if it contains one

image
image
image

Almost finished the general design of the World Selection Pane. Currently trying to figure out how to get the text in the middle of the world listing to align correctly
- Added more basic UI (the only issue is that some elements have hardcoded widths since I couldn't figure out how to get them to fill up the space automatically).

- Added the basic sliding animations and the buttons that activate them for the World Selection and World Settings panes.

- Fixed up the start server button and added a checkbox on the bottom right of it that allows the server to run externally when checked.
- Added text boxes to input World name and seed (non functional)

- Designed and added Gamemode select buttons

- Added Game Options pane basic UI and some of the options I plan on having on there, with the exception of the switches

- Started the design for a functioning switch.
- Added switches to World Settings pane

- Created methods for all of the buttons in ServerPage.xaml.cs and started investigating out to create a new world
- Assigned variables to the switches in the World Options pane that can be changed to be equal to the values in the server.cfg file (TODO)

- Attempted to get the state of the IsServerExternal checkbox to persist across sessions. I'm close, but the value keeps resetting to true when starting up the launcher :bigangry:
- Changed the world selection pane into a list viewer

-Pre-set some world options as examples, and to test the scrollability of the pane

There are still some problems:
  - Clicking one of the world options will crash the launcher, since I did not get to handling that yet.
  - The hard-coded width values caused the UI to look wrong when the scroll bar appeared. I still need to figure that out. For now, I have the width of the button itself to adjust automatically but the world info text in each button is not aligned correct.
- Fixed the scroll bar having an extra bit of space above it in the world listing container

- Bound a few variables to some text boxes and blocks in the World Settings pane. They are meant to and will be bound to the information of the world that is selected by the user.

TODO: Remove or customize the background of each world listing that shows when the mouse is hovering over it.
- Fixed launcher crash that happens when you click one of the world listing buttons, which tried to play the WorldSelectedAnimation and didn't recognize the target names of the storyboard.

- Moved the logic behind activating the animations into ServerPage.xaml.cs for more uniformity

- Prepared for the next task on hand, which is to write the code for writing and managing the save files
…ches

- Started work on file management, such as having Nitrox create a "saves" file in "%AppData%\Roaming"

- Tied switches to some serverconfig variables, though they don't yet update the file itself just yet
…e "servers" file

- Added the ability for the world option switches to set their values to those in the server.cfg file.
- Added the ability to update those values when the user goes back to the world selection pane or when the server is started if the values are different.
- Changed the save location of the server list file "servers" to `C:\Users\(Username)\AppData\Roaming\Nitrox`
- Changed the "Enable PvP" setting to "LAN Discovery", but if PVP is ever added, it would go in place of that option and LAN Discovery would be moved to the "Advanced Settings" pane

NOTE: The world listing buttons are disabled since I'm still trying to figure out how I can double click them so that I can get the value of the world listing the user selected. -- To test the world options, select the "Add World" button.

One last thing: I think that there is no need for the world settings variables that I set in ServerPage.xaml.cs, so when I work to optimize my code later, I might remove these along with the Checkbox/radio button methods.
- Added the functionality of scanning for valid save files in the "saves" folder and displaying them on the list
- Fixed the world listing buttons so that they activate after the world listing is selected
- Added a background to the world selection pane listview that shows when there are no server listings. It contains the server image that was there before and some text telling the user to click the + button to add a new world.

NOTE: To test out the server listing, make a copy of your "world" folder and move a copy of the server.cfg file into it. Then after you opened the launcher once, move that world folder to `C:\Users\(Username)\AppData\Roaming\Nitrox\saves`. Rename it to "save0" and make copies of it, incrementing the last number by 1 for each file
…orld listing

- Added the functionality to view and edit the server.cfg file of the selected world listing
- Added some basic functionality for the Add World button
- (Temporarily?) fixed up some server commands to be able to run correctly (once I can fix up the server itself to be able to run)

NOTE: The server does not run, and the Add World button does not write a complete "world" folder, only a server.cfg file, so it won't show up on the list after you add it. I have yet to fix these
- Added the functionality to delete save files in the launcher
- Added a confirmation overlay that pops up when the user clicks the delete world button
- Started work on getting the world listing save versions to display correctly (some parts are commented out)
As title says

NOTE: Server does not yet work. May have to move world manager logic into its own class if this way does not end up working.
…name verification

- (Credits to Measurity) Moved most of the WorldManager logic into its own class named "WorldManager"
- Made the scroll viewer scroll more smoothly instead of item-by-item
- Tied save names to folder names, and added checks on user inputs for whether the name is a duplicate or contains illegal filename characters. Extra whitespaces at either end of the name and illegal characters are removed, and duplicated names will have a "(#)" added to the end of it.

NOTE: The file name check should be finished, but there may still be some crashes for certain file name check cases that I have not come across. If I or someone else does come across them, it will be fixed as long as I'm made aware of it.
- Added input checks for the World seed and server port text boxes
- Added tooltips to the text boxes
- Did more work to try to get the server working, though still to no avail
…asurity)

- The server now starts up with the selected save folder
…resh button

- Added logic for NitroxServer-Subnautica.exe so that it can handle running the server by using the last used save file, or it would create a new save file if there are none detected.
- Added a refresh button to the world selection pane so that the user can refresh the world listing in case they make any changes to the save files manually (with file explorer)
- Cleaned up some comments that weren't needed
As title says
- Fixed an issue with the server listing button that caused it to extend past the world listing container when the user sets a very long world name in the config file
- Re-added that useless class but commented out, so that you can view the pre-set world listings in intellisense if you want to
- Replaced the "Delete Server" icon in the world selection page with a smaller Delete Server icon under a "World Settings" icon, and had them animate to appear when the mouse is hovering over the world listing.
- Made the world listing button itself start the server instead of having it open the world settings pane.
- Move the "Is external" checkbox back into a radio button with a new design and it's location at the top of both world manager panes.
- Added more icons to help with these (NOTE: These icons are temporary and should be replaced with ones that fit the Nirox design)
- Slightly increased the size of both panes upwards
…another bug

- Replaced the "Start Server" button in the world settings pane with a Delete World and Restore backup Button (the Restore Backup button is still non-functional, I might comment it out for this PR and include it in another PR which I plan to add better backup logic)
- Solved an issue where clicking the "GoBack" button too soon after world creation would crash the launcher

NOTE: I commented out the code and logic for the Start Server button in the World Settings pane in case we decide later on to have it there too.

NOTE 2: World seed input does not get saved now when creating a new world for some reason - will need to investigate and fix when I try to get the world seed from the world's save files if the config file doesn't have one.
- Improved UI for world settings pane with a lot more options added (currently non-functional)

NOTE: Unsupported settings are there as a placeholder and will be commented out in the final version for future use.
- Redesigned the Combobox to be used in the server settings (I seek a more efficient way of doing this), and added it in the World Settings pane
- Commented out the PvP and Mods settings for later use and marked them as TODO
- Added functionality for the new options that were added
- Shortened and moved the code for the Comobox restyle to ServerPage.xaml (having it to App.xaml causes fake errors to happen)
- Changed the Save interval limit to be greater than or equal to 1 in the ServerConfig.cs to better work with the textbox input validation for that option.
- Started work on save file listing validation based on save file number
- Added functionality to disallow server listings with invalid save versions (higher than the current launcher version and lower than v1.5.0.1)
- Fixed the launcher to correctly serialize the save file version when the save files are in the Protobuf format

NOTE: Need to investigate and fix the server not being able to use protobuf saves
- Commented out the Restore Backup button, which should be readded along with better backup logic in another PR
NinjaPedroX and others added 27 commits June 6, 2022 18:05
- Changed back class access modifier that I accidentally changed when testing something
…orld deletion logic

- Fixed the server startup logicfor saves that were created by the world manager (empty save files have a size of 0 bytes)
- Improved save deletion logic so that special cases (such as the user having the server.cfg file of that save opened manually) won't crash the launcher
- Changed the style of the list view item MouseOver and Selection highlighting
- Corrected a commend to better represent the future purpose of some commented out code
- Corrected a spelling mistake :)
- Made server listing update when a world's server is started by changing the write time of the selected save file and running the "InitializeWorldListing()" method
- Added checks for the Delete World and World Settings buttons to not run its code if the selected world is being used
- Added a better error message for when the user tries to start another server when one has already been started
- Changed the world delete code to move the file to the recycling bin instead.
- Made a small improvement to the UI for the file import pane
- Removed a few useless lines of code in WorldManager.cs
- Fixed crashes that can occur if a selected folder was deleted after the world list was initialized
- Reorganized the structure of some of the methods
- Fixed some tooltips and comments
…ed various improvements

- Further fixed bugs caused by the recent fixes I made (for real this time)
- Improved the Textbox input check by having it reset the input to the previously inputted text when an invalid input is given
- Made the Delete World and World Settings buttons in the main page take up the whole space of the button instead of only being the image itself
- Improved seed logic for new worlds so that seeds that are manually defined in the debug mode of the launcher will be used instead of being set to the default debug seed
- Improved the server seed textbox to be read-only instead of being disabled when the world is not newly created
- Added new functionality for save file backup
    - Save files are backed up every time the server starts up, for a maximum of 3 backups
- The server console message for corrupted save files has been simplified with the errors being saved in a separate file and the corrupted save files being backed up along with it.
- Added new UI for backup restoration
- Improved backup file validation check
- Set the error log name to be a public variable that can be referenced when needed (to make it easier to change its name if desired)
- Changed the error message in the console to open the error log created in the save file when "L" is entered
- Added the functionality to restore a selected backup file
- Changed the number of max backups to 5
- Fixed the scroll bar of the List Viewer to align with the very top/bottom of the ListView items
…e files inside of the .zip backup

As title says
Co-authored-by: rootcan <tortornac@gmail.com>
Co-authored-by: rootcan <tortornac@gmail.com>
- Added a try-catch statement for the save file import functionality to prevent crashes
- Added a try-catch statement for the creation of the "saves" folder to prevent crashes in case there are issues with user permissions
As title says

Co-authored-by: iOnyme <10561268+dartasen@users.noreply.github.com>
Co-authored-by: rootcan <tortornac@gmail.com>
- Added new functionality for save file backup
    - Save files are backed up every time the server starts up, for a maximum of 3 backups
- The server console message for corrupted save files has been simplified with the errors being saved in a separate file and the corrupted save files being backed up along with it.
- Added new UI for backup restoration
- Improved backup file validation check
- Set the error log name to be a public variable that can be referenced when needed (to make it easier to change its name if desired)
- Changed the error message in the console to open the error log created in the save file when "L" is entered
- Added the functionality to restore a selected backup file
- Changed the number of max backups to 5
- Fixed the scroll bar of the List Viewer to align with the very top/bottom of the ListView items
…e files inside of the .zip backup

As title says
…ager"

This reverts commit f63fbe3, reversing
changes made to 748fcab.
@dartasen
Copy link
Member

As discussed with rux, we'll focus on world-manager itself so we can improve your design and user experience, especially for non-dev. I opened a PR to replace all the icons to fit the design. In the meantime rux is working on your figma prototype so we can focus on the overhaul (you'll be able to work on it if you want).

Since we're getting closer every day to the Subnautica 2.0 update, I wanna make sure the launcher is ready so we can ship this feature with 1.7. For now it's better to focus on this particular feature to make it 100% perfect and then we'll look at backup.

I'm closing this for now

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.

None yet

2 participants