|
|
|
@ -54,7 +54,7 @@ const float TARGET_RATE = 1/60.0; |
|
|
|
|
int MAP_WIDTH=-1; |
|
|
|
|
int MAP_HEIGHT=-1; |
|
|
|
|
Map*CURRENT_MAP=nullptr; |
|
|
|
|
extern std::map<MapName::Map,Map*> MAPS; |
|
|
|
|
std::map<MapName::Map,Map*> MAPS; |
|
|
|
|
int GAME_STATE = GameState::EDITOR; |
|
|
|
|
vi2d SELECTED_TILE={0,0}; |
|
|
|
|
vi2d HIGHLIGHTED_TILE={0,0}; |
|
|
|
@ -238,6 +238,7 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
SetupEncounters(); |
|
|
|
|
SetupBattleProperties(); |
|
|
|
|
SetupCutscenes(); |
|
|
|
|
SetupMapList(); |
|
|
|
|
SetGameFlag(Flag::TEST_FLAG1,false); |
|
|
|
|
SetGameFlag(Flag::TEST_FLAG2,false); |
|
|
|
|
SetGameFlag(Flag::TEST_FLAG3,false); |
|
|
|
@ -862,27 +863,37 @@ void SeasonI::LoadMap(Map*map) { |
|
|
|
|
lastMarker=marker; |
|
|
|
|
int size_x,size_y; |
|
|
|
|
split4>>size_x; |
|
|
|
|
marker=data.find_first_of(';',marker+1); |
|
|
|
|
std::stringstream split5(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
lastMarker=marker; |
|
|
|
|
split5>>size_y; |
|
|
|
|
Map*mapTrigger=nullptr; |
|
|
|
|
vd2d triggerCoords; |
|
|
|
|
if (data.find_first_of(';',marker+1)!=std::string::npos) { |
|
|
|
|
if (marker!=std::string::npos) { |
|
|
|
|
//This means there's extra data we should grab. Should be map, and two positional coordinates.
|
|
|
|
|
marker=data.find_first_of(';',marker+1); |
|
|
|
|
std::stringstream split6(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
lastMarker=marker; |
|
|
|
|
int mapVal; |
|
|
|
|
int mapVal=0; |
|
|
|
|
split6>>mapVal; |
|
|
|
|
mapTrigger=MAPS[(MapName::Map)mapVal]; |
|
|
|
|
std::stringstream split7(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
lastMarker=marker; |
|
|
|
|
split7>>triggerCoords.x; |
|
|
|
|
std::stringstream split8(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
lastMarker=marker; |
|
|
|
|
split8>>triggerCoords.y; |
|
|
|
|
printf(" Found extra data.\n"); |
|
|
|
|
if (MAPS.count((MapName::Map)mapVal)) { |
|
|
|
|
mapTrigger=MAPS[(MapName::Map)mapVal]; |
|
|
|
|
marker=data.find_first_of(';',marker+1); |
|
|
|
|
std::stringstream split7(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
lastMarker=marker; |
|
|
|
|
split7>>triggerCoords.x; |
|
|
|
|
marker=data.find_first_of(';',marker+1); |
|
|
|
|
std::stringstream split8(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
lastMarker=marker; |
|
|
|
|
split8>>triggerCoords.y; |
|
|
|
|
printf(" Found extra data. Map:%s\n",mapTrigger->mapname.c_str()); |
|
|
|
|
map->triggers.push_back(new Trigger({(int)x,(int)y},{size_x,size_y},(TriggerName::Trigger)id,triggerCoords,mapTrigger)); |
|
|
|
|
} else { |
|
|
|
|
printf(" Failed to load extra data.\n"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
map->triggers.push_back(new Trigger({(int)x,(int)y},{size_x,size_y},(TriggerName::Trigger)id)); |
|
|
|
|
} |
|
|
|
|
map->triggers.push_back(new Trigger({(int)x,(int)y},{size_x,size_y},(TriggerName::Trigger)id,triggerCoords,mapTrigger)); |
|
|
|
|
printf("Trigger %d Loaded.\n",id); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -1009,7 +1020,10 @@ void SeasonI::SaveMap(Map*map) { |
|
|
|
|
|
|
|
|
|
for (int i=0;i<map->triggers.size();i++) { |
|
|
|
|
f.put('\n'); |
|
|
|
|
const std::string trigger="TRIGGER"+std::to_string(map->triggers[i]->GetPosX())+";"+std::to_string(map->triggers[i]->GetPosY())+";"+std::to_string(map->triggers[i]->GetID())+";"+std::to_string(map->triggers[i]->GetSizeX())+";"+std::to_string(map->triggers[i]->GetSizeY())+";"+std::to_string(map->triggers[i]->GetMapPtr()->myID)+";"+std::to_string(map->triggers[i]->GetAdditionalCoordData().x)+";"+std::to_string(map->triggers[i]->GetAdditionalCoordData().y); |
|
|
|
|
std::string trigger="TRIGGER"+std::to_string(map->triggers[i]->GetPosX())+";"+std::to_string(map->triggers[i]->GetPosY())+";"+std::to_string(map->triggers[i]->GetID())+";"+std::to_string(map->triggers[i]->GetSizeX())+";"+std::to_string(map->triggers[i]->GetSizeY()); |
|
|
|
|
if (map->triggers[i]->GetMapPtr()!=nullptr) { |
|
|
|
|
trigger+=";"+std::to_string(map->triggers[i]->GetMapPtr()->myID)+";"+std::to_string(map->triggers[i]->GetAdditionalCoordData().x)+";"+std::to_string(map->triggers[i]->GetAdditionalCoordData().y); |
|
|
|
|
} |
|
|
|
|
for (int j=0;j<trigger.length();j++) { |
|
|
|
|
f.put(trigger[j]); |
|
|
|
|
} |
|
|
|
@ -1294,6 +1308,13 @@ void SeasonI::updateGame(){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::MAP_POSITION_SELECT:{ |
|
|
|
|
int selectedTileX=(GetMouseX()+cameraPos.x)/32; |
|
|
|
|
int selectedTileY=(GetMouseY()+cameraPos.y)/32; |
|
|
|
|
if (selectedTileX<MAP_WIDTH&&selectedTileY<MAP_HEIGHT&&selectedTileX>=0&&selectedTileY>=0) { |
|
|
|
|
HIGHLIGHTED_TILE={selectedTileX,selectedTileY}; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::EDITOR:{ |
|
|
|
|
if (IsTextEntryEnabled()) { |
|
|
|
|
return; |
|
|
|
@ -1384,8 +1405,17 @@ void SeasonI::updateGame(){ |
|
|
|
|
if (GetMouse(1).bHeld) { |
|
|
|
|
switch (EDITING_LAYER) { |
|
|
|
|
case layer::COLLISION:{ |
|
|
|
|
TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; |
|
|
|
|
tile->tileX=tile->tileY=15; |
|
|
|
|
if (EDITING_LAYER==layer::COLLISION&&SELECTED_TRIGGER!=TriggerName::NONE) { |
|
|
|
|
for (int i=0;i<CURRENT_MAP->triggers.size();i++) { |
|
|
|
|
if (CURRENT_MAP->triggers[i]->GetPos()==HIGHLIGHTED_TILE*32) { |
|
|
|
|
delete CURRENT_MAP->triggers[i]; |
|
|
|
|
CURRENT_MAP->triggers.erase(CURRENT_MAP->triggers.begin()+i--); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; |
|
|
|
|
tile->tileX=tile->tileY=15; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case layer::HIGH:{ |
|
|
|
|
TILE*tile=MAP[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; |
|
|
|
@ -2258,11 +2288,15 @@ void SeasonI::keyUpdates() { |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::MAP_POSITION_SELECT:{ |
|
|
|
|
LAST_PLACED_TRIGGER->SetExtraCoords(HIGHLIGHTED_TILE*32); |
|
|
|
|
CURRENT_MAP=LAST_PLACED_TRIGGER->GetMapPtr(); |
|
|
|
|
LoadMap(ORIGINATING_MAP); |
|
|
|
|
CURRENT_MAP->triggers.push_back(LAST_PLACED_TRIGGER); |
|
|
|
|
LAST_PLACED_TRIGGER=nullptr; |
|
|
|
|
if (GetMouse(0).bReleased) { |
|
|
|
|
LAST_PLACED_TRIGGER->SetExtraCoords(HIGHLIGHTED_TILE*32); |
|
|
|
|
CURRENT_MAP=ORIGINATING_MAP; |
|
|
|
|
LoadMap(CURRENT_MAP); |
|
|
|
|
CURRENT_MAP->triggers.push_back(LAST_PLACED_TRIGGER); |
|
|
|
|
LAST_PLACED_TRIGGER=nullptr; |
|
|
|
|
GAME_STATE=GameState::EDITOR; |
|
|
|
|
SELECTING_A_MAP_FOR_TRIGGER=false; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::EDITOR:{ |
|
|
|
|
if (IsTextEntryEnabled()) { |
|
|
|
@ -2352,7 +2386,7 @@ void SeasonI::keyUpdates() { |
|
|
|
|
if (SELECTING_A_MAP_FOR_TRIGGER) { |
|
|
|
|
SELECTING_A_MAP_FOR_TRIGGER=false; |
|
|
|
|
LAST_PLACED_TRIGGER->SetMap(CURRENT_MAP); |
|
|
|
|
printf("Trigger Map Location set to %s",CURRENT_MAP->mapname.c_str()); |
|
|
|
|
printf("Trigger Map Location set to %s\n",CURRENT_MAP->mapname.c_str()); |
|
|
|
|
GAME_STATE=GameState::MAP_POSITION_SELECT; |
|
|
|
|
} else { |
|
|
|
|
GAME_STATE=GameState::EDITOR; |
|
|
|
@ -2830,16 +2864,7 @@ void SeasonI::drawGame(){ |
|
|
|
|
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); |
|
|
|
|
if (EDITING_LAYER==layer::COLLISION&&SELECTED_TRIGGER!=TriggerName::NONE) { |
|
|
|
|
DrawStringPropDecal({2,2},Wrap("Editing Triggers - Selected "+TRIGGERS[SELECTED_TRIGGER],WIDTH-4,true,{1,1})); |
|
|
|
|
for (auto&trigger:CURRENT_MAP->triggers) { |
|
|
|
|
FillRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),Pixel(255,0,0,64)); |
|
|
|
|
DrawRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),YELLOW); |
|
|
|
|
vi2d textOffset={2,2}; |
|
|
|
|
std::string triggerText=TRIGGERS[(TriggerName::Trigger)trigger->GetID()]; |
|
|
|
|
if ((TriggerName::Trigger)trigger->GetID()==TriggerName::GOTO_MAP) { |
|
|
|
|
triggerText="GOTO "+trigger->GetMapPtr()->mapname+"\n"+std::to_string(trigger->GetAdditionalCoordData().x)+"\n"+std::to_string(trigger->GetAdditionalCoordData().y); |
|
|
|
|
} |
|
|
|
|
DrawStringDecal(trigger->GetPos()-cameraPos+textOffset,triggerText,WHITE,{28.f/GetTextSize(triggerText).x,1.f}); |
|
|
|
|
} |
|
|
|
|
DrawTriggers(); |
|
|
|
|
} else |
|
|
|
|
if (EDITING_LAYER==layer::ENCOUNTER) { |
|
|
|
|
if (IsTextEntryEnabled()) { |
|
|
|
@ -3808,6 +3833,7 @@ void SeasonI::HandleCutscenes() { |
|
|
|
|
case ActionType::LOAD_MAP:{ |
|
|
|
|
class LoadMap*action=(class LoadMap*)CurrentCutscene->GetAction(); |
|
|
|
|
Map*map=action->GetTargetMap(); |
|
|
|
|
CURRENT_MAP=map; |
|
|
|
|
LoadMap(map); |
|
|
|
|
CurrentCutscene->AdvanceAction(); |
|
|
|
|
}break; |
|
|
|
@ -3817,6 +3843,9 @@ void SeasonI::HandleCutscenes() { |
|
|
|
|
for (int i=0;i<PARTY_MEMBER_COUNT;i++) { |
|
|
|
|
PARTY_MEMBER_OBJ[i]->SetPos(pos); |
|
|
|
|
} |
|
|
|
|
const vi2d cameraOffset={WIDTH/2,HEIGHT/2}; |
|
|
|
|
cameraPos=PARTY_MEMBER_OBJ[0]->GetPos()-cameraOffset; |
|
|
|
|
CurrentCutscene->AdvanceAction(); |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5127,6 +5156,27 @@ void SeasonI::SetupCutscenes(){ |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::DrawTriggers(){ |
|
|
|
|
for (auto&trigger:CURRENT_MAP->triggers) { |
|
|
|
|
FillRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),Pixel(255,0,0,64)); |
|
|
|
|
DrawRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),YELLOW); |
|
|
|
|
vi2d textOffset={2,2}; |
|
|
|
|
std::string triggerText=TRIGGERS[(TriggerName::Trigger)trigger->GetID()]; |
|
|
|
|
if ((TriggerName::Trigger)trigger->GetID()==TriggerName::GOTO_MAP) { |
|
|
|
|
triggerText="GOTO "+trigger->GetMapPtr()->mapname+"\n"+std::to_string(trigger->GetAdditionalCoordData().x)+"\n"+std::to_string(trigger->GetAdditionalCoordData().y); |
|
|
|
|
} |
|
|
|
|
DrawStringDecal(trigger->GetPos()-cameraPos+textOffset,triggerText,WHITE,{28.f/GetTextSize(triggerText).x,1.f}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::SetupMapList(){ |
|
|
|
|
int MAP_ENUM_COUNT=0; |
|
|
|
|
MAPS={ |
|
|
|
|
{(MapName::Map)MAP_ENUM_COUNT++,new Map("map0","map0_2","map0_3","map0_4","map0_5",SPRITES["terrainmap.png"],"Onett",(MapName::Map)(MAP_ENUM_COUNT-1))}, |
|
|
|
|
{(MapName::Map)MAP_ENUM_COUNT++,new Map("newmap","newmap_2","newmap_3","newmap_4","newmap_5",SPRITES["terrainmap.png"],"Twoson",(MapName::Map)(MAP_ENUM_COUNT-1))}, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifndef TEST_SUITE |
|
|
|
|
int main() |
|
|
|
|
{ |
|
|
|
|