Add Splash Text From MCPIL

This commit is contained in:
TheBrokenRail 2024-02-07 21:15:48 -05:00
parent ecbcfb2922
commit db22caa50f
8 changed files with 155 additions and 5 deletions

View File

@ -1,12 +1,23 @@
project(launcher)
# Launcher
add_executable(launcher src/bootstrap.c src/patchelf.cpp src/util.c src/crash-report.c src/sdk.c src/mods.c)
add_executable(launcher
src/bootstrap.c
src/patchelf.cpp
src/util.c
src/crash-report.c
src/sdk.c
src/mods.c
)
if(MCPI_SERVER_MODE)
target_sources(launcher PRIVATE src/server/launcher.c)
else()
embed_resource(launcher src/client/available-feature-flags)
target_sources(launcher PRIVATE src/client/launcher.cpp src/client/cache.cpp)
target_sources(launcher PRIVATE
src/client/launcher.cpp
src/client/cache.cpp
src/client/available-feature-flags # Show In IDE
)
endif()
target_link_libraries(launcher reborn-util LIB_LIEF)
# RPath

View File

@ -57,3 +57,4 @@ TRUE Add Cake
TRUE Use Java Beta 1.3 Light Ramp
TRUE Send Full Level When Hosting Game
FALSE Food Overlay
TRUE Add Splashes

View File

@ -90,6 +90,7 @@ else()
src/atlas/atlas.cpp
# title-screen
src/title-screen/title-screen.cpp
src/title-screen/splashes.txt # Show In IDE
# skin
src/skin/skin.cpp
src/skin/loader.cpp
@ -102,6 +103,11 @@ else()
src/text-input-box/TextInputBox.cpp
src/text-input-box/TextInputScreen.cpp
)
# Install Splashes
install(
FILES "src/title-screen/splashes.txt"
DESTINATION "${MCPI_INSTALL_DIR}/data"
)
endif()
# Build

View File

@ -2,4 +2,5 @@
#include <symbols/minecraft.h>
extern int touch_gui;
Button *touch_create_button(int id, std::string text);

View File

@ -0,0 +1,53 @@
(Not) Made by Notch!
@Banana!
As (not) seen on TV!
As seen on Discord!
Awesome community!
Awesome!
BANANA!
Boba was here!
Casual gaming!
Classic!
Create!
Definitely not Minecraft Console!
Didn't remove Herobrine!
Don't look directly at the bugs!
Enhanced!
Exploding Creepers!
FREE!
Fantasy!
I was promised pie!
It's the segment's fault!
Join the Discord!
Keyboard compatible!
Minecraft!
Not Minecraft Java!
Now With Multiplayer!
Now In 3D!
Now without Docker!
Obfuscated!
Oh yeah, that version...
Oh, OK, Pigmen...
Open-source!
Pixels!
Pretty!
RIP MCPIL-Legacy, 2020-2020
RIP Picraft
Segmentation fault
Segmentation fault (core dumped)
Singleplayer!
Survive!
Teh!
unsigend char!
unsigned char!
Try It!
WDYM discontinued?
Watch out for StevePi!
Waterproof!
We fixed the rail!
Where is my pie?
Who broke the rail?
Who is StevePi?
Why must you hurt me?
Wow! Modded MCPI!
mcpi-revival.github.io!

View File

@ -1,18 +1,23 @@
#include <fstream>
#include <cmath>
#include <libreborn/libreborn.h>
#include <symbols/minecraft.h>
#include <GLES/gl.h>
#include <mods/feature/feature.h>
#include <mods/init/init.h>
#include <mods/compat/compat.h>
#include <mods/touch/touch.h>
// Improved Title Screen Background
static void StartMenuScreen_render_Screen_renderBackground_injection(StartMenuScreen *screen) {
static void StartMenuScreen_render_Screen_renderBackground_injection(Screen *screen) {
// Draw
Minecraft *minecraft = screen->minecraft;
Textures *textures = minecraft->textures;
std::string texture = "gui/titleBG.png";
Textures_loadAndBindTexture(textures, &texture);
StartMenuScreen_blit(screen, 0, 0, 0, 0, screen->width, screen->height, 0x100, 0x100);
Screen_blit(screen, 0, 0, 0, 0, screen->width, screen->height, 0x100, 0x100);
}
// Add Buttons Back To Classic Start Screen
@ -43,6 +48,69 @@ static void StartMenuScreen_buttonClicked_injection(StartMenuScreen *screen, But
}
}
// Add Splashes
static Screen *last_screen = nullptr;
static std::string current_splash;
static void StartMenuScreen_render_Screen_render_injection(Screen *screen, int x, int y, float param_1) {
// Call Original Method
Screen_render_non_virtual(screen, x, y, param_1);
// Load Splashes
static std::vector<std::string> splashes;
static bool splashes_loaded = false;
if (!splashes_loaded) {
// Mark As Loaded
splashes_loaded = true;
// Load
std::ifstream stream("data/splashes.txt");
if (stream.good()) {
std::string line;
while (std::getline(stream, line)) {
if (line.length() > 0) {
splashes.push_back(line);
}
}
stream.close();
} else {
WARN("Unable To Load Splashes");
}
}
// Display Splash
if (splashes.size() > 0) {
// Pick Splash
if (last_screen != screen) {
last_screen = screen;
current_splash = splashes[rand() % splashes.size()];
}
// Choose Position
float multiplier = touch_gui ? 0.5f: 1.0f;
float splash_x = (float(screen->width) / 2.0f) + (94.0f * multiplier);
float splash_y = 4.0f + (36.0f * multiplier);
float max_width = 86;
// Draw (From https://github.com/ReMinecraftPE/mcpe/blob/d7a8b6baecf8b3b050538abdbc976f690312aa2d/source/client/gui/screens/StartMenuScreen.cpp#L699-L718)
glPushMatrix();
// Position
glTranslatef(splash_x, splash_y, 0.0f);
glRotatef(-20.0f, 0.0f, 0.0f, 1.0f);
// Scale
int textWidth = Font_width(screen->font, &current_splash);
float timeMS = float(Common_getTimeMs() % 1000) / 1000.0f;
float scale = 2.0f - Mth_abs(0.1f * Mth_sin(2.0f * float(M_PI) * timeMS));
float real_text_width = textWidth * scale;
if (real_text_width > max_width) {
scale *= max_width / real_text_width;
}
scale *= multiplier;
glScalef(scale, scale, scale);
// Render
static int line_height = 8;
Screen_drawCenteredString(screen, screen->font, &current_splash, 0, -(float(line_height) / 2), 0xffff00);
// Finish
glPopMatrix();
}
}
// Init
void init_title_screen() {
// Improved Title Screen Background
@ -84,4 +152,12 @@ void init_title_screen() {
// Add Functionality To Quit Button
patch_address(StartMenuScreen_buttonClicked_vtable_addr, (void *) StartMenuScreen_buttonClicked_injection);
}
// Add Splashes
if (feature_has("Add Splashes", server_disabled)) {
overwrite_call((void *) 0x39764, (void *) StartMenuScreen_render_Screen_render_injection);
overwrite_call((void *) 0x3e0c4, (void *) StartMenuScreen_render_Screen_render_injection);
// Init Random
srand(time(NULL));
}
}

View File

@ -42,7 +42,7 @@ static void LargeImageButton_render_GuiComponent_drawCenteredString_injection(Gu
}
// Create Button
static int touch_gui = 0;
int touch_gui = 0;
Button *touch_create_button(int id, std::string text) {
Button *button = nullptr;
if (touch_gui) {

View File

@ -3,3 +3,5 @@ static-method float random() = 0x777a4;
static-method float sin(float x) = 0x7775c;
static-method float cos(float x) = 0x77728;
static-method float abs(float x) = 0x7781c;
static-method float min(float a, float b) = 0x7782c;