mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-25 18:12:41 +01:00
TU53 + Bug Fixes (Many)
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
This commit is contained in:
1 parent
8de3b79e65
commit
9abd52985e
483 files changed
+15228
-4114
No files matched your search
@@ -57,6 +57,9 @@ void KeyboardMouseInput::Init()
|
||||
m_screenWantsCursorHidden = false;
|
||||
m_charBufferHead = 0;
|
||||
m_charBufferTail = 0;
|
||||
m_bindCapture = false;
|
||||
ResetBinds();
|
||||
LoadBinds();
|
||||
|
||||
RAWINPUTDEVICE rid;
|
||||
rid.usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC
|
||||
@@ -204,8 +207,18 @@ void KeyboardMouseInput::OnRawMouseDelta(int dx, int dy)
|
||||
m_mouseDeltaAccumY += dy;
|
||||
}
|
||||
|
||||
static int MouseButtonForVk(int vkCode)
|
||||
{
|
||||
if (vkCode == VK_LBUTTON) return KeyboardMouseInput::MOUSE_LEFT;
|
||||
if (vkCode == VK_RBUTTON) return KeyboardMouseInput::MOUSE_RIGHT;
|
||||
if (vkCode == VK_MBUTTON) return KeyboardMouseInput::MOUSE_MIDDLE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool KeyboardMouseInput::IsKeyDown(int vkCode) const
|
||||
{
|
||||
if (MouseButtonForVk(vkCode) >= 0)
|
||||
return IsMouseButtonDown(MouseButtonForVk(vkCode));
|
||||
if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
|
||||
return IsModifierKeyDown(m_keyDown, vkCode);
|
||||
|
||||
@@ -216,6 +229,8 @@ bool KeyboardMouseInput::IsKeyDown(int vkCode) const
|
||||
|
||||
bool KeyboardMouseInput::IsKeyPressed(int vkCode) const
|
||||
{
|
||||
if (MouseButtonForVk(vkCode) >= 0)
|
||||
return IsMouseButtonPressed(MouseButtonForVk(vkCode));
|
||||
if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
|
||||
return IsModifierKeyDown(m_keyPressed, vkCode);
|
||||
|
||||
@@ -226,6 +241,8 @@ bool KeyboardMouseInput::IsKeyPressed(int vkCode) const
|
||||
|
||||
bool KeyboardMouseInput::IsKeyReleased(int vkCode) const
|
||||
{
|
||||
if (MouseButtonForVk(vkCode) >= 0)
|
||||
return IsMouseButtonReleased(MouseButtonForVk(vkCode));
|
||||
if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
|
||||
return IsModifierKeyDown(m_keyReleased, vkCode);
|
||||
|
||||
@@ -238,6 +255,8 @@ int KeyboardMouseInput::GetPressedKey() const
|
||||
{
|
||||
for (int i = 0; i < MAX_KEYS; ++i)
|
||||
if (m_keyPressed[i]) return i;
|
||||
if (m_mouseBtnPressed[MOUSE_MIDDLE]) return VK_MBUTTON;
|
||||
if (m_mouseBtnPressed[MOUSE_RIGHT]) return VK_RBUTTON;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -367,19 +386,202 @@ void KeyboardMouseInput::SetWindowFocused(bool focused)
|
||||
float KeyboardMouseInput::GetMoveX() const
|
||||
{
|
||||
float x = 0.0f;
|
||||
if (m_keyDown[KEY_LEFT]) x += 1.0f;
|
||||
if (m_keyDown[KEY_RIGHT]) x -= 1.0f;
|
||||
if (IsBindDown(KB_LEFT)) x += 1.0f;
|
||||
if (IsBindDown(KB_RIGHT)) x -= 1.0f;
|
||||
return x;
|
||||
}
|
||||
|
||||
float KeyboardMouseInput::GetMoveY() const
|
||||
{
|
||||
float y = 0.0f;
|
||||
if (m_keyDown[KEY_FORWARD]) y += 1.0f;
|
||||
if (m_keyDown[KEY_BACKWARD]) y -= 1.0f;
|
||||
if (IsBindDown(KB_FORWARD)) y += 1.0f;
|
||||
if (IsBindDown(KB_BACKWARD)) y -= 1.0f;
|
||||
return y;
|
||||
}
|
||||
|
||||
static const int s_defaultBinds[KeyboardMouseInput::KB_COUNT] =
|
||||
{
|
||||
'W', 'S', 'A', 'D',
|
||||
VK_SPACE, VK_LSHIFT, VK_CONTROL,
|
||||
'E', 'Q', 'C', 'R', 'T',
|
||||
VK_F5, VK_MBUTTON,
|
||||
'1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
VK_F1, VK_F2, VK_F3, VK_F11,
|
||||
};
|
||||
|
||||
static const char* s_bindIds[KeyboardMouseInput::KB_COUNT] =
|
||||
{
|
||||
"forward", "back", "left", "right",
|
||||
"jump", "sneak", "sprint",
|
||||
"inventory", "drop", "crafting", "crafting_alt", "chat",
|
||||
"perspective", "pick_block",
|
||||
"hotbar1", "hotbar2", "hotbar3", "hotbar4", "hotbar5", "hotbar6", "hotbar7", "hotbar8", "hotbar9",
|
||||
"toggle_hud", "screenshot", "debug_info", "fullscreen",
|
||||
};
|
||||
|
||||
int KeyboardMouseInput::GetDefaultBind(int bind)
|
||||
{
|
||||
return (bind >= 0 && bind < KB_COUNT) ? s_defaultBinds[bind] : 0;
|
||||
}
|
||||
|
||||
const char* KeyboardMouseInput::GetBindId(int bind)
|
||||
{
|
||||
return (bind >= 0 && bind < KB_COUNT) ? s_bindIds[bind] : "";
|
||||
}
|
||||
|
||||
void KeyboardMouseInput::SetBind(int bind, int vkCode)
|
||||
{
|
||||
if (bind < 0 || bind >= KB_COUNT || vkCode < 0 || vkCode >= MAX_KEYS)
|
||||
return;
|
||||
if (vkCode == VK_LCONTROL || vkCode == VK_RCONTROL) vkCode = VK_CONTROL;
|
||||
else if (vkCode == VK_LMENU || vkCode == VK_RMENU) vkCode = VK_MENU;
|
||||
m_binds[bind] = vkCode;
|
||||
}
|
||||
|
||||
void KeyboardMouseInput::ResetBinds()
|
||||
{
|
||||
for (int i = 0; i < KB_COUNT; ++i)
|
||||
m_binds[i] = s_defaultBinds[i];
|
||||
}
|
||||
|
||||
static void GetBindsPath(char* out, size_t outLen)
|
||||
{
|
||||
char exePath[MAX_PATH] = {};
|
||||
GetModuleFileNameA(nullptr, exePath, MAX_PATH);
|
||||
char* lastSlash = strrchr(exePath, '\\');
|
||||
if (lastSlash)
|
||||
*(lastSlash + 1) = '\0';
|
||||
_snprintf_s(out, outLen, _TRUNCATE, "%skeybinds.txt", exePath);
|
||||
}
|
||||
|
||||
void KeyboardMouseInput::LoadBinds()
|
||||
{
|
||||
char path[MAX_PATH] = {};
|
||||
GetBindsPath(path, sizeof(path));
|
||||
FILE* f = nullptr;
|
||||
if (fopen_s(&f, path, "r") != 0 || !f)
|
||||
return;
|
||||
char line[128];
|
||||
while (fgets(line, sizeof(line), f))
|
||||
{
|
||||
char* eq = strchr(line, '=');
|
||||
if (!eq)
|
||||
continue;
|
||||
*eq = '\0';
|
||||
int vk = atoi(eq + 1);
|
||||
for (int i = 0; i < KB_COUNT; ++i)
|
||||
{
|
||||
if (strcmp(line, s_bindIds[i]) == 0)
|
||||
{
|
||||
if (vk > 0 && vk < MAX_KEYS)
|
||||
m_binds[i] = vk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void KeyboardMouseInput::SaveBinds() const
|
||||
{
|
||||
char path[MAX_PATH] = {};
|
||||
GetBindsPath(path, sizeof(path));
|
||||
FILE* f = nullptr;
|
||||
if (fopen_s(&f, path, "w") != 0 || !f)
|
||||
return;
|
||||
for (int i = 0; i < KB_COUNT; ++i)
|
||||
fprintf(f, "%s=%d\n", s_bindIds[i], m_binds[i]);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
const wchar_t* KeyboardMouseInput::GetKeyIconName(int vkCode, bool* wide)
|
||||
{
|
||||
static const wchar_t* s_letters[26] =
|
||||
{
|
||||
L"Key_A", L"Key_B", L"Key_C", L"Key_D", L"Key_E", L"Key_F", L"Key_G", L"Key_H", L"Key_I",
|
||||
L"Key_J", L"Key_K", L"Key_L", L"Key_M", L"Key_N", L"Key_O", L"Key_P", L"Key_Q", L"Key_R",
|
||||
L"Key_S", L"Key_T", L"Key_U", L"Key_V", L"Key_W", L"Key_X", L"Key_Y", L"Key_Z",
|
||||
};
|
||||
static const wchar_t* s_digits[10] =
|
||||
{
|
||||
L"Key_0", L"Key_1", L"Key_2", L"Key_3", L"Key_4", L"Key_5", L"Key_6", L"Key_7", L"Key_8", L"Key_9",
|
||||
};
|
||||
static const wchar_t* s_functions[12] =
|
||||
{
|
||||
L"Key_F1", L"Key_F2", L"Key_F3", L"Key_F4", L"Key_F5", L"Key_F6",
|
||||
L"Key_F7", L"Key_F8", L"Key_F9", L"Key_F10", L"Key_F11", L"Key_F12",
|
||||
};
|
||||
|
||||
if (wide)
|
||||
*wide = false;
|
||||
|
||||
if (vkCode >= 'A' && vkCode <= 'Z')
|
||||
return s_letters[vkCode - 'A'];
|
||||
if (vkCode >= '0' && vkCode <= '9')
|
||||
return s_digits[vkCode - '0'];
|
||||
if (vkCode >= VK_F1 && vkCode <= VK_F12)
|
||||
return s_functions[vkCode - VK_F1];
|
||||
|
||||
const wchar_t* wideName = nullptr;
|
||||
switch (vkCode)
|
||||
{
|
||||
case VK_UP: return L"Key_UP";
|
||||
case VK_DOWN: return L"Key_DOWN";
|
||||
case VK_LEFT: return L"Key_LEFT";
|
||||
case VK_RIGHT: return L"Key_RIGHT";
|
||||
case VK_OEM_1: return L"Key_Semicolon";
|
||||
case VK_OEM_PLUS: return L"Key_Equals";
|
||||
case VK_OEM_COMMA: return L"Key_Comma";
|
||||
case VK_OEM_MINUS: return L"Key_Minus";
|
||||
case VK_OEM_PERIOD: return L"Key_Period";
|
||||
case VK_OEM_3: return L"Key_Grave";
|
||||
case VK_OEM_4: return L"Key_LBracket";
|
||||
case VK_OEM_6: return L"Key_RBracket";
|
||||
case VK_OEM_5: return L"Key_Backslash";
|
||||
case VK_OEM_7: return L"Key_Apostrophe";
|
||||
case VK_SPACE: wideName = L"Key_Space"; break;
|
||||
case VK_RETURN: wideName = L"Key_Enter"; break;
|
||||
case VK_ESCAPE: wideName = L"Key_Esc"; break;
|
||||
case VK_TAB: wideName = L"Key_Tab"; break;
|
||||
case VK_BACK: wideName = L"Key_Backspace"; break;
|
||||
case VK_SHIFT: case VK_LSHIFT: case VK_RSHIFT: wideName = L"Key_Shift"; break;
|
||||
case VK_CONTROL: case VK_LCONTROL: case VK_RCONTROL: wideName = L"Key_Ctrl"; break;
|
||||
}
|
||||
if (wideName && wide)
|
||||
*wide = true;
|
||||
return wideName;
|
||||
}
|
||||
|
||||
void KeyboardMouseInput::GetKeyName(int vkCode, wchar_t* out, int outLen)
|
||||
{
|
||||
if (!out || outLen <= 0)
|
||||
return;
|
||||
out[0] = L'\0';
|
||||
switch (vkCode)
|
||||
{
|
||||
case 0: wcsncpy_s(out, outLen, L"None", _TRUNCATE); return;
|
||||
case VK_LBUTTON: wcsncpy_s(out, outLen, L"Left Mouse", _TRUNCATE); return;
|
||||
case VK_RBUTTON: wcsncpy_s(out, outLen, L"Right Mouse", _TRUNCATE); return;
|
||||
case VK_MBUTTON: wcsncpy_s(out, outLen, L"Middle Mouse", _TRUNCATE); return;
|
||||
case VK_CONTROL: wcsncpy_s(out, outLen, L"Ctrl", _TRUNCATE); return;
|
||||
case VK_MENU: wcsncpy_s(out, outLen, L"Alt", _TRUNCATE); return;
|
||||
case VK_SHIFT: wcsncpy_s(out, outLen, L"Shift", _TRUNCATE); return;
|
||||
case VK_LSHIFT: wcsncpy_s(out, outLen, L"Left Shift", _TRUNCATE); return;
|
||||
case VK_RSHIFT: wcsncpy_s(out, outLen, L"Right Shift", _TRUNCATE); return;
|
||||
}
|
||||
UINT scan = MapVirtualKeyW(vkCode, MAPVK_VK_TO_VSC);
|
||||
switch (vkCode)
|
||||
{
|
||||
case VK_LEFT: case VK_RIGHT: case VK_UP: case VK_DOWN:
|
||||
case VK_PRIOR: case VK_NEXT: case VK_END: case VK_HOME:
|
||||
case VK_INSERT: case VK_DELETE: case VK_DIVIDE: case VK_NUMLOCK:
|
||||
scan |= 0x100;
|
||||
break;
|
||||
}
|
||||
if (scan == 0 || GetKeyNameTextW(static_cast<LONG>(scan << 16), out, outLen) == 0)
|
||||
_snwprintf_s(out, outLen, _TRUNCATE, L"Key %d", vkCode);
|
||||
}
|
||||
|
||||
float KeyboardMouseInput::GetLookX(float sensitivity) const
|
||||
{
|
||||
return static_cast<float>(m_mouseDeltaX) * sensitivity;
|
||||
|
||||
Reference in new issue
Block a user