ok ok i made a ton of progress on theming
This commit is contained in:
parent
9ebb95135b
commit
5cbb13cf4b
14 changed files with 128 additions and 61 deletions
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
project(games)
|
||||
set(CMAKE_CXX_FLAGS "-std=c++17 -Wno-error ")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -Oz")
|
||||
if(WIN32)
|
||||
set(PLATFORM_DIR "windows")
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -w")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -w -Oz -g")
|
||||
|
||||
if (DEFINED PLATFORMNAME)
|
||||
SET(CURRPLATFORM ${PLATFORMNAME})
|
||||
|
|
@ -9,7 +9,7 @@ endif (DEFINED PLATFORMNAME)
|
|||
|
||||
file(GLOB_RECURSE ENGINE_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||
|
||||
add_library(enginend SHARED ${ENGINE_SOURCES} )
|
||||
add_library(enginend STATIC ${ENGINE_SOURCES} )
|
||||
target_link_directories(
|
||||
enginend PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/link/${CURRPLATFORM}")
|
||||
|
|
@ -33,8 +33,8 @@ target_link_directories(
|
|||
test PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/link/${CURRPLATFORM}")
|
||||
target_link_libraries(test PRIVATE
|
||||
#"${CMAKE_SOURCE_DIR}/link/${CURRPLATFORM}/libenginend.so"
|
||||
enginend
|
||||
raylib
|
||||
)
|
||||
target_include_directories(test PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
|
|
|
|||
|
|
@ -135,17 +135,15 @@ namespace enginend{
|
|||
protected:
|
||||
std::string result;
|
||||
public:
|
||||
Font font;
|
||||
float fs;
|
||||
Color txc;
|
||||
std::string content;
|
||||
text(){fs=20;}
|
||||
text(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize,std::string txt):
|
||||
text(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,float fsize,std::string txt):
|
||||
//tinted(texture,color,x,y,w,h),
|
||||
font(f),fs(fsize),content(txt),txc(txcol)
|
||||
fs(fsize),content(txt)
|
||||
{
|
||||
this->x=x;this->y=y;this->w=w;this->h=h;
|
||||
this->texture=texture;this->c=color;
|
||||
this->texture=texture;this->theme=theme;
|
||||
result=content;
|
||||
size_t initp=0;
|
||||
while((initp=result.find("\n",initp))!=std::string::npos){
|
||||
|
|
@ -175,14 +173,14 @@ namespace enginend{
|
|||
tiny::echo("og: %f %f %f %f", x,y,w,h);
|
||||
tiny::echo("drawing text: %s", content.c_str());
|
||||
tiny::echo("transformed: %f %f %f %f", ax, ay, aw, ah);
|
||||
Vector2 minsize=MeasureTextEx(font,content.c_str(),fs,1);
|
||||
Vector2 charsize=MeasureTextEx(font," ",fs,1);
|
||||
Vector2 minsize=MeasureTextEx(this->theme->font,content.c_str(),fs,1);
|
||||
Vector2 charsize=MeasureTextEx(this->theme->font," ",fs,1);
|
||||
float p=charsize.x>charsize.y?charsize.x/minsize.x:charsize.y/minsize.y;
|
||||
p=p*2;
|
||||
int minh=(minsize.y>ah)?minsize.y:ah;
|
||||
int minw=(minsize.x>aw)?minsize.x:aw;
|
||||
DrawRectangle(ax-charsize.x,ay-charsize.y,minw+p,minh+p,c);
|
||||
DrawTextEx(font,content.c_str(),{ax,ay},fs,1,txc);
|
||||
DrawRectangle(ax-charsize.x,ay-charsize.y,minw+p,minh+p,this->theme->background);
|
||||
DrawTextEx(this->theme->font,content.c_str(),{ax,ay},fs,1,this->theme->text);
|
||||
}
|
||||
void exit()override{
|
||||
tinted::exit();
|
||||
|
|
@ -192,8 +190,14 @@ namespace enginend{
|
|||
void(*func)();
|
||||
bool pressed;
|
||||
bool hover;
|
||||
button():func(nullptr),pressed(false),hover(false){}
|
||||
button(Texture2D* texture,Color color,double x,double y,double w,double h,void(*f)()):func(f),pressed(false),hover(false),tinted(texture,color,x,y,w,h){}
|
||||
const bool isboolean;
|
||||
bool boolean=false;
|
||||
button():func(nullptr),pressed(false),hover(false),isboolean(false){}
|
||||
button(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,void(*f)()):func(f),pressed(false),hover(false),isboolean(false) {
|
||||
this->theme=theme;
|
||||
}button(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,void(*f)(),bool isboolean):func(f),pressed(false),hover(false),isboolean(isboolean) {
|
||||
this->theme=theme;
|
||||
}
|
||||
void boot()override{}
|
||||
void tick()override{
|
||||
Vector2 mouse=GetMousePosition();
|
||||
|
|
@ -203,16 +207,26 @@ namespace enginend{
|
|||
if(CheckCollisionPointRec(mouse,r)){hover=true;
|
||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||
pressed=true;
|
||||
c=isboolean?boolean?
|
||||
this->theme->booleanbutton[5]:this->theme->booleanbutton[2]:
|
||||
this->theme->button[2];
|
||||
if(func)func();
|
||||
}else{
|
||||
pressed=false;
|
||||
c=isboolean?boolean?
|
||||
this->theme->booleanbutton[4]:this->theme->button[1]:
|
||||
this->theme->button[1];
|
||||
}
|
||||
}else{
|
||||
hover=false;
|
||||
pressed=false;
|
||||
c=isboolean?boolean?
|
||||
this->theme->booleanbutton[3]:this->theme->button[0]:
|
||||
this->theme->button[0];
|
||||
}
|
||||
}
|
||||
void draw()override {
|
||||
|
||||
tinted::draw();
|
||||
}
|
||||
void exit()override{
|
||||
|
|
@ -221,13 +235,16 @@ namespace enginend{
|
|||
};
|
||||
struct labeledbutton :virtual public button {
|
||||
std::string label;
|
||||
Font font;
|
||||
int fs;
|
||||
Color txc;
|
||||
labeledbutton(std::string name,Texture2D* texture,Color color,Color text,
|
||||
labeledbutton(std::string name,Texture2D* texture,enginend::theme*theme,Color text,
|
||||
double x,double y,double w,double h,void(*f)(),int size):fs(size),txc(text),label(name),
|
||||
button(texture,theme,x,y,w,h,f)
|
||||
{}
|
||||
labeledbutton(std::string name,Texture2D* texture,enginend::theme*theme,Color text,
|
||||
double x,double y,double w,double h,void(*f)(),
|
||||
Font fnt,int size):font(fnt),fs(size),txc(text),label(name),
|
||||
button(texture,color,x,y,w,h,f)
|
||||
int size,bool isboolean):fs(size),txc(text),label(name),
|
||||
button(texture,theme,x,y,w,h,f,isboolean)
|
||||
{}
|
||||
void boot()override{}
|
||||
void tick()override{
|
||||
|
|
@ -241,12 +258,27 @@ namespace enginend{
|
|||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
float ah=h*sh;
|
||||
Vector2 tsize=MeasureTextEx(font,label.c_str(),fs,1);
|
||||
Vector2 tsize=MeasureTextEx(this->theme->font,label.c_str(),fs,1);
|
||||
Vector2 tpos={
|
||||
ax+(aw-tsize.x)/2,
|
||||
ay+(ah-tsize.y)/2
|
||||
};
|
||||
DrawTextEx(font,label.c_str(),tpos,fs,1,txc);
|
||||
if (hover) {
|
||||
if (pressed) {
|
||||
txc=isboolean?boolean?
|
||||
this->theme->booleantext[5]:this->theme->booleantext[2]:
|
||||
this->theme->buttontext[2];
|
||||
}else {
|
||||
txc=isboolean?boolean?
|
||||
this->theme->booleantext[4]:this->theme->buttontext[1]:
|
||||
this->theme->button[1];
|
||||
}
|
||||
}else {
|
||||
txc=isboolean?boolean?
|
||||
this->theme->booleantext[3]:this->theme->button[0]:
|
||||
this->theme->button[0];
|
||||
}
|
||||
DrawTextEx(this->theme->font,label.c_str(),tpos,fs,1,txc);
|
||||
}
|
||||
void exit()override{
|
||||
button::exit();
|
||||
|
|
@ -288,8 +320,8 @@ namespace enginend{
|
|||
};
|
||||
struct textfield :public text{
|
||||
textfield(){}
|
||||
textfield(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize,std::string txt):
|
||||
text(texture,txcol,color,x,y,w,h,f,fsize,txt){}
|
||||
textfield(Texture2D* texture,enginend::theme *theme,double x,double y,double w,double h,float fsize,std::string txt):
|
||||
text(texture,theme,x,y,w,h,fsize,txt){}
|
||||
void boot()override{}
|
||||
void tick()override{
|
||||
text::tick();
|
||||
|
|
@ -301,13 +333,13 @@ namespace enginend{
|
|||
float ay=y*sh;
|
||||
float aw=w*sw;
|
||||
float ah=h*sh;
|
||||
Vector2 charsize=MeasureTextEx(font," ",fs,0);
|
||||
Vector2 minsize=MeasureTextEx(font,content.c_str(),fs,charsize.x/2);
|
||||
Vector2 charsize=MeasureTextEx(this->theme->font," ",fs,0);
|
||||
Vector2 minsize=MeasureTextEx(this->theme->font,content.c_str(),fs,charsize.x/2);
|
||||
float po=charsize.x>charsize.y?charsize.x/charsize.y:charsize.y/charsize.x;po=po*5;
|
||||
int minh=(minsize.y>ah)?minsize.y:ah;
|
||||
int minw=(minsize.x>aw)?minsize.x:aw;
|
||||
DrawRectangle(ax-(po/2),ay-(po/2),minw+(po*1.1),minh+(po*1.1),c);
|
||||
DrawTextEx(font,content.c_str(),{ax,ay},fs,charsize.x/2,txc);
|
||||
DrawRectangle(ax-(po/2),ay-(po/2),minw+(po*1.1),minh+(po*1.1),this->theme->textfieldbg);
|
||||
DrawTextEx(this->theme->font,content.c_str(),{ax,ay},fs,charsize.x/2,this->theme->text);
|
||||
}
|
||||
void exit()override{
|
||||
text::exit();
|
||||
|
|
@ -317,8 +349,8 @@ namespace enginend{
|
|||
bool active;
|
||||
int cpos;
|
||||
textinput():active(false),cpos(0){}
|
||||
textinput(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize):active(false),cpos(0),
|
||||
text(texture,txcol,color,x,y,w,h,f,fsize,""){}
|
||||
textinput(Texture2D* texture,enginend::theme *theme,double x,double y,double w,double h,float fsize):active(false),cpos(0),
|
||||
text(texture,theme,x,y,w,h,fsize,""){}
|
||||
void boot()override{}
|
||||
void tick()override{
|
||||
text::tick();
|
||||
|
|
@ -351,7 +383,7 @@ namespace enginend{
|
|||
float sh=GetScreenHeight();
|
||||
float ax=x*sw;
|
||||
float ay=y*sh;
|
||||
DrawRectangle(ax+MeasureTextEx(font,content.c_str(),fs,1).x,ay,2,fs,{0,0,0,127});
|
||||
DrawRectangle(ax+MeasureTextEx(this->theme->font,content.c_str(),fs,1).x,ay,2,fs,{0,0,0,127});
|
||||
}
|
||||
}
|
||||
void exit()override{
|
||||
|
|
@ -362,8 +394,8 @@ namespace enginend{
|
|||
bool active;
|
||||
int cpos;
|
||||
textinputfield():active(false),cpos(0){}
|
||||
textinputfield(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize):active(false),cpos(0),
|
||||
textfield(texture,txcol,color,x,y,w,h,f,fsize,""){}
|
||||
textinputfield(Texture2D* texture,enginend::theme *theme,double x,double y,double w,double h,float fsize):active(false),cpos(0),
|
||||
textfield(texture,theme,x,y,w,h,fsize,""){}
|
||||
void boot()override{}
|
||||
void tick()override{
|
||||
textfield::tick();
|
||||
|
|
@ -411,7 +443,7 @@ namespace enginend{
|
|||
line+=ch;
|
||||
}
|
||||
}
|
||||
DrawRectangle(p.x+MeasureTextEx(font,line.c_str(),fs,1).x,p.y,2,fs,rl::BLACK);
|
||||
DrawRectangle(p.x+MeasureTextEx(this->theme->font,line.c_str(),fs,1).x,p.y,2,fs,rl::BLACK);
|
||||
}
|
||||
}
|
||||
void exit()override{
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@
|
|||
#include<tiny/term.h>
|
||||
|
||||
namespace enginend {
|
||||
struct theme;
|
||||
|
||||
namespace nodes {
|
||||
struct node{
|
||||
public:
|
||||
enginend::theme* theme;
|
||||
virtual void boot()=0;
|
||||
virtual void tick()=0;
|
||||
virtual void draw()=0;
|
||||
|
|
@ -29,7 +32,9 @@
|
|||
|
||||
struct theme {
|
||||
// in case if its a boolean button, it will use booleanbutton
|
||||
Color booleanbutton[3],button[3],booleantext[3],buttontext[3],text,buttonborder[3],booleanborder[3],border;
|
||||
Color booleanbutton[6],button[3],booleantext[6],buttontext[3],text,buttonborder[3],booleanborder[6],border,background
|
||||
,textfieldbg
|
||||
;
|
||||
|
||||
Font font;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ else ()
|
|||
endif (DEFINED PLATFORMNAME)
|
||||
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++26 -w -g -Wno-error -O0")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -w -g -Wno-error -O0")
|
||||
file(GLOB_RECURSE ENDLAUNCHER "src/*.cpp")
|
||||
add_executable(endlauncher ${ENDLAUNCHER})
|
||||
|
||||
|
|
@ -18,7 +18,8 @@ target_link_directories(
|
|||
endlauncher PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/link/${PLATFORMNAME}")
|
||||
target_link_libraries(endlauncher PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/link/${PLATFORMNAME}/libenginend.so"
|
||||
enginend
|
||||
raylib
|
||||
curl zip
|
||||
)
|
||||
target_include_directories(endlauncher PUBLIC
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include <incmgr.h>
|
||||
#include <raylib.h>
|
||||
#include <enginend/scenes/node2d.h>
|
||||
|
||||
#include <enginend/engine.h>
|
||||
#include "netio.h"
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
|
@ -119,6 +118,8 @@ public:
|
|||
const char* CONF() final{return "test.tdf";}
|
||||
launcher(){};
|
||||
void boot() override {
|
||||
currentscene = new scene{};
|
||||
|
||||
tickrate=15;
|
||||
framerate=15;
|
||||
SetConfigFlags(FLAG_WINDOW_UNDECORATED|FLAG_WINDOW_TRANSPARENT|FLAG_WINDOW_TOPMOST);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -w")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -Oz -w -g")
|
||||
file(GLOB_RECURSE FORESPEND_SOURCES CONFIGURE_DEPENDS "src/*.cpp")
|
||||
add_executable(forespend ${FORESPEND_SOURCES})
|
||||
if(NOT DEFINED ${ARCH})
|
||||
|
|
@ -14,8 +14,8 @@ target_link_directories(
|
|||
forespend PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/link")
|
||||
target_link_libraries(forespend PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/link/${PLATFORMNAME}/libenginend.so"
|
||||
"${CMAKE_SOURCE_DIR}/link/${PLATFORMNAME}/libraylib.a"
|
||||
enginend
|
||||
raylib
|
||||
)
|
||||
target_include_directories(forespend PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ void client::boot() {
|
|||
this->tickrate=20;
|
||||
// SetConfigFlags();
|
||||
InitWindow(380,240,"forespend - 0.03h");
|
||||
initconfigmenu();
|
||||
this->currentscene=new mainmenu();
|
||||
this->currentscene->boot();
|
||||
target=LoadRenderTexture(380,240);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
#include "configmenu.h"
|
||||
|
||||
#include "../../common/themes.h"
|
||||
#include <enginend/scenes/node2d.h>
|
||||
Font forefont;
|
||||
int configmenupage=0; // 0 is before the mainpage is showing. aka pause menu/main menu when start game
|
||||
enginend::group mainpage= enginend::group(
|
||||
{
|
||||
new enginend::nodes::labeledbutton("video",nullptr,{255,127,0,255},{0,0,0,0},100,100,0,0,std::function<void()>([]() {
|
||||
new enginend::nodes::labeledbutton("video",nullptr,&clienttheme,100,100,0,0,std::function<void()>([]() {
|
||||
|
||||
}),forefont,32),
|
||||
new enginend::nodes::labeledbutton("sound",nullptr,{255,127,0,255},{0,0,0,0},100,100,0,0,std::function<void()>([]() {
|
||||
new enginend::nodes::labeledbutton("sound",nullptr,&clienttheme,100,100,0,0,std::function<void()>([]() {
|
||||
|
||||
}),forefont,32),
|
||||
new enginend::nodes::labeledbutton("input",nullptr,{255,127,0,255},{0,0,0,0},100,100,0,0,std::function<void()>([]() {
|
||||
new enginend::nodes::labeledbutton("input",nullptr,&clienttheme,100,100,0,0,std::function<void()>([]() {
|
||||
|
||||
}),forefont,32),
|
||||
|
||||
|
|
@ -20,7 +19,7 @@ enginend::group mainpage= enginend::group(
|
|||
|
||||
enginend::group graphics= enginend::group(
|
||||
{
|
||||
new enginend::nodes::labeledbutton("fullscreen",nullptr,{255,127,0,255},{0,0,0,0},100,100,0,0,std::function<void()>([]() {
|
||||
new enginend::nodes::labeledbutton("fullscreen",nullptr,&clienttheme,100,100,0,0,std::function<void()>([]() {
|
||||
|
||||
}),forefont,32),
|
||||
}
|
||||
|
|
@ -34,7 +33,4 @@ enginend::group controls= enginend::group(
|
|||
{
|
||||
|
||||
}
|
||||
);
|
||||
void initconfigmenu() {
|
||||
forefont=LoadFont(AT("res/fonts/dos.fnt"));
|
||||
}
|
||||
);
|
||||
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
#include <enginend/engine.h>
|
||||
|
||||
extern Font forefont;
|
||||
extern enginend::group maincfgpage;
|
||||
extern enginend::group graphics;
|
||||
extern enginend::group sound;
|
||||
extern enginend::group controls;
|
||||
extern int configmenupage;
|
||||
void initconfigmenu();
|
||||
extern int configmenupage;
|
||||
|
|
@ -1,4 +1,35 @@
|
|||
#include "themes.h"
|
||||
|
||||
enginend::theme clienttheme;
|
||||
enginend::theme servertheme;
|
||||
Font forefont;
|
||||
enginend::theme clienttheme{
|
||||
.textfieldbg ={127,0,0,127},
|
||||
.background = {0,0,0,0},
|
||||
.border = {0,0,0,0},
|
||||
.booleanbutton = {
|
||||
{0,200,0,180},
|
||||
{100,200,100,180},
|
||||
{100,255,100,255},
|
||||
{200,0,0,180},
|
||||
{200,100,100,180},
|
||||
{255,100,100,255},
|
||||
},
|
||||
.text = {255,127,0,255},
|
||||
.font = forefont,
|
||||
.tint = {255,255,255,255},
|
||||
.button = {
|
||||
{0,0,0,0},
|
||||
{255,255,255,80},
|
||||
{255,255,255,160}
|
||||
},
|
||||
.buttontext = {
|
||||
{255,255,255,255},
|
||||
{255,255,255,255},
|
||||
{255,255,255,255}
|
||||
}
|
||||
|
||||
};
|
||||
enginend::theme servertheme;
|
||||
|
||||
void initthemes() {
|
||||
forefont=LoadFont(AT("res/fonts/dos.fnt"));
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
#include <enginend/scenes/nodes.h>
|
||||
#include <enginend/engine.h>
|
||||
|
||||
extern Font forefont;
|
||||
extern enginend::theme clienttheme;
|
||||
extern enginend::theme servertheme;
|
||||
extern enginend::theme servertheme;
|
||||
void initthemes();
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "server/server.h"
|
||||
#include "client/client.h"
|
||||
#include "common/themes.h"
|
||||
PLATFORM platform=LINUX;
|
||||
std::string androidpackage="kn.kinfuyuki.forespend";
|
||||
inline const char* COMMONCONFIG(){return "common.tdf";}
|
||||
|
|
@ -12,6 +13,7 @@ int main(int argc, char** argv) {
|
|||
enginend::program* game;
|
||||
tiny::startup("forespend","0.03g-rewrite");
|
||||
bool isserver = false;
|
||||
initthemes();
|
||||
if (argc>1) {
|
||||
for (int i=1;i<argc;i++) {
|
||||
if (argv[i]=="server ") {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 970c955be89ba6a25db3880e508634467357aff4
|
||||
Subproject commit 2783e40e292de9fb9e671be834baadddeffc325b
|
||||
Loading…
Add table
Add a link
Reference in a new issue