mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
af
This commit is contained in:
parent
21fdab06ef
commit
8ea7f55a2e
8 changed files with 79 additions and 22 deletions
|
|
@ -242,6 +242,7 @@ set(EMBEDDED_INPUT
|
|||
assets/icon.png
|
||||
assets/gamecontrollerdb.txt
|
||||
assets/crash.png
|
||||
assets/the_modded_machine.png
|
||||
binding-mri/module_rpg1.rb
|
||||
)
|
||||
|
||||
|
|
|
|||
BIN
assets/the_modded_machine.png
Normal file
BIN
assets/the_modded_machine.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
|
|
@ -75,14 +75,12 @@ void windowVXBindingInit();
|
|||
void tilemapVXBindingInit();
|
||||
void TimeBindingInit();
|
||||
void SignalConnectionBindingInit();
|
||||
|
||||
void inputBindingInit();
|
||||
void audioPlaybackBindingInit();
|
||||
void audioBindingInit();
|
||||
void graphicsBindingInit();
|
||||
|
||||
void fileIntBindingInit();
|
||||
|
||||
void ModLoaderBindingInit();
|
||||
void journalBindingInit();
|
||||
void wallpaperBindingInit();
|
||||
#ifdef unix_like
|
||||
|
|
@ -93,7 +91,6 @@ void oneshotBindingInit();
|
|||
void SunshineBindingInit();
|
||||
void steamBindingInit();
|
||||
void shaderBindingInit();
|
||||
void ModLoaderBindingInit();
|
||||
void keybindingsBindingInit();
|
||||
void lightmapBindingInit();
|
||||
void ProfilerInit();
|
||||
|
|
@ -148,7 +145,6 @@ static void mriBindingInit(){
|
|||
SunshineBindingInit();
|
||||
steamBindingInit();
|
||||
shaderBindingInit();
|
||||
ModLoader();
|
||||
ModLoaderBindingInit();
|
||||
keybindingsBindingInit();
|
||||
lightmapBindingInit();
|
||||
|
|
@ -168,7 +164,6 @@ static void mriBindingInit(){
|
|||
script[binding_mri_module_rpg1_rb_len] = '\0';
|
||||
|
||||
rb_eval_string(script);
|
||||
|
||||
SDL_free(script);
|
||||
|
||||
VALUE mod = rb_define_module("MKXP");
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
#include "security.h"
|
||||
|
||||
#include "sunshine.h"
|
||||
#include "modloader.h"
|
||||
|
||||
#include "define.h"
|
||||
#include "meow.h"
|
||||
|
|
@ -272,7 +273,6 @@ int main(int argc, char *argv[]){
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern int screenMain(Config &conf);
|
||||
if (conf.screenMode)
|
||||
return screenMain(conf);
|
||||
|
|
@ -348,6 +348,8 @@ int main(int argc, char *argv[]){
|
|||
SDL_GetWindowSize(win, &winW, &winH); // SDL_GL_GetDrawableSize(win, &winW, &winH);
|
||||
rtData.windowSizeMsg.post(Vec2i(winW, winH));
|
||||
|
||||
ModLoader(conf, win);
|
||||
|
||||
/* Load and post key bindings */
|
||||
rtData.bindingUpdateMsg.post(loadBindings(conf));
|
||||
/* Start RGSS thread */
|
||||
|
|
|
|||
10
src/meow.cpp
10
src/meow.cpp
|
|
@ -8,6 +8,9 @@
|
|||
#include <SDL3_image/SDL_image.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
#include <SDL3/SDL_filesystem.h>
|
||||
#include <SDL3/SDL_timer.h>
|
||||
#include <SDL3/SDL_system.h>
|
||||
#include <SDL3/SDL_cpuinfo.h>
|
||||
#include "meow.h"
|
||||
#include "eventthread.h"
|
||||
#include "exception.h"
|
||||
|
|
@ -33,8 +36,6 @@
|
|||
#include <zlib.h>
|
||||
#include <physfs.h>
|
||||
#include <pixman.h>
|
||||
#include <SDL3/SDL_system.h>
|
||||
#include <SDL3/SDL_cpuinfo.h>
|
||||
#include "sunshine.h"
|
||||
#ifdef unix_like
|
||||
#include <gtk/gtk.h>
|
||||
|
|
@ -43,8 +44,6 @@
|
|||
#include <android/api-level.h>
|
||||
#elif web
|
||||
#include <emscripten/console.h>
|
||||
#elif dos
|
||||
#include <dpmi.h>
|
||||
#endif
|
||||
#include "crash.png.xxd"
|
||||
using namespace std;
|
||||
|
|
@ -145,7 +144,7 @@ void crash(Exception::Type t, const char *fmt, ...) {
|
|||
}
|
||||
|
||||
void crash_screen(SDL_Window* win){
|
||||
// Skil Crash screen if failed initialize
|
||||
// Skip Crash screen if failed initialize
|
||||
static bool skip_crash_screen = false;
|
||||
//creating render
|
||||
SDL_Renderer* ren = SDL_CreateRenderer(win, NULL);
|
||||
|
|
@ -306,6 +305,7 @@ void crash_screen(SDL_Window* win){
|
|||
SDL_RenderDebugTextFormat(ren, 10, 70, "If you are sure that the problem is not in your modifications,");
|
||||
SDL_RenderDebugTextFormat(ren, 10, 80, "your hands or in your device - please report the bug to the developers");
|
||||
SDL_RenderPresent(ren);
|
||||
SDL_Delay(32);
|
||||
}
|
||||
SDL_DestroyTexture(tex);
|
||||
SDL_DestroyRenderer(ren);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <string>
|
||||
|
||||
inline std::vector<std::string> logs = {};
|
||||
inline std::vector<std::string> modloader_logs = {};
|
||||
|
||||
inline bool show_crash_sceen = false;
|
||||
inline bool is_privacy_crashdump_enabled = false;
|
||||
|
|
|
|||
|
|
@ -7,23 +7,77 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <system_error>
|
||||
|
||||
#include <physfs.h>
|
||||
|
||||
#include <SDL3/SDL_thread.h>
|
||||
#include <SDL3/SDL_render.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <SDL3/SDL_timer.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
|
||||
#include "the_modded_machine.png.xxd"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void ModLoader() {
|
||||
static bool stop_render = false;
|
||||
const static std::size_t N = 46;
|
||||
|
||||
static void modloader_add_to_log(const std::string data){
|
||||
Debug() << "[MODLOADER] " << data;
|
||||
modloader_logs.push_back(data);
|
||||
}
|
||||
|
||||
static int renderer_thread(void* data){
|
||||
SDL_Window* win = static_cast<SDL_Window*>(data);
|
||||
SDL_Renderer* ren = SDL_CreateRenderer(win, NULL);
|
||||
if (ren == nullptr) {return(0);}
|
||||
SDL_Surface* crash_img = IMG_Load_IO(SDL_IOFromConstMem(assets_the_modded_machine_png, assets_the_modded_machine_png_len), true);
|
||||
if (crash_img == nullptr){
|
||||
SDL_DestroyRenderer(ren);
|
||||
return(0);
|
||||
}
|
||||
SDL_Texture* tex = SDL_CreateTextureFromSurface(ren, crash_img);
|
||||
SDL_DestroySurface(crash_img);
|
||||
if (tex == nullptr) {
|
||||
SDL_DestroyRenderer(ren);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int index_on_screen = 10;
|
||||
while(!stop_render){
|
||||
index_on_screen = 10;
|
||||
SDL_SetRenderDrawColor(ren, 0, 0, 0, 255);
|
||||
SDL_RenderClear(ren);
|
||||
SDL_RenderTexture(ren, tex, NULL, NULL);
|
||||
SDL_SetRenderDrawColor(ren, 109, 0, 198, 255);
|
||||
std::size_t size = modloader_logs.size();
|
||||
std::size_t n = std::min<std::size_t>(static_cast<std::size_t>(N), size);
|
||||
std::size_t start = size > n ? (size - n) : 0;
|
||||
for (std::size_t i = start; i < size; ++i) {
|
||||
SDL_RenderDebugTextFormat(ren, 10, index_on_screen, "%s", modloader_logs[i].c_str());
|
||||
index_on_screen += 10;
|
||||
}
|
||||
SDL_RenderPresent(ren);
|
||||
SDL_Delay(16);
|
||||
}
|
||||
SDL_RenderClear(ren);
|
||||
SDL_RenderPresent(ren);
|
||||
SDL_DestroyTexture(tex);
|
||||
SDL_DestroyRenderer(ren);
|
||||
return(0);
|
||||
}
|
||||
|
||||
void ModLoader(Config conf, SDL_Window* win){
|
||||
std::string path = "mods";
|
||||
if (!fs::exists(path) || !fs::is_directory(path)) {
|
||||
Debug() << "[MODLOADER] Mods directory not found, skip.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (fs::is_empty(path)) {
|
||||
}else if (fs::is_empty(path)) {
|
||||
Debug() << "[MODLOADER] Mods directory empty, skip.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SDL_Thread* render_thread_pointer = SDL_CreateThread(renderer_thread, "ModRenderer", win);
|
||||
std::vector<std::string> mod_list = {};
|
||||
try {
|
||||
// 1.check if any zip(mod) file, 2. calculate sha256 hash of zip(mod) files 3.mount mod via PhysFS
|
||||
|
|
@ -37,16 +91,18 @@ void ModLoader() {
|
|||
|
||||
if (ext == ".zip") {
|
||||
int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0);
|
||||
(void)ok; // если не используете ok дальше
|
||||
Debug() << "[MODLOADER] " << full;
|
||||
mod_list.push_back(full);
|
||||
modloader_add_to_log("Added mod " + full);
|
||||
mods_count++;
|
||||
} else if (ext == ".rb") {
|
||||
preloadScripts.insert(full);
|
||||
Debug() << "[MODLOADER] Loading Preload Script: " << full;
|
||||
modloader_add_to_log("Added script " + full);
|
||||
preloaded_script_count++;
|
||||
}
|
||||
}
|
||||
sleep(1);
|
||||
stop_render = true;
|
||||
SDL_WaitThread(render_thread_pointer, NULL);
|
||||
modloader_is_enabled = true;
|
||||
} catch (const std::exception& e) {
|
||||
crash(Exception::ModLoaderError, "Something is wrong, Exception: %s ", e.what());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <string>
|
||||
#include <set>
|
||||
void ModLoader();
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include "config.h"
|
||||
void ModLoader(Config conf, SDL_Window* win);
|
||||
|
||||
inline bool modloader_is_enabled = false;
|
||||
inline unsigned int mods_count = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue