Skip to content

Commit

Permalink
Added support for additional evolution methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Nifyr committed Jan 30, 2024
1 parent 164c23d commit 58280e2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
39 changes: 33 additions & 6 deletions Forms/EvolutionEditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,42 @@ public EvolutionEditorForm(PokemonEditorForm pef)
Text = "Evolution Editor: " + p.GetName();

destinationDexIDColumn.DataSource = gameData.dexEntries.Select(d => d.GetName()).ToArray();
methodColumn.DataSource = evolutionMethods;
methodColumn.DataSource = GetEvolutionMethods();

p.evolutionPaths.ForEach(e => dataGridView.Rows.Add(new object[] { gameData.GetPokemon(e.destDexID, e.destFormID).GetName(), evolutionMethods[e.method] }));
p.evolutionPaths.ForEach(e => dataGridView.Rows.Add(new object[] { gameData.GetPokemon(e.destDexID, e.destFormID).GetName(), GetEvolutionMethods()[e.method] }));

RefreshEvolutionPathDisplay();

ActivateControls();
}

private List<string> GetEvolutionMethods()
{
List<string> ems = evolutionMethods.ToList();
int emCount = gameData.GetEvolutionMethodCount();
for (int i = ems.Count; i < emCount; i++)
ems.Add(i.ToString());
return ems;
}

private List<bool> GetLvReqMethods()
{
List<bool> lrms = lvReqMethods.ToList();
int emCount = gameData.GetEvolutionMethodCount();
for (int i = lrms.Count; i < emCount; i++)
lrms.Add(true);
return lrms;
}

private List<EvolutionParamType> GetParamTypes()
{
List<EvolutionParamType> pts = paramTypes.ToList();
int emCount = gameData.GetEvolutionMethodCount();
for (int i = pts.Count; i < emCount; i++)
pts.Add(EvolutionParamType.Byte);
return pts;
}

private void FocusEvoPathChanged(object sender, EventArgs e)
{
DeactivateControls();
Expand Down Expand Up @@ -109,7 +136,7 @@ private void CellEndEdit(object sender, DataGridViewCellEventArgs e)
}
if (e.ColumnIndex == 1)
{
int evoMethod = evolutionMethods.ToList().IndexOf((string)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
int evoMethod = GetEvolutionMethods().IndexOf((string)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
m.method = evoMethod == -1 ? (ushort)0 : (ushort)evoMethod;
m.parameter = 0;
}
Expand Down Expand Up @@ -142,7 +169,7 @@ private void RefreshEvolutionPathDisplay()
formIDComboBox.DataSource = gameData.dexEntries[m.destDexID].forms.Select((p, i) => i.ToString()).ToArray();
formIDComboBox.SelectedIndex = m.destFormID;

if (lvReqMethods[m.method])
if (GetLvReqMethods()[m.method])
{
label2.Visible = true;
lvReqNumericUpDown.Visible = true;
Expand All @@ -154,7 +181,7 @@ private void RefreshEvolutionPathDisplay()
lvReqNumericUpDown.Visible = false;
}

switch (paramTypes[m.method])
switch (GetParamTypes()[m.method])
{
case EvolutionParamType.None:
label3.Visible = false;
Expand Down Expand Up @@ -203,7 +230,7 @@ private void RefreshEvolutionPathDisplay()

case EvolutionParamType.Byte:
label3.Visible = true;
label3.Text = "Number";
label3.Text = "Argument";
evoParamComboBox.Visible = true;
evoParamComboBox.DataSource = Enumerable.Range(0, 256).Select(i => i.ToString()).ToArray();
evoParamComboBox.SelectedIndex = m.parameter;
Expand Down
8 changes: 8 additions & 0 deletions GlobalData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ public bool Uint16EncounterTables()
.Any(e => (uint)e.dexID > 0xFFFF))));
}

public int GetEvolutionMethodCount()
{
int emCount = modArgs != null ? modArgs.evolutionMethodCount : 0;
if (emCount == 0)
emCount = Math.Max(48, (int)personalEntries.SelectMany(p => p.evolutionPaths.Select(em => em.method)).Max());
return emCount;
}

public bool FormDescriptionsExist()
{
return messageFileSets.SelectMany(mfs => mfs.messageFiles)
Expand Down
9 changes: 2 additions & 7 deletions Structs/ModArgs.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImpostersOrdeal
namespace ImpostersOrdeal
{
public class ModArgs
{
public bool ugVersionsUnbounded;
public bool uint16UgTables;
public bool uint16EncounterTables;
public int evolutionMethodCount;
}
}

0 comments on commit 58280e2

Please sign in to comment.