Skip to content

Commit

Permalink
update GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ca1e committed Apr 20, 2022
1 parent 4c6a092 commit 9fb22b6
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 44 deletions.
5 changes: 5 additions & 0 deletions PKHeX_Hunter_Plugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ public bool TryLoadFile(string filePath)
}
}
}

namespace System.Runtime.CompilerServices
{
internal class IsExternalInit { }
}
60 changes: 29 additions & 31 deletions PKHeX_Hunter_Plugin/Searcher.Designer.cs

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

32 changes: 19 additions & 13 deletions PKHeX_Hunter_Plugin/Searcher.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using PKHeX.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -39,14 +40,29 @@ private void BindingData()
RNGMethod = (MethodType)Enum.Parse(typeof(MethodType), this.methodTypeBox.SelectedItem.ToString(), false);
};
this.methodTypeBox.SelectedIndex = 0;

CB_Species.InitializeBinding();
CB_GameOrigin.InitializeBinding();

var Any = new ComboItem(MessageStrings.MsgAny, -1);
var DS_Species = new List<ComboItem>(GameInfo.SpeciesDataSource);
DS_Species.RemoveAt(0);
CB_Species.DataSource = DS_Species;

var DS_Version = new List<ComboItem>(GameInfo.VersionDataSource);
DS_Version.Insert(0, Any); CB_GameOrigin.DataSource = DS_Version;

CB_Species.SelectedIndex = 0;
CB_GameOrigin.SelectedIndex = 0;
}

private void show(PkmEntry pe)
{
int species = GetSpecies();
var vers = GetSearchVer();
int species = WinFormsUtil.GetIndex(CB_Species);
var Version = WinFormsUtil.GetIndex(CB_GameOrigin);

var encs = EncounterUtil.SearchEncounters(species, 0, SAV.SAV.BlankPKM, (GameVersion)Version);

var encs = EncounterUtil.SearchEncounters(species, 0, SAV.SAV.BlankPKM, vers);
// skip egg
var enc = encs.Where(z => z.EggEncounter == false).First();

Expand Down Expand Up @@ -105,16 +121,6 @@ private int TypeXor()
};
}

private int GetSpecies()
{
return RNGMethod switch
{
MethodType.Method1 => 285,
MethodType.Roaming8b => radioButton2.Checked ? 488 : 481,
_ => throw new NotSupportedException(),
};
}

private GameVersion GetSearchVer()
{
return RNGMethod switch
Expand Down
26 changes: 26 additions & 0 deletions PKHeX_Hunter_Plugin/WinFormsUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using PKHeX.Core;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace PKHeX_Hunter_Plugin
{
public static class WinFormsUtil
{
internal static int GetIndex(ListControl cb)
{
return (int)(cb.SelectedValue ?? 0);
}

public static void InitializeBinding(this ListControl control)
{
control.DisplayMember = nameof(ComboItem.Text);
control.ValueMember = nameof(ComboItem.Value);
}
}
}

0 comments on commit 9fb22b6

Please sign in to comment.