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 "VideoSettingsScreen.h"
3#include "SmallButton.h"
4#include "SlideButton.h"
5#include "Options.h"
6#include "ControlsScreen.h"
7#include "..\Minecraft.World\net.minecraft.locale.h"
8
9VideoSettingsScreen::VideoSettingsScreen(Screen *lastScreen, Options *options)
10{
11 this->title = L"Video Settings"; // 4J - added
12 this->lastScreen = lastScreen;
13 this->options = options;
14}
15
16void VideoSettingsScreen::init()
17{
18 Language *language = Language::getInstance();
19 this->title = language->getElement(L"options.videoTitle");
20
21 // 4J - this was as static array but moving it into the function to remove any issues with static initialisation order
22 const Options::Option *items[8] = {
23 Options::Option::GRAPHICS, Options::Option::RENDER_DISTANCE, Options::Option::AMBIENT_OCCLUSION, Options::Option::FRAMERATE_LIMIT, Options::Option::ANAGLYPH, Options::Option::VIEW_BOBBING,
24 Options::Option::GUI_SCALE, Options::Option::ADVANCED_OPENGL
25 };
26
27 for (int position = 0; position < 8; position++)
28 {
29 const Options::Option *item = items[position];
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 }
39
40// buttons.add(new Button(VIDEO_BUTTON_ID, width / 2 - 100, height / 6 + 24 * 4 + 12, language.getElement("options.video")));
41// buttons.add(new Button(CONTROLS_BUTTON_ID, width / 2 - 100, height / 6 + 24 * 5 + 12, language.getElement("options.controls")));
42 buttons.push_back(new Button(200, width / 2 - 100, height / 6 + 24 * 7, language->getElement(L"gui.done")));
43
44}
45
46void VideoSettingsScreen::buttonClicked(Button *button)
47{
48 if (!button->active) return;
49 if (button->id < 100 && (dynamic_cast<SmallButton *>(button) != NULL))
50 {
51 options->toggle(((SmallButton *) button)->getOption(), 1);
52 button->msg = options->getMessage(Options::Option::getItem(button->id));
53 }
54 if (button->id == 200)
55 {
56 minecraft->options->save();
57 minecraft->setScreen(lastScreen);
58 }
59
60 ScreenSizeCalculator ssc(minecraft->options, minecraft->width, minecraft->height);
61 int screenWidth = ssc.getWidth();
62 int screenHeight = ssc.getHeight();
63 Screen::init(minecraft, screenWidth, screenHeight); // 4J - was this.init
64}
65
66void VideoSettingsScreen::render(int xm, int ym, float a)
67{
68 renderBackground();
69 drawCenteredString(font, title, width / 2, 20, 0xffffff);
70 Screen::render(xm, ym, a);
71}