chore: format Minecraft.Client

This commit is contained in:
Tropical
2026-03-13 17:10:10 -05:00
parent 33d0737d1d
commit e8424f2000
531 changed files with 67709 additions and 62690 deletions

View File

@@ -3,65 +3,57 @@
#include "../Button.h"
#include "../../../Minecraft.World/Util/StringHelpers.h"
const std::wstring NameEntryScreen::allowedChars = L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_'*!\"#%/()=+?[]{}<>";
const std::wstring NameEntryScreen::allowedChars =
L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "
L",.:-_'*!\"#%/()=+?[]{}<>";
NameEntryScreen::NameEntryScreen(Screen *lastScreen, const std::wstring& oldName, int slot)
{
frame = 0; // 4J added
NameEntryScreen::NameEntryScreen(Screen* lastScreen,
const std::wstring& oldName, int slot) {
frame = 0; // 4J added
this->lastScreen = lastScreen;
this->slot = slot;
this->name = oldName;
if (name==L"-") name = L"";
if (name == L"-") name = L"";
}
void NameEntryScreen::init()
{
void NameEntryScreen::init() {
buttons.clear();
Keyboard::enableRepeatEvents(true);
buttons.push_back(new Button(0, width / 2 - 100, height / 4 + 24 * 5, L"Save"));
buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 6, L"Cancel"));
buttons.push_back(
new Button(0, width / 2 - 100, height / 4 + 24 * 5, L"Save"));
buttons.push_back(
new Button(1, width / 2 - 100, height / 4 + 24 * 6, L"Cancel"));
buttons[0]->active = trimString(name).length() > 1;
}
void NameEntryScreen::removed()
{
Keyboard::enableRepeatEvents(false);
}
void NameEntryScreen::removed() { Keyboard::enableRepeatEvents(false); }
void NameEntryScreen::tick()
{
frame++;
}
void NameEntryScreen::tick() { frame++; }
void NameEntryScreen::buttonClicked(Button button)
{
void NameEntryScreen::buttonClicked(Button button) {
if (!button.active) return;
if (button.id == 0 && trimString(name).length() > 1)
{
if (button.id == 0 && trimString(name).length() > 1) {
minecraft->saveSlot(slot, trimString(name));
minecraft->setScreen(NULL);
// minecraft->grabMouse(); // 4J - removed
// minecraft->grabMouse(); // 4J - removed
}
if (button.id == 1)
{
if (button.id == 1) {
minecraft->setScreen(lastScreen);
}
}
void NameEntryScreen::keyPressed(wchar_t ch, int eventKey)
{
if (eventKey == Keyboard::KEY_BACK && name.length() > 0) name = name.substr(0, name.length() - 1);
if (allowedChars.find(ch) != std::wstring::npos && name.length()<64)
{
void NameEntryScreen::keyPressed(wchar_t ch, int eventKey) {
if (eventKey == Keyboard::KEY_BACK && name.length() > 0)
name = name.substr(0, name.length() - 1);
if (allowedChars.find(ch) != std::wstring::npos && name.length() < 64) {
name += ch;
}
buttons[0]->active = trimString(name).length() > 1;
}
void NameEntryScreen::render(int xm, int ym, float a)
{
void NameEntryScreen::render(int xm, int ym, float a) {
renderBackground();
drawCenteredString(font, title, width / 2, 40, 0xffffff);
@@ -72,7 +64,8 @@ void NameEntryScreen::render(int xm, int ym, float a)
int bh = 20;
fill(bx - 1, by - 1, bx + bw + 1, by + bh + 1, 0xffa0a0a0);
fill(bx, by, bx + bw, by + bh, 0xff000000);
drawString(font, name + (frame / 6 % 2 == 0 ? L"_" : L""), bx + 4, by + (bh - 8) / 2, 0xe0e0e0);
drawString(font, name + (frame / 6 % 2 == 0 ? L"_" : L""), bx + 4,
by + (bh - 8) / 2, 0xe0e0e0);
Screen::render(xm, ym, a);
}