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 "UI.h"
3#include "UIComponent_Chat.h"
4#include "..\..\Minecraft.h"
5#include "..\..\Gui.h"
6
7UIComponent_Chat::UIComponent_Chat(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
8{
9 // Setup all the Iggy references we need for this scene
10 initialiseMovie();
11
12 for(unsigned int i = 0; i < CHAT_LINES_COUNT; ++i)
13 {
14 m_labelChatText[i].init(L"");
15 }
16 m_labelJukebox.init(L"");
17
18 addTimer(0, 100);
19}
20
21wstring UIComponent_Chat::getMoviePath()
22{
23 switch( m_parentLayer->getViewport() )
24 {
25 case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
26 case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
27 case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
28 case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
29 case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
30 case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
31 case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
32 case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
33 m_bSplitscreen = true;
34 return L"ComponentChatSplit";
35 break;
36 case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
37 default:
38 m_bSplitscreen = false;
39 return L"ComponentChat";
40 break;
41 }
42}
43
44void UIComponent_Chat::handleTimerComplete(int id)
45{
46 Minecraft *pMinecraft = Minecraft::GetInstance();
47
48 bool anyVisible = false;
49 if(pMinecraft->localplayers[m_iPad]!= NULL)
50 {
51 Gui *pGui = pMinecraft->gui;
52 //DWORD messagesToDisplay = min( CHAT_LINES_COUNT, pGui->getMessagesCount(m_iPad) );
53 for( unsigned int i = 0; i < CHAT_LINES_COUNT; ++i )
54 {
55 float opacity = pGui->getOpacity(m_iPad, i);
56 if( opacity > 0 )
57 {
58 m_controlLabelBackground[i].setOpacity(opacity);
59 m_labelChatText[i].setOpacity(opacity);
60 m_labelChatText[i].setLabel( pGui->getMessage(m_iPad,i) );
61
62 anyVisible = true;
63 }
64 else
65 {
66 m_controlLabelBackground[i].setOpacity(0);
67 m_labelChatText[i].setOpacity(0);
68 m_labelChatText[i].setLabel(L"");
69 }
70 }
71 if(pGui->getJukeboxOpacity(m_iPad) > 0) anyVisible = true;
72 m_labelJukebox.setOpacity( pGui->getJukeboxOpacity(m_iPad) );
73 m_labelJukebox.setLabel( pGui->getJukeboxMessage(m_iPad) );
74 }
75 else
76 {
77 for( unsigned int i = 0; i < CHAT_LINES_COUNT; ++i )
78 {
79 m_controlLabelBackground[i].setOpacity(0);
80 m_labelChatText[i].setOpacity(0);
81 m_labelChatText[i].setLabel(L"");
82 }
83 m_labelJukebox.setOpacity( 0 );
84 }
85
86 setVisible(anyVisible);
87}
88
89void UIComponent_Chat::render(S32 width, S32 height, C4JRender::eViewportType viewport)
90{
91 if(m_bSplitscreen)
92 {
93 S32 xPos = 0;
94 S32 yPos = 0;
95 switch( viewport )
96 {
97 case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
98 case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
99 yPos = (S32)(ui.getScreenHeight() / 2);
100 break;
101 case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
102 case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
103 xPos = (S32)(ui.getScreenWidth() / 2);
104 break;
105 case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
106 xPos = (S32)(ui.getScreenWidth() / 2);
107 yPos = (S32)(ui.getScreenHeight() / 2);
108 break;
109 }
110 ui.setupRenderPosition(xPos, yPos);
111
112 S32 tileXStart = 0;
113 S32 tileYStart = 0;
114 S32 tileWidth = width;
115 S32 tileHeight = height;
116
117 switch( viewport )
118 {
119 case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
120 case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
121 tileHeight = (S32)(ui.getScreenHeight());
122 break;
123 case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
124 tileWidth = (S32)(ui.getScreenWidth());
125 tileYStart = (S32)(m_movieHeight / 2);
126 break;
127 case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
128 tileWidth = (S32)(ui.getScreenWidth());
129 tileYStart = (S32)(m_movieHeight / 2);
130 break;
131 case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
132 case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
133 case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
134 case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
135 tileYStart = (S32)(m_movieHeight / 2);
136 break;
137 }
138
139 IggyPlayerSetDisplaySize( getMovie(), m_movieWidth, m_movieHeight );
140
141 IggyPlayerDrawTilesStart ( getMovie() );
142
143 m_renderWidth = tileWidth;
144 m_renderHeight = tileHeight;
145 IggyPlayerDrawTile ( getMovie() ,
146 tileXStart ,
147 tileYStart ,
148 tileXStart + tileWidth ,
149 tileYStart + tileHeight ,
150 0 );
151 IggyPlayerDrawTilesEnd ( getMovie() );
152 }
153 else
154 {
155 UIScene::render(width, height, viewport);
156 }
157}