|
|
|
@ -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<targetText.length()) { |
|
|
|
|
messageBoxStartMarker+=messageBoxStopMarker; |
|
|
|
|
messageBoxStopMarker=0; |
|
|
|
|
messageBoxFinalText=""; |
|
|
|
|
messageBoxText=""; |
|
|
|
|
messageBoxMarker=0; |
|
|
|
|
messageBoxLoad=true; |
|
|
|
|
} else { |
|
|
|
|
messageBoxVisible=false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void updateGame(){ |
|
|
|
|
frameCount++; |
|
|
|
@ -292,6 +321,40 @@ public: |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (messageBoxVisible) { |
|
|
|
|
if (messageBoxLoad) { |
|
|
|
|
const int MESSAGE_BORDER_X=4; |
|
|
|
|
const int MESSAGE_BORDER_Y=4; |
|
|
|
|
bool charsWritten=false; |
|
|
|
|
while (messageBoxStartMarker+messageBoxStopMarker<targetText.length()&&GetTextSizeProp(messageBoxFinalText).y<HEIGHT/4-MESSAGE_BORDER_Y) { |
|
|
|
|
while (messageBoxStartMarker+messageBoxStopMarker<targetText.length()&&GetTextSizeProp(messageBoxFinalText).x<WIDTH/2-MESSAGE_BORDER_X) { |
|
|
|
|
if (!charsWritten&&targetText[messageBoxStopMarker+messageBoxStartMarker]!=' ') { |
|
|
|
|
messageBoxFinalText+=targetText[messageBoxStopMarker+++messageBoxStartMarker]; |
|
|
|
|
charsWritten=true; |
|
|
|
|
} else
|
|
|
|
|
if (charsWritten){ |
|
|
|
|
messageBoxFinalText+=targetText[messageBoxStopMarker+++messageBoxStartMarker]; |
|
|
|
|
} else { |
|
|
|
|
messageBoxStartMarker++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (GetTextSizeProp(messageBoxFinalText).x>=WIDTH/2-MESSAGE_BORDER_X) { |
|
|
|
|
while (messageBoxFinalText[messageBoxStopMarker]!=' ') { |
|
|
|
|
messageBoxStopMarker--; |
|
|
|
|
}; |
|
|
|
|
messageBoxFinalText.erase(messageBoxFinalText.begin()+messageBoxStopMarker,messageBoxFinalText.end()); |
|
|
|
|
messageBoxFinalText+='\n'; |
|
|
|
|
charsWritten=false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
messageBoxLoad=false; |
|
|
|
|
} else { |
|
|
|
|
if (messageBoxMarker<messageBoxFinalText.length()) { |
|
|
|
|
messageBoxText+=messageBoxFinalText[messageBoxMarker++]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
|
|
|
|
|
cameraUpdate(); |
|
|
|
|
} |
|
|
|
@ -443,11 +506,11 @@ public: |
|
|
|
|
} |
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
|
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); |
|
|
|
|
if (EDITING_LAYER==layer::OBJECT) { |
|
|
|
|
/*if (EDITING_LAYER==layer::OBJECT) {
|
|
|
|
|
DrawStringPropDecal({2,2},"Editing Objects"); |
|
|
|
|
} else { |
|
|
|
|
DrawStringPropDecal({2,2},"Editing Layer "+std::to_string(EDITING_LAYER)); |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
}break; |
|
|
|
|
case GameState::TILE_SELECT:{ |
|
|
|
|
//14x14 pixels per tile.
|
|
|
|
@ -489,6 +552,11 @@ public: |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
if (messageBoxVisible) { |
|
|
|
|
SetDrawTarget(layer::INTERFACE); |
|
|
|
|
DrawDialogBox({1,1},{WIDTH/2,HEIGHT/4},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128)); |
|
|
|
|
DrawStringPropDecal({6,6},messageBoxText); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
void LoadMap(Map*map) { |
|
|
|
@ -1051,6 +1119,28 @@ public: |
|
|
|
|
bool PlayerCanMove(){ |
|
|
|
|
return !messageBoxVisible&&PLAYER_OBJ!=nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DisplayMessageBox(std::string targetText) { |
|
|
|
|
this->targetText=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)); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|