Show Reborn Version In Start Screen

This commit is contained in:
TheBrokenRail 2021-06-28 16:00:52 -04:00
parent 2b0d1d55ff
commit 053bf4aa5f
18 changed files with 88 additions and 13 deletions

View File

@ -94,6 +94,10 @@ if(MCPI_SERVER_MODE)
add_definitions(-DMCPI_SERVER_MODE) add_definitions(-DMCPI_SERVER_MODE)
endif() endif()
# Version
file(STRINGS VERSION VERSION)
add_definitions(-DVERSION="${VERSION}")
# Build libreborn # Build libreborn
add_subdirectory(libreborn) add_subdirectory(libreborn)

View File

@ -1,6 +1,7 @@
# Changelog # Changelog
**2.0.5** **2.0.5**
* Show Reborn Version In Start Screen
* External Server Support * External Server Support
**2.0.4** **2.0.4**

View File

@ -3,7 +3,7 @@ Name=Minecraft: Pi Edition: Reborn
Comment=Fun with Blocks Comment=Fun with Blocks
Icon=/usr/share/pixmaps/minecraft-pi-reborn-client.png Icon=/usr/share/pixmaps/minecraft-pi-reborn-client.png
StartupNotify=false StartupNotify=false
StartupWMClass=Minecraft - Pi edition StartupWMClass=Minecraft: Pi Edition: Reborn
Exec=/usr/bin/minecraft-pi-reborn-client Exec=/usr/bin/minecraft-pi-reborn-client
Terminal=false Terminal=false
Type=Application Type=Application

View File

@ -106,7 +106,7 @@ static void run_zenity_and_set_env(const char *env_name, std::vector<std::string
std::vector<std::string> full_command; std::vector<std::string> full_command;
full_command.push_back("zenity"); full_command.push_back("zenity");
full_command.push_back("--class"); full_command.push_back("--class");
full_command.push_back("Minecraft - Pi edition"); full_command.push_back("Minecraft: Pi Edition: Reborn");
full_command.insert(full_command.end(), command.begin(), command.end()); full_command.insert(full_command.end(), command.begin(), command.end());
// Convert To C Array // Convert To C Array
const char *full_command_array[full_command.size() + 1]; const char *full_command_array[full_command.size() + 1];

View File

@ -17,6 +17,7 @@ static renderCursor_t renderCursor = (renderCursor_t) 0x480c4;
static char **default_path = (char **) 0xe264; // /.minecraft/ static char **default_path = (char **) 0xe264; // /.minecraft/
static char **default_username = (char **) 0x18fd4; // StevePi static char **default_username = (char **) 0x18fd4; // StevePi
static char **minecraft_pi_version = (char **) 0x39d94; // v0.1.1 alpha
static unsigned char **Item_flintAndSteel = (unsigned char **) 0x17ba70; static unsigned char **Item_flintAndSteel = (unsigned char **) 0x17ba70;
static unsigned char **Item_snowball = (unsigned char **) 0x17bbb0; static unsigned char **Item_snowball = (unsigned char **) 0x17bbb0;
@ -477,6 +478,11 @@ static SelectWorldScreen_getUniqueLevelName_t SelectWorldScreen_getUniqueLevelNa
static SelectWorldScreen_getUniqueLevelName_t Touch_SelectWorldScreen_getUniqueLevelName = (SelectWorldScreen_getUniqueLevelName_t) 0x3d82c; static SelectWorldScreen_getUniqueLevelName_t Touch_SelectWorldScreen_getUniqueLevelName = (SelectWorldScreen_getUniqueLevelName_t) 0x3d82c;
// Common
typedef std::string (*Common_getGameVersionString_t)(std::string const& version_suffix);
static Common_getGameVersionString_t Common_getGameVersionString = (Common_getGameVersionString_t) 0x15068;
#endif #endif
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

View File

@ -15,9 +15,12 @@ add_library(readdir SHARED src/readdir/readdir.c)
add_library(feature SHARED src/feature/feature.c) add_library(feature SHARED src/feature/feature.c)
target_link_libraries(feature reborn) target_link_libraries(feature reborn)
add_library(version SHARED src/version/version.cpp)
target_link_libraries(version reborn)
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
add_library(server SHARED src/server/server.cpp src/server/server_properties.cpp) add_library(server SHARED src/server/server.cpp src/server/server_properties.cpp)
target_link_libraries(server reborn feature home compat dl media-layer-core pthread) target_link_libraries(server reborn feature home compat version dl media-layer-core pthread)
else() else()
add_library(multiplayer SHARED src/multiplayer/multiplayer.cpp) add_library(multiplayer SHARED src/multiplayer/multiplayer.cpp)
target_link_libraries(multiplayer reborn home) target_link_libraries(multiplayer reborn home)
@ -60,7 +63,7 @@ add_library(test SHARED src/test/test.c)
target_link_libraries(test reborn home) target_link_libraries(test reborn home)
add_library(init SHARED src/init/init.c) add_library(init SHARED src/init/init.c)
target_link_libraries(init compat game_mode camera input misc death options touch textures chat home test) target_link_libraries(init compat game_mode camera input misc death options touch textures chat home version test)
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
target_link_libraries(init server) target_link_libraries(init server)
else() else()
@ -68,7 +71,7 @@ else()
endif() endif()
## Install Mods ## Install Mods
install(TARGETS init compat readdir feature override game_mode camera input misc death options touch textures chat home test DESTINATION "${MCPI_INSTALL_DIR}/mods") install(TARGETS init compat readdir feature override game_mode camera input misc death options touch textures chat home version test DESTINATION "${MCPI_INSTALL_DIR}/mods")
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
install(TARGETS server DESTINATION "${MCPI_INSTALL_DIR}/mods") install(TARGETS server DESTINATION "${MCPI_INSTALL_DIR}/mods")
else() else()

View File

@ -42,7 +42,7 @@ unsigned int chat_get_counter() {
static void *chat_thread(__attribute__((unused)) void *nop) { static void *chat_thread(__attribute__((unused)) void *nop) {
// Open // Open
int return_code; int return_code;
char *output = run_command("zenity --title \"Chat\" --class \"Minecraft - Pi edition\" --entry --text \"Enter Chat Message:\"", &return_code); char *output = run_command("zenity --title 'Chat' --class 'Minecraft: Pi Edition: Reborn' --entry --text 'Enter Chat Message:'", &return_code);
// Handle Message // Handle Message
if (output != NULL) { if (output != NULL) {
// Check Return Code // Check Return Code

View File

@ -12,6 +12,12 @@
#include "../init/init.h" #include "../init/init.h"
#include "compat.h" #include "compat.h"
// Custom Title
HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) {
ensure_SDL_WM_SetCaption();
(*real_SDL_WM_SetCaption)("Minecraft: Pi Edition: Reborn", icon);
}
// Mouse Cursor Is Always Invisible In Vanilla MCPI // Mouse Cursor Is Always Invisible In Vanilla MCPI
// Because In Vanilla MCPI, The GPU Overlay Covered The Normal Mouse Cursor // Because In Vanilla MCPI, The GPU Overlay Covered The Normal Mouse Cursor
HOOK(SDL_ShowCursor, int, (int toggle)) { HOOK(SDL_ShowCursor, int, (int toggle)) {

View File

@ -31,10 +31,18 @@ HOOK(getenv, char *, (const char *name)) {
// Get MCPI Home Directory // Get MCPI Home Directory
char *home_get() { char *home_get() {
char *dir = NULL; static char *dir = NULL;
// Load
if (dir == NULL) {
safe_asprintf(&dir, "%s/" NEW_PATH, getenv("HOME")); safe_asprintf(&dir, "%s/" NEW_PATH, getenv("HOME"));
}
// Return
return dir; return dir;
} }
// Free
__attribute__((destructor)) static void _free_home() {
free(home_get());
}
// Init // Init
void init_home() { void init_home() {

View File

@ -4,7 +4,7 @@
extern "C" { extern "C" {
#endif #endif
char *home_get(); // Remember To free() char *home_get();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -18,4 +18,5 @@ __attribute__((constructor)) static void init() {
init_textures(); init_textures();
init_chat(); init_chat();
init_home(); init_home();
init_version();
} }

View File

@ -21,6 +21,7 @@ void init_touch();
void init_textures(); void init_textures();
void init_chat(); void init_chat();
void init_home(); void init_home();
void init_version();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -20,8 +20,6 @@ static char *get_override_path(const char *filename) {
// Get Asset Override Path // Get Asset Override Path
char *overrides = NULL; char *overrides = NULL;
safe_asprintf(&overrides, "%s/overrides", home_path); safe_asprintf(&overrides, "%s/overrides", home_path);
// Free Home Path
free(home_path);
// Get Data Path // Get Data Path
char *data = NULL; char *data = NULL;
char *cwd = getcwd(NULL, 0); char *cwd = getcwd(NULL, 0);

View File

@ -23,6 +23,7 @@
#include "../init/init.h" #include "../init/init.h"
#include "../home/home.h" #include "../home/home.h"
#include "../compat/compat.h" #include "../compat/compat.h"
#include "../version/version.h"
#include <libreborn/minecraft.h> #include <libreborn/minecraft.h>
@ -65,7 +66,7 @@ static std::string get_world_name() {
// Create/Start World // Create/Start World
static void start_world(unsigned char *minecraft) { static void start_world(unsigned char *minecraft) {
INFO("%s", "Starting Minecraft: Pi Edition Dedicated Server"); INFO("Starting Minecraft: Pi Edition: Dedicated Server (%s)", version_get());
// Specify Level Settings // Specify Level Settings
LevelSettings settings; LevelSettings settings;

View File

@ -13,7 +13,6 @@ void run_tests() {
char *path = home_get(); char *path = home_get();
int exists = access(path, F_OK) == 0; int exists = access(path, F_OK) == 0;
int can_write = exists ? access(path, R_OK | W_OK) == 0 : 1; int can_write = exists ? access(path, R_OK | W_OK) == 0 : 1;
free(path);
if (!can_write) { if (!can_write) {
// Failure // Failure

View File

@ -0,0 +1,2 @@
# ``version`` Mod
This mod adds the MCPI-Reborn version to the start screen.

View File

@ -0,0 +1,34 @@
#include <libreborn/libreborn.h>
#include <libreborn/minecraft.h>
#include "version.h"
#include "../init/init.h"
// Get New Version
char *version_get() {
static char *version = NULL;
// Load
if (version == NULL) {
safe_asprintf(&version, "%s / Reborn v" VERSION, *minecraft_pi_version);
}
// Return
return version;
}
// Free
__attribute__((destructor)) static void _free_version() {
free(version_get());
}
// Injection For Touch GUI Version
static std::string Common_getGameVersionString_injection(__attribute__((unused)) std::string const& version_suffix) {
// Set Version
return version_get();
}
// Init
void init_version() {
// Touch GUI
overwrite((void *) Common_getGameVersionString, (void *) Common_getGameVersionString_injection);
// Normal GUI
patch_address((void *) minecraft_pi_version, version_get());
}

View File

@ -0,0 +1,11 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
char *version_get();
#ifdef __cplusplus
}
#endif