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

View file

@ -96,10 +96,10 @@ struct logi: public virtual textfield {
}
}
};
void playbuttonfunc();
void quit(){exit(0);}
class test:public program {
#include <boost/process.hpp>
class launcher:public program {
public:
Texture2D bg;
Texture2D buttonfore;
@ -118,7 +118,7 @@ public:
Image img;
bool captured=true;
const char* CONF() final{return "test.tdf";}
test(){};
launcher(){};
void boot() override {
tickrate=15;
framerate=15;
@ -168,7 +168,7 @@ public:
buttonslabel[7]=LoadTexture("res/exit.png");
playbtn[0]=LoadTexture("res/playoff.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*>{
new background(&bg,0,0,600,300),
new textured(&buttonfore,3,36,62,62),
@ -271,6 +271,7 @@ public:
}
};
launcher* launch;
tiny::ErrorLevel tiny::level{8};
int main(int argc, char *argv[]) {
@ -289,14 +290,14 @@ int main(int argc, char *argv[]) {
nete.currentversion=version;
config.setstring({"version"},nete.currentversion);
}
launcher e;
launch=&e;
tiny::echo ("starting net");
nete.start();
tiny::echo ("downloading github info");
nete.github();
tiny::echo ("starting launcher");
test e;
e.boot();
std::atomic<bool> running{true};
std::thread tickthread([&e, &running]() {
@ -339,4 +340,18 @@ int main(int argc, char *argv[]) {
config.save();
config.close();
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);
}
}
}