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 "Button.h"
3#include "OptionsScreen.h"
4#include "SelectWorldScreen.h"
5#include "JoinMultiplayerScreen.h"
6#include "Tesselator.h"
7#include "Textures.h"
8#include "..\Minecraft.World\StringHelpers.h"
9#include "..\Minecraft.World\InputOutputStream.h"
10#include "..\Minecraft.World\net.minecraft.locale.h"
11#include "..\Minecraft.World\System.h"
12#include "..\Minecraft.World\Random.h"
13#include "TitleScreen.h"
14
15Random *TitleScreen::random = new Random();
16
17TitleScreen::TitleScreen()
18{
19 // 4J - added initialisers
20 vo = 0;
21 multiplayerButton = NULL;
22
23 splash = L"missingno";
24// try { // 4J - removed try/catch
25 vector<wstring> splashes;
26
27 /*
28 BufferedReader *br = new BufferedReader(new InputStreamReader(InputStream::getResourceAsStream(L"res\\title\\splashes.txt"))); //, Charset.forName("UTF-8")
29
30 wstring line = L"";
31 while ( !(line = br->readLine()).empty() )
32 {
33 line = trimString( line );
34 if (line.length() > 0)
35 {
36 splashes.push_back(line);
37 }
38 }
39
40 br->close();
41 delete br;
42 */
43
44 splash = L""; //splashes.at(random->nextInt(splashes.size()));
45
46// } catch (Exception e) {
47// }
48}
49
50void TitleScreen::tick()
51{
52 //vo += 1.0f;
53 //if( vo > 100.0f ) minecraft->setScreen(new SelectWorldScreen(this)); // 4J - temp testing
54}
55
56void TitleScreen::keyPressed(wchar_t eventCharacter, int eventKey)
57{
58}
59
60void TitleScreen::init()
61{
62 /* 4J - Implemented in main menu instead
63 Calendar c = Calendar.getInstance();
64 c.setTime(new Date());
65
66 if (c.get(Calendar.MONTH) + 1 == 11 && c.get(Calendar.DAY_OF_MONTH) == 9) {
67 splash = "Happy birthday, ez!";
68 } else if (c.get(Calendar.MONTH) + 1 == 6 && c.get(Calendar.DAY_OF_MONTH) == 1) {
69 splash = "Happy birthday, Notch!";
70 } else if (c.get(Calendar.MONTH) + 1 == 12 && c.get(Calendar.DAY_OF_MONTH) == 24) {
71 splash = "Merry X-mas!";
72 } else if (c.get(Calendar.MONTH) + 1 == 1 && c.get(Calendar.DAY_OF_MONTH) == 1) {
73 splash = "Happy new year!";
74 }
75 */
76
77 Language *language = Language::getInstance();
78
79 const int spacing = 24;
80 const int topPos = height / 4 + spacing * 2;
81
82 buttons.push_back(new Button(1, width / 2 - 100, topPos, language->getElement(L"menu.singleplayer")));
83 buttons.push_back(multiplayerButton = new Button(2, width / 2 - 100, topPos + spacing * 1, language->getElement(L"menu.multiplayer")));
84 buttons.push_back(new Button(3, width / 2 - 100, topPos + spacing * 2, language->getElement(L"menu.mods")));
85
86 if (minecraft->appletMode)
87 {
88 buttons.push_back(new Button(0, width / 2 - 100, topPos + spacing * 3, language->getElement(L"menu.options")));
89 }
90 else
91 {
92 buttons.push_back(new Button(0, width / 2 - 100, topPos + spacing * 3 + 12, 98, 20, language->getElement(L"menu.options")));
93 buttons.push_back(new Button(4, width / 2 + 2, topPos + spacing * 3 + 12, 98, 20, language->getElement(L"menu.quit")));
94 }
95
96 if (minecraft->user == NULL)
97 {
98 multiplayerButton->active = false;
99 }
100
101}
102
103void TitleScreen::buttonClicked(Button *button)
104{
105 if (button->id == 0)
106 {
107 minecraft->setScreen(new OptionsScreen(this, minecraft->options));
108 }
109 if (button->id == 1)
110 {
111 minecraft->setScreen(new SelectWorldScreen(this));
112 }
113 if (button->id == 2)
114 {
115 minecraft->setScreen(new JoinMultiplayerScreen(this));
116 }
117 if (button->id == 3)
118 {
119 // minecraft->setScreen(new TexturePackSelectScreen(this)); // 4J - TODO put back in
120 }
121 if (button->id == 4)
122 {
123 minecraft->stop();
124 }
125}
126
127void TitleScreen::render(int xm, int ym, float a)
128{
129 // 4J Unused
130#if 0
131 renderBackground();
132 Tesselator *t = Tesselator::getInstance();
133
134 int logoWidth = 155 + 119;
135 int logoX = width / 2 - logoWidth / 2;
136 int logoY = 30;
137
138 glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadTexture(L"/title/mclogo.png"));
139 glColor4f(1, 1, 1, 1);
140 blit(logoX + 0, logoY + 0, 0, 0, 155, 44);
141 blit(logoX + 155, logoY + 0, 0, 45, 155, 44);
142 t->color(0xffffff);
143 glPushMatrix();
144 glTranslatef((float)width / 2 + 90, 70, 0);
145
146 glRotatef(-20, 0, 0, 1);
147 float sss = 1.8f - Mth::abs(Mth::sin(System::currentTimeMillis() % 1000 / 1000.0f * PI * 2) * 0.1f);
148
149 sss = sss * 100 / (font->width(splash) + 8 * 4);
150 glScalef(sss, sss, sss);
151 drawCenteredString(font, splash, 0, -8, 0xffff00);
152 glPopMatrix();
153
154 drawString(font, ClientConstants::VERSION_STRING, 2, 2, 0x505050);
155 wstring msg = L"Copyright Mojang AB. Do not distribute.";
156 drawString(font, msg, width - font->width(msg) - 2, height - 10, 0xffffff);
157
158 Screen::render(xm, ym, a);
159#endif
160}