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

[Feature] System for saving and loading option presets using a local file #727

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jere0500
Copy link
Contributor

Hey there, I have implemented a working version of a preset saving and loading system and would like some general feedback :). Unfortunatly, I currently keep finding bugs.

The system works both in singleplayer (Skirmish) and in multiplayer. The system allows you to save settings in your local lobby and save them to a preset, which can be restored at a later point.
The feature got requested multiple times (#270 #460).

Implementation

In the current iteration I added a button below the advanced options to access the Preset Menu.
image

The button opens the preset loading and saving menu.
image

New presets can be selected in the drop-down menu when clicking <new>
image

This opens a prompt where you can enter a name.
image

Saving

When opening the optionPreset panel, various settings are collected from the current lobby and stored in local variables.
When clicking the save button, the settings will be added to the optionPreset.json file under the preset name. The file will be created/ written in your installation folder.
Only options that are selected in the Load Option tab will be saved.

Loading

The settings will be read from the file and saved to local variables. The values are applied at their places in the lobby. Some settings are differently applied in singleplayer and multiplayer. Additionally, you can specify the settings that should be loaded in the Load Option tab. If a specific setting is not defined for a preset, the setting will be ignored, and the current value will remain.

Quirks/Workarounds

  • it was necessary to expose access to the current battle lobby through multiple functions for fetching/ applying specific options.
    • Some of these might not be necessary, if there are better options available. I will be more than happy to use them
  • I do not know if there is a better option to refresh elements like the drop-down menu of the preset selection:
    • I did it by deleting and recreating the elements
  • Multiplayer: The modoptions set in the multiplayer lobby when joining will be cached as the default. Which allows to reset the modoptions when switching to another preset
    • (This could also be solved by getting the defaults directly)

Features

As of now it supports saving and loading of.

  • modoptions (advanced options)
  • the currently selected map
  • the defined bots with their team and settings
  • the defined starting rects and their position

Multiplayer specific

  • loading of spads related settings:
    • e.g. team, locked, etc..

Other features:

  • When the optionPreset.json file gets damaged, it gets copied to an optionPresetError[date].json with the current date and replaced with a blank file.
  • Specific setting, what to save and load from presets:
    • If an option is not defined in a set, it does not get loaded
      image

Limitations/ Known problems:

  • Multiplayer: loading of the bots/ teams can lead to incorrect mapping of teams and bots and requires some moving of bots
  • Presets can have a lot of options:
    • in multiplayer many options are applied with chat commands that can lead to spam (which might be unwanted)
  • the json library used in chobby can only handle compact json (new lines, tabs and spaces cause errors)
  • in rare cases the presets create to many start boxes
  • currently, there is a problem with saving/ loading modoptions in multiplayer not being applied correctly

Untested:

  • how loading of complex team presets work in multiplayer
    • are people moved to teams correctly?
  • that the optionPreset button is grayed out in MP (same as advanced options)
  • correct functionality on Windows

Ideas for future work/ Ideas

  • implement also saving of resource boosts that can be defined when right clicking a bot
  • import/ export feature of presets:
    • could be a further iteration/ implementation that allows sharing of presets (e.g. by exporting/ importing dedicated.json files, which can be shared freely)
    • this would currently require some level of json knowledge
    • could also think about a sending system

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.

1 participant