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
663 lines
17 KiB
C++
663 lines
17 KiB
C++
#include "stdafx.h"
|
|
#include "UI.h"
|
|
#include "UIScene_SuperflatEditLayerMenu.h"
|
|
#include "SuperflatData.h"
|
|
#include "UICustomStrings.h"
|
|
#include "../../../Minecraft.World/net.minecraft.world.item.h"
|
|
#ifdef _WINDOWS64
|
|
#include "../../Windows64/KeyboardMouseInput.h"
|
|
#endif
|
|
|
|
namespace
|
|
{
|
|
const float kGridX = 567.0f;
|
|
const float kGridY = 222.0f;
|
|
const float kSlot = 75.0f;
|
|
const float kSliderX = 569.0f;
|
|
const float kSliderY = 620.0f;
|
|
const float kSliderW = 745.0f;
|
|
const float kSliderH = 56.0f;
|
|
const float kOkX = 685.0f;
|
|
const float kOkY = 796.0f;
|
|
const float kOkW = 550.0f;
|
|
const float kOkH = 64.0f;
|
|
const float kPanelX = 510.0f;
|
|
const float kPanelY = 160.0f;
|
|
const float kPanelW = 900.0f;
|
|
const float kPanelH = 720.0f;
|
|
const float kTrackX = 1332.0f;
|
|
const float kTrackY = 222.0f;
|
|
const float kTrackW = 44.0f;
|
|
const float kTrackH = 375.0f;
|
|
const float kThumbTop = 222.0f;
|
|
const float kThumbH = 52.0f;
|
|
const float kThumbRange = kTrackH - kThumbH - (kThumbTop - kTrackY) * 2.0f;
|
|
|
|
bool InRect(F32 x, F32 y, float rx, float ry, float rw, float rh)
|
|
{
|
|
return x >= rx && y >= ry && x < rx + rw && y < ry + rh;
|
|
}
|
|
}
|
|
|
|
UIScene_SuperflatEditLayerMenu::UIScene_SuperflatEditLayerMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer), m_original(1, 0)
|
|
{
|
|
initialiseMovie();
|
|
m_data = static_cast<SuperflatEditLayerInitData *>(initData);
|
|
m_original = layer();
|
|
m_iSelectedBlock = SuperflatData::FindBlock(m_original.getId(), m_original.getData());
|
|
m_iCursorBlock = m_iSelectedBlock < 0 ? 0 : m_iSelectedBlock;
|
|
m_iScrollRow = 0;
|
|
int others = m_data->info->getTotalHeight() - m_original.getHeight();
|
|
m_iMaxHeight = FlatGeneratorInfo::MAX_HEIGHT - others;
|
|
if (m_iMaxHeight < 1)
|
|
m_iMaxHeight = 1;
|
|
m_focus = eFocus_Grid;
|
|
m_bNeedsPopulate = true;
|
|
m_bPopulated = false;
|
|
m_bPendingConfirm = false;
|
|
m_bMouseMode = false;
|
|
m_fMouseX = kGridX + kSlot * 5.0f;
|
|
m_fMouseY = kGridY + kSlot * 2.5f;
|
|
m_iHoverBlock = -1;
|
|
m_iDrag = eDrag_None;
|
|
m_fDragOffset = 0.0f;
|
|
|
|
m_title.init(UICustomStrings::Lookup(UICustomStrings::Get(m_data->insert ? L"Add Layer" : L"Edit Layer")));
|
|
int height = layer().getHeight();
|
|
if (height > m_iMaxHeight)
|
|
height = m_iMaxHeight;
|
|
m_heightSlider.init(heightLabel(height), eControl_Height, 1, m_iMaxHeight, height);
|
|
m_confirmButton.init(app.GetString(IDS_CONFIRM_OK), eControl_Confirm);
|
|
m_heightLabel.init(L"");
|
|
m_typeLabel.init(L"");
|
|
|
|
#ifdef _WINDOWS64
|
|
g_KBMInput.SetScreenCursorHidden(true);
|
|
g_KBMInput.SetCursorHiddenForUI(true);
|
|
#endif
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::handleDestroy()
|
|
{
|
|
#ifdef _WINDOWS64
|
|
g_KBMInput.SetScreenCursorHidden(false);
|
|
g_KBMInput.SetCursorHiddenForUI(false);
|
|
#endif
|
|
}
|
|
|
|
wstring UIScene_SuperflatEditLayerMenu::getMoviePath()
|
|
{
|
|
return L"SuperflatEditLayerMenu";
|
|
}
|
|
|
|
FlatLayerInfo &UIScene_SuperflatEditLayerMenu::layer()
|
|
{
|
|
return (*m_data->info->getLayers())[m_data->layerIndex];
|
|
}
|
|
|
|
wstring UIScene_SuperflatEditLayerMenu::heightLabel(int height)
|
|
{
|
|
return L"Layer Height";
|
|
}
|
|
|
|
int UIScene_SuperflatEditLayerMenu::totalRows()
|
|
{
|
|
return (SuperflatData::GetBlockCount() + kColumns - 1) / kColumns;
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::cancel()
|
|
{
|
|
vector<FlatLayerInfo> &layers = *m_data->info->getLayers();
|
|
if (m_data->insert)
|
|
{
|
|
layers.erase(layers.begin() + m_data->layerIndex);
|
|
}
|
|
else
|
|
{
|
|
layer().setHeight(m_original.getHeight());
|
|
layer().setId(m_original.getId());
|
|
layer().setData(m_original.getData());
|
|
}
|
|
m_data->info->updateLayers();
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::populate()
|
|
{
|
|
m_slotList.addSlots(0, kColumns * kRows);
|
|
updatePreview();
|
|
setCursorBlock(m_iCursorBlock);
|
|
enterGrid();
|
|
m_bPopulated = true;
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::updatePreview()
|
|
{
|
|
FlatLayerInfo &l = layer();
|
|
m_typeLabel.setLabel(SuperflatData::GetBlockName(l.getId(), l.getData()));
|
|
m_heightLabel.setLabel(std::to_wstring(l.getHeight()) + L"x");
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::updateScrollBar()
|
|
{
|
|
int pages = totalRows() - kRows + 1;
|
|
if (pages < 1)
|
|
pages = 1;
|
|
IggyDataValue result;
|
|
IggyDataValue value[2];
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = pages;
|
|
value[1].type = IGGY_DATATYPE_number;
|
|
value[1].number = m_iScrollRow;
|
|
IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetScrollBar, 2, value);
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::setCursorLabel(const wstring &plain)
|
|
{
|
|
wstring label;
|
|
if (!plain.empty())
|
|
{
|
|
wchar_t startTags[64];
|
|
swprintf(startTags, 64, L"<font color=\"#%08x\">", app.GetHTMLColour(eHTMLColor_White));
|
|
label = startTags + plain + L"</font>";
|
|
}
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
value[0].type = IGGY_DATATYPE_string_UTF16;
|
|
value[0].string16.string = (IggyUTF16 *)label.c_str();
|
|
value[0].string16.length = static_cast<S32>(label.length());
|
|
IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetCursorLabel, 1, value);
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::setCursorPos(F32 x, F32 y)
|
|
{
|
|
IggyDataValue result;
|
|
IggyDataValue value[2];
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = x;
|
|
value[1].type = IGGY_DATATYPE_number;
|
|
value[1].number = y;
|
|
IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcSetCursorPos, 2, value);
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::showCursor(bool show)
|
|
{
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
value[0].type = IGGY_DATATYPE_boolean;
|
|
value[0].boolval = show;
|
|
IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcShowCursor, 1, value);
|
|
}
|
|
|
|
static wstring BlockNameAt(int block)
|
|
{
|
|
return SuperflatData::GetBlockName(SuperflatData::GetBlockId(block), SuperflatData::GetBlockData(block));
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::updateCursor()
|
|
{
|
|
if (m_bMouseMode)
|
|
{
|
|
refreshMouseHover();
|
|
return;
|
|
}
|
|
|
|
showCursor(m_focus == eFocus_Grid);
|
|
if (m_focus != eFocus_Grid)
|
|
{
|
|
m_slotList.setHighlightSlot(-1);
|
|
return;
|
|
}
|
|
|
|
int visible = m_iCursorBlock - m_iScrollRow * kColumns;
|
|
int col = visible % kColumns;
|
|
int row = visible / kColumns;
|
|
setCursorPos(kGridX + col * kSlot + kSlot * 0.5f, kGridY + row * kSlot + kSlot * 0.5f);
|
|
setCursorLabel(BlockNameAt(m_iCursorBlock));
|
|
m_slotList.setHighlightSlot(visible);
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::refreshMouseHover()
|
|
{
|
|
showCursor(true);
|
|
setCursorPos(m_fMouseX, m_fMouseY);
|
|
int block = slotAt(m_fMouseX, m_fMouseY);
|
|
m_iHoverBlock = block;
|
|
if (block >= 0)
|
|
{
|
|
m_iCursorBlock = block;
|
|
m_slotList.setHighlightSlot(block - m_iScrollRow * kColumns);
|
|
setCursorLabel(BlockNameAt(block));
|
|
}
|
|
else
|
|
{
|
|
m_slotList.setHighlightSlot(-1);
|
|
setCursorLabel(L"");
|
|
}
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::leaveMouseMode()
|
|
{
|
|
if (!m_bMouseMode)
|
|
return;
|
|
m_bMouseMode = false;
|
|
if (m_focus == eFocus_Grid)
|
|
setCursorBlock(m_iCursorBlock);
|
|
else
|
|
updateCursor();
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::setCursorBlock(int block)
|
|
{
|
|
int count = SuperflatData::GetBlockCount();
|
|
if (block < 0)
|
|
block = 0;
|
|
if (block >= count)
|
|
block = count - 1;
|
|
m_iCursorBlock = block;
|
|
int row = block / kColumns;
|
|
if (row < m_iScrollRow)
|
|
m_iScrollRow = row;
|
|
if (row >= m_iScrollRow + kRows)
|
|
m_iScrollRow = row - kRows + 1;
|
|
int maxScroll = totalRows() - kRows;
|
|
if (maxScroll < 0)
|
|
maxScroll = 0;
|
|
if (m_iScrollRow > maxScroll)
|
|
m_iScrollRow = maxScroll;
|
|
if (m_iScrollRow < 0)
|
|
m_iScrollRow = 0;
|
|
updateScrollBar();
|
|
updateCursor();
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::selectBlock(int block)
|
|
{
|
|
if (block < 0 || block >= SuperflatData::GetBlockCount())
|
|
return;
|
|
ui.PlayUISFX(eSFX_Press);
|
|
m_iSelectedBlock = block;
|
|
layer().setId(SuperflatData::GetBlockId(block));
|
|
layer().setData(SuperflatData::GetBlockData(block));
|
|
m_data->info->updateLayers();
|
|
updatePreview();
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::enterGrid()
|
|
{
|
|
m_focus = eFocus_Grid;
|
|
IggyPlayerSetFocusRS(getMovie(), nullptr, 0);
|
|
updateCursor();
|
|
updateTooltips();
|
|
}
|
|
|
|
int UIScene_SuperflatEditLayerMenu::maxScrollRow()
|
|
{
|
|
int maxScroll = totalRows() - kRows;
|
|
return maxScroll < 0 ? 0 : maxScroll;
|
|
}
|
|
|
|
float UIScene_SuperflatEditLayerMenu::thumbPos()
|
|
{
|
|
int maxScroll = maxScrollRow();
|
|
if (maxScroll <= 0)
|
|
return kThumbTop;
|
|
return kThumbTop + kThumbRange * (static_cast<float>(m_iScrollRow) / static_cast<float>(maxScroll));
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::setScrollRow(int row)
|
|
{
|
|
int maxScroll = maxScrollRow();
|
|
if (row < 0) row = 0;
|
|
if (row > maxScroll) row = maxScroll;
|
|
if (row == m_iScrollRow)
|
|
return;
|
|
m_iScrollRow = row;
|
|
updateScrollBar();
|
|
if (m_bMouseMode)
|
|
refreshMouseHover();
|
|
else
|
|
updateCursor();
|
|
}
|
|
|
|
int UIScene_SuperflatEditLayerMenu::slotAt(F32 x, F32 y)
|
|
{
|
|
if (x < kGridX || y < kGridY || x >= kGridX + kSlot * kColumns || y >= kGridY + kSlot * kRows)
|
|
return -1;
|
|
int col = static_cast<int>((x - kGridX) / kSlot);
|
|
int row = static_cast<int>((y - kGridY) / kSlot);
|
|
int block = (m_iScrollRow + row) * kColumns + col;
|
|
if (block >= SuperflatData::GetBlockCount())
|
|
return -1;
|
|
return block;
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::tick()
|
|
{
|
|
if (m_bNeedsPopulate)
|
|
{
|
|
m_bNeedsPopulate = false;
|
|
populate();
|
|
}
|
|
|
|
if (m_bPendingConfirm)
|
|
{
|
|
m_bPendingConfirm = false;
|
|
m_data->info->updateLayers();
|
|
navigateBack();
|
|
return;
|
|
}
|
|
|
|
#ifdef _WINDOWS64
|
|
if (m_bPopulated && hasFocus(m_iPad) && g_KBMInput.IsKBMActive() && !g_KBMInput.IsMouseGrabbed())
|
|
{
|
|
int dx = g_KBMInput.GetMouseDeltaX();
|
|
int dy = g_KBMInput.GetMouseDeltaY();
|
|
bool leftPressed = g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT);
|
|
bool leftDown = g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT);
|
|
int wheel = g_KBMInput.GetMouseWheel();
|
|
|
|
if (dx != 0 || dy != 0)
|
|
{
|
|
extern HWND g_hWnd;
|
|
RECT rc;
|
|
GetClientRect(g_hWnd, &rc);
|
|
int winW = rc.right - rc.left;
|
|
int winH = rc.bottom - rc.top;
|
|
float scaleX = 1.0f;
|
|
float scaleY = 1.0f;
|
|
if (winW > 0 && winH > 0)
|
|
{
|
|
scaleX = static_cast<float>(getRenderWidth()) / static_cast<float>(winW);
|
|
scaleY = static_cast<float>(getRenderHeight()) / static_cast<float>(winH);
|
|
}
|
|
m_fMouseX += dx * scaleX;
|
|
m_fMouseY += dy * scaleY;
|
|
if (m_fMouseX < kPanelX) m_fMouseX = kPanelX;
|
|
if (m_fMouseY < kPanelY) m_fMouseY = kPanelY;
|
|
if (m_fMouseX > kPanelX + kPanelW) m_fMouseX = kPanelX + kPanelW;
|
|
if (m_fMouseY > kPanelY + kPanelH) m_fMouseY = kPanelY + kPanelH;
|
|
m_bMouseMode = true;
|
|
if (slotAt(m_fMouseX, m_fMouseY) >= 0 && m_focus != eFocus_Grid)
|
|
{
|
|
m_focus = eFocus_Grid;
|
|
IggyPlayerSetFocusRS(getMovie(), nullptr, 0);
|
|
}
|
|
else if (InRect(m_fMouseX, m_fMouseY, kSliderX, kSliderY, kSliderW, kSliderH) && m_focus != eFocus_Slider)
|
|
{
|
|
SetFocusToElement(eControl_Height);
|
|
}
|
|
else if (InRect(m_fMouseX, m_fMouseY, kOkX, kOkY, kOkW, kOkH) && m_focus != eFocus_Button)
|
|
{
|
|
SetFocusToElement(eControl_Confirm);
|
|
}
|
|
refreshMouseHover();
|
|
}
|
|
|
|
if (wheel != 0 && m_bMouseMode)
|
|
{
|
|
setScrollRow(m_iScrollRow + (wheel > 0 ? -1 : 1));
|
|
}
|
|
|
|
if (!leftDown)
|
|
m_iDrag = eDrag_None;
|
|
|
|
if (m_bMouseMode && leftPressed)
|
|
{
|
|
int block = slotAt(m_fMouseX, m_fMouseY);
|
|
if (block >= 0)
|
|
{
|
|
selectBlock(block);
|
|
}
|
|
else if (InRect(m_fMouseX, m_fMouseY, kSliderX, kSliderY, kSliderW, kSliderH))
|
|
{
|
|
m_iDrag = eDrag_Slider;
|
|
}
|
|
else if (InRect(m_fMouseX, m_fMouseY, kTrackX, kTrackY, kTrackW, kTrackH))
|
|
{
|
|
float thumbY = thumbPos();
|
|
if (m_fMouseY >= thumbY && m_fMouseY < thumbY + kThumbH)
|
|
m_fDragOffset = m_fMouseY - thumbY;
|
|
else
|
|
m_fDragOffset = kThumbH * 0.5f;
|
|
m_iDrag = eDrag_Scroll;
|
|
}
|
|
else if (InRect(m_fMouseX, m_fMouseY, kOkX, kOkY, kOkW, kOkH))
|
|
{
|
|
ui.PlayUISFX(eSFX_Press);
|
|
m_bPendingConfirm = true;
|
|
}
|
|
}
|
|
|
|
if (m_bMouseMode && leftDown && m_iDrag == eDrag_Slider)
|
|
{
|
|
float t = (m_fMouseX - kSliderX) / kSliderW;
|
|
if (t < 0.0f) t = 0.0f;
|
|
if (t > 1.0f) t = 1.0f;
|
|
int value = static_cast<int>(floorf((m_iMaxHeight - 1) * t + (t > 0.0f ? 1.0f : 0.0f) + 0.5f));
|
|
if (value < 1)
|
|
value = 1;
|
|
if (value > m_iMaxHeight)
|
|
value = m_iMaxHeight;
|
|
if (value != layer().getHeight())
|
|
m_heightSlider.SetSliderTouchPos(t);
|
|
}
|
|
|
|
if (m_bMouseMode && leftDown && m_iDrag == eDrag_Scroll)
|
|
{
|
|
int maxScroll = maxScrollRow();
|
|
if (maxScroll > 0 && kThumbRange > 0.0f)
|
|
{
|
|
float t = (m_fMouseY - m_fDragOffset - kThumbTop) / kThumbRange;
|
|
if (t < 0.0f) t = 0.0f;
|
|
if (t > 1.0f) t = 1.0f;
|
|
int row = static_cast<int>(floorf(t * maxScroll + 0.5f));
|
|
if (row != m_iScrollRow)
|
|
setScrollRow(row);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
UIScene::tick();
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::updateTooltips()
|
|
{
|
|
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_CANCEL);
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::updateComponents()
|
|
{
|
|
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true);
|
|
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false);
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::customDraw(IggyCustomDrawCallbackRegion *region)
|
|
{
|
|
shared_ptr<ItemInstance> item = nullptr;
|
|
int list = -1;
|
|
int index = -1;
|
|
if (swscanf(static_cast<wchar_t *>(region->name), L"layerslot_%d", &index) == 1)
|
|
{
|
|
item = SuperflatData::GetBlockIcon(layer().getId(), layer().getData());
|
|
}
|
|
else if (swscanf(static_cast<wchar_t *>(region->name), L"slot_%d", &index) == 1)
|
|
{
|
|
int block = m_iScrollRow * kColumns + index;
|
|
if (block >= 0 && block < SuperflatData::GetBlockCount())
|
|
item = SuperflatData::GetBlockIcon(SuperflatData::GetBlockId(block), SuperflatData::GetBlockData(block));
|
|
}
|
|
if (item != nullptr)
|
|
customDrawSlotControl(region, m_iPad, item, 1.0f, false, false);
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
|
{
|
|
ui.AnimateKeyPress(iPad, key, repeat, pressed, released);
|
|
|
|
if (key == ACTION_MENU_CANCEL)
|
|
{
|
|
if (pressed)
|
|
{
|
|
cancel();
|
|
navigateBack();
|
|
}
|
|
handled = true;
|
|
return;
|
|
}
|
|
|
|
if (pressed && (key == ACTION_MENU_LEFT || key == ACTION_MENU_RIGHT || key == ACTION_MENU_UP || key == ACTION_MENU_DOWN))
|
|
leaveMouseMode();
|
|
|
|
if (m_focus == eFocus_Grid)
|
|
{
|
|
if (!pressed)
|
|
{
|
|
handled = true;
|
|
return;
|
|
}
|
|
int col = m_iCursorBlock % kColumns;
|
|
switch (key)
|
|
{
|
|
case ACTION_MENU_LEFT:
|
|
if (col > 0)
|
|
{
|
|
ui.PlayUISFX(eSFX_Focus);
|
|
setCursorBlock(m_iCursorBlock - 1);
|
|
}
|
|
break;
|
|
case ACTION_MENU_RIGHT:
|
|
if (col < kColumns - 1 && m_iCursorBlock + 1 < SuperflatData::GetBlockCount())
|
|
{
|
|
ui.PlayUISFX(eSFX_Focus);
|
|
setCursorBlock(m_iCursorBlock + 1);
|
|
}
|
|
break;
|
|
case ACTION_MENU_UP:
|
|
if (m_iCursorBlock >= kColumns)
|
|
{
|
|
ui.PlayUISFX(eSFX_Focus);
|
|
setCursorBlock(m_iCursorBlock - kColumns);
|
|
}
|
|
break;
|
|
case ACTION_MENU_DOWN:
|
|
ui.PlayUISFX(eSFX_Focus);
|
|
if (m_iCursorBlock / kColumns < totalRows() - 1)
|
|
{
|
|
setCursorBlock(m_iCursorBlock + kColumns);
|
|
}
|
|
else
|
|
{
|
|
m_focus = eFocus_Slider;
|
|
updateCursor();
|
|
SetFocusToElement(eControl_Height);
|
|
}
|
|
break;
|
|
case ACTION_MENU_PAGEUP:
|
|
case ACTION_MENU_OTHER_STICK_UP:
|
|
if (!m_bMouseMode)
|
|
setCursorBlock(m_iCursorBlock - kColumns * kRows);
|
|
break;
|
|
case ACTION_MENU_PAGEDOWN:
|
|
case ACTION_MENU_OTHER_STICK_DOWN:
|
|
if (!m_bMouseMode)
|
|
setCursorBlock(m_iCursorBlock + kColumns * kRows);
|
|
break;
|
|
case ACTION_MENU_OK:
|
|
if (m_bMouseMode)
|
|
{
|
|
if (m_iHoverBlock >= 0)
|
|
selectBlock(m_iHoverBlock);
|
|
}
|
|
else
|
|
{
|
|
selectBlock(m_iCursorBlock);
|
|
}
|
|
break;
|
|
}
|
|
handled = true;
|
|
return;
|
|
}
|
|
|
|
switch (key)
|
|
{
|
|
case ACTION_MENU_UP:
|
|
if (m_focus == eFocus_Slider)
|
|
{
|
|
if (pressed)
|
|
{
|
|
ui.PlayUISFX(eSFX_Focus);
|
|
enterGrid();
|
|
}
|
|
handled = true;
|
|
return;
|
|
}
|
|
sendInputToMovie(key, repeat, pressed, released);
|
|
handled = true;
|
|
break;
|
|
case ACTION_MENU_OK:
|
|
case ACTION_MENU_DOWN:
|
|
case ACTION_MENU_LEFT:
|
|
case ACTION_MENU_RIGHT:
|
|
sendInputToMovie(key, repeat, pressed, released);
|
|
handled = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::handlePress(F64 controlId, F64 childId)
|
|
{
|
|
if (!m_bPopulated)
|
|
return;
|
|
if (static_cast<int>(controlId) == eControl_Confirm)
|
|
{
|
|
ui.PlayUISFX(eSFX_Press);
|
|
m_bPendingConfirm = true;
|
|
}
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::handleFocusChange(F64 controlId, F64 childId)
|
|
{
|
|
int id = static_cast<int>(controlId);
|
|
if (id == eControl_Height)
|
|
m_focus = eFocus_Slider;
|
|
else if (id == eControl_Confirm)
|
|
m_focus = eFocus_Button;
|
|
else
|
|
return;
|
|
updateCursor();
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::handleSliderMove(F64 sliderId, F64 currentValue)
|
|
{
|
|
if (static_cast<int>(sliderId) != eControl_Height)
|
|
return;
|
|
int value = static_cast<int>(currentValue);
|
|
if (value < 1)
|
|
value = 1;
|
|
if (value > m_iMaxHeight)
|
|
value = m_iMaxHeight;
|
|
m_heightSlider.handleSliderMove(value);
|
|
m_heightSlider.setLabel(heightLabel(value));
|
|
layer().setHeight(value);
|
|
m_data->info->updateLayers();
|
|
if (m_bPopulated)
|
|
updatePreview();
|
|
}
|
|
|
|
#ifdef _WINDOWS64
|
|
bool UIScene_SuperflatEditLayerMenu::canMoveSlider(F64 sliderId)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool UIScene_SuperflatEditLayerMenu::handleMouseClick(F32 x, F32 y)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void UIScene_SuperflatEditLayerMenu::handleMouseHover(F32 x, F32 y)
|
|
{
|
|
}
|
|
#endif
|