aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_NewUpdateMessage.cpp
blob: 118712a463fc5c105c1af117eefbeeb6b791c48f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "stdafx.h"
#include "UI.h"
#include "UIScene_NewUpdateMessage.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"

UIScene_NewUpdateMessage::UIScene_NewUpdateMessage(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
	// Setup all the Iggy references we need for this scene
	initialiseMovie();

	parentLayer->addComponent(iPad,eUIComponent_Panorama);
	parentLayer->addComponent(iPad,eUIComponent_Logo);

	m_buttonConfirm.init(app.GetString(IDS_TOOLTIPS_ACCEPT),eControl_Confirm);

	wstring message = app.GetString(IDS_TITLEUPDATE);
	message.append(L"\r\n");

	message=app.FormatHTMLString(m_iPad,message);

	vector<wstring> paragraphs;
	size_t lastIndex = 0;
	for (	size_t index = message.find(L"\r\n", lastIndex, 2);
			index != wstring::npos; 
			index = message.find(L"\r\n", lastIndex, 2)
		)
	{
		paragraphs.push_back( message.substr(lastIndex, index-lastIndex) + L" " );
		lastIndex = index + 2;
	}
	paragraphs.push_back( message.substr( lastIndex, message.length() - lastIndex ) );

	for(unsigned int i = 0; i < paragraphs.size(); ++i)
	{
		m_labelDescription.addText(paragraphs[i],i == (paragraphs.size() - 1) );
	}

	m_bIgnoreInput=false;

#ifdef __PSVITA__
	ui.TouchBoxRebuild(this);
#endif
}

UIScene_NewUpdateMessage::~UIScene_NewUpdateMessage()
{
	m_parentLayer->removeComponent(eUIComponent_Panorama);
	m_parentLayer->removeComponent(eUIComponent_Logo);
}

wstring UIScene_NewUpdateMessage::getMoviePath()
{
	return L"EULA";
}

void UIScene_NewUpdateMessage::updateTooltips()
{
	ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT );
}

void UIScene_NewUpdateMessage::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
{
	if(m_bIgnoreInput) return;

#ifdef __ORBIS__
	// ignore all players except player 0 - it's their profile that is currently being used
	if(iPad!=0) return;
#endif
	
	ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);

	switch(key)
	{
	case ACTION_MENU_B:
		{
			int iVal=app.GetGameSettings(m_iPad,eGameSetting_DisplayUpdateMessage);
			if(iVal>0) iVal--;

			// set the update text as seen, by clearing the flag
			app.SetGameSettings(m_iPad,eGameSetting_DisplayUpdateMessage,iVal);
			// force a profile write
			app.CheckGameSettingsChanged(true,m_iPad);
			ui.NavigateBack(m_iPad);
		}
		break;
#ifdef __ORBIS__
	case ACTION_MENU_TOUCHPAD_PRESS:
#endif
	case ACTION_MENU_OK:
	case ACTION_MENU_DOWN:
	case ACTION_MENU_UP:
	case ACTION_MENU_PAGEUP:
	case ACTION_MENU_PAGEDOWN:
	case ACTION_MENU_OTHER_STICK_DOWN:
	case ACTION_MENU_OTHER_STICK_UP:
		sendInputToMovie(key, repeat, pressed, released);
		break;
	}
}

void UIScene_NewUpdateMessage::handlePress(F64 controlId, F64 childId)
{
	switch(static_cast<int>(controlId))
	{
	case eControl_Confirm:
		{
			//CD - Added for audio
			ui.PlayUISFX(eSFX_Press);

			int iVal=app.GetGameSettings(m_iPad,eGameSetting_DisplayUpdateMessage);
			if(iVal>0) iVal--;

			// set the update text as seen, by clearing the flag
			app.SetGameSettings(m_iPad,eGameSetting_DisplayUpdateMessage,iVal);
			// force a profile write
			app.CheckGameSettingsChanged(true,m_iPad);
			ui.NavigateBack(m_iPad);
		}
		break;
	};
}