the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 77 lines 2.7 kB view raw
1#include "stdafx.h" 2#include "OptionsScreen.h" 3#include "SmallButton.h" 4#include "SlideButton.h" 5#include "Options.h" 6#include "ControlsScreen.h" 7#include "VideoSettingsScreen.h" 8#include "..\Minecraft.World\net.minecraft.locale.h" 9 10OptionsScreen::OptionsScreen(Screen *lastScreen, Options *options) 11{ 12 title = L"Options"; // 4J added 13 14 this->lastScreen = lastScreen; 15 this->options = options; 16} 17 18void OptionsScreen::init() 19{ 20 Language *language = Language::getInstance(); 21 this->title = language->getElement(L"options.title"); 22 23 int position = 0; 24 25 // 4J - this was as static array but moving it into the function to remove any issues with static initialisation order 26 const Options::Option *items[5] = {Options::Option::MUSIC, Options::Option::SOUND, Options::Option::INVERT_MOUSE, Options::Option::SENSITIVITY, Options::Option::DIFFICULTY}; 27 for (int i = 0; i < 5; i++) 28 { 29 const Options::Option *item = items[i]; 30 if (!item->isProgress()) 31 { 32 buttons.push_back(new SmallButton(item->getId(), width / 2 - 155 + position % 2 * 160, height / 6 + 24 * (position >> 1), item, options->getMessage(item))); 33 } 34 else 35 { 36 buttons.push_back(new SlideButton(item->getId(), width / 2 - 155 + position % 2 * 160, height / 6 + 24 * (position >> 1), item, options->getMessage(item), options->getProgressValue(item))); 37 } 38 position++; 39 } 40 41 buttons.push_back(new Button(VIDEO_BUTTON_ID, width / 2 - 100, height / 6 + 24 * 4 + 12, language->getElement(L"options.video"))); 42 buttons.push_back(new Button(CONTROLS_BUTTON_ID, width / 2 - 100, height / 6 + 24 * 5 + 12, language->getElement(L"options.controls"))); 43 buttons.push_back(new Button(200, width / 2 - 100, height / 6 + 24 * 7, language->getElement(L"gui.done"))); 44 45} 46 47void OptionsScreen::buttonClicked(Button *button) 48{ 49 if (!button->active) return; 50 if (button->id < 100 && (dynamic_cast<SmallButton *>(button) != NULL)) 51 { 52 options->toggle(((SmallButton *) button)->getOption(), 1); 53 button->msg = options->getMessage(Options::Option::getItem(button->id)); 54 } 55 if (button->id == VIDEO_BUTTON_ID) 56 { 57 minecraft->options->save(); 58 minecraft->setScreen(new VideoSettingsScreen(this, options)); 59 } 60 if (button->id == CONTROLS_BUTTON_ID) 61 { 62 minecraft->options->save(); 63 minecraft->setScreen(new ControlsScreen(this, options)); 64 } 65 if (button->id == 200) 66 { 67 minecraft->options->save(); 68 minecraft->setScreen(lastScreen); 69 } 70} 71 72void OptionsScreen::render(int xm, int ym, float a) 73{ 74 renderBackground(); 75 drawCenteredString(font, title, width / 2, 20, 0xffffff); 76 Screen::render(xm, ym, a); 77}