making launcher close when open game

This commit is contained in:
kin fuyuki 2025-12-24 15:01:59 -03:00
commit 2b62c95db4
No known key found for this signature in database
GPG key ID: 0E4E8E519FB71401
2 changed files with 26 additions and 11 deletions

View file

@ -2,13 +2,13 @@
#include <raylib.h> #include <raylib.h>
#include <enginend/scenes/node2d.h> #include <enginend/scenes/node2d.h>
using namespace enginend; using namespace enginend;
class test:public program { class launcher:public program {
public: public:
bool vsync = true; bool vsync = true;
scene s; scene s;
const char* CONF() final{return "test.tdf";} const char* CONF() final{return "test.tdf";}
test(){}; launcher(){};
void boot() override { void boot() override {
SetConfigFlags(FLAG_VSYNC_HINT); SetConfigFlags(FLAG_VSYNC_HINT);
InitWindow(500,500,"test"); InitWindow(500,500,"test");
@ -42,7 +42,7 @@ public:
tiny::ErrorLevel tiny::level{6}; tiny::ErrorLevel tiny::level{6};
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
tiny::startup((char*)"enginend test",(char*)"1.0"); tiny::startup((char*)"enginend test",(char*)"1.0");
test e; launcher e;
e.boot(); e.boot();
while (!WindowShouldClose()) { while (!WindowShouldClose()) {
e.tick(); e.tick();

View file

@ -96,10 +96,10 @@ struct logi: public virtual textfield {
} }
} }
}; };
void playbuttonfunc();
void quit(){exit(0);} void quit(){exit(0);}
#include <boost/process.hpp>
class test:public program { class launcher:public program {
public: public:
Texture2D bg; Texture2D bg;
Texture2D buttonfore; Texture2D buttonfore;
@ -118,7 +118,7 @@ public:
Image img; Image img;
bool captured=true; bool captured=true;
const char* CONF() final{return "test.tdf";} const char* CONF() final{return "test.tdf";}
test(){}; launcher(){};
void boot() override { void boot() override {
tickrate=15; tickrate=15;
framerate=15; framerate=15;
@ -168,7 +168,7 @@ public:
buttonslabel[7]=LoadTexture("res/exit.png"); buttonslabel[7]=LoadTexture("res/exit.png");
playbtn[0]=LoadTexture("res/playoff.png"); playbtn[0]=LoadTexture("res/playoff.png");
playbtn[1]=LoadTexture("res/playon.png"); playbtn[1]=LoadTexture("res/playon.png");
playbutton= new button(&playbtn[0], {255,255,255,255},406,(18*11)+17+9,153,59,nullptr); playbutton= new button(&playbtn[0], {255,255,255,255},406,(18*11)+17+9,153,59,std::function<void()>(playbuttonfunc));
s.nodes=std::list<node*>{ s.nodes=std::list<node*>{
new background(&bg,0,0,600,300), new background(&bg,0,0,600,300),
new textured(&buttonfore,3,36,62,62), new textured(&buttonfore,3,36,62,62),
@ -271,6 +271,7 @@ public:
} }
}; };
launcher* launch;
tiny::ErrorLevel tiny::level{8}; tiny::ErrorLevel tiny::level{8};
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@ -289,14 +290,14 @@ int main(int argc, char *argv[]) {
nete.currentversion=version; nete.currentversion=version;
config.setstring({"version"},nete.currentversion); config.setstring({"version"},nete.currentversion);
} }
launcher e;
launch=&e;
tiny::echo ("starting net"); tiny::echo ("starting net");
nete.start(); nete.start();
tiny::echo ("downloading github info"); tiny::echo ("downloading github info");
nete.github(); nete.github();
tiny::echo ("starting launcher"); tiny::echo ("starting launcher");
test e;
e.boot(); e.boot();
std::atomic<bool> running{true}; std::atomic<bool> running{true};
std::thread tickthread([&e, &running]() { std::thread tickthread([&e, &running]() {
@ -339,4 +340,18 @@ int main(int argc, char *argv[]) {
config.save(); config.save();
config.close(); config.close();
return 0; return 0;
} }
void playbuttonfunc() {
if (nete.currentversion!="NULL") {
FILE* gameexe = fopen(("forespend/versions/"+nete.currentversion+"/bin/game").c_str(), "r");
if (gameexe) {
fclose(gameexe);
std::thread thread([]() {
boost::process::system("bin/game",boost::process::start_dir=("forespend/versions/"+nete.currentversion));
});
exit(0);
}
}
}