aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/ConfirmScreen.cpp
blob: b67ea19d868be4bd03c4eedc54f4aa4062107271 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "stdafx.h"
#include "ConfirmScreen.h"
#include "SmallButton.h"
#include "..\Minecraft.World\net.minecraft.locale.h"

ConfirmScreen::ConfirmScreen(Screen *parent, const wstring& title1, const wstring& title2, int id)
{
    this->parent = parent;
    this->title1 = title1;
    this->title2 = title2;
    this->id = id;

    Language *language = Language::getInstance();
    yesButton = language->getElement(L"gui.yes");
    noButton = language->getElement(L"gui.no");
}

ConfirmScreen::ConfirmScreen(Screen *parent, const wstring& title1, const wstring& title2, const wstring& yesButton, const wstring& noButton, int id)
{
    this->parent = parent;
    this->title1 = title1;
    this->title2 = title2;
    this->yesButton = yesButton;
    this->noButton = noButton;
    this->id = id;
}

void ConfirmScreen::init()
{
    buttons.push_back(new SmallButton(0, width / 2 - 155 + 0 % 2 * 160, height / 6 + 24 * 4, yesButton));
    buttons.push_back(new SmallButton(1, width / 2 - 155 + 1 % 2 * 160, height / 6 + 24 * 4, noButton));
}

void ConfirmScreen::buttonClicked(Button *button)
{
	parent->confirmResult(button->id == 0, id);
}

void ConfirmScreen::render(int xm, int ym, float a)
{
    renderBackground();

    drawCenteredString(font, title1, width / 2, 70, 0xffffff);
    drawCenteredString(font, title2, width / 2, 90, 0xffffff);

    Screen::render(xm, ym, a);

	// 4J - debug code - remove
	static int count = 0;
	if( count++ == 100 )
	{
		count = 0;
		buttonClicked(buttons[0]);
	}
}