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
236 lines
6.5 KiB
C++
236 lines
6.5 KiB
C++
#include "stdafx.h"
|
|
#include "UI.h"
|
|
#include "UIScene_SuperflatPresetsMenu.h"
|
|
#include "SuperflatData.h"
|
|
#include "UICustomStrings.h"
|
|
#include "../../../Minecraft.World/net.minecraft.world.item.h"
|
|
#include "../../../Minecraft.World/net.minecraft.world.level.tile.h"
|
|
#ifdef _WINDOWS64
|
|
#include "../../Windows64/KeyboardMouseInput.h"
|
|
#endif
|
|
|
|
UIScene_SuperflatPresetsMenu::UIScene_SuperflatPresetsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
|
{
|
|
initialiseMovie();
|
|
m_info = static_cast<FlatGeneratorInfo *>(initData);
|
|
m_bNeedsPopulate = true;
|
|
m_bPopulated = false;
|
|
m_bIgnoreInput = false;
|
|
m_iFocusId = eControl_PresetBase;
|
|
m_iPendingPress = -1;
|
|
m_iPendingDelete = -1;
|
|
m_bPendingSaveName = false;
|
|
SuperflatData::LoadCustomPresets();
|
|
m_title.init(UICustomStrings::Lookup(UICustomStrings::Get(L"Presets")));
|
|
m_list.init(eControl_PresetsList);
|
|
m_list.UseIggyIcons();
|
|
}
|
|
|
|
wstring UIScene_SuperflatPresetsMenu::getMoviePath()
|
|
{
|
|
return L"SuperflatPresetsMenu";
|
|
}
|
|
|
|
bool UIScene_SuperflatPresetsMenu::isCustomId(int id)
|
|
{
|
|
return id >= eControl_CustomBase && id < eControl_CustomBase + static_cast<int>(SuperflatData::GetCustomPresets().size());
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::populate()
|
|
{
|
|
m_list.clearList();
|
|
m_list.AddNewItem(L"Save Current as Preset", eControl_Save);
|
|
vector<SuperflatData::CustomPreset> &custom = SuperflatData::GetCustomPresets();
|
|
for (int i = 0; i < static_cast<int>(custom.size()); ++i)
|
|
m_list.AddNewItem(custom[i].name, eControl_CustomBase + i);
|
|
for (int i = 0; i < SuperflatData::GetPresetCount(); ++i)
|
|
m_list.AddNewItem(SuperflatData::GetPresetName(i), eControl_PresetBase + i);
|
|
SetFocusToElement(eControl_PresetsList);
|
|
m_list.setCurrentSelection(0);
|
|
m_iFocusId = eControl_Save;
|
|
m_bPopulated = true;
|
|
updateTooltips();
|
|
}
|
|
|
|
int UIScene_SuperflatPresetsMenu::KeyboardCompleteCallback(LPVOID lpParam, bool bRes)
|
|
{
|
|
UIScene_SuperflatPresetsMenu *pClass = static_cast<UIScene_SuperflatPresetsMenu *>(lpParam);
|
|
pClass->m_bIgnoreInput = false;
|
|
if (bRes)
|
|
{
|
|
uint16_t pchText[128];
|
|
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
|
#ifdef _WINDOWS64
|
|
Win64_GetKeyboardText(pchText, 128);
|
|
#else
|
|
InputManager.GetText(pchText);
|
|
#endif
|
|
pClass->m_pendingName = reinterpret_cast<wchar_t *>(pchText);
|
|
pClass->m_bPendingSaveName = true;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::tick()
|
|
{
|
|
if (m_bNeedsPopulate)
|
|
{
|
|
m_bNeedsPopulate = false;
|
|
populate();
|
|
}
|
|
|
|
if (m_bPendingSaveName)
|
|
{
|
|
m_bPendingSaveName = false;
|
|
wstring name = m_pendingName;
|
|
for (auto &c : name)
|
|
{
|
|
if (c == L'\t' || c == L'\n' || c == L'\r')
|
|
c = L' ';
|
|
}
|
|
while (!name.empty() && name.back() == L' ')
|
|
name.pop_back();
|
|
if (name.empty())
|
|
name = L"Custom Preset " + std::to_wstring(SuperflatData::GetCustomPresets().size() + 1);
|
|
SuperflatData::CustomPreset preset;
|
|
preset.name = name;
|
|
preset.value = m_info->toString();
|
|
SuperflatData::GetCustomPresets().push_back(preset);
|
|
SuperflatData::SaveCustomPresets();
|
|
m_bNeedsPopulate = true;
|
|
}
|
|
|
|
if (m_iPendingDelete >= 0)
|
|
{
|
|
int index = m_iPendingDelete;
|
|
m_iPendingDelete = -1;
|
|
vector<SuperflatData::CustomPreset> &custom = SuperflatData::GetCustomPresets();
|
|
if (index < static_cast<int>(custom.size()))
|
|
{
|
|
custom.erase(custom.begin() + index);
|
|
SuperflatData::SaveCustomPresets();
|
|
m_bNeedsPopulate = true;
|
|
}
|
|
}
|
|
|
|
if (m_iPendingPress >= 0)
|
|
{
|
|
int id = m_iPendingPress;
|
|
m_iPendingPress = -1;
|
|
if (id == eControl_Save)
|
|
{
|
|
m_bIgnoreInput = true;
|
|
UIKeyboardInitData kbData;
|
|
kbData.title = L"Preset Name";
|
|
kbData.defaultText = L"";
|
|
kbData.maxChars = 40;
|
|
kbData.callback = &UIScene_SuperflatPresetsMenu::KeyboardCompleteCallback;
|
|
kbData.lpParam = this;
|
|
#ifdef _WINDOWS64
|
|
kbData.pcMode = g_KBMInput.IsKBMActive();
|
|
#endif
|
|
ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData);
|
|
}
|
|
else if (id >= eControl_PresetBase && id < eControl_PresetBase + SuperflatData::GetPresetCount())
|
|
{
|
|
*m_info = SuperflatData::MakePreset(id - eControl_PresetBase);
|
|
navigateBack();
|
|
return;
|
|
}
|
|
else if (isCustomId(id))
|
|
{
|
|
*m_info = FlatGeneratorInfo::fromValue(SuperflatData::GetCustomPresets()[id - eControl_CustomBase].value);
|
|
navigateBack();
|
|
return;
|
|
}
|
|
}
|
|
|
|
UIScene::tick();
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::updateTooltips()
|
|
{
|
|
int deleteTip = isCustomId(m_iFocusId) ? IDS_TOOLTIPS_DELETE : -1;
|
|
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, deleteTip);
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::updateComponents()
|
|
{
|
|
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true);
|
|
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false);
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::handleGainFocus(bool navBack)
|
|
{
|
|
UIScene::handleGainFocus(navBack);
|
|
if (navBack)
|
|
m_bNeedsPopulate = true;
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::customDraw(IggyCustomDrawCallbackRegion *region)
|
|
{
|
|
int list = -1;
|
|
int id = -1;
|
|
if (swscanf(static_cast<wchar_t *>(region->name), L"slot_%d_%d", &list, &id) != 2)
|
|
return;
|
|
shared_ptr<ItemInstance> item = nullptr;
|
|
if (id >= eControl_PresetBase && id < eControl_PresetBase + SuperflatData::GetPresetCount())
|
|
item = SuperflatData::GetPresetIcon(id - eControl_PresetBase);
|
|
else if (id == eControl_Save)
|
|
item = std::make_shared<ItemInstance>(Tile::crafting_table_Id, 1, 0);
|
|
else if (isCustomId(id))
|
|
item = std::make_shared<ItemInstance>(Item::painting);
|
|
if (item != nullptr)
|
|
customDrawSlotControl(region, m_iPad, item, 1.0f, false, false);
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
|
{
|
|
if (m_bIgnoreInput)
|
|
return;
|
|
|
|
ui.AnimateKeyPress(iPad, key, repeat, pressed, released);
|
|
|
|
switch (key)
|
|
{
|
|
case ACTION_MENU_CANCEL:
|
|
if (pressed)
|
|
navigateBack();
|
|
handled = true;
|
|
break;
|
|
case ACTION_MENU_X:
|
|
if (pressed && !repeat && isCustomId(m_iFocusId))
|
|
{
|
|
ui.PlayUISFX(eSFX_Press);
|
|
m_iPendingDelete = m_iFocusId - eControl_CustomBase;
|
|
}
|
|
handled = true;
|
|
break;
|
|
case ACTION_MENU_OK:
|
|
case ACTION_MENU_UP:
|
|
case ACTION_MENU_DOWN:
|
|
case ACTION_MENU_PAGEUP:
|
|
case ACTION_MENU_PAGEDOWN:
|
|
case ACTION_MENU_OTHER_STICK_UP:
|
|
case ACTION_MENU_OTHER_STICK_DOWN:
|
|
sendInputToMovie(key, repeat, pressed, released);
|
|
handled = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::handlePress(F64 controlId, F64 childId)
|
|
{
|
|
if (!m_bPopulated || m_bIgnoreInput)
|
|
return;
|
|
ui.PlayUISFX(eSFX_Press);
|
|
m_iPendingPress = static_cast<int>(childId);
|
|
}
|
|
|
|
void UIScene_SuperflatPresetsMenu::handleFocusChange(F64 controlId, F64 childId)
|
|
{
|
|
m_iFocusId = static_cast<int>(childId);
|
|
m_list.updateChildFocus(m_iFocusId);
|
|
updateTooltips();
|
|
}
|