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 "AchievementPopup.h"
3#include "ItemRenderer.h"
4#include "Font.h"
5#include "Textures.h"
6#include "Lighting.h"
7#include "..\Minecraft.World\System.h"
8#include "..\Minecraft.World\net.minecraft.locale.h"
9#include "..\Minecraft.World\net.minecraft.stats.h"
10#include "..\Minecraft.World\SharedConstants.h"
11
12AchievementPopup::AchievementPopup(Minecraft *mc)
13{
14 // 4J - added initialisers
15 width = 0;
16 height = 0;
17 ach = NULL;
18 startTime = 0;
19 isHelper = false;
20
21 this->mc = mc;
22 ir = new ItemRenderer();
23}
24
25void AchievementPopup::popup(Achievement *ach)
26{
27 title = I18n::get(L"achievement.get");
28 desc = ach->name;
29 startTime = System::currentTimeMillis();
30 this->ach = ach;
31 isHelper = false;
32}
33
34void AchievementPopup::permanent(Achievement *ach)
35{
36 title = ach->name;
37 desc = ach->getDescription();
38
39 startTime = System::currentTimeMillis() - 2500;
40 this->ach = ach;
41 isHelper = true;
42}
43
44void AchievementPopup::prepareWindow()
45{
46 glViewport(0, 0, mc->width, mc->height);
47 glMatrixMode(GL_PROJECTION);
48 glLoadIdentity();
49 glMatrixMode(GL_MODELVIEW);
50 glLoadIdentity();
51
52 this->width = mc->width;
53 this->height = mc->height;
54
55 ScreenSizeCalculator ssc(mc->options, mc->width, mc->height);
56 width = ssc.getWidth();
57 height = ssc.getHeight();
58
59 glClear(GL_DEPTH_BUFFER_BIT);
60 glMatrixMode(GL_PROJECTION);
61 glLoadIdentity();
62 glOrtho(0, (float)width, (float)height, 0, 1000, 3000);
63 glMatrixMode(GL_MODELVIEW);
64 glLoadIdentity();
65 glTranslatef(0, 0, -2000);
66
67}
68
69void AchievementPopup::render()
70{
71// 4J Unused
72#if 0
73 if (Minecraft::warezTime > 0)
74 {
75 glDisable(GL_DEPTH_TEST);
76 glDepthMask(false);
77 Lighting::turnOff();
78 prepareWindow();
79
80 wstring title = L"Minecraft " + SharedConstants::VERSION_STRING + L" Unlicensed Copy :(";
81 wstring msg1 = L"(Or logged in from another location)";
82 wstring msg2 = L"Purchase at minecraft.net";
83
84 mc->font->drawShadow(title, 2, 2 + 9 * 0, 0xffffff);
85 mc->font->drawShadow(msg1, 2, 2 + 9 * 1, 0xffffff);
86 mc->font->drawShadow(msg2, 2, 2 + 9 * 2, 0xffffff);
87
88 glDepthMask(true);
89 glEnable(GL_DEPTH_TEST);
90 }
91 if (ach == NULL || startTime == 0) return;
92
93 double time = (System::currentTimeMillis() - startTime) / 3000.0;
94 if (isHelper)
95 {
96 }
97 else if (!isHelper && (time < 0 || time > 1))
98 {
99 startTime = 0;
100 return;
101 }
102
103
104 prepareWindow();
105 glDisable(GL_DEPTH_TEST);
106 glDepthMask(false);
107
108 double yo = time * 2;
109 if (yo > 1) yo = 2 - yo;
110 yo = yo * 4;
111 yo = 1 - yo;
112 if (yo < 0) yo = 0;
113 yo = yo * yo;
114 yo = yo * yo;
115
116 int xx = width - 160;
117 int yy = 0 - (int) (yo * 36);
118 int tex = mc->textures->loadTexture(L"/achievement/bg.png");
119 glColor4f(1, 1, 1, 1);
120 glEnable(GL_TEXTURE_2D);
121 glBindTexture(GL_TEXTURE_2D, tex);
122 glDisable(GL_LIGHTING);
123
124 blit(xx, yy, 96, 202, 160, 32);
125
126 if (isHelper)
127 {
128 mc->font->drawWordWrap(desc, xx + 30, yy + 7, 120, 0xffffffff);
129 }
130 else
131 {
132 mc->font->draw(title, xx + 30, yy + 7, 0xffffff00);
133 mc->font->draw(desc, xx + 30, yy + 18, 0xffffffff);
134 }
135
136 glPushMatrix();
137 glRotatef(180, 1, 0, 0);
138 Lighting::turnOn();
139 glPopMatrix();
140 glDisable(GL_LIGHTING);
141 glEnable(GL_RESCALE_NORMAL);
142 glEnable(GL_COLOR_MATERIAL);
143
144 glEnable(GL_LIGHTING);
145 ir->renderGuiItem(mc->font, mc->textures, ach->icon, xx + 8, yy + 8);
146 glDisable(GL_LIGHTING);
147
148 glDepthMask(true);
149 glEnable(GL_DEPTH_TEST);
150#endif
151}