Skip to content

Commit

Permalink
Add party Pokemon editing
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicpkmn11 committed Jun 26, 2019
1 parent 85b40aa commit 3521167
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 25 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions arm9/include/party.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef PARTY_H
#define PARTY_H

void manageParty(void);

#endif
4 changes: 2 additions & 2 deletions arm9/source/configMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ void configMenu(void) {
} else if(pressed & KEY_A) {
optionSelected = true;
} else if(pressed & KEY_B) {
setSpriteVisibility(bottomArrowID, false);
updateOam();
return;
} else if(pressed & KEY_TOUCH) {
touchRead(&touch);
Expand Down Expand Up @@ -143,6 +145,4 @@ void configMenu(void) {
setSpritePosition(bottomArrowID, textCP1[selection].x+getTextWidth(textCP1[selection].text), textCP1[selection].y-6);
updateOam();
}
setSpriteVisibility(bottomArrowID, false);
updateOam();
}
2 changes: 1 addition & 1 deletion arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void showDirectoryContents(const std::vector<DirEntry>& dirContents, int startRo
}
}

#define verNumber "v0.2"
#define verNumber "v0.3"

bool showTopMenuOnExit = true, noCardMessageSet = false;
int tmCurPos = 0, tmScreenOffset = 0, tmSlot1Offset = 0;
Expand Down
51 changes: 29 additions & 22 deletions arm9/source/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "graphics/graphics.h"
#include "keyboard.h"
#include "loader.h"
#include "party.h"
#include "saves/cardSaves.h"
#include "summary.h"
#include "utils.hpp"
Expand All @@ -17,6 +18,15 @@ std::string savePath;
std::vector<u16> arrow, ballSheet, bankBox, menuButton, shiny, pokemonSheet, stripes, types;
ImageData ballSheetData, bankBoxData, menuButtonData, pokemonSheetData, shinyData, stripesData, typesData;

struct button {
int x;
int y;
std::string text;
} xMenuButtons[] = {
{3, 24, "Party"}, {131, 24, "Options"},
{3, 72, "Save"}, {131, 72, "Exit"},
};

int currentBox(void) {
return topScreen ? currentBankBox : currentSaveBox;
}
Expand Down Expand Up @@ -289,13 +299,11 @@ void savePrompt(void) {
drawRectangle(0, 176, 256, 16, BLACK, false);
}

void drawXMenuButtons(int menuSelection) {
drawImageTinted(3, 24, menuButtonData.width, menuButtonData.height, menuSelection == 0 ? TEAL_RGB : LIGHT_GRAY, menuButton, false);
drawImageTinted(131, 24, menuButtonData.width, menuButtonData.height, menuSelection == 1 ? TEAL_RGB : LIGHT_GRAY, menuButton, false);
drawImageTinted(3, 72, menuButtonData.width, menuButtonData.height, menuSelection == 2 ? TEAL_RGB : LIGHT_GRAY, menuButton, false);
printText("Options", 50, 40, false);
printText("Save", 178, 40, false);
printText("Exit", 50, 88, false);
void drawXMenuButtons(uint menuSelection) {
for(uint i=0;i<(sizeof(xMenuButtons)/sizeof(xMenuButtons[0]));i++) {
drawImageTinted(xMenuButtons[i].x, xMenuButtons[i].y, menuButtonData.width, menuButtonData.height, menuSelection == i ? TEAL_RGB : LIGHT_GRAY, menuButton, false);
printText(xMenuButtons[i].text, xMenuButtons[i].x+47, xMenuButtons[i].y+14, false);
}
}

bool xMenu(void) {
Expand All @@ -321,21 +329,20 @@ bool xMenu(void) {
scanKeys();
pressed = keysDown();
} while(!pressed);
if(menuSelection == -1 && (pressed & KEY_UP || pressed & KEY_DOWN || pressed & KEY_LEFT || pressed & KEY_RIGHT)) {
if(menuSelection == -1 && !(pressed & KEY_TOUCH)) {
menuSelection = 0;
} else if(pressed & KEY_UP) {
if(menuSelection > 1) menuSelection -= 2;
} else if(pressed & KEY_DOWN) {
if(menuSelection < 1) menuSelection += 2;
if(menuSelection < 2) menuSelection += 2;
} else if(pressed & KEY_LEFT) {
if(menuSelection % 2) menuSelection--;
} else if(pressed & KEY_RIGHT) {
if(!(menuSelection % 2)) menuSelection++;
} else if(pressed & KEY_TOUCH) {
touchRead(&touch);
XYCoords menuButtons[] = {{3, 24}, {131, 24}, {3, 72}};
for(uint i=0; i<(sizeof(menuButtons)/sizeof(menuButtons[0]));i++) {
if(touch.px >= menuButtons[i].x && touch.px <= menuButtons[i].x+menuButtonData.width && touch.py >= menuButtons[i].y && touch.py <= menuButtons[i].y+menuButtonData.height) {
for(uint i=0; i<(sizeof(xMenuButtons)/sizeof(xMenuButtons[0]));i++) {
if(touch.px >= xMenuButtons[i].x && touch.px <= xMenuButtons[i].x+menuButtonData.width && touch.py >= xMenuButtons[i].y && touch.py <= xMenuButtons[i].y+menuButtonData.height) {
selectedOption = i;
}
}
Expand All @@ -350,26 +357,26 @@ bool xMenu(void) {
}

if(selectedOption != -1) {
// Flash selected option
drawXMenuButtons(selectedOption);
for(int i=0;i<6;i++) swiWaitForVBlank();
drawXMenuButtons(-1);
for(int i=0;i<6;i++) swiWaitForVBlank();
drawXMenuButtons(selectedOption);
for(int i=0;i<6;i++) swiWaitForVBlank();

if(selectedOption == 0) {
manageParty();

// Redraw menu
drawRectangle(0, 0, 256, 16, BLACK, false);
drawRectangle(0, 16, 256, 160, DARK_GRAY, false);
drawRectangle(0, 176, 256, 16, BLACK, false);
drawXMenuButtons(1);
} else if(selectedOption == 1) {
configMenu();

// Redraw menu
drawRectangle(0, 0, 256, 16, BLACK, false);
drawRectangle(0, 16, 256, 160, DARK_GRAY, false);
drawRectangle(0, 176, 256, 16, BLACK, false);
drawXMenuButtons(1);
} else if(selectedOption == 1) {
savePrompt();
} else if(selectedOption == 2) {
savePrompt();
} else if(selectedOption == 3) {
savePrompt();
// Hide remaining sprites
for(uint i=30;i<getSpriteAmount();i++) {
setSpriteVisibility(i, false);
Expand Down
86 changes: 86 additions & 0 deletions arm9/source/party.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "party.h"
#include "graphics/colors.h"
#include "graphics/graphics.h"
#include "loader.h"
#include "manager.h"
#include "summary.h"

struct button {
int x;
int y;
std::string text;
} partyButtons[] = {
{3, 24}, {131, 24},
{3, 72}, {131, 72},
{3, 120}, {131, 120},
};

void showParty(int selection) {
for(int i=0;i<6;i++) {
XYCoords xy = getPokemonPosition(save->pkm(i)->species());
drawImageTinted(partyButtons[i].x, partyButtons[i].y, menuButtonData.width, menuButtonData.height, selection == i ? TEAL_RGB : LIGHT_GRAY, menuButton, false);
drawImageFromSheet(partyButtons[i].x+8, partyButtons[i].y, 32, 32, pokemonSheet, pokemonSheetData.width, xy.x, xy.y, false);
printText(save->pkm(i)->nickname(), partyButtons[i].x+47, partyButtons[i].y+14, false);
}
}

void manageParty(void) {
// Draw background
drawRectangle(0, 0, 256, 16, BLACK, false);
drawRectangle(0, 16, 256, 160, DARK_GRAY, false);
drawRectangle(0, 176, 256, 16, BLACK, false);

showParty(-1);

int held = 0, pressed = 0, menuSelection = -1, selectedOption = -1;
touchPosition touch;
while(1) {
do {
swiWaitForVBlank();
scanKeys();
pressed = keysDown();
held = keysDownRepeat();
} while(!held);

if(menuSelection == -1 && !(pressed & KEY_TOUCH)) {
menuSelection = 0;
} else if(held & KEY_UP) {
if(menuSelection > 1) menuSelection -= 2;
} else if(held & KEY_DOWN) {
if(menuSelection < 4) menuSelection += 2;
} else if(pressed & KEY_LEFT) {
if(menuSelection % 2) menuSelection--;
} else if(pressed & KEY_RIGHT) {
if(!(menuSelection % 2)) menuSelection++;
} else if(pressed & KEY_TOUCH) {
touchRead(&touch);
for(uint i=0; i<(sizeof(partyButtons)/sizeof(partyButtons[0]));i++) {
if(touch.px >= partyButtons[i].x && touch.px <= partyButtons[i].x+menuButtonData.width && touch.py >= partyButtons[i].y && touch.py <= partyButtons[i].y+menuButtonData.height) {
selectedOption = i;
}
}
menuSelection = -1;
} else if(pressed & KEY_A) {
selectedOption = menuSelection;
} else if(pressed & KEY_B) {
break;
}

if(selectedOption != -1) {
save->pkm(showPokemonSummary(save->pkm(selectedOption)), selectedOption);

// Redraw background
drawRectangle(0, 0, 256, 16, BLACK, false);
drawRectangle(0, 16, 256, 160, DARK_GRAY, false);
drawRectangle(0, 176, 256, 16, BLACK, false);

// Hide arrow
setSpriteVisibility(bottomArrowID, false);
updateOam();

selectedOption = -1;
}

showParty(menuSelection);
}
}

0 comments on commit 3521167

Please sign in to comment.