diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 4d7c2d4..b79d12d 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index c7ab0e9..3e1a2c2 100644 --- a/main.cpp +++ b/main.cpp @@ -121,6 +121,14 @@ public: bool GAME_FLAGS[128]={}; Object* PLAYER_OBJ; bool messageBoxVisible=false; + std::string messageBoxText=""; + std::string targetText=""; + std::string messageBoxFinalText=""; + int messageBoxMarker=0; + int messageBoxStartMarker=0; //Start of text display. + int messageBoxStopMarker=0; //End of text display for current printout. + int messageBoxFrameWaitTime=1; + bool messageBoxLoad=false; //Set to true when ready to load a message in. bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things. @@ -159,6 +167,11 @@ public: //OBJ_INFO["PLAYER"]=PLAYER_ANIMATION; LoadMap(MAP_ONETT); + DisplayMessageBox(R"(Hello World! +This is a rather long message, but I hope it reaches you well +in some form or capacity or another. Even though it +goes on a very long time, I hope you can understand this is only for testing purposes! +)"); return true; } @@ -189,6 +202,22 @@ public: drawGame(); return true; } + void GetAnyKeyPress() override { + if (messageBoxVisible) { + if (messageBoxMarker==messageBoxFinalText.length()) { + if (messageBoxStartMarker+messageBoxStopMarker=WIDTH/2-MESSAGE_BORDER_X) { + while (messageBoxFinalText[messageBoxStopMarker]!=' ') { + messageBoxStopMarker--; + }; + messageBoxFinalText.erase(messageBoxFinalText.begin()+messageBoxStopMarker,messageBoxFinalText.end()); + messageBoxFinalText+='\n'; + charsWritten=false; + } + } + messageBoxLoad=false; + } else { + if (messageBoxMarkertargetText=targetText; + messageBoxText=""; + messageBoxFinalText=""; + messageBoxLoad=true; + messageBoxVisible=true; + messageBoxMarker=0; + messageBoxStartMarker=0; + messageBoxStopMarker=0; + } + + void DrawDialogBox(const vi2d &pos, const vi2d &size, Pixel p = WHITE, Pixel p2 = DARK_GREY, Pixel p3 = VERY_DARK_GREY) { + FillRect({(float)pos.x,(float)pos.y},size,p2); + FillRect({(float)pos.x+1,(float)pos.y+1},{(float)size.x-2,(float)size.y-2},p); + FillRect({(float)pos.x+2,(float)pos.y+2},{(float)size.x-4,(float)size.y-4},p3); + FillRect({(float)pos.x+3,(float)pos.y+3},{(float)size.x-5,(float)size.y-5},p); + Draw({pos.x,pos.y},Pixel(77, 51, 125)); + Draw({pos.x+size.x-1,pos.y+size.y-1},Pixel(77, 51, 125)); + Draw({pos.x+size.x-1,pos.y},Pixel(77, 51, 125)); + Draw({pos.x,pos.y+size.y-1},Pixel(77, 51, 125)); + } };