aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/XUI/XUI_SocialPost.cpp
blob: 2bd842638f83e1e9f117251539b852ee1dbf8c6a (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
// Minecraft.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

#include <assert.h>
#include "..\XUI\XUI_SocialPost.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\SharedConstants.h"
#include "..\..\..\Minecraft.World\Random.h"
#include "..\..\..\Minecraft.Client\SurvivalMode.h"
#include "..\..\..\Minecraft.Client\CreateWorldScreen.h"
#include "..\..\..\Minecraft.World\ConsoleSaveFileIO.h"
#include "..\..\..\Minecraft.World\AABB.h"
#include "..\..\..\Minecraft.World\Vec3.h"
#include "..\..\LocalPlayer.h"


//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_SocialPost::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
	m_iPad = *static_cast<int *>(pInitData->pvInitData);

	MapChildControls();
	
	XuiControlSetText(m_text,app.GetString(IDS_SOCIAL_TEXT));
	XuiControlSetText(m_LabelCaption,app.GetString(IDS_SOCIAL_LABEL_CAPTION));
	XuiControlSetText(m_EditCaption,app.GetString(IDS_SOCIAL_DEFAULT_CAPTION));
	XuiControlSetText(m_LabelDescription,app.GetString(IDS_SOCIAL_LABEL_DESCRIPTION));
	XuiControlSetText(m_EditDesc,app.GetString(IDS_SOCIAL_DEFAULT_DESCRIPTION));
	XuiControlSetText(m_OK,app.GetString(IDS_CONFIRM_OK));

	ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);


	m_EditCaption.SetTextLimit(MAX_SOCIALPOST_CAPTION);
	m_EditDesc.SetTextLimit(MAX_SOCIALPOST_DESC);
	
	// Hardcoded so posts will have this in 
	m_wTitle = L"Minecraft: Xbox 360 Edition";

	m_EditCaption.SetTitleAndText(IDS_NAME_CAPTION,IDS_NAME_CAPTION_TEXT);
	m_EditDesc.SetTitleAndText(IDS_NAME_DESC,IDS_NAME_DESC_TEXT);

	wstring wCaption = m_EditCaption.GetText();
	wstring wDesc = m_EditDesc.GetText();

	// set the caret to the end of the default text
	m_EditCaption.SetCaretPosition(static_cast<int>(wCaption.length()));
	m_EditDesc.SetCaretPosition(static_cast<int>(wDesc.length()));
	
	BOOL bHasAllText = /*( wTitle.length()!=0) && */(wCaption.length()!=0) && (wDesc.length()!=0);

	m_OK.SetEnable(bHasAllText); 

	if(app.GetLocalPlayerCount()>1)
	{
		app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
	}
	
	TelemetryManager->RecordMenuShown(m_iPad, eUIScene_SocialPost, 0);

	return S_OK;
}


HRESULT CScene_SocialPost::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValueChanged* pValueChangedData, BOOL& rfHandled)
{	wstring wCaption = m_EditCaption.GetText();
wstring wDesc = m_EditDesc.GetText();


	if(/*(hObjSource == m_EditTitle) || */(hObjSource == m_EditCaption) || (hObjSource == m_EditDesc))
	{
		//  Enable the done button when we have all of the necessary information
		//wstring wTitle = m_EditTitle.GetText();
		wstring wCaption = m_EditCaption.GetText();
		wstring wDesc = m_EditDesc.GetText();

		BOOL bHasAllText = /*( wTitle.length()!=0) &&*/ (wCaption.length()!=0) && (wDesc.length()!=0);
		m_OK.SetEnable(bHasAllText);        
	}

	return S_OK;
}

HRESULT CScene_SocialPost::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled)
{
	pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE);

	if(pControlNavigateData->hObjDest==nullptr)
	{
		pControlNavigateData->hObjDest=pControlNavigateData->hObjSource;
	}

	bHandled=TRUE;
	return S_OK;
}

//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_SocialPost::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
	// This assumes all buttons can only be pressed with the A button
	ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
	
	if(hObjPressed==m_OK)
	{
		CSocialManager::Instance()->SetSocialPostText(m_wTitle.c_str(),m_EditCaption.GetText(),m_EditDesc.GetText());
		
		CSocialManager::Instance()->PostImageToSocialNetwork( eFacebook, pNotifyPressData->UserIndex, false);	

		app.NavigateBack(pNotifyPressData->UserIndex);
	}

	return S_OK;
}


HRESULT CScene_SocialPost::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
	ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);

	//HXUIOBJ hFocus=XuiElementGetFocus();
	switch(pInputData->dwKeyCode)
	{

	case VK_PAD_B:
	case VK_ESCAPE:
		app.NavigateBack(pInputData->UserIndex);
		rfHandled = TRUE;

		break;
	}


	return S_OK;
}


HRESULT CScene_SocialPost::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
	bHandled=true;
	return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining,false);
}