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

Improved Options system #140

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
Draft

Improved Options system #140

wants to merge 14 commits into from

Conversation

Spartan322
Copy link
Collaborator

@Spartan322 Spartan322 commented Nov 9, 2021

  • Deprecates old options system, marked for deletion in next major version
  • Enables overriding default behavior
  • Default behavior saves and loads to configs according to its Id, and in accordance to default value, can be overriden
  • Tab names and tab ids can be separated
  • Tabs are optionally modifiable
  • Tabs and Options store their position and size data in an instance DrawData struct
  • Simplifies PathfinderOptions immensely
  • Manages config loading and registers saving in PostLoad
  • DrawData allows storing and modifying position and size structs easily (currently the X position of tab buttons are hard coded to be 10 pixels after the previous tab button however)

Added DrawData

  • Simple position and size data struct
  • Converts between any draw relevant types
  • Also has simple data modifiers

Added PluginOptionTab registry methods

  • Registers the option tab object for drawing and retrieves the tab object
  • Enables chained method calls like GetOrRegisterTab("tabName").AddOption(PluginOption).AddOption(PluginOption2)
  • Can separate tab ids and tab names

Added ease of use PluginOption registry method

  • For the case that one does not wish to mess with tab objects
  • Does not allow chain methods, is called instead like so RegisterOption("tabName", PluginOption);
  • Shortcut for GetOrRegisterTab(string).AddOption(IPluginOption) while returning the option object
  • Can separate tab ids and tab names

#127 needs to be updated when this is merged, or this needs to be updated when #127 is merged

@Spartan322 Spartan322 marked this pull request as draft November 26, 2021 07:07
@Spartan322
Copy link
Collaborator Author

I hope to add a capability to change the plugin options so that they can also support being drawn in a less "standard" position better, might require manually storing X, Y as nullable ints however.

@Spartan322
Copy link
Collaborator Author

Spartan322 commented Apr 25, 2022

And with that tabs and options support being in custom positions with overriding the draw methods.

@Spartan322
Copy link
Collaborator Author

Additions to #164:

  • Pathfinder.Meta.Load:
    • OptionAttribute.Tag
    • OptionsTabAttribute.Tag
  • Pathfinder.Options:
    • Option
    • OptionsManager.Tabs
    • OptionsManager.AddOption(string, Option)
    • OptionsTab

	Deprecates old options system, marked for deletion in next major version
	Enables overriding default behavior
	Default behavior saves and loads to configs according to its Id, and in accordance to default value
	Tab names and tab ids can be separated
	Tabs are optionally modifiable
	Tabs and Options store their position and size data in DrawData
	Simplifies PathfinderOptions immensely
	Manages config loading and registers saving in PostLoad
	DrawData allows storing and modifying position and size structs easily
Updater now uses new option/config system
MainMenuOverride:
	Changed IsEnabledBox, IncludePrerelease, and NotRestartPrompt to PluginCheckbox
	Modify PFAPILoaded to use OptionsManager Tab PluginOptionTab registry
	Removed OptionsSaved method as superflous
Removed PathfinderUpdaterPlugin's superflous ConfigEntry variables, relies on MainMenuOverride option values
Changed RestartPopupScreen.ExitScreen to only update MainMenuOverride.RestartPrompt.Value
	Eases the construction of custom tabs
GUI.DrawData updated to C#10
	Renamed to PluginOptionDrawData
	X, Y, Width, and Height made as stored nullable ints instead
	Modified Add method for ease of convenience
	Added QuickAdd for simpler alternative to modified Add
	Corrected cases of PluginOptionDrawData's nullable ints usage
Corrected ambiguous generic type references for GetTab in OptionsManager
PathfinderOptionsMenu:
	Renamed currentTabName to public CurrentTabId { get; private set; }
	Added SetCurrentTab(string), SetCurrentTab(PlugionOptionTab), and SetCurrentTab(OptionsTab) for tab registry safety
PlugionOptionTab:
	Move option draw data setting functionality to _SetDrawPositions method
	Correct options OnDraw calls to use gameTime
Disabled obsolete warnings in Options and PathfinderOptionsMenu
	pluginToOptionsTag renamed to pluginToOptTabAttribute that stores OptionsTabAttribute as value
	Added TabName and TabId
	Made Tag obsolete and redirects to TabName
	Property setters are made public
Added OptionsManager.GetIdFrom(string, string) for PluginOptionTab id resolution
OptionsAttribute:
	Added TabName and TabId
	Made Tag obsolete redirects to TabName
	Can register tabs with ID
…adContent

BasePluginOption:
	Removed DrawDataField, use DrawData
	Removed Id.set
	Added HeaderColor, DescriptionColor, HeaderFont, DescriptionFont, HeaderTextSize, and DescritptionTextSize
	Added protected constructor for needed assignment
	Assign fonts and size in LoadContent
	Fix config.Bind throwing for ConfigDescription being null
	Added protected DrawString method
OptionManager:
	Made GetIdFrom public
	Added Postfix Patch to Game1.LoadContent for calling LoadContent on all tabs
PathfinderOptions will add to an existing Pathfinder option tab if it exists
PluginCheckbox has been cleaned up and given SelectedColor
PluginOptionTab:
	Changed options to IDictionary<string, IPluginOption>
	Added SpriteBatch Batch
	Renamed IsRegistered to IsLoaded
	Implements IReadOnlyDictionary<string, IPluginOption> for options instead
	Renamed OnRegistered to LoadContent, runs on Game1.LoadContent
	Properly set IsLoaded to true in LoadContent
	Properly set draw data positions
Added PluginSlider for slider option
Added incomplete and unpolished PluginTextbox
Partly addresses #72
Deleted PluginOptionDrawData
IPluginOption:
	Removed DrawData
	Added Rectangle and Size
	Added TrySetOffset(Vector2)
BasePluginOption:
	Added Position, Offset, and MinSize
BasePluginOption derived classes use Position and Size for drawing and MinSize for configuring the Size
PluginOptionTab corrects option positions on every draw call using IPluginOption.TrySetOffset
Added expanding behavior for PluginTextbox
PluginOptionTab:
	Removed ButtonData
	Added ButtonRect, ButtonPosition, ButtonOffset
	Added TrySetButtonOffset(Point)
	Draws tab button using ButtonPosition and ButtonRect's Size values
PathfinderOptionsMenu relies on tab button offset drawing
Added CustomOptionsLoadEvent:
	Runs when opening the options screen
	Inverse of CustomOptionsSaveEvent
Corrected MiscPatches.NoSteamErrorMessageIL for PathfinderOptions.DisableSteamCloudError's conversion to a PluginCheckbox
Moved OptionsTab to a new file
PluginOptionTab:
	Added HacknetPlugin Plugin
	Constructor relies on assigning a plugin to the tab
	Modified OnSave(ConfigFile) to Save(), by default forces Plugin.Config to Save to disk
	Modified OnLoad(ConfigFile) to Load(), by default does nothing
IPluginOption:
	Removed OnSave and OnLoad
	Added ConfigEntryBase IPluginOption.ConfigEntry
BasePluginOption<ValueT>:
	Added ConfigEntry<ValueT> TypedConfigEntry
	Automatically handles the setting and retrieving of its config value
	Added static string MakeIdFrom(string, string) to replace old OptionsManager.GetIdFrom
OptionsManager:
	PluginTabs made into a Dictionary<string, PluginOptionTab>
	PluginTabs made private and renamed to _PluginTabs
	Public PluginTabs accessor has become a ReadOnlyDictionary of _PluginTabs
	Added const string PluginOptionTabIdPostfix
	Added MakeTabDataFrom(HacknetPlugin, string)
	Reworked GetIdFrom as GetIdFrom(HacknetPlugin, string, string)
	All RegisterTab methods require a HacknetPlugin argument now
	All RegisterOption methods also require a HacknetPlugin argument now
	Added ThrowDuplicateIdAttempt(string) for consistent exception response
Removed OPTION_TAG from PathfinderOptions
Removed Rectangle Outline from PluginCheckbox, PluginSlider, and PluginTextbox
PathfinderAPIPlugin:
	Added PathfinderAPIPlugin Instance for singleton reference
	Postfix patched HacknetPlugin.PostLoad to automatically load and save configs
		(Is disabled if it does not call HacknetPlugin.PostLoad)
MainMenuOverride:
	Call PFAPILoaded in PathfinderAPIPlugin.Load, removed patching
	Added UpdaterTab
	MainMenuOverride always refers to MainMenuOverride.NoRestartPrompt for NoRestartPrompt option
	MainMenuOverride always refers to MainMenuOverride.IsEnabledBox for  Enabled option
	Implementation currently ignores the old config implmentation
PathfinderUpdaterPlugin:
	Added PathfinderUpdaterPlugin Instance for singleton reference
	Replaced uses of IsEnabled with MainMenuOverride.IsEnabledBox
	Replaced uses of IncludePreReleases with MainMenuOverride.IncludePrerelease
RestartPopupScreen:
	Made NoRestartPrompt PluginCheckbox
	Constructor requires a ConfigFile argument
	Moved buttons and checkbox for the sake of polish
	Forcibly save data if NoRestartPrompt's value changes
Updated OptionAttribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant