diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 6845635..e1165ab 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index e57dbd3..3743a62 100644 --- a/main.cpp +++ b/main.cpp @@ -33,6 +33,12 @@ using namespace olc; +struct SaveFileData{ + int frameTime; + std::string playerName; + int chapterNumber; +}; + std::vector OBJECTS; const vd2d NO_NEIGHBOR = {-999,-999}; SeasonI*GAME; @@ -59,7 +65,7 @@ int MAP_WIDTH=-1; int MAP_HEIGHT=-1; Map*CURRENT_MAP=nullptr; std::map MAPS; -int GAME_STATE = GameState::EDITOR; +int GAME_STATE=GameState::FILE_LOAD_SELECT; vi2d SELECTED_TILE={0,0}; vi2d HIGHLIGHTED_TILE={0,0}; int EDITING_LAYER=layer::DYNAMIC; @@ -168,6 +174,8 @@ bool SELECTING_A_MAP_FOR_TRIGGER=false; Trigger*LAST_PLACED_TRIGGER=nullptr; Map* ORIGINATING_MAP=nullptr; std::array PARTY_MEMBER_NAMES={"PLAYER","NESS","PAULA","JEFF","ANNA","KING","POO"}; +std::array SAVE_FILE_DATA={{}}; +int CHAPTER_NUMBER=0; /* [Choice1,Choice2,Choice3] @@ -309,6 +317,25 @@ bool SeasonI::OnUserCreate(){ AddItemToPlayerInventory(ItemName::TEE_BALL_BAT); AddItemToPlayerInventory(ItemName::FREEZE_PACKET); + + for (int i=0;i<3;i++) { + if (std::filesystem::exists("save"+std::to_string(i))) { + std::ifstream f("save"+std::to_string(i)); + std::string data; + std::getline(f,data); + int commaPos=data.find_last_of(" ",data.size()-2)+1; + std::string chapterNumber=data.substr(commaPos,data.size()); + int prevCommaPos=commaPos; + commaPos=data.find_last_of(" ",commaPos-2)+1; + std::string playerName=data.substr(commaPos,prevCommaPos-commaPos); + prevCommaPos=commaPos; + commaPos=data.find_last_of(" ",commaPos-2)+1; + std::string fileTime=data.substr(commaPos,prevCommaPos-commaPos); + //printf("File time detected is %s\n",fileTime.c_str()); + SAVE_FILE_DATA[i]={frameTime:stoi(fileTime),playerName:playerName,chapterNumber:stoi(chapterNumber)}; + } + } + return true; } #endif @@ -2709,6 +2736,12 @@ void SeasonI::drawGame(){ } switch (GAME_STATE) { + case GameState::FILE_LOAD_SELECT:{ + DrawDialogBox({4,4},{(int)(WIDTH-8),HEIGHT/4},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220)); + for (int i=0;i<3;i++) { + DrawStringDecal({8.f,(float)(8+i*12)},SAVE_FILE_DATA[i].playerName+" Chapter "+std::to_string(SAVE_FILE_DATA[i].chapterNumber)+" "+std::to_string(SAVE_FILE_DATA[i].frameTime)); + } + }break; case GameState::GAME_WORLD: case GameState::OVERWORLD_MENU: case GameState::OVERWORLD_POWER_MENU: @@ -5226,6 +5259,9 @@ void SeasonI::SaveGameSaveData(int saveSlot) { file<myID<<" "; + file<SetPos(positions[i]); } + frameCount=ReadIntFromStream(file); + ReadStringFromStream(file); + CHAPTER_NUMBER=ReadIntFromStream(file); } #ifndef TEST_SUITE diff --git a/object.h b/object.h index f171fa8..57306a2 100644 --- a/object.h +++ b/object.h @@ -73,7 +73,6 @@ class Object{ :Object(id,name,{gridx*32-(spr->sprSize.x*0.5)*(scale.x-1),gridy*32-(spr->sprSize.y-4)*(scale.y-1)},spr,scale,color,animationSpd,temp,data) {} Object(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1,bool temp=false,ObjectExtraData data={moveTime:0,moveFreq:0,moveSpd:0}) :spr(spr),pos(pos),id(id),name(name),color(color),animationSpd(animationSpd),temp(temp),extraData(data),startPos(pos) { - printf("Extra data:%d %d %lf\n",extraData.moveFreq,extraData.moveTime,extraData.moveSpd); SetScale(scale); } virtual Object* CreateType(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1,bool temp=false,ObjectExtraData data={moveTime:0,moveFreq:0,moveSpd:0})=0; diff --git a/save0 b/save0 index ce7b5de..c0bd050 100644 --- a/save0 +++ b/save0 @@ -1 +1 @@ -120 120 PLAYER 30 30 8 8 4 0 0 0 0 0 0 0 11 9 10 13 14 15 16 17 33 29 21 25 1 6 4 3 -1 -1 -1 147 231 120 120 NESS 30 30 8 8 4 0 0 0 0 0 0 0 6 33 34 29 30 31 32 0 3 -1 -1 -1 150 259 120 120 PAULA 30 30 8 8 4 0 0 0 0 0 0 0 6 21 22 23 24 37 38 0 3 -1 -1 -1 138 261 120 120 JEFF 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 48 0 ANNA 30 0 0 0 4 0 0 0 0 0 0 0 0 0 3 -1 -1 -1 126 273 0 0 KING 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 0 0 POO 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 0 512 1 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 \ No newline at end of file +120 120 PLAYER 30 30 8 8 4 0 0 0 0 0 0 0 11 9 10 13 14 15 16 17 33 29 21 25 1 6 4 3 -1 -1 -1 343 200 120 120 NESS 30 30 8 8 4 0 0 0 0 0 0 0 6 33 34 29 30 31 32 0 3 -1 -1 -1 343 200 120 120 PAULA 30 30 8 8 4 0 0 0 0 0 0 0 6 21 22 23 24 37 38 0 3 -1 -1 -1 343 200 120 120 JEFF 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 120 120 ANNA 30 30 8 8 4 0 0 0 0 0 0 0 4 21 25 26 29 0 3 -1 -1 -1 343 200 120 120 KING 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 120 120 POO 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 67 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 8 3 3 3 10 10 10 10 12 12 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 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0 0 0 0 0 0 0 0 0 0 0 0 408 PLAYER 0 \ No newline at end of file diff --git a/states.h b/states.h index c673dd3..8b9da24 100644 --- a/states.h +++ b/states.h @@ -23,6 +23,7 @@ namespace GameState{ TRIGGER_SELECT, MAP_SELECT, MAP_POSITION_SELECT, + FILE_LOAD_SELECT, }; }