-
Notifications
You must be signed in to change notification settings - Fork 389
Expand file tree
/
Copy pathDialogBox.cpp
More file actions
35 lines (31 loc) · 910 Bytes
/
DialogBox.cpp
File metadata and controls
35 lines (31 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// ----------------------------------------------------------------
// From Game Programming in C++ by Sanjay Madhav
// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
//
// Released under the BSD License
// See LICENSE in root directory for full details.
// ----------------------------------------------------------------
#include "DialogBox.h"
#include "Game.h"
#include "Renderer.h"
#include <SDL/SDL.h>
DialogBox::DialogBox(Game* game, const std::string& text,
std::function<void()> onOK)
:UIScreen(game)
{
// Adjust positions for dialog box
mBGPos = Vector2(0.0f, 0.0f);
mTitlePos = Vector2(0.0f, 100.0f);
mNextButtonPos = Vector2(0.0f, 0.0f);
mBackground = mGame->GetRenderer()->GetTexture("Assets/DialogBG.png");
SetTitle(text, Vector3::Zero, 30);
AddButton("OKButton", [onOK]() {
onOK();
});
AddButton("CancelButton", [this]() {
Close();
});
}
DialogBox::~DialogBox()
{
}