Update to NeoLegacy Latest
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)
|
||||
{
|
||||
@@ -27,6 +35,70 @@ UIScene_JoinMenu::UIScene_JoinMenu(int iPad, void *_initData, UILayer *parentLay
|
||||
m_friendInfoUpdatedOK = false;
|
||||
m_friendInfoUpdatedERROR = false;
|
||||
m_friendInfoRequestIssued = false;
|
||||
#ifdef _WINDOWS64
|
||||
m_serverIndex = initData->serverIndex;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
updateServerDescription();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#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()
|
||||
@@ -45,51 +117,60 @@ void UIScene_JoinMenu::updateTooltips()
|
||||
iA = IDS_TOOLTIPS_SELECT;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (m_serverIndex >= 0)
|
||||
{
|
||||
iX = IDS_TOOLTIPS_DELETE;
|
||||
iY = IDS_TITLE_RENAME;
|
||||
}
|
||||
#endif
|
||||
|
||||
ui.SetTooltips( DEFAULT_XUI_MENU_USER, iA, IDS_TOOLTIPS_BACK, iX, iY );
|
||||
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::tick()
|
||||
{
|
||||
if( !m_friendInfoRequestIssued )
|
||||
if (!m_friendInfoRequestIssued)
|
||||
{
|
||||
ui.NavigateToScene(m_iPad, eUIScene_Timer);
|
||||
g_NetworkManager.GetFullFriendSessionInfo(m_selectedSession, &friendSessionUpdated, this);
|
||||
m_friendInfoRequestIssued = true;
|
||||
}
|
||||
|
||||
if( m_friendInfoUpdatedOK )
|
||||
if (m_friendInfoUpdatedOK)
|
||||
{
|
||||
m_friendInfoUpdatedOK = false;
|
||||
|
||||
m_buttonJoinGame.init(app.GetString(IDS_JOIN_GAME),eControl_JoinGame);
|
||||
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++ )
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
if( m_selectedSession->data.players[i] != nullptr )
|
||||
if (m_selectedSession->data.players[i] != nullptr)
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask()&(1L<<eDebugSetting_DebugLeaderboards)))
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (app.DebugSettingsOn() && (app.GetGameSettingsDebugMask() & (1L << eDebugSetting_DebugLeaderboards)))
|
||||
{
|
||||
m_buttonListPlayers.addItem(L"WWWWWWWWWWWWWWWW");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
string playerName(m_selectedSession->data.players[i].getOnlineID());
|
||||
|
||||
#ifndef __PSVITA__
|
||||
#ifndef __PSVITA__
|
||||
// Append guest number (any players in an online game not signed into PSN are guests)
|
||||
if( m_selectedSession->data.players[i].isSignedIntoPSN() == false )
|
||||
if (m_selectedSession->data.players[i].isSignedIntoPSN() == false)
|
||||
{
|
||||
char suffix[5];
|
||||
sprintf(suffix, " (%d)", m_selectedSession->data.players[i].getQuadrant() + 1);
|
||||
playerName.append(suffix);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
m_buttonListPlayers.addItem(playerName);
|
||||
}
|
||||
}
|
||||
@@ -100,9 +181,9 @@ void UIScene_JoinMenu::tick()
|
||||
}
|
||||
}
|
||||
#elif defined(_DURANGO)
|
||||
for( int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++ )
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
if ( m_selectedSession->searchResult.m_playerNames[i].size() )
|
||||
if (m_selectedSession->searchResult.m_playerNames[i].size())
|
||||
{
|
||||
m_buttonListPlayers.addItem(m_selectedSession->searchResult.m_playerNames[i]);
|
||||
}
|
||||
@@ -114,6 +195,16 @@ void UIScene_JoinMenu::tick()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (m_serverIndex >= 0)
|
||||
{
|
||||
m_editServerButtonIndex = m_buttonListPlayers.getItemCount();
|
||||
m_buttonListPlayers.addItem(L"Edit Server");
|
||||
m_deleteServerButtonIndex = m_buttonListPlayers.getItemCount();
|
||||
m_buttonListPlayers.addItem(L"Delete Server");
|
||||
}
|
||||
#endif
|
||||
|
||||
m_labelLabels[eLabel_Difficulty].init(app.GetString(IDS_LABEL_DIFFICULTY));
|
||||
m_labelLabels[eLabel_GameType].init(app.GetString(IDS_LABEL_GAME_TYPE));
|
||||
m_labelLabels[eLabel_GamertagsOn].init(app.GetString(IDS_LABEL_GAMERTAGS));
|
||||
@@ -125,73 +216,74 @@ void UIScene_JoinMenu::tick()
|
||||
m_labelLabels[eLabel_FireOn].init(app.GetString(IDS_LABEL_FIRE_SPREADS));
|
||||
|
||||
unsigned int uiGameHostSettings = m_selectedSession->data.m_uiGameHostSettings;
|
||||
switch(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_Difficulty))
|
||||
switch (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_Difficulty))
|
||||
{
|
||||
case Difficulty::EASY:
|
||||
m_labelValues[eLabel_Difficulty].init( app.GetString(IDS_DIFFICULTY_TITLE_EASY) );
|
||||
m_labelValues[eLabel_Difficulty].init(app.GetString(IDS_DIFFICULTY_TITLE_EASY));
|
||||
break;
|
||||
case Difficulty::NORMAL:
|
||||
m_labelValues[eLabel_Difficulty].init( app.GetString(IDS_DIFFICULTY_TITLE_NORMAL) );
|
||||
m_labelValues[eLabel_Difficulty].init(app.GetString(IDS_DIFFICULTY_TITLE_NORMAL));
|
||||
break;
|
||||
case Difficulty::HARD:
|
||||
m_labelValues[eLabel_Difficulty].init( app.GetString(IDS_DIFFICULTY_TITLE_HARD) );
|
||||
m_labelValues[eLabel_Difficulty].init(app.GetString(IDS_DIFFICULTY_TITLE_HARD));
|
||||
break;
|
||||
case Difficulty::PEACEFUL:
|
||||
default:
|
||||
m_labelValues[eLabel_Difficulty].init( app.GetString(IDS_DIFFICULTY_TITLE_PEACEFUL) );
|
||||
m_labelValues[eLabel_Difficulty].init(app.GetString(IDS_DIFFICULTY_TITLE_PEACEFUL));
|
||||
break;
|
||||
}
|
||||
|
||||
int option = app.GetGameHostOption(uiGameHostSettings,eGameHostOption_GameType);
|
||||
if(option == GameType::CREATIVE->getId())
|
||||
int option = app.GetGameHostOption(uiGameHostSettings, eGameHostOption_GameType);
|
||||
if (option == GameType::CREATIVE->getId())
|
||||
{
|
||||
m_labelValues[eLabel_GameType].init( app.GetString(IDS_CREATIVE) );
|
||||
m_labelValues[eLabel_GameType].init(app.GetString(IDS_CREATIVE));
|
||||
}
|
||||
else if(option == GameType::ADVENTURE->getId())
|
||||
else if (option == GameType::ADVENTURE->getId())
|
||||
{
|
||||
m_labelValues[eLabel_GameType].init( app.GetString(IDS_ADVENTURE) );
|
||||
m_labelValues[eLabel_GameType].init(app.GetString(IDS_ADVENTURE));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_labelValues[eLabel_GameType].init( app.GetString(IDS_SURVIVAL) );
|
||||
m_labelValues[eLabel_GameType].init(app.GetString(IDS_SURVIVAL));
|
||||
}
|
||||
|
||||
if(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_Gamertags)) m_labelValues[eLabel_GamertagsOn].init( app.GetString(IDS_ON) );
|
||||
else m_labelValues[eLabel_GamertagsOn].init( app.GetString(IDS_OFF) );
|
||||
if (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_Gamertags)) m_labelValues[eLabel_GamertagsOn].init(app.GetString(IDS_ON));
|
||||
else m_labelValues[eLabel_GamertagsOn].init(app.GetString(IDS_OFF));
|
||||
|
||||
if(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_Structures)) m_labelValues[eLabel_Structures].init( app.GetString(IDS_ON) );
|
||||
else m_labelValues[eLabel_Structures].init( app.GetString(IDS_OFF) );
|
||||
if (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_Structures)) m_labelValues[eLabel_Structures].init(app.GetString(IDS_ON));
|
||||
else m_labelValues[eLabel_Structures].init(app.GetString(IDS_OFF));
|
||||
|
||||
if(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_LevelType)) m_labelValues[eLabel_LevelType].init( app.GetString(IDS_LEVELTYPE_SUPERFLAT) );
|
||||
else m_labelValues[eLabel_LevelType].init( app.GetString(IDS_LEVELTYPE_NORMAL) );
|
||||
if (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_LevelType)) m_labelValues[eLabel_LevelType].init(app.GetString(IDS_LEVELTYPE_SUPERFLAT));
|
||||
else m_labelValues[eLabel_LevelType].init(app.GetString(IDS_LEVELTYPE_NORMAL));
|
||||
|
||||
if(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_PvP))m_labelValues[eLabel_PVP].init( app.GetString(IDS_ON) );
|
||||
else m_labelValues[eLabel_PVP].init( app.GetString(IDS_OFF) );
|
||||
if (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_PvP))m_labelValues[eLabel_PVP].init(app.GetString(IDS_ON));
|
||||
else m_labelValues[eLabel_PVP].init(app.GetString(IDS_OFF));
|
||||
|
||||
if(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_TrustPlayers)) m_labelValues[eLabel_Trust].init( app.GetString(IDS_ON) );
|
||||
else m_labelValues[eLabel_Trust].init( app.GetString(IDS_OFF) );
|
||||
if (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_TrustPlayers)) m_labelValues[eLabel_Trust].init(app.GetString(IDS_ON));
|
||||
else m_labelValues[eLabel_Trust].init(app.GetString(IDS_OFF));
|
||||
|
||||
if(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_TNT)) m_labelValues[eLabel_TNTOn].init( app.GetString(IDS_ON) );
|
||||
else m_labelValues[eLabel_TNTOn].init( app.GetString(IDS_OFF) );
|
||||
if (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_TNT)) m_labelValues[eLabel_TNTOn].init(app.GetString(IDS_ON));
|
||||
else m_labelValues[eLabel_TNTOn].init(app.GetString(IDS_OFF));
|
||||
|
||||
if(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_FireSpreads)) m_labelValues[eLabel_FireOn].init( app.GetString(IDS_ON) );
|
||||
else m_labelValues[eLabel_FireOn].init( app.GetString(IDS_OFF) );
|
||||
if (app.GetGameHostOption(uiGameHostSettings, eGameHostOption_FireSpreads)) m_labelValues[eLabel_FireOn].init(app.GetString(IDS_ON));
|
||||
else m_labelValues[eLabel_FireOn].init(app.GetString(IDS_OFF));
|
||||
|
||||
m_bIgnoreInput = false;
|
||||
|
||||
// Alert the app the we want to be informed of ethernet connections
|
||||
app.SetLiveLinkRequired( true );
|
||||
app.SetLiveLinkRequired(true);
|
||||
|
||||
TelemetryManager->RecordMenuShown(m_iPad, eUIScene_JoinMenu, 0);
|
||||
|
||||
addTimer(UPDATE_PLAYERS_TIMER_ID,UPDATE_PLAYERS_TIMER_TIME);
|
||||
addTimer(UPDATE_PLAYERS_TIMER_ID, UPDATE_PLAYERS_TIMER_TIME);
|
||||
}
|
||||
|
||||
if( m_friendInfoUpdatedERROR )
|
||||
if (m_friendInfoUpdatedERROR)
|
||||
{
|
||||
m_buttonJoinGame.init(app.GetString(IDS_JOIN_GAME),eControl_JoinGame);
|
||||
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));
|
||||
@@ -204,14 +296,14 @@ void UIScene_JoinMenu::tick()
|
||||
m_labelLabels[eLabel_FireOn].init(app.GetString(IDS_LABEL_FIRE_SPREADS));
|
||||
|
||||
m_labelValues[eLabel_Difficulty].init(app.GetString(IDS_DIFFICULTY_TITLE_PEACEFUL));
|
||||
m_labelValues[eLabel_GameType].init( app.GetString(IDS_CREATIVE) );
|
||||
m_labelValues[eLabel_GamertagsOn].init( app.GetString(IDS_OFF) );
|
||||
m_labelValues[eLabel_Structures].init( app.GetString(IDS_OFF) );
|
||||
m_labelValues[eLabel_LevelType].init( app.GetString(IDS_LEVELTYPE_NORMAL) );
|
||||
m_labelValues[eLabel_PVP].init( app.GetString(IDS_OFF) );
|
||||
m_labelValues[eLabel_Trust].init( app.GetString(IDS_OFF) );
|
||||
m_labelValues[eLabel_TNTOn].init( app.GetString(IDS_OFF) );
|
||||
m_labelValues[eLabel_FireOn].init( app.GetString(IDS_OFF) );
|
||||
m_labelValues[eLabel_GameType].init(app.GetString(IDS_CREATIVE));
|
||||
m_labelValues[eLabel_GamertagsOn].init(app.GetString(IDS_OFF));
|
||||
m_labelValues[eLabel_Structures].init(app.GetString(IDS_OFF));
|
||||
m_labelValues[eLabel_LevelType].init(app.GetString(IDS_LEVELTYPE_NORMAL));
|
||||
m_labelValues[eLabel_PVP].init(app.GetString(IDS_OFF));
|
||||
m_labelValues[eLabel_Trust].init(app.GetString(IDS_OFF));
|
||||
m_labelValues[eLabel_TNTOn].init(app.GetString(IDS_OFF));
|
||||
m_labelValues[eLabel_FireOn].init(app.GetString(IDS_OFF));
|
||||
|
||||
m_friendInfoUpdatedERROR = false;
|
||||
|
||||
@@ -220,15 +312,109 @@ void UIScene_JoinMenu::tick()
|
||||
UINT uiIDA[1];
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
#ifdef _XBOX_ONE
|
||||
ui.RequestErrorMessage( IDS_CONNECTION_FAILED, IDS_DISCONNECTED_SERVER_QUIT, uiIDA,1,m_iPad,ErrorDialogReturned,this);
|
||||
ui.RequestErrorMessage(IDS_CONNECTION_FAILED, IDS_DISCONNECTED_SERVER_QUIT, uiIDA, 1, m_iPad, ErrorDialogReturned, this);
|
||||
#else
|
||||
ui.RequestErrorMessage( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA,1,m_iPad,ErrorDialogReturned,this);
|
||||
ui.RequestErrorMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, m_iPad, ErrorDialogReturned, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (s_movieServerDesc)
|
||||
{
|
||||
if (IggyPlayerReadyToTick(s_movieServerDesc))
|
||||
{
|
||||
IggyPlayerTickRS(s_movieServerDesc);
|
||||
|
||||
updateServerDescription();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
UIScene::tick();
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::updateServerDescription() {
|
||||
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_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.EscapeHTMLString(testText);
|
||||
formattedText = app.FormatChatMessage(formattedText);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::friendSessionUpdated(bool success, void *pParam)
|
||||
{
|
||||
UIScene_JoinMenu *scene = static_cast<UIScene_JoinMenu *>(pParam);
|
||||
@@ -251,6 +437,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);
|
||||
@@ -262,6 +449,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;
|
||||
@@ -285,12 +485,38 @@ void UIScene_JoinMenu::handleInput(int iPad, int key, bool repeat, bool pressed,
|
||||
if( uid != INVALID_XUID ) ProfileManager.ShowProfileCard(ProfileManager.GetLockedProfile(),uid);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef _WINDOWS64
|
||||
case ACTION_MENU_X:
|
||||
if(pressed && m_serverIndex >= 0)
|
||||
{
|
||||
BeginDeleteServer();
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
case ACTION_MENU_Y:
|
||||
if(pressed && m_serverIndex >= 0)
|
||||
{
|
||||
BeginEditServer();
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case ACTION_MENU_OK:
|
||||
if (getControlFocus() != eControl_GamePlayers)
|
||||
{
|
||||
sendInputToMovie(key, repeat, pressed, released);
|
||||
}
|
||||
#ifdef _WINDOWS64
|
||||
else if (pressed && m_serverIndex >= 0)
|
||||
{
|
||||
int sel = m_buttonListPlayers.getCurrentSelection();
|
||||
if (sel == m_editServerButtonIndex)
|
||||
BeginEditServer();
|
||||
else if (sel == m_deleteServerButtonIndex)
|
||||
BeginDeleteServer();
|
||||
}
|
||||
#endif
|
||||
handled = true;
|
||||
break;
|
||||
#ifdef __ORBIS__
|
||||
@@ -303,6 +529,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,6 +566,16 @@ void UIScene_JoinMenu::handlePress(F64 controlId, F64 childId)
|
||||
}
|
||||
break;
|
||||
case eControl_GamePlayers:
|
||||
#ifdef _WINDOWS64
|
||||
if (m_serverIndex >= 0)
|
||||
{
|
||||
int sel = (int)childId;
|
||||
if (sel == m_editServerButtonIndex)
|
||||
BeginEditServer();
|
||||
else if (sel == m_deleteServerButtonIndex)
|
||||
BeginDeleteServer();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
};
|
||||
}
|
||||
@@ -529,6 +780,23 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
// Alert the app the we no longer want to be informed of ethernet connections
|
||||
app.SetLiveLinkRequired( false );
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (result == CGameNetworkManager::JOINGAME_PENDING)
|
||||
{
|
||||
pClass->m_bIgnoreInput = false;
|
||||
ConnectionProgressParams *param = new ConnectionProgressParams();
|
||||
param->iPad = ProfileManager.GetPrimaryPad();
|
||||
param->stringId = IDS_PROGRESS_CONNECTING;
|
||||
param->showTooltips = true;
|
||||
param->setFailTimer = false;
|
||||
param->timerTime = 0;
|
||||
param->cancelFunc = nullptr;
|
||||
param->cancelFuncParam = nullptr;
|
||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_ConnectingProgress, param);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( result != CGameNetworkManager::JOINGAME_SUCCESS )
|
||||
{
|
||||
int exitReasonStringId = -1;
|
||||
@@ -644,4 +912,279 @@ void UIScene_JoinMenu::handleTimerComplete(int id)
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
void UIScene_JoinMenu::BeginDeleteServer()
|
||||
{
|
||||
m_bIgnoreInput = true;
|
||||
UINT uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
ui.RequestAlertMessage(IDS_TOOLTIPS_DELETE, IDS_TEXT_DELETE_SAVE, uiIDA, 2, m_iPad, &UIScene_JoinMenu::DeleteServerDialogReturned, this);
|
||||
}
|
||||
|
||||
int UIScene_JoinMenu::DeleteServerDialogReturned(void *pParam, int iPad, C4JStorage::EMessageResult result)
|
||||
{
|
||||
UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)pParam;
|
||||
|
||||
if (result == C4JStorage::EMessage_ResultDecline)
|
||||
{
|
||||
pClass->RemoveServerFromFile();
|
||||
g_NetworkManager.ForceFriendsSessionRefresh();
|
||||
pClass->navigateBack();
|
||||
}
|
||||
else
|
||||
{
|
||||
pClass->m_bIgnoreInput = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::BeginEditServer()
|
||||
{
|
||||
m_bIgnoreInput = true;
|
||||
m_editServerPhase = eEditServer_IP;
|
||||
m_editServerIP.clear();
|
||||
m_editServerPort.clear();
|
||||
|
||||
wchar_t wDefaultIP[64] = {};
|
||||
mbstowcs(wDefaultIP, m_selectedSession->data.hostIP, 63);
|
||||
|
||||
UIKeyboardInitData kbData;
|
||||
kbData.title = L"Server Address";
|
||||
kbData.defaultText = wDefaultIP;
|
||||
kbData.maxChars = 128;
|
||||
kbData.callback = &UIScene_JoinMenu::EditServerKeyboardCallback;
|
||||
kbData.lpParam = this;
|
||||
kbData.pcMode = g_KBMInput.IsKBMActive();
|
||||
ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData);
|
||||
}
|
||||
|
||||
int UIScene_JoinMenu::EditServerKeyboardCallback(LPVOID lpParam, bool bRes)
|
||||
{
|
||||
UIScene_JoinMenu *pClass = (UIScene_JoinMenu *)lpParam;
|
||||
|
||||
if (!bRes)
|
||||
{
|
||||
pClass->m_editServerPhase = eEditServer_Idle;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t ui16Text[256];
|
||||
ZeroMemory(ui16Text, sizeof(ui16Text));
|
||||
Win64_GetKeyboardText(ui16Text, 256);
|
||||
|
||||
wchar_t wBuf[256] = {};
|
||||
for (int k = 0; k < 255 && ui16Text[k]; k++)
|
||||
wBuf[k] = (wchar_t)ui16Text[k];
|
||||
|
||||
if (wBuf[0] == 0)
|
||||
{
|
||||
pClass->m_editServerPhase = eEditServer_Idle;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (pClass->m_editServerPhase)
|
||||
{
|
||||
case eEditServer_IP:
|
||||
{
|
||||
pClass->m_editServerIP = wBuf;
|
||||
pClass->m_editServerPhase = eEditServer_Port;
|
||||
|
||||
wchar_t wDefaultPort[16] = {};
|
||||
swprintf(wDefaultPort, 16, L"%d", pClass->m_selectedSession->data.hostPort);
|
||||
|
||||
UIKeyboardInitData kbData;
|
||||
kbData.title = L"Server Port";
|
||||
kbData.defaultText = wDefaultPort;
|
||||
kbData.maxChars = 6;
|
||||
kbData.callback = &UIScene_JoinMenu::EditServerKeyboardCallback;
|
||||
kbData.lpParam = pClass;
|
||||
kbData.pcMode = g_KBMInput.IsKBMActive();
|
||||
ui.NavigateToScene(pClass->m_iPad, eUIScene_Keyboard, &kbData);
|
||||
break;
|
||||
}
|
||||
case eEditServer_Port:
|
||||
{
|
||||
pClass->m_editServerPort = wBuf;
|
||||
pClass->m_editServerPhase = eEditServer_Name;
|
||||
|
||||
wchar_t wDefaultName[64] = {};
|
||||
if (pClass->m_selectedSession->displayLabel)
|
||||
wcsncpy(wDefaultName, pClass->m_selectedSession->displayLabel, 63);
|
||||
|
||||
UIKeyboardInitData kbData;
|
||||
kbData.title = L"Server Name";
|
||||
kbData.defaultText = wDefaultName;
|
||||
kbData.maxChars = 64;
|
||||
kbData.callback = &UIScene_JoinMenu::EditServerKeyboardCallback;
|
||||
kbData.lpParam = pClass;
|
||||
kbData.pcMode = g_KBMInput.IsKBMActive();
|
||||
ui.NavigateToScene(pClass->m_iPad, eUIScene_Keyboard, &kbData);
|
||||
break;
|
||||
}
|
||||
case eEditServer_Name:
|
||||
{
|
||||
wstring newName = wBuf;
|
||||
pClass->UpdateServerInFile(pClass->m_editServerIP, pClass->m_editServerPort, newName);
|
||||
pClass->m_editServerPhase = eEditServer_Idle;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
|
||||
g_NetworkManager.ForceFriendsSessionRefresh();
|
||||
pClass->navigateBack();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
pClass->m_editServerPhase = eEditServer_Idle;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::UpdateServerInFile(const wstring& newIP, const wstring& newPort, const wstring& newName)
|
||||
{
|
||||
char narrowNewIP[256] = {};
|
||||
char narrowNewPort[16] = {};
|
||||
char narrowNewName[256] = {};
|
||||
wcstombs(narrowNewIP, newIP.c_str(), sizeof(narrowNewIP) - 1);
|
||||
wcstombs(narrowNewPort, newPort.c_str(), sizeof(narrowNewPort) - 1);
|
||||
wcstombs(narrowNewName, newName.c_str(), sizeof(narrowNewName) - 1);
|
||||
|
||||
uint16_t newPortNum = (uint16_t)atoi(narrowNewPort);
|
||||
|
||||
struct ServerEntry { std::string ip; uint16_t port; std::string name; };
|
||||
std::vector<ServerEntry> entries;
|
||||
|
||||
FILE* file = fopen("servers.db", "rb");
|
||||
if (file)
|
||||
{
|
||||
char magic[4] = {};
|
||||
if (fread(magic, 1, 4, file) == 4 && memcmp(magic, "MCSV", 4) == 0)
|
||||
{
|
||||
uint32_t version = 0, count = 0;
|
||||
fread(&version, sizeof(uint32_t), 1, file);
|
||||
fread(&count, sizeof(uint32_t), 1, file);
|
||||
if (version == 1)
|
||||
{
|
||||
for (uint32_t s = 0; s < count; s++)
|
||||
{
|
||||
uint16_t ipLen = 0, p = 0, nameLen = 0;
|
||||
if (fread(&ipLen, sizeof(uint16_t), 1, file) != 1) break;
|
||||
if (ipLen == 0 || ipLen > 256) break;
|
||||
char ipBuf[257] = {};
|
||||
if (fread(ipBuf, 1, ipLen, file) != ipLen) break;
|
||||
if (fread(&p, sizeof(uint16_t), 1, file) != 1) break;
|
||||
if (fread(&nameLen, sizeof(uint16_t), 1, file) != 1) break;
|
||||
if (nameLen > 256) break;
|
||||
char nameBuf[257] = {};
|
||||
if (nameLen > 0 && fread(nameBuf, 1, nameLen, file) != nameLen) break;
|
||||
entries.push_back({std::string(ipBuf), p, std::string(nameBuf)});
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
// Find and update the matching entry by original IP and port
|
||||
int idx = m_serverIndex;
|
||||
if (idx >= 0 && idx < (int)entries.size())
|
||||
{
|
||||
entries[idx].ip = std::string(narrowNewIP);
|
||||
entries[idx].port = newPortNum;
|
||||
entries[idx].name = std::string(narrowNewName);
|
||||
}
|
||||
|
||||
file = fopen("servers.db", "wb");
|
||||
if (file)
|
||||
{
|
||||
fwrite("MCSV", 1, 4, file);
|
||||
uint32_t version = 1;
|
||||
uint32_t count = (uint32_t)entries.size();
|
||||
fwrite(&version, sizeof(uint32_t), 1, file);
|
||||
fwrite(&count, sizeof(uint32_t), 1, file);
|
||||
|
||||
for (size_t i = 0; i < entries.size(); i++)
|
||||
{
|
||||
uint16_t ipLen = (uint16_t)entries[i].ip.length();
|
||||
fwrite(&ipLen, sizeof(uint16_t), 1, file);
|
||||
fwrite(entries[i].ip.c_str(), 1, ipLen, file);
|
||||
fwrite(&entries[i].port, sizeof(uint16_t), 1, file);
|
||||
uint16_t nameLen = (uint16_t)entries[i].name.length();
|
||||
fwrite(&nameLen, sizeof(uint16_t), 1, file);
|
||||
fwrite(entries[i].name.c_str(), 1, nameLen, file);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_JoinMenu::RemoveServerFromFile()
|
||||
{
|
||||
struct ServerEntry { std::string ip; uint16_t port; std::string name; };
|
||||
std::vector<ServerEntry> entries;
|
||||
|
||||
FILE* file = fopen("servers.db", "rb");
|
||||
if (file)
|
||||
{
|
||||
char magic[4] = {};
|
||||
if (fread(magic, 1, 4, file) == 4 && memcmp(magic, "MCSV", 4) == 0)
|
||||
{
|
||||
uint32_t version = 0, count = 0;
|
||||
fread(&version, sizeof(uint32_t), 1, file);
|
||||
fread(&count, sizeof(uint32_t), 1, file);
|
||||
if (version == 1)
|
||||
{
|
||||
for (uint32_t s = 0; s < count; s++)
|
||||
{
|
||||
uint16_t ipLen = 0, p = 0, nameLen = 0;
|
||||
if (fread(&ipLen, sizeof(uint16_t), 1, file) != 1) break;
|
||||
if (ipLen == 0 || ipLen > 256) break;
|
||||
char ipBuf[257] = {};
|
||||
if (fread(ipBuf, 1, ipLen, file) != ipLen) break;
|
||||
if (fread(&p, sizeof(uint16_t), 1, file) != 1) break;
|
||||
if (fread(&nameLen, sizeof(uint16_t), 1, file) != 1) break;
|
||||
if (nameLen > 256) break;
|
||||
char nameBuf[257] = {};
|
||||
if (nameLen > 0 && fread(nameBuf, 1, nameLen, file) != nameLen) break;
|
||||
entries.push_back({std::string(ipBuf), p, std::string(nameBuf)});
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
// Remove the entry at m_serverIndex
|
||||
int idx = m_serverIndex;
|
||||
if (idx >= 0 && idx < (int)entries.size())
|
||||
{
|
||||
entries.erase(entries.begin() + idx);
|
||||
}
|
||||
|
||||
file = fopen("servers.db", "wb");
|
||||
if (file)
|
||||
{
|
||||
fwrite("MCSV", 1, 4, file);
|
||||
uint32_t version = 1;
|
||||
uint32_t count = (uint32_t)entries.size();
|
||||
fwrite(&version, sizeof(uint32_t), 1, file);
|
||||
fwrite(&count, sizeof(uint32_t), 1, file);
|
||||
|
||||
for (size_t i = 0; i < entries.size(); i++)
|
||||
{
|
||||
uint16_t ipLen = (uint16_t)entries[i].ip.length();
|
||||
fwrite(&ipLen, sizeof(uint16_t), 1, file);
|
||||
fwrite(entries[i].ip.c_str(), 1, ipLen, file);
|
||||
fwrite(&entries[i].port, sizeof(uint16_t), 1, file);
|
||||
uint16_t nameLen = (uint16_t)entries[i].name.length();
|
||||
fwrite(&nameLen, sizeof(uint16_t), 1, file);
|
||||
fwrite(entries[i].name.c_str(), 1, nameLen, file);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
#endif // _WINDOWS64
|
||||
Reference in New Issue
Block a user