Skip to content

Commit

Permalink
Add filter to resource viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
laqieer committed Sep 8, 2024
1 parent f727c93 commit ee7edaa
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 16 deletions.
23 changes: 17 additions & 6 deletions FEBuilderGBA/EtcCacheResource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using FEBuilderGBA.Properties;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -24,23 +25,33 @@ public int Count
}
}

public string ListAll(int sortKey = 0, bool reversed = false)
public string[] MakeCategoryList()
{
return this.Resource.Keys.Select(x => x.Split('_')[0]).Distinct().ToArray();
}

public string ListAll(int sortKey = 0, bool reversed = false, string filter = "")
{
if (filter != "")
{
filter += "_";
}
Dictionary<string, string> filtered = this.Resource.Where(x => x.Key.StartsWith(filter)).ToDictionary(x => x.Key, x => x.Value);
StringBuilder sb = new StringBuilder();
switch (sortKey)
{
case 1: // sort by category

if (reversed)
{
foreach (var pair in this.Resource.OrderByDescending(x => x.Key))
foreach (var pair in filtered.OrderByDescending(x => x.Key))
{
sb.AppendLine(pair.Key + "\t" + pair.Value);
}
}
else
{
foreach (var pair in this.Resource.OrderBy(x => x.Key))
foreach (var pair in filtered.OrderBy(x => x.Key))
{
sb.AppendLine(pair.Key + "\t" + pair.Value);
}
Expand All @@ -52,14 +63,14 @@ public string ListAll(int sortKey = 0, bool reversed = false)

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

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

10 changes: 9 additions & 1 deletion FEBuilderGBA/ResourceForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ public partial class ResourceForm : Form
{
private int sortKey = 0;
private bool reversed = false;
private string filter = "";
public ResourceForm()
{
InitializeComponent();

this.listBoxEx1.SelectedIndex = this.sortKey;
this.listBoxEx2.SelectedIndex = this.reversed ? 1 : 0;
this.comboBoxEx1.Items.AddRange(Program.ResourceCache.MakeCategoryList());

UpdateResources();
}

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

private void listBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
Expand All @@ -38,5 +40,11 @@ private void listBoxEx2_SelectedIndexChanged(object sender, EventArgs e)
this.reversed = this.listBoxEx2.SelectedIndex == 1;
UpdateResources();
}

private void comboBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
{
this.filter = this.comboBoxEx1.Text;
UpdateResources();
}
}
}
2 changes: 1 addition & 1 deletion FEBuilderGBA/WorldMapImageFE7Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void ImportButton_Click(object sender, EventArgs e)
//ポインタの書き込み
this.AllWriteButton.PerformClick();

Program.ResourceCache.Update("WorldMap", bitmap.Tag.ToString());
Program.ResourceCache.Update("WorldMap_", bitmap.Tag.ToString());

WMPictureBox.Image = DrawWorldMap();
}
Expand Down
4 changes: 2 additions & 2 deletions FEBuilderGBA/WorldMapImageForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void ImportButton_Click(object sender, EventArgs e)
//ポインタの書き込み
this.AllWriteButton.PerformClick();

Program.ResourceCache.Update("WorldMap", bitmap.Tag.ToString());
Program.ResourceCache.Update("WorldMap_", bitmap.Tag.ToString());

WMPictureBox.Image = DrawWorldMap();
}
Expand Down Expand Up @@ -222,7 +222,7 @@ private void DarkMAPImportButton_Click(object sender, EventArgs e)
//ポインタの書き込み
this.AllWriteButton.PerformClick();

Program.ResourceCache.Update("WorldMap_Dark", bitmap.Tag.ToString());
Program.ResourceCache.Update("WorldMapDark_", bitmap.Tag.ToString());
}


Expand Down
3 changes: 3 additions & 0 deletions FEBuilderGBA/bin/Debug/config/translate/en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13842,3 +13842,6 @@ Ascending

:降順
Descending

:フィルター
Filter
3 changes: 3 additions & 0 deletions FEBuilderGBA/bin/Debug/config/translate/zh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13842,3 +13842,6 @@ This is the destination which you will go to when ChapterID is completed.\r\nDif

:降順
逆序

:フィルター
筛选

0 comments on commit ee7edaa

Please sign in to comment.