git repos / blockattack-game

commit 96e759d9

sago007 · 2016-04-17 18:45
96e759d9abf8408478d5b0c7920d82ba239f799e patch · browse files
parent 7a792f2c6f13ab246cdc1ff06b606bfe5e812189

Header on dialog box

Changed files

M source/code/DialogBox.cpp before
M source/code/DialogBox.hpp before
M source/code/global.hpp before
M source/code/menudef.cpp before
diff --git a/source/code/DialogBox.cpp b/source/code/DialogBox.cpp index 8481bad..f8ae13b 100644 --- a/source/code/DialogBox.cpp +++ b/source/code/DialogBox.cpp
@@ -69,8 +69,8 @@ static void DrawRectYellow(SDL_Renderer* target, int topx, int topy, int height,
DrawRect(target, topx, topy, height, width, name);
}
-bool OpenDialogbox(int x, int y, std::string& name) {
- DialogBox d(x, y, name);
+bool OpenDialogbox(int x, int y, std::string& name, const std::string& header) {
+ DialogBox d(x, y, name, header);
RunGameState(d);
if (d.IsUpdated()) {
name = d.GetName();
@@ -79,7 +79,7 @@ bool OpenDialogbox(int x, int y, std::string& name) {
return false;
}
-DialogBox::DialogBox(int x, int y, const std::string& name) {
+DialogBox::DialogBox(int x, int y, const std::string& name, const std::string& header) : header(header) {
this->x = x;
this->y = y;
SetName(name);
@@ -97,7 +97,7 @@ bool DialogBox::IsActive() {
void DialogBox::Draw(SDL_Renderer* target) {
backgroundImage.Draw(screen, SDL_GetTicks(), 0, 0);
DrawRectYellow(screen, x, y, 200, 600);
- nf_button_font.draw(screen, x+300, y+20, NFont::CENTER, _("Enter player name:"));
+ nf_button_font.draw(screen, x+300, y+20, NFont::CENTER, "%s", header.c_str());
nf_button_font.draw(screen, x+150, y+140, NFont::CENTER, _("Enter to accept"));
nf_button_font.draw(screen, x+450, y+140, NFont::CENTER, _("Esc to cancel"));
DrawRectWhite(screen, x+26, y+64, 54, 600-2*26);
diff --git a/source/code/DialogBox.hpp b/source/code/DialogBox.hpp index be010bb..a3a00f1 100644 --- a/source/code/DialogBox.hpp +++ b/source/code/DialogBox.hpp
@@ -33,7 +33,7 @@ http://www.blockattack.net
class DialogBox : public sago::GameStateInterface {
public:
- DialogBox(int x, int y, const std::string& name);
+ DialogBox(int x, int y, const std::string& name, const std::string& header);
DialogBox(const DialogBox& orig) = delete;
virtual ~DialogBox();
@@ -49,6 +49,7 @@ private:
int x;
int y;
std::string name;
+ std::string header;
bool updated = false;
SDL_TextInput textInputScope;
};
diff --git a/source/code/global.hpp b/source/code/global.hpp index ce11b19..ab42ac5 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp
@@ -33,7 +33,7 @@ http://blockattack.net
void MainMenu();
void ResetFullscreen();
void RunGameState(sago::GameStateInterface& state );
-bool OpenDialogbox(int x, int y, std::string& name);
+bool OpenDialogbox(int x, int y, std::string& name, const std::string& header);
extern sago::SagoSprite menuMarked;
extern sago::SagoSprite menuUnmarked;
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp index a24a684..415bb15 100644 --- a/source/code/menudef.cpp +++ b/source/code/menudef.cpp
@@ -46,7 +46,6 @@ struct control {
SDL_Keycode push;
};
-bool OpenDialogbox(int x, int y, std::string& name);
void OpenScoresDisplay();
extern control keySettings[3];
@@ -145,13 +144,13 @@ static void buttonActionFullscreen(Button* b) {
}
static void buttonActionPlayer1Name(Button* b) {
- if (OpenDialogbox(200, 100, player1name)) {
+ if ( OpenDialogbox(200, 100, player1name, _("Enter player 1 name:")) ) {
return; //must save if true
}
}
static void buttonActionPlayer2Name(Button* b) {
- if (OpenDialogbox(200, 100, player2name)) {
+ if ( OpenDialogbox(200, 100, player2name, _("Enter player 2 name:")) ) {
return; //must save if true
}
}