Add files via upload

This commit is contained in:
ethxn 2026-03-19 19:25:51 +08:00 committed by GitHub
parent ecb3f00bd6
commit 2a683c19e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 169 additions and 26 deletions

View file

@ -6,6 +6,7 @@
#include "..\Minecraft.World\SharedConstants.h"
#include "..\Minecraft.World\StringHelpers.h"
#include "..\Minecraft.World\ChatPacket.h"
#include "Windows64\KeyboardMouseInput.h"
const wstring ChatScreen::allowedChars = SharedConstants::acceptableLetters;
vector<wstring> ChatScreen::s_chatHistory;
@ -85,24 +86,27 @@ void ChatScreen::handleHistoryDown()
void ChatScreen::keyPressed(wchar_t ch, int eventKey)
{
if (eventKey == Keyboard::KEY_ESCAPE)
{
{
minecraft->setScreen(nullptr);
return;
}
if (eventKey == Keyboard::KEY_RETURN)
{
{
wstring trim = trimString(message);
if (trim.length() > 0)
{
if (!trim.empty())
{
if (!minecraft->handleClientSideCommand(trim))
{
{
MultiplayerLocalPlayer* mplp = dynamic_cast<MultiplayerLocalPlayer*>(minecraft->player.get());
if (mplp && mplp->connection)
mplp->connection->send(shared_ptr<ChatPacket>(new ChatPacket(trim)));
}
if (s_chatHistory.empty() || s_chatHistory.back() != trim)
{
{
s_chatHistory.push_back(trim);
if (s_chatHistory.size() > CHAT_HISTORY_MAX)
s_chatHistory.erase(s_chatHistory.begin());
@ -111,33 +115,97 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey)
minecraft->setScreen(nullptr);
return;
}
if (eventKey == Keyboard::KEY_UP) { handleHistoryUp(); return; }
if (eventKey == Keyboard::KEY_DOWN) { handleHistoryDown(); return; }
if (eventKey == Keyboard::KEY_LEFT)
{
if (cursorIndex > 0)
{
if (g_KBMInput.IsKeyDown(VK_CONTROL))
{
// move left by word
while (cursorIndex > 0 && iswspace(message[cursorIndex - 1])) cursorIndex--;
while (cursorIndex > 0 && !iswspace(message[cursorIndex - 1])) cursorIndex--;
}
else if (cursorIndex > 0)
{
cursorIndex--;
}
return;
}
if (eventKey == Keyboard::KEY_RIGHT)
{
if (cursorIndex < static_cast<int>(message.length()))
{
int len = static_cast<int>(message.length());
if (g_KBMInput.IsKeyDown(VK_CONTROL))
{
// move right by word
while (cursorIndex < len && !iswspace(message[cursorIndex])) cursorIndex++;
while (cursorIndex < len && iswspace(message[cursorIndex])) cursorIndex++;
}
else if (cursorIndex < len)
{
cursorIndex++;
}
return;
}
// NEEDS IMPLEMENTING (CTRL + BACKSPACE TO DELETE WORD)
if (eventKey == Keyboard::KEY_BACK && cursorIndex > 0)
{
message.erase(cursorIndex - 1, 1);
cursorIndex--;
{
if (g_KBMInput.IsKeyDown(VK_CONTROL))
{
return;
}
else
{
message.erase(cursorIndex - 1, 1);
cursorIndex--;
return;
}
}
// NEEDS IMPLEMENTING (CTRL + A TO SELECT ALL)
if (g_KBMInput.IsKeyDown(VK_CONTROL) && g_KBMInput.IsKeyPressed('A'))
{
return;
}
// NEEDS IMPLEMENTING (SHIFT + LEFT ARROW TO SELECT CHARACTER)
if (g_KBMInput.IsKeyDown(VK_SHIFT) && g_KBMInput.IsKeyPressed(VK_LEFT))
{
return;
}
// NEEDS IMPLEMENTING (SHIFT + RIGHT ARROW TO SELECT CHARACTER)
if (g_KBMInput.IsKeyDown(VK_SHIFT) && g_KBMInput.IsKeyPressed(VK_RIGHT))
{
return;
}
// NEEDS IMPLEMENTING (TAB TO AUTOFILL USERNAMES e.g( et > TAB > ethxnblxd ))
// if theres multiple usernames then make a gui above the chat window and cycle through them by using tab)
if (eventKey == Keyboard::KEY_TAB) // NEEDS FIXING OPENS PLAYERLIST IN CHAT WINDOW
{
return;
}
if (isAllowedChatChar(ch) && static_cast<int>(message.length()) < SharedConstants::maxChatLength)
{
{
message.insert(cursorIndex, 1, ch);
cursorIndex++;
}
}
// NEEDS IMPLEMENTING (BLUE CHARACTER SELECTION RENDERING)
void ChatScreen::render(int xm, int ym, float a)
{
fill(2, height - 14, width - 2, height - 2, 0x80000000);

View file

@ -36,6 +36,8 @@
#include "FrustumCuller.h"
#include "Camera.h"
#include "chrono"
#include "..\Minecraft.World\MobEffect.h"
#include "..\Minecraft.World\Difficulty.h"
#include "..\Minecraft.World\net.minecraft.world.level.h"
@ -1509,10 +1511,42 @@ void Minecraft::run_middle()
}
}
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP))
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_DROP;
static bool wasDown = false;
static std::chrono::steady_clock::time_point pressTime;
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT))
bool down = g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_DROP);
if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP) && g_KBMInput.IsKeyDown(VK_CONTROL))
// TO DROP A STACK
{
localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROPALL;
}
else if (down)
// CHANGED FROM IsKeyPressed SO YOU CAN HOLD TO DROP (after 0.3 sec delay).
{
auto now = std::chrono::steady_clock::now();
if (!wasDown)
{
// first press
localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROP;
pressTime = now;
}
else
{
float held = std::chrono::duration<float>(now - pressTime).count();
if (held > 0.3f)
{
localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROP;
}
}
}
wasDown = down;
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING))
{
if((ui.IsSceneInStack(i, eUIScene_Crafting2x2Menu) || ui.IsSceneInStack(i, eUIScene_Crafting3x3Menu) || ui.IsSceneInStack(i, eUIScene_CreativeMenu) || isClosableByEitherKey) && !isEditing)
{
@ -1524,18 +1558,27 @@ void Minecraft::run_middle()
}
}
for (int slot = 0; slot < 9; slot++)
// PREVENTS SWITCHING HOTBAR SLOTS WHEN IN MENUS
if (!ui.GetMenuDisplayed(0))
{
if (g_KBMInput.IsKeyPressed('1' + slot))
for (int slot = 0; slot < 9; slot++)
{
if (localplayers[i]->inventory)
localplayers[i]->inventory->selected = slot;
if (g_KBMInput.IsKeyPressed('1' + slot))
{
if (localplayers[i]->inventory)
localplayers[i]->inventory->selected = slot;
}
}
}
}
// Utility keys always work regardless of KBM active state
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.GetMenuDisplayed(i))
Minecraft* pMinecraft = Minecraft::GetInstance();
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.GetMenuDisplayed(i) && pMinecraft->screen == NULL)
{
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_PAUSEMENU;
app.DebugPrintf("PAUSE PRESSED (keyboard) - ipad = %d\n",i);
@ -2592,6 +2635,36 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
*piUse=IDS_TOOLTIPS_BLOCK;
break;
// QUICK EQUIP FOR ARMOR (TOOLTIPS ONLY)
// LEATHER
case Item::helmet_leather_Id:
case Item::chestplate_leather_Id:
case Item::leggings_leather_Id:
case Item::boots_leather_Id:
// CHAIN
case Item::helmet_chain_Id:
case Item::chestplate_chain_Id:
case Item::leggings_chain_Id:
case Item::boots_chain_Id:
// IRON
case Item::helmet_iron_Id:
case Item::chestplate_iron_Id:
case Item::leggings_iron_Id:
case Item::boots_iron_Id:
// GOLD
case Item::helmet_gold_Id:
case Item::chestplate_gold_Id:
case Item::leggings_gold_Id:
case Item::boots_gold_Id:
// DIAMOND
case Item::helmet_diamond_Id:
case Item::chestplate_diamond_Id:
case Item::leggings_diamond_Id:
case Item::boots_diamond_Id:
*piUse=IDS_TOOLTIPS_EQUIP;
break;
case Item::bucket_empty_Id:
case Item::glassBottle_Id:
if (bUseItem) *piUse=IDS_TOOLTIPS_COLLECT;
@ -3746,10 +3819,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY))
{
shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->player;
if (!player->isRiding())
{
ui.PlayUISFX(eSFX_Press);
}
ui.PlayUISFX(eSFX_Press);
if(gameMode->isServerControlledInventory())
{
@ -3805,6 +3875,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
player->drop();
}
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROPALL)) && gameMode->isInputAllowed(MINECRAFT_ACTION_DROPALL))
{
player->dropall();
}
uint64_t ullButtonsPressed=player->ullButtonsPressed;
bool selected = false;