Skip to content

Commit

Permalink
[VE] Move language selection to config to free up space in the window
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Jun 4, 2022
1 parent ce27868 commit d951f47
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions VideoExport.Core/VideoExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private enum UpdateDynamicBonesType
private string _imagesPostfix = "";
private bool _clearSceneBeforeEncoding;
private bool _closeWhenDone;
private Language _language;
private ConfigEntry<Language> _language;
#endregion

#region Public Accessors (for other plugins probably)
Expand Down Expand Up @@ -267,8 +267,9 @@ protected override void Awake()
_prewarmLoopCount = _configFile.AddInt("prewarmLoopCount", 3, true);
_imagesPrefix = _configFile.AddString("imagesPrefix", "", true);
_imagesPostfix = _configFile.AddString("imagesPostfix", "", true);
_language = (Language)_configFile.AddInt("language", (int)Language.English, true);
SetLanguage(_language);
_language = Config.Bind(Name, "Language", Language.English, "Interface language");
_language.SettingChanged += (sender, args) => SetLanguage(_language.Value);
SetLanguage(_language.Value);
string newOutputFolder = _configFile.AddString("outputFolder", _outputFolder, true, _currentDictionary.GetString(TranslationKey.VideosFolderDesc));
if (Directory.Exists(newOutputFolder))
_outputFolder = newOutputFolder;
Expand Down Expand Up @@ -301,7 +302,7 @@ protected override void Awake()
if (_screenshotPlugins.Count == 0)
Logger.LogError("No compatible screenshot plugin found, please install one.");
SetLanguage(_language);
SetLanguage(_language.Value);
}, 5);
}

Expand Down Expand Up @@ -379,7 +380,6 @@ protected override void OnGUI()
protected override void OnDestroy()
{
base.OnDestroy();
_configFile.SetInt("language", (int)_language);
_configFile.SetInt("selectedScreenshotPlugin", _selectedPlugin);
_configFile.SetInt("framerate", _fps);
_configFile.SetBool("autoGenerateVideo", _autoGenerateVideo);
Expand All @@ -395,7 +395,6 @@ protected override void OnDestroy()
_configFile.SetInt("prewarmLoopCount", _prewarmLoopCount);
_configFile.SetString("imagesPrefix", _imagesPrefix);
_configFile.SetString("imagesPostfix", _imagesPostfix);
_configFile.SetInt("language", (int)_language);
_configFile.SetString("outputFolder", _outputFolder);
_configFile.SetString("framesFolder", _globalFramesFolder);
foreach (IScreenshotPlugin plugin in _screenshotPlugins)
Expand Down Expand Up @@ -442,13 +441,6 @@ private void Window(int id)
{
GUILayout.BeginVertical();
{
GUILayout.BeginHorizontal();
if (GUILayout.Button(Language.English.ToString()))
SetLanguage(Language.English);
if (GUILayout.Button(Language.中文.ToString()))
SetLanguage(Language.中文);
GUILayout.EndHorizontal();

GUI.enabled = _isRecording == false;

if (_screenshotPlugins.Count > 1)
Expand Down Expand Up @@ -765,8 +757,8 @@ private void Window(int id)

private void SetLanguage(Language language)
{
_language = language;
switch (_language)
_language.Value = language;
switch (language)
{
case Language.English:
_currentDictionary = _englishDictionary;
Expand Down

0 comments on commit d951f47

Please sign in to comment.