Update page navigation

Add Achievement page
This commit is contained in:
2023-05-07 14:55:50 +08:00
parent c7d3e5021c
commit b8cfaf308d
22 changed files with 2599 additions and 2145 deletions

View File

@@ -34,6 +34,7 @@ namespace GrasscutterTools.Pages
{
Font = new Font("Microsoft YaHei UI", 9, GraphicsUnit.Point);
//Size = new Size(652, 245);
Dock = DockStyle.Fill;
Size = new Size(646, 239);
BackColor = Color.FromArgb(0xF9, 0xF9, 0xF9);
Margin = new Padding(0);
@@ -74,7 +75,7 @@ namespace GrasscutterTools.Pages
if (commands.IndexOf('|') == -1)
return await RunCommands(FormatCommand(commands));
else
return await RunCommands(commands.Split('|').Select(it => FormatCommand(it)).ToArray());
return await RunCommands(commands.Split('|').Select(FormatCommand).ToArray());
}
/// <summary>
@@ -83,7 +84,7 @@ namespace GrasscutterTools.Pages
/// </summary>
/// <param name="raw">原始输入</param>
/// <returns>格式化后可执行命令</returns>
private string FormatCommand(string raw)
private static string FormatCommand(string raw)
{
return raw.Trim().Replace("\\r", "\r").Replace("\\n", "\n");
}

View File

@@ -0,0 +1,201 @@
namespace GrasscutterTools.Pages
{
partial class PageAchievement
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ListAchievements = new System.Windows.Forms.ListBox();
this.GrpAchievements = new System.Windows.Forms.GroupBox();
this.TxtAchievementFilter = new System.Windows.Forms.TextBox();
this.LnkRevokeAll = new System.Windows.Forms.LinkLabel();
this.LnkGrantAll = new System.Windows.Forms.LinkLabel();
this.GrpAchievementCommands = new System.Windows.Forms.GroupBox();
this.NUDProgress = new System.Windows.Forms.NumericUpDown();
this.BtnProgress = new System.Windows.Forms.Button();
this.BtnRevoke = new System.Windows.Forms.Button();
this.BtnGrant = new System.Windows.Forms.Button();
this.GrpAchievements.SuspendLayout();
this.GrpAchievementCommands.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUDProgress)).BeginInit();
this.SuspendLayout();
//
// ListAchievements
//
this.ListAchievements.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ListAchievements.FormattingEnabled = true;
this.ListAchievements.ItemHeight = 17;
this.ListAchievements.Location = new System.Drawing.Point(6, 51);
this.ListAchievements.Name = "ListAchievements";
this.ListAchievements.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.ListAchievements.Size = new System.Drawing.Size(628, 106);
this.ListAchievements.TabIndex = 0;
//
// GrpAchievements
//
this.GrpAchievements.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.GrpAchievements.Controls.Add(this.TxtAchievementFilter);
this.GrpAchievements.Controls.Add(this.LnkRevokeAll);
this.GrpAchievements.Controls.Add(this.ListAchievements);
this.GrpAchievements.Controls.Add(this.LnkGrantAll);
this.GrpAchievements.Location = new System.Drawing.Point(3, 3);
this.GrpAchievements.Name = "GrpAchievements";
this.GrpAchievements.Size = new System.Drawing.Size(640, 167);
this.GrpAchievements.TabIndex = 1;
this.GrpAchievements.TabStop = false;
this.GrpAchievements.Text = "成就列表GC v1.4.7 起)";
//
// TxtAchievementFilter
//
this.TxtAchievementFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtAchievementFilter.Location = new System.Drawing.Point(6, 22);
this.TxtAchievementFilter.Name = "TxtAchievementFilter";
this.TxtAchievementFilter.Size = new System.Drawing.Size(628, 23);
this.TxtAchievementFilter.TabIndex = 8;
this.TxtAchievementFilter.TextChanged += new System.EventHandler(this.TxtAchievementFilter_TextChanged);
//
// LnkRevokeAll
//
this.LnkRevokeAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.LnkRevokeAll.AutoSize = true;
this.LnkRevokeAll.Location = new System.Drawing.Point(578, 0);
this.LnkRevokeAll.Name = "LnkRevokeAll";
this.LnkRevokeAll.Size = new System.Drawing.Size(56, 17);
this.LnkRevokeAll.TabIndex = 7;
this.LnkRevokeAll.TabStop = true;
this.LnkRevokeAll.Text = "全部撤销";
this.LnkRevokeAll.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LnkRevokeAll_LinkClicked);
//
// LnkGrantAll
//
this.LnkGrantAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.LnkGrantAll.AutoSize = true;
this.LnkGrantAll.Location = new System.Drawing.Point(516, 0);
this.LnkGrantAll.Name = "LnkGrantAll";
this.LnkGrantAll.Size = new System.Drawing.Size(56, 17);
this.LnkGrantAll.TabIndex = 6;
this.LnkGrantAll.TabStop = true;
this.LnkGrantAll.Text = "全部达成";
this.LnkGrantAll.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LnkGrantAll_LinkClicked);
//
// GrpAchievementCommands
//
this.GrpAchievementCommands.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.GrpAchievementCommands.Controls.Add(this.NUDProgress);
this.GrpAchievementCommands.Controls.Add(this.BtnProgress);
this.GrpAchievementCommands.Controls.Add(this.BtnRevoke);
this.GrpAchievementCommands.Controls.Add(this.BtnGrant);
this.GrpAchievementCommands.Location = new System.Drawing.Point(3, 176);
this.GrpAchievementCommands.Name = "GrpAchievementCommands";
this.GrpAchievementCommands.Size = new System.Drawing.Size(640, 60);
this.GrpAchievementCommands.TabIndex = 2;
this.GrpAchievementCommands.TabStop = false;
this.GrpAchievementCommands.Text = "成就控制(在列表中选择目标项)";
//
// NUDProgress
//
this.NUDProgress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NUDProgress.Location = new System.Drawing.Point(579, 25);
this.NUDProgress.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.NUDProgress.Name = "NUDProgress";
this.NUDProgress.Size = new System.Drawing.Size(55, 23);
this.NUDProgress.TabIndex = 5;
this.NUDProgress.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// BtnProgress
//
this.BtnProgress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.BtnProgress.Location = new System.Drawing.Point(473, 25);
this.BtnProgress.Name = "BtnProgress";
this.BtnProgress.Size = new System.Drawing.Size(100, 23);
this.BtnProgress.TabIndex = 4;
this.BtnProgress.Text = "修改进度";
this.BtnProgress.UseVisualStyleBackColor = true;
this.BtnProgress.Click += new System.EventHandler(this.BtnProgress_Click);
//
// BtnRevoke
//
this.BtnRevoke.Location = new System.Drawing.Point(112, 25);
this.BtnRevoke.Name = "BtnRevoke";
this.BtnRevoke.Size = new System.Drawing.Size(100, 23);
this.BtnRevoke.TabIndex = 1;
this.BtnRevoke.Text = "撤销";
this.BtnRevoke.UseVisualStyleBackColor = true;
this.BtnRevoke.Click += new System.EventHandler(this.BtnRevoke_Click);
//
// BtnGrant
//
this.BtnGrant.Location = new System.Drawing.Point(6, 25);
this.BtnGrant.Name = "BtnGrant";
this.BtnGrant.Size = new System.Drawing.Size(100, 23);
this.BtnGrant.TabIndex = 0;
this.BtnGrant.Text = "达成";
this.BtnGrant.UseVisualStyleBackColor = true;
this.BtnGrant.Click += new System.EventHandler(this.BtnGrant_Click);
//
// PageAchievement
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.GrpAchievementCommands);
this.Controls.Add(this.GrpAchievements);
this.Name = "PageAchievement";
this.GrpAchievements.ResumeLayout(false);
this.GrpAchievements.PerformLayout();
this.GrpAchievementCommands.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUDProgress)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox ListAchievements;
private System.Windows.Forms.GroupBox GrpAchievements;
private System.Windows.Forms.GroupBox GrpAchievementCommands;
private System.Windows.Forms.Button BtnProgress;
private System.Windows.Forms.Button BtnRevoke;
private System.Windows.Forms.Button BtnGrant;
private System.Windows.Forms.NumericUpDown NUDProgress;
private System.Windows.Forms.TextBox TxtAchievementFilter;
private System.Windows.Forms.LinkLabel LnkRevokeAll;
private System.Windows.Forms.LinkLabel LnkGrantAll;
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Linq;
using System.Windows.Forms;
using GrasscutterTools.Game;
using GrasscutterTools.Properties;
using GrasscutterTools.Utils;
namespace GrasscutterTools.Pages
{
internal partial class PageAchievement : BasePage
{
public PageAchievement()
{
InitializeComponent();
}
public override void OnLoad()
{
base.OnLoad();
UpdateList();
}
/// <summary>
/// 点击全部达成时触发
/// </summary>
private void LnkGrantAll_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
SetCommand("/achievement grantall");
}
/// <summary>
/// 点击全部撤销时触发
/// </summary>
private void LnkRevokeAll_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
SetCommand("/achievement revokeall");
}
/// <summary>
/// 更新列表显示内容
/// </summary>
private void UpdateList()
{
UIUtil.ListBoxFilter(ListAchievements, GameData.Achievements.Lines, TxtAchievementFilter.Text);
}
/// <summary>
/// 过滤器输入改变时触发
/// </summary>
private void TxtAchievementFilter_TextChanged(object sender, EventArgs e)
{
UpdateList();
}
/// <summary>
/// 获取所有选中项ID
/// </summary>
/// <returns>所有选中项ID如未选中返回 null</returns>
private int[] GetSelectedIds()
{
if (ListAchievements.SelectedItems.Count == 0)
return null;
var selectedIds = new int[ListAchievements.SelectedItems.Count];
var i = 0;
foreach (string item in ListAchievements.SelectedItems)
selectedIds[i++] = int.Parse(item.Substring(0, item.IndexOf(':')));
return selectedIds;
}
private void GenSelected(string command, string args = "")
{
var selectedIds = GetSelectedIds();
if (selectedIds == null)
{
MessageBox.Show(Resources.SelectAnyItem, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (selectedIds.Length == 1)
SetCommand(args == "" ? $"{command} {selectedIds[0]}" : $"{command} {selectedIds[0]} {args}");
else
SetCommand(string.Join(" | ", selectedIds.Select(it => args == "" ? $"{command} {it}" : $"{command} {it} {args}")));
}
private void BtnGrant_Click(object sender, EventArgs e)
{
GenSelected("/achievement grant");
}
private void BtnRevoke_Click(object sender, EventArgs e)
{
GenSelected("/achievement revoke");
}
private void BtnProgress_Click(object sender, EventArgs e)
{
GenSelected("/achievement progress", NUDProgress.Text);
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -85,12 +85,12 @@ namespace GrasscutterTools.Pages
#region - Check update -
private ReleaseAPI.ReleaseInfo LastestInfo = null;
private GithubHelper.ReleaseInfo LastestInfo = null;
private Version lastestVersion = null;
private async Task LoadUpdate()
{
var info = await ReleaseAPI.GetReleasesLastest("jie65535", "GrasscutterCommandGenerator");
var info = await GithubHelper.GetReleasesLatest("jie65535", "GrasscutterCommandGenerator");
if (Version.TryParse(info.TagName.Substring(1), out lastestVersion) && Common.AppVersion < lastestVersion)
{
if (!string.IsNullOrEmpty(Settings.Default.CheckedLastVersion)
@@ -179,7 +179,7 @@ namespace GrasscutterTools.Pages
if (LastestInfo != null)
{
var r = MessageBox.Show(
string.Format(Resources.NewVersionInfo, LastestInfo.Name, LastestInfo.CraeteTime.ToLocalTime(), LastestInfo.Body),
string.Format(Resources.NewVersionInfo, LastestInfo.Name, LastestInfo.CreateTime.ToLocalTime(), LastestInfo.Body),
Resources.CheckToNewVersion,
MessageBoxButtons.YesNo,
MessageBoxIcon.Information);