public void AddSlave(PokemonBoxViewer boxSlave) { this.boxSlaves.Add(boxSlave); boxSlave.master = this; pokeBoxControlMaster.AddSlave(boxSlave.pokeBoxControlMaster); boxSlave.pokeBoxControlMaster.ClearSlaves(); pokeBoxControlMaster.AddSlave(boxSlave.pokeBoxControlParty); }
private void FindNextGameIndex(PokemonBoxViewer boxViewer, int invalidGameIndex1, int invalidRow1, int invalidGameIndex2, int invalidRow2) { // Check if we don't need to change things if (boxViewer.ComboBoxGames.SelectedGameIndex != -2) { int index = boxViewer.ComboBoxGames.SelectedGameIndex; int row = boxViewer.ComboBoxRows.SelectedIndex; if (boxViewer.ComboBoxGames.SelectedGameSave is ManagerGameSave) { if ((index != invalidGameIndex1 || row != invalidRow1) && (index != invalidGameIndex2 || row != invalidRow2)) { return; } else { for (int j = 0; j < (PokeManager.GetGameSaveAt(index) as ManagerGameSave).NumPokePCRows; j++) { if ((index != invalidGameIndex1 || j != invalidRow1) && (index != invalidGameIndex2 || j != invalidRow2)) { boxViewer.ComboBoxGames.SelectedGameIndex = index; boxViewer.comboBoxRows.SelectedIndex = j; break; //boxViewer.LoadGame(PokeManager.GetGameSaveAt(i), pokemonViewer, i, j); } } } } else if (index != invalidGameIndex1 && index != invalidGameIndex2) { return; } } bool finished = false; for (int i = -1; i < PokeManager.NumGameSaves && !finished; i++) { if (PokeManager.GetGameSaveAt(i) is ManagerGameSave) { for (int j = 0; j < (PokeManager.GetGameSaveAt(i) as ManagerGameSave).NumPokePCRows; j++) { if ((i != invalidGameIndex1 || j != invalidRow1) && (i != invalidGameIndex2 || j != invalidRow2)) { boxViewer.ComboBoxGames.SelectedGameIndex = i; boxViewer.comboBoxRows.SelectedIndex = j; finished = true; break; //boxViewer.LoadGame(PokeManager.GetGameSaveAt(i), pokemonViewer, i, j); } } } else if (i != invalidGameIndex1 && i != invalidGameIndex2) { //boxViewer.LoadGame(PokeManager.GetGameSaveAt(i), pokemonViewer, i); boxViewer.ComboBoxGames.SelectedGameIndex = i; break; } } }
public void RefreshSelectedGameSaves(PokemonBoxViewer refresher = null, bool rowOnly = false) { int refreshIndex = 1; if (refresher == boxViewer2) { refreshIndex = 2; } if (refresher == boxViewer3) { refreshIndex = 3; } boxViewer2.SupressIndexChanged = true; boxViewer3.SupressIndexChanged = true; if (refreshIndex == 1) { boxViewer2.ComboBoxGames.ResetGameSaveVisibility(); boxViewer3.ComboBoxGames.ResetGameSaveVisibility(); FindNextGameIndex(boxViewer2, GameIndex, boxViewer1.comboBoxRows.SelectedIndex, boxViewer3.ComboBoxGames.SelectedGameIndex, boxViewer3.comboBoxRows.SelectedIndex); FindNextGameIndex(boxViewer3, GameIndex, boxViewer1.comboBoxRows.SelectedIndex, boxViewer2.ComboBoxGames.SelectedGameIndex, boxViewer2.comboBoxRows.SelectedIndex); if (!(gameSave is ManagerGameSave) || (gameSave as ManagerGameSave).NumPokePCRows == 1) { boxViewer2.ComboBoxGames.SetGameSaveVisible(GameIndex, false); boxViewer3.ComboBoxGames.SetGameSaveVisible(GameIndex, false); } } else if (refreshIndex == 2) { if (rowOnly) { FindNextRow(boxViewer1, refresher.ComboBoxGames.SelectedGameIndex, refresher.comboBoxRows.SelectedIndex, boxViewer3.ComboBoxGames.SelectedGameIndex, boxViewer3.comboBoxRows.SelectedIndex); } else { FindNextRow(refresher, GameIndex, boxViewer1.comboBoxRows.SelectedIndex, -2, -1); } FindNextGameIndex(boxViewer3, GameIndex, boxViewer1.comboBoxRows.SelectedIndex, boxViewer2.ComboBoxGames.SelectedGameIndex, boxViewer2.comboBoxRows.SelectedIndex); } else if (refreshIndex == 3) { if (rowOnly) { FindNextRow(boxViewer1, refresher.ComboBoxGames.SelectedGameIndex, refresher.comboBoxRows.SelectedIndex, -2, -1); } else { FindNextRow(refresher, GameIndex, boxViewer1.comboBoxRows.SelectedIndex, boxViewer2.ComboBoxGames.SelectedGameIndex, boxViewer2.comboBoxRows.SelectedIndex); } FindNextGameIndex(boxViewer2, GameIndex, boxViewer1.comboBoxRows.SelectedIndex, boxViewer3.ComboBoxGames.SelectedGameIndex, boxViewer3.comboBoxRows.SelectedIndex); } boxViewer2.SupressIndexChanged = false; boxViewer3.SupressIndexChanged = false; }
public bool IsValid(int gameIndex, int row, PokemonBoxViewer check1, PokemonBoxViewer check2 = null) { if (gameIndex == -1 && row >= GetNumRows(-1)) { return(false); } return((gameIndex != -2 && row != -1) && (gameIndex != GetGameIndex(check1) || row != GetRow(check1)) && (check2 == null || gameIndex != GetGameIndex(check2) || row != GetRow(check2))); }
public int GetNumRows(PokemonBoxViewer viewer) { IGameSave gameSave = PokeManager.GetGameSaveAt(GetGameIndex(viewer)); if (gameSave is ManagerGameSave) { return((gameSave as ManagerGameSave).NumPokePCRows); } return(1); }
public int GetRow(PokemonBoxViewer viewer) { if (viewer.ComboBoxRows.SelectedIndex >= GetNumRows(viewer)) { if (GetGameIndex(viewer) == -1) { return(-1); } return(0); } return(viewer.ComboBoxRows.SelectedIndex); }
public void OnRowSwitch(PokemonBoxViewer caller) { if (PokeManager.IsHoldingPokemon || PokeManager.HasSelection) { PokeManager.DropAll(); PokeManager.ClearSelectedPokemon(); PokeManager.RefreshUI(); } if (!PokeManager.Settings.AllowDoubleBoxRows) { int callerIndex = GetIndex(caller); PokemonBoxViewer[] priorities = new PokemonBoxViewer[3]; boxViewer1.SupressIndexChanged = true; boxViewer2.SupressIndexChanged = true; boxViewer3.SupressIndexChanged = true; priorities[0] = caller; if (callerIndex == 1) { if (IsValid(boxViewer2, caller) || !IsValid(boxViewer3, caller)) { priorities[1] = boxViewer2; priorities[2] = boxViewer3; } else { priorities[1] = boxViewer3; priorities[2] = boxViewer2; } } else if (callerIndex == 2) { priorities[1] = boxViewer1; priorities[2] = boxViewer3; } else { priorities[1] = boxViewer1; priorities[2] = boxViewer2; } MakeValid(priorities[1], priorities[0]); MakeValid(priorities[2], priorities[0], priorities[1]); boxViewer1.SupressIndexChanged = false; boxViewer2.SupressIndexChanged = false; boxViewer3.SupressIndexChanged = false; } else { } }
public int GetIndex(PokemonBoxViewer viewer) { if (viewer == boxViewer1) { return(1); } else if (viewer == boxViewer2) { return(2); } else { return(3); } }
public void FindAvailableRow(PokemonBoxViewer viewer, PokemonBoxViewer check1, PokemonBoxViewer check2 = null) { if (!IsValid(viewer, check1, check2)) { if (GetNumRows(viewer) > 1) { for (int newRow = 0; newRow < GetNumRows(viewer); newRow++) { if (IsValid(GetGameIndex(viewer), newRow, check1, check2)) { //viewer.ComboBoxRows.SelectedIndex = newRow; viewer.LoadUI(-2, newRow); return; } } } } }
public void SetFocus() { if (master != null && master.focus != null && master.focus != this) { master.focus.UnsetFocus(); } else if (focus != null && focus != this) { focus.UnsetFocus(); } if (master != null) { master.focus = this; } else { focus = this; } Background = new LinearGradientBrush(Color.FromRgb(0, 122, 204), Color.FromRgb(238, 238, 238), 0); }
private void FindNextRow(PokemonBoxViewer boxViewer, int invalidGameIndex1, int invalidRow1, int invalidGameIndex2, int invalidRow2) { int index = boxViewer.ComboBoxGames.SelectedGameIndex; int row = boxViewer.ComboBoxRows.SelectedIndex; if (PokeManager.GetGameSaveAt(index) is ManagerGameSave) { if ((index == invalidGameIndex1 && row == invalidRow1) || (index == invalidGameIndex2 && row == invalidRow2)) { for (int j = 0; j < (PokeManager.GetGameSaveAt(index) as ManagerGameSave).NumPokePCRows; j++) { if ((index != invalidGameIndex1 || j != invalidRow1) && (index != invalidGameIndex2 || j != invalidRow2)) { //boxViewer.LoadGame(boxViewer.ComboBoxGames.SelectedGameSave, pokemonViewer, boxViewer.ComboBoxGames.SelectedGameIndex, j); boxViewer.ComboBoxRows.SelectedIndex = j; break; } } } } }
public void MakeValid(PokemonBoxViewer viewer, PokemonBoxViewer check1, PokemonBoxViewer check2 = null) { if (!IsValid(viewer, check1, check2)) { if (GetNumRows(viewer) > 1) { for (int newRow = 0; newRow < GetNumRows(viewer); newRow++) { if (IsValid(GetGameIndex(viewer), newRow, check1, check2)) { //viewer.ComboBoxRows.SelectedIndex = newRow; viewer.LoadUI(-2, newRow); return; } } } for (int newGameIndex = -1; newGameIndex < PokeManager.NumGameSaves; newGameIndex++) { if (GetNumRows(newGameIndex) > 1) { for (int newRow = 0; newRow < GetNumRows(newGameIndex); newRow++) { if (IsValid(newGameIndex, newRow, check1, check2)) { //viewer.ComboBoxGames.SelectedGameIndex = newGameIndex; //viewer.ComboBoxRows.SelectedIndex = newRow; viewer.LoadUI(newGameIndex, newRow); return; } } } else if (IsValid(newGameIndex, 0, check1, check2)) { //viewer.ComboBoxGames.SelectedGameIndex = newGameIndex; viewer.LoadUI(newGameIndex); return; } } } }
public void SetFocus() { if (master != null && master.focus != null && master.focus != this) master.focus.UnsetFocus(); else if (focus != null && focus != this) focus.UnsetFocus(); if (master != null) master.focus = this; else focus = this; Background = new LinearGradientBrush(Color.FromRgb(0, 122, 204), Color.FromRgb(238, 238, 238), 0); }
public int GetGameIndex(PokemonBoxViewer viewer) { return(viewer == boxViewer1 ? PokeManager.ManagerWindow.GameIndex : viewer.ComboBoxGames.SelectedGameIndex); }
public bool IsValid(PokemonBoxViewer viewer) { return(GetGameIndex(viewer) != -2 && GetRow(viewer) != -1); }
public bool IsValid(PokemonBoxViewer viewer, PokemonBoxViewer check1, PokemonBoxViewer check2 = null) { return((GetGameIndex(viewer) != -2 && GetRow(viewer) != -1) && (GetGameIndex(viewer) != GetGameIndex(check1) || GetRow(viewer) != GetRow(check1)) && (check2 == null || GetGameIndex(viewer) != GetGameIndex(check2) || GetRow(viewer) != GetRow(check2))); }
public void OnGameSwitch(PokemonBoxViewer caller = null) { if (PokeManager.IsHoldingPokemon || PokeManager.HasSelection) { PokeManager.DropAll(); PokeManager.ClearSelectedPokemon(); PokeManager.RefreshUI(); } if (!PokeManager.Settings.AllowDoubleBoxRows) { if (caller == null) { caller = boxViewer1; } int callerIndex = GetIndex(caller); PokemonBoxViewer[] priorities = new PokemonBoxViewer[3]; boxViewer1.SupressIndexChanged = true; boxViewer2.SupressIndexChanged = true; boxViewer3.SupressIndexChanged = true; priorities[0] = boxViewer1; if (callerIndex == 1) { if (IsValid(boxViewer2, caller) || !IsValid(boxViewer3, caller)) { priorities[1] = boxViewer2; priorities[2] = boxViewer3; } else { priorities[1] = boxViewer3; priorities[2] = boxViewer2; } boxViewer2.ComboBoxGames.ResetGameSaveVisibility(); boxViewer3.ComboBoxGames.ResetGameSaveVisibility(); if (GetNumRows(caller) == 1) { boxViewer2.ComboBoxGames.SetGameSaveVisible(GameIndex, false); boxViewer3.ComboBoxGames.SetGameSaveVisible(GameIndex, false); } } else if (callerIndex == 2) { if (GetNumRows(caller) > 2) { priorities[1] = boxViewer3; priorities[2] = boxViewer2; } else { priorities[1] = boxViewer2; priorities[2] = boxViewer3; } //FindAvailableRow(priorities[1], priorities[1]); } else { if (GetNumRows(caller) > 2) { priorities[1] = boxViewer2; priorities[2] = boxViewer3; } else { priorities[1] = boxViewer3; priorities[2] = boxViewer2; } //FindAvailableRow(priorities[1], priorities[1]); } MakeValid(priorities[1], priorities[0]); MakeValid(priorities[2], priorities[0], priorities[1]); boxViewer1.SupressIndexChanged = false; boxViewer2.SupressIndexChanged = false; boxViewer3.SupressIndexChanged = false; } else { boxViewer2.ComboBoxGames.ResetGameSaveVisibility(); boxViewer3.ComboBoxGames.ResetGameSaveVisibility(); } }