chaaangelog!
This commit is contained in:
parent
1051610ffa
commit
f6fee0982f
4 changed files with 539 additions and 353 deletions
|
|
@ -56,20 +56,20 @@ namespace enginend {
|
||||||
std::string result;
|
std::string result;
|
||||||
public:
|
public:
|
||||||
Font font;
|
Font font;
|
||||||
float fontsize;
|
float fs;
|
||||||
Color textcolor;
|
Color txc;
|
||||||
std::string content;
|
std::string content;
|
||||||
text(){ fontsize = 20; }
|
text(){fs=20;}
|
||||||
text(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt):
|
text(Texture2D* texture,Color txcol,Color color,float x,float y,float w,float h,Font f,float fsize,std::string txt):
|
||||||
font(f),fontsize(fs),content(txt)
|
font(f),fs(fsize),content(txt)
|
||||||
{
|
{
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color;this->textcolor=textcol;
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color;this->txc=txcol;
|
||||||
|
|
||||||
result=content;
|
result=content;
|
||||||
size_t initpos = 0;
|
size_t initp=0;
|
||||||
while((initpos = result.find("\n", initpos)) != std::string::npos) {
|
while((initp=result.find("\n",initp))!=std::string::npos){
|
||||||
result.replace(initpos, 1, "\\n");
|
result.replace(initp,1,"\\n");
|
||||||
initpos += 2;
|
initp+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void boot()override{this->tinted::boot();}
|
void boot()override{this->tinted::boot();}
|
||||||
|
|
@ -77,83 +77,85 @@ namespace enginend {
|
||||||
this->tinted::tick();
|
this->tinted::tick();
|
||||||
if(result!=content){
|
if(result!=content){
|
||||||
result=content;
|
result=content;
|
||||||
size_t initpos = 0;
|
size_t initp=0;
|
||||||
while((initpos = result.find("\n", initpos)) != std::string::npos) {
|
while((initp=result.find("\n",initp))!=std::string::npos){
|
||||||
result.replace(initpos, 1, "\\n");
|
result.replace(initp,1,"\\n");
|
||||||
initpos += 2;
|
initp+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void draw()override {
|
void draw()override {
|
||||||
Vector2 minsize=MeasureTextEx(font, content.c_str(), fontsize, 1);
|
Vector2 minsize=MeasureTextEx(font,content.c_str(),fs,1);
|
||||||
Vector2 charsize=MeasureTextEx(font, " ", fontsize, 1);
|
Vector2 charsize=MeasureTextEx(font," ",fs,1);
|
||||||
float p=charsize.x>charsize.y?charsize.x/minsize.x:charsize.y/minsize.y;
|
float p=charsize.x>charsize.y?charsize.x/minsize.x:charsize.y/minsize.y;
|
||||||
p=p*2;
|
p=p*2;
|
||||||
int minh=(minsize.y>size.y)?minsize.y:size.y;
|
int minh=(minsize.y>size.y)?minsize.y:size.y;
|
||||||
int minw=(minsize.x>size.x)?minsize.x:size.x;
|
int minw=(minsize.x>size.x)?minsize.x:size.x;
|
||||||
DrawRectangle(pos.x-charsize.x,pos.y-charsize.y,minw+p,minh+p,c);
|
DrawRectangle(pos.x-charsize.x,pos.y-charsize.y,minw+p,minh+p,c);
|
||||||
DrawTextEx(font, content.c_str(), pos, fontsize, 1, textcolor);
|
DrawTextEx(font,content.c_str(),pos,fs,1,txc);
|
||||||
}
|
}
|
||||||
void exit()override{this->tinted::exit();}
|
void exit()override{this->tinted::exit();}
|
||||||
};
|
};
|
||||||
struct button :virtual public tinted{
|
struct button :virtual public tinted{
|
||||||
std::function<void()> function;
|
std::function<void()> func;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
|
bool hover;
|
||||||
button():pressed(false){}
|
button():pressed(false){}
|
||||||
button(Texture2D* texture,Color color,float x,float y,float w,float h,std::function<void()> func):function(func),pressed(false){
|
button(Texture2D* texture,Color color,float x,float y,float w,float h,std::function<void()> f):func(f),pressed(false){
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color;
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color;
|
||||||
}
|
}
|
||||||
void boot()override{this->tinted::boot();}
|
void boot()override{this->tinted::boot();}
|
||||||
void tick()override{
|
void tick()override{
|
||||||
this->tinted::tick();
|
this->tinted::tick();
|
||||||
Vector2 mouse=GetMousePosition();
|
Vector2 mouse=GetMousePosition();
|
||||||
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})&&IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})){hover=true;
|
||||||
if(function)function();
|
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||||
|
pressed=true;
|
||||||
|
if(func)func();
|
||||||
|
}else{
|
||||||
|
pressed=false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hover=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void draw()override {
|
void draw()override {
|
||||||
if(this->texture!=nullptr)DrawTexture(*texture,pos.x,pos.y,c);
|
if(this->texture!=nullptr)DrawTexture(*texture,pos.x,pos.y,c);
|
||||||
else
|
else DrawRectangle(pos.x,pos.y,size.x,size.y,c);
|
||||||
DrawRectangle(pos.x,pos.y,size.x,size.y,c);
|
|
||||||
}
|
}
|
||||||
void exit()override{this->tinted::exit();}
|
void exit()override{this->tinted::exit();}
|
||||||
};
|
};
|
||||||
struct labeledbutton :virtual public button {
|
struct labeledbutton :virtual public button {
|
||||||
std::string label;
|
std::string label;
|
||||||
Font font;
|
Font font;
|
||||||
int fontsize;
|
int fs;
|
||||||
Color textcolor;
|
Color txc;
|
||||||
labeledbutton(std::string name,Texture2D* texture,Color color,Color text,
|
labeledbutton(std::string name,Texture2D* texture,Color color,Color text,
|
||||||
float x,float y,float w,float h,std::function<void()> func,
|
float x,float y,float w,float h,std::function<void()> f,
|
||||||
Font f,int size):font(f), fontsize(size),textcolor(text){
|
Font fnt,int size):font(fnt),fs(size),txc(text){
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color;
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=color;
|
||||||
this->function=func;this->pressed=false;
|
this->func=f;this->pressed=false;
|
||||||
this->label=name;
|
this->label=name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void boot()override{this->button::boot();}
|
void boot()override{this->button::boot();}
|
||||||
void tick()override{
|
void tick()override{this->button::tick();}
|
||||||
this->button::tick();
|
|
||||||
}
|
|
||||||
void draw()override{
|
void draw()override{
|
||||||
this->button::draw();
|
this->button::draw();
|
||||||
|
Vector2 tsize=MeasureTextEx(font,label.c_str(),fs,1);
|
||||||
Vector2 textsize = MeasureTextEx(font, label.c_str(), fontsize, 1);
|
Vector2 tpos={
|
||||||
Vector2 textpos = {
|
pos.x+(size.x-tsize.x)/2,
|
||||||
pos.x + (size.x - textsize.x)/2,
|
pos.y+(size.y-tsize.y)/2
|
||||||
pos.y + (size.y - textsize.y)/2
|
|
||||||
};
|
};
|
||||||
DrawTextEx(font, label.c_str(), textpos, fontsize, 1, textcolor);
|
DrawTextEx(font,label.c_str(),tpos,fs,1,txc);
|
||||||
}
|
}
|
||||||
void exit()override{this->button::exit();}
|
void exit()override{this->button::exit();}
|
||||||
};
|
};
|
||||||
struct slider :virtual public tinted{
|
struct slider :virtual public tinted{
|
||||||
float value;
|
float val;
|
||||||
float minvalue;
|
float minv;
|
||||||
float maxvalue;
|
float maxv;
|
||||||
slider():value(0),minvalue(0),maxvalue(1){}
|
slider():val(0),minv(0),maxv(1){}
|
||||||
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){
|
slider(Texture2D* texture,Color color,float x,float y,float w,float h,float min,float max,float v):val(v),minv(min),maxv(max){
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->texture=texture;this->c=color;
|
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->texture=texture;this->c=color;
|
||||||
}
|
}
|
||||||
void boot()override{this->tinted::boot();}
|
void boot()override{this->tinted::boot();}
|
||||||
|
|
@ -162,45 +164,43 @@ namespace enginend {
|
||||||
Vector2 mouse=GetMousePosition();
|
Vector2 mouse=GetMousePosition();
|
||||||
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})&&IsMouseButtonDown(MOUSE_LEFT_BUTTON)){
|
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})&&IsMouseButtonDown(MOUSE_LEFT_BUTTON)){
|
||||||
float t=(mouse.x-pos.x)/size.x;
|
float t=(mouse.x-pos.x)/size.x;
|
||||||
value=minvalue+t*(maxvalue-minvalue);
|
val=minv+t*(maxv-minv);
|
||||||
if(value<minvalue)value=minvalue;
|
if(val<minv)val=minv;
|
||||||
if(value>maxvalue)value=maxvalue;
|
if(val>maxv)val=maxv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void draw()override{
|
void draw()override{
|
||||||
DrawRectangle(pos.x,pos.y,size.x,size.y,DARKGRAY);
|
DrawRectangle(pos.x,pos.y,size.x,size.y,DARKGRAY);
|
||||||
float t=(value-minvalue)/(maxvalue-minvalue);
|
float t=(val-minv)/(maxv-minv);
|
||||||
DrawRectangle(pos.x,pos.y,size.x*t,size.y,c);
|
DrawRectangle(pos.x,pos.y,size.x*t,size.y,c);
|
||||||
}
|
}
|
||||||
void exit()override{this->tinted::exit();}
|
void exit()override{this->tinted::exit();}
|
||||||
};
|
};
|
||||||
struct textfield :public text{
|
struct textfield :public text{
|
||||||
textfield(){}
|
textfield(){}
|
||||||
textfield(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt):
|
textfield(Texture2D* texture,Color txcol,Color color,float x,float y,float w,float h,Font f,float fsize,std::string txt):
|
||||||
text(texture,textcol,color,x,y,w,h,f,fs,txt){}
|
text(texture,txcol,color,x,y,w,h,f,fsize,txt){}
|
||||||
void boot()override{this->text::boot();}
|
void boot()override{this->text::boot();}
|
||||||
void tick()override{this->text::tick();}
|
void tick()override{this->text::tick();}
|
||||||
void draw()override{
|
void draw()override{
|
||||||
Vector2 p=pos;
|
Vector2 p=pos;
|
||||||
float lineheight=fontsize+2;
|
Vector2 charsize=MeasureTextEx(font," ",fs,0);
|
||||||
std::string line="";
|
Vector2 minsize=MeasureTextEx(font,content.c_str(),fs,charsize.x/2);
|
||||||
Vector2 charsize=MeasureTextEx(font, " ", fontsize, 0);
|
|
||||||
Vector2 minsize=MeasureTextEx(font, content.c_str(), fontsize, charsize.x/2);
|
|
||||||
float po=charsize.x>charsize.y?charsize.x/charsize.y:charsize.y/charsize.x;po=po*5;
|
float po=charsize.x>charsize.y?charsize.x/charsize.y:charsize.y/charsize.x;po=po*5;
|
||||||
int minh=(minsize.y>size.y)?minsize.y:size.y;
|
int minh=(minsize.y>size.y)?minsize.y:size.y;
|
||||||
int minw=(minsize.x>size.x)?minsize.x:size.x;
|
int minw=(minsize.x>size.x)?minsize.x:size.x;
|
||||||
DrawRectangle(pos.x-(po/2),pos.y-(po/2),minw+(po*1.1),minh+(po*1.1),c);
|
DrawRectangle(pos.x-(po/2),pos.y-(po/2),minw+(po*1.1),minh+(po*1.1),c);
|
||||||
DrawTextEx(font,content.c_str(),p,fontsize,charsize.x/2,this->textcolor);
|
DrawTextEx(font,content.c_str(),p,fs,charsize.x/2,this->txc);
|
||||||
}
|
}
|
||||||
void exit()override{this->text::exit();}
|
void exit()override{this->text::exit();}
|
||||||
};
|
};
|
||||||
struct textinput :public text{
|
struct textinput :public text{
|
||||||
bool active;
|
bool active;
|
||||||
int cursorpos;
|
int cpos;
|
||||||
textinput():active(false),cursorpos(0){}
|
textinput():active(false),cpos(0){}
|
||||||
textinput(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0){
|
textinput(Texture2D* texture,Color txcol,Color color,float x,float y,float w,float h,Font f,float fsize):active(false),cpos(0){
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->texture=texture;this->c=color;this->font=f;this->content="";
|
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;
|
this->txc=txcol;this->fs=fsize;
|
||||||
}
|
}
|
||||||
void boot()override{this->text::boot();}
|
void boot()override{this->text::boot();}
|
||||||
void tick()override{
|
void tick()override{
|
||||||
|
|
@ -214,28 +214,28 @@ namespace enginend {
|
||||||
while(key>0){
|
while(key>0){
|
||||||
if(key>=32&&key<=125){
|
if(key>=32&&key<=125){
|
||||||
content+=static_cast<char>(key);
|
content+=static_cast<char>(key);
|
||||||
cursorpos++;
|
cpos++;
|
||||||
}
|
}
|
||||||
key=GetCharPressed();
|
key=GetCharPressed();
|
||||||
}
|
}
|
||||||
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
||||||
content.pop_back();
|
content.pop_back();
|
||||||
cursorpos--;
|
cpos--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void draw()override{
|
void draw()override{
|
||||||
this->text::draw();
|
this->text::draw();
|
||||||
if(active)DrawRectangle(pos.x+MeasureText(content.c_str(),fontsize),pos.y,2,fontsize,{0,0,0,127});
|
if(active)DrawRectangle(pos.x+MeasureText(content.c_str(),fs),pos.y,2,fs,{0,0,0,127});
|
||||||
}
|
}
|
||||||
void exit()override{this->text::exit();}
|
void exit()override{this->text::exit();}
|
||||||
};
|
};
|
||||||
struct textinputfield :public textfield{
|
struct textinputfield :public textfield{
|
||||||
bool active;
|
bool active;
|
||||||
int cursorpos;
|
int cpos;
|
||||||
textinputfield():active(false),cursorpos(0){}
|
textinputfield():active(false),cpos(0){}
|
||||||
textinputfield(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0),
|
textinputfield(Texture2D* texture,Color txcol,Color color,float x,float y,float w,float h,Font f,float fsize):active(false),cpos(0),
|
||||||
textfield(texture,textcol,color,x,y,w,h,f,fs,""){}
|
textfield(texture,txcol,color,x,y,w,h,f,fsize,""){}
|
||||||
void boot()override{this->textfield::boot();}
|
void boot()override{this->textfield::boot();}
|
||||||
void tick()override{
|
void tick()override{
|
||||||
this->textfield::tick();
|
this->textfield::tick();
|
||||||
|
|
@ -248,17 +248,17 @@ namespace enginend {
|
||||||
while(key>0){
|
while(key>0){
|
||||||
if(key>=32&&key<=125){
|
if(key>=32&&key<=125){
|
||||||
content+=static_cast<char>(key);
|
content+=static_cast<char>(key);
|
||||||
cursorpos++;
|
cpos++;
|
||||||
}
|
}
|
||||||
key=GetCharPressed();
|
key=GetCharPressed();
|
||||||
}
|
}
|
||||||
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
||||||
content.pop_back();
|
content.pop_back();
|
||||||
cursorpos--;
|
cpos--;
|
||||||
}
|
}
|
||||||
if(IsKeyPressed(KEY_ENTER)){
|
if(IsKeyPressed(KEY_ENTER)){
|
||||||
content+='\n';
|
content+='\n';
|
||||||
cursorpos++;
|
cpos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -266,17 +266,17 @@ namespace enginend {
|
||||||
this->textfield::draw();
|
this->textfield::draw();
|
||||||
if(active){
|
if(active){
|
||||||
Vector2 p=pos;
|
Vector2 p=pos;
|
||||||
float lineheight=fontsize+2;
|
float lh=fs+2;
|
||||||
std::string line="";
|
std::string line="";
|
||||||
for(char ch:content){
|
for(char ch:content){
|
||||||
if(ch=='\n'){
|
if(ch=='\n'){
|
||||||
p.y+=lineheight;
|
p.y+=lh;
|
||||||
line="";
|
line="";
|
||||||
}else{
|
}else{
|
||||||
line+=ch;
|
line+=ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawRectangle(p.x+MeasureText(line.c_str(),fontsize),p.y,2,fontsize,BLACK);
|
DrawRectangle(p.x+MeasureText(line.c_str(),fs),p.y,2,fs,BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void exit()override{this->textfield::exit();}
|
void exit()override{this->textfield::exit();}
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,24 @@
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <enginend/scenes/node2d.h>
|
#include <enginend/scenes/node2d.h>
|
||||||
#include "netio.h"
|
#include "netio.h"
|
||||||
|
#include <thread>
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace enginend;
|
using namespace enginend;
|
||||||
|
|
||||||
|
netio nete{};
|
||||||
|
|
||||||
struct background: public virtual textured {
|
struct background: public virtual textured {
|
||||||
background(Texture2D* texture,float x,float y,float w, float h) {
|
background(Texture2D* texture,float x,float y,float w, float h) {
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};
|
||||||
this->texture=texture;
|
this->texture=texture;
|
||||||
this->justclicked=false;
|
this->justclicked=false;
|
||||||
|
|
||||||
}
|
}
|
||||||
void boot()override{
|
void boot()override{
|
||||||
img=LoadImageFromTexture(*this->texture);
|
img=LoadImageFromTexture(*this->texture);
|
||||||
}
|
}
|
||||||
void tick()override {
|
void tick()override {
|
||||||
|
|
||||||
Vector2 mp=Vector2(GetMousePositionDesktop());
|
Vector2 mp=Vector2(GetMousePositionDesktop());
|
||||||
Vector2 wp=GetWindowPosition();
|
Vector2 wp=GetWindowPosition();
|
||||||
Vector2 rp=Vector2{mp.x-wp.x,mp.y-wp.y};
|
Vector2 rp=Vector2{mp.x-wp.x,mp.y-wp.y};
|
||||||
|
|
@ -22,7 +27,6 @@ struct background: public virtual textured {
|
||||||
if (rp.x>=0&&rp.y>=0&&rp.x<600&&rp.y<300) {
|
if (rp.x>=0&&rp.y>=0&&rp.x<600&&rp.y<300) {
|
||||||
Color pix=GetImageColor(img, (int)rp.x, (int)(300-rp.y));
|
Color pix=GetImageColor(img, (int)rp.x, (int)(300-rp.y));
|
||||||
if (pix.a!=0) {
|
if (pix.a!=0) {
|
||||||
|
|
||||||
if (clicked==false) {
|
if (clicked==false) {
|
||||||
clicked=true;
|
clicked=true;
|
||||||
relmouse=rp;
|
relmouse=rp;
|
||||||
|
|
@ -33,30 +37,17 @@ struct background: public virtual textured {
|
||||||
clicked=false;
|
clicked=false;
|
||||||
}
|
}
|
||||||
if (clicked) {
|
if (clicked) {
|
||||||
|
|
||||||
Vector2 nwp{
|
Vector2 nwp{
|
||||||
mp.x-relmouse.x, mp.y-relmouse.y
|
mp.x-relmouse.x, mp.y-relmouse.y
|
||||||
};
|
};
|
||||||
//todo: implement proper multi-monitor lmaooo
|
|
||||||
int it =GetMonitorCount();
|
|
||||||
RenderTexture rt;
|
|
||||||
for (int i=0;i<it;i++) {
|
|
||||||
Vector2 mtp=GetMonitorPosition(i);
|
|
||||||
int mtw=GetMonitorWidth(i);
|
|
||||||
int mth=GetMonitorHeight(i);
|
|
||||||
if (mp.x>=mtp.x && mp.y>=mtp.y && mp.x<mtp.x+mtw && mp.y<mtp.y+mth) {
|
|
||||||
SetWindowMonitor(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int cm=GetCurrentMonitor();
|
int cm=GetCurrentMonitor();
|
||||||
Vector2 mop=GetMonitorPosition(cm);
|
Vector2 mop=GetMonitorPosition(cm);
|
||||||
int newwpx=nwp.x-mop.x;
|
int newwpx=nwp.x-mop.x;
|
||||||
int newwpy=nwp.y-mop.y;
|
int newwpy=nwp.y-mop.y;
|
||||||
int maxwpx=GetMonitorWidth(cm)-GetScreenWidth();
|
int maxwpx=GetMonitorWidth(cm)-GetScreenWidth();
|
||||||
int maxwpy=GetMonitorHeight(cm)-GetScreenHeight();
|
int maxwpy=GetMonitorHeight(cm)-GetScreenHeight();
|
||||||
newwpx=newwpx>maxwpx?maxwpx:newwpx;
|
newwpx=newwpx>maxwpx?maxwpx:newwpx<0?0:newwpx;
|
||||||
newwpy=newwpy>maxwpy?maxwpy:newwpy;
|
newwpy=newwpy>maxwpy?maxwpy:newwpy<0?0:newwpy;
|
||||||
SetWindowPosition(newwpx,newwpy);
|
SetWindowPosition(newwpx,newwpy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +58,44 @@ private:
|
||||||
Vector2 relmouse;
|
Vector2 relmouse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct logi: public virtual textfield {
|
||||||
|
logi(Texture2D* texture,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt) {
|
||||||
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->content=txt;
|
||||||
|
this->texture=texture;this->txc=textcol;this->c=color;
|
||||||
|
this->font=f;
|
||||||
|
this->fs=fs;
|
||||||
|
}
|
||||||
|
void draw() override {
|
||||||
|
Vector2 p=pos;
|
||||||
|
float spacing=fs/2.0f;
|
||||||
|
std::stringstream ss(content);
|
||||||
|
std::string line;
|
||||||
|
int lines=0;
|
||||||
|
|
||||||
|
while (std::getline(ss, line)) {
|
||||||
|
if (lines%2==0) {
|
||||||
|
Vector2 charPos=p;
|
||||||
|
for (char& c : line) {
|
||||||
|
char str[2]={c, '\0'};
|
||||||
|
Color fc=Color{255,0,255,255};
|
||||||
|
if (c=='/'||c==':') {
|
||||||
|
fc=Color{255,255,0,255};
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawTextEx(font, str, charPos, (float)fs, spacing, fc);
|
||||||
|
charPos.x+=MeasureTextEx(font, str, (float)fs, spacing).x;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DrawTextEx(font, line.c_str(), p, (float)fs, spacing, Color{0,255,255,255});
|
||||||
|
}
|
||||||
|
|
||||||
|
p.y+=(fs+2);
|
||||||
|
lines++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void quit(){exit(0);}
|
||||||
|
|
||||||
class test:public program {
|
class test:public program {
|
||||||
public:
|
public:
|
||||||
|
|
@ -77,7 +106,7 @@ public:
|
||||||
Texture2D menubtn[3];
|
Texture2D menubtn[3];
|
||||||
button* buttons[8];
|
button* buttons[8];
|
||||||
Texture2D buttonslabel[8];
|
Texture2D buttonslabel[8];
|
||||||
Font gamename;
|
Font gamename,changelog,information;
|
||||||
bool vsync=true;
|
bool vsync=true;
|
||||||
scene s;
|
scene s;
|
||||||
RenderTexture2D target;
|
RenderTexture2D target;
|
||||||
|
|
@ -86,9 +115,9 @@ public:
|
||||||
const char* CONF() final{return "test.tdf";}
|
const char* CONF() final{return "test.tdf";}
|
||||||
test(){};
|
test(){};
|
||||||
void boot() override {
|
void boot() override {
|
||||||
tickrate=10;
|
tickrate=15;
|
||||||
framerate=10;
|
framerate=15;
|
||||||
SetConfigFlags(FLAG_VSYNC_HINT|FLAG_WINDOW_UNDECORATED|FLAG_WINDOW_TRANSPARENT);
|
SetConfigFlags(FLAG_WINDOW_UNDECORATED|FLAG_WINDOW_TRANSPARENT|FLAG_WINDOW_TOPMOST);
|
||||||
tiny::error("is transparent lol");
|
tiny::error("is transparent lol");
|
||||||
InitWindow(600,300,"test");target=LoadRenderTexture(600, 300);
|
InitWindow(600,300,"test");target=LoadRenderTexture(600, 300);
|
||||||
img=GenImageColor(600, 300, BLANK);
|
img=GenImageColor(600, 300, BLANK);
|
||||||
|
|
@ -101,23 +130,33 @@ public:
|
||||||
menubtn[0]=LoadTexture("res/btn.png");
|
menubtn[0]=LoadTexture("res/btn.png");
|
||||||
menubtn[1]=LoadTexture("res/btnhover.png");
|
menubtn[1]=LoadTexture("res/btnhover.png");
|
||||||
menubtn[2]=LoadTexture("res/btnpress.png");
|
menubtn[2]=LoadTexture("res/btnpress.png");
|
||||||
|
changelog=LoadFont("res/log.ttf");
|
||||||
SetTraceLogLevel(LOG_ERROR);
|
SetTraceLogLevel(LOG_ERROR);
|
||||||
//468
|
|
||||||
//58
|
|
||||||
buttons[0]=new button(&menubtn[0], {255,255,255,255},468,58,96,16,nullptr);
|
buttons[0]=new button(&menubtn[0], {255,255,255,255},468,58,96,16,nullptr);
|
||||||
buttonslabel[0]=LoadTexture("res/options.png");
|
buttonslabel[0]=LoadTexture("res/options.png");
|
||||||
buttons[1]= new button(&menubtn[0], {255,255,255,255},468,58+(18*1),96,16,nullptr);
|
buttons[1]=new button(&menubtn[0], {255,255,255,255},468,58+(18*1),96,16,std::function<void()>([]() {
|
||||||
|
OpenURL("http://kosumi.ddns.net:60000/");
|
||||||
|
}));
|
||||||
buttonslabel[1]=LoadTexture("res/website.png");
|
buttonslabel[1]=LoadTexture("res/website.png");
|
||||||
buttons[2]= new button(&menubtn[0], {255,255,255,255},468,58+(18*2),96,16,nullptr);
|
buttons[2]=new button(&menubtn[0], {255,255,255,255},468,58+(18*2),96,16,std::function<void()>([]() {
|
||||||
|
OpenURL("http://kosumi.ddns.net:60001/");
|
||||||
|
}));
|
||||||
buttonslabel[2]=LoadTexture("res/forums.png");
|
buttonslabel[2]=LoadTexture("res/forums.png");
|
||||||
buttons[3]= new button(&menubtn[0], {255,255,255,255},468,58+(18*3),96,16,nullptr);
|
buttons[3]=new button(&menubtn[0], {255,255,255,255},468,58+(18*3),96,16,std::function<void()>([]() {
|
||||||
buttons[4]= new button(&menubtn[0], {255,255,255,255},468,58+(18*4),96,16,nullptr);
|
OpenURL("https://github.com/kin-fuyuki/allgames/issues");
|
||||||
|
}));
|
||||||
|
buttonslabel[3]=LoadTexture("res/help.png");
|
||||||
|
buttons[4]=new button(&menubtn[0], {255,255,255,255},468,58+(18*4),96,16,std::function<void()>([]() {
|
||||||
|
nete.download();
|
||||||
|
}));
|
||||||
buttonslabel[4]=LoadTexture("res/update.png");
|
buttonslabel[4]=LoadTexture("res/update.png");
|
||||||
buttons[5]=new button(&menubtn[0], {255,255,255,255},468,58+(18*5),96,16,nullptr);
|
buttons[5]=new button(&menubtn[0], {255,255,255,255},468,58+(18*5),96,16,nullptr);
|
||||||
buttonslabel[5]=LoadTexture("res/verify.png");
|
buttonslabel[5]=LoadTexture("res/verify.png");
|
||||||
buttons[6]=new button(&menubtn[0], {255,255,255,255},468,58+(18*6)+15,96,16,nullptr);
|
buttons[6]=new button(&menubtn[0], {255,255,255,255},468,58+(18*6)+15,96,16,nullptr);
|
||||||
buttonslabel[6]=LoadTexture("res/versions.png");
|
buttonslabel[6]=LoadTexture("res/versions.png");
|
||||||
buttons[7]= new button(&menubtn[0], {255,255,255,255},468,58+(18*7)+17,96,16,nullptr);
|
buttons[7]=new button(&menubtn[0], {255,255,255,255},468,58+(18*7)+17,96,16,std::function<void()>([]() {
|
||||||
|
quit();
|
||||||
|
}));
|
||||||
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");
|
||||||
|
|
@ -131,41 +170,64 @@ public:
|
||||||
buttons[0],new textured(&buttonslabel[0],468,58,96,16),
|
buttons[0],new textured(&buttonslabel[0],468,58,96,16),
|
||||||
buttons[1],new textured(&buttonslabel[1],468,58+(18*1),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[2],new textured(&buttonslabel[2],468,58+(18*2),96,16),
|
||||||
buttons[3],//new textured(&buttonslabel[3],468,58+(18*3),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[4],new textured(&buttonslabel[4],468,58+(18*4),96,16),
|
||||||
buttons[5],new textured(&buttonslabel[5],468,58+(18*5),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[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),
|
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),
|
new button(&playbtn[0], {255,255,255,255},406,(18*11)+17+9,153,59,nullptr),
|
||||||
|
new logi(nullptr,Color{255,0,255,255},Color{0,0,0,0},90,58,466,159,changelog,8,nete.changelog),
|
||||||
};
|
};
|
||||||
s.boot();
|
s.boot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
int buttondelay=0;
|
||||||
void tick() override {
|
void tick() override {
|
||||||
if (shouldtick()) {
|
for (button* b : buttons) {
|
||||||
|
if (b->hover) {
|
||||||
|
if (b->pressed) {
|
||||||
|
b->texture=&menubtn[2];
|
||||||
|
buttondelay=5;
|
||||||
|
}else {
|
||||||
|
if (b->texture->id==menubtn[2].id) {
|
||||||
|
if(buttondelay<0) {
|
||||||
|
b->texture=&menubtn[1];
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
b->texture=&menubtn[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (b->texture->id==menubtn[2].id) {
|
||||||
|
if(buttondelay<0) {
|
||||||
|
b->texture=&menubtn[0];
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
b->texture=&menubtn[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
s.tick();
|
s.tick();
|
||||||
|
buttondelay--;
|
||||||
}
|
}
|
||||||
|
bool changedmenu=true;
|
||||||
}
|
bool itemchanged=true;
|
||||||
void draw() override {
|
void draw() override {
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
s.draw();
|
s.draw();
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLANK);
|
ClearBackground(BLANK);
|
||||||
DrawTexturePro(target.texture, {0, 0, 600, -300}, {0, 0, 600, 300}, {0, 0}, 0, WHITE);
|
DrawTexturePro(target.texture, {0, 0, 600, -300}, {0, 0, 600, 300}, {0, 0}, 0, WHITE);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
||||||
Vector2 mp=Vector2(GetMousePositionDesktop());
|
Vector2 mp=Vector2(GetMousePositionDesktop());
|
||||||
Vector2 wp=GetWindowPosition();
|
Vector2 wp=GetWindowPosition();
|
||||||
Vector2 rp=Vector2{mp.x-wp.x,mp.y-wp.y};
|
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) {
|
if (rp.x>=0&&rp.y>=0&&rp.x<600&&rp.y<300) {
|
||||||
|
if (changedmenu) {
|
||||||
UnloadImage(img);
|
UnloadImage(img);
|
||||||
img=LoadImageFromTexture(target.texture);
|
img=LoadImageFromTexture(target.texture);
|
||||||
|
changedmenu=false;
|
||||||
|
}
|
||||||
Color pix=GetImageColor(img, (int)rp.x, (int)(300-rp.y));
|
Color pix=GetImageColor(img, (int)rp.x, (int)(300-rp.y));
|
||||||
if (pix.a==0) {
|
if (pix.a==0) {
|
||||||
SetWindowState(FLAG_WINDOW_MOUSE_PASSTHROUGH);
|
SetWindowState(FLAG_WINDOW_MOUSE_PASSTHROUGH);
|
||||||
|
|
@ -182,16 +244,51 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
tiny::ErrorLevel tiny::level{6};
|
tiny::ErrorLevel tiny::level{6};
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
netio nete{};
|
nete.start();
|
||||||
nete.download();
|
nete.github();
|
||||||
tiny::startup((char*)"enginend test",(char*)"1.0");
|
tiny::startup((char*)"enginend test",(char*)"1.0");
|
||||||
test e;
|
test e;
|
||||||
e.boot();
|
e.boot();
|
||||||
while (!WindowShouldClose()) {
|
|
||||||
|
std::atomic<bool> running{true};
|
||||||
|
|
||||||
|
std::thread tickthread([&e, &running]() {
|
||||||
|
double tickrate=1.0/e.tickrate;
|
||||||
|
auto lasttick=std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
while (running) {
|
||||||
|
auto now=std::chrono::high_resolution_clock::now();
|
||||||
|
double elapsed=std::chrono::duration_cast<std::chrono::duration<double>>(now-lasttick).count();
|
||||||
|
|
||||||
|
if (elapsed>=tickrate) {
|
||||||
e.tick();
|
e.tick();
|
||||||
e.draw();
|
lasttick=now;
|
||||||
|
} else {
|
||||||
|
std::this_thread::sleep_for(std::chrono::duration<double>(tickrate-elapsed));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
double framerate=1.0/e.framerate;
|
||||||
|
auto lastframe=std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
while (!WindowShouldClose()) {
|
||||||
|
auto now=std::chrono::high_resolution_clock::now();
|
||||||
|
double elapsed=std::chrono::duration_cast<std::chrono::duration<double>>(now-lastframe).count();
|
||||||
|
|
||||||
|
if (elapsed>=framerate) {
|
||||||
|
e.draw();
|
||||||
|
lastframe=now;
|
||||||
|
} else {
|
||||||
|
WaitTime(framerate-elapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
running=false;
|
||||||
|
tickthread.join();
|
||||||
|
|
||||||
e.exit();
|
e.exit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -5,21 +5,41 @@
|
||||||
#include<zip.h>
|
#include<zip.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <tiny/tdf.h>
|
#include <tiny/tdf.h>
|
||||||
|
#include <json.h>
|
||||||
|
#ifndef GAMEPLATFORM
|
||||||
|
#define GAMEPLATFORM "l5.64"
|
||||||
|
#endif
|
||||||
extern size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
extern size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
|
inline void makedirs(std::string path) {
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = path.find_first_of('/', pos)) != std::string::npos) {
|
||||||
|
std::string dir = path.substr(0, pos);
|
||||||
|
if (!dir.empty()) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
mkdir(dir.c_str(), 0);
|
||||||
|
#else
|
||||||
|
mkdir(dir.c_str(), 0755);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
struct netio {
|
struct netio {
|
||||||
netio()= default;
|
netio()= default;
|
||||||
std::string url="https://github.com/kin-fuyuki/forespend_cpp/releases/download/";
|
std::string url="https://github.com/kin-fuyuki/forespend_cpp/releases/download/";
|
||||||
std::vector<std::string> *versionhistory;
|
std::vector<std::string> *versionhistory;
|
||||||
void download() {
|
std::string changelog="could not connect to github\nplease check your internet connection";
|
||||||
CURL* curl = curl_easy_init();
|
void start() {
|
||||||
|
CURL* curltdf = curl_easy_init();
|
||||||
CURLcode ret;
|
CURLcode ret;
|
||||||
if (curl) {
|
if (curltdf) {
|
||||||
FILE* history = fopen("versions.tdf", "wb");
|
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(curltdf, 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(curltdf, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, history);
|
curl_easy_setopt(curltdf, CURLOPT_WRITEDATA, history);
|
||||||
ret = curl_easy_perform(curl);
|
ret = curl_easy_perform(curltdf);
|
||||||
|
curl_easy_cleanup(curltdf);
|
||||||
|
fclose(history);
|
||||||
|
|
||||||
tiny::TDF_FILE fetchversions;
|
tiny::TDF_FILE fetchversions;
|
||||||
fetchversions.filepath = "versions.tdf";
|
fetchversions.filepath = "versions.tdf";
|
||||||
|
|
@ -27,6 +47,7 @@ struct netio {
|
||||||
boost::unordered_map<std::string,tiny::TDF_DATA>* foreversions= fetchversions.getclass({"forespend"});
|
boost::unordered_map<std::string,tiny::TDF_DATA>* foreversions= fetchversions.getclass({"forespend"});
|
||||||
std::vector<std::string> versions;
|
std::vector<std::string> versions;
|
||||||
for (auto version:*foreversions) {
|
for (auto version:*foreversions) {
|
||||||
|
tiny::error("path: %s",version.first.c_str());
|
||||||
if (version.second.type==tiny::TDF_Type::TDF_DEFINES) {
|
if (version.second.type==tiny::TDF_Type::TDF_DEFINES) {
|
||||||
versions=*(std::vector<std::string>*)version.second.datapointer;
|
versions=*(std::vector<std::string>*)version.second.datapointer;
|
||||||
}
|
}
|
||||||
|
|
@ -36,22 +57,87 @@ struct netio {
|
||||||
float va = 0.0f, vb = 0.0f;
|
float va = 0.0f, vb = 0.0f;
|
||||||
char pa = ' ', pb = ' ';
|
char pa = ' ', pb = ' ';
|
||||||
char rea = ' ', reb = ' ';
|
char rea = ' ', reb = ' ';
|
||||||
|
|
||||||
sscanf(a.c_str(), "%d.%f.%c.%c", &ra, &va, &pa, &rea);
|
sscanf(a.c_str(), "%d.%f.%c.%c", &ra, &va, &pa, &rea);
|
||||||
sscanf(b.c_str(), "%d.%f.%c.%c", &rb, &vb, &pb, &reb);
|
sscanf(b.c_str(), "%d.%f.%c.%c", &rb, &vb, &pb, &reb);
|
||||||
|
|
||||||
if (ra != rb) return ra > rb;
|
if (ra != rb) return ra > rb;
|
||||||
if (va != vb) return va > vb;
|
if (va != vb) return va > vb;
|
||||||
if (pa != pb) return pa > pb;
|
if (pa != pb) return pa > pb;
|
||||||
return rea < reb;
|
return rea < reb;
|
||||||
});
|
});
|
||||||
#ifndef GAMEPLATFORM
|
tiny::success("\n\nforespend versions:");
|
||||||
#define GAMEPLATFORM "l5.64"
|
for (auto version:versions) {
|
||||||
#endif
|
|
||||||
|
tiny::warning("%s",version.c_str());
|
||||||
|
}
|
||||||
|
tiny::success("found\n\n");
|
||||||
versionhistory=&versions;
|
versionhistory=&versions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
void github() {
|
||||||
|
CURL* curl;
|
||||||
|
CURLcode res;
|
||||||
|
FILE* commitsjson = fopen("commitsjson", "wb");
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if (curl) {
|
||||||
|
std::string u = "https://api.github.com/repos/kin-fuyuki/allgames/commits";
|
||||||
|
struct curl_slist* headers = NULL;
|
||||||
|
headers = curl_slist_append(headers, "User-Agent: C++-App"); // Required by GitHub
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, u.c_str());
|
||||||
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, commitsjson);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 10L);
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
fclose(commitsjson);
|
||||||
|
changelog="changelog download error";
|
||||||
|
if (res == CURLE_OK) {
|
||||||
|
try {
|
||||||
|
changelog="json read error";
|
||||||
|
FILE* thecommits=fopen("commitsjson","rb");
|
||||||
|
changelog="json parse error";
|
||||||
|
nlohmann::json commits = nlohmann::json::parse(thecommits);
|
||||||
|
std::ostringstream oss;
|
||||||
|
std::vector<std::string> monthNames = {
|
||||||
|
"", "jan", "feb", "mar", "apr", "may", "jun",
|
||||||
|
"jul", "aug", "sep", "oct", "nov", "dec"
|
||||||
|
};
|
||||||
|
std::string lastMonth = "";
|
||||||
|
std::string currentYear = "";
|
||||||
|
int limit = std::min((int)commits.size(), 8);
|
||||||
|
for (int i = 0; i < limit; ++i) {
|
||||||
|
auto& item = commits[i];
|
||||||
|
std::string message = item["commit"]["message"];
|
||||||
|
std::string date = item["commit"]["author"]["date"]; // Format: 2025-12-21T13:08:50Z
|
||||||
|
// Extract components: YYYY-MM-DD and HH:MM:SS
|
||||||
|
std::string y = date.substr(0, 4);
|
||||||
|
std::string m = date.substr(5, 2);
|
||||||
|
std::string d = date.substr(8, 2);
|
||||||
|
std::string t = date.substr(11, 8);
|
||||||
|
// Format: MM/DD/YYYY HH:MM:SS
|
||||||
|
std::string first_line = message.substr(0, message.find('\n'));
|
||||||
|
oss << m << "/" << d << "/" << y << " " << t << "\n" << " " << first_line << "\n";
|
||||||
|
}
|
||||||
|
changelog = oss.str();
|
||||||
|
tiny::fatal("%s", changelog.c_str() );
|
||||||
|
} catch (nlohmann::json::parse_error& e) {
|
||||||
|
tiny::fatal("JSON Parse Error: %s", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void download() {
|
||||||
|
CURLcode ret;
|
||||||
std::string version=versionhistory->at(0);
|
std::string version=versionhistory->at(0);
|
||||||
|
tiny::success("using version: %s\ndownloading from: %s",version.c_str(),(url+version+"/"+GAMEPLATFORM+"."+version+".zip").c_str());
|
||||||
|
|
||||||
|
CURL*curl = curl_easy_init();
|
||||||
FILE* file = fopen(("fore."+version+".zip").c_str(), "wb");
|
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_FOLLOWLOCATION, 1L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 10L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, "https://github.com/kin-fuyuki/forespend_cpp/releases/download/0.03.a.g/l5.64.0.03.a.g.zip");
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
||||||
ret = curl_easy_perform(curl);
|
ret = curl_easy_perform(curl);
|
||||||
|
|
@ -59,18 +145,18 @@ struct netio {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
|
|
||||||
|
makedirs("forespend/versions/"+version+"/");
|
||||||
int err=0;
|
int err=0;
|
||||||
zip *z=zip_open("fore.0.03.a.g.zip",0,&err);
|
zip *z=zip_open("fore.0.03.a.g.zip",0,&err);
|
||||||
if (z) {
|
if (z) {
|
||||||
|
|
||||||
zip_int64_t it=zip_get_num_entries(z, 0);
|
zip_int64_t it=zip_get_num_entries(z, 0);
|
||||||
for (zip_int64_t i = 0; i < it; ++i) {
|
for (zip_int64_t i = 0; i < it; ++i) {
|
||||||
struct zip_stat st;
|
struct zip_stat st;
|
||||||
zip_stat_init(&st);
|
zip_stat_init(&st);
|
||||||
if (zip_stat_index(z, i, 0, &st) != 0) continue;
|
if (zip_stat_index(z, i, 0, &st) != 0) continue;
|
||||||
|
|
||||||
std::string name = st.name;
|
std::string name = st.name;
|
||||||
std::string full = "forespend/versions/"+version+"/" + name;
|
std::string full = "forespend/versions/"+version+"/" + name;
|
||||||
|
|
||||||
if (name.back() == '/') {
|
if (name.back() == '/') {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
mkdir(full.c_str(), 0);
|
mkdir(full.c_str(), 0);
|
||||||
|
|
@ -79,7 +165,6 @@ struct netio {
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pos = full.find_last_of('/');
|
size_t pos = full.find_last_of('/');
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
std::string dir = full.substr(0, pos);
|
std::string dir = full.substr(0, pos);
|
||||||
|
|
@ -89,7 +174,6 @@ struct netio {
|
||||||
mkdir(dir.c_str(), 0755);
|
mkdir(dir.c_str(), 0755);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
zip_file_t *zf = zip_fopen_index(z, i, 0);
|
zip_file_t *zf = zip_fopen_index(z, i, 0);
|
||||||
if (zf) {
|
if (zf) {
|
||||||
std::ofstream ofs(full, std::ios::binary);
|
std::ofstream ofs(full, std::ios::binary);
|
||||||
|
|
@ -105,6 +189,5 @@ struct netio {
|
||||||
zip_close(z);
|
zip_close(z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
{ forespend
|
{ forespend
|
||||||
0.03.a.g
|
0.03.a.g
|
||||||
|
#0.04.a.g
|
||||||
|
#0.4.a.g
|
||||||
|
#0.40.a.g
|
||||||
|
#4.0.a.g
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue