mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-25 18:12:41 +01:00
Patch Notes: Blocks + Colored shulker boxes + Concrete powder + Concrete + Glazed terracotta Items + Shulker shell + Iron nugget UI Changes + Added Custom Controls to Keyboard & Mouse, as well as Controller + Added Custom SuperFlat + Added Edit Server Menu + Added Firework Crafting Feature Changes + Host Options + Added Pick Block + Added off-hand slot for maps and arrows. Bug Fixes & changes + TU47: Banner hitbox wrong (and inventory model fixed) + TU47/48: Ice not melting properly + TU48: Dead bushes not dropping sticks + TU48: Guardians and polar bears not dropping cooked fish when on fire + TU48: Bonus chest missing saplings and seeds + TU48: Frosted ice obtainable + TU48: Hoppers not collecting items + TU48: Wither skeletons spawning in 2-high gaps + TU48: End crystals exploding with “TNT Explodes” off + TU48: Tamed ocelots staying hostile + TU48: Signs not placing on tall grass + TU51: Skeleton hitbox wrong + TU53: Fall damage in shallow water + TU53: Squids not spawning in man-made pools + Elytra has been improved to be more accurate to the source material + Removed Spectral Arrow from crafting + Fixed several broken item descriptions + You can no longer cook Pufferfish or Clownfish + Fixed scaling issue with paperdoll and chat + Iron and gold armor can now be smelted into nuggets. + More items can now be used as fuel in a furnace. + Using a firework rocket while gliding with elytra will now give the player a boost. + Changed the color of dyes, wool, carpets, and banners. + Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items. + Fishing rods can now hook on entities without causing knockback or pseudo-damage. + Fixed banner crafting + Fixed Map colors for certain blocks + Fixed Path block height + Fixed String block issues + Fixed Item frame culling. + Fixed Tutorial world NBT/Block State issues + Fixed World Slider + Fixed Enderman AI + Fixed Player animation bug + HUD Flash text changes + Generation accuracy changes + Many other small accuracy changes and fixes
254 lines
6.1 KiB
C++
254 lines
6.1 KiB
C++
#include "stdafx.h"
|
|
#include "UI.h"
|
|
#include "UIScene_EditServerMenu.h"
|
|
#ifdef _WINDOWS64
|
|
#include "../../Windows64/KeyboardMouseInput.h"
|
|
#endif
|
|
|
|
namespace
|
|
{
|
|
const int kNameLimit = 64;
|
|
const int kAddressLimit = 128;
|
|
}
|
|
|
|
UIScene_EditServerMenu::UIScene_EditServerMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
|
{
|
|
initialiseMovie();
|
|
if (initData != nullptr)
|
|
m_data = *static_cast<EditServerInitData *>(initData);
|
|
m_name = m_data.name;
|
|
m_address = m_data.address;
|
|
m_iOKEnabled = -1;
|
|
m_bIgnoreInput = false;
|
|
m_bFinished = false;
|
|
|
|
m_title.init(L"Edit Server Info");
|
|
m_labelName.init(L"Server Name");
|
|
m_labelAddress.init(L"Server Address");
|
|
m_editName.init(m_name, eControl_Name);
|
|
m_editAddress.init(m_address, eControl_Address);
|
|
m_editName.SetCharLimit(kNameLimit);
|
|
m_editAddress.SetCharLimit(kAddressLimit);
|
|
m_buttonCancel.init(app.GetString(IDS_CANCEL), eControl_Cancel);
|
|
m_buttonOK.init(app.GetString(IDS_CONFIRM_OK), eControl_OK);
|
|
}
|
|
|
|
wstring UIScene_EditServerMenu::getMoviePath()
|
|
{
|
|
return L"EditServerMenu";
|
|
}
|
|
|
|
bool UIScene_EditServerMenu::canConfirm()
|
|
{
|
|
wstring address = m_address;
|
|
#ifdef _WINDOWS64
|
|
if (m_editAddress.isDirectEditing())
|
|
address = m_editAddress.getEditBuffer();
|
|
#endif
|
|
for (size_t i = 0; i < address.length(); ++i)
|
|
{
|
|
if (address[i] != L' ')
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void UIScene_EditServerMenu::syncOKButton()
|
|
{
|
|
int enabled = canConfirm() ? 1 : 0;
|
|
if (enabled == m_iOKEnabled)
|
|
return;
|
|
m_iOKEnabled = enabled;
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
value[0].type = IGGY_DATATYPE_boolean;
|
|
value[0].boolval = enabled != 0;
|
|
IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetOKEnabled, 1, value);
|
|
}
|
|
|
|
void UIScene_EditServerMenu::tick()
|
|
{
|
|
UIScene::tick();
|
|
syncOKButton();
|
|
}
|
|
|
|
void UIScene_EditServerMenu::updateTooltips()
|
|
{
|
|
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK);
|
|
}
|
|
|
|
void UIScene_EditServerMenu::updateComponents()
|
|
{
|
|
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true);
|
|
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false);
|
|
}
|
|
|
|
wstring UIScene_EditServerMenu::ReadKeyboardText()
|
|
{
|
|
uint16_t text[256];
|
|
ZeroMemory(text, sizeof(text));
|
|
#ifdef _WINDOWS64
|
|
Win64_GetKeyboardText(text, 256);
|
|
#endif
|
|
wstring result;
|
|
for (int i = 0; i < 255 && text[i]; ++i)
|
|
result += static_cast<wchar_t>(text[i]);
|
|
return result;
|
|
}
|
|
|
|
int UIScene_EditServerMenu::NameKeyboardCallback(LPVOID lpParam, const bool bRes)
|
|
{
|
|
UIScene_EditServerMenu *pClass = static_cast<UIScene_EditServerMenu *>(lpParam);
|
|
pClass->m_bIgnoreInput = false;
|
|
if (bRes)
|
|
{
|
|
pClass->m_name = ReadKeyboardText();
|
|
pClass->m_editName.setLabel(pClass->m_name);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int UIScene_EditServerMenu::AddressKeyboardCallback(LPVOID lpParam, const bool bRes)
|
|
{
|
|
UIScene_EditServerMenu *pClass = static_cast<UIScene_EditServerMenu *>(lpParam);
|
|
pClass->m_bIgnoreInput = false;
|
|
if (bRes)
|
|
{
|
|
pClass->m_address = ReadKeyboardText();
|
|
pClass->m_editAddress.setLabel(pClass->m_address);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void UIScene_EditServerMenu::openKeyboard(int control)
|
|
{
|
|
bool isName = control == eControl_Name;
|
|
UIControl_TextInput &input = isName ? m_editName : m_editAddress;
|
|
int limit = isName ? kNameLimit : kAddressLimit;
|
|
#ifdef _WINDOWS64
|
|
if (g_KBMInput.IsKBMActive())
|
|
{
|
|
input.beginDirectEdit(limit);
|
|
return;
|
|
}
|
|
UIKeyboardInitData kbData;
|
|
kbData.title = isName ? L"Server Name" : L"Server Address";
|
|
kbData.defaultText = isName ? m_name.c_str() : m_address.c_str();
|
|
kbData.maxChars = limit;
|
|
kbData.callback = isName ? &UIScene_EditServerMenu::NameKeyboardCallback : &UIScene_EditServerMenu::AddressKeyboardCallback;
|
|
kbData.lpParam = this;
|
|
kbData.pcMode = false;
|
|
m_bIgnoreInput = true;
|
|
ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData);
|
|
#endif
|
|
}
|
|
|
|
void UIScene_EditServerMenu::finish(bool confirmed)
|
|
{
|
|
if (m_bFinished)
|
|
return;
|
|
if (confirmed && !canConfirm())
|
|
{
|
|
ui.PlayUISFX(eSFX_CraftFail);
|
|
return;
|
|
}
|
|
m_bFinished = true;
|
|
ui.PlayUISFX(eSFX_Press);
|
|
|
|
wstring host = m_address;
|
|
while (!host.empty() && host[0] == L' ')
|
|
host.erase(0, 1);
|
|
while (!host.empty() && host[host.length() - 1] == L' ')
|
|
host.erase(host.length() - 1);
|
|
wstring port = L"25565";
|
|
size_t colon = host.rfind(L':');
|
|
if (colon != wstring::npos && host.find(L':') == colon)
|
|
{
|
|
wstring tail = host.substr(colon + 1);
|
|
host = host.substr(0, colon);
|
|
if (!tail.empty())
|
|
port = tail;
|
|
}
|
|
wstring name = m_name;
|
|
if (name.empty())
|
|
name = L"Minecraft Server";
|
|
|
|
EditServerInitData data = m_data;
|
|
navigateBack();
|
|
if (data.callback != nullptr)
|
|
data.callback(data.lpParam, confirmed, name, host, port);
|
|
}
|
|
|
|
void UIScene_EditServerMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
|
{
|
|
if (m_bIgnoreInput || m_bFinished)
|
|
return;
|
|
#ifdef _WINDOWS64
|
|
if (isDirectEditBlocking())
|
|
{
|
|
handled = true;
|
|
return;
|
|
}
|
|
#endif
|
|
ui.AnimateKeyPress(iPad, key, repeat, pressed, released);
|
|
|
|
switch (key)
|
|
{
|
|
case ACTION_MENU_CANCEL:
|
|
if (pressed)
|
|
finish(false);
|
|
handled = true;
|
|
break;
|
|
case ACTION_MENU_OK:
|
|
case ACTION_MENU_UP:
|
|
case ACTION_MENU_DOWN:
|
|
case ACTION_MENU_LEFT:
|
|
case ACTION_MENU_RIGHT:
|
|
sendInputToMovie(key, repeat, pressed, released);
|
|
handled = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIScene_EditServerMenu::handlePress(F64 controlId, F64 childId)
|
|
{
|
|
if (m_bIgnoreInput || m_bFinished)
|
|
return;
|
|
#ifdef _WINDOWS64
|
|
if (isDirectEditBlocking())
|
|
return;
|
|
#endif
|
|
switch (static_cast<int>(controlId))
|
|
{
|
|
case eControl_Name:
|
|
case eControl_Address:
|
|
ui.PlayUISFX(eSFX_Press);
|
|
openKeyboard(static_cast<int>(controlId));
|
|
break;
|
|
case eControl_Cancel:
|
|
finish(false);
|
|
break;
|
|
case eControl_OK:
|
|
finish(true);
|
|
break;
|
|
}
|
|
}
|
|
|
|
#ifdef _WINDOWS64
|
|
void UIScene_EditServerMenu::getDirectEditInputs(vector<UIControl_TextInput*> &inputs)
|
|
{
|
|
inputs.push_back(&m_editName);
|
|
inputs.push_back(&m_editAddress);
|
|
}
|
|
|
|
void UIScene_EditServerMenu::onDirectEditFinished(UIControl_TextInput *input, UIControl_TextInput::EDirectEditResult result)
|
|
{
|
|
if (result != UIControl_TextInput::eDirectEdit_Confirmed)
|
|
return;
|
|
if (input == &m_editName)
|
|
m_name = input->getEditBuffer();
|
|
else if (input == &m_editAddress)
|
|
m_address = input->getEditBuffer();
|
|
}
|
|
#endif
|