Implemented the .NET generator
- Added .NET generator setting for the namespace to use - Added .NET generator setting to choose the default culture - Added get child section method to section processor - Added util to convert any string to a verbatim string literal - Removed redundant variables on exceptions
This commit is contained in:
13 files changed
+454
-5
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using DataModel.Database;
|
||||
using Processor;
|
||||
using Processor.Generators;
|
||||
using UI_WinForms.Dialogs;
|
||||
using UI_WinForms.Resources;
|
||||
|
||||
@@ -293,8 +294,10 @@ public partial class SectionTree : UserControl
|
||||
selectedNode.Name = alteredSection.Result.DataKey; // [sic] name is the key
|
||||
}
|
||||
|
||||
private void buttonGenerate_Click(object sender, EventArgs e)
|
||||
private async void buttonGenerate_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.buttonGenerate.Enabled = false;
|
||||
await Generator.TriggerAllAsync();
|
||||
this.buttonGenerate.Enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -523,6 +523,82 @@ public sealed partial class Setting : UserControl
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowGeneratorDotnetNamespaceSettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetGeneratorDotnetNamespace();
|
||||
|
||||
var settingData = new SettingUIData(
|
||||
Icon: Icons.icons8_code_512,
|
||||
SettingName: () => "Generator: .NET Namespace",
|
||||
ChangeNeedsRestart: false,
|
||||
SettingExplanation: () => "The namespace for the .NET I18N files.",
|
||||
SettingExplanationLink: () => (string.Empty, string.Empty),
|
||||
SetupDataControl: (changeTrigger) =>
|
||||
{
|
||||
// Set up a textbox:
|
||||
var textbox = new TextBox();
|
||||
textbox.Text = currentSetting;
|
||||
textbox.TextChanged += async (sender, args) => await AppSettings.SetGeneratorDotnetNamespace(textbox.Text);
|
||||
textbox.TextChanged += (sender, args) => changeTrigger();
|
||||
textbox.Dock = DockStyle.Fill;
|
||||
textbox.Margin = new Padding(0, 13, 0, 13);
|
||||
return textbox;
|
||||
}
|
||||
);
|
||||
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowGeneratorDotnetDefaultCultureSettingAsync()
|
||||
{
|
||||
var currentSourceCultureIndex = await AppSettings.GetGeneratorDotnetDefaultCultureIndex();
|
||||
|
||||
// We load the corresponding culture for that index. As dropdown items, we show
|
||||
// all other available cultures:
|
||||
var allCultures = await AppSettings.GetCultureInfos();
|
||||
|
||||
// Attention: We have to store the culture's index, because the index is not
|
||||
// continuous and can change when the user adds or removes a culture!
|
||||
var settingData = new SettingUIData(
|
||||
Icon: Icons.icons8_code_512,
|
||||
SettingName: () => "Generator: .NET Default Culture",
|
||||
ChangeNeedsRestart: false,
|
||||
SettingExplanation: () => "The default culture for the .NET, which is used when no culture is specified or available.",
|
||||
SettingExplanationLink: () => (string.Empty, string.Empty),
|
||||
SetupDataControl: (changeTrigger) =>
|
||||
{
|
||||
var dropdown = new ComboBox();
|
||||
var currentCultureDropdownIndex = 0;
|
||||
for (var n = 0; n < allCultures.Count; n++)
|
||||
{
|
||||
var cultureInfo = allCultures[n];
|
||||
if(cultureInfo.Index == currentSourceCultureIndex)
|
||||
currentCultureDropdownIndex = n;
|
||||
|
||||
dropdown.Items.Add(new ComboBoxItem($"{cultureInfo.Index}.: {cultureInfo.Code}", cultureInfo.Index));
|
||||
}
|
||||
|
||||
dropdown.SelectedIndex = currentCultureDropdownIndex;
|
||||
|
||||
// Setup the change event handler:
|
||||
dropdown.SelectedValueChanged += async (sender, args) =>
|
||||
{
|
||||
if(dropdown.SelectedItem is ComboBoxItem selectedItem)
|
||||
await AppSettings.SetGeneratorDotnetDefaultCultureIndex(selectedItem.CultureIndex);
|
||||
};
|
||||
dropdown.SelectedValueChanged += (sender, args) => changeTrigger();
|
||||
|
||||
// Apply the desired layout:
|
||||
dropdown.Dock = DockStyle.Fill;
|
||||
dropdown.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
|
||||
return dropdown;
|
||||
}
|
||||
);
|
||||
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowGeneratorGodotEnabledSettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetGeneratorGodotEnabled();
|
||||
@@ -614,6 +690,8 @@ public sealed partial class Setting : UserControl
|
||||
{
|
||||
yield return ShowGeneratorGodotDestinationPathSettingAsync();
|
||||
yield return ShowGeneratorGodotEnabledSettingAsync();
|
||||
yield return ShowGeneratorDotnetDefaultCultureSettingAsync();
|
||||
yield return ShowGeneratorDotnetNamespaceSettingAsync();
|
||||
yield return ShowGeneratorDotnetDestinationPathSettingAsync();
|
||||
yield return ShowGeneratorDotnetEnabledSettingAsync();
|
||||
yield return ShowGeneratorModeSettingAsync();
|
||||
|
||||
Reference in new issue
Block a user