Merge pull request 'Connection points no longer make connections to the starting level mistakenly thanks to the Tiled editor. Fixes Issue #101. Release Build 12296.' (#103) from ConnectionPointFixes into master
All checks were successful
Emscripten Build / Build_and_Deploy_Web_Build (push) Successful in 6m53s

Reviewed-on: #103
This commit is contained in:
sigonasr2 2026-01-21 14:31:06 -06:00
commit 4426582256
5 changed files with 69 additions and 60 deletions

View File

@ -35,20 +35,20 @@ Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "AdventuresInLestoria.h"
#include "DEFINES.h"
#include "Menu.h"
#include "Unlock.h"
#include "ConnectionPoint.h"
#include "util.h"
#include "drawutil.h"
#include "MenuLabel.h"
#include "EncountersSpawnListScrollableWindowComponent.h"
#include "VisualNovel.h"
#include "State_OverworldMap.h"
#include "SaveFile.h"
#include "Audio.h"
#include "Tutorial.h"
#include"AdventuresInLestoria.h"
#include"DEFINES.h"
#include"Menu.h"
#include"Unlock.h"
#include"ConnectionPoint.h"
#include"util.h"
#include"drawutil.h"
#include"MenuLabel.h"
#include"EncountersSpawnListScrollableWindowComponent.h"
#include"VisualNovel.h"
#include"State_OverworldMap.h"
#include"SaveFile.h"
#include"Audio.h"
#include"Tutorial.h"
INCLUDE_MONSTER_LIST
INCLUDE_game
@ -70,9 +70,7 @@ void State_OverworldMap::OnStateChange(GameState*prevState){
game->LoadLevel("WORLD_MAP");
};
void State_OverworldMap::OnLevelLoad(){
if(Menu::IsMenuOpen()){
Menu::CloseAllMenus();
}
if(Menu::IsMenuOpen())Menu::CloseAllMenus();
game->GetPlayer()->ForceSetPos(currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16});
playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16};
game->GetPlayer()->UpdateWalkingAnimation(DOWN);
@ -108,44 +106,41 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
#pragma region Handle Connection Point Clicking and Movement
for(ConnectionPoint&cp:connections){
if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)
||game->KEY_LEFT.Pressed()||game->KEY_RIGHT.Pressed()||game->KEY_UP.Pressed()||game->KEY_DOWN.Pressed()
||(!analogMove&&(abs(game->KEY_SCROLLHORZ_L.Analog())>=0.2f||abs(game->KEY_SCROLLVERT_L.Analog())>=0.2f))){
bool mouseUsed=game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)&&!Menu::IsMouseOverMenu()&&game->IsMouseInsideWindow();
if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)&&!Menu::IsMouseOverMenu()){
if(Unlock::IsUnlocked(cp)){
if(mouseUsed){
UpdateCurrentConnectionPoint(cp);
playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16};
if(abs(game->KEY_SCROLLHORZ_L.Analog())>=0.2f||abs(game->KEY_SCROLLVERT_L.Analog()>=0.2f))analogMove=true;
goto doneNavigating;
}else{
for(int directionInd=0;int neighborInd:currentConnectionPoint->neighbors){
int targetDirection=-1;
if(game->KEY_LEFT.Pressed()||game->KEY_SCROLLHORZ_L.Analog()<=-0.2f)targetDirection=ConnectionPoint::WEST;
if(game->KEY_RIGHT.Pressed()||game->KEY_SCROLLHORZ_L.Analog()>=0.2f)targetDirection=ConnectionPoint::EAST;
if(game->KEY_UP.Pressed()||game->KEY_SCROLLVERT_L.Analog()<=-0.2f)targetDirection=ConnectionPoint::NORTH;
if(game->KEY_DOWN.Pressed()||game->KEY_SCROLLVERT_L.Analog()>=0.2f)targetDirection=ConnectionPoint::SOUTH;
if(neighborInd==-1){
directionInd++;
continue;
}
ConnectionPoint&neighbor=ConnectionPointFromIndex(neighborInd);
if(Unlock::IsUnlocked(neighbor.unlockCondition)&&targetDirection==directionInd){
UpdateCurrentConnectionPoint(neighbor);
playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16};
if(abs(game->KEY_SCROLLHORZ_L.Analog())>=0.2f||abs(game->KEY_SCROLLVERT_L.Analog()>=0.2f))analogMove=true;
goto doneNavigating;
}
directionInd++;
}
}
UpdateCurrentConnectionPoint(cp);
playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16};
if(abs(game->KEY_SCROLLHORZ_L.Analog())>=0.2f||abs(game->KEY_SCROLLVERT_L.Analog()>=0.2f))analogMove=true;
}
}
}
if(game->KEY_LEFT.Pressed()||game->KEY_RIGHT.Pressed()||game->KEY_UP.Pressed()||game->KEY_DOWN.Pressed()
||(!analogMove&&(abs(game->KEY_SCROLLHORZ_L.Analog())>=0.2f||abs(game->KEY_SCROLLVERT_L.Analog())>=0.2f))){
for(int directionInd=0;int neighborInd:currentConnectionPoint->neighbors){
int targetDirection=-1;
if(game->KEY_UP.Pressed()||game->KEY_SCROLLVERT_L.Analog()<=-0.2f)targetDirection=ConnectionPoint::NORTH;
if(game->KEY_RIGHT.Pressed()||game->KEY_SCROLLHORZ_L.Analog()>=0.2f)targetDirection=ConnectionPoint::EAST;
if(game->KEY_DOWN.Pressed()||game->KEY_SCROLLVERT_L.Analog()>=0.2f)targetDirection=ConnectionPoint::SOUTH;
if(game->KEY_LEFT.Pressed()||game->KEY_SCROLLHORZ_L.Analog()<=-0.2f)targetDirection=ConnectionPoint::WEST;
if(neighborInd==-1){
directionInd++;
continue;
}
ConnectionPoint&neighbor=ConnectionPointFromIndex(neighborInd);
if(Unlock::IsUnlocked(neighbor.unlockCondition)&&targetDirection==directionInd){
UpdateCurrentConnectionPoint(neighbor);
playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16};
if(abs(game->KEY_SCROLLHORZ_L.Analog())>=0.2f||abs(game->KEY_SCROLLVERT_L.Analog()>=0.2f))analogMove=true;
break;
}
directionInd++;
}
}
#pragma endregion
doneNavigating:
if(abs(game->KEY_SCROLLVERT_L.Analog())<0.2f&&abs(game->KEY_SCROLLHORZ_L.Analog())<0.2f){
@ -169,11 +164,13 @@ void State_OverworldMap::Draw(AiL*game){
}
}
bool highlightedAStage=false;
for(ConnectionPoint&cp:connections){
if(Unlock::IsUnlocked(cp)&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)&&!Menu::IsMouseOverMenu()&&game->IsMouseInsideWindow()){
drawutil::DrawCrosshairDecalTransformedView(game->view,cp.rect,currentTime);
highlightedAStage=true;
break;
if(Menu::stack.size()==1){
for(ConnectionPoint&cp:connections){
if(Unlock::IsUnlocked(cp)&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)&&!Menu::IsMouseOverMenu()&&game->IsMouseInsideWindow()){
drawutil::DrawCrosshairDecalTransformedView(game->view,cp.rect,currentTime);
highlightedAStage=true;
break;
}
}
}
if(!highlightedAStage)drawutil::DrawCrosshairDecalTransformedView(game->view,currentConnectionPoint->rect,currentTime); //Highlight the current stage instead then if we haven't moused over a new one.

View File

@ -715,7 +715,12 @@ class TMXParser{
int direction=stoi(key2.first.substr("Connection "s.length(),1))-1;
int&neighborElement=newConnection.neighbors[direction];
if(neighborElement!=-1)ERR(std::format("WARNING! Connection Point in direction {} is already occupied by node {}!",direction,neighborElement));
newConnection.neighbors[direction]=key2.second.GetInteger();
const int val{key2.second.GetInteger()};
if(val==0){
LOG(std::format("WARNING! {} is supposedly connected to {}, this is very likely a mistake!!!",newConnection.name,State_OverworldMap::connections[val].name));
continue; //Prevents accidental connections to index 0 (Which shouldn't be happening)!
}
newConnection.neighbors[direction]=val;
}
}
State_OverworldMap::connections.push_back(newConnection);

View File

@ -13,6 +13,11 @@ You get placed in an arena that changes every 5 waves visually and spawns random
Instead of the area buffs i switched to giving highest exp and locking extra lore behind first time wave completions.
Red flashing entity with hasten buff
Mouse usage on overworld map might be screwed up with other menus open
"0" is always invalid? Potentially
Mana icon pixel snapping
DEMO
====

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 12289
#define VERSION_BUILD 12298
#define stringify(a) stringify_(a)
#define stringify_(a) #a

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="left-down" width="266" height="184" tilewidth="4" tileheight="4" infinite="0" nextlayerid="5" nextobjectid="65">
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="left-down" width="266" height="184" tilewidth="4" tileheight="4" infinite="0" nextlayerid="5" nextobjectid="66">
<properties>
<property name="Background Music" propertytype="BGM" value="overworld"/>
<property name="Level Type" type="int" propertytype="LevelType" value="4"/>
@ -986,7 +986,6 @@
</object>
<object id="52" name="Story IV-I" type="StagePlate" x="565" y="257" width="18" height="22">
<properties>
<property name="Connection 1 - North" type="object" value="0"/>
<property name="Connection 2 - East" type="object" value="53"/>
<property name="Connection 4 - West" type="object" value="51"/>
<property name="Map" propertytype="Level" value="STORY_4_1"/>
@ -996,8 +995,8 @@
</object>
<object id="53" name="Stage IV-I" type="StagePlate" x="609" y="253" width="42" height="14">
<properties>
<property name="Connection 1 - North" type="object" value="0"/>
<property name="Connection 2 - East" type="object" value="55"/>
<property name="Connection 3 - South" type="object" value="0"/>
<property name="Connection 4 - West" type="object" value="52"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_4_1"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/>
@ -1103,5 +1102,8 @@
<property name="Unlock Condition" propertytype="Level" value="STORY_2_1"/>
</properties>
</object>
<object id="65" x="261" y="447" width="130" height="46">
<text fontfamily="Courier New" pixelsize="9" wrap="1" color="#ff0000" bold="1">NOTE: Nothing should be connected to the initial stage plate!!</text>
</object>
</objectgroup>
</map>