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

Core / Settings: Improved settings loading / saving and the integration #190

Merged
merged 56 commits into from
Aug 23, 2021

Conversation

Alf21
Copy link
Member

@Alf21 Alf21 commented Aug 15, 2021

  • implemented a safe-fail in case the user tries to load a non-settings file as a setting
  • improved settings' FileSelection handling

image

image

Added Tooltip basic UI component:
unknown (6)

TODO

  • Update settings if a settings file was loaded
  • Create Server- and ClientSettings separation
  • Integrate already existing settings into the settings menu
  • Convert ConVars into SettingsVars

Updated json structure (e.g. serversettings):

{
  "Round": {
    "MinPlayers": 2,
    "PreRoundTime": 10,
    "RoundTime": 100,
    "PostRoundTime": 8,
    "KillTimeReward": 20
  },
  "Movement": {
    "IsSprintEnabled": true
  },
  "General": {
    "Language": "en-US"
  },
  "JsonType": "ServerSettings"
}

Fixed dropdown cut off as well (caused by overflow):
image

@Alf21 Alf21 added area/code Something regarding the codebase issue/feature-request This issue is a feature request labels Aug 15, 2021
@Alf21 Alf21 self-assigned this Aug 15, 2021
@Alf21 Alf21 changed the base branch from master to settings August 15, 2021 11:25
@Alf21 Alf21 linked an issue Aug 15, 2021 that may be closed by this pull request
6 tasks
@Alf21 Alf21 changed the base branch from settings to master August 15, 2021 21:35
- Fixed settings not updating in certain stages
- Improved settings handling
- Added a main setting change event
- Fixed dropdown auto select bug
- Default settings will be overwritten without dialog when loading settings from a file
Comment on lines +13 to +21
public int MinPlayers { get; set; } = 2; // The minimum players required to start.

public int PreRoundTime { get; set; } = 20; // The amount of time allowed for preparation.

public int RoundTime { get; set; } = 300; // The amount of time allowed for the main round.

public int PostRoundTime { get; set; } = 10; // The amount of time before the next round starts.

public int KillTimeReward { get; set; } = 30; // The amount of extra time given to traitors for killing an innocent.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know someone suggested this, but imo these comments are not needed. If the variable name is that bad that someone can't understand it, it should be changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept this for e.g. upcoming attribute property support. Anyways, these comments doesn't hurt imo.

code/lang/TTTLanguage.cs Outdated Show resolved Hide resolved
DefaultWalkController.SetSprintEnabled(value);
}

namespace Topics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this namespace a few times, what is the goal of describing what should be underneath it? Topics seems pretty vague to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While TTTReborn.Settings stores the settings stuff, TTTReborn.Settings.Topic holds the setting topics, so you don't have just json structure stuff inside the defeault settings namespace.


settings.JsonType = settingsName;

FileSystem.Data.WriteAllText(path + fileName + SETTINGS_FILE_EXTENSION, GetJSON<T>(settings));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use ${}

code/ui/components/modal/Modal.cs Outdated Show resolved Hide resolved
@@ -163,7 +169,7 @@ public void OnConfirm(FileSelectionEntry fileSelectionEntry)
}
else
{
CreateTreeView(_currentFolderPath + fileSelectionEntry.FileNameLabel.Text);
CreateTreeView(CurrentFolderPath + fileSelectionEntry.FileNameLabel.Text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use ${}

code/ui/components/switch/Switch.cs Show resolved Hide resolved
});
}

private void OnAgreeSaveAs(FileSelection fileSelection)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably can just be SaveAs

dialogBox.Display();
}

private void OnAgreeLoadFrom(FileSelection fileSelection, PanelContent menuContent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoadFrom

code/ui/generalhud/menu/Menu.Settings.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@matekdev matekdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Alf21 Alf21 merged commit 7907a17 into master Aug 23, 2021
@Alf21 Alf21 deleted the settings-integration branch August 23, 2021 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code Something regarding the codebase issue/feature-request This issue is a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SettingsSystem
2 participants