Skip to content

Commit

Permalink
Add sort to resource viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
laqieer committed Sep 8, 2024
1 parent 50f3bc1 commit f727c93
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 11 deletions.
42 changes: 39 additions & 3 deletions FEBuilderGBA/EtcCacheResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace FEBuilderGBA
class EtcCacheResource
{
Dictionary<string, string> Resource;

public EtcCacheResource()
{
this.Resource = U.LoadTSVResourcePair2(U.ConfigEtcFilename("resource_"), false);
Expand All @@ -23,12 +24,47 @@ public int Count
}
}

public string ListAll()
public string ListAll(int sortKey = 0, bool reversed = false)
{
StringBuilder sb = new StringBuilder();
foreach (var pair in this.Resource)
switch (sortKey)
{
sb.AppendLine(pair.Key + "\t" + pair.Value);
case 1: // sort by category

if (reversed)
{
foreach (var pair in this.Resource.OrderByDescending(x => x.Key))
{
sb.AppendLine(pair.Key + "\t" + pair.Value);
}
}
else
{
foreach (var pair in this.Resource.OrderBy(x => x.Key))
{
sb.AppendLine(pair.Key + "\t" + pair.Value);
}
}
break;

case 0: // sort by date by default
default:

if (reversed)
{
foreach (var pair in this.Resource.Reverse())
{
sb.AppendLine(pair.Key + "\t" + pair.Value);
}
}
else
{
foreach (var pair in this.Resource)
{
sb.AppendLine(pair.Key + "\t" + pair.Value);
}
}
break;
}
return sb.ToString();
}
Expand Down
63 changes: 63 additions & 0 deletions FEBuilderGBA/ResourceForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions FEBuilderGBA/ResourceForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,33 @@ namespace FEBuilderGBA
{
public partial class ResourceForm : Form
{
private int sortKey = 0;
private bool reversed = false;
public ResourceForm()
{
InitializeComponent();

TextBoxEx info = new TextBoxEx();
info.Multiline = true;
info.Location = new Point(5, 5);
info.Size = new Size(600, 400);
info.ReadOnly = true;
info.ScrollBars = ScrollBars.Both;
info.Text = Program.ResourceCache.ListAll();
this.Controls.Add(info);
this.listBoxEx1.SelectedIndex = this.sortKey;
this.listBoxEx2.SelectedIndex = this.reversed ? 1 : 0;

UpdateResources();
}

private void UpdateResources()
{
this.resources.Text = Program.ResourceCache.ListAll(this.sortKey, this.reversed);
}

private void listBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
{
this.sortKey = this.listBoxEx1.SelectedIndex;
UpdateResources();
}

private void listBoxEx2_SelectedIndexChanged(object sender, EventArgs e)
{
this.reversed = this.listBoxEx2.SelectedIndex == 1;
UpdateResources();
}
}
}
11 changes: 11 additions & 0 deletions FEBuilderGBA/bin/Debug/config/translate/en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13831,3 +13831,14 @@ Map Skirmish Type
:いつでも入れるかどうか
Placement Flag

:日付順
By Date

:種類順
By Category

:昇順
Ascending

:降順
Descending
12 changes: 12 additions & 0 deletions FEBuilderGBA/bin/Debug/config/translate/zh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13830,3 +13830,15 @@ This is the destination which you will go to when ChapterID is completed.\r\nDif

:リソース
素材

:日付順
按日期

:種類順
按类别

:昇順
正序

:降順
逆序

0 comments on commit f727c93

Please sign in to comment.