Small Rename
This commit is contained in:
parent
dd25805af9
commit
eeace9cf14
@ -37,27 +37,27 @@ T *extend_get_vtable() {
|
|||||||
static void setup_##name##_vtable(parent##_vtable *vtable)
|
static void setup_##name##_vtable(parent##_vtable *vtable)
|
||||||
|
|
||||||
// Extend MCPI Classes
|
// Extend MCPI Classes
|
||||||
template <typename Super, typename Self>
|
template <typename Self, typename Data>
|
||||||
Self *extend_get_data(Super *super) {
|
Data *extend_get_data(Self *self) {
|
||||||
return (Self *) (super + 1);
|
return (Data *) (self + 1);
|
||||||
}
|
}
|
||||||
template <typename Super, typename Self>
|
template <typename Self, typename Data>
|
||||||
auto extend_struct(auto&&... args) -> decltype(Super::allocate()) {
|
auto extend_struct(auto&&... args) -> decltype(Self::allocate()) {
|
||||||
constexpr size_t size = sizeof(Super) + sizeof(Self);
|
constexpr size_t size = sizeof(Self) + sizeof(Data);
|
||||||
Super *super = (Super *) ::operator new(size);
|
Self *out = (Self *) ::operator new(size);
|
||||||
Self *self = extend_get_data<Super, Self>(super);
|
Data *data = extend_get_data<Self, Data>(out);
|
||||||
new (self) Self(std::forward<decltype(args)>(args)...);
|
new (data) Data(std::forward<decltype(args)>(args)...);
|
||||||
return super;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
#define CREATE_HELPER(name) \
|
#define CREATE_HELPER(name) \
|
||||||
struct Custom##name { \
|
struct Custom##name { \
|
||||||
explicit Custom##name(auto&&... args): super(((name *) this) - 1) { \
|
explicit Custom##name(auto&&... args): self(((name *) this) - 1) { \
|
||||||
super->constructor(std::forward<decltype(args)>(args)...); \
|
self->constructor(std::forward<decltype(args)>(args)...); \
|
||||||
super->vtable = get_vtable(); \
|
self->vtable = get_vtable(); \
|
||||||
} \
|
} \
|
||||||
name *const super; \
|
name *const self; \
|
||||||
static name##_vtable *get_vtable(); \
|
static name##_vtable *get_vtable(); \
|
||||||
private: \
|
private: \
|
||||||
static void setup_vtable(name##_vtable *vtable); \
|
static void setup_vtable(name##_vtable *vtable); \
|
||||||
|
@ -26,7 +26,7 @@ struct ChatScreen final : TextInputScreen {
|
|||||||
// Text Input
|
// Text Input
|
||||||
chat = new TextInputBox;
|
chat = new TextInputBox;
|
||||||
m_textInputs->push_back(chat);
|
m_textInputs->push_back(chat);
|
||||||
chat->init(super->font);
|
chat->init(self->font);
|
||||||
chat->setFocused(true);
|
chat->setFocused(true);
|
||||||
history_pos = get_history().size();
|
history_pos = get_history().size();
|
||||||
local_history = get_history();
|
local_history = get_history();
|
||||||
@ -37,8 +37,8 @@ struct ChatScreen final : TextInputScreen {
|
|||||||
chat->setMaxLength(max_length);
|
chat->setMaxLength(max_length);
|
||||||
// Send Button
|
// Send Button
|
||||||
send = touch_create_button(1, "Send");
|
send = touch_create_button(1, "Send");
|
||||||
super->rendered_buttons.push_back(send);
|
self->rendered_buttons.push_back(send);
|
||||||
super->selectable_buttons.push_back(send);
|
self->selectable_buttons.push_back(send);
|
||||||
// Hide Chat Messages
|
// Hide Chat Messages
|
||||||
is_in_chat = true;
|
is_in_chat = true;
|
||||||
}
|
}
|
||||||
@ -51,9 +51,9 @@ struct ChatScreen final : TextInputScreen {
|
|||||||
// Rendering
|
// Rendering
|
||||||
void render(const int x, const int y, const float param_1) override {
|
void render(const int x, const int y, const float param_1) override {
|
||||||
// Background
|
// Background
|
||||||
super->renderBackground();
|
self->renderBackground();
|
||||||
// Render Chat
|
// 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
|
// Call Original Method
|
||||||
TextInputScreen::render(x, y, param_1);
|
TextInputScreen::render(x, y, param_1);
|
||||||
}
|
}
|
||||||
@ -63,10 +63,10 @@ struct ChatScreen final : TextInputScreen {
|
|||||||
send->height = 24;
|
send->height = 24;
|
||||||
send->width = 40;
|
send->width = 40;
|
||||||
constexpr int x = 0;
|
constexpr int x = 0;
|
||||||
const int y = super->height - send->height;
|
const int y = self->height - send->height;
|
||||||
const int width = super->width - send->width;
|
const int width = self->width - send->width;
|
||||||
chat->setSize(x, y, width, send->height);
|
chat->setSize(x, y, width, send->height);
|
||||||
send->y = super->height - send->height;
|
send->y = self->height - send->height;
|
||||||
send->x = x + width;
|
send->x = x + width;
|
||||||
}
|
}
|
||||||
// Key Presses
|
// Key Presses
|
||||||
@ -78,9 +78,9 @@ struct ChatScreen final : TextInputScreen {
|
|||||||
if (get_history().size() == 0 || text != get_history().back()) {
|
if (get_history().size() == 0 || text != get_history().back()) {
|
||||||
get_history().push_back(text);
|
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) {
|
} else if (key == MC_KEY_UP) {
|
||||||
// Up
|
// Up
|
||||||
local_history.at(history_pos) = chat->getText();
|
local_history.at(history_pos) = chat->getText();
|
||||||
@ -107,7 +107,7 @@ struct ChatScreen final : TextInputScreen {
|
|||||||
if (button == send) {
|
if (button == send) {
|
||||||
// Send
|
// Send
|
||||||
chat->setFocused(true);
|
chat->setFocused(true);
|
||||||
super->keyPressed(0x0d);
|
self->keyPressed(0x0d);
|
||||||
} else {
|
} else {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
TextInputScreen::buttonClicked(button);
|
TextInputScreen::buttonClicked(button);
|
||||||
|
@ -2,34 +2,34 @@
|
|||||||
|
|
||||||
// Easily Create Custom Screens
|
// Easily Create Custom Screens
|
||||||
void CustomScreen::init() {
|
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) {
|
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() {
|
void CustomScreen::setupPositions() {
|
||||||
Screen_vtable::base->setupPositions(super);
|
Screen_vtable::base->setupPositions(self);
|
||||||
}
|
}
|
||||||
bool CustomScreen::handleBackEvent(const bool do_nothing) {
|
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() {
|
void CustomScreen::tick() {
|
||||||
Screen_vtable::base->tick(super);
|
Screen_vtable::base->tick(self);
|
||||||
}
|
}
|
||||||
void CustomScreen::buttonClicked(Button *button) {
|
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) {
|
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) {
|
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) {
|
void CustomScreen::keyPressed(const int key) {
|
||||||
Screen_vtable::base->keyPressed(super, key);
|
Screen_vtable::base->keyPressed(self, key);
|
||||||
}
|
}
|
||||||
void CustomScreen::keyboardNewChar(const char key) {
|
void CustomScreen::keyboardNewChar(const char key) {
|
||||||
Screen_vtable::base->keyboardNewChar(super, key);
|
Screen_vtable::base->keyboardNewChar(self, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// VTable
|
// VTable
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
// VTable Patching
|
// VTable Patching
|
||||||
#define PATCH_VTABLE(name) \
|
#define PATCH_VTABLE(name) \
|
||||||
vtable->name = [](_Super *super, auto... args) { \
|
vtable->name = [](_Self *self, auto... args) { \
|
||||||
return extend_get_data<_Super, _Self>(super)->name(std::forward<decltype(args)>(args)...); \
|
return extend_get_data<_Self, _Data>(self)->name(std::forward<decltype(args)>(args)...); \
|
||||||
}
|
}
|
||||||
#define _PATCH_VTABLE_DESTRUCTOR(name, type) \
|
#define _PATCH_VTABLE_DESTRUCTOR(name, type) \
|
||||||
vtable->type = [](_Super *super) { \
|
vtable->type = [](_Self *self) { \
|
||||||
extend_get_data<_Super, _Self>(super)->~_Self(); \
|
extend_get_data<_Self, _Data>(self)->~_Data(); \
|
||||||
return name##_vtable::base->type(super); \
|
return name##_vtable::base->type(self); \
|
||||||
}
|
}
|
||||||
#define _PATCH_VTABLE_DESTRUCTORS(name) \
|
#define _PATCH_VTABLE_DESTRUCTORS(name) \
|
||||||
_PATCH_VTABLE_DESTRUCTOR(name, destructor_complete); \
|
_PATCH_VTABLE_DESTRUCTOR(name, destructor_complete); \
|
||||||
@ -19,7 +19,7 @@
|
|||||||
name##_vtable *Custom##name::get_vtable() { \
|
name##_vtable *Custom##name::get_vtable() { \
|
||||||
return extend_get_vtable<name##_vtable, setup_vtable>(); \
|
return extend_get_vtable<name##_vtable, setup_vtable>(); \
|
||||||
} \
|
} \
|
||||||
typedef name _Super; \
|
typedef name _Self; \
|
||||||
typedef Custom##name _Self; \
|
typedef Custom##name _Data; \
|
||||||
void Custom##name::setup_vtable(name##_vtable *vtable) { \
|
void Custom##name::setup_vtable(name##_vtable *vtable) { \
|
||||||
_PATCH_VTABLE_DESTRUCTORS(name);
|
_PATCH_VTABLE_DESTRUCTORS(name);
|
||||||
|
@ -39,25 +39,25 @@ struct CreateWorldScreen final : TextInputScreen {
|
|||||||
// Name
|
// Name
|
||||||
name = new TextInputBox("World Name", "Unnamed world");
|
name = new TextInputBox("World Name", "Unnamed world");
|
||||||
m_textInputs->push_back(name);
|
m_textInputs->push_back(name);
|
||||||
name->init(super->font);
|
name->init(self->font);
|
||||||
name->setFocused(true);
|
name->setFocused(true);
|
||||||
// Seed
|
// Seed
|
||||||
seed = new TextInputBox("Seed");
|
seed = new TextInputBox("Seed");
|
||||||
m_textInputs->push_back(seed);
|
m_textInputs->push_back(seed);
|
||||||
seed->init(super->font);
|
seed->init(self->font);
|
||||||
seed->setFocused(false);
|
seed->setFocused(false);
|
||||||
// Game Mode
|
// Game Mode
|
||||||
game_mode = touch_create_button(1, CREATIVE_STR);
|
game_mode = touch_create_button(1, CREATIVE_STR);
|
||||||
super->rendered_buttons.push_back(game_mode);
|
self->rendered_buttons.push_back(game_mode);
|
||||||
super->selectable_buttons.push_back(game_mode);
|
self->selectable_buttons.push_back(game_mode);
|
||||||
// Create
|
// Create
|
||||||
create = touch_create_button(2, "Create");
|
create = touch_create_button(2, "Create");
|
||||||
super->rendered_buttons.push_back(create);
|
self->rendered_buttons.push_back(create);
|
||||||
super->selectable_buttons.push_back(create);
|
self->selectable_buttons.push_back(create);
|
||||||
// Back
|
// Back
|
||||||
back = touch_create_button(3, "Back");
|
back = touch_create_button(3, "Back");
|
||||||
super->rendered_buttons.push_back(back);
|
self->rendered_buttons.push_back(back);
|
||||||
super->selectable_buttons.push_back(back);
|
self->selectable_buttons.push_back(back);
|
||||||
}
|
}
|
||||||
// Removal
|
// Removal
|
||||||
~CreateWorldScreen() override {
|
~CreateWorldScreen() override {
|
||||||
@ -70,17 +70,17 @@ struct CreateWorldScreen final : TextInputScreen {
|
|||||||
// Rendering
|
// Rendering
|
||||||
void render(const int x, const int y, const float param_1) override {
|
void render(const int x, const int y, const float param_1) override {
|
||||||
// Background
|
// Background
|
||||||
misc_render_background(80, super->minecraft, 0, 0, super->width, super->height);
|
misc_render_background(80, self->minecraft, 0, 0, self->width, self->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(32, self->minecraft, 0, content_y_offset_top, self->width, self->height - content_y_offset_top - content_y_offset_bottom);
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
TextInputScreen::render(x, y, param_1);
|
TextInputScreen::render(x, y, param_1);
|
||||||
// Title
|
// Title
|
||||||
std::string title = "Create world";
|
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
|
// Game Mode Description
|
||||||
const bool is_creative = game_mode->text == CREATIVE_STR;
|
const bool is_creative = game_mode->text == CREATIVE_STR;
|
||||||
std::string description = is_creative ? Strings::creative_mode_description : Strings::survival_mode_description;
|
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
|
// Positioning
|
||||||
void setupPositions() override {
|
void setupPositions() override {
|
||||||
@ -95,15 +95,15 @@ struct CreateWorldScreen final : TextInputScreen {
|
|||||||
const int text_box_height = game_mode->height;
|
const int text_box_height = game_mode->height;
|
||||||
// Find Center Y
|
// Find Center Y
|
||||||
constexpr int top = content_y_offset_top;
|
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;
|
int center_y = ((bottom - top) / 2) + top;
|
||||||
center_y -= (description_padding + line_height) / 2;
|
center_y -= (description_padding + line_height) / 2;
|
||||||
// X/Y
|
// X/Y
|
||||||
create->y = back->y = super->height - bottom_padding - height;
|
create->y = back->y = self->height - bottom_padding - height;
|
||||||
create->x = game_mode->x = (super->width / 2) - inner_padding - width;
|
create->x = game_mode->x = (self->width / 2) - inner_padding - width;
|
||||||
back->x = (super->width / 2) + inner_padding;
|
back->x = (self->width / 2) + inner_padding;
|
||||||
const int seed_x = back->x;
|
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;
|
const int name_y = center_y - inner_padding - height;
|
||||||
game_mode->y = center_y + inner_padding;
|
game_mode->y = center_y + inner_padding;
|
||||||
const int seed_y = game_mode->y;
|
const int seed_y = game_mode->y;
|
||||||
@ -114,7 +114,7 @@ struct CreateWorldScreen final : TextInputScreen {
|
|||||||
// ESC
|
// ESC
|
||||||
bool handleBackEvent(const bool do_nothing) override {
|
bool handleBackEvent(const bool do_nothing) override {
|
||||||
if (!do_nothing) {
|
if (!do_nothing) {
|
||||||
super->minecraft->screen_chooser.setScreen(5);
|
self->minecraft->screen_chooser.setScreen(5);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -126,10 +126,10 @@ struct CreateWorldScreen final : TextInputScreen {
|
|||||||
game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR;
|
game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR;
|
||||||
} else if (button == back) {
|
} else if (button == back) {
|
||||||
// Back
|
// Back
|
||||||
super->handleBackEvent(false);
|
self->handleBackEvent(false);
|
||||||
} else if (button == create) {
|
} else if (button == create) {
|
||||||
// Create
|
// Create
|
||||||
create_world(super->minecraft, name->getText(), is_creative, seed->getText());
|
create_world(self->minecraft, name->getText(), is_creative, seed->getText());
|
||||||
} else {
|
} else {
|
||||||
TextInputScreen::buttonClicked(button);
|
TextInputScreen::buttonClicked(button);
|
||||||
}
|
}
|
||||||
|
@ -182,42 +182,42 @@ struct InfoScreen final : CustomScreen {
|
|||||||
// Info
|
// Info
|
||||||
for (int i = 0; i < info_size; i++) {
|
for (int i = 0; i < info_size; i++) {
|
||||||
Button *button = touch_create_button(INFO_ID_START + i, info[i].button_text);
|
Button *button = touch_create_button(INFO_ID_START + i, info[i].button_text);
|
||||||
super->rendered_buttons.push_back(button);
|
self->rendered_buttons.push_back(button);
|
||||||
super->selectable_buttons.push_back(button);
|
self->selectable_buttons.push_back(button);
|
||||||
info_buttons[i] = button;
|
info_buttons[i] = button;
|
||||||
}
|
}
|
||||||
// Discord Button
|
// Discord Button
|
||||||
discord = touch_create_button(DISCORD_ID, "Discord");
|
discord = touch_create_button(DISCORD_ID, "Discord");
|
||||||
super->rendered_buttons.push_back(discord);
|
self->rendered_buttons.push_back(discord);
|
||||||
super->selectable_buttons.push_back(discord);
|
self->selectable_buttons.push_back(discord);
|
||||||
// Back Button
|
// Back Button
|
||||||
back = touch_create_button(BACK_ID, "Back");
|
back = touch_create_button(BACK_ID, "Back");
|
||||||
super->rendered_buttons.push_back(back);
|
self->rendered_buttons.push_back(back);
|
||||||
super->selectable_buttons.push_back(back);
|
self->selectable_buttons.push_back(back);
|
||||||
}
|
}
|
||||||
// Handle Back
|
// Handle Back
|
||||||
bool handleBackEvent(const bool do_nothing) override {
|
bool handleBackEvent(const bool do_nothing) override {
|
||||||
if (!do_nothing) {
|
if (!do_nothing) {
|
||||||
OptionsScreen *screen = OptionsScreen::allocate();
|
OptionsScreen *screen = OptionsScreen::allocate();
|
||||||
screen->constructor();
|
screen->constructor();
|
||||||
super->minecraft->setScreen((Screen *) screen);
|
self->minecraft->setScreen((Screen *) screen);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Rendering
|
// Rendering
|
||||||
void render(const int x, const int y, const float param_1) override {
|
void render(const int x, const int y, const float param_1) override {
|
||||||
// Background
|
// Background
|
||||||
misc_render_background(80, super->minecraft, 0, 0, super->width, super->height);
|
misc_render_background(80, self->minecraft, 0, 0, self->width, self->height);
|
||||||
misc_render_background(32, super->minecraft, 0, content_y_offset_top, super->width, content_height);
|
misc_render_background(32, self->minecraft, 0, content_y_offset_top, self->width, content_height);
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
CustomScreen::render(x, y, param_1);
|
CustomScreen::render(x, y, param_1);
|
||||||
// Title
|
// Title
|
||||||
std::string title = "Reborn Information";
|
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
|
// Info Text
|
||||||
for (int i = 0; i < info_size; i++) {
|
for (int i = 0; i < info_size; i++) {
|
||||||
std::string text = info[i].get_text();
|
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
|
// Positioning
|
||||||
@ -228,11 +228,11 @@ struct InfoScreen final : CustomScreen {
|
|||||||
discord->width = back->width = width;
|
discord->width = back->width = width;
|
||||||
discord->height = back->height = line_button_height;
|
discord->height = back->height = line_button_height;
|
||||||
// X/Y
|
// X/Y
|
||||||
discord->y = back->y = super->height - bottom_padding - line_button_height;
|
discord->y = back->y = self->height - bottom_padding - line_button_height;
|
||||||
discord->x = (super->width / 2) - inner_padding - width;
|
discord->x = (self->width / 2) - inner_padding - width;
|
||||||
back->x = (super->width / 2) + inner_padding;
|
back->x = (self->width / 2) + inner_padding;
|
||||||
// Info
|
// 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++) {
|
for (int i = 0; i < info_size; i++) {
|
||||||
Button *button = info_buttons[i];
|
Button *button = info_buttons[i];
|
||||||
button->width = line_button_width;
|
button->width = line_button_width;
|
||||||
@ -243,7 +243,7 @@ struct InfoScreen final : CustomScreen {
|
|||||||
}
|
}
|
||||||
// Cleanup
|
// Cleanup
|
||||||
~InfoScreen() override {
|
~InfoScreen() override {
|
||||||
for (Button *button : super->rendered_buttons) {
|
for (Button *button : self->rendered_buttons) {
|
||||||
button->destructor_deleting();
|
button->destructor_deleting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ struct InfoScreen final : CustomScreen {
|
|||||||
void buttonClicked(Button *button) override {
|
void buttonClicked(Button *button) override {
|
||||||
if (button->id == BACK_ID) {
|
if (button->id == BACK_ID) {
|
||||||
// Back
|
// Back
|
||||||
super->handleBackEvent(false);
|
self->handleBackEvent(false);
|
||||||
} else if (button->id == DISCORD_ID) {
|
} else if (button->id == DISCORD_ID) {
|
||||||
// Open Discord Invite
|
// Open Discord Invite
|
||||||
open_url(MCPI_DISCORD_INVITE);
|
open_url(MCPI_DISCORD_INVITE);
|
||||||
|
@ -60,10 +60,10 @@ struct LavaTexture final : CustomDynamicTexture {
|
|||||||
if (x1 < 0.0f) {
|
if (x1 < 0.0f) {
|
||||||
x1 = 0.0f;
|
x1 = 0.0f;
|
||||||
}
|
}
|
||||||
super->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1);
|
self->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1);
|
||||||
super->pixels[i * 4 + 1] = int(255.0f * x1 * x1);
|
self->pixels[i * 4 + 1] = int(255.0f * x1 * x1);
|
||||||
super->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1);
|
self->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1);
|
||||||
super->pixels[i * 4 + 3] = 255;
|
self->pixels[i * 4 + 3] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -84,7 +84,7 @@ struct LavaSideTexture final : CustomDynamicTexture {
|
|||||||
field_14 = 0;
|
field_14 = 0;
|
||||||
field_18 = 0;
|
field_18 = 0;
|
||||||
field_1C = 0;
|
field_1C = 0;
|
||||||
super->texture_size = 2;
|
self->texture_size = 2;
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
m_data1[i] = 0.0f;
|
m_data1[i] = 0.0f;
|
||||||
m_data2[i] = 0.0f;
|
m_data2[i] = 0.0f;
|
||||||
@ -126,10 +126,10 @@ struct LavaSideTexture final : CustomDynamicTexture {
|
|||||||
if (x1 < 0.0f) {
|
if (x1 < 0.0f) {
|
||||||
x1 = 0.0f;
|
x1 = 0.0f;
|
||||||
}
|
}
|
||||||
super->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1);
|
self->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1);
|
||||||
super->pixels[i * 4 + 1] = int(255.0f * x1 * x1);
|
self->pixels[i * 4 + 1] = int(255.0f * x1 * x1);
|
||||||
super->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1);
|
self->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1);
|
||||||
super->pixels[i * 4 + 3] = 255;
|
self->pixels[i * 4 + 3] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -186,10 +186,10 @@ struct FireTexture final : CustomDynamicTexture {
|
|||||||
if (x < 0.0f) {
|
if (x < 0.0f) {
|
||||||
x = 0.0f;
|
x = 0.0f;
|
||||||
}
|
}
|
||||||
super->pixels[4 * i + 0] = int(x * 155.0f + 100.0f);
|
self->pixels[4 * i + 0] = int(x * 155.0f + 100.0f);
|
||||||
super->pixels[4 * i + 1] = int(x * x * 255.0f);
|
self->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);
|
self->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 + 3] = x >= 0.5f ? 255 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -85,27 +85,27 @@ struct WelcomeScreen final : CustomScreen {
|
|||||||
changelog = touch_create_button(1, "Changelog");
|
changelog = touch_create_button(1, "Changelog");
|
||||||
proceed = touch_create_button(2, "Proceed");
|
proceed = touch_create_button(2, "Proceed");
|
||||||
for (Button *button : {getting_started, changelog, proceed}) {
|
for (Button *button : {getting_started, changelog, proceed}) {
|
||||||
super->rendered_buttons.push_back(button);
|
self->rendered_buttons.push_back(button);
|
||||||
super->selectable_buttons.push_back(button);
|
self->selectable_buttons.push_back(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Rendering
|
// Rendering
|
||||||
void render(const int x, const int y, const float param_1) override {
|
void render(const int x, const int y, const float param_1) override {
|
||||||
// Background
|
// Background
|
||||||
super->renderBackground();
|
self->renderBackground();
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
CustomScreen::render(x, y, param_1);
|
CustomScreen::render(x, y, param_1);
|
||||||
// Text
|
// Text
|
||||||
super->drawCenteredString(super->font, line1, super->width / 2, text_y, 0xFFFFFFFF);
|
self->drawCenteredString(self->font, line1, self->width / 2, text_y, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
// Positioning
|
// Positioning
|
||||||
void setupPositions() override {
|
void setupPositions() override {
|
||||||
CustomScreen::setupPositions();
|
CustomScreen::setupPositions();
|
||||||
position_screen(super->width, super->height);
|
position_screen(self->width, self->height);
|
||||||
}
|
}
|
||||||
// Cleanup
|
// Cleanup
|
||||||
~WelcomeScreen() override {
|
~WelcomeScreen() override {
|
||||||
for (Button *button : super->rendered_buttons) {
|
for (Button *button : self->rendered_buttons) {
|
||||||
button->destructor_deleting();
|
button->destructor_deleting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ struct WelcomeScreen final : CustomScreen {
|
|||||||
open_url(MCPI_DOCUMENTATION CHANGELOG_FILE);
|
open_url(MCPI_DOCUMENTATION CHANGELOG_FILE);
|
||||||
} else if (button == proceed) {
|
} else if (button == proceed) {
|
||||||
mark_welcome_as_shown();
|
mark_welcome_as_shown();
|
||||||
super->minecraft->screen_chooser.setScreen(1);
|
self->minecraft->screen_chooser.setScreen(1);
|
||||||
} else {
|
} else {
|
||||||
CustomScreen::buttonClicked(button);
|
CustomScreen::buttonClicked(button);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user