GUI: Rename some methods, start to implement new one

This commit is contained in:
Er2
2023-12-09 19:44:25 +03:00
parent 5e311cbbb3
commit b6bf9d616a
76 changed files with 883 additions and 263 deletions

View File

@@ -22,7 +22,7 @@ void ChatScreen::buttonClicked(Button* pButton)
sendMessageAndExit();
}
void ChatScreen::init()
void ChatScreen::onInit()
{
m_btnSend.m_height = 20;
m_btnSend.m_width = 40;
@@ -34,7 +34,7 @@ void ChatScreen::init()
m_btnSend.m_xPos = m_textChat.m_xPos + m_textChat.m_width;
// set focus directly on the chat text box
m_textChat.init(m_pFont);
m_textChat.onInit(m_pFont);
m_textChat.setFocused(true);
m_buttons.push_back(&m_btnSend);
@@ -47,14 +47,14 @@ void ChatScreen::removed()
m_pMinecraft->m_pGui->m_bRenderChatMessages = true;
}
void ChatScreen::render(int mouseX, int mouseY, float f)
void ChatScreen::onRender(int mouseX, int mouseY, float f)
{
renderBackground();
// override the default behavior of rendering chat messages
m_pMinecraft->m_pGui->m_bRenderChatMessages = true;
Screen::render(mouseX, mouseY, f);
Screen::onRender(mouseX, mouseY, f);
}
void ChatScreen::keyPressed(int keyCode)

View File

@@ -15,9 +15,9 @@ class ChatScreen : public Screen
public:
ChatScreen(bool slash = false);
void buttonClicked(Button*) override;
void init() override;
void onInit() override;
void removed() override;
void render(int mouseX, int mouseY, float f) override;
void onRender(int mouseX, int mouseY, float f) override;
void keyPressed(int keyCode) override;
void sendMessageAndExit();

View File

@@ -43,7 +43,7 @@ bool ConfirmScreen::handleBackEvent(bool b)
return true;
}
void ConfirmScreen::init()
void ConfirmScreen::onInit()
{
m_btnOK.m_xPos = m_width / 2 - 4 - 120;
m_btnCancel.m_xPos = m_width / 2 + 4;
@@ -59,12 +59,12 @@ void ConfirmScreen::init()
m_buttonTabList.push_back(&m_btnCancel);
}
void ConfirmScreen::render(int mouseX, int mouseY, float f)
void ConfirmScreen::onRender(int mouseX, int mouseY, float f)
{
renderBackground();
drawCenteredString(m_pFont, m_textLine1, m_width / 2, 50, 0xFFFFFF);
drawCenteredString(m_pFont, m_textLine2, m_width / 2, 70, 0xFFFFFF);
Screen::render(mouseX, mouseY, f);
Screen::onRender(mouseX, mouseY, f);
}
void ConfirmScreen::postResult(bool b)

View File

@@ -19,8 +19,8 @@ public:
void buttonClicked(Button* pButton) override;
bool handleBackEvent(bool b) override;
void init() override;
void render(int mouseX, int mouseY, float f) override;
void onInit() override;
void onRender(int mouseX, int mouseY, float f) override;
virtual void postResult(bool b);

View File

@@ -21,7 +21,7 @@ CreateWorldScreen::CreateWorldScreen() :
#define CRAMPED() (100 + 32 + 58 > m_height)
void CreateWorldScreen::init()
void CreateWorldScreen::onInit()
{
m_textName.m_width = m_textSeed.m_width = 200;
m_textName.m_height = m_textSeed.m_height = 20;
@@ -43,8 +43,8 @@ void CreateWorldScreen::init()
m_buttons.push_back(&m_btnCreate);
m_buttonTabList.push_back(&m_btnBack);
m_buttonTabList.push_back(&m_btnCreate);
m_textName.init(m_pFont);
m_textSeed.init(m_pFont);
m_textName.onInit(m_pFont);
m_textSeed.onInit(m_pFont);
// 100 - yPos of textSeed
// 32 - offset + height of "Leave blank for random" text
@@ -124,10 +124,10 @@ void CreateWorldScreen::buttonClicked(Button* pButton)
}
}
void CreateWorldScreen::render(int mouseX, int mouseY, float f)
void CreateWorldScreen::onRender(int mouseX, int mouseY, float f)
{
renderBackground();
Screen::render(mouseX, mouseY, f);
Screen::onRender(mouseX, mouseY, f);
drawCenteredString(m_pFont, "Create New World", m_width / 2, CRAMPED() ? 10 : 30, 0xFFFFFF);
drawString(m_pFont, "World name", m_textName.m_xPos, m_textName.m_yPos - 10, 0xDDDDDD);

View File

@@ -17,9 +17,9 @@ class CreateWorldScreen : public Screen
public:
CreateWorldScreen();
void init() override;
void onInit() override;
void buttonClicked(Button* pButton) override;
void render(int mouseX, int mouseY, float f) override;
void onRender(int mouseX, int mouseY, float f) override;
public:
TextInputBox m_textName;

View File

@@ -7,7 +7,7 @@ DeathScreen::DeathScreen() :
m_tickCounter = 0;
}
void DeathScreen::init()
void DeathScreen::onInit()
{
m_btnRespawn.m_width = m_btnTitle.m_width = m_width / 4;
m_btnRespawn.m_xPos = m_width / 2 - 10 - m_btnRespawn.m_width;
@@ -34,7 +34,7 @@ void DeathScreen::buttonClicked(Button* pButton)
}
}
void DeathScreen::tick()
void DeathScreen::onTick()
{
m_tickCounter++;
}
@@ -43,7 +43,7 @@ void DeathScreen::keyPressed(int key)
{
}
void DeathScreen::render(int x, int y, float f)
void DeathScreen::onRender(int x, int y, float f)
{
fillGradient(0, 0, m_width, m_height, 0xA0303080, 0x60000050);
@@ -54,5 +54,5 @@ void DeathScreen::render(int x, int y, float f)
// render the buttons after 1.5 seconds
if (m_tickCounter >= 30)
Screen::render(x, y, f);
Screen::onRender(x, y, f);
}

View File

@@ -15,11 +15,11 @@ class DeathScreen : public Screen
public:
DeathScreen();
virtual void init() override;
virtual void onInit() override;
virtual void buttonClicked(Button* pButton) override;
virtual void tick() override;
virtual void onTick() override;
virtual void keyPressed(int key) override;
virtual void render(int x, int y, float f) override;
virtual void onRender(int x, int y, float f) override;
private:
int m_tickCounter;

View File

@@ -17,7 +17,7 @@ DirectConnectScreen::DirectConnectScreen() :
m_btnJoin(2, "Connect")
{}
void DirectConnectScreen::init()
void DirectConnectScreen::onInit()
{
m_textAddress.m_width = 200;
m_textAddress.m_height = 20;
@@ -41,13 +41,13 @@ void DirectConnectScreen::init()
m_buttons.push_back(&m_btnQuit);
m_buttons.push_back(&m_btnJoin);
m_textAddress.init(m_pFont);
m_textAddress.onInit(m_pFont);
}
void DirectConnectScreen::render(int x, int y, float f)
void DirectConnectScreen::onRender(int x, int y, float f)
{
renderBackground();
Screen::render(x, y, f);
Screen::onRender(x, y, f);
drawCenteredString(m_pFont, "Play Multiplayer", m_width / 2, 30, 0xFFFFFF);
drawCenteredString(m_pFont, "Enter the IP address of a server to connect to it:", m_width / 2, m_textAddress.m_yPos - 20, 0x999999);

View File

@@ -15,12 +15,12 @@ class DirectConnectScreen : public Screen
public:
DirectConnectScreen();
virtual void init() override;
virtual void onInit() override;
virtual void buttonClicked(Button* pButton) override;
virtual void render(int x, int y, float f) override;
virtual void onRender(int x, int y, float f) override;
private:
TextInputBox m_textAddress;
Button m_btnQuit;
Button m_btnJoin;
};
};

View File

@@ -67,7 +67,7 @@ bool IngameBlockSelectionScreen::isAllowed(int slot)
return slot >= 0 && slot < getInventory()->getNumSlots();
}
void IngameBlockSelectionScreen::init()
void IngameBlockSelectionScreen::onInit()
{
Inventory* pInv = getInventory();
@@ -131,9 +131,9 @@ void IngameBlockSelectionScreen::renderDemoOverlay()
drawCenteredString(m_pMinecraft->m_pFont, g_sNotAvailableInDemoVersion, x, y, 0xFFFFFFFF);
}
void IngameBlockSelectionScreen::render(int x, int y, float f)
void IngameBlockSelectionScreen::onRender(int x, int y, float f)
{
Screen::render(x, y, f);
Screen::onRender(x, y, f);
glDisable(GL_DEPTH_TEST);
fill(0, 0, m_width, m_height, 0x80000000);

View File

@@ -29,8 +29,8 @@ public:
void renderSlot(int index, int x, int y, float f);
void selectSlotAndClose();
virtual void init() override;
virtual void render(int x, int y, float f) override;
virtual void onInit() override;
virtual void onRender(int x, int y, float f) override;
virtual void mouseClicked(int x, int y, int type) override;
virtual void mouseReleased(int x, int y, int type) override;
virtual void removed() override;

View File

@@ -32,7 +32,7 @@ void InvalidLicenseScreen::buttonClicked(Button* pButton)
}
}
void InvalidLicenseScreen::init()
void InvalidLicenseScreen::onInit()
{
field_E4 = m_height / 3;
if (m_bHasQuitButton)
@@ -57,14 +57,10 @@ void InvalidLicenseScreen::init()
m_buttonTabList.push_back(&m_btnBuy);
}
void InvalidLicenseScreen::tick()
{
}
void InvalidLicenseScreen::render(int mouseX, int mouseY, float f)
void InvalidLicenseScreen::onRender(int mouseX, int mouseY, float f)
{
renderDirtBackground(0);
drawCenteredString(m_pMinecraft->m_pFont, m_textLine1, m_width / 2, field_E4, 0xFFFFFF);
drawCenteredString(m_pMinecraft->m_pFont, m_textLine2, m_width / 2, field_E4 + 24, 0xFFFFFF);
Screen::render(mouseX, mouseY, f);
Screen::onRender(mouseX, mouseY, f);
}

View File

@@ -15,9 +15,8 @@ class InvalidLicenseScreen : public Screen
public:
InvalidLicenseScreen(int error, bool bHasQuitButton);
void buttonClicked(Button* pButton) override;
void init() override;
void tick() override;
void render(int mouseX, int mouseY, float f) override;
void onInit() override;
void onRender(int mouseX, int mouseY, float f) override;
private:
int m_error;

View File

@@ -61,7 +61,7 @@ bool JoinGameScreen::handleBackEvent(bool b)
return true;
}
void JoinGameScreen::init()
void JoinGameScreen::onInit()
{
const int BUTTON_WIDTH = 100;
@@ -92,16 +92,16 @@ bool JoinGameScreen::isInGameScreen()
return false;
}
void JoinGameScreen::render(int mouseX, int mouseY, float f)
void JoinGameScreen::onRender(int mouseX, int mouseY, float f)
{
renderBackground();
m_pAvailableGamesList->render(mouseX, mouseY, f);
Screen::render(mouseX, mouseY, f);
m_pAvailableGamesList->onRender(mouseX, mouseY, f);
Screen::onRender(mouseX, mouseY, f);
drawCenteredString(m_pMinecraft->m_pFont, "Scanning for Games...", m_width / 2, 8, 0xFFFFFFFF);
}
void JoinGameScreen::tick()
void JoinGameScreen::onTick()
{
std::vector<PingedCompatibleServer> *serverList, serverListFiltered;
serverList = m_pMinecraft->m_pRakNetInstance->getServerList();

View File

@@ -18,10 +18,10 @@ public:
~JoinGameScreen();
void buttonClicked(Button* pButton) override;
bool handleBackEvent(bool b) override;
void init() override;
void onInit() override;
bool isInGameScreen() override;
void render(int mouseX, int mouseY, float f) override;
void tick() override;
void onRender(int mouseX, int mouseY, float f) override;
void onTick() override;
virtual bool isIndexValid(int idx);

View File

@@ -23,7 +23,7 @@ OptionsScreen::~OptionsScreen()
SAFE_DELETE(m_pList);
}
void OptionsScreen::init()
void OptionsScreen::onInit()
{
if (m_pList)
SAFE_DELETE(m_pList);
@@ -41,14 +41,14 @@ void OptionsScreen::init()
m_buttonTabList.push_back(&m_backButton);
}
void OptionsScreen::render(int mouseX, int mouseY, float f)
void OptionsScreen::onRender(int mouseX, int mouseY, float f)
{
if (!m_pList)
return;
m_pList->render(mouseX, mouseY, f);
m_pList->onRender(mouseX, mouseY, f);
Screen::render(mouseX, mouseY, f);
Screen::onRender(mouseX, mouseY, f);
drawCenteredString(m_pFont, "Options", m_width / 2, 10, 0xFFFFFF);
}
@@ -275,7 +275,7 @@ void OptionsScreen::init()
#endif
}
void OptionsScreen::render(int a, int b, float c)
void OptionsScreen::onRender(int a, int b, float c)
{
if (!m_pMinecraft->isLevelGenerated())
renderMenuBackground(c);
@@ -290,7 +290,7 @@ void OptionsScreen::render(int a, int b, float c)
#ifndef ORIGINAL_CODE
drawCenteredString(m_pFont, "Options", m_width / 2, isCramped() ? 5 : 20, 0xFFFFFF);
Screen::render(a, b, c);
Screen::onRender(a, b, c);
#endif
}

View File

@@ -19,8 +19,8 @@ class OptionsScreen : public Screen
public:
OptionsScreen();
~OptionsScreen();
void init() override;
void render(int, int, float) override;
void onInit() override;
void onRender(int, int, float) override;
void removed() override;
void buttonClicked(Button* pButton) override;
@@ -37,7 +37,7 @@ class OptionsScreen : public Screen
public:
OptionsScreen();
void init() override;
void render(int, int, float) override;
void onRender(int, int, float) override;
void removed() override;
#ifndef ORIGINAL_CODE

View File

@@ -23,7 +23,7 @@ PauseScreen::PauseScreen() :
{
}
void PauseScreen::init()
void PauseScreen::onInit()
{
bool bAddVisibleButton = m_pMinecraft->m_pRakNetInstance && m_pMinecraft->m_pRakNetInstance->m_bIsHost;
@@ -108,17 +108,17 @@ void PauseScreen::updateServerVisibilityText()
m_btnVisible.m_text = "Server is invisible";
}
void PauseScreen::tick()
void PauseScreen::onTick()
{
field_40++;
}
void PauseScreen::render(int a, int b, float c)
void PauseScreen::onRender(int a, int b, float c)
{
renderBackground();
drawCenteredString(m_pFont, "Game menu", m_width / 2, 24, 0xFFFFFF);
Screen::render(a, b, c);
Screen::onRender(a, b, c);
}
void PauseScreen::buttonClicked(Button* pButton)

View File

@@ -14,9 +14,9 @@ class PauseScreen : public Screen
{
public:
PauseScreen();
virtual void init() override;
virtual void tick() override;
virtual void render(int a, int b, float c) override;
virtual void onInit() override;
virtual void onTick() override;
virtual void onRender(int a, int b, float c) override;
virtual void buttonClicked(Button*) override;
void updateServerVisibilityText();

View File

@@ -13,7 +13,7 @@ bool ProgressScreen::isInGameScreen()
return false;
}
void ProgressScreen::render(int a, int b, float c)
void ProgressScreen::onRender(int a, int b, float c)
{
renderBackground();

View File

@@ -13,7 +13,7 @@
class ProgressScreen : public Screen
{
public:
void render(int, int, float) override;
void onRender(int, int, float) override;
void onEvents() override;
bool isInGameScreen() override;
};

View File

@@ -13,13 +13,13 @@ RenameMPLevelScreen::RenameMPLevelScreen(const std::string& levelName) : m_level
{
}
void RenameMPLevelScreen::init()
void RenameMPLevelScreen::onInit()
{
m_pMinecraft->platform()->showDialog(AppPlatform::DLG_RENAME_MP_WORLD);
m_pMinecraft->platform()->createUserInput();
}
void RenameMPLevelScreen::render(int mouseX, int mouseY, float f)
void RenameMPLevelScreen::onRender(int mouseX, int mouseY, float f)
{
int userInputStatus = m_pMinecraft->platform()->getUserInputStatus();
if (userInputStatus < 0)

View File

@@ -14,8 +14,8 @@ class RenameMPLevelScreen : public Screen
{
public:
RenameMPLevelScreen(const std::string& levelName);
void init() override;
void render(int mouseX, int mouseY, float f) override;
void onInit() override;
void onRender(int mouseX, int mouseY, float f) override;
private:
std::string m_levelName;

View File

@@ -19,7 +19,7 @@ SavingWorldScreen::SavingWorldScreen(bool bCopyMap, Entity *pEnt)
m_pEntityToDeleteAfterSave = pEnt;
}
void SavingWorldScreen::render(int mouseX, int mouseY, float f)
void SavingWorldScreen::onRender(int mouseX, int mouseY, float f)
{
renderDirtBackground(0);
@@ -32,7 +32,7 @@ void SavingWorldScreen::render(int mouseX, int mouseY, float f)
m_pFont->drawShadow("Saving chunks", (x_width - width) / 2, yPos, 0xFFFFFF);
}
void SavingWorldScreen::tick()
void SavingWorldScreen::onTick()
{
if (m_timer < 0)
return;

View File

@@ -19,8 +19,8 @@ class SavingWorldScreen : public Screen
public:
SavingWorldScreen(bool bCopyMap, Entity* pEntityToDeleteAfterSave);
void render(int mouseX, int mouseY, float f) override;
void tick() override;
void onRender(int mouseX, int mouseY, float f) override;
void onTick() override;
public:
bool m_bCopyMapAtEnd;

View File

@@ -25,7 +25,7 @@ SelectWorldScreen::SelectWorldScreen() :
field_130 = 0;
}
void SelectWorldScreen::init()
void SelectWorldScreen::onInit()
{
SAFE_DELETE(m_pWorldSelectionList);
@@ -81,7 +81,7 @@ void SelectWorldScreen::keyPressed(int code)
static char g_SelectWorldFilterArray[] = { '/','\n','\r','\x09','\0','\xC','`','?','*','\\','<','>','|','"',':'};
void SelectWorldScreen::tick()
void SelectWorldScreen::onTick()
{
#ifndef ORIGINAL_CODE
m_btnUnknown.field_36 = true;
@@ -141,7 +141,7 @@ void SelectWorldScreen::tick()
return;
}
m_pWorldSelectionList->tick();
m_pWorldSelectionList->onTick();
if (m_pWorldSelectionList->field_90)
{
LevelSummary& ls = m_pWorldSelectionList->m_levelSummary;
@@ -159,7 +159,7 @@ void SelectWorldScreen::tick()
m_btnDelete.m_bEnabled = isIndexValid(m_pWorldSelectionList->m_selectedIndex);
}
void SelectWorldScreen::render(int mouseX, int mouseY, float f)
void SelectWorldScreen::onRender(int mouseX, int mouseY, float f)
{
renderBackground();
#ifndef ORIGINAL_CODE
@@ -168,15 +168,15 @@ void SelectWorldScreen::render(int mouseX, int mouseY, float f)
m_pWorldSelectionList->setComponentSelected(m_btnUnknown.field_36);
if (field_12C)
{
m_pWorldSelectionList->render(mouseX, mouseY, f);
m_pWorldSelectionList->onRender(mouseX, mouseY, f);
}
else
{
m_pWorldSelectionList->render(0, 0, f);
m_pWorldSelectionList->onRender(0, 0, f);
field_12C = Mouse::getButtonState(BUTTON_LEFT);
}
Screen::render(mouseX, mouseY, f);
Screen::onRender(mouseX, mouseY, f);
drawCenteredString(m_pMinecraft->m_pFont, "Select world", m_width / 2, 8, 0xFFFFFFFF);
}

View File

@@ -16,11 +16,11 @@ class SelectWorldScreen : public Screen
public:
SelectWorldScreen();
void init() override;
void onInit() override;
bool isInGameScreen() override;
void keyPressed(int code) override;
void tick() override;
void render(int mouseX, int mouseY, float f) override;
void onTick() override;
void onRender(int mouseX, int mouseY, float f) override;
bool handleBackEvent(bool b) override;
void buttonClicked(Button* pButton) override;

View File

@@ -397,7 +397,7 @@ void StartMenuScreen::buttonClicked(Button* pButton)
}
}
void StartMenuScreen::init()
void StartMenuScreen::onInit()
{
int yPos = m_height / 2;
@@ -455,7 +455,7 @@ bool StartMenuScreen::isInGameScreen()
return false;
}
void StartMenuScreen::render(int a, int b, float c)
void StartMenuScreen::onRender(int a, int b, float c)
{
//renderBackground();
renderMenuBackground(c);
@@ -506,12 +506,12 @@ void StartMenuScreen::render(int a, int b, float c)
if (!crampedMode)
drawSplash();
Screen::render(a, b, c);
Screen::onRender(a, b, c);
}
void StartMenuScreen::tick()
void StartMenuScreen::onTick()
{
Screen::tick();
Screen::onTick();
_updateLicense();
}

View File

@@ -16,11 +16,11 @@ public:
StartMenuScreen();
void _updateLicense();
void init() override;
void onInit() override;
void buttonClicked(Button*) override;
bool isInGameScreen() override;
void render(int, int, float) override;
void tick() override;
void onRender(int, int, float) override;
void onTick() override;
void drawSplash();