aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_SaveMessage.cpp
blob: 0b8e0ca4ac18cea96487b73df4ca5c2951ba2e79 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include "stdafx.h"
#include "UI.h"
#include "UIScene_SaveMessage.h"

#define PROFILE_LOADED_TIMER_ID 0
#define PROFILE_LOADED_TIMER_TIME 50

UIScene_SaveMessage::UIScene_SaveMessage(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_CONFIRM_OK),eControl_Confirm);
	m_labelDescription.init(app.GetString(IDS_SAVE_ICON_MESSAGE));

	IggyDataValue result;

	// Russian needs to resize the box
	IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , nullptr );

	// 4J-PB - If we have a signed in user connected, let's get the DLC now
	for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
	{
		if( (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) ) 
		{
			if(!app.DLCInstallProcessCompleted() && !app.DLCInstallPending()) 
			{
				app.StartInstallDLCProcess(i);
				break;
			}
		}
	}

	m_bIgnoreInput=false;

	// 4J-TomK - rebuild touch after auto resize
#ifdef __PSVITA__
	ui.TouchBoxRebuild(this);
#endif
}

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

wstring UIScene_SaveMessage::getMoviePath()
{
	return L"SaveMessage";
}

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

void UIScene_SaveMessage::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
{
	if(m_bIgnoreInput) return;
#if defined (__ORBIS__) || defined (__PSVITA__)
	// 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_OK:
#ifdef __ORBIS__
	case ACTION_MENU_TOUCHPAD_PRESS:
#endif
		sendInputToMovie(key, repeat, pressed, released);
		break;
		// #ifdef __PS3__
		// 	case ACTION_MENU_Y:
		// 		if(pressed)
		// 		{		
		// 			// language select - switch to Greek for now
		// 			if(app.GetMinecraftLanguage(iPad)==MINECRAFT_LANGUAGE_DEFAULT)
		// 			{
		// 				app.SetMinecraftLanguage(iPad,MINECRAFT_LANGUAGE_GREEK);
		// 			}
		// 			else
		// 			{
		// 				app.SetMinecraftLanguage(iPad,MINECRAFT_LANGUAGE_DEFAULT);
		// 			}
		// 			// reload the string table
		// 			ui.SetupFont();
		// 			app.loadStringTable();
		// 			handleReload();
		// 		}
		// 		break;
		// #endif
	}
}

void UIScene_SaveMessage::handlePress(F64 controlId, F64 childId)
{
	switch(static_cast<int>(controlId))
	{
	case eControl_Confirm:

		//CD - Added for audio
		ui.PlayUISFX(eSFX_Press);

		m_bIgnoreInput=true;

#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
		// wait for the profile to be read - this has been kicked off earlier, so should be read by now
		addTimer(PROFILE_LOADED_TIMER_ID,PROFILE_LOADED_TIMER_TIME);
#else
		ui.NavigateToHomeMenu();
#endif
		break;
	};
}

void UIScene_SaveMessage::handleTimerComplete(int id)
{
	switch(id)
	{
	case PROFILE_LOADED_TIMER_ID:
		{
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
			C4JStorage::eOptionsCallback eStatus=app.GetOptionsCallbackStatus(0);

			switch(eStatus)
			{
			case C4JStorage::eOptions_Callback_Read:
			case C4JStorage::eOptions_Callback_Read_FileNotFound:
			case C4JStorage::eOptions_Callback_Read_Fail:
#ifdef __PSVITA__
			case C4JStorage::eOptions_Callback_Write_Fail:
			case C4JStorage::eOptions_Callback_Write:
#endif
				// set defaults - which has already been done				
				killTimer(PROFILE_LOADED_TIMER_ID);
				ui.NavigateToHomeMenu();
				SQRNetworkManager::SafeToRespondToGameBootInvite();
				app.SetOptionsCallbackStatus(0,C4JStorage::eOptions_Callback_Idle);
				break;
			case C4JStorage::eOptions_Callback_Read_CorruptDeleted:
				killTimer(PROFILE_LOADED_TIMER_ID);
				ui.NavigateToHomeMenu();
				SQRNetworkManager::SafeToRespondToGameBootInvite();
				app.SetOptionsCallbackStatus(0,C4JStorage::eOptions_Callback_Idle);
				break;
			case C4JStorage::eOptions_Callback_Read_Corrupt:
				// get the user to delete the options file
				app.DebugPrintf("Corrupt options file\n");
				app.SetOptionsCallbackStatus(0,C4JStorage::eOptions_Callback_Read_CorruptDeletePending);
				m_bIgnoreInput=false;
				// give the option to delete the save
				UINT uiIDA[2];
				uiIDA[0]=IDS_CORRUPT_OPTIONS_RETRY;
				uiIDA[1]=IDS_CORRUPT_OPTIONS_DELETE;
				ui.RequestErrorMessage(IDS_CORRUPT_FILE, IDS_CORRUPT_OPTIONS, uiIDA, 2, 0,&UIScene_SaveMessage::DeleteOptionsDialogReturned,this);
				break;
			}
#endif
		}

		break;
	}
}

#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
int UIScene_SaveMessage::DeleteOptionsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
	//UIScene_SaveMessage* pClass = (UIScene_SaveMessage*)pParam;
	if(result == C4JStorage::EMessage_ResultAccept)
	{
		// retry loading the options file
		StorageManager.ReadFromProfile(iPad);
	}
	else // result == EMessage_ResultDecline
	{
		// kick off the delete
		StorageManager.DeleteOptionsData(iPad);
	}
	return 0;
}
#endif