From eeace9cf149b49c5455649137e53f886cb81b796 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 8 Nov 2024 20:50:34 -0500 Subject: [PATCH] Small Rename --- mods/include/mods/extend/extend.h | 28 +++++++++++----------- mods/src/chat/ui.cpp | 22 ++++++++--------- mods/src/extend/Screen.cpp | 20 ++++++++-------- mods/src/extend/extend-internal.h | 14 +++++------ mods/src/game-mode/ui.cpp | 40 +++++++++++++++---------------- mods/src/options/info.cpp | 34 +++++++++++++------------- mods/src/textures/lava.cpp | 26 ++++++++++---------- mods/src/title-screen/welcome.cpp | 14 +++++------ 8 files changed, 99 insertions(+), 99 deletions(-) diff --git a/mods/include/mods/extend/extend.h b/mods/include/mods/extend/extend.h index df37e026b7..c6b3e02137 100644 --- a/mods/include/mods/extend/extend.h +++ b/mods/include/mods/extend/extend.h @@ -37,27 +37,27 @@ T *extend_get_vtable() { static void setup_##name##_vtable(parent##_vtable *vtable) // Extend MCPI Classes -template -Self *extend_get_data(Super *super) { - return (Self *) (super + 1); +template +Data *extend_get_data(Self *self) { + return (Data *) (self + 1); } -template -auto extend_struct(auto&&... args) -> decltype(Super::allocate()) { - constexpr size_t size = sizeof(Super) + sizeof(Self); - Super *super = (Super *) ::operator new(size); - Self *self = extend_get_data(super); - new (self) Self(std::forward(args)...); - return super; +template +auto extend_struct(auto&&... args) -> decltype(Self::allocate()) { + constexpr size_t size = sizeof(Self) + sizeof(Data); + Self *out = (Self *) ::operator new(size); + Data *data = extend_get_data(out); + new (data) Data(std::forward(args)...); + return out; } // Helpers #define CREATE_HELPER(name) \ struct Custom##name { \ - explicit Custom##name(auto&&... args): super(((name *) this) - 1) { \ - super->constructor(std::forward(args)...); \ - super->vtable = get_vtable(); \ + explicit Custom##name(auto&&... args): self(((name *) this) - 1) { \ + self->constructor(std::forward(args)...); \ + self->vtable = get_vtable(); \ } \ - name *const super; \ + name *const self; \ static name##_vtable *get_vtable(); \ private: \ static void setup_vtable(name##_vtable *vtable); \ diff --git a/mods/src/chat/ui.cpp b/mods/src/chat/ui.cpp index e9198e0b38..bf313c0b10 100644 --- a/mods/src/chat/ui.cpp +++ b/mods/src/chat/ui.cpp @@ -26,7 +26,7 @@ struct ChatScreen final : TextInputScreen { // Text Input chat = new TextInputBox; m_textInputs->push_back(chat); - chat->init(super->font); + chat->init(self->font); chat->setFocused(true); history_pos = get_history().size(); local_history = get_history(); @@ -37,8 +37,8 @@ struct ChatScreen final : TextInputScreen { chat->setMaxLength(max_length); // Send Button send = touch_create_button(1, "Send"); - super->rendered_buttons.push_back(send); - super->selectable_buttons.push_back(send); + self->rendered_buttons.push_back(send); + self->selectable_buttons.push_back(send); // Hide Chat Messages is_in_chat = true; } @@ -51,9 +51,9 @@ struct ChatScreen final : TextInputScreen { // Rendering void render(const int x, const int y, const float param_1) override { // Background - super->renderBackground(); + self->renderBackground(); // Render Chat - super->minecraft->gui.renderChatMessages(super->height, 20, true, super->font); + self->minecraft->gui.renderChatMessages(self->height, 20, true, self->font); // Call Original Method TextInputScreen::render(x, y, param_1); } @@ -63,10 +63,10 @@ struct ChatScreen final : TextInputScreen { send->height = 24; send->width = 40; constexpr int x = 0; - const int y = super->height - send->height; - const int width = super->width - send->width; + const int y = self->height - send->height; + const int width = self->width - send->width; chat->setSize(x, y, width, send->height); - send->y = super->height - send->height; + send->y = self->height - send->height; send->x = x + width; } // Key Presses @@ -78,9 +78,9 @@ struct ChatScreen final : TextInputScreen { if (get_history().size() == 0 || text != get_history().back()) { get_history().push_back(text); } - _chat_send_message_to_server(super->minecraft, text.c_str()); + _chat_send_message_to_server(self->minecraft, text.c_str()); } - super->minecraft->setScreen(nullptr); + self->minecraft->setScreen(nullptr); } else if (key == MC_KEY_UP) { // Up local_history.at(history_pos) = chat->getText(); @@ -107,7 +107,7 @@ struct ChatScreen final : TextInputScreen { if (button == send) { // Send chat->setFocused(true); - super->keyPressed(0x0d); + self->keyPressed(0x0d); } else { // Call Original Method TextInputScreen::buttonClicked(button); diff --git a/mods/src/extend/Screen.cpp b/mods/src/extend/Screen.cpp index b75c460991..224918d608 100644 --- a/mods/src/extend/Screen.cpp +++ b/mods/src/extend/Screen.cpp @@ -2,34 +2,34 @@ // Easily Create Custom Screens void CustomScreen::init() { - Screen_vtable::base->init(super); + Screen_vtable::base->init(self); } void CustomScreen::render(const int x, const int y, const float param_1) { - Screen_vtable::base->render(super, x, y, param_1); + Screen_vtable::base->render(self, x, y, param_1); } void CustomScreen::setupPositions() { - Screen_vtable::base->setupPositions(super); + Screen_vtable::base->setupPositions(self); } bool CustomScreen::handleBackEvent(const bool do_nothing) { - return Screen_vtable::base->handleBackEvent(super, do_nothing); + return Screen_vtable::base->handleBackEvent(self, do_nothing); } void CustomScreen::tick() { - Screen_vtable::base->tick(super); + Screen_vtable::base->tick(self); } void CustomScreen::buttonClicked(Button *button) { - Screen_vtable::base->buttonClicked(super, button); + Screen_vtable::base->buttonClicked(self, button); } void CustomScreen::mouseClicked(const int x, const int y, const int param_1) { - Screen_vtable::base->mouseClicked(super, x, y, param_1); + Screen_vtable::base->mouseClicked(self, x, y, param_1); } void CustomScreen::mouseReleased(const int x, const int y, const int param_1) { - Screen_vtable::base->mouseReleased(super, x, y, param_1); + Screen_vtable::base->mouseReleased(self, x, y, param_1); } void CustomScreen::keyPressed(const int key) { - Screen_vtable::base->keyPressed(super, key); + Screen_vtable::base->keyPressed(self, key); } void CustomScreen::keyboardNewChar(const char key) { - Screen_vtable::base->keyboardNewChar(super, key); + Screen_vtable::base->keyboardNewChar(self, key); } // VTable diff --git a/mods/src/extend/extend-internal.h b/mods/src/extend/extend-internal.h index 4e7f8ab175..28cf032900 100644 --- a/mods/src/extend/extend-internal.h +++ b/mods/src/extend/extend-internal.h @@ -4,13 +4,13 @@ // VTable Patching #define PATCH_VTABLE(name) \ - vtable->name = [](_Super *super, auto... args) { \ - return extend_get_data<_Super, _Self>(super)->name(std::forward(args)...); \ + vtable->name = [](_Self *self, auto... args) { \ + return extend_get_data<_Self, _Data>(self)->name(std::forward(args)...); \ } #define _PATCH_VTABLE_DESTRUCTOR(name, type) \ - vtable->type = [](_Super *super) { \ - extend_get_data<_Super, _Self>(super)->~_Self(); \ - return name##_vtable::base->type(super); \ + vtable->type = [](_Self *self) { \ + extend_get_data<_Self, _Data>(self)->~_Data(); \ + return name##_vtable::base->type(self); \ } #define _PATCH_VTABLE_DESTRUCTORS(name) \ _PATCH_VTABLE_DESTRUCTOR(name, destructor_complete); \ @@ -19,7 +19,7 @@ name##_vtable *Custom##name::get_vtable() { \ return extend_get_vtable(); \ } \ - typedef name _Super; \ - typedef Custom##name _Self; \ + typedef name _Self; \ + typedef Custom##name _Data; \ void Custom##name::setup_vtable(name##_vtable *vtable) { \ _PATCH_VTABLE_DESTRUCTORS(name); diff --git a/mods/src/game-mode/ui.cpp b/mods/src/game-mode/ui.cpp index c164b84f50..915a013911 100644 --- a/mods/src/game-mode/ui.cpp +++ b/mods/src/game-mode/ui.cpp @@ -39,25 +39,25 @@ struct CreateWorldScreen final : TextInputScreen { // Name name = new TextInputBox("World Name", "Unnamed world"); m_textInputs->push_back(name); - name->init(super->font); + name->init(self->font); name->setFocused(true); // Seed seed = new TextInputBox("Seed"); m_textInputs->push_back(seed); - seed->init(super->font); + seed->init(self->font); seed->setFocused(false); // Game Mode game_mode = touch_create_button(1, CREATIVE_STR); - super->rendered_buttons.push_back(game_mode); - super->selectable_buttons.push_back(game_mode); + self->rendered_buttons.push_back(game_mode); + self->selectable_buttons.push_back(game_mode); // Create create = touch_create_button(2, "Create"); - super->rendered_buttons.push_back(create); - super->selectable_buttons.push_back(create); + self->rendered_buttons.push_back(create); + self->selectable_buttons.push_back(create); // Back back = touch_create_button(3, "Back"); - super->rendered_buttons.push_back(back); - super->selectable_buttons.push_back(back); + self->rendered_buttons.push_back(back); + self->selectable_buttons.push_back(back); } // Removal ~CreateWorldScreen() override { @@ -70,17 +70,17 @@ struct CreateWorldScreen final : TextInputScreen { // Rendering void render(const int x, const int y, const float param_1) override { // Background - misc_render_background(80, super->minecraft, 0, 0, super->width, super->height); - misc_render_background(32, super->minecraft, 0, content_y_offset_top, super->width, super->height - content_y_offset_top - content_y_offset_bottom); + misc_render_background(80, self->minecraft, 0, 0, self->width, self->height); + misc_render_background(32, self->minecraft, 0, content_y_offset_top, self->width, self->height - content_y_offset_top - content_y_offset_bottom); // Call Original Method TextInputScreen::render(x, y, param_1); // Title std::string title = "Create world"; - super->drawCenteredString(super->font, title, super->width / 2, title_padding, 0xffffffff); + self->drawCenteredString(self->font, title, self->width / 2, title_padding, 0xffffffff); // Game Mode Description const bool is_creative = game_mode->text == CREATIVE_STR; std::string description = is_creative ? Strings::creative_mode_description : Strings::survival_mode_description; - super->drawString(super->font, description, game_mode->x, game_mode->y + game_mode->height + description_padding, 0xa0a0a0); + self->drawString(self->font, description, game_mode->x, game_mode->y + game_mode->height + description_padding, 0xa0a0a0); } // Positioning void setupPositions() override { @@ -95,15 +95,15 @@ struct CreateWorldScreen final : TextInputScreen { const int text_box_height = game_mode->height; // Find Center Y constexpr int top = content_y_offset_top; - const int bottom = super->height - content_y_offset_bottom; + const int bottom = self->height - content_y_offset_bottom; int center_y = ((bottom - top) / 2) + top; center_y -= (description_padding + line_height) / 2; // X/Y - create->y = back->y = super->height - bottom_padding - height; - create->x = game_mode->x = (super->width / 2) - inner_padding - width; - back->x = (super->width / 2) + inner_padding; + create->y = back->y = self->height - bottom_padding - height; + create->x = game_mode->x = (self->width / 2) - inner_padding - width; + back->x = (self->width / 2) + inner_padding; const int seed_x = back->x; - const int name_x = (super->width / 2) - (name_width / 2); + const int name_x = (self->width / 2) - (name_width / 2); const int name_y = center_y - inner_padding - height; game_mode->y = center_y + inner_padding; const int seed_y = game_mode->y; @@ -114,7 +114,7 @@ struct CreateWorldScreen final : TextInputScreen { // ESC bool handleBackEvent(const bool do_nothing) override { if (!do_nothing) { - super->minecraft->screen_chooser.setScreen(5); + self->minecraft->screen_chooser.setScreen(5); } return true; } @@ -126,10 +126,10 @@ struct CreateWorldScreen final : TextInputScreen { game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR; } else if (button == back) { // Back - super->handleBackEvent(false); + self->handleBackEvent(false); } else if (button == create) { // Create - create_world(super->minecraft, name->getText(), is_creative, seed->getText()); + create_world(self->minecraft, name->getText(), is_creative, seed->getText()); } else { TextInputScreen::buttonClicked(button); } diff --git a/mods/src/options/info.cpp b/mods/src/options/info.cpp index bcbdd02073..74d3533a75 100644 --- a/mods/src/options/info.cpp +++ b/mods/src/options/info.cpp @@ -182,42 +182,42 @@ struct InfoScreen final : CustomScreen { // Info for (int i = 0; i < info_size; i++) { Button *button = touch_create_button(INFO_ID_START + i, info[i].button_text); - super->rendered_buttons.push_back(button); - super->selectable_buttons.push_back(button); + self->rendered_buttons.push_back(button); + self->selectable_buttons.push_back(button); info_buttons[i] = button; } // Discord Button discord = touch_create_button(DISCORD_ID, "Discord"); - super->rendered_buttons.push_back(discord); - super->selectable_buttons.push_back(discord); + self->rendered_buttons.push_back(discord); + self->selectable_buttons.push_back(discord); // Back Button back = touch_create_button(BACK_ID, "Back"); - super->rendered_buttons.push_back(back); - super->selectable_buttons.push_back(back); + self->rendered_buttons.push_back(back); + self->selectable_buttons.push_back(back); } // Handle Back bool handleBackEvent(const bool do_nothing) override { if (!do_nothing) { OptionsScreen *screen = OptionsScreen::allocate(); screen->constructor(); - super->minecraft->setScreen((Screen *) screen); + self->minecraft->setScreen((Screen *) screen); } return true; } // Rendering void render(const int x, const int y, const float param_1) override { // Background - misc_render_background(80, super->minecraft, 0, 0, super->width, super->height); - misc_render_background(32, super->minecraft, 0, content_y_offset_top, super->width, content_height); + misc_render_background(80, self->minecraft, 0, 0, self->width, self->height); + misc_render_background(32, self->minecraft, 0, content_y_offset_top, self->width, content_height); // Call Original Method CustomScreen::render(x, y, param_1); // Title std::string title = "Reborn Information"; - super->drawCenteredString(super->font, title, super->width / 2, title_padding, 0xffffffff); + self->drawCenteredString(self->font, title, self->width / 2, title_padding, 0xffffffff); // Info Text for (int i = 0; i < info_size; i++) { std::string text = info[i].get_text(); - super->drawString(super->font, text, positioned_info[i].text.x, positioned_info[i].text.y, 0xffffffff); + self->drawString(self->font, text, positioned_info[i].text.x, positioned_info[i].text.y, 0xffffffff); } } // Positioning @@ -228,11 +228,11 @@ struct InfoScreen final : CustomScreen { discord->width = back->width = width; discord->height = back->height = line_button_height; // X/Y - discord->y = back->y = super->height - bottom_padding - line_button_height; - discord->x = (super->width / 2) - inner_padding - width; - back->x = (super->width / 2) + inner_padding; + discord->y = back->y = self->height - bottom_padding - line_button_height; + discord->x = (self->width / 2) - inner_padding - width; + back->x = (self->width / 2) + inner_padding; // Info - position_info(super->font, super->width, super->height); + position_info(self->font, self->width, self->height); for (int i = 0; i < info_size; i++) { Button *button = info_buttons[i]; button->width = line_button_width; @@ -243,7 +243,7 @@ struct InfoScreen final : CustomScreen { } // Cleanup ~InfoScreen() override { - for (Button *button : super->rendered_buttons) { + for (Button *button : self->rendered_buttons) { button->destructor_deleting(); } } @@ -251,7 +251,7 @@ struct InfoScreen final : CustomScreen { void buttonClicked(Button *button) override { if (button->id == BACK_ID) { // Back - super->handleBackEvent(false); + self->handleBackEvent(false); } else if (button->id == DISCORD_ID) { // Open Discord Invite open_url(MCPI_DISCORD_INVITE); diff --git a/mods/src/textures/lava.cpp b/mods/src/textures/lava.cpp index d3cfc97bb6..c178bdf962 100644 --- a/mods/src/textures/lava.cpp +++ b/mods/src/textures/lava.cpp @@ -60,10 +60,10 @@ struct LavaTexture final : CustomDynamicTexture { if (x1 < 0.0f) { x1 = 0.0f; } - super->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); - super->pixels[i * 4 + 1] = int(255.0f * x1 * x1); - super->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); - super->pixels[i * 4 + 3] = 255; + self->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); + self->pixels[i * 4 + 1] = int(255.0f * x1 * x1); + self->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); + self->pixels[i * 4 + 3] = 255; } } }; @@ -84,7 +84,7 @@ struct LavaSideTexture final : CustomDynamicTexture { field_14 = 0; field_18 = 0; field_1C = 0; - super->texture_size = 2; + self->texture_size = 2; for (int i = 0; i < 256; i++) { m_data1[i] = 0.0f; m_data2[i] = 0.0f; @@ -126,10 +126,10 @@ struct LavaSideTexture final : CustomDynamicTexture { if (x1 < 0.0f) { x1 = 0.0f; } - super->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); - super->pixels[i * 4 + 1] = int(255.0f * x1 * x1); - super->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); - super->pixels[i * 4 + 3] = 255; + self->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); + self->pixels[i * 4 + 1] = int(255.0f * x1 * x1); + self->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); + self->pixels[i * 4 + 3] = 255; } } }; @@ -186,10 +186,10 @@ struct FireTexture final : CustomDynamicTexture { if (x < 0.0f) { x = 0.0f; } - super->pixels[4 * i + 0] = int(x * 155.0f + 100.0f); - super->pixels[4 * i + 1] = int(x * x * 255.0f); - super->pixels[4 * i + 2] = int(x * x * x * x * x * x * x * x * x * x * 255.0f); - super->pixels[4 * i + 3] = x >= 0.5f ? 255 : 0; + self->pixels[4 * i + 0] = int(x * 155.0f + 100.0f); + self->pixels[4 * i + 1] = int(x * x * 255.0f); + self->pixels[4 * i + 2] = int(x * x * x * x * x * x * x * x * x * x * 255.0f); + self->pixels[4 * i + 3] = x >= 0.5f ? 255 : 0; } } }; diff --git a/mods/src/title-screen/welcome.cpp b/mods/src/title-screen/welcome.cpp index 8ed2270e51..73fa7d1959 100644 --- a/mods/src/title-screen/welcome.cpp +++ b/mods/src/title-screen/welcome.cpp @@ -85,27 +85,27 @@ struct WelcomeScreen final : CustomScreen { changelog = touch_create_button(1, "Changelog"); proceed = touch_create_button(2, "Proceed"); for (Button *button : {getting_started, changelog, proceed}) { - super->rendered_buttons.push_back(button); - super->selectable_buttons.push_back(button); + self->rendered_buttons.push_back(button); + self->selectable_buttons.push_back(button); } } // Rendering void render(const int x, const int y, const float param_1) override { // Background - super->renderBackground(); + self->renderBackground(); // Call Original Method CustomScreen::render(x, y, param_1); // Text - super->drawCenteredString(super->font, line1, super->width / 2, text_y, 0xFFFFFFFF); + self->drawCenteredString(self->font, line1, self->width / 2, text_y, 0xFFFFFFFF); } // Positioning void setupPositions() override { CustomScreen::setupPositions(); - position_screen(super->width, super->height); + position_screen(self->width, self->height); } // Cleanup ~WelcomeScreen() override { - for (Button *button : super->rendered_buttons) { + for (Button *button : self->rendered_buttons) { button->destructor_deleting(); } } @@ -117,7 +117,7 @@ struct WelcomeScreen final : CustomScreen { open_url(MCPI_DOCUMENTATION CHANGELOG_FILE); } else if (button == proceed) { mark_welcome_as_shown(); - super->minecraft->screen_chooser.setScreen(1); + self->minecraft->screen_chooser.setScreen(1); } else { CustomScreen::buttonClicked(button); }