Update to NeoLegacy Latest

This commit is contained in:
2026-05-28 01:23:47 -04:00
parent f4390d5f0b
commit 10f9576b72
201 changed files with 12535 additions and 25235 deletions
@@ -1,3 +1,4 @@
#include "IUIScene_CreativeMenu.h"
#include "stdafx.h"
#include "IUIScene_CreativeMenu.h"
@@ -22,6 +23,56 @@ vector< shared_ptr<ItemInstance> > IUIScene_CreativeMenu::categoryGroups[eCreati
#define ITEM_AUX(id, aux) list->push_back( shared_ptr<ItemInstance>(new ItemInstance(id, 1, aux)) );
#define DEF(index) list = &categoryGroups[index];
void IUIScene_CreativeMenu::_wipeCreativeItems() {
for (int i = 0; i < eCreativeInventoryGroupsCount; i++) {
IUIScene_CreativeMenu::categoryGroups[i].clear();
}
}
void IUIScene_CreativeMenu::loadFromLocal() {
IUIScene_CreativeMenu::_wipeCreativeItems();
IUIScene_CreativeMenu::staticCtor();
}
void IUIScene_CreativeMenu::loadFromPacket(byteArray packetData) {
ByteArrayInputStream bais(packetData);
DataInputStream input(&bais);
IUIScene_CreativeMenu::_wipeCreativeItems();
for (int i = 0; i < eCreativeInventoryGroupsCount; i++) {
int itemCount = input.readShort();
for (int j = 0; j < itemCount; j++) {
int itemId = input.readShort();
int itemAux = input.readShort();
shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(itemId, 1, 0);
item->setRawAuxValue(itemAux);
item->tag = Packet::readNbt(&input);
IUIScene_CreativeMenu::categoryGroups[i].emplace_back(item);
}
}
}
std::shared_ptr<CustomPayloadPacket> IUIScene_CreativeMenu::createUpdatePacket() {
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
for (int i = 0; i < eCreativeInventoryGroupsCount; i++) {
dos.writeShort(IUIScene_CreativeMenu::categoryGroups[i].size());
for (shared_ptr<ItemInstance>& item : IUIScene_CreativeMenu::categoryGroups[i]) {
dos.writeShort(item->id);
dos.writeShort(item->getAuxValue());
Packet::writeNbt(item->tag, &dos);
}
}
return std::make_shared<CustomPayloadPacket>(CustomPayloadPacket::UPDATE_CREATIVE_REGISTRY, baos.toByteArray());
}
void IUIScene_CreativeMenu::staticCtor()
{
vector< shared_ptr<ItemInstance> > *list;
@@ -801,55 +852,56 @@ void IUIScene_CreativeMenu::staticCtor()
ITEM_AUX(Item::potion_Id,MACRO_MAKEPOTION_AUXVAL(MASK_SPLASH, MASK_LEVEL2EXTENDED, MASK_JUMPBOOST))
// end of tu31 potions
if (specs == nullptr) {
specs = new TabSpec * [eCreativeInventoryTab_COUNT];
specs = new TabSpec*[eCreativeInventoryTab_COUNT];
// Top Row
ECreative_Inventory_Groups blocksGroup[] = {eCreativeInventory_BuildingBlocks};
specs[eCreativeInventoryTab_BuildingBlocks] = new TabSpec(L"Structures", IDS_GROUPNAME_BUILDING_BLOCKS, 1, blocksGroup);
// Top Row
ECreative_Inventory_Groups blocksGroup[] = { eCreativeInventory_BuildingBlocks };
specs[eCreativeInventoryTab_BuildingBlocks] = new TabSpec(L"Structures", IDS_GROUPNAME_BUILDING_BLOCKS, 1, blocksGroup);
#ifndef _CONTENT_PACKAGE
ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration};
ECreative_Inventory_Groups debugDecorationsGroup[] = {eCreativeInventory_ArtToolsDecorations};
specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, nullptr, 1, debugDecorationsGroup);
ECreative_Inventory_Groups decorationsGroup[] = { eCreativeInventory_Decoration };
ECreative_Inventory_Groups debugDecorationsGroup[] = { eCreativeInventory_ArtToolsDecorations };
specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, nullptr, 1, debugDecorationsGroup);
#else
ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration};
specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup);
ECreative_Inventory_Groups decorationsGroup[] = { eCreativeInventory_Decoration };
specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup);
#endif
ECreative_Inventory_Groups redAndTranGroup[] = {eCreativeInventory_Transport, eCreativeInventory_Redstone};
specs[eCreativeInventoryTab_RedstoneAndTransport] = new TabSpec(L"RedstoneAndTransport", IDS_GROUPNAME_REDSTONE_AND_TRANSPORT, 2, redAndTranGroup);
ECreative_Inventory_Groups redAndTranGroup[] = { eCreativeInventory_Transport, eCreativeInventory_Redstone };
specs[eCreativeInventoryTab_RedstoneAndTransport] = new TabSpec(L"RedstoneAndTransport", IDS_GROUPNAME_REDSTONE_AND_TRANSPORT, 2, redAndTranGroup);
ECreative_Inventory_Groups materialsGroup[] = {eCreativeInventory_Materials};
specs[eCreativeInventoryTab_Materials] = new TabSpec(L"Materials", IDS_GROUPNAME_MATERIALS, 1, materialsGroup);
ECreative_Inventory_Groups materialsGroup[] = { eCreativeInventory_Materials };
specs[eCreativeInventoryTab_Materials] = new TabSpec(L"Materials", IDS_GROUPNAME_MATERIALS, 1, materialsGroup);
ECreative_Inventory_Groups foodGroup[] = {eCreativeInventory_Food};
specs[eCreativeInventoryTab_Food] = new TabSpec(L"Food", IDS_GROUPNAME_FOOD, 1, foodGroup);
ECreative_Inventory_Groups foodGroup[] = { eCreativeInventory_Food };
specs[eCreativeInventoryTab_Food] = new TabSpec(L"Food", IDS_GROUPNAME_FOOD, 1, foodGroup);
ECreative_Inventory_Groups toolsGroup[] = {eCreativeInventory_ToolsArmourWeapons};
specs[eCreativeInventoryTab_ToolsWeaponsArmor] = new TabSpec(L"Tools", IDS_GROUPNAME_TOOLS_WEAPONS_ARMOR, 1, toolsGroup);
ECreative_Inventory_Groups toolsGroup[] = { eCreativeInventory_ToolsArmourWeapons };
specs[eCreativeInventoryTab_ToolsWeaponsArmor] = new TabSpec(L"Tools", IDS_GROUPNAME_TOOLS_WEAPONS_ARMOR, 1, toolsGroup);
ECreative_Inventory_Groups brewingGroup[] = {eCreativeInventory_Brewing, eCreativeInventory_Potions_Level2_Extended, eCreativeInventory_Potions_Extended, eCreativeInventory_Potions_Level2, eCreativeInventory_Potions_Basic};
ECreative_Inventory_Groups brewingGroup[] = { eCreativeInventory_Brewing, eCreativeInventory_Potions_Level2_Extended, eCreativeInventory_Potions_Extended, eCreativeInventory_Potions_Level2, eCreativeInventory_Potions_Basic };
// Just use the text LT - the graphic doesn't fit in splitscreen either
// In 480p there's not enough room for the LT button, so use text instead
//if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())
{
specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"Brewing", IDS_GROUPNAME_POTIONS_480, 5, brewingGroup);
// Just use the text LT - the graphic doesn't fit in splitscreen either
// In 480p there's not enough room for the LT button, so use text instead
//if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())
{
specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"Brewing", IDS_GROUPNAME_POTIONS_480, 5, brewingGroup);
}
// else
// {
// specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"icon_brewing.png", IDS_GROUPNAME_POTIONS, 1, brewingGroup, 4, potionsGroup);
// }
#ifndef _CONTENT_PACKAGE
ECreative_Inventory_Groups miscGroup[] = { eCreativeInventory_Misc };
ECreative_Inventory_Groups debugMiscGroup[] = { eCreativeInventory_ArtToolsMisc };
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, 1, debugMiscGroup);
#else
ECreative_Inventory_Groups miscGroup[] = { eCreativeInventory_Misc };
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup);
#endif
}
// else
// {
// specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"icon_brewing.png", IDS_GROUPNAME_POTIONS, 1, brewingGroup, 4, potionsGroup);
// }
#ifndef _CONTENT_PACKAGE
ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc};
ECreative_Inventory_Groups debugMiscGroup[] = {eCreativeInventory_ArtToolsMisc};
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, 1, debugMiscGroup);
#else
ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc};
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup);
#endif
}
IUIScene_CreativeMenu::IUIScene_CreativeMenu()
@@ -1,6 +1,7 @@
#pragma once
#include "IUIScene_AbstractContainerMenu.h"
#include "../../../Minecraft.World/AbstractContainerMenu.h"
#include "../../../Minecraft.World/CustomPayloadPacket.h"
// 4J Stu - This class is for code that is common between XUI and Iggy
class SimpleContainer;
@@ -100,10 +101,16 @@ protected:
bool m_bCarryingCreativeItem;
int m_creativeSlotX, m_creativeSlotY, m_inventorySlotX, m_inventorySlotY;
static void _wipeCreativeItems();
public:
static void staticCtor();
IUIScene_CreativeMenu();
static void loadFromLocal();
static void loadFromPacket(byteArray packetData);
static std::shared_ptr<CustomPayloadPacket> createUpdatePacket();
protected:
ECreativeInventoryTabs m_curTab;
int m_tabDynamicPos[eCreativeInventoryTab_COUNT];
+12
View File
@@ -94,6 +94,18 @@ S32 UIControl::getYPos()
return m_y;
}
void UIControl::setXPos(S32 x)
{
m_x = x;
IggyValueSetF64RS( getIggyValuePath(), m_nameXPos, nullptr, (F64)x );
}
void UIControl::setYPos(S32 y)
{
m_y = y;
IggyValueSetF64RS( getIggyValuePath(), m_nameYPos, nullptr, (F64)y );
}
S32 UIControl::getWidth()
{
return m_width;
+2
View File
@@ -81,6 +81,8 @@ public:
S32 getXPos();
S32 getYPos();
void setXPos(S32 x);
void setYPos(S32 y);
S32 getWidth();
S32 getHeight();
@@ -14,6 +14,14 @@ bool UIControl_SaveList::setupControl(UIScene *scene, IggyValuePath *parent, con
return success;
}
void UIControl_SaveList::enableX2Icons()
{
IggyName useX2 = registerFastName(L"m_bUseX2IconButtons");
IggyValueSetBooleanRS(getIggyValuePath(), useX2, nullptr, true);
}
void UIControl_SaveList::addItem(const wstring &label)
{
addItem(label, L"");
@@ -92,6 +100,78 @@ void UIControl_SaveList::addItem(const wstring &label, const wstring &iconName,
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 3 , value );
}
void UIControl_SaveList::addItem(const string &label, const wstring &iconName1, const wstring &iconName2)
{
addItem(label, iconName1, iconName2, m_itemCount);
++m_itemCount;
}
void UIControl_SaveList::addItem(const wstring &label, const wstring &iconName1, const wstring &iconName2)
{
addItem(label, iconName1, iconName2, m_itemCount);
++m_itemCount;
}
void UIControl_SaveList::addItem(const string &label, const wstring &iconName1, const wstring &iconName2, int data)
{
IggyDataValue result;
IggyDataValue value[4];
IggyStringUTF8 stringVal;
stringVal.string = (char*)label.c_str();
stringVal.length = static_cast<S32>(label.length());
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = data;
IggyStringUTF16 stringVal2;
stringVal2.string = (IggyUTF16*)iconName1.c_str();
stringVal2.length = iconName1.length();
value[2].type = IGGY_DATATYPE_string_UTF16;
value[2].string16 = stringVal2;
IggyStringUTF16 stringVal3;
stringVal3.string = (IggyUTF16*)iconName2.c_str();
stringVal3.length = iconName2.length();
value[3].type = IGGY_DATATYPE_string_UTF16;
value[3].string16 = stringVal3;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_addNewItemFunc, 4, value);
}
void UIControl_SaveList::addItem(const wstring &label, const wstring &iconName1, const wstring &iconName2, int data)
{
wstring shaped = shapeArabicText(label);
IggyDataValue result;
IggyDataValue value[4];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)shaped.c_str();
stringVal.length = static_cast<S32>(shaped.length());
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = data;
IggyStringUTF16 stringVal2;
stringVal2.string = (IggyUTF16*)iconName1.c_str();
stringVal2.length = iconName1.length();
value[2].type = IGGY_DATATYPE_string_UTF16;
value[2].string16 = stringVal2;
IggyStringUTF16 stringVal3;
stringVal3.string = (IggyUTF16*)iconName2.c_str();
stringVal3.length = iconName2.length();
value[3].type = IGGY_DATATYPE_string_UTF16;
value[3].string16 = stringVal3;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_addNewItemFunc, 4, value);
}
void UIControl_SaveList::setTextureName(int iId, const wstring &iconName)
{
IggyDataValue result;
@@ -107,3 +187,4 @@ void UIControl_SaveList::setTextureName(int iId, const wstring &iconName)
value[1].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetTextureName , 2 , value );
}
@@ -20,10 +20,17 @@ public:
void addItem(const string &label, const wstring &iconName);
void addItem(const wstring &label, const wstring &iconName);
void addItem(const string &label, const wstring &iconName1, const wstring &iconName2);
void addItem(const wstring &label, const wstring &iconName1, const wstring &iconName2);
void setTextureName(int iId, const wstring &iconName);
void enableX2Icons();
private:
void addItem(const string &label, const wstring &iconName, int data);
void addItem(const wstring &label, const wstring &iconName, int data);
void addItem(const string &label, const wstring &iconName1, const wstring &iconName2, int data);
void addItem(const wstring &label, const wstring &iconName1, const wstring &iconName2, int data);
};
+41 -4
View File
@@ -5,6 +5,7 @@
#include "UIScene.h"
#include "UIControl_Slider.h"
#include "UIControl_TexturePackList.h"
#include "UIControl_CheckBox.h"
#include "UIControl_AchievementsList.h"
#include "UIScene_AchievementsMenu.h"
#include "../../../Minecraft.World/StringHelpers.h"
@@ -615,6 +616,8 @@ void UIController::loadSkins()
//used these as skin.swf and skinInGame.swf it breaks some other things
m_iggyLibraries[eLibrary_LCDefault] = loadSkin(L"skinLC.swf", L"skinLC.swf");
m_iggyLibraries[eLibrary_LCInGame] = loadSkin(L"skinInGameLC.swf", L"skinInGameLC.swf");
m_iggyLibraries[eLibrary_LCGraphics] = loadSkin(L"skinGraphicsLC.swf", L"skinGraphicsLC.swf");
m_iggyLibraries[eLibrary_LCLabels] = loadSkin(L"skinLabelsLC.swf", L"skinLabelsLC.swf");
// Some 1080p menu ports (such as LoadCreateJoin) may import DR-specific HD
// libraries by distinct names. Load them opportunistically when present so
@@ -834,6 +837,7 @@ void UIController::tickInput()
{
#ifdef _WINDOWS64
m_mouseClickConsumedByScene = false;
UIControl* currHitCtrl = NULL;
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
{
UIScene *pScene = nullptr;
@@ -1008,6 +1012,7 @@ void UIController::tickInput()
hitControlId = -1;
hitArea = INT_MAX;
hitCtrl = NULL;
hitCtrl = ctrl;
break; // ButtonList takes priority
}
if (type == UIControl::eAchievementList)
@@ -1020,6 +1025,7 @@ void UIController::tickInput()
hitControlId = -1;
hitArea = INT_MAX;
hitCtrl = NULL;
hitCtrl = ctrl;
break;
}
if (type == UIControl::eTexturePackList)
@@ -1068,6 +1074,8 @@ void UIController::tickInput()
}
}
}
currHitCtrl = hitCtrl;
UpdateCursorIcon(currHitCtrl);
}
}
@@ -1194,6 +1202,27 @@ void UIController::tickInput()
}
}
void UIController::UpdateCursorIcon(UIControl *hitCtrl)
{
// from WinUser.h
if (hitCtrl && (hitCtrl->getControlType() == UIControl::eButton || hitCtrl->getControlType() == UIControl::eButtonList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
else if (hitCtrl && (hitCtrl->getControlType() == UIControl::eSlider || hitCtrl->getControlType() == UIControl::eTexturePackList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_SIZEWE));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput)
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_IBEAM));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eCheckBox) // Show the cross sign shaped cursor only when the checkbox is disabled/grayed out
{
UIControl_CheckBox *pCheck = static_cast<UIControl_CheckBox *>(hitCtrl);
if (pCheck && !pCheck->IsEnabled())
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_NO));
else
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
}
else
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_ARROW));
}
void UIController::handleInput()
{
// For each user, loop over each key type and send messages based on the state
@@ -1487,10 +1516,16 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
// hovering a horizontal list (e.g. TexturePackList), UP/DOWN otherwise.
if (pressed && g_KBMInput.IsKBMActive())
{
if (m_bMouseHoverHorizontalList)
key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_LEFT : ACTION_MENU_RIGHT;
else
key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_UP : ACTION_MENU_DOWN;
UIScene* pTopScene = GetTopScene(0); // using 0 as default pad for KBM
bool isJoinMenu = pTopScene && pTopScene->getSceneType() == eUIScene_JoinMenu;
if (!isJoinMenu)
{
if (m_bMouseHoverHorizontalList)
key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_LEFT : ACTION_MENU_RIGHT;
else
key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_UP : ACTION_MENU_DOWN;
}
}
}
}
@@ -2070,6 +2105,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
SetMenuDisplayed(menuDisplayedPad,true);
bool success = m_groups[static_cast<int>(group)]->NavigateToScene(iPad, scene, initData, layer);
if(success && group == eUIGroup_Fullscreen) setFullscreenMenuDisplayed(true);
UpdateCursorIcon(nullptr);
LeaveCriticalSection(&m_navigationLock);
timer.PrintElapsedTime(L"Navigate to scene");
@@ -2109,6 +2145,7 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI
navComplete = m_groups[static_cast<int>(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer);
if(!m_groups[static_cast<int>(eUIGroup_Fullscreen)]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false);
}
UpdateCursorIcon(nullptr);
return navComplete;
}
@@ -105,6 +105,8 @@ private:
eLibrary_LCDefault,
eLibrary_LCInGame,
eLibrary_LCGraphics,
eLibrary_LCLabels,
#if defined(_WINDOWS64)
// Non-HD skin libraries needed by 720p/480p scene SWFs.
@@ -260,6 +262,7 @@ public:
// INPUT
private:
void tickInput();
void UpdateCursorIcon(UIControl *hitCtrl);
void handleInput();
void handleKeyPress(unsigned int iPad, unsigned int key);
@@ -2,6 +2,12 @@
#include "UI.h"
#include "UIScene_Intro.h"
// HUCKLE - added below for joining game on launch
#ifdef _WINDOWS64
#include "../../Windows64/Network/WinsockNetLayer.h"
#include "../../User.h"
#endif
UIScene_Intro::UIScene_Intro(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
@@ -104,6 +110,82 @@ void UIScene_Intro::handleInput(int iPad, int key, bool repeat, bool pressed, bo
}
#elif defined _XBOX_ONE
ui.NavigateToScene(0,eUIScene_MainMenu);
#elif defined _WINDOWS64
// HUCKLE - added this for auto joining servers on game launch
// THANKS so much to DrPerky and GeorgeV22 for helping with this bit, honestly got stuck for 4 hours :sob:
if(g_Win64MultiplayerJoin == true)
{
int primaryPad = ProfileManager.GetPrimaryPad();
if (!ProfileManager.IsSignedIn(primaryPad) || ProfileManager.IsGuest(primaryPad))
{
UINT uiIDA[1] = { IDS_OK };
ui.RequestErrorMessage(IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, uiIDA, 1);
ui.NavigateToScene(0, eUIScene_MainMenu);
return;
}
app.ClearSignInChangeUsersMask();
app.ReleaseSaveThumbnail();
ProfileManager.SetLockedProfile(primaryPad);
ProfileManager.QuerySigninStatus();
if (!app.DLCInstallProcessCompleted())
app.StartInstallDLCProcess(primaryPad);
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->user->name = convStringToWstring(ProfileManager.GetGamertag(primaryPad));
app.ApplyGameSettingsChanged(primaryPad);
auto sessionInfo = std::make_unique<FriendSessionInfo>();
// label and name
const wchar_t* defaultName = L"";
size_t nameLen = wcslen(defaultName);
// ip and port
strncpy_s(sessionInfo->data.hostIP, g_Win64MultiplayerIP, sizeof(sessionInfo->data.hostIP) - 1);
sessionInfo->data.hostPort = g_Win64MultiplayerPort;
// display label
sessionInfo->displayLabel = new wchar_t[nameLen + 1];
wcscpy_s(sessionInfo->displayLabel, nameLen + 1, defaultName);
sessionInfo->displayLabelLength = static_cast<unsigned char>(nameLen);
sessionInfo->displayLabelViewableStartIndex = 0;
// name
wcsncpy_s(sessionInfo->data.hostName, XUSER_NAME_SIZE, defaultName, _TRUNCATE);
// session ids
sessionInfo->sessionId = static_cast<uint64_t>(inet_addr(g_Win64MultiplayerIP)) |
static_cast<uint64_t>(g_Win64MultiplayerPort) << 32;
// random props
sessionInfo->data.isReadyToJoin = true;
sessionInfo->data.isJoinable = true;
DWORD dwLocalUsersMask = 0;
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( sessionInfo.get(), dwLocalUsersMask );
if (result == CGameNetworkManager::JOINGAME_PENDING)
{
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);
}
}
else
{
ui.NavigateToScene(0,eUIScene_SaveMessage);
}
#else
ui.NavigateToScene(0,eUIScene_SaveMessage);
#endif
@@ -169,6 +251,82 @@ void UIScene_Intro::handleAnimationEnd()
{
m_bAnimationEnded = true;
}
#elif defined _WINDOWS64
// HUCKLE - added this for auto joining servers on game launch
// THANKS so much to DrPerky and GeorgeV22 for helping with this bit, honestly got stuck for 4 hours :sob:
if(g_Win64MultiplayerJoin == true)
{
int primaryPad = ProfileManager.GetPrimaryPad();
if (!ProfileManager.IsSignedIn(primaryPad) || ProfileManager.IsGuest(primaryPad))
{
UINT uiIDA[1] = { IDS_OK };
ui.RequestErrorMessage(IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, uiIDA, 1);
ui.NavigateToScene(0, eUIScene_MainMenu);
return;
}
app.ClearSignInChangeUsersMask();
app.ReleaseSaveThumbnail();
ProfileManager.SetLockedProfile(primaryPad);
ProfileManager.QuerySigninStatus();
if (!app.DLCInstallProcessCompleted())
app.StartInstallDLCProcess(primaryPad);
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->user->name = convStringToWstring(ProfileManager.GetGamertag(primaryPad));
app.ApplyGameSettingsChanged(primaryPad);
auto sessionInfo = std::make_unique<FriendSessionInfo>();
// label and name
const wchar_t* defaultName = L"";
size_t nameLen = wcslen(defaultName);
// ip and port
strncpy_s(sessionInfo->data.hostIP, g_Win64MultiplayerIP, sizeof(sessionInfo->data.hostIP) - 1);
sessionInfo->data.hostPort = g_Win64MultiplayerPort;
// display label
sessionInfo->displayLabel = new wchar_t[nameLen + 1];
wcscpy_s(sessionInfo->displayLabel, nameLen + 1, defaultName);
sessionInfo->displayLabelLength = static_cast<unsigned char>(nameLen);
sessionInfo->displayLabelViewableStartIndex = 0;
// name
wcsncpy_s(sessionInfo->data.hostName, XUSER_NAME_SIZE, defaultName, _TRUNCATE);
// session ids
sessionInfo->sessionId = static_cast<uint64_t>(inet_addr(g_Win64MultiplayerIP)) |
static_cast<uint64_t>(g_Win64MultiplayerPort) << 32;
// random props
sessionInfo->data.isReadyToJoin = true;
sessionInfo->data.isJoinable = true;
DWORD dwLocalUsersMask = 0;
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( sessionInfo.get(), dwLocalUsersMask );
if (result == CGameNetworkManager::JOINGAME_PENDING)
{
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);
}
}
else
{
ui.NavigateToScene(0,eUIScene_SaveMessage);
}
#else
ui.NavigateToScene(0,eUIScene_SaveMessage);
#endif
@@ -6,7 +6,7 @@
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "..\..\..\Minecraft.World\net.minecraft.stats.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.effect.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "..\..\MultiPlayerLocalPlayer.h"
#include "..\..\Minecraft.h"
#include "..\..\Options.h"
#include "..\..\EntityRenderDispatcher.h"
+597 -54
View File
@@ -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
+29 -1
View File
@@ -34,6 +34,10 @@ private:
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT( m_buttonJoinGame, "JoinGame")
UI_MAP_ELEMENT( m_buttonListPlayers, "GamePlayers")
if (m_loadedResolution == eSceneResolution_720)
{
m_buttonListPlayers.setYPos(170.0);
}
UI_MAP_ELEMENT( m_labelLabels[0], "Label0")
UI_MAP_ELEMENT( m_labelLabels[1], "Label1")
@@ -62,21 +66,36 @@ private:
bool m_friendInfoUpdatedOK;
bool m_friendInfoUpdatedERROR;
#ifdef _WINDOWS64
int m_serverIndex; // Index in servers.db, -1 if not a saved server
enum eEditServerPhase { eEditServer_Idle, eEditServer_IP, eEditServer_Port, eEditServer_Name };
eEditServerPhase m_editServerPhase;
wstring m_editServerIP;
wstring m_editServerPort;
int m_editServerButtonIndex;
int m_deleteServerButtonIndex;
#endif
public:
UIScene_JoinMenu(int iPad, void *initData, UILayer *parentLayer);
virtual ~UIScene_JoinMenu();
void tick();
static void friendSessionUpdated(bool success, void *pParam);
static int ErrorDialogReturned(void *pParam, int iPad, const C4JStorage::EMessageResult);
virtual void updateTooltips();
virtual void updateComponents();
virtual void render(S32 width, S32 height, C4JRender::eViewportType viewpBort);
virtual EUIScene getSceneType() { return eUIScene_LoadMenu;}
virtual EUIScene getSceneType() { return eUIScene_JoinMenu;}
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
void updateServerDescription();
public:
public:
// INPUT
virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);
@@ -95,4 +114,13 @@ protected:
static int StartGame_SignInReturned(void *pParam, bool, int);
static void JoinGame(UIScene_JoinMenu* pClass);
#ifdef _WINDOWS64
void BeginEditServer();
void BeginDeleteServer();
static int EditServerKeyboardCallback(LPVOID lpParam, bool bRes);
static int DeleteServerDialogReturned(void *pParam, int iPad, C4JStorage::EMessageResult result);
void UpdateServerInFile(const wstring& newIP, const wstring& newPort, const wstring& newName);
void RemoveServerFromFile();
#endif
};
@@ -751,6 +751,7 @@ UIScene_LoadCreateJoinMenu::UIScene_LoadCreateJoinMenu(int iPad, void *initData,
m_buttonListNewGames.init(eControl_NewGamesList);
m_buttonListGames.init(eControl_GamesList);
m_buttonListGames.enableX2Icons();
@@ -1606,6 +1607,32 @@ void UIScene_LoadCreateJoinMenu::UpdateMouseHoverForActiveTab()
if (!ConvertMouseToSceneCoords(sceneMouseX, sceneMouseY))
return;
// tab area threshold (approx coordinates based on handleMouseClick)
float maxY = (getSceneResolution() == eSceneResolution_1080) ? 200.0f : 135.0f;
if (sceneMouseY < maxY)
{
// mouse is high up (near or on tabs) deselect lists to avoid collisions
if (m_buttonListSaves.getCurrentSelection() != -1)
{
m_buttonListSaves.setCurrentSelection(-1);
}
if (m_buttonListNewGames.getCurrentSelection() != -1)
{
m_buttonListNewGames.setCurrentSelection(-1);
}
if (m_buttonListGames.getCurrentSelection() != -1)
{
m_buttonListGames.setCurrentSelection(-1);
}
// reset internal indices to -1 so tick() doesn't restore selection
m_iSaveListIndex = -1;
m_iNewGameListIndex = -1;
m_iGameListIndex = -1;
m_bUpdateSaveSize = true; // refresh save size bar / secondary UI
}
UIControl_ButtonList *pActiveList = nullptr;
switch (m_activeTab)
{
@@ -1749,6 +1776,76 @@ void UIScene_LoadCreateJoinMenu::UpdateMouseHoverForActiveTab()
m_bPendingSaveSizeBarRefresh = true;
m_bPendingJoinTabAvailabilityRefresh = true;
}
bool UIScene_LoadCreateJoinMenu::handleMouseClick(F32 x, F32 y)
{
if (!hasFocus(m_iPad) || getMovie() == nullptr || g_KBMInput.IsMouseGrabbed() || !g_KBMInput.IsKBMActive())
{
return false;
}
if (m_bIgnoreInput)
{
return false;
}
float sceneMouseX = 0.0f;
float sceneMouseY = 0.0f;
if (!ConvertMouseToSceneCoords(sceneMouseX, sceneMouseY))
{
return false;
}
float loadMinX = 335.0f;
float loadMaxX = 535.0f;
float createMaxX = 735.0f;
float joinMaxX = 935.0f;
float minY = 77.0f;
float maxY = 135.0f;
if (getSceneResolution() == eSceneResolution_1080)
{
loadMinX = 502.0f;
loadMaxX = 802.0f;
createMaxX = 1102.0f;
joinMaxX = 1402.0f;
minY = 115.0f;
maxY = 200.0f;
}
if (sceneMouseY >= minY && sceneMouseY <= maxY)
{
if (sceneMouseX >= loadMinX && sceneMouseX <= loadMaxX)
{
if (m_activeTab != eTab_Load)
{
SetActiveTab(eTab_Load, true);
ui.PlayUISFX(eSFX_Press);
}
return true; // click consumed by tab
}
else if (sceneMouseX > loadMaxX && sceneMouseX <= createMaxX)
{
if (m_activeTab != eTab_Create)
{
SetActiveTab(eTab_Create, true);
ui.PlayUISFX(eSFX_Press);
}
return true; // click consumed by tab
}
else if (sceneMouseX > createMaxX && sceneMouseX <= joinMaxX)
{
if (m_activeTab != eTab_Join)
{
SetActiveTab(eTab_Join, true);
ui.PlayUISFX(eSFX_Press);
}
return true; // click consumed by tab
}
}
return UIScene::handleMouseClick(x, y);
}
#endif
wstring UIScene_LoadCreateJoinMenu::getMoviePath()
@@ -1935,7 +2032,10 @@ void UIScene_LoadCreateJoinMenu::UpdateSaveSizeBarVisibility()
const bool showSaveSizeBar = (m_activeTab == eTab_Load);
// user option to hide the save size bar entirely (added via SettingsUIMenu checkbox)
const bool hideBar = (app.GetGameSettings(m_iPad, eGameSetting_HideSaveSizeBar) != 0);
const bool showSaveSizeBar = (m_activeTab == eTab_Load) && !hideBar;
IggyDataValue result;
@@ -1955,6 +2055,10 @@ void UIScene_LoadCreateJoinMenu::tick()
UIScene::tick();
#ifdef _WINDOWS64
UpdateMouseHoverForActiveTab();
#endif
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined _WINDOWS64 || defined __PSVITA__)
if(m_bExitScene) // navigate forward or back
@@ -3665,6 +3769,12 @@ void UIScene_LoadCreateJoinMenu::handleFocusChange(F64 controlId, F64 childId)
m_iGameListIndex = childId;
#ifdef _WINDOWS64
m_iGameListIndex -= 1;
#endif
m_buttonListGames.updateChildFocus(static_cast<int>(childId));
if (childId < m_hoverBaseIndexJoin)
@@ -4189,6 +4299,58 @@ void UIScene_LoadCreateJoinMenu::CheckAndJoinGame(int gameIndex)
m_initData->selectedSession = m_currentSessions->at( gameIndex );
#ifdef _WINDOWS64
{
int serverDbCount = 0;
FILE* dbFile = fopen("servers.db", "rb");
if (dbFile)
{
char magic[4] = {};
if (fread(magic, 1, 4, dbFile) == 4 && memcmp(magic, "MCSV", 4) == 0)
{
uint32_t version = 0, count = 0;
fread(&version, sizeof(uint32_t), 1, dbFile);
fread(&count, sizeof(uint32_t), 1, dbFile);
if (version == 1)
serverDbCount = static_cast<int>(count);
}
fclose(dbFile);
}
int lanCount = static_cast<int>(m_currentSessions->size()) - serverDbCount;
if (gameIndex >= lanCount && lanCount >= 0)
m_initData->serverIndex = gameIndex - lanCount;
else
m_initData->serverIndex = -1;
}
#endif
if(m_initData->selectedSession->data.texturePackParentId!=0)
{
@@ -4452,10 +4614,20 @@ void UIScene_LoadCreateJoinMenu::RebuildJoinGamesListVisual(bool syncFocus)
unsigned int nIndex = m_buttonListGames.getCurrentSelection();
#ifdef _WINDOWS64
if (m_currentSessions != nullptr && nIndex > 0 && (nIndex - 1) < m_currentSessions->size())
pSelectedSession = m_currentSessions->at( nIndex - 1 );
#else
if (m_currentSessions != nullptr && nIndex < m_currentSessions->size())
pSelectedSession = m_currentSessions->at( nIndex );
#endif
}
SessionID selectedSessionId;
@@ -4478,81 +4650,74 @@ void UIScene_LoadCreateJoinMenu::RebuildJoinGamesListVisual(bool syncFocus)
m_buttonListGames.setCurrentSelection(0);
for( FriendSessionInfo *sessionInfo : *m_currentSessions )
for (FriendSessionInfo *sessionInfo : *m_currentSessions)
{
const int gameType = app.GetGameHostOption(sessionInfo->data.m_uiGameHostSettings, eGameHostOption_GameType);
const wchar_t *modeIconFile = L"SurvivalIcon.png";
const wchar_t *modeIconName = L"SurvivalIcon";
wchar_t textureName[64] = L"\0";
if(sessionInfo->data.texturePackParentId!=0)
if (gameType == GameType::CREATIVE->getId())
{
Minecraft *pMinecraft = Minecraft::GetInstance();
TexturePack *tp = pMinecraft->skins->getTexturePackById(sessionInfo->data.texturePackParentId);
DWORD dwImageBytes=0;
PBYTE pbImageData=nullptr;
if(tp==nullptr)
{
DWORD dwBytes=0;
PBYTE pbData=nullptr;
app.GetTPD(sessionInfo->data.texturePackParentId,&pbData,&dwBytes);
app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes );
if(dwImageBytes > 0 && pbImageData)
{
swprintf(textureName,64,L"%ls",sessionInfo->displayLabel);
registerSubstitutionTexture(textureName,pbImageData,dwImageBytes);
}
}
else
{
pbImageData = tp->getPackIcon(dwImageBytes);
if(dwImageBytes > 0 && pbImageData)
{
swprintf(textureName,64,L"%ls",sessionInfo->displayLabel);
registerSubstitutionTexture(textureName,pbImageData,dwImageBytes);
}
}
modeIconFile = L"CreativeIcon.png";
modeIconName = L"CreativeIcon";
}
else if (gameType == GameType::ADVENTURE->getId())
{
modeIconFile = L"AdventureIcon.png";
modeIconName = L"AdventureIcon";
}
else
// register game mode icon
TrySetButtonListIcon(m_buttonListGames, -1, modeIconFile, modeIconName);
// texture pack icon logic
wchar_t tpIconName[64] = L"\0";
if (sessionInfo->data.texturePackParentId != 0)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
TexturePack *tp = pMinecraft->skins->getTexturePackById(sessionInfo->data.texturePackParentId);
DWORD dwImageBytes = 0;
PBYTE pbImageData = nullptr;
if (tp == nullptr)
{
DWORD dwBytes = 0;
PBYTE pbData = nullptr;
app.GetTPD(sessionInfo->data.texturePackParentId, &pbData, &dwBytes);
app.GetFileFromTPD(eTPDFileType_Icon, pbData, dwBytes, &pbImageData, &dwImageBytes);
if (dwImageBytes > 0 && pbImageData)
{
swprintf(tpIconName, 64, L"tp_%ls", sessionInfo->displayLabel);
registerSubstitutionTexture(tpIconName, pbImageData, dwImageBytes);
}
}
else
{
pbImageData = tp->getPackIcon(dwImageBytes);
if (dwImageBytes > 0 && pbImageData)
{
swprintf(tpIconName, 64, L"tp_%ls", sessionInfo->displayLabel);
registerSubstitutionTexture(tpIconName, pbImageData, dwImageBytes);
}
}
}
else
{
Minecraft *pMinecraft = Minecraft::GetInstance();
TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(0);
DWORD dwImageBytes;
PBYTE pbImageData = tp->getPackIcon(dwImageBytes);
if(dwImageBytes > 0 && pbImageData)
if (dwImageBytes > 0 && pbImageData)
{
swprintf(textureName,64,L"%ls",sessionInfo->displayLabel);
registerSubstitutionTexture(textureName,pbImageData,dwImageBytes);
swprintf(tpIconName, 64, L"tp_%ls", sessionInfo->displayLabel);
registerSubstitutionTexture(tpIconName, pbImageData, dwImageBytes);
}
}
m_buttonListGames.addItem( sessionInfo->displayLabel, textureName );
m_buttonListGames.addItem(sessionInfo->displayLabel, modeIconName, tpIconName);
if(memcmp( &selectedSessionId, &sessionInfo->sessionId, sizeof(SessionID) ) == 0)
if (memcmp(&selectedSessionId, &sessionInfo->sessionId, sizeof(SessionID)) == 0)
{
@@ -8816,3 +8981,95 @@ int UIScene_LoadCreateJoinMenu::CopySaveErrorDialogFinishedCallback(void *pParam
#endif // _XBOX_ONE
@@ -220,6 +220,7 @@ private:
void UpdateSaveSizeBarVisibility();
#ifdef _WINDOWS64
void UpdateMouseHoverForActiveTab();
virtual bool handleMouseClick(F32 x, F32 y) override;
bool ConvertMouseToSceneCoords(float &sceneMouseX, float &sceneMouseY);
void GetAbsoluteControlRect(UIControl *pControl, S32 &x, S32 &y, S32 &w, S32 &h);
#endif
@@ -2041,6 +2041,11 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList()
// clear out the games list and re-fill
m_buttonListGames.clearList();
#ifdef _WINDOWS64
// Always add the "Add Server" button as the first entry in the games list
m_buttonListGames.addItem(wstring(L"Add Server"));
#endif
if( filteredListSize > 0 )
{
// Reset the focus to the selected session if it still exists
@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "../App_enums.h"
#include "UI.h"
#include "UIScene_SettingsUIMenu.h"
@@ -16,6 +17,8 @@ UIScene_SettingsUIMenu::UIScene_SettingsUIMenu(int iPad, void *initData, UILayer
m_checkboxSplitscreen.init(app.GetString(IDS_CHECKBOX_VERTICAL_SPLIT_SCREEN),eControl_Splitscreen,(app.GetGameSettings(m_iPad,eGameSetting_SplitScreenVertical)!=0));
m_checkboxShowSplitscreenGamertags.init(app.GetString(IDS_CHECKBOX_DISPLAY_SPLITSCREENGAMERTAGS),eControl_ShowSplitscreenGamertags,(app.GetGameSettings(m_iPad,eGameSetting_DisplaySplitscreenGamertags)!=0));
m_checkboxShowClassicCrafting.init(app.GetString(IDS_CHECKBOX_CLASSICCRAFTING), eControl_ShowClassicCrafting, (app.GetGameSettings(m_iPad, eGameSetting_ClassicCrafting) != 0));
// label is hardcoded for now (no IDS_* yet)
m_checkboxHideLoadCreateJoinSaveSizeBar.init(L"Hide world disk space bar", eControl_HideSaveSizeBar, (app.GetGameSettings(m_iPad, eGameSetting_HideSaveSizeBar) != 0));
WCHAR TempString[256];
@@ -106,6 +109,7 @@ void UIScene_SettingsUIMenu::handleInput(int iPad, int key, bool repeat, bool pr
app.SetGameSettings(m_iPad,eGameSetting_DeathMessages,m_checkboxDisplayDeathMessages.IsChecked()?1:0);
app.SetGameSettings(m_iPad,eGameSetting_AnimatedCharacter,m_checkboxDisplayAnimatedCharacter.IsChecked()?1:0);
app.SetGameSettings(m_iPad, eGameSetting_ClassicCrafting, m_checkboxShowClassicCrafting.IsChecked() ? 1 : 0);
app.SetGameSettings(m_iPad, eGameSetting_HideSaveSizeBar, m_checkboxHideLoadCreateJoinSaveSizeBar.IsChecked() ? 1 : 0);
// if the splitscreen vertical/horizontal has changed, need to update the scenes
@@ -14,11 +14,12 @@ private:
eControl_Splitscreen,
eControl_ShowSplitscreenGamertags,
eControl_ShowClassicCrafting,
eControl_HideSaveSizeBar,
eControl_UISize,
eControl_UISizeSplitscreen
};
UIControl_CheckBox m_checkboxDisplayHUD, m_checkboxDisplayHand, m_checkboxDisplayDeathMessages, m_checkboxDisplayAnimatedCharacter, m_checkboxSplitscreen, m_checkboxShowSplitscreenGamertags, m_checkboxShowClassicCrafting; // Checkboxes
UIControl_CheckBox m_checkboxDisplayHUD, m_checkboxDisplayHand, m_checkboxDisplayDeathMessages, m_checkboxDisplayAnimatedCharacter, m_checkboxSplitscreen, m_checkboxShowSplitscreenGamertags, m_checkboxShowClassicCrafting, m_checkboxHideLoadCreateJoinSaveSizeBar; // Checkboxes
UIControl_Slider m_sliderUISize, m_sliderUISizeSplitscreen; // Sliders
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT( m_checkboxDisplayHUD, "DisplayHUD")
@@ -28,6 +29,7 @@ private:
UI_MAP_ELEMENT( m_checkboxSplitscreen, "Splitscreen")
UI_MAP_ELEMENT( m_checkboxShowSplitscreenGamertags, "ShowSplitscreenGamertags")
UI_MAP_ELEMENT(m_checkboxShowClassicCrafting, "ShowClassicCrafting")
UI_MAP_ELEMENT(m_checkboxHideLoadCreateJoinSaveSizeBar, "LoadCreateJoinSaveSizeBar")
UI_MAP_ELEMENT( m_sliderUISize, "UISize")
UI_MAP_ELEMENT( m_sliderUISizeSplitscreen, "UISizeSplitscreen")
@@ -52,4 +54,4 @@ public:
virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);
virtual void handleSliderMove(F64 sliderId, F64 currentValue);
};
};