Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
2.1 kB · 80 lines
C++
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980#include "stdafx.h"#include "ControlsScreen.h"#include "Options.h"#include "SmallButton.h"#include "..\Minecraft.World\net.minecraft.locale.h"
ControlsScreen::ControlsScreen(Screen *lastScreen, Options *options){ // 4J - added initialisers title == L"Controls"; selectedKey = -1;
this->lastScreen = lastScreen; this->options = options;}
int ControlsScreen::getLeftScreenPosition(){ return width / 2 - 155;}
void ControlsScreen::init(){ Language *language = Language::getInstance();
int leftPos = getLeftScreenPosition(); for (int i = 0; i < Options::keyMappings_length; i++) { buttons.push_back(new SmallButton(i, leftPos + i % 2 * ROW_WIDTH, height / 6 + 24 * (i >> 1), BUTTON_WIDTH, 20, options->getKeyMessage(i))); }
buttons.push_back(new Button(200, width / 2 - 100, height / 6 + 24 * 7, language->getElement(L"gui.done"))); title = language->getElement(L"controls.title");
}
void ControlsScreen::buttonClicked(Button *button){ for (int i = 0; i < Options::keyMappings_length; i++) { buttons[i]->msg = options->getKeyMessage(i); } if (button->id == 200) { minecraft->setScreen(lastScreen); } else { selectedKey = button->id; button->msg = L"> " + options->getKeyMessage(button->id) + L" <"; }}
void ControlsScreen::keyPressed(wchar_t eventCharacter, int eventKey){ if (selectedKey >= 0) { options->setKey(selectedKey, eventKey); buttons[selectedKey]->msg = options->getKeyMessage(selectedKey); selectedKey = -1; } else { Screen::keyPressed(eventCharacter, eventKey); }}
void ControlsScreen::render(int xm, int ym, float a){ renderBackground(); drawCenteredString(font, title, width / 2, 20, 0xffffff);
int leftPos = getLeftScreenPosition(); for (int i = 0; i < Options::keyMappings_length; i++) { drawString(font, options->getKeyDescription(i), leftPos + i % 2 * ROW_WIDTH + BUTTON_WIDTH + 6, height / 6 + 24 * (i >> 1) + 7, 0xffffffff); }
Screen::render(xm, ym, a);}