install keys
This commit is contained in:
@@ -20,9 +20,6 @@ public partial class Form1
|
||||
{
|
||||
this.updateOptions = updateOptions;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(updateOptions.ModpackConfig))
|
||||
LoadUpdateConfigFile(updateOptions.ModpackConfig);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(updateOptions.ProfileFolder))
|
||||
LoadMinecraftProfile(updateOptions.ProfileFolder);
|
||||
}
|
||||
@@ -37,7 +34,7 @@ public partial class Form1
|
||||
RadButton_CheckForUpdates.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small);
|
||||
radButton_RefreshConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.refresh, SvgImageSize.Small);
|
||||
RadButton_SearchMinecraftProfileFolder.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SvgImageSize.Small);
|
||||
RadButton_SearchModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SvgImageSize.Small);
|
||||
radButton_PasteInstallKey.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SvgImageSize.Small);
|
||||
RadButton_PasteModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SvgImageSize.Small);
|
||||
}
|
||||
|
||||
@@ -102,6 +99,7 @@ public partial class Form1
|
||||
try
|
||||
{
|
||||
modpackInfo = ModpackInfo.TryLoad(folderPath);
|
||||
radTextBoxControl_InstallKey.Text = modpackInfo.ExtrasKey;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -110,7 +108,7 @@ public partial class Form1
|
||||
|
||||
if (string.IsNullOrWhiteSpace(RadTextBoxControl_ModpackConfig.Text) && !string.IsNullOrWhiteSpace(modpackInfo?.ConfigUrl))
|
||||
LoadUpdateConfigFile(modpackInfo.ConfigUrl);
|
||||
else
|
||||
else if (IsUpdateConfigLoaded())
|
||||
RadButton_CheckForUpdates.PerformClick();
|
||||
}
|
||||
else
|
||||
@@ -119,24 +117,31 @@ public partial class Form1
|
||||
|
||||
private void LoadUpdateConfigFile(string filePath)
|
||||
{
|
||||
static ModpackConfig loadConfig(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ModpackConfig.LoadFromUrl(filePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
RadTextBoxControl_ModpackConfig.Text = filePath;
|
||||
|
||||
try
|
||||
if (!string.IsNullOrWhiteSpace(filePath) && loadConfig(filePath) is ModpackConfig modpackConfig)
|
||||
{
|
||||
if (IsUpdateConfigLoaded())
|
||||
updateConfig = ModpackConfig.LoadFromUrl(filePath);
|
||||
if (updateConfig.Maintenance && !updateOptions.IgnoreMaintenance)
|
||||
SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SvgImageSize.Small));
|
||||
else
|
||||
RadButton_CheckForUpdates.PerformClick();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RadTextBoxControl_ModpackConfig.Text = string.Empty;
|
||||
}
|
||||
|
||||
if (updateConfig != null && updateConfig.Maintenance && !updateOptions.IgnoreMaintenance)
|
||||
SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SvgImageSize.Small));
|
||||
else if (IsMinecaftProfileLoaded())
|
||||
RadButton_CheckForUpdates.PerformClick();
|
||||
else
|
||||
{
|
||||
ClearStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExecuteUpdate(bool doInstall)
|
||||
@@ -150,6 +155,10 @@ public partial class Form1
|
||||
{
|
||||
SetStatus(LangRes.StatusText_CheckingForUpdates, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small));
|
||||
|
||||
// Check for extras once again
|
||||
modpackInfo.ExtrasKey = radTextBoxControl_InstallKey.Text.Trim();
|
||||
updateOptions.IncludeExtras = AppFeatures.AllowExtras.IsEnabled(new AllowExtrasFeatureContext(modpackInfo, updateConfig));
|
||||
|
||||
try
|
||||
{
|
||||
lastUpdateCheckResult = await updater.Check(updateOptions);
|
||||
@@ -214,26 +223,24 @@ public partial class Form1
|
||||
private void ButtonX_SearchMinecraftProfile_Click(object sender, EventArgs e)
|
||||
{
|
||||
var ofd = new RadOpenFolderDialog();
|
||||
|
||||
if (ofd.ShowDialog(this) == DialogResult.OK)
|
||||
LoadMinecraftProfile(ofd.FileName);
|
||||
}
|
||||
|
||||
private void ButtonX_SearchUpdateConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
var ofd = new RadOpenFileDialog() { Filter = FiledialogFilters.JSON_Display + "|" + FiledialogFilters.JSON_Filter };
|
||||
|
||||
if (ofd.ShowDialog(this) == DialogResult.OK)
|
||||
LoadUpdateConfigFile(ofd.FileName);
|
||||
}
|
||||
|
||||
private void RadButton_PasteModpackConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
string text = Clipboard.GetText();
|
||||
var text = Clipboard.GetText();
|
||||
if (text.StartsWith("http"))
|
||||
LoadUpdateConfigFile(text);
|
||||
}
|
||||
|
||||
private void RadButton_PasteInstallKey_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (modpackInfo == null)
|
||||
return;
|
||||
radTextBoxControl_InstallKey.Text = modpackInfo.ExtrasKey = Clipboard.GetText();
|
||||
}
|
||||
|
||||
private void RadButton_RefreshConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadUpdateConfigFile(RadTextBoxControl_ModpackConfig.Text);
|
||||
@@ -259,15 +266,12 @@ public partial class Form1
|
||||
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
AppConfig.Instance.LastMinecraftProfilePath = RadTextBoxControl_MinecraftProfileFolder.Text;
|
||||
AppConfig.Instance.LastConfigFilePath = RadTextBoxControl_ModpackConfig.Text;
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Directory.Exists(AppConfig.Instance.LastMinecraftProfilePath))
|
||||
LoadMinecraftProfile(AppConfig.Instance.LastMinecraftProfilePath);
|
||||
if (!string.IsNullOrWhiteSpace(AppConfig.Instance.LastConfigFilePath))
|
||||
LoadUpdateConfigFile(AppConfig.Instance.LastConfigFilePath);
|
||||
}
|
||||
|
||||
private async void Form1_Shown(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user