Update to no longer automatically pop-up prompts to update
Change when to look for native services
This commit is contained in:
2022-09-01 23:17:38 +08:00
parent a70a3979e5
commit 43ff071250
3 changed files with 5488 additions and 5423 deletions

View File

@ -216,6 +216,7 @@ namespace GrasscutterTools.Forms
this.BtnSaveCustomCommand = new System.Windows.Forms.Button();
this.TxtCustomName = new System.Windows.Forms.TextBox();
this.TPHome = new System.Windows.Forms.TabPage();
this.LnkNewVersion = new System.Windows.Forms.LinkLabel();
this.LblAbout = new System.Windows.Forms.Label();
this.BtnOpenTextMap = new System.Windows.Forms.Button();
this.BtnOpenGachaBannerEditor = new System.Windows.Forms.Button();
@ -326,7 +327,6 @@ namespace GrasscutterTools.Forms
//
// TPRemoteCall
//
resources.ApplyResources(this.TPRemoteCall, "TPRemoteCall");
this.TPRemoteCall.Controls.Add(this.LnkLinks);
this.TPRemoteCall.Controls.Add(this.LnkGOODHelp);
this.TPRemoteCall.Controls.Add(this.LnkInventoryKamera);
@ -338,8 +338,10 @@ namespace GrasscutterTools.Forms
this.TPRemoteCall.Controls.Add(this.TxtHost);
this.TPRemoteCall.Controls.Add(this.BtnQueryServerStatus);
this.TPRemoteCall.Controls.Add(this.LblHost);
resources.ApplyResources(this.TPRemoteCall, "TPRemoteCall");
this.TPRemoteCall.Name = "TPRemoteCall";
this.TPRemoteCall.UseVisualStyleBackColor = true;
this.TPRemoteCall.Enter += new System.EventHandler(this.TPRemoteCall_Enter);
//
// LnkLinks
//
@ -434,15 +436,14 @@ namespace GrasscutterTools.Forms
//
// TPOpenCommandCheck
//
resources.ApplyResources(this.TPOpenCommandCheck, "TPOpenCommandCheck");
this.TPOpenCommandCheck.Controls.Add(this.TPPlayerCheck);
this.TPOpenCommandCheck.Controls.Add(this.TPConsoleCheck);
resources.ApplyResources(this.TPOpenCommandCheck, "TPOpenCommandCheck");
this.TPOpenCommandCheck.Name = "TPOpenCommandCheck";
this.TPOpenCommandCheck.SelectedIndex = 0;
//
// TPPlayerCheck
//
resources.ApplyResources(this.TPPlayerCheck, "TPPlayerCheck");
this.TPPlayerCheck.Controls.Add(this.LnkRCHelp);
this.TPPlayerCheck.Controls.Add(this.NUDRemotePlayerId);
this.TPPlayerCheck.Controls.Add(this.BtnConnectOpenCommand);
@ -450,6 +451,7 @@ namespace GrasscutterTools.Forms
this.TPPlayerCheck.Controls.Add(this.BtnSendVerificationCode);
this.TPPlayerCheck.Controls.Add(this.NUDVerificationCode);
this.TPPlayerCheck.Controls.Add(this.LblRemotePlayerId);
resources.ApplyResources(this.TPPlayerCheck, "TPPlayerCheck");
this.TPPlayerCheck.Name = "TPPlayerCheck";
this.TPPlayerCheck.UseVisualStyleBackColor = true;
//
@ -521,11 +523,11 @@ namespace GrasscutterTools.Forms
//
// TPConsoleCheck
//
resources.ApplyResources(this.TPConsoleCheck, "TPConsoleCheck");
this.TPConsoleCheck.Controls.Add(this.BtnConsoleConnect);
this.TPConsoleCheck.Controls.Add(this.TxtToken);
this.TPConsoleCheck.Controls.Add(this.LblToken);
this.TPConsoleCheck.Controls.Add(this.LblConsoleTip);
resources.ApplyResources(this.TPConsoleCheck, "TPConsoleCheck");
this.TPConsoleCheck.Name = "TPConsoleCheck";
this.TPConsoleCheck.UseVisualStyleBackColor = true;
//
@ -570,10 +572,10 @@ namespace GrasscutterTools.Forms
//
// TPAbout
//
resources.ApplyResources(this.TPAbout, "TPAbout");
this.TPAbout.Controls.Add(this.GrasscutterToolsSupport);
this.TPAbout.Controls.Add(this.LnkGithub);
this.TPAbout.Controls.Add(this.LblSupportDescription);
resources.ApplyResources(this.TPAbout, "TPAbout");
this.TPAbout.Name = "TPAbout";
this.TPAbout.UseVisualStyleBackColor = true;
//
@ -598,10 +600,10 @@ namespace GrasscutterTools.Forms
//
// TPManage
//
resources.ApplyResources(this.TPManage, "TPManage");
this.TPManage.Controls.Add(this.GrpBanPlayer);
this.TPManage.Controls.Add(this.GrpAccount);
this.TPManage.Controls.Add(this.GrpPermission);
resources.ApplyResources(this.TPManage, "TPManage");
this.TPManage.Name = "TPManage";
this.TPManage.UseVisualStyleBackColor = true;
//
@ -619,8 +621,8 @@ namespace GrasscutterTools.Forms
//
// DTPBanEndTime
//
resources.ApplyResources(this.DTPBanEndTime, "DTPBanEndTime");
this.DTPBanEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Short;
resources.ApplyResources(this.DTPBanEndTime, "DTPBanEndTime");
this.DTPBanEndTime.MaxDate = new System.DateTime(2034, 12, 31, 0, 0, 0, 0);
this.DTPBanEndTime.MinDate = new System.DateTime(2022, 6, 28, 0, 0, 0, 0);
this.DTPBanEndTime.Name = "DTPBanEndTime";
@ -642,8 +644,8 @@ namespace GrasscutterTools.Forms
//
// TxtBanReason
//
resources.ApplyResources(this.TxtBanReason, "TxtBanReason");
this.TxtBanReason.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
resources.ApplyResources(this.TxtBanReason, "TxtBanReason");
this.TxtBanReason.Maximum = 0F;
this.TxtBanReason.Minimum = 0F;
this.TxtBanReason.Name = "TxtBanReason";
@ -750,10 +752,10 @@ namespace GrasscutterTools.Forms
//
// CmbPerm
//
resources.ApplyResources(this.CmbPerm, "CmbPerm");
this.CmbPerm.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
this.CmbPerm.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
this.CmbPerm.FormattingEnabled = true;
resources.ApplyResources(this.CmbPerm, "CmbPerm");
this.CmbPerm.Name = "CmbPerm";
//
// NUDPermUID
@ -815,7 +817,6 @@ namespace GrasscutterTools.Forms
//
// TPScene
//
resources.ApplyResources(this.TPScene, "TPScene");
this.TPScene.Controls.Add(this.TxtSceneFilter);
this.TPScene.Controls.Add(this.ChkIncludeSceneId);
this.TPScene.Controls.Add(this.LblTpZ);
@ -830,6 +831,7 @@ namespace GrasscutterTools.Forms
this.TPScene.Controls.Add(this.LblSceneDescription);
this.TPScene.Controls.Add(this.ListScenes);
this.TPScene.Controls.Add(this.LblTp);
resources.ApplyResources(this.TPScene, "TPScene");
this.TPScene.Name = "TPScene";
this.TPScene.UseVisualStyleBackColor = true;
//
@ -964,7 +966,6 @@ namespace GrasscutterTools.Forms
//
// TPItem
//
resources.ApplyResources(this.TPItem, "TPItem");
this.TPItem.Controls.Add(this.LblClearGiveItemLogs);
this.TPItem.Controls.Add(this.BtnSaveGiveItemLog);
this.TPItem.Controls.Add(this.BtnRemoveGiveItemLog);
@ -977,6 +978,7 @@ namespace GrasscutterTools.Forms
this.TPItem.Controls.Add(this.NUDGameItemAmout);
this.TPItem.Controls.Add(this.NUDGameItemLevel);
this.TPItem.Controls.Add(this.LblGiveCommandDescription);
resources.ApplyResources(this.TPItem, "TPItem");
this.TPItem.Name = "TPItem";
this.TPItem.UseVisualStyleBackColor = true;
//
@ -1094,7 +1096,6 @@ namespace GrasscutterTools.Forms
//
// TPWeapon
//
resources.ApplyResources(this.TPWeapon, "TPWeapon");
this.TPWeapon.Controls.Add(this.TxtWeaponFilter);
this.TPWeapon.Controls.Add(this.LblWeaponDescription);
this.TPWeapon.Controls.Add(this.LblWeaponRefinement);
@ -1104,6 +1105,7 @@ namespace GrasscutterTools.Forms
this.TPWeapon.Controls.Add(this.NUDWeaponAmout);
this.TPWeapon.Controls.Add(this.NUDWeaponLevel);
this.TPWeapon.Controls.Add(this.ListWeapons);
resources.ApplyResources(this.TPWeapon, "TPWeapon");
this.TPWeapon.Name = "TPWeapon";
this.TPWeapon.UseVisualStyleBackColor = true;
//
@ -1200,10 +1202,10 @@ namespace GrasscutterTools.Forms
//
// TPStats
//
resources.ApplyResources(this.TPStats, "TPStats");
this.TPStats.Controls.Add(this.GrpSetStats);
this.TPStats.Controls.Add(this.GrpTalentLevel);
this.TPStats.Controls.Add(this.LblStatsDescription);
resources.ApplyResources(this.TPStats, "TPStats");
this.TPStats.Name = "TPStats";
this.TPStats.UseVisualStyleBackColor = true;
//
@ -1235,9 +1237,9 @@ namespace GrasscutterTools.Forms
//
// LblStatTip
//
resources.ApplyResources(this.LblStatTip, "LblStatTip");
this.LblStatTip.AutoEllipsis = true;
this.LblStatTip.ForeColor = System.Drawing.SystemColors.GrayText;
resources.ApplyResources(this.LblStatTip, "LblStatTip");
this.LblStatTip.Name = "LblStatTip";
//
// LblStatPercent
@ -1263,9 +1265,9 @@ namespace GrasscutterTools.Forms
//
// CmbStat
//
resources.ApplyResources(this.CmbStat, "CmbStat");
this.CmbStat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CmbStat.FormattingEnabled = true;
resources.ApplyResources(this.CmbStat, "CmbStat");
this.CmbStat.Name = "CmbStat";
this.CmbStat.SelectedIndexChanged += new System.EventHandler(this.SetStatsInputChanged);
//
@ -1325,7 +1327,6 @@ namespace GrasscutterTools.Forms
//
// TPAvatar
//
resources.ApplyResources(this.TPAvatar, "TPAvatar");
this.TPAvatar.Controls.Add(this.BtnGiveAllChar);
this.TPAvatar.Controls.Add(this.LblConstellationTip);
this.TPAvatar.Controls.Add(this.LblAvatarConstellation);
@ -1335,6 +1336,7 @@ namespace GrasscutterTools.Forms
this.TPAvatar.Controls.Add(this.LblAvatarLevel);
this.TPAvatar.Controls.Add(this.NUDAvatarLevel);
this.TPAvatar.Controls.Add(this.CmbAvatar);
resources.ApplyResources(this.TPAvatar, "TPAvatar");
this.TPAvatar.Name = "TPAvatar";
this.TPAvatar.UseVisualStyleBackColor = true;
//
@ -1420,7 +1422,6 @@ namespace GrasscutterTools.Forms
//
// TPSpawn
//
resources.ApplyResources(this.TPSpawn, "TPSpawn");
this.TPSpawn.Controls.Add(this.LblClearSpawnLogs);
this.TPSpawn.Controls.Add(this.BtnSaveSpawnLog);
this.TPSpawn.Controls.Add(this.BtnRemoveSpawnLog);
@ -1433,6 +1434,7 @@ namespace GrasscutterTools.Forms
this.TPSpawn.Controls.Add(this.NUDEntityLevel);
this.TPSpawn.Controls.Add(this.TxtEntityFilter);
this.TPSpawn.Controls.Add(this.ListEntity);
resources.ApplyResources(this.TPSpawn, "TPSpawn");
this.TPSpawn.Name = "TPSpawn";
this.TPSpawn.UseVisualStyleBackColor = true;
//
@ -1573,13 +1575,13 @@ namespace GrasscutterTools.Forms
//
// TPQuest
//
resources.ApplyResources(this.TPQuest, "TPQuest");
this.TPQuest.Controls.Add(this.GrpQuestFilters);
this.TPQuest.Controls.Add(this.BtnFinishQuest);
this.TPQuest.Controls.Add(this.BtnAddQuest);
this.TPQuest.Controls.Add(this.LblQuestDescription);
this.TPQuest.Controls.Add(this.TxtQuestFilter);
this.TPQuest.Controls.Add(this.ListQuest);
resources.ApplyResources(this.TPQuest, "TPQuest");
this.TPQuest.Name = "TPQuest";
this.TPQuest.UseVisualStyleBackColor = true;
//
@ -1651,7 +1653,6 @@ namespace GrasscutterTools.Forms
//
// TPArtifact
//
resources.ApplyResources(this.TPArtifact, "TPArtifact");
this.TPArtifact.Controls.Add(this.LblArtifactLevelTip);
this.TPArtifact.Controls.Add(this.BtnAddSubAttr);
this.TPArtifact.Controls.Add(this.LblArtifactName);
@ -1671,6 +1672,7 @@ namespace GrasscutterTools.Forms
this.TPArtifact.Controls.Add(this.NUDArtifactLevel);
this.TPArtifact.Controls.Add(this.LblArtifactStars);
this.TPArtifact.Controls.Add(this.NUDArtifactStars);
resources.ApplyResources(this.TPArtifact, "TPArtifact");
this.TPArtifact.Name = "TPArtifact";
this.TPArtifact.UseVisualStyleBackColor = true;
//
@ -1836,7 +1838,6 @@ namespace GrasscutterTools.Forms
//
// TPCustom
//
resources.ApplyResources(this.TPCustom, "TPCustom");
this.TPCustom.Controls.Add(this.BtnExportCustomCommands);
this.TPCustom.Controls.Add(this.BtnLoadCustomCommands);
this.TPCustom.Controls.Add(this.LblCustomName);
@ -1844,6 +1845,7 @@ namespace GrasscutterTools.Forms
this.TPCustom.Controls.Add(this.BtnRemoveCustomCommand);
this.TPCustom.Controls.Add(this.BtnSaveCustomCommand);
this.TPCustom.Controls.Add(this.TxtCustomName);
resources.ApplyResources(this.TPCustom, "TPCustom");
this.TPCustom.Name = "TPCustom";
this.TPCustom.UseVisualStyleBackColor = true;
//
@ -1907,15 +1909,23 @@ namespace GrasscutterTools.Forms
//
// TPHome
//
resources.ApplyResources(this.TPHome, "TPHome");
this.TPHome.Controls.Add(this.LnkNewVersion);
this.TPHome.Controls.Add(this.LblAbout);
this.TPHome.Controls.Add(this.BtnOpenTextMap);
this.TPHome.Controls.Add(this.BtnOpenGachaBannerEditor);
this.TPHome.Controls.Add(this.GrasscutterToolsIcon);
this.TPHome.Controls.Add(this.GrpSettings);
resources.ApplyResources(this.TPHome, "TPHome");
this.TPHome.Name = "TPHome";
this.TPHome.UseVisualStyleBackColor = true;
//
// LnkNewVersion
//
resources.ApplyResources(this.LnkNewVersion, "LnkNewVersion");
this.LnkNewVersion.Name = "LnkNewVersion";
this.LnkNewVersion.TabStop = true;
this.LnkNewVersion.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LnkNewVersion_LinkClicked);
//
// LblAbout
//
resources.ApplyResources(this.LblAbout, "LblAbout");
@ -1963,9 +1973,9 @@ namespace GrasscutterTools.Forms
//
// CmbGcVersions
//
resources.ApplyResources(this.CmbGcVersions, "CmbGcVersions");
this.CmbGcVersions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CmbGcVersions.FormattingEnabled = true;
resources.ApplyResources(this.CmbGcVersions, "CmbGcVersions");
this.CmbGcVersions.Name = "CmbGcVersions";
//
// ChkTopMost
@ -1976,9 +1986,9 @@ namespace GrasscutterTools.Forms
//
// CmbLanguage
//
resources.ApplyResources(this.CmbLanguage, "CmbLanguage");
this.CmbLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CmbLanguage.FormattingEnabled = true;
resources.ApplyResources(this.CmbLanguage, "CmbLanguage");
this.CmbLanguage.Name = "CmbLanguage";
//
// LblLanguage
@ -2331,5 +2341,6 @@ namespace GrasscutterTools.Forms
private System.Windows.Forms.Label LblPermNewCommandTip;
private System.Windows.Forms.Button BtnPermClear;
private System.Windows.Forms.Button BtnPermList;
private System.Windows.Forms.LinkLabel LnkNewVersion;
}
}

View File

@ -46,9 +46,17 @@ namespace GrasscutterTools.Forms
{
InitializeComponent();
Icon = Resources.IconGrasscutter;
// 加载版本信息
LoadVersion();
// 加载设置
LoadSettings();
LoadUpdate();
#if !DEBUG // 仅正式版
// 检查更新,但不要弹窗
Task.Run(async () => { try { await LoadUpdate(); } catch { /* 启动时检查更新,忽略异常 */ }});
#endif
}
private void FormMain_Load(object sender, EventArgs e)
@ -142,41 +150,22 @@ namespace GrasscutterTools.Forms
}
}
private void LoadUpdate()
private ReleaseAPI.ReleaseInfo LastestInfo = null;
private Version lastestVersion = null;
private async Task LoadUpdate()
{
#if !DEBUG
Task.Run(async () =>
var info = await ReleaseAPI.GetReleasesLastest("jie65535", "GrasscutterCommandGenerator");
if (Version.TryParse(info.TagName.Substring(1), out lastestVersion) && AppVersion < lastestVersion)
{
try
{
await Task.Delay(5000);
var info = await ReleaseAPI.GetReleasesLastest("jie65535", "GrasscutterCommandGenerator");
if (Version.TryParse(info.TagName.Substring(1), out Version lastestVersion) && AppVersion < lastestVersion)
{
if (!string.IsNullOrEmpty(Settings.Default.CheckedLastVersion)
&& Version.TryParse(Settings.Default.CheckedLastVersion, out Version checkedVersion)
&& checkedVersion >= lastestVersion)
return;
BeginInvoke(new Action(() =>
{
var r = MessageBox.Show(
string.Format(Resources.NewVersionInfo, info.Name, info.CraeteTime.ToLocalTime(), info.Body),
Resources.CheckToNewVersion,
MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
if (r == DialogResult.Yes)
OpenURL(info.Url);
else if (r == DialogResult.No)
Settings.Default.CheckedLastVersion = lastestVersion.ToString();
}));
}
}
catch (Exception)
{
throw;
}
});
#endif
if (!string.IsNullOrEmpty(Settings.Default.CheckedLastVersion)
&& Version.TryParse(Settings.Default.CheckedLastVersion, out Version checkedVersion)
&& checkedVersion >= lastestVersion)
return;
LnkNewVersion.Text = Resources.CheckToNewVersion;
LnkNewVersion.Visible = true;
LastestInfo = info;
}
}
#endregion - Init -
@ -291,6 +280,31 @@ namespace GrasscutterTools.Forms
ChangeTPArtifact();
}
/// <summary>
/// 点击检查更新时触发
/// </summary>
private void LnkNewVersion_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (LastestInfo != null)
{
var r = MessageBox.Show(
string.Format(Resources.NewVersionInfo, LastestInfo.Name, LastestInfo.CraeteTime.ToLocalTime(), LastestInfo.Body),
Resources.CheckToNewVersion,
MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
if (r == DialogResult.Yes)
OpenURL(LastestInfo.Url);
else if (r == DialogResult.No)
Settings.Default.CheckedLastVersion = lastestVersion.ToString();
}
else
{
// 没有更新,隐藏
LnkNewVersion.Visible = false;
}
}
#endregion - Home -
#region - Custom -
@ -1647,29 +1661,16 @@ namespace GrasscutterTools.Forms
private OpenCommandAPI OC;
/// <summary>
/// 初始化开放命令
/// 进入远程页面时触发
/// </summary>
private void InitOpenCommand()
private void TPRemoteCall_Enter(object sender, EventArgs e)
{
NUDRemotePlayerId.Value = Settings.Default.RemoteUid;
TxtHost.Text = Settings.Default.Host;
if (!string.IsNullOrEmpty(Settings.Default.Host) && !string.IsNullOrEmpty(Settings.Default.TokenCache))
{
OC = new OpenCommandAPI(Settings.Default.Host, Settings.Default.TokenCache);
TxtToken.Text = Settings.Default.TokenCache;
Task.Run(async () =>
{
await Task.Delay(1000);
BeginInvoke(new Action(() => ShowTip(Resources.TokenRestoredFromCache, BtnInvokeOpenCommand)));
});
}
else
{
#if !DEBUG
if (string.IsNullOrEmpty(Settings.Default.Host) || string.IsNullOrEmpty(Settings.Default.TokenCache))
{
// 自动尝试查询本地服务端地址,降低使用门槛
Task.Run(async () =>
{
await Task.Delay(5000);
var localhosts = new string[] {
"http://127.0.0.1:443",
"https://127.0.0.1",
@ -1693,7 +1694,26 @@ namespace GrasscutterTools.Forms
}
}
});
}
#endif
}
/// <summary>
/// 初始化开放命令
/// </summary>
private void InitOpenCommand()
{
NUDRemotePlayerId.Value = Settings.Default.RemoteUid;
TxtHost.Text = Settings.Default.Host;
if (!string.IsNullOrEmpty(Settings.Default.Host) && !string.IsNullOrEmpty(Settings.Default.TokenCache))
{
OC = new OpenCommandAPI(Settings.Default.Host, Settings.Default.TokenCache);
TxtToken.Text = Settings.Default.TokenCache;
Task.Run(async () =>
{
await Task.Delay(1000);
BeginInvoke(new Action(() => ShowTip(Resources.TokenRestoredFromCache, BtnInvokeOpenCommand)));
});
}
}
@ -2084,5 +2104,6 @@ namespace GrasscutterTools.Forms
}
#endregion - Quests -
}
}

File diff suppressed because it is too large Load Diff