Cursor wrap limiting

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 71b85e0926
commit 9b28a8970b
  1. BIN
      C++ProjectTemplate
  2. 156
      main.cpp

Binary file not shown.

@ -167,6 +167,9 @@ public:
int lastPress=0;
int lastRepeatedFrame=0;
EquipSlot::Equip EQUIP_MENU_SLOT=EquipSlot::WEAPON;
int EQUIP_ITEM_MENU_CURSOR=0;
int EQUIP_ITEM_MENU_OFFSET=0;
std::vector<int> EQUIP_ITEM_MENU_CONTENTS={};
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
@ -256,6 +259,28 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
AddItemToPlayerInventory(ItemName::COPPER_BRACELET);
AddItemToPlayerInventory(ItemName::MIRACLE_FOOD_LUNCH);
AddItemToPlayerInventory(ItemName::MIRACLE_FOOD_LUNCH);
@ -686,6 +711,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
case BattleState::SELECT_ACTION:{
if (CURRENT_TURN<0) {
if (UpPressed()||DownPressed()) {
KEY_LASTPRESSED=NONE;
if (BATTLE_SELECTION_CURSOR%2==0) {
BATTLE_SELECTION_CURSOR++;
} else {
@ -694,12 +720,18 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
if (RightPressed()) {
BATTLE_SELECTION_CURSOR=(BATTLE_SELECTION_CURSOR+2)%6;
if (BATTLE_SELECTION_CURSOR>=4) {
KEY_LASTPRESSED=NONE;
}
}
if (LeftPressed()) {
BATTLE_SELECTION_CURSOR-=2;
if (BATTLE_SELECTION_CURSOR<0) {
BATTLE_SELECTION_CURSOR+=6;
}
if (BATTLE_SELECTION_CURSOR<=1) {
KEY_LASTPRESSED=NONE;
}
}
if (ACTIONKEYPRESSED) {
switch (BATTLE_SELECTION_CURSOR) {
@ -746,6 +778,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
POWER_SELECTION_OFFSET[-CURRENT_TURN-1]++;
}
}
if (POWER_SELECTION_CURSOR[-CURRENT_TURN-1]==(int)BATTLE_MOVELIST_DISPLAY.size()-1) {
KEY_LASTPRESSED=NONE;
}
}
if (UpPressed()) {
if (POWER_SELECTION_CURSOR[-CURRENT_TURN-1]==0) {
@ -757,6 +792,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
POWER_SELECTION_OFFSET[-CURRENT_TURN-1]--;
}
}
if (POWER_SELECTION_CURSOR[-CURRENT_TURN-1]==0) {
KEY_LASTPRESSED=NONE;
}
}
if (LeftPressed()) {
BATTLE_STATE=BattleState::SELECT_ACTION;
@ -770,6 +808,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if (CURRENT_TURN<0) {
if (RightPressed()) {
POWER_GRADE_CURSOR[-CURRENT_TURN-1]=(POWER_GRADE_CURSOR[-CURRENT_TURN-1]+1)%BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]].size();
if (POWER_GRADE_CURSOR[-CURRENT_TURN-1]==BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]].size()-1) {
KEY_LASTPRESSED=NONE;
}
}
if (DownPressed()||UpPressed()||LeftPressed()&&POWER_GRADE_CURSOR[-CURRENT_TURN-1]==0) {
if (UpPressed()) {
@ -785,6 +826,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
POWER_SELECTION_OFFSET[-CURRENT_TURN-1]--;
}
}
if (POWER_SELECTION_CURSOR[-CURRENT_TURN-1]==0) {
KEY_LASTPRESSED=NONE;
}
}
} else
if (DownPressed()) {
@ -800,6 +844,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
POWER_SELECTION_OFFSET[-CURRENT_TURN-1]++;
}
}
if (POWER_SELECTION_CURSOR[-CURRENT_TURN-1]==(int)BATTLE_MOVELIST_DISPLAY.size()-1) {
KEY_LASTPRESSED=NONE;
}
}
} else {
POWER_GRADE_CURSOR[-CURRENT_TURN-1]=0;
@ -809,6 +856,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} else
if (LeftPressed()) {
POWER_GRADE_CURSOR[-CURRENT_TURN-1]=std::clamp(POWER_GRADE_CURSOR[-CURRENT_TURN-1]-1,0,(int)(BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]].size())-1);
if (POWER_GRADE_CURSOR[-CURRENT_TURN-1]==0) {
KEY_LASTPRESSED=NONE;
}
}
if (ACTIONKEYPRESSED) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->GetPP()>=BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]]->PPCost) {
@ -1068,12 +1118,18 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
if (DownPressed()) {
OVERWORLD_MENU_SELECTION=(OVERWORLD_MENU_SELECTION+1)%5;
if (OVERWORLD_MENU_SELECTION==4) {
KEY_LASTPRESSED=NONE;
}
}
if (UpPressed()) {
OVERWORLD_MENU_SELECTION--;
if (OVERWORLD_MENU_SELECTION<0) {
OVERWORLD_MENU_SELECTION+=5;
}
if (OVERWORLD_MENU_SELECTION==0) {
KEY_LASTPRESSED=NONE;
}
}
if (ACTIONKEYPRESSED) {
switch (OVERWORLD_MENU_SELECTION) {
@ -1141,18 +1197,26 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
OVERWORLD_POWER_SELECTION_MEMBER=PARTY_MEMBER_COUNT-1;
}
PopulateBattleMoveList(OVERWORLD_POWER_SELECTION_MEMBER,true);
if (OVERWORLD_POWER_SELECTION_MEMBER==0) {
KEY_LASTPRESSED=NONE;
}
}
if (RightPressed()) {
OVERWORLD_POWER_SELECTION_MEMBER=(OVERWORLD_POWER_SELECTION_MEMBER+1)%PARTY_MEMBER_COUNT;
PopulateBattleMoveList(OVERWORLD_POWER_SELECTION_MEMBER,true);
if (OVERWORLD_POWER_SELECTION_MEMBER==PARTY_MEMBER_COUNT-1) {
KEY_LASTPRESSED=NONE;
}
}
if (UpPressed()) {
GAME_STATE=GameState::OVERWORLD_MENU;
OVERWORLD_POWER_SELECTION_MEMBER=-1;
}
if (ACTIONKEYPRESSED) {
if (BATTLE_MOVELIST_DISPLAY.size()>0) {
GAME_STATE=GameState::OVERWORLD_POWER_MENU;
}
}
}break;
case GameState::OVERWORLD_POWER_MENU:{
if (DownPressed()) {
@ -1165,6 +1229,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
OVERWORLD_POWER_SELECTION_OFFSET[OVERWORLD_POWER_SELECTION_MEMBER]++;
}
}
if (OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]==(int)BATTLE_MOVELIST_DISPLAY.size()-1) {
KEY_LASTPRESSED=NONE;
}
}
if (UpPressed()) {
if (OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]==0) {
@ -1176,6 +1243,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
OVERWORLD_POWER_SELECTION_OFFSET[OVERWORLD_POWER_SELECTION_MEMBER]--;
}
}
if (OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]==0) {
KEY_LASTPRESSED=NONE;
}
}
if (LeftPressed()) {
if (PARTY_MEMBER_COUNT==1) {
@ -1191,6 +1261,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
case GameState::OVERWORLD_GRADE_MENU:{
if (RightPressed()) {
OVERWORLD_POWER_GRADE_CURSOR=(OVERWORLD_POWER_GRADE_CURSOR+1)%BATTLE_MOVELIST_DISPLAY[OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]].size();
if (OVERWORLD_POWER_GRADE_CURSOR==BATTLE_MOVELIST_DISPLAY[OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]].size()-1) {
KEY_LASTPRESSED=NONE;
}
}
if (DownPressed()||UpPressed()||LeftPressed()&&OVERWORLD_POWER_GRADE_CURSOR==0) {
if (UpPressed()) {
@ -1207,6 +1280,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}
}
if (OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]==0) {
KEY_LASTPRESSED=NONE;
}
} else
if (DownPressed()) {
if (BATTLE_MOVELIST_DISPLAY.size()>1) {
@ -1222,6 +1298,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}
}
if (OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]==(int)BATTLE_MOVELIST_DISPLAY.size()-1) {
KEY_LASTPRESSED=NONE;
}
} else {
OVERWORLD_POWER_GRADE_CURSOR=0;
GAME_STATE=GameState::OVERWORLD_POWER_MENU;
@ -1229,6 +1308,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} else
if (LeftPressed()) {
OVERWORLD_POWER_GRADE_CURSOR=std::clamp(OVERWORLD_POWER_GRADE_CURSOR-1,0,(int)(BATTLE_MOVELIST_DISPLAY[OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]].size())-1);
if (OVERWORLD_POWER_GRADE_CURSOR==0) {
KEY_LASTPRESSED=NONE;
}
}
if (ACTIONKEYPRESSED) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_POWER_SELECTION_MEMBER]]->GetPP()>=BATTLE_MOVELIST_DISPLAY[OVERWORLD_POWER_SELECTION_CURSOR[OVERWORLD_POWER_SELECTION_MEMBER]][OVERWORLD_POWER_GRADE_CURSOR]->PPCost) {
@ -1464,12 +1546,18 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
case GameState::OVERWORLD_EQUIP_PLAYER_MENU:{
if (LeftPressed()) {
OVERWORLD_POWER_SELECTION_MEMBER--;
if (OVERWORLD_POWER_SELECTION_MEMBER==0) {
KEY_LASTPRESSED=NONE;
}
if (OVERWORLD_POWER_SELECTION_MEMBER<0) {
OVERWORLD_POWER_SELECTION_MEMBER=PARTY_MEMBER_COUNT-1;
}
}
if (RightPressed()) {
OVERWORLD_POWER_SELECTION_MEMBER=(OVERWORLD_POWER_SELECTION_MEMBER+1)%PARTY_MEMBER_COUNT;
if (OVERWORLD_POWER_SELECTION_MEMBER==PARTY_MEMBER_COUNT-1) {
KEY_LASTPRESSED=NONE;
}
}
if (UpPressed()) {
GAME_STATE=GameState::OVERWORLD_MENU;
@ -1496,9 +1584,55 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
GAME_STATE=GameState::OVERWORLD_EQUIP_PLAYER_MENU;
}
}
if (ACTIONKEYPRESSED) {
GAME_STATE=GameState::OVERWORLD_EQUIP_ITEM_MENU;
EQUIP_ITEM_MENU_CONTENTS.clear();
EQUIP_ITEM_MENU_OFFSET=0;
EQUIP_ITEM_MENU_CURSOR=0;
for (int i=0;i<PARTY_INVENTORY.size();i++) {
if (PARTY_INVENTORY[i]->stats.equip==EQUIP_MENU_SLOT) {
EQUIP_ITEM_MENU_CONTENTS.push_back(i);
}
}
}
}break;
case GameState::OVERWORLD_EQUIP_ITEM_MENU:{
if (UpPressed()) {
EQUIP_ITEM_MENU_CURSOR--;
if (EQUIP_ITEM_MENU_CURSOR==0) {
KEY_LASTPRESSED=NONE;
}
if (EQUIP_ITEM_MENU_CURSOR<0) {
EQUIP_ITEM_MENU_CURSOR=EQUIP_ITEM_MENU_CONTENTS.size()-1;
if (EQUIP_ITEM_MENU_OFFSET+8<=EQUIP_ITEM_MENU_CURSOR) {
EQUIP_ITEM_MENU_OFFSET=EQUIP_ITEM_MENU_CURSOR-7;
}
}
if (EQUIP_ITEM_MENU_OFFSET>EQUIP_ITEM_MENU_CURSOR) {
EQUIP_ITEM_MENU_OFFSET=EQUIP_ITEM_MENU_CURSOR;
}
}
if (DownPressed()) {
EQUIP_ITEM_MENU_CURSOR=(EQUIP_ITEM_MENU_CURSOR+1)%EQUIP_ITEM_MENU_CONTENTS.size();
if (EQUIP_ITEM_MENU_CURSOR==EQUIP_ITEM_MENU_CONTENTS.size()-1) {
KEY_LASTPRESSED=NONE;
}
if (EQUIP_ITEM_MENU_OFFSET+8<=EQUIP_ITEM_MENU_CURSOR) {
EQUIP_ITEM_MENU_OFFSET++;
}
if (EQUIP_ITEM_MENU_CURSOR==0) {
EQUIP_ITEM_MENU_OFFSET=0;
}
}
if (LeftPressed()) {
GAME_STATE=GameState::OVERWORLD_EQUIP_MENU;
}
}break;
}
ANYKEYPRESSED=ACTIONKEYPRESSED=false;
if (KEY_LASTPRESSED!=NONE) {
lastRepeatedFrame=frameCount;
}
}
void drawGame(){
@ -1654,6 +1788,21 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
DrawStringPropDecal({12+64,(float)(19+i*12)},(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_POWER_SELECTION_MEMBER]]->equipment[i]!=nullptr)?PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_POWER_SELECTION_MEMBER]]->equipment[i]->name:"None");
}
}
if (GAME_STATE==GameState::OVERWORLD_EQUIP_ITEM_MENU) {
DrawDialogBox({4,4},{(int)(WIDTH/2+4),HEIGHT/2},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawDecal({8,(float)(12+(EQUIP_ITEM_MENU_CURSOR-EQUIP_ITEM_MENU_OFFSET)*12)},SPRITES["cursor.png"]);
for (int i=0;i<8;i++) {
if (EQUIP_ITEM_MENU_OFFSET+i<EQUIP_ITEM_MENU_CONTENTS.size()) {
DrawStringPropDecal({16,(float)(12+i*12)},PARTY_INVENTORY[EQUIP_ITEM_MENU_CONTENTS[i+EQUIP_ITEM_MENU_OFFSET]]->name);
}
}
if (EQUIP_ITEM_MENU_OFFSET>0) {
DrawRotatedDecal({WIDTH/2-20,8},SPRITES["cursor.png"],-M_PI_2,{4,4});
}
if (EQUIP_ITEM_MENU_OFFSET+8<EQUIP_ITEM_MENU_CONTENTS.size()) {
DrawRotatedDecal({WIDTH/2-20,4+HEIGHT/2-4},SPRITES["cursor.png"],M_PI_2,{4,4});
}
}
if (GAME_STATE==GameState::OVERWORLD_POWER_MENU||GAME_STATE==GameState::OVERWORLD_POWER_PLAYER_MENU||GAME_STATE==GameState::OVERWORLD_GRADE_MENU) {
DrawBattleMoveList(OVERWORLD_POWER_SELECTION_MEMBER);
}
@ -3831,6 +3980,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if (ITEM_SELECTION_CURSOR<ITEM_SELECTION_OFFSET) {
ITEM_SELECTION_OFFSET=ITEM_SELECTION_CURSOR/2*2;
}
if (ITEM_SELECTION_CURSOR<2) {
KEY_LASTPRESSED=NONE;
}
}
if (DownPressed()) {
ITEM_SELECTION_CURSOR+=2;
@ -3849,6 +4001,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if (ITEM_SELECTION_CURSOR>=ITEM_SELECTION_OFFSET+18) {
ITEM_SELECTION_OFFSET=ITEM_SELECTION_CURSOR/2*2-16;
}
if (ITEM_SELECTION_CURSOR>=PARTY_INVENTORY.size()-2) {
KEY_LASTPRESSED=NONE;
}
}
}
@ -4234,7 +4389,6 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}break;
}
if (allowed) {
lastRepeatedFrame=frameCount;
return true;
}
}

Loading…
Cancel
Save