diff --git a/CMakeLists.txt b/CMakeLists.txt index a89850c..2ff3595 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,4 +8,5 @@ else() endif() add_subdirectory(engine) add_subdirectory(games/forespend) +add_subdirectory(games/endlauncher) include(ExternalProject) \ No newline at end of file diff --git a/built/launcher/linux/res/btn.png b/built/launcher/linux/res/btn.png new file mode 100644 index 0000000..f68b8a0 Binary files /dev/null and b/built/launcher/linux/res/btn.png differ diff --git a/built/launcher/linux/res/btnhover.png b/built/launcher/linux/res/btnhover.png new file mode 100644 index 0000000..75814fa Binary files /dev/null and b/built/launcher/linux/res/btnhover.png differ diff --git a/built/launcher/linux/res/btnpress.png b/built/launcher/linux/res/btnpress.png new file mode 100644 index 0000000..2a6b800 Binary files /dev/null and b/built/launcher/linux/res/btnpress.png differ diff --git a/built/launcher/linux/res/exit.png b/built/launcher/linux/res/exit.png new file mode 100644 index 0000000..328384c Binary files /dev/null and b/built/launcher/linux/res/exit.png differ diff --git a/built/launcher/linux/res/forebutton.png b/built/launcher/linux/res/forebutton.png new file mode 100644 index 0000000..d38eddc Binary files /dev/null and b/built/launcher/linux/res/forebutton.png differ diff --git a/built/launcher/linux/res/forebuttonon.png b/built/launcher/linux/res/forebuttonon.png new file mode 100644 index 0000000..5c0c010 Binary files /dev/null and b/built/launcher/linux/res/forebuttonon.png differ diff --git a/built/launcher/linux/res/forums.png b/built/launcher/linux/res/forums.png new file mode 100644 index 0000000..5611d84 Binary files /dev/null and b/built/launcher/linux/res/forums.png differ diff --git a/built/launcher/linux/res/launcher.png b/built/launcher/linux/res/launcher.png new file mode 100644 index 0000000..72a1c40 Binary files /dev/null and b/built/launcher/linux/res/launcher.png differ diff --git a/built/launcher/linux/res/lockbutton.png b/built/launcher/linux/res/lockbutton.png new file mode 100644 index 0000000..1bddb89 Binary files /dev/null and b/built/launcher/linux/res/lockbutton.png differ diff --git a/built/launcher/linux/res/options.png b/built/launcher/linux/res/options.png new file mode 100644 index 0000000..b349c23 Binary files /dev/null and b/built/launcher/linux/res/options.png differ diff --git a/built/launcher/linux/res/playoff.png b/built/launcher/linux/res/playoff.png new file mode 100644 index 0000000..d5ef220 Binary files /dev/null and b/built/launcher/linux/res/playoff.png differ diff --git a/built/launcher/linux/res/playon.png b/built/launcher/linux/res/playon.png new file mode 100644 index 0000000..48a57fc Binary files /dev/null and b/built/launcher/linux/res/playon.png differ diff --git a/built/launcher/linux/res/showcase.ttf b/built/launcher/linux/res/showcase.ttf new file mode 100644 index 0000000..3566ebf Binary files /dev/null and b/built/launcher/linux/res/showcase.ttf differ diff --git a/built/launcher/linux/res/update.png b/built/launcher/linux/res/update.png new file mode 100644 index 0000000..c47f0ca Binary files /dev/null and b/built/launcher/linux/res/update.png differ diff --git a/built/launcher/linux/res/verify.png b/built/launcher/linux/res/verify.png new file mode 100644 index 0000000..207bd09 Binary files /dev/null and b/built/launcher/linux/res/verify.png differ diff --git a/built/launcher/linux/res/versions.png b/built/launcher/linux/res/versions.png new file mode 100644 index 0000000..f080aac Binary files /dev/null and b/built/launcher/linux/res/versions.png differ diff --git a/built/launcher/linux/res/website.png b/built/launcher/linux/res/website.png new file mode 100644 index 0000000..58ad3a7 Binary files /dev/null and b/built/launcher/linux/res/website.png differ diff --git a/engine/src/scenes/node2d.h b/engine/src/scenes/node2d.h index b022f49..a624a55 100644 --- a/engine/src/scenes/node2d.h +++ b/engine/src/scenes/node2d.h @@ -2,7 +2,6 @@ #include #include "nodes.h" -#include namespace enginend { struct node2d :public node { @@ -18,14 +17,14 @@ namespace enginend { } }; struct textured :virtual public rect{ - int ID; + Texture2D* texture; textured(){} - textured(int id,float x,float y,float w, float h):ID(id){ + textured(Texture2D* texture,float x,float y,float w, float h):texture(texture){ this->pos=Vector2{x,y};this->size=Vector2{w,h}; } void boot()override{} void tick()override{} - void draw()override{DrawTexture(LoadTexture(""),pos.x,pos.y,WHITE);} + void draw()override{if (texture!=nullptr)DrawTexture(*texture,pos.x,pos.y,WHITE);} void exit()override{} }; struct colored :virtual public rect{ @@ -41,15 +40,15 @@ namespace enginend { }; struct tinted :virtual public colored, virtual public textured{ tinted(){} - tinted(int id,Color color,float x,float y,float w, float h): + tinted(Texture2D* texture,Color color,float x,float y,float w, float h): node2d(x, y), rect(x, y, w, h), colored(color, x, y, w, h), - textured(id, x, y, w, h) + textured(texture, x, y, w, h) {} void boot()override{this->colored::boot();this->textured::boot();} void tick()override{this->colored::tick();this->textured::tick();} - void draw()override{DrawTexture(LoadTexture(""),pos.x,pos.y,c);} + void draw()override{if (texture!=nullptr)DrawTexture(*texture,pos.x,pos.y,c);} void exit()override{this->colored::exit();this->textured::exit();} }; struct text :public tinted { @@ -61,10 +60,10 @@ namespace enginend { Color textcolor; std::string content; text(){ fontsize = 20; } - text(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt): + text(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt): font(f),fontsize(fs),content(txt) { - this->pos=Vector2{x,y};this->size=Vector2{w,h};this->ID=id;this->c=color;this->textcolor=textcol; + this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color;this->textcolor=textcol; result=content; size_t initpos = 0; @@ -101,8 +100,8 @@ namespace enginend { std::function function; bool pressed; button():pressed(false){} - button(int id,Color color,float x,float y,float w,float h,std::function func):function(func),pressed(false){ - this->pos=Vector2{x,y};this->size=Vector2{x,y};this->ID=id;this->c=color; + button(Texture2D* texture,Color color,float x,float y,float w,float h,std::function func):function(func),pressed(false){ + this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color; } void boot()override{this->tinted::boot();} void tick()override{ @@ -112,16 +111,50 @@ namespace enginend { if(function)function(); } } - void draw()override{DrawRectangle(pos.x,pos.y,size.x,size.y,c);} + void draw()override { + if (this->texture!=nullptr)DrawTexture(*texture,pos.x,pos.y,c); + else + DrawRectangle(pos.x,pos.y,size.x,size.y,c); + } void exit()override{this->tinted::exit();} }; + struct labeledbutton :virtual public button { + std::string label; + Font font; + int fontsize; + Color textcolor; + labeledbutton(std::string name,Texture2D* texture,Color color,Color text, + float x,float y,float w,float h,std::function func, + Font f,int size):font(f), fontsize(size),textcolor(text){ + this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color; + this->function=func;this->pressed=false; + this->label=name; + + } + + void boot()override{this->button::boot();} + void tick()override{ + this->button::tick(); + } + void draw()override{ + this->button::draw(); + + Vector2 textsize = MeasureTextEx(font, label.c_str(), fontsize, 1); + Vector2 textpos = { + pos.x + (size.x - textsize.x)/2, + pos.y + (size.y - textsize.y)/2 + }; + DrawTextEx(font, label.c_str(), textpos, fontsize, 1, textcolor); + } + void exit()override{this->button::exit();} + }; struct slider :virtual public tinted{ float value; float minvalue; float maxvalue; slider():value(0),minvalue(0),maxvalue(1){} - slider(int id,Color color,float x,float y,float w,float h,float min,float max,float val):value(val),minvalue(min),maxvalue(max){ - this->pos=Vector2{x,y};this->size=Vector2{x,y};this->ID=id;this->c=color; + slider(Texture2D* texture,Color color,float x,float y,float w,float h,float min,float max,float val):value(val),minvalue(min),maxvalue(max){ + this->pos=Vector2{x,y};this->size=Vector2{x,y};this->texture=texture;this->c=color; } void boot()override{this->tinted::boot();} void tick()override{ @@ -143,8 +176,8 @@ namespace enginend { }; struct textfield :public text{ textfield(){} - textfield(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt): - text(id,textcol,color,x,y,w,h,f,fs,txt){} + textfield(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt): + text(texture,textcol,color,x,y,w,h,f,fs,txt){} void boot()override{this->text::boot();} void tick()override{this->text::tick();} void draw()override{ @@ -165,8 +198,8 @@ namespace enginend { bool active; int cursorpos; textinput():active(false),cursorpos(0){} - textinput(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0){ - this->pos=Vector2{x,y};this->size=Vector2{x,y};this->ID=id;this->c=color;this->font=f;this->content=""; + textinput(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0){ + this->pos=Vector2{x,y};this->size=Vector2{x,y};this->texture=texture;this->c=color;this->font=f;this->content=""; this->textcolor=textcol;this->fontsize=fs; } void boot()override{this->text::boot();} @@ -201,8 +234,8 @@ namespace enginend { bool active; int cursorpos; textinputfield():active(false),cursorpos(0){} - textinputfield(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0), - textfield(id,textcol,color,x,y,w,h,f,fs,""){} + textinputfield(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0), + textfield(texture,textcol,color,x,y,w,h,f,fs,""){} void boot()override{this->textfield::boot();} void tick()override{ this->textfield::tick(); diff --git a/engine/src/scenes/nodes.h b/engine/src/scenes/nodes.h index b64be56..2def91f 100644 --- a/engine/src/scenes/nodes.h +++ b/engine/src/scenes/nodes.h @@ -2,6 +2,7 @@ #include "../gr.h" #include "../aud.h" #include "../net.h" +#include namespace enginend { struct node{ diff --git a/engine/src/scenes/scene.h b/engine/src/scenes/scene.h index e6a205b..35a24ea 100644 --- a/engine/src/scenes/scene.h +++ b/engine/src/scenes/scene.h @@ -6,11 +6,16 @@ namespace enginend { struct scene{ std::list nodes; virtual void boot() { + int i=0; + tiny::echo((char*)"initializing scene"); for (enginend::node* n : nodes) { + tiny::echo((char*)"initializing object of ID: %i",i++); n->boot(); } } virtual void draw() { + + ClearBackground(BLANK); BeginDrawing(); for (enginend::node* n : nodes) { n->draw(); diff --git a/engine/test.cpp b/engine/test.cpp index 5296f9b..f60786c 100644 --- a/engine/test.cpp +++ b/engine/test.cpp @@ -17,7 +17,7 @@ public: s.nodes=std::list{ new colored(Color{255,255,255,255},0,0,500,500), - new textfield(0,Color{255,127,127,255},Color{127,127,127,255} + new textfield(nullptr,Color{255,127,127,255},Color{127,127,127,255} ,100,100,220,32,GetFontDefault(),32, "welcome to enginend!\n" "hehe" diff --git a/engine/test/libenginend.so b/engine/test/libenginend.so new file mode 120000 index 0000000..d81c6b5 --- /dev/null +++ b/engine/test/libenginend.so @@ -0,0 +1 @@ +link/libenginend.so \ No newline at end of file diff --git a/games/endlauncher/CMakeLists.txt b/games/endlauncher/CMakeLists.txt new file mode 100644 index 0000000..670fd61 --- /dev/null +++ b/games/endlauncher/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.20) + +set(CMAKE_CXX_FLAGS "-std=c++17 -g -Wno-error") +file(GLOB_RECURSE ENDLAUNCHER "src/*.cpp") +add_executable(endlauncher ${ENDLAUNCHER}) + +set_target_properties(endlauncher PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built/launcher/${PLATFORM_DIR}" +) +target_link_directories( + endlauncher PUBLIC + "${CMAKE_SOURCE_DIR}/link") +target_link_libraries(endlauncher PRIVATE + "${CMAKE_SOURCE_DIR}/link/libenginend.so" + "${CMAKE_SOURCE_DIR}/link/libdesktopraylib.so" + curl zip +) +target_include_directories(endlauncher PUBLIC + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/lib/raylib/build/raylib/include + ${CMAKE_SOURCE_DIR}/engine/include +) \ No newline at end of file diff --git a/games/endlauncher/src/main.cpp b/games/endlauncher/src/main.cpp new file mode 100644 index 0000000..97d7f0b --- /dev/null +++ b/games/endlauncher/src/main.cpp @@ -0,0 +1,197 @@ +#include +#include +#include +#include "netio.h" +using namespace enginend; +struct background: public virtual textured { + background(Texture2D* texture,float x,float y,float w, float h) { + this->pos=Vector2{x,y};this->size=Vector2{w,h}; + this->texture=texture; + this->justclicked=false; + + } + void boot()override{ + img=LoadImageFromTexture(*this->texture); + } + void tick()override { + + Vector2 mp = Vector2(GetMousePositionDesktop()); + Vector2 wp = GetWindowPosition(); + Vector2 rp=Vector2{mp.x-wp.x,mp.y-wp.y}; + if (IsMouseButtonDown(0)) { + if (rp.x >= 0 && rp.y >= 0 && rp.x < 600 && rp.y < 300) { + Color pix = GetImageColor(img, (int)rp.x, (int)(300 - rp.y)); + if (pix.a != 0) { + + if (clicked==false) { + clicked=true; + relmouse = rp; + } + } + } + }else { + clicked=false; + } + if (clicked) { + + Vector2 nwp{ + mp.x-relmouse.x, mp.y-relmouse.y + }; + //todo: implement proper multi-monitor lmaooo + int it =GetMonitorCount(); + RenderTexture rt; + for (int i=0;i=mtp.x && mp.y>=mtp.y && mp.xmaxwpx?maxwpx:newwpx; + newwpy=newwpy>maxwpy?maxwpy:newwpy; + SetWindowPosition(newwpx,newwpy); + } + } + void draw()override{this->textured::draw();} + void exit()override{} +private: + Image img;bool justclicked;bool clicked=false; + Vector2 relmouse; +}; + + +class test:public program { +public: + Texture2D bg; + Texture2D buttonfore; + Texture2D buttonlock; + Texture2D playbtn[2]; + Texture2D menubtn[3]; + button* buttons[8]; + Texture2D buttonslabel[8]; + Font gamename; + bool vsync = true; + scene s; + RenderTexture2D target; + Image img; + bool captured=true; + const char* CONF() final{return "test.tdf";} + test(){}; + void boot() override { + tickrate=10; + framerate=10; + SetConfigFlags(FLAG_VSYNC_HINT|FLAG_WINDOW_UNDECORATED|FLAG_WINDOW_TRANSPARENT); + tiny::error("is transparent lol"); + InitWindow(600,300,"test");target = LoadRenderTexture(600, 300); + img = GenImageColor(600, 300, BLANK); + SetTargetFPS(GetMonitorRefreshRate(GetCurrentMonitor())); + this->tickrate=GetMonitorRefreshRate(GetCurrentMonitor()); + bg=LoadTexture("res/launcher.png"); + buttonfore=LoadTexture("res/forebuttonon.png"); + buttonlock=LoadTexture("res/lockbutton.png"); + gamename=LoadFont("res/showcase.ttf"); + menubtn[0]=LoadTexture("res/btn.png"); + menubtn[1]=LoadTexture("res/btnhover.png"); + menubtn[2]=LoadTexture("res/btnpress.png"); + SetTraceLogLevel(LOG_ERROR); + //468 + //58 + buttons[0]= new button(&menubtn[0], {255,255,255,255},468,58,96,16,nullptr); + buttonslabel[0]=LoadTexture("res/options.png"); + buttons[1]= new button(&menubtn[0], {255,255,255,255},468,58+(18*1),96,16,nullptr); + buttonslabel[1]=LoadTexture("res/website.png"); + buttons[2]= new button(&menubtn[0], {255,255,255,255},468,58+(18*2),96,16,nullptr); + buttonslabel[2]=LoadTexture("res/forums.png"); + buttons[3]= new button(&menubtn[0], {255,255,255,255},468,58+(18*3),96,16,nullptr); + buttons[4]= new button(&menubtn[0], {255,255,255,255},468,58+(18*4),96,16,nullptr); + buttonslabel[4]=LoadTexture("res/update.png"); + buttons[5]= new button(&menubtn[0], {255,255,255,255},468,58+(18*5),96,16,nullptr); + buttonslabel[5]=LoadTexture("res/verify.png"); + buttons[6]= new button(&menubtn[0], {255,255,255,255},468,58+(18*6)+15,96,16,nullptr); + buttonslabel[6]=LoadTexture("res/versions.png"); + buttons[7]= new button(&menubtn[0], {255,255,255,255},468,58+(18*7)+17,96,16,nullptr); + buttonslabel[7]=LoadTexture("res/exit.png"); + playbtn[0]=LoadTexture("res/playoff.png"); + playbtn[1]=LoadTexture("res/playon.png"); + s.nodes=std::list{ + new background(&bg,0,0,600,300), + new textured(&buttonfore,3,36,62,62), + new textured(&buttonlock,3,36+((62+4)*1),62,62), + new textured(&buttonlock,3,36+((62+4)*2),62,62), + new textured(&buttonlock,3,36+((62+4)*3),62,62), + new text(nullptr,Color{0,255,0,255},{0,0,0,0},232,19,1,1,gamename,16,"FORESPEND"), + buttons[0],new textured(&buttonslabel[0],468,58,96,16), + buttons[1],new textured(&buttonslabel[1],468,58+(18*1),96,16), + buttons[2],new textured(&buttonslabel[2],468,58+(18*2),96,16), + buttons[3],//new textured(&buttonslabel[3],468,58+(18*3),96,16), + buttons[4],new textured(&buttonslabel[4],468,58+(18*4),96,16), + buttons[5],new textured(&buttonslabel[5],468,58+(18*5),96,16), + buttons[6],new textured(&buttonslabel[6],468,58+(18*6)+15,96,16), + buttons[7],new textured(&buttonslabel[7],468,58+(18*7)+17,96,16), + new button(&playbtn[0], {255,255,255,255},406,(18*11)+17+9,153,59,nullptr), + + }; + s.boot(); + + } + void tick() override { + if (shouldtick()) { + s.tick(); + } + + } + void draw() override { + BeginTextureMode(target); + s.draw(); + EndTextureMode(); + + BeginDrawing(); + ClearBackground(BLANK); + DrawTexturePro(target.texture, {0, 0, 600, -300}, {0, 0, 600, 300}, {0, 0}, 0, WHITE); + EndDrawing(); + + Vector2 mp = Vector2(GetMousePositionDesktop()); + Vector2 wp = GetWindowPosition(); + Vector2 rp=Vector2{mp.x-wp.x,mp.y-wp.y}; + tiny::error("%f %f",rp.x,rp.y); + + if (rp.x >= 0 && rp.y >= 0 && rp.x < 600 && rp.y < 300) { + UnloadImage(img); + img = LoadImageFromTexture(target.texture); + Color pix = GetImageColor(img, (int)rp.x, (int)(300 - rp.y)); + if (pix.a == 0) { + SetWindowState(FLAG_WINDOW_MOUSE_PASSTHROUGH); + captured = false; + } else { + ClearWindowState(FLAG_WINDOW_MOUSE_PASSTHROUGH); + captured = true; + } + } + } + void exit() override { + s.exit(); + } +}; + +tiny::ErrorLevel tiny::level{6}; +int main(int argc, char *argv[]) { + netio nete{}; + nete.download(); + tiny::startup((char*)"enginend test",(char*)"1.0"); + test e; + e.boot(); + while (!WindowShouldClose()) { + e.tick(); + e.draw(); + } + e.exit(); + return 0; +} \ No newline at end of file diff --git a/games/endlauncher/src/netio.cpp b/games/endlauncher/src/netio.cpp new file mode 100644 index 0000000..a0175ef --- /dev/null +++ b/games/endlauncher/src/netio.cpp @@ -0,0 +1,5 @@ +#include "netio.h" +size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { + size_t written = fwrite(ptr, size, nmemb, stream); + return written; +}; \ No newline at end of file diff --git a/games/endlauncher/src/netio.h b/games/endlauncher/src/netio.h new file mode 100644 index 0000000..c41e730 --- /dev/null +++ b/games/endlauncher/src/netio.h @@ -0,0 +1,110 @@ +#pragma once +#include +#include +#include +#include +#include +#include +extern size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream); + +struct netio { + netio()= default; + std::string url="https://github.com/kin-fuyuki/forespend_cpp/releases/download/"; + std::vector *versionhistory; + void download() { + CURL* curl = curl_easy_init(); + CURLcode ret; + if (curl) { + FILE* history = fopen("versions.tdf", "wb"); + curl_easy_setopt(curl, CURLOPT_URL, "https://raw.githubusercontent.com/kin-fuyuki/allgames/refs/heads/master/versions.tdf"); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, history); + ret = curl_easy_perform(curl); + + tiny::TDF_FILE fetchversions; + fetchversions.filepath = "versions.tdf"; + fetchversions.read(); + boost::unordered_map* foreversions= fetchversions.getclass({"forespend"}); + std::vector versions; + for (auto version:*foreversions) { + if (version.second.type==tiny::TDF_Type::TDF_DEFINES) { + versions=*(std::vector*)version.second.datapointer; + } + } + std::sort(versions.begin(), versions.end(), [](const std::string& a, const std::string& b) { + int ra = 0, rb = 0; + float va = 0.0f, vb = 0.0f; + char pa = ' ', pb = ' '; + char rea = ' ', reb = ' '; + + sscanf(a.c_str(), "%d.%f.%c.%c", &ra, &va, &pa, &rea); + sscanf(b.c_str(), "%d.%f.%c.%c", &rb, &vb, &pb, &reb); + + if (ra != rb) return ra > rb; + if (va != vb) return va > vb; + if (pa != pb) return pa > pb; + return rea < reb; + }); +#ifndef GAMEPLATFORM +#define GAMEPLATFORM "l5.64" +#endif + versionhistory=&versions; + std::string version=versionhistory->at(0); + FILE* file = fopen(("fore."+version+".zip").c_str(), "wb"); + curl_easy_setopt(curl, CURLOPT_URL, (url+version+"/"+GAMEPLATFORM+"."+version+".zip").c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, file); + ret = curl_easy_perform(curl); + curl_easy_cleanup(curl); + fclose(file); + + + int err=0; + zip *z=zip_open("fore.0.03.a.g.zip",0,&err); + if (z) { + zip_int64_t it=zip_get_num_entries(z, 0); + for (zip_int64_t i = 0; i < it; ++i) { + struct zip_stat st; + zip_stat_init(&st); + if (zip_stat_index(z, i, 0, &st) != 0) continue; + + std::string name = st.name; + std::string full = "forespend/versions/"+version+"/" + name; + + if (name.back() == '/') { +#ifdef _WIN32 + mkdir(full.c_str(), 0); +#else + mkdir(full.c_str(), 0755); +#endif + continue; + } + + size_t pos = full.find_last_of('/'); + if (pos != std::string::npos) { + std::string dir = full.substr(0, pos); +#ifdef _WIN32 + mkdir(dir.c_str(), 0); +#else + mkdir(dir.c_str(), 0755); +#endif + } + + zip_file_t *zf = zip_fopen_index(z, i, 0); + if (zf) { + std::ofstream ofs(full, std::ios::binary); + char buff[1 << 16]; + zip_int64_t read; + while ((read = zip_fread(zf, buff, sizeof(buff))) > 0) { + ofs.write(buff, read); + } + ofs.close(); + zip_fclose(zf); + } + } + zip_close(z); + } + } + } + +}; \ No newline at end of file diff --git a/games/forespend/CMakeLists.txt b/games/forespend/CMakeLists.txt index bf3e4d9..82ba8f3 100644 --- a/games/forespend/CMakeLists.txt +++ b/games/forespend/CMakeLists.txt @@ -16,6 +16,6 @@ target_link_libraries(forespend PRIVATE ) target_include_directories(forespend PUBLIC ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/lib/raylib/include + ${CMAKE_SOURCE_DIR}/lib/raylib/build/raylib/include ${CMAKE_SOURCE_DIR}/engine/include ) \ No newline at end of file diff --git a/include/tiny/term.h b/include/tiny/term.h index e3a0f9b..c70ce7b 100644 --- a/include/tiny/term.h +++ b/include/tiny/term.h @@ -39,23 +39,23 @@ tiny::ErrorLevel tiny::level={1}; extern tiny::ErrorLevel level; - const char* WHITE="\033[0m"; - const char* BLACK="\033[30m"; - const char* RED="\033[31m"; - const char* GREEN="\033[32m"; - const char* YELLOW="\033[33m"; - const char* BLUE="\033[34m"; - const char* MAGENTA="\033[35m"; - const char* CYAN="\033[36m"; - const char* BGRED="\033[41m"; - const char* BOLDBLACK="\033[1m\033[30m"; - const char* BOLDRED="\033[1m\033[31m"; - const char* BOLDGREEN="\033[1m\033[32m"; - const char* BOLDYELLOW="\033[1m\033[33m"; - const char* BOLDBLUE="\033[1m\033[34m"; - const char* BOLDMAGENTA="\033[1m\033[35m"; - const char* BOLDCYAN="\033[1m\033[36m"; - const char* BOLDWHITE="\033[1m\033[37m"; +inline const char* WHITE="\033[0m"; +inline const char* BLACK="\033[30m"; +inline const char* RED="\033[31m"; +inline const char* GREEN="\033[32m"; +inline const char* YELLOW="\033[33m"; +inline const char* BLUE="\033[34m"; +inline const char* MAGENTA="\033[35m"; +inline const char* CYAN="\033[36m"; +inline const char* BGRED="\033[41m"; +inline const char* BOLDBLACK="\033[1m\033[30m"; +inline const char* BOLDRED="\033[1m\033[31m"; +inline const char* BOLDGREEN="\033[1m\033[32m"; +inline const char* BOLDYELLOW="\033[1m\033[33m"; +inline const char* BOLDBLUE="\033[1m\033[34m"; +inline const char* BOLDMAGENTA="\033[1m\033[35m"; +inline const char* BOLDCYAN="\033[1m\033[36m"; +inline const char* BOLDWHITE="\033[1m\033[37m"; #define ending \ mixer.append(info); mixer.append("\033[0m\n");\ const char * finalinfo=mixer.c_str();\ diff --git a/versions.tdf b/versions.tdf new file mode 100644 index 0000000..1bf617d --- /dev/null +++ b/versions.tdf @@ -0,0 +1,3 @@ +{ forespend +0.03.a.g +} \ No newline at end of file