feat(TU31): LoadCreateJoin improvements (#65)
Feat: JoinMenu have description (for now isn't working because i'm waiting for the fourkit code rewriting)
This commit is contained in:
@@ -12,10 +12,18 @@
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "../../Windows64/Network/WinsockNetLayer.h"
|
||||
#include "../../Windows64/4JLibs/inc/4J_Input.h"
|
||||
#endif
|
||||
|
||||
#define UPDATE_PLAYERS_TIMER_ID 0
|
||||
#define UPDATE_PLAYERS_TIMER_TIME 30000
|
||||
#define UPDATE_PLAYERS_TIMER_TIME 400.0
|
||||
|
||||
// static overlay state for howtoplay
|
||||
static Iggy* s_movieServerDesc = nullptr;
|
||||
static vector<unsigned char> s_movieDataServerDesc;
|
||||
static IggyName s_funcLoadPage = 0;
|
||||
static bool s_textInjected = false;
|
||||
static int s_injectionDelay = 0;
|
||||
|
||||
UIScene_JoinMenu::UIScene_JoinMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
||||
{
|
||||
@@ -32,9 +40,65 @@ UIScene_JoinMenu::UIScene_JoinMenu(int iPad, void *_initData, UILayer *parentLay
|
||||
m_editServerPhase = eEditServer_Idle;
|
||||
m_editServerButtonIndex = -1;
|
||||
m_deleteServerButtonIndex = -1;
|
||||
|
||||
// reset the howtoplay state
|
||||
s_textInjected = false;
|
||||
s_injectionDelay = 0;
|
||||
|
||||
// load howtoplay it's like the messagebox xd
|
||||
if (!s_movieServerDesc)
|
||||
{
|
||||
wstring moviePath = L"HowToPlay";
|
||||
if (m_loadedResolution == eSceneResolution_1080) moviePath.append(L"1080.swf");
|
||||
else if (m_loadedResolution == eSceneResolution_720) moviePath.append(L"720.swf");
|
||||
else moviePath.append(L"480.swf");
|
||||
|
||||
byteArray baFile = ui.getMovieData(moviePath.c_str());
|
||||
if (baFile.data)
|
||||
{
|
||||
s_movieDataServerDesc.assign((unsigned char*)baFile.data, (unsigned char*)baFile.data + baFile.length);
|
||||
s_movieServerDesc = IggyPlayerCreateFromMemory(s_movieDataServerDesc.data(), (unsigned int)s_movieDataServerDesc.size(), nullptr);
|
||||
if (s_movieServerDesc)
|
||||
{
|
||||
IggyPlayerInitializeAndTickRS(s_movieServerDesc);
|
||||
IggyPlayerSetDisplaySize(s_movieServerDesc, m_movieWidth, m_movieHeight);
|
||||
s_funcLoadPage = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"LoadHowToPlayPage", -1);
|
||||
|
||||
// it maintains the resolution at 1080p so that it looks sharp
|
||||
IggyValuePath *root = IggyPlayerRootPath(s_movieServerDesc);
|
||||
if (root)
|
||||
{
|
||||
IggyValueSetF64RS(root, IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"x", -1), nullptr, 0.0);
|
||||
IggyValueSetF64RS(root, IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"y", -1), nullptr, 0.0);
|
||||
IggyValueSetF64RS(root, IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"width", -1), nullptr, (double)m_movieWidth);
|
||||
IggyValueSetF64RS(root, IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"height", -1), nullptr, (double)m_movieHeight);
|
||||
|
||||
// it hides the logo and other things that the howtoplay has
|
||||
const char* elementsToHide[] = { "__id0_", "__id1_", "__id2_" };
|
||||
IggyName visibleName = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"visible", -1);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
IggyValuePath path;
|
||||
if (IggyValuePathMakeNameRef(&path, root, elementsToHide[i])) {
|
||||
IggyValueSetBooleanRS(&path, visibleName, nullptr, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
UIScene_JoinMenu::~UIScene_JoinMenu()
|
||||
{
|
||||
// destroy the player when closing the scene to avoid zombie pointers
|
||||
if (s_movieServerDesc)
|
||||
{
|
||||
IggyPlayerDestroy(s_movieServerDesc);
|
||||
s_movieServerDesc = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::updateTooltips()
|
||||
{
|
||||
int iA = -1;
|
||||
@@ -79,6 +143,7 @@ void UIScene_JoinMenu::tick()
|
||||
m_buttonJoinGame.init(app.GetString(IDS_JOIN_GAME),eControl_JoinGame);
|
||||
|
||||
m_buttonListPlayers.init(eControl_GamePlayers);
|
||||
m_buttonListPlayers.setYPos( m_buttonListPlayers.getYPos() + 300 );
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__
|
||||
for( int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++ )
|
||||
@@ -216,6 +281,7 @@ void UIScene_JoinMenu::tick()
|
||||
m_buttonJoinGame.init(app.GetString(IDS_JOIN_GAME),eControl_JoinGame);
|
||||
|
||||
m_buttonListPlayers.init(eControl_GamePlayers);
|
||||
m_buttonListPlayers.setYPos( m_buttonListPlayers.getYPos() + 300 );
|
||||
|
||||
m_labelLabels[eLabel_Difficulty].init(app.GetString(IDS_LABEL_DIFFICULTY));
|
||||
m_labelLabels[eLabel_GameType].init(app.GetString(IDS_LABEL_GAME_TYPE));
|
||||
@@ -250,6 +316,95 @@ void UIScene_JoinMenu::tick()
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (s_movieServerDesc)
|
||||
{
|
||||
if (IggyPlayerReadyToTick(s_movieServerDesc))
|
||||
{
|
||||
IggyPlayerTickRS(s_movieServerDesc);
|
||||
|
||||
IggyValuePath *root = IggyPlayerRootPath(s_movieServerDesc);
|
||||
if (root)
|
||||
{
|
||||
// scale the size before Iggy reads it
|
||||
IggyValuePath textPath;
|
||||
if (IggyValuePathMakeNameRef(&textPath, root, "HowToPlayText_0"))
|
||||
{
|
||||
IggyName nameX = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"x", -1);
|
||||
IggyName nameY = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"y", -1);
|
||||
IggyName nameW = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"width", -1);
|
||||
IggyName nameH = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"height", -1);
|
||||
|
||||
if (m_loadedResolution == eSceneResolution_1080)
|
||||
{
|
||||
IggyValueSetF64RS(&textPath, nameX, nullptr, 333.0);// horizontal
|
||||
IggyValueSetF64RS(&textPath, nameY, nullptr, 340.0);// vertical
|
||||
IggyValueSetF64RS(&textPath, nameW, nullptr, 580.0);
|
||||
IggyValueSetF64RS(&textPath, nameH, nullptr, 270.0);
|
||||
}
|
||||
else //720
|
||||
{
|
||||
IggyValueSetF64RS(&textPath, nameX, nullptr, 252.0);
|
||||
IggyValueSetF64RS(&textPath, nameY, nullptr, 285.0);
|
||||
IggyValueSetF64RS(&textPath, nameW, nullptr, 440.0);
|
||||
IggyValueSetF64RS(&textPath, nameH, nullptr, 220.0);
|
||||
}
|
||||
}
|
||||
|
||||
// harcoded text for test it, later im gonna delete this and
|
||||
// and convert it so that people can add their description when adding the server
|
||||
if (!s_textInjected && s_funcLoadPage != 0)
|
||||
{
|
||||
IggyDataValue result;
|
||||
IggyDataValue args[2];
|
||||
args[0].type = IGGY_DATATYPE_number;
|
||||
args[0].number = 0; // 0 is the what's new page on howtoplay don't change it
|
||||
|
||||
wstring testText = L"\nNothing yet...";
|
||||
IggyStringUTF16 iggyStr;
|
||||
wstring formattedText = app.FormatChatMessage(testText);
|
||||
iggyStr.string = (IggyUTF16*)formattedText.c_str();
|
||||
iggyStr.length = (unsigned int)formattedText.length();
|
||||
|
||||
args[1].type = IGGY_DATATYPE_string_UTF16;
|
||||
args[1].string16 = iggyStr;
|
||||
|
||||
IggyResult res = IggyPlayerCallMethodRS(s_movieServerDesc, &result, root, s_funcLoadPage, 2, args);
|
||||
if (res == IGGY_RESULT_SUCCESS)
|
||||
{
|
||||
s_textInjected = true;
|
||||
}
|
||||
}
|
||||
|
||||
// keeps the text fixed so it doesn't move from its place
|
||||
IggyValuePath panelPath;
|
||||
if (s_textInjected && IggyValuePathMakeNameRef(&panelPath, root, "DynamicHtmlText"))
|
||||
{
|
||||
IggyName nameX = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"x", -1);
|
||||
IggyName nameY = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"y", -1);
|
||||
IggyName nameW = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"width", -1);
|
||||
IggyName nameH = IggyPlayerCreateFastName(s_movieServerDesc, (IggyUTF16 *)L"height", -1);
|
||||
|
||||
if (m_loadedResolution == eSceneResolution_1080)
|
||||
{
|
||||
IggyValueSetF64RS(&panelPath, nameX, nullptr, 332.0);// horizontal
|
||||
IggyValueSetF64RS(&panelPath, nameY, nullptr, 340.0);// vertical
|
||||
IggyValueSetF64RS(&panelPath, nameW, nullptr, 580.0);
|
||||
IggyValueSetF64RS(&panelPath, nameH, nullptr, 270.0);
|
||||
}
|
||||
else //720p
|
||||
{
|
||||
IggyValueSetF64RS(&panelPath, nameX, nullptr, 250.0);
|
||||
IggyValueSetF64RS(&panelPath, nameY, nullptr, 290.0);
|
||||
IggyValueSetF64RS(&panelPath, nameW, nullptr, 400.0);
|
||||
IggyValueSetF64RS(&panelPath, nameH, nullptr, 230.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
UIScene::tick();
|
||||
}
|
||||
|
||||
@@ -275,6 +430,7 @@ int UIScene_JoinMenu::ErrorDialogReturned(void *pParam, int iPad, const C4JStora
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void UIScene_JoinMenu::updateComponents()
|
||||
{
|
||||
m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true);
|
||||
@@ -286,6 +442,19 @@ wstring UIScene_JoinMenu::getMoviePath()
|
||||
return L"JoinMenu";
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::render(S32 width, S32 height, C4JRender::eViewportType viewpBort)
|
||||
{
|
||||
UIScene::render(width, height, viewpBort);
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (s_movieServerDesc)
|
||||
{
|
||||
IggyPlayerSetDisplaySize(s_movieServerDesc, width, height);
|
||||
IggyPlayerDraw(s_movieServerDesc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
||||
{
|
||||
if(m_bIgnoreInput) return;
|
||||
@@ -353,6 +522,21 @@ void UIScene_JoinMenu::handleInput(int iPad, int key, bool repeat, bool pressed,
|
||||
sendInputToMovie(key, repeat, pressed, released);
|
||||
handled = true;
|
||||
break;
|
||||
#ifdef _WINDOWS64
|
||||
case ACTION_MENU_OTHER_STICK_UP:
|
||||
case ACTION_MENU_OTHER_STICK_DOWN:
|
||||
if (s_movieServerDesc)
|
||||
{
|
||||
IggyEvent keyEvent;
|
||||
IggyKeycode iggyKeyCode = (key == ACTION_MENU_OTHER_STICK_UP) ? IGGY_KEYCODE_F11 : IGGY_KEYCODE_F12;
|
||||
IggyMakeEventKey(&keyEvent, pressed ? IGGY_KEYEVENT_Down : IGGY_KEYEVENT_Up, iggyKeyCode, IGGY_KEYLOC_Standard);
|
||||
|
||||
IggyEventResult res;
|
||||
IggyPlayerDispatchEventRS(s_movieServerDesc, &keyEvent, &res);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user