the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "ControlsScreen.h"
3#include "Options.h"
4#include "SmallButton.h"
5#include "..\Minecraft.World\net.minecraft.locale.h"
6
7ControlsScreen::ControlsScreen(Screen *lastScreen, Options *options)
8{
9 // 4J - added initialisers
10 title == L"Controls";
11 selectedKey = -1;
12
13 this->lastScreen = lastScreen;
14 this->options = options;
15}
16
17int ControlsScreen::getLeftScreenPosition()
18{
19 return width / 2 - 155;
20}
21
22void ControlsScreen::init()
23{
24 Language *language = Language::getInstance();
25
26 int leftPos = getLeftScreenPosition();
27 for (int i = 0; i < Options::keyMappings_length; i++)
28 {
29 buttons.push_back(new SmallButton(i, leftPos + i % 2 * ROW_WIDTH, height / 6 + 24 * (i >> 1), BUTTON_WIDTH, 20, options->getKeyMessage(i)));
30 }
31
32 buttons.push_back(new Button(200, width / 2 - 100, height / 6 + 24 * 7, language->getElement(L"gui.done")));
33 title = language->getElement(L"controls.title");
34
35}
36
37void ControlsScreen::buttonClicked(Button *button)
38{
39 for (int i = 0; i < Options::keyMappings_length; i++)
40 {
41 buttons[i]->msg = options->getKeyMessage(i);
42 }
43 if (button->id == 200)
44 {
45 minecraft->setScreen(lastScreen);
46 }
47 else
48 {
49 selectedKey = button->id;
50 button->msg = L"> " + options->getKeyMessage(button->id) + L" <";
51 }
52}
53
54void ControlsScreen::keyPressed(wchar_t eventCharacter, int eventKey)
55{
56 if (selectedKey >= 0)
57 {
58 options->setKey(selectedKey, eventKey);
59 buttons[selectedKey]->msg = options->getKeyMessage(selectedKey);
60 selectedKey = -1;
61 }
62 else
63 {
64 Screen::keyPressed(eventCharacter, eventKey);
65 }
66}
67
68void ControlsScreen::render(int xm, int ym, float a)
69{
70 renderBackground();
71 drawCenteredString(font, title, width / 2, 20, 0xffffff);
72
73 int leftPos = getLeftScreenPosition();
74 for (int i = 0; i < Options::keyMappings_length; i++)
75 {
76 drawString(font, options->getKeyDescription(i), leftPos + i % 2 * ROW_WIDTH + BUTTON_WIDTH + 6, height / 6 + 24 * (i >> 1) + 7, 0xffffffff);
77 }
78
79 Screen::render(xm, ym, a);
80}