changed some stuf around lol
wow i didnt know that kate had extended git message. this is rlly cool rlly
This commit is contained in:
parent
aa92184cf5
commit
1df1cef78f
33 changed files with 659 additions and 900 deletions
12
.gitignore
vendored
12
.gitignore
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
*.so
|
.idea
|
||||||
*.so*
|
.cache
|
||||||
endlauncher.l5
|
.vscode
|
||||||
test.l5
|
_old
|
||||||
forespend.l5
|
cmake-build-debug
|
||||||
|
build.sh
|
||||||
|
|
|
||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -23,3 +23,6 @@
|
||||||
path = lib/luajit
|
path = lib/luajit
|
||||||
url = https://github.com/LuaJIT/LuaJIT.git
|
url = https://github.com/LuaJIT/LuaJIT.git
|
||||||
branch = v2.0
|
branch = v2.0
|
||||||
|
[submodule "lib/ultralight"]
|
||||||
|
path = lib/ultralight
|
||||||
|
url = https://github.com/ultralight-ux/Ultralight.git
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@ add_subdirectory(games/forespend)
|
||||||
add_subdirectory(games/pretend)
|
add_subdirectory(games/pretend)
|
||||||
add_subdirectory(games/animatronical/q1/a1)
|
add_subdirectory(games/animatronical/q1/a1)
|
||||||
add_subdirectory(games/endlauncher)
|
add_subdirectory(games/endlauncher)
|
||||||
|
add_subdirectory(apps/kstralight)
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
8
CONTRIBUTING.md
Normal file
8
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# IF YOU DONT FOLLOW THESE RULES, YOU WILL BE BLOCKED
|
||||||
|
|
||||||
|
DO NOT AI SLOP PULL REQUEST, IF YOU USE AI FOR CODE PLEASE VERIFY INTEGRITY MANUALLY.
|
||||||
|
|
||||||
|
ONLY PULL REQUEST FOR WHAT IS TOLD ON ISSUES, MANUALLY LOOK THROUGH ISSUES ON THE BUG ASPECT AND APPROVED FEATURE REQUESTS
|
||||||
|
|
||||||
|
DO NOT MAKE "SYNTAX FIX" OR "STYLE FIX" PULL REQUESTS OR ISSUES, AS THEY ARE BASICALLY USELESS.
|
||||||
|
# THE COMPUTER DOESNT GIVE A DAMN IF YOU ARE SAYING C, COL, COLOR OR COLOUR.
|
||||||
112
MEDIA_LICENSE.MD
Normal file
112
MEDIA_LICENSE.MD
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
Free Art License 1.3 (FAL 1.3)
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The Free Art License grants the right to freely copy, distribute, and transform creative works without infringing the author’s rights.
|
||||||
|
|
||||||
|
The Free Art License recognizes and protects these rights. Their implementation has been reformulated in order to allow everyone to use creations of the human mind in a creative manner, regardless of their types and ways of expression.
|
||||||
|
|
||||||
|
While the public’s access to creations of the human mind usually is restricted by the implementation of copyright law, it is favoured by the Free Art License. This license intends to allow the use of a work’s resources; to establish new conditions for creating in order to increase creation opportunities. The Free Art License grants the right to use a work, and acknowledges the right holder’s and the user’s rights and responsibility.
|
||||||
|
|
||||||
|
The invention and development of digital technologies, Internet and Free Software have changed creation methods: creations of the human mind can obviously be distributed, exchanged, and transformed. They allow to produce common works to which everyone can contribute to the benefit of all.
|
||||||
|
|
||||||
|
The main rationale for this Free Art License is to promote and protect these creations of the human mind according to the principles of copyleft: freedom to use, copy, distribute, transform, and prohibition of exclusive appropriation.
|
||||||
|
|
||||||
|
Definitions
|
||||||
|
|
||||||
|
« work » either means the initial work, the subsequent works or the common work as defined hereafter:
|
||||||
|
|
||||||
|
« common work » means a work composed of the initial work and all subsequent contributions to it (originals and copies). The initial author is the one who, by choosing this license, defines the conditions under which contributions are made.
|
||||||
|
|
||||||
|
« Initial work » means the work created by the initiator of the common work (as defined above), the copies of which can be modified by whoever wants to
|
||||||
|
|
||||||
|
« Subsequent works » means the contributions made by authors who participate in the evolution of the common work by exercising the rights to reproduce, distribute, and modify that are granted by the license.
|
||||||
|
|
||||||
|
« Originals » (sources or resources of the work) means all copies of either the initial work or any subsequent work mentioning a date and used by their author(s) as references for any subsequent updates, interpretations, copies or reproductions.
|
||||||
|
|
||||||
|
« Copy » means any reproduction of an original as defined by this license.
|
||||||
|
|
||||||
|
1. OBJECT
|
||||||
|
The aim of this license is to define the conditions under which one can use this work freely.
|
||||||
|
|
||||||
|
2. SCOPE
|
||||||
|
This work is subject to copyright law. Through this license its author specifies the extent to which you can copy, distribute, and modify it.
|
||||||
|
|
||||||
|
2.1 FREEDOM TO COPY (OR TO MAKE REPRODUCTIONS)
|
||||||
|
You have the right to copy this work for yourself, your friends or any other person, whatever the technique used.
|
||||||
|
|
||||||
|
2.2 FREEDOM TO DISTRIBUTE, TO PERFORM IN PUBLIC
|
||||||
|
You have the right to distribute copies of this work; whether modified or not, whatever the medium and the place, with or without any charge, provided that you:
|
||||||
|
attach this license without any modification to the copies of this work or indicate precisely where the license can be found,
|
||||||
|
specify to the recipient the names of the author(s) of the originals, including yours if you have modified the work,
|
||||||
|
specify to the recipient where to access the originals (either initial or subsequent).
|
||||||
|
The authors of the originals may, if they wish to, give you the right to distribute the originals under the same conditions as the copies.
|
||||||
|
|
||||||
|
2.3 FREEDOM TO MODIFY
|
||||||
|
You have the right to modify copies of the originals (whether initial or subsequent) provided you comply with the following conditions:
|
||||||
|
all conditions in article 2.2 above, if you distribute modified copies;
|
||||||
|
indicate that the work has been modified and, if it is possible, what kind of modifications have been made;
|
||||||
|
distribute the subsequent work under the same license or any compatible license.
|
||||||
|
The author(s) of the original work may give you the right to modify it under the same conditions as the copies.
|
||||||
|
|
||||||
|
3. RELATED RIGHTS
|
||||||
|
Activities giving rise to author’s rights and related rights shall not challenge the rights granted by this license.
|
||||||
|
For example, this is the reason why performances must be subject to the same license or a compatible license. Similarly, integrating the work in a database, a compilation or an anthology shall not prevent anyone from using the work under the same conditions as those defined in this license.
|
||||||
|
|
||||||
|
4. INCORPORATION OF THE WORK
|
||||||
|
Incorporating this work into a larger work that is not subject to the Free Art License shall not challenge the rights granted by this license.
|
||||||
|
If the work can no longer be accessed apart from the larger work in which it is incorporated, then incorporation shall only be allowed under the condition that the larger work is subject either to the Free Art License or a compatible license.
|
||||||
|
|
||||||
|
5. COMPATIBILITY
|
||||||
|
A license is compatible with the Free Art License provided:
|
||||||
|
it gives the right to copy, distribute, and modify copies of the work including for commercial purposes and without any other restrictions than those required by the respect of the other compatibility criteria;
|
||||||
|
it ensures proper attribution of the work to its authors and access to previous versions of the work when possible;
|
||||||
|
it recognizes the Free Art License as compatible (reciprocity);
|
||||||
|
it requires that changes made to the work be subject to the same license or to a license which also meets these compatibility criteria.
|
||||||
|
|
||||||
|
6. YOUR INTELLECTUAL RIGHTS
|
||||||
|
This license does not aim at denying your author’s rights in your contribution or any related right. By choosing to contribute to the development of this common work, you only agree to grant others the same rights with regard to your contribution as those you were granted by this license. Conferring these rights does not mean you have to give up your intellectual rights.
|
||||||
|
|
||||||
|
7. YOUR RESPONSIBILITIES
|
||||||
|
The freedom to use the work as defined by the Free Art License (right to copy, distribute, modify) implies that everyone is responsible for their own actions.
|
||||||
|
|
||||||
|
8. DURATION OF THE LICENSE
|
||||||
|
This license takes effect as of your acceptance of its terms. The act of copying, distributing, or modifying the work constitutes a tacit agreement. This license will remain in effect for as long as the copyright which is attached to the work. If you do not respect the terms of this license, you automatically lose the rights that it confers.
|
||||||
|
If the legal status or legislation to which you are subject makes it impossible for you to respect the terms of this license, you may not make use of the rights which it confers.
|
||||||
|
|
||||||
|
9. VARIOUS VERSIONS OF THE LICENSE
|
||||||
|
This license may undergo periodic modifications to incorporate improvements by its authors (instigators of the « Copyleft Attitude » movement) by way of new, numbered versions.
|
||||||
|
You will always have the choice of accepting the terms contained in the version under which the copy of the work was distributed to you, or alternatively, to use the provisions of one of the subsequent versions.
|
||||||
|
|
||||||
|
10. SUB-LICENSING
|
||||||
|
Sub-licenses are not authorized by this license. Any person wishing to make use of the rights that it confers will be directly bound to the authors of the common work.
|
||||||
|
|
||||||
|
11. LEGAL FRAMEWORK
|
||||||
|
This license is written with respect to both French law and the Berne Convention for the Protection of Literary and Artistic Works.
|
||||||
|
|
||||||
|
USER GUIDE
|
||||||
|
|
||||||
|
– How to use the Free Art License?
|
||||||
|
To benefit from the Free Art License, you only need to mention the following elements on your work:
|
||||||
|
[Name of the author, title, date of the work. When applicable, names of authors of the common work and, if possible, where to find the originals].
|
||||||
|
Copyleft: This is a free work, you can copy, distribute, and modify it under the terms of the Free Art License https://artlibre.org/licence/lal/en/
|
||||||
|
|
||||||
|
– Why to use the Free Art License?
|
||||||
|
1.To give the greatest number of people access to your work.
|
||||||
|
2.To allow it to be distributed freely.
|
||||||
|
3.To allow it to evolve by allowing its copy, distribution, and transformation by others.
|
||||||
|
4.So that you benefit from the resources of a work when it is under the Free Art License: to be able to copy, distribute or transform it freely.
|
||||||
|
5.But also, because the Free Art License offers a legal framework to disallow any misappropriation. It is forbidden to take hold of your work and bypass the creative process for one’s exclusive possession.
|
||||||
|
|
||||||
|
– When to use the Free Art License?
|
||||||
|
Any time you want to benefit and make others benefit from the right to copy, distribute and transform creative works without any exclusive appropriation, you should use the Free Art License. You can for example use it for scientific, artistic or educational projects.
|
||||||
|
|
||||||
|
– What kinds of works can be subject to the Free Art License?
|
||||||
|
The Free Art License can be applied to digital as well as physical works.
|
||||||
|
You can choose to apply the Free Art License on any text, picture, sound, gesture, or whatever sort of stuff on which you have sufficient author’s rights.
|
||||||
|
|
||||||
|
– Historical background of this license:
|
||||||
|
It is the result of observing, using and creating digital technologies, free software, the Internet and art. It arose from the « Copyleft Attitude » meetings which took place in Paris in 2000. For the first time, these meetings brought together members of the Free Software community, artists, and members of the art world. The goal was to adapt the principles of Copyleft and free software to all sorts of creations. http://www.artlibre.org
|
||||||
|
|
||||||
|
Copyleft Attitude, 2007.
|
||||||
|
You can make reproductions and distribute this license verbatim (without any changes).
|
||||||
23
apps/kstralight/CMakeLists.txt
Normal file
23
apps/kstralight/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -Oz -w -g -mavx2")
|
||||||
|
file(GLOB_RECURSE kstralight_SOURCES CONFIGURE_DEPENDS "src/*.cpp")
|
||||||
|
add_executable(kstralight ${kstralight_SOURCES})
|
||||||
|
if(NOT DEFINED ${ARCH})
|
||||||
|
set(ARCH "linux-64")
|
||||||
|
endif(NOT DEFINED ${ARCH})
|
||||||
|
set_target_properties(kstralight PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built/kstralight/${PLATFORM_DIR}/bin"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_directories(
|
||||||
|
kstralight PUBLIC
|
||||||
|
"${CMAKE_SOURCE_DIR}/link")
|
||||||
|
target_link_libraries(kstralight PRIVATE
|
||||||
|
enginend
|
||||||
|
raylib
|
||||||
|
|
||||||
|
)
|
||||||
|
target_include_directories(kstralight PUBLIC
|
||||||
|
${CMAKE_SOURCE_DIR}/include
|
||||||
|
)
|
||||||
37
apps/kstralight/res/index.tsf.tdf
Normal file
37
apps/kstralight/res/index.tsf.tdf
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
" font eagle.ttf
|
||||||
|
|
||||||
|
{ text
|
||||||
|
f r 255
|
||||||
|
f g 255
|
||||||
|
f b 255
|
||||||
|
f a 255
|
||||||
|
}
|
||||||
|
|
||||||
|
{ link
|
||||||
|
" font dos.ttf
|
||||||
|
{ normal
|
||||||
|
|
||||||
|
}
|
||||||
|
{ hover
|
||||||
|
|
||||||
|
}
|
||||||
|
{ click
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ button
|
||||||
|
{ normal
|
||||||
|
|
||||||
|
}
|
||||||
|
{ hover
|
||||||
|
|
||||||
|
}
|
||||||
|
{ click
|
||||||
|
|
||||||
|
}
|
||||||
|
{ disabled
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
80
apps/kstralight/res/index.twf.tdf
Normal file
80
apps/kstralight/res/index.twf.tdf
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
{ style main
|
||||||
|
" path index.tsf.tdf
|
||||||
|
|
||||||
|
{ sub
|
||||||
|
{ col header
|
||||||
|
b rel T
|
||||||
|
f x 0
|
||||||
|
f y 0
|
||||||
|
f w 1
|
||||||
|
f h 0.2
|
||||||
|
f r 0.25
|
||||||
|
f g 0
|
||||||
|
f b 0
|
||||||
|
f a 1
|
||||||
|
{ sub
|
||||||
|
{ text welcome
|
||||||
|
b rel T
|
||||||
|
f x 0
|
||||||
|
f y 0
|
||||||
|
f w 1
|
||||||
|
f h 0.75
|
||||||
|
S txt
|
||||||
|
welcome to tiny web ^^
|
||||||
|
\
|
||||||
|
}
|
||||||
|
{ text message
|
||||||
|
b rel T
|
||||||
|
f x 0
|
||||||
|
f y 0.75
|
||||||
|
f w 1
|
||||||
|
f h 0.25
|
||||||
|
S txt
|
||||||
|
here you will learn the basics of how to create a tiny webpage
|
||||||
|
\
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# header end
|
||||||
|
{ col body
|
||||||
|
b rel T
|
||||||
|
f x 0.2
|
||||||
|
f y 0
|
||||||
|
f w 1
|
||||||
|
f h 5.0
|
||||||
|
f r 0.125
|
||||||
|
f g 0.125
|
||||||
|
f b 0.125
|
||||||
|
f a 1
|
||||||
|
{ sub
|
||||||
|
{ text message
|
||||||
|
b rel T
|
||||||
|
f x 0.1
|
||||||
|
f y 0.1
|
||||||
|
f w 0.9
|
||||||
|
f h 0.2
|
||||||
|
S txt
|
||||||
|
first of all, sorry to tell you but you will have to create these tiny files that.. are not the most readable
|
||||||
|
so until i can create an editor, i deeply recommend you to keep your pages very simple in styling.
|
||||||
|
|
||||||
|
but i do plan to create a proper IDE for TDF and TMK where you will not have to worry about the code at all...
|
||||||
|
just have to place nodes and blocks and pointers and u can be happy heh.
|
||||||
|
\
|
||||||
|
}
|
||||||
|
{ link repo
|
||||||
|
b rel T
|
||||||
|
f x 0.3
|
||||||
|
f y 0.1
|
||||||
|
f w 0.9
|
||||||
|
f h 0.02
|
||||||
|
S txt
|
||||||
|
look at my other projects!
|
||||||
|
\
|
||||||
|
" path https://github.com/kin-fuyuki
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# body end
|
||||||
|
}
|
||||||
|
# end of the style sub-elements
|
||||||
|
}
|
||||||
1
apps/kstralight/src/data/browser/config.cpp
Normal file
1
apps/kstralight/src/data/browser/config.cpp
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "config.h"
|
||||||
5
apps/kstralight/src/data/browser/config.h
Normal file
5
apps/kstralight/src/data/browser/config.h
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class config {
|
||||||
|
};
|
||||||
1
apps/kstralight/src/data/browser/session.cpp
Normal file
1
apps/kstralight/src/data/browser/session.cpp
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "session.h"
|
||||||
5
apps/kstralight/src/data/browser/session.h
Normal file
5
apps/kstralight/src/data/browser/session.h
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class session {
|
||||||
|
};
|
||||||
20
apps/kstralight/src/data/formats.cpp
Normal file
20
apps/kstralight/src/data/formats.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "formats.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::map<std::string,datagroup> cookie{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::map<std::string,datagroup> tinywebformat{
|
||||||
|
{"point",datagroup({TWFPOINT})},
|
||||||
|
{"rect",datagroup({TWFRECT})},
|
||||||
|
{"text",datagroup({TWFTEXT})},
|
||||||
|
{"img",datagroup({TWFIMG})},
|
||||||
|
{"link",datagroup({TWFLINK})},
|
||||||
|
{"col",datagroup({TWFCOL})},
|
||||||
|
};
|
||||||
|
std::map<std::string,datagroup> tinywebstyle{
|
||||||
|
|
||||||
|
};
|
||||||
24
apps/kstralight/src/data/formats.h
Normal file
24
apps/kstralight/src/data/formats.h
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include <tiny/tdf.h>
|
||||||
|
|
||||||
|
struct datagroup {
|
||||||
|
std::map<std::string, tiny::TDF_Type> data;
|
||||||
|
datagroup(std::map<std::string, tiny::TDF_Type> data):data(data){}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern std::map<std::string,datagroup> cookie;
|
||||||
|
#define TWFELEMENT {"sub",tiny::TDF_CLASS},
|
||||||
|
#define TWFSTYLE TWFELEMENT {"path",tiny::TDF_STR},
|
||||||
|
#define TWFSTYLED {"style",tiny::TDF_CLASS},
|
||||||
|
#define TWFPOINT TWFELEMENT {"x",tiny::TDF_FLOAT},{"y",tiny::TDF_FLOAT},{"rel",tiny::TDF_BOOL},
|
||||||
|
#define TWFRECT TWFPOINT {"w",tiny::TDF_FLOAT},{"h",tiny::TDF_FLOAT},
|
||||||
|
#define TWFCOL TWFRECT {"r",tiny::TDF_FLOAT},{"g",tiny::TDF_FLOAT},{"b",tiny::TDF_FLOAT},{"a",tiny::TDF_FLOAT},
|
||||||
|
#define TWFTEXT TWFRECT TWFSTYLED {"txt",tiny::TDF_BLOCK},
|
||||||
|
#define TWFLINK TWFTEXT {"path",tiny::TDF_STR},
|
||||||
|
#define TWFBUTTON TWFLINK {"disabled",tiny::TDF_BOOL},
|
||||||
|
#define TWFIMG TWFRECT {"path",tiny::TDF_STR},
|
||||||
|
|
||||||
|
extern std::map<std::string,datagroup> tinywebformat;
|
||||||
|
|
||||||
|
extern std::map<std::string,datagroup> tinywebstyle;
|
||||||
1
apps/kstralight/src/data/web/cookies.cpp
Normal file
1
apps/kstralight/src/data/web/cookies.cpp
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "cookies.h"
|
||||||
5
apps/kstralight/src/data/web/cookies.h
Normal file
5
apps/kstralight/src/data/web/cookies.h
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class cookies {
|
||||||
|
};
|
||||||
1
apps/kstralight/src/gui/browser.cpp
Normal file
1
apps/kstralight/src/gui/browser.cpp
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "browser.h"
|
||||||
22
apps/kstralight/src/gui/browser.h
Normal file
22
apps/kstralight/src/gui/browser.h
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
#include <enginend/engine.h>
|
||||||
|
|
||||||
|
|
||||||
|
class basic : public enginend::program{
|
||||||
|
public:
|
||||||
|
basic();
|
||||||
|
void boot() override;
|
||||||
|
void draw() override;
|
||||||
|
void tick() override;
|
||||||
|
void exit() override;
|
||||||
|
~basic();
|
||||||
|
};
|
||||||
|
class browser: public basic {
|
||||||
|
public:
|
||||||
|
browser();
|
||||||
|
void boot() final;
|
||||||
|
void draw() final;
|
||||||
|
void tick() final;
|
||||||
|
void exit() final;
|
||||||
|
~browser();
|
||||||
|
};
|
||||||
1
apps/kstralight/src/main.cpp
Normal file
1
apps/kstralight/src/main.cpp
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "gui/browser.h"
|
||||||
|
|
@ -6,26 +6,22 @@
|
||||||
namespace enginend::nodes::twod {
|
namespace enginend::nodes::twod {
|
||||||
struct node2d :public node {
|
struct node2d :public node {
|
||||||
Vector2 pos;
|
Vector2 pos;
|
||||||
node2d(){}
|
node2d();
|
||||||
node2d(float x,float y):pos(Vector2{x,y}){}
|
node2d(float x,float y);
|
||||||
};
|
};
|
||||||
struct rect :virtual public node2d{
|
struct rect :virtual public node2d{
|
||||||
Vector2 size;
|
Vector2 size;
|
||||||
rect(){}
|
rect();
|
||||||
rect(float x,float y,float w,float h):size(Vector2{w,h}){
|
rect(float x,float y,float w,float h);
|
||||||
this->pos=Vector2{x,y};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct textured :virtual public rect{
|
struct textured :virtual public rect{
|
||||||
Texture2D* texture;
|
Texture2D* texture;
|
||||||
textured(){}
|
textured();
|
||||||
textured(Texture2D* texture,float x,float y,float w,float h):texture(texture){
|
textured(Texture2D* texture,float x,float y,float w,float h);
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};
|
void boot()override;
|
||||||
}
|
void tick()override;
|
||||||
void boot()override{}
|
void draw()override;
|
||||||
void tick()override{}
|
void exit()override;
|
||||||
void draw()override{if(texture!=nullptr)DrawTexture(*texture,pos.x,pos.y,rl::WHITE);}
|
|
||||||
void exit()override{}
|
|
||||||
};
|
};
|
||||||
struct animated : virtual public textured {
|
struct animated : virtual public textured {
|
||||||
Image animimage;
|
Image animimage;
|
||||||
|
|
@ -36,74 +32,29 @@ namespace enginend::nodes::twod {
|
||||||
unsigned int nextframeoffset;
|
unsigned int nextframeoffset;
|
||||||
int prevframe;
|
int prevframe;
|
||||||
const char*path;
|
const char*path;
|
||||||
animated() : frames(0), currentframe(0), framedelay(6), framecounter(0), nextframeoffset(0) {
|
animated();
|
||||||
animimage.data = nullptr;
|
animated(const char* gifpath, Vector2 position, Vector2 size, int delay = 6);
|
||||||
}
|
void boot()override;
|
||||||
|
void tick()override;
|
||||||
animated(const char* gifpath, Vector2 position, Vector2 size, int delay = 6)
|
void draw()override;
|
||||||
: textured(nullptr, position.x, position.y, size.x, size.y),
|
void exit()override;
|
||||||
framedelay(delay), currentframe(0), framecounter(0), frames(0), nextframeoffset(0),path(gifpath)
|
|
||||||
{
|
|
||||||
animimage = LoadImageAnim(path, &frames);
|
|
||||||
if (frames > 0) {
|
|
||||||
texture = new Texture2D(LoadTextureFromImage(animimage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void boot() override {
|
|
||||||
|
|
||||||
}
|
|
||||||
void tick() override {
|
|
||||||
textured::tick();
|
|
||||||
if (frames <= 1) return;
|
|
||||||
|
|
||||||
framecounter++;
|
|
||||||
if (framecounter >= framedelay) {
|
|
||||||
framecounter = 0;
|
|
||||||
currentframe++;
|
|
||||||
if (currentframe >= frames) currentframe = 0;
|
|
||||||
nextframeoffset = animimage.width * animimage.height * 4 * currentframe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw() override {
|
|
||||||
|
|
||||||
if (prevframe!=currentframe){
|
|
||||||
prevframe=currentframe;
|
|
||||||
UpdateTexture(*this->texture,((unsigned char*)animimage.data)+nextframeoffset);
|
|
||||||
}
|
|
||||||
textured::draw();
|
|
||||||
}
|
|
||||||
void exit() override {
|
|
||||||
if (animimage.data) UnloadImage(animimage);
|
|
||||||
if (texture) {
|
|
||||||
UnloadTexture(*texture);
|
|
||||||
delete texture;
|
|
||||||
texture = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct colored :virtual public rect{
|
struct colored :virtual public rect{
|
||||||
Color c;
|
Color c;
|
||||||
colored(){}
|
colored();
|
||||||
colored(Color color,float x,float y,float w,float h):c(color){
|
colored(Color color,float x,float y,float w,float h);
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};
|
void boot()override;
|
||||||
}
|
void tick()override;
|
||||||
void boot()override{}
|
void draw()override;
|
||||||
void tick()override{}
|
void exit()override;
|
||||||
void draw()override{DrawRectangle(pos.x,pos.y,size.x,size.y,c);}
|
|
||||||
void exit()override{}
|
|
||||||
};
|
};
|
||||||
struct tinted :virtual public colored,virtual public textured{
|
struct tinted :virtual public colored,virtual public textured{
|
||||||
tinted(){}
|
tinted();
|
||||||
tinted(Texture2D* texture,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),
|
void boot()override;
|
||||||
rect(x,y,w,h),
|
void tick()override;
|
||||||
colored(color,x,y,w,h),
|
void draw()override;
|
||||||
textured(texture,x,y,w,h)
|
void exit()override;
|
||||||
{}
|
|
||||||
void boot()override{this->colored::boot();this->textured::boot();}
|
|
||||||
void tick()override{this->colored::tick();this->textured::tick();}
|
|
||||||
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 {
|
struct text :public tinted {
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -112,42 +63,12 @@ namespace enginend::nodes::twod {
|
||||||
float fs;
|
float fs;
|
||||||
Color txc;
|
Color txc;
|
||||||
std::string content;
|
std::string content;
|
||||||
text(){fs=20;}
|
text();
|
||||||
text(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize,std::string txt):
|
text(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize,std::string txt);
|
||||||
fs(fsize),content(txt)
|
void boot()override;
|
||||||
{
|
void tick()override;
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->theme=theme;
|
void draw()override;
|
||||||
|
void exit()override;
|
||||||
result=content;
|
|
||||||
size_t initp=0;
|
|
||||||
while((initp=result.find("\n",initp))!=std::string::npos){
|
|
||||||
result.replace(initp,1,"\\n");
|
|
||||||
initp+=2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void boot()override{this->tinted::boot();}
|
|
||||||
void tick()override {
|
|
||||||
this->tinted::tick();
|
|
||||||
if(result!=content){
|
|
||||||
result=content;
|
|
||||||
size_t initp=0;
|
|
||||||
while((initp=result.find("\n",initp))!=std::string::npos){
|
|
||||||
result.replace(initp,1,"\\n");
|
|
||||||
initp+=2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override {
|
|
||||||
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>size.y)?minsize.y:size.y;
|
|
||||||
int minw=(minsize.x>size.x)?minsize.x:size.x;
|
|
||||||
DrawRectangle(pos.x-charsize.x,pos.y-charsize.y,minw+p,minh+p,this->theme->background);
|
|
||||||
DrawTextEx(this->theme->font,content.c_str(),pos,fs,1,this->theme->text);
|
|
||||||
}
|
|
||||||
void exit()override{this->tinted::exit();}
|
|
||||||
};
|
};
|
||||||
struct button :virtual public tinted{
|
struct button :virtual public tinted{
|
||||||
std::function<void()> func;
|
std::function<void()> func;
|
||||||
|
|
@ -155,233 +76,62 @@ namespace enginend::nodes::twod {
|
||||||
bool hover;
|
bool hover;
|
||||||
const bool isboolean;
|
const bool isboolean;
|
||||||
bool boolean=false;
|
bool boolean=false;
|
||||||
button():pressed(false),isboolean(false){}
|
button();
|
||||||
button(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,std::function<void()> f):func(f),pressed(false),isboolean(false){
|
button(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,std::function<void()> f);
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=theme->tint;this->theme=theme;
|
button(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,std::function<void()> f,bool isboolean);
|
||||||
}
|
void boot()override;
|
||||||
button(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,std::function<void()> f,bool isboolean):func(f),pressed(false),isboolean(isboolean){
|
void tick()override;
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->c=theme->tint;this->theme=theme;
|
void draw()override;
|
||||||
}
|
void exit()override;
|
||||||
void boot()override{this->tinted::boot();}
|
|
||||||
void tick()override{
|
|
||||||
this->tinted::tick();
|
|
||||||
}
|
|
||||||
void draw()override {
|
|
||||||
|
|
||||||
Vector2 mouse=GetMousePosition();
|
|
||||||
float wstretch=(float)GetScreenWidth()/(float)GetRenderWidth();
|
|
||||||
float hstretch=(float)GetScreenHeight()/(float)GetRenderHeight();
|
|
||||||
mouse.x/=wstretch;mouse.y/=hstretch;
|
|
||||||
tiny::echo(
|
|
||||||
"render:\nwidth:%i height:%i\n\nscreen:\nwidth:%i height:%i\n\n\n",
|
|
||||||
GetRenderWidth(),GetRenderHeight(),
|
|
||||||
GetScreenWidth(),GetScreenHeight()
|
|
||||||
);
|
|
||||||
|
|
||||||
tiny::echo(
|
|
||||||
"stretch:\nwidth:%f height:%f\n\nmouse:\nwidth:%f height:%f",
|
|
||||||
wstretch,hstretch,
|
|
||||||
mouse.x,mouse.y
|
|
||||||
);
|
|
||||||
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})){hover=true;
|
|
||||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
|
||||||
pressed=true;
|
|
||||||
if(func)func();
|
|
||||||
}else{
|
|
||||||
pressed=false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
hover=false;
|
|
||||||
}
|
|
||||||
if (hover) {
|
|
||||||
if (pressed) {
|
|
||||||
c=isboolean?boolean?
|
|
||||||
this->theme->booleanbutton[5]:this->theme->booleanbutton[2]:
|
|
||||||
this->theme->button[2];
|
|
||||||
}else {
|
|
||||||
c=isboolean?boolean?
|
|
||||||
this->theme->booleanbutton[4]:this->theme->booleanbutton[1]:
|
|
||||||
this->theme->button[1];
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
c=isboolean?boolean?
|
|
||||||
this->theme->booleanbutton[3]:this->theme->booleanbutton[0]:
|
|
||||||
this->theme->button[0];
|
|
||||||
}
|
|
||||||
if(this->texture!=nullptr)DrawTexture(*texture,pos.x,pos.y,this->theme->tint);
|
|
||||||
else DrawRectangle(pos.x,pos.y,size.x,size.y,this->theme->tint);
|
|
||||||
|
|
||||||
}
|
|
||||||
void exit()override{this->tinted::exit();}
|
|
||||||
};
|
};
|
||||||
struct labeledbutton :virtual public button {
|
struct labeledbutton :virtual public button {
|
||||||
std::string label;
|
std::string label;
|
||||||
int fs;
|
int fs;
|
||||||
Color txc;
|
Color txc;
|
||||||
labeledbutton(std::string name,Texture2D* texture,enginend::theme* theme,
|
labeledbutton(std::string name,Texture2D* texture,enginend::theme* theme,
|
||||||
float x,float y,float w,float h,std::function<void()> f,int size):fs(size){
|
float x,float y,float w,float h,std::function<void()> f,int size);
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->texture=texture;this->theme=theme;
|
void boot()override;
|
||||||
this->func=f;this->pressed=false;
|
void tick()override;
|
||||||
this->label=name;
|
void draw()override;
|
||||||
}
|
void exit()override;
|
||||||
void boot()override{this->button::boot();}
|
|
||||||
void tick()override{this->button::tick();}
|
|
||||||
void draw()override{
|
|
||||||
this->button::draw();
|
|
||||||
|
|
||||||
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->booleantext[1]:
|
|
||||||
this->theme->buttontext[1];
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
txc=isboolean?boolean?
|
|
||||||
this->theme->booleantext[3]:this->theme->booleantext[0]:
|
|
||||||
this->theme->buttontext[0];
|
|
||||||
}
|
|
||||||
Vector2 tsize=MeasureTextEx(theme->font,label.c_str(),fs,1);
|
|
||||||
Vector2 tpos={
|
|
||||||
pos.x+(size.x-tsize.x)/2,
|
|
||||||
pos.y+(size.y-tsize.y)/2
|
|
||||||
};
|
|
||||||
DrawTextEx(theme->font,label.c_str(),tpos,fs,1,txc);
|
|
||||||
}
|
|
||||||
void exit()override{this->button::exit();}
|
|
||||||
};
|
};
|
||||||
struct slider :virtual public tinted{
|
struct slider :virtual public tinted{
|
||||||
float val;
|
float val;
|
||||||
float minv;
|
float minv;
|
||||||
float maxv;
|
float maxv;
|
||||||
slider():val(0),minv(0),maxv(1){}
|
slider();
|
||||||
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){
|
slider(Texture2D* texture,Color color,float x,float y,float w,float h,float min,float max,float v);
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->texture=texture;this->c=color;
|
void boot()override;
|
||||||
}
|
void tick()override;
|
||||||
void boot()override{this->tinted::boot();}
|
void draw()override;
|
||||||
void tick()override{
|
void exit()override;
|
||||||
this->tinted::tick();
|
|
||||||
Vector2 mouse=GetMousePosition();
|
|
||||||
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})&&IsMouseButtonDown(MOUSE_LEFT_BUTTON)){
|
|
||||||
float t=(mouse.x-pos.x)/size.x;
|
|
||||||
val=minv+t*(maxv-minv);
|
|
||||||
if(val<minv)val=minv;
|
|
||||||
if(val>maxv)val=maxv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
DrawRectangle(pos.x,pos.y,size.x,size.y,rl::DARKGRAY);
|
|
||||||
float t=(val-minv)/(maxv-minv);
|
|
||||||
DrawRectangle(pos.x,pos.y,size.x*t,size.y,c);
|
|
||||||
}
|
|
||||||
void exit()override{this->tinted::exit();}
|
|
||||||
};
|
};
|
||||||
struct textfield :public text{
|
struct textfield :public text{
|
||||||
textfield(){}
|
textfield();
|
||||||
textfield(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize,std::string txt):
|
textfield(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize,std::string txt);
|
||||||
text(texture,theme,x,y,w,h,fsize,txt){}
|
void boot()override;
|
||||||
void boot()override{this->text::boot();}
|
void tick()override;
|
||||||
void tick()override{this->text::tick();}
|
void draw()override;
|
||||||
void draw()override{
|
void exit()override;
|
||||||
Vector2 p=pos;
|
|
||||||
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>size.y)?minsize.y:size.y;
|
|
||||||
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);
|
|
||||||
DrawTextEx(this->theme->font,content.c_str(),p,fs,charsize.x/2,this->txc);
|
|
||||||
}
|
|
||||||
void exit()override{this->text::exit();}
|
|
||||||
};
|
};
|
||||||
struct textinput :public text{
|
struct textinput :public text{
|
||||||
bool active;
|
bool active;
|
||||||
int cpos;
|
int cpos;
|
||||||
textinput():active(false),cpos(0){}
|
textinput();
|
||||||
textinput(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize):active(false),cpos(0){
|
textinput(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize);
|
||||||
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->texture=texture;this->theme=theme;this->content="";
|
void boot()override;
|
||||||
this->fs=fsize;
|
void tick()override;
|
||||||
}
|
void draw()override;
|
||||||
void boot()override{this->text::boot();}
|
void exit()override;
|
||||||
void tick()override{
|
|
||||||
this->text::tick();
|
|
||||||
Vector2 mouse=GetMousePosition();
|
|
||||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
|
||||||
active=CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y});
|
|
||||||
}
|
|
||||||
if(active){
|
|
||||||
int key=GetCharPressed();
|
|
||||||
while(key>0){
|
|
||||||
if(key>=32&&key<=125){
|
|
||||||
content+=static_cast<char>(key);
|
|
||||||
cpos++;
|
|
||||||
}
|
|
||||||
key=GetCharPressed();
|
|
||||||
}
|
|
||||||
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
|
||||||
content.pop_back();
|
|
||||||
cpos--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
this->text::draw();
|
|
||||||
if(active)DrawRectangle(pos.x+MeasureText(content.c_str(),fs),pos.y,2,fs,{0,0,0,127});
|
|
||||||
}
|
|
||||||
void exit()override{this->text::exit();}
|
|
||||||
};
|
};
|
||||||
struct textinputfield :public textfield{
|
struct textinputfield :public textfield{
|
||||||
bool active;
|
bool active;
|
||||||
int cpos;
|
int cpos;
|
||||||
textinputfield():active(false),cpos(0){}
|
textinputfield();
|
||||||
textinputfield(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize):active(false),cpos(0),
|
textinputfield(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize);
|
||||||
textfield(texture,theme,x,y,w,h,fsize,""){}
|
void boot()override;
|
||||||
void boot()override{this->textfield::boot();}
|
void tick()override;
|
||||||
void tick()override{
|
void draw()override;
|
||||||
this->textfield::tick();
|
void exit()override;
|
||||||
Vector2 mouse=GetMousePosition();
|
|
||||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
|
||||||
active=CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y});
|
|
||||||
}
|
|
||||||
if(active){
|
|
||||||
int key=GetCharPressed();
|
|
||||||
while(key>0){
|
|
||||||
if(key>=32&&key<=125){
|
|
||||||
content+=static_cast<char>(key);
|
|
||||||
cpos++;
|
|
||||||
}
|
|
||||||
key=GetCharPressed();
|
|
||||||
}
|
|
||||||
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
|
||||||
content.pop_back();
|
|
||||||
cpos--;
|
|
||||||
}
|
|
||||||
if(IsKeyPressed(KEY_ENTER)){
|
|
||||||
content+='\n';
|
|
||||||
cpos++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
this->textfield::draw();
|
|
||||||
if(active){
|
|
||||||
Vector2 p=pos;
|
|
||||||
float lh=fs+2;
|
|
||||||
std::string line="";
|
|
||||||
for(char ch:content){
|
|
||||||
if(ch=='\n'){
|
|
||||||
p.y+=lh;
|
|
||||||
line="";
|
|
||||||
}else{
|
|
||||||
line+=ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DrawRectangle(p.x+MeasureText(line.c_str(),fs),p.y,2,fs,rl::BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void exit()override{this->textfield::exit();}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include <raylib/raylib.h>
|
#include <raylib/raylib.h>
|
||||||
namespace enginend::nodes::twod::relative {
|
namespace enginend::nodes::twod::relative {
|
||||||
|
|
@ -9,38 +10,21 @@ namespace enginend::nodes::twod::relative {
|
||||||
double y;
|
double y;
|
||||||
double w;
|
double w;
|
||||||
double h;
|
double h;
|
||||||
node2d(){x=0;y=0;w=0;h=0;}
|
node2d();
|
||||||
node2d(double x,double y,double w=0,double h=0):x(x),y(y),w(w),h(h){}
|
node2d(double x,double y,double w=0,double h=0);
|
||||||
};
|
};
|
||||||
struct rect :virtual public node2d{
|
struct rect :virtual public node2d{
|
||||||
rect(){}
|
rect();
|
||||||
rect(double x,double y,double w,double h):node2d(x,y,w,h){}
|
rect(double x,double y,double w,double h);
|
||||||
};
|
};
|
||||||
struct textured :virtual public rect{
|
struct textured :virtual public rect{
|
||||||
Texture2D* texture;
|
Texture2D* texture;
|
||||||
textured(){texture=nullptr;}
|
textured();
|
||||||
textured(Texture2D* texture,double x,double y,double w,double h):texture(texture),rect(x,y,w,h){}
|
textured(Texture2D* texture,double x,double y,double w,double h);
|
||||||
void boot() override{}
|
void boot()override;
|
||||||
void tick() override{}
|
void tick()override;
|
||||||
void draw()override{
|
void draw()override;
|
||||||
if(texture==nullptr)return;
|
void exit()override;
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
tiny::echo("og: %f %f %f %f", x,y,w,h);
|
|
||||||
tiny::echo("transformed: %f %f %f %f", ax, ay, aw, ah);
|
|
||||||
DrawTexturePro(*texture,{0,0,(float)texture->width,(float)texture->height},{ax,ay,aw,ah},{0,0},0,rl::WHITE);
|
|
||||||
}
|
|
||||||
void exit()override {
|
|
||||||
if(texture){
|
|
||||||
UnloadTexture(*texture);
|
|
||||||
delete texture;
|
|
||||||
texture=nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct animated :virtual public textured{
|
struct animated :virtual public textured{
|
||||||
Image animimage;
|
Image animimage;
|
||||||
|
|
@ -50,87 +34,28 @@ namespace enginend::nodes::twod::relative {
|
||||||
int framecounter;
|
int framecounter;
|
||||||
int prevframe;
|
int prevframe;
|
||||||
unsigned int nextframeoffset;
|
unsigned int nextframeoffset;
|
||||||
animated():frames(0),currentframe(1),framedelay(6),framecounter(0),nextframeoffset(0){
|
animated();
|
||||||
animimage.data=nullptr;
|
animated(const char* gifpath,double x,double y,double w,double h,int delay=6);
|
||||||
prevframe=currentframe;
|
void tick()override;
|
||||||
}
|
void draw()override;
|
||||||
animated(const char* gifpath,double x,double y,double w,double h,int delay=6):
|
void exit()override;
|
||||||
textured(nullptr,x,y,w,h),framedelay(delay),currentframe(1),framecounter(0),frames(0),nextframeoffset(0)
|
|
||||||
{
|
|
||||||
prevframe=currentframe;
|
|
||||||
this->x=x; this->y=y; this->w=w; this->h=h;
|
|
||||||
animimage=LoadImageAnim(gifpath,&frames);
|
|
||||||
if(frames>0){
|
|
||||||
texture=new Texture2D(LoadTextureFromImage(animimage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void tick()override{
|
|
||||||
if(frames<=1)return;
|
|
||||||
framecounter++;
|
|
||||||
if(framecounter>=framedelay){
|
|
||||||
framecounter=0;
|
|
||||||
currentframe++;
|
|
||||||
if(currentframe>=frames)currentframe=0;
|
|
||||||
nextframeoffset=animimage.width*animimage.height*4*currentframe;
|
|
||||||
tiny::echo("updating node\nframes: %i\n current frame: %i",frames,currentframe);
|
|
||||||
tiny::echo("%i",nextframeoffset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override {
|
|
||||||
if (prevframe!=currentframe){
|
|
||||||
prevframe=currentframe;
|
|
||||||
UpdateTexture(*this->texture,((unsigned char*)animimage.data)+nextframeoffset);
|
|
||||||
}
|
|
||||||
textured::draw();
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
if(animimage.data)UnloadImage(animimage);
|
|
||||||
textured::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct colored :virtual public rect{
|
struct colored :virtual public rect{
|
||||||
Color c;
|
Color c;
|
||||||
colored(){}
|
colored();
|
||||||
colored(Color color,double x,double y,double w,double h):c(color),rect(x,y,w,h){}
|
colored(Color color,double x,double y,double w,double h);
|
||||||
void boot()override{}
|
void boot()override;
|
||||||
void tick()override{}
|
void tick()override;
|
||||||
void draw()override{
|
void draw()override;
|
||||||
float sw=GetRenderWidth();
|
void exit()override;
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
DrawRectangle(ax,ay,aw,ah,c);
|
|
||||||
}
|
|
||||||
void exit()override{}
|
|
||||||
};
|
};
|
||||||
struct tinted :virtual public colored,virtual public textured{
|
struct tinted :virtual public colored,virtual public textured{
|
||||||
tinted(){}
|
tinted();
|
||||||
tinted(Texture2D* texture,Color color,double x,double y,double w,double h):
|
tinted(Texture2D* texture,Color color,double x,double y,double w,double h);
|
||||||
node2d(x,y,w,h),
|
void boot()override;
|
||||||
rect(x,y,w,h),
|
void tick()override;
|
||||||
colored(color,x,y,w,h),
|
void draw()override;
|
||||||
textured(texture,x,y,w,h)
|
void exit()override;
|
||||||
{}
|
|
||||||
void boot()override{}
|
|
||||||
void tick()override{}
|
|
||||||
void draw()override{
|
|
||||||
if(texture==nullptr) {
|
|
||||||
colored::draw();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
DrawTexturePro(*texture,{0,0,(float)texture->width,(float)texture->height},{ax,ay,aw,ah},{0,0},0,c);
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
textured::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct text :public tinted {
|
struct text :public tinted {
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -138,55 +63,12 @@ namespace enginend::nodes::twod::relative {
|
||||||
public:
|
public:
|
||||||
float fs;
|
float fs;
|
||||||
std::string content;
|
std::string content;
|
||||||
text(){fs=20;}
|
text();
|
||||||
text(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,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),
|
void boot()override;
|
||||||
fs(fsize),content(txt)
|
void tick()override;
|
||||||
{
|
void draw()override;
|
||||||
this->x=x;this->y=y;this->w=w;this->h=h;
|
void exit()override;
|
||||||
this->texture=texture;this->theme=theme;
|
|
||||||
result=content;
|
|
||||||
size_t initp=0;
|
|
||||||
while((initp=result.find("\n",initp))!=std::string::npos){
|
|
||||||
result.replace(initp,1,"\\n");
|
|
||||||
initp+=2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void boot()override{}
|
|
||||||
void tick()override {
|
|
||||||
if(result!=content){
|
|
||||||
result=content;
|
|
||||||
size_t initp=0;
|
|
||||||
while((initp=result.find("\n",initp))!=std::string::npos){
|
|
||||||
result.replace(initp,1,"\\n");
|
|
||||||
initp+=2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override {
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
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(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,this->theme->background);
|
|
||||||
DrawTextEx(this->theme->font,content.c_str(),{ax,ay},fs,1,this->theme->text);
|
|
||||||
DrawRectangleLines(ax, ay, aw, ah, this->theme->border);
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
tinted::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct button :virtual public tinted{
|
struct button :virtual public tinted{
|
||||||
std::function<void()> func;
|
std::function<void()> func;
|
||||||
|
|
@ -194,278 +76,64 @@ namespace enginend::nodes::twod::relative {
|
||||||
bool hover;
|
bool hover;
|
||||||
const bool isboolean;
|
const bool isboolean;
|
||||||
bool boolean=false;
|
bool boolean=false;
|
||||||
button():func(nullptr),pressed(false),hover(false),isboolean(false){}
|
button();
|
||||||
button(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,std::function<void()> f):func(f),pressed(false),hover(false),isboolean(false) {
|
button(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,std::function<void()> f);
|
||||||
this->theme=theme;this->texture=texture;this->x=x;this->y=y;this->w=w;this->h=h;
|
button(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,std::function<void()> f,bool isboolean);
|
||||||
}button(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,std::function<void()> f,bool isboolean):func(f),pressed(false),hover(false),isboolean(isboolean) {
|
void boot()override;
|
||||||
this->theme=theme;this->texture=texture;this->x=x;this->y=y;this->w=w;this->h=h;
|
void tick()override;
|
||||||
}
|
void draw()override;
|
||||||
void boot()override{}
|
void exit()override;
|
||||||
void tick()override{
|
|
||||||
}
|
|
||||||
void draw()override {
|
|
||||||
|
|
||||||
Vector2 mouse=GetMousePosition();
|
|
||||||
float wstretch=(float)GetScreenWidth()/(float)GetRenderWidth();
|
|
||||||
float hstretch=(float)GetScreenHeight()/(float)GetRenderHeight();
|
|
||||||
mouse.x/=wstretch;mouse.y/=hstretch;
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
|
||||||
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->booleanbutton[1]:
|
|
||||||
this->theme->button[1];
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
hover=false;
|
|
||||||
pressed=false;
|
|
||||||
c=isboolean?boolean?
|
|
||||||
this->theme->booleanbutton[3]:this->theme->booleanbutton[0]:
|
|
||||||
this->theme->button[0];
|
|
||||||
}
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
DrawRectangle(ax,ay,aw,ah,c);
|
|
||||||
DrawRectangleLines(ax, ay, aw, ah, this->theme->border);
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
tinted::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct labeledbutton :virtual public button {
|
struct labeledbutton :virtual public button {
|
||||||
std::string label;
|
std::string label;
|
||||||
int fs;
|
int fs;
|
||||||
Color txc;
|
Color txc;
|
||||||
labeledbutton(std::string name,Texture2D* texture,enginend::theme*theme,
|
labeledbutton(std::string name,Texture2D* texture,enginend::theme* theme,
|
||||||
double x,double y,double w,double h,std::function<void()> f,int size):fs(size),label(name),
|
double x,double y,double w,double h,std::function<void()> f,int size);
|
||||||
button(texture,theme,x,y,w,h,f)
|
labeledbutton(std::string name,Texture2D* texture,enginend::theme* theme,
|
||||||
{}
|
double x,double y,double w,double h,std::function<void()> f,int size,bool isboolean);
|
||||||
labeledbutton(std::string name,Texture2D* texture,enginend::theme*theme,
|
void boot()override;
|
||||||
double x,double y,double w,double h,std::function<void()> f,
|
void tick()override;
|
||||||
int size,bool isboolean):fs(size),label(name),
|
void draw()override;
|
||||||
button(texture,theme,x,y,w,h,f,isboolean)
|
void exit()override;
|
||||||
{}
|
|
||||||
void boot()override{}
|
|
||||||
void tick()override{
|
|
||||||
button::tick();
|
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
button::draw();
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
tiny::echo("ax %f x %f sw %f",ax,x,sw);
|
|
||||||
tiny::echo("ay %f y %f sh %f",ay,y,sh);
|
|
||||||
tiny::echo("aw %f w %f sw %f",aw,w,sw);
|
|
||||||
tiny::echo("ah %f h %f sh %f",ah,h,sh);
|
|
||||||
Vector2 tsize=MeasureTextEx(this->theme->font,label.c_str(),fs,1);
|
|
||||||
Vector2 tpos={
|
|
||||||
ax+(aw-tsize.x)/2,
|
|
||||||
ay+(ah-tsize.y)/2
|
|
||||||
};
|
|
||||||
tiny::echo("tsize\nw %f h %f",tsize.x,tsize.y);
|
|
||||||
tiny::echo("tpos\nx %f y %f",tpos.x,tpos.y);
|
|
||||||
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->booleantext[1]:
|
|
||||||
this->theme->buttontext[1];
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
txc=isboolean?boolean?
|
|
||||||
this->theme->booleantext[3]:this->theme->booleantext[0]:
|
|
||||||
this->theme->buttontext[0];
|
|
||||||
}
|
|
||||||
DrawTextEx(this->theme->font,label.c_str(),tpos,fs,1,txc);
|
|
||||||
DrawRectangleLinesEx({ax, ay, aw, ah},5., this->theme->border);
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
button::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct slider :virtual public tinted{
|
struct slider :virtual public tinted{
|
||||||
float val;
|
float val;
|
||||||
float minv;
|
float minv;
|
||||||
float maxv;
|
float maxv;
|
||||||
slider():val(0),minv(0),maxv(1){}
|
slider();
|
||||||
slider(Texture2D* texture,Color color,double x,double y,double w,double h,float min,float max,float v):val(v),minv(min),maxv(max),tinted(texture,color,x,y,w,h){}
|
slider(Texture2D* texture,Color color,double x,double y,double w,double h,float min,float max,float v);
|
||||||
void boot()override{}
|
void boot()override;
|
||||||
void tick()override{
|
void tick()override;
|
||||||
Vector2 mouse=GetMousePosition();
|
void draw()override;
|
||||||
float sw=GetRenderWidth();
|
void exit()override;
|
||||||
float sh=GetRenderHeight();
|
|
||||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
|
||||||
if(CheckCollisionPointRec(mouse,r)&&IsMouseButtonDown(MOUSE_LEFT_BUTTON)){
|
|
||||||
float t=(mouse.x-(x*sw))/(w*sw);
|
|
||||||
val=minv+t*(maxv-minv);
|
|
||||||
if(val<minv)val=minv;
|
|
||||||
if(val>maxv)val=maxv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
DrawRectangle(ax,ay,aw,ah,rl::DARKGRAY);
|
|
||||||
float t=(val-minv)/(maxv-minv);
|
|
||||||
DrawRectangle(ax,ay,aw*t,ah,c);
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
tinted::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct textfield :public text{
|
struct textfield :public text{
|
||||||
textfield(){}
|
textfield();
|
||||||
textfield(Texture2D* texture,enginend::theme *theme,double x,double y,double w,double h,float fsize,std::string 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 boot()override{}
|
void tick()override;
|
||||||
void tick()override{
|
void draw()override;
|
||||||
text::tick();
|
void exit()override;
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float aw=w*sw;
|
|
||||||
float ah=h*sh;
|
|
||||||
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),this->theme->textfieldbg);
|
|
||||||
DrawTextEx(this->theme->font,content.c_str(),{ax,ay},fs,charsize.x/2,this->theme->text);
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
text::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct textinput :public text{
|
struct textinput :public text{
|
||||||
bool active;
|
bool active;
|
||||||
int cpos;
|
int cpos;
|
||||||
textinput():active(false),cpos(0){}
|
textinput();
|
||||||
textinput(Texture2D* texture,enginend::theme *theme,double x,double y,double w,double h,float fsize):active(false),cpos(0),
|
textinput(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,float fsize);
|
||||||
text(texture,theme,x,y,w,h,fsize,""){}
|
void boot()override;
|
||||||
void boot()override{}
|
void tick()override;
|
||||||
void tick()override{
|
void draw()override;
|
||||||
text::tick();
|
void exit()override;
|
||||||
Vector2 mouse=GetMousePosition();
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
|
||||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
|
||||||
active=CheckCollisionPointRec(mouse,r);
|
|
||||||
}
|
|
||||||
if(active){
|
|
||||||
int key=GetCharPressed();
|
|
||||||
while(key>0){
|
|
||||||
if(key>=32&&key<=125){
|
|
||||||
content+=static_cast<char>(key);
|
|
||||||
cpos++;
|
|
||||||
}
|
|
||||||
key=GetCharPressed();
|
|
||||||
}
|
|
||||||
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
|
||||||
content.pop_back();
|
|
||||||
cpos--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
text::draw();
|
|
||||||
if(active){
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
DrawRectangle(ax+MeasureTextEx(this->theme->font,content.c_str(),fs,1).x,ay,2,fs,{0,0,0,127});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
text::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
struct textinputfield :public textfield{
|
struct textinputfield :public textfield{
|
||||||
bool active;
|
bool active;
|
||||||
int cpos;
|
int cpos;
|
||||||
textinputfield():active(false),cpos(0){}
|
textinputfield();
|
||||||
textinputfield(Texture2D* texture,enginend::theme *theme,double x,double y,double w,double h,float fsize):active(false),cpos(0),
|
textinputfield(Texture2D* texture,enginend::theme* theme,double x,double y,double w,double h,float fsize);
|
||||||
textfield(texture,theme,x,y,w,h,fsize,""){}
|
void boot()override;
|
||||||
void boot()override{}
|
void tick()override;
|
||||||
void tick()override{
|
void draw()override;
|
||||||
textfield::tick();
|
void exit()override;
|
||||||
Vector2 mouse=GetMousePosition();
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
Rectangle r={float(x*sw),float(y*sh),float(w*sw),float(h*sh)};
|
|
||||||
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
|
||||||
active=CheckCollisionPointRec(mouse,r);
|
|
||||||
}
|
|
||||||
if(active){
|
|
||||||
int key=GetCharPressed();
|
|
||||||
while(key>0){
|
|
||||||
if(key>=32&&key<=125){
|
|
||||||
content+=static_cast<char>(key);
|
|
||||||
cpos++;
|
|
||||||
}
|
|
||||||
key=GetCharPressed();
|
|
||||||
}
|
|
||||||
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
|
||||||
content.pop_back();
|
|
||||||
cpos--;
|
|
||||||
}
|
|
||||||
if(IsKeyPressed(KEY_ENTER)){
|
|
||||||
content+='\n';
|
|
||||||
cpos++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw()override{
|
|
||||||
textfield::draw();
|
|
||||||
if(active){
|
|
||||||
float sw=GetRenderWidth();
|
|
||||||
float sh=GetRenderHeight();
|
|
||||||
float ax=x*sw;
|
|
||||||
float ay=y*sh;
|
|
||||||
float lh=fs+2;
|
|
||||||
Vector2 p={ax,ay};
|
|
||||||
std::string line="";
|
|
||||||
for(char ch:content){
|
|
||||||
if(ch=='\n'){
|
|
||||||
p.y+=lh;
|
|
||||||
line="";
|
|
||||||
}else{
|
|
||||||
line+=ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DrawRectangle(p.x+MeasureTextEx(this->theme->font,line.c_str(),fs,1).x,p.y,2,fs,rl::BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void exit()override{
|
|
||||||
textfield::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,61 +8,42 @@ namespace enginend::nodes::trid {
|
||||||
Shader* shader;
|
Shader* shader;
|
||||||
Color tint;
|
Color tint;
|
||||||
node3d(){}
|
node3d(){}
|
||||||
node3d(Vector3 pos,Vector3 rot,Vector3 size,Vector3 scale):
|
node3d(Vector3 pos,Vector3 rot,Vector3 size,Vector3 scale);
|
||||||
pos(pos),rot(rot),scale(scale),size(size) {
|
|
||||||
tint={255,255,255,255};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct physicsagent:virtual public node3d {
|
struct physicsagent:virtual public node3d {
|
||||||
bool hardbody,isphysics;
|
bool hardbody,isphysics;
|
||||||
std::vector<BoundingBox>* bboxes;
|
std::vector<BoundingBox>* bboxes;
|
||||||
physicsagent():hardbody(false),isphysics(false) {
|
physicsagent();
|
||||||
bboxes = new std::vector<BoundingBox>();
|
physicsagent(bool hardbody,bool isphysics);
|
||||||
}
|
physicsagent(bool hardbody,bool isphysics,std::vector<BoundingBox>* bboxes);
|
||||||
physicsagent(bool hardbody,bool isphysics):hardbody(hardbody),isphysics(isphysics) {
|
void boot() override;
|
||||||
bboxes = new std::vector<BoundingBox>();
|
void tick() override;
|
||||||
}
|
void draw() override;
|
||||||
physicsagent(bool hardbody,bool isphysics,std::vector<BoundingBox>* bboxes):
|
void exit() override;
|
||||||
hardbody(hardbody),isphysics(isphysics),bboxes(bboxes) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct billboard:virtual public physicsagent {
|
struct billboard:virtual public physicsagent {
|
||||||
Texture2D* texture;
|
Texture2D texture;
|
||||||
billboard(){texture=nullptr;}
|
char*texpath;
|
||||||
billboard(Vector3 pos,Vector3 rot,Vector3 size,Vector3 scale,Texture2D* texture):
|
billboard(){}
|
||||||
node3d(pos,rot,size,scale),texture(texture){}
|
billboard(Vector3 pos,Vector3 rot,Vector3 size,Vector3 scale,char* texture);
|
||||||
void boot() override {
|
void boot() override;
|
||||||
|
void tick() override;
|
||||||
}
|
void draw() override;
|
||||||
void draw() override {
|
void exit() override;
|
||||||
DrawBillboard(*watcher,*texture,pos,1.,tint);
|
|
||||||
}
|
|
||||||
void exit() override {
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct object3d:public physicsagent {
|
struct object3d:public physicsagent {
|
||||||
Model* model;
|
Model* model;
|
||||||
const char *path;
|
const char *path;
|
||||||
object3d(const char* path):path(path) {
|
object3d(const char* path);
|
||||||
}
|
void boot() override;
|
||||||
void boot() override {
|
void tick() override;
|
||||||
(*model)=LoadModel(path);
|
void draw() override;
|
||||||
}
|
void exit() override;
|
||||||
void tick() override {
|
|
||||||
|
|
||||||
}
|
|
||||||
void draw() override {
|
|
||||||
DrawModel(*model,pos,1.,tint);
|
|
||||||
}
|
|
||||||
void exit() override {
|
|
||||||
UnloadModel(*model);
|
|
||||||
delete model;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct animatedbillboard:virtual public physicsagent {
|
struct animatedbillboard:virtual public physicsagent {
|
||||||
Image animimage;
|
Image animimage;
|
||||||
int frames;
|
int frames;
|
||||||
|
|
@ -72,68 +53,22 @@ namespace enginend::nodes::trid {
|
||||||
unsigned int nextframeoffset;
|
unsigned int nextframeoffset;
|
||||||
int prevframe;
|
int prevframe;
|
||||||
Texture2D* texture;
|
Texture2D* texture;
|
||||||
|
animatedbillboard();
|
||||||
animatedbillboard() : frames(0), currentframe(0), framedelay(6), framecounter(0), nextframeoffset(0) {
|
animatedbillboard(const char* gifpath, int delay = 6,Vector3 pos={},Vector3 rot={},Vector3 size={},Vector3 scale={});
|
||||||
animimage.data = nullptr;
|
void tick() override;
|
||||||
}
|
void draw() override;
|
||||||
|
void exit() override;
|
||||||
animatedbillboard(const char* gifpath, int delay = 6,Vector3 pos={},Vector3 rot={},Vector3 size={},Vector3 scale={}):node3d(pos,rot,size,scale),
|
|
||||||
framedelay(delay), currentframe(0), framecounter(0), frames(0), nextframeoffset(0)
|
|
||||||
{
|
|
||||||
animimage = LoadImageAnim(gifpath, &frames);
|
|
||||||
if (frames > 0) {
|
|
||||||
texture = new Texture2D(LoadTextureFromImage(animimage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void tick() override {
|
|
||||||
if (frames <= 1) return;
|
|
||||||
|
|
||||||
framecounter++;
|
|
||||||
if (framecounter >= framedelay) {
|
|
||||||
framecounter = 0;
|
|
||||||
currentframe++;
|
|
||||||
if (currentframe >= frames) currentframe = 0;
|
|
||||||
nextframeoffset = animimage.width * animimage.height * 4 * currentframe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw() override {
|
|
||||||
|
|
||||||
if (prevframe!=currentframe){
|
|
||||||
prevframe=currentframe;
|
|
||||||
UpdateTexture(*this->texture,((unsigned char*)animimage.data)+nextframeoffset);
|
|
||||||
}
|
|
||||||
DrawBillboard(*watcher,*texture,pos,1.,tint);
|
|
||||||
}
|
|
||||||
void exit() override {
|
|
||||||
if (animimage.data) UnloadImage(animimage);
|
|
||||||
if (texture) {
|
|
||||||
UnloadTexture(*texture);
|
|
||||||
delete texture;
|
|
||||||
texture = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct animatedmodel:virtual public physicsagent {
|
struct animatedmodel:virtual public physicsagent {
|
||||||
std::vector<ModelAnimation> *animation;
|
std::vector<ModelAnimation> *animation;
|
||||||
Model *model;
|
Model *model;
|
||||||
int animcount;
|
int animcount;
|
||||||
int curranimation=0;
|
int curranimation=0;
|
||||||
int currentframe=0;
|
int currentframe=0;
|
||||||
animatedmodel() {
|
animatedmodel();
|
||||||
model = nullptr;
|
animatedmodel(Model *model,std::vector<ModelAnimation>* animation,int animcount,Vector3 pos,Vector3 rot,Vector3 size,Vector3 scale);
|
||||||
animation = nullptr;
|
void draw() override;
|
||||||
}
|
void exit() override;
|
||||||
animatedmodel(Model *model,std::vector<ModelAnimation>* animation,int animcount,Vector3 pos,Vector3 rot,Vector3 size,Vector3 scale):
|
|
||||||
model(model), animation(animation),node3d(pos,rot,size,scale),animcount(animcount)
|
|
||||||
{}
|
|
||||||
void draw() override {
|
|
||||||
UpdateModelAnimationBones(*model,(*animation)[curranimation],currentframe++);
|
|
||||||
if (currentframe >= (*animation)[curranimation].frameCount) currentframe = 0;
|
|
||||||
DrawModel(*model,pos,1.,tint);
|
|
||||||
}
|
|
||||||
void exit() override {
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
BIN
engine/test/test
BIN
engine/test/test
Binary file not shown.
15
games/forespend/player/kinfuyuki/player.json
Normal file
15
games/forespend/player/kinfuyuki/player.json
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "kin fuyuki",
|
||||||
|
"description":
|
||||||
|
"me sprite yay im the creator of this game",
|
||||||
|
"spritew":16,
|
||||||
|
"spriteh":32,
|
||||||
|
"width": 1.0,
|
||||||
|
"height": 2.0,
|
||||||
|
"speed": 1.0,
|
||||||
|
"health": 1.0,
|
||||||
|
"radiores": 1.0,
|
||||||
|
"exhaustres": 1.0,
|
||||||
|
"singlesprite": true
|
||||||
|
}
|
||||||
|
|
||||||
BIN
games/forespend/player/kinfuyuki/player.png
Normal file
BIN
games/forespend/player/kinfuyuki/player.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 369 B |
22
games/forespend/player/kinfuyuki/player.tdf
Normal file
22
games/forespend/player/kinfuyuki/player.tdf
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#BLOCKTYPE LIST
|
||||||
|
#
|
||||||
|
|
||||||
|
" name kin fuyuki
|
||||||
|
S description
|
||||||
|
me sprite yay im the creator of this game
|
||||||
|
heya hoihoi
|
||||||
|
\
|
||||||
|
i spritew 16
|
||||||
|
i spriteh 32
|
||||||
|
f width 8.0
|
||||||
|
f height 2.0
|
||||||
|
f speed 2.0
|
||||||
|
f health 2.0
|
||||||
|
f radiores 2.0
|
||||||
|
f exhaustres 2.0
|
||||||
|
B singlesprite T
|
||||||
|
B 3dprerendered F
|
||||||
|
# 0 = 1 side 1 = 4 sides 2 = 8 sides (diagonal axes)
|
||||||
|
# 3 = 10 sides (top and down)
|
||||||
|
i directions 0
|
||||||
|
# defined
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 94 B |
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB |
|
|
@ -18,6 +18,7 @@ void client::boot() {
|
||||||
AT("res/shaders/screen.vs"),
|
AT("res/shaders/screen.vs"),
|
||||||
AT("res/shaders/screen.fs")
|
AT("res/shaders/screen.fs")
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
void client::draw() {
|
void client::draw() {
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <enginend/engine.h>
|
#include <enginend/engine.h>
|
||||||
|
#include "../../common/themes.h"
|
||||||
extern enginend::group maincfgpage;
|
extern enginend::group maincfgpage;
|
||||||
extern enginend::group graphics;
|
extern enginend::group graphics;
|
||||||
extern enginend::group sound;
|
extern enginend::group sound;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,71 @@
|
||||||
#include "mainmenu.h"
|
#include"mainmenu.h"
|
||||||
|
|
||||||
|
void mainmenu::boot(){
|
||||||
|
this->nodes=std::vector<enginend::nodes::node*>{
|
||||||
|
new animated(AT("res/images/sky.gif"),0,0,1,1,2),
|
||||||
|
new text(nullptr,clienttheme,0.17,0.05,0.8,0.3,32,"FORESPEND"),
|
||||||
|
new labeledbutton("PLAY",nullptr,clienttheme,0.30,0.25,0.4,0.2,
|
||||||
|
std::function<void()>([]{
|
||||||
|
|
||||||
|
}),32),
|
||||||
|
new labeledbutton("OPTIONS",nullptr,clienttheme,0.02,0.75,0.56,0.2,
|
||||||
|
std::function<void()>([]{
|
||||||
|
configmenupage=1;
|
||||||
|
}),32),
|
||||||
|
new labeledbutton("EXIT",nullptr,clienttheme,0.63,0.75,0.35,0.2,
|
||||||
|
std::function<void()>([](){
|
||||||
|
std::exit(1);
|
||||||
|
}),32),
|
||||||
|
};
|
||||||
|
enginend::scene::boot();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mainmenu::tick(){
|
||||||
|
switch (configmenupage) {
|
||||||
|
case 0:{
|
||||||
|
for (enginend::nodes::node* n : this->nodes) {
|
||||||
|
n->tick();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {this->nodes[0]->tick();
|
||||||
|
for (enginend::nodes::node* n : maincfgpage.children) {
|
||||||
|
n->tick();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {this->nodes[0]->tick();
|
||||||
|
for (enginend::nodes::node* n : graphics.children) {
|
||||||
|
n->tick();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainmenu::draw(){
|
||||||
|
switch (configmenupage) {
|
||||||
|
case 0:{
|
||||||
|
for (enginend::nodes::node* n : this->nodes) {
|
||||||
|
n->draw();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {(this->nodes[0])->draw();
|
||||||
|
for (enginend::nodes::node* n : maincfgpage.children) {
|
||||||
|
n->draw();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {this->nodes[0]->draw();
|
||||||
|
for (enginend::nodes::node* n : graphics.children) {
|
||||||
|
n->draw();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void mainmenu::exit(){
|
||||||
|
enginend::scene::exit();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,70 +8,8 @@ private:
|
||||||
Texture2D bg= LoadTexture(AT("res/images/tilesheet.png"));
|
Texture2D bg= LoadTexture(AT("res/images/tilesheet.png"));
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void boot() override {
|
void boot() override ;
|
||||||
this->nodes=std::vector<enginend::nodes::node*>{
|
void tick() override ;
|
||||||
new animated(AT("res/images/sky.gif"),0,0,1,1,2),
|
void draw() override ;
|
||||||
new text(nullptr,clienttheme,0.17,0.05,0.8,0.3,32,"FORESPEND"),
|
void exit() override ;
|
||||||
new labeledbutton("PLAY",nullptr,clienttheme,0.30,0.25,0.4,0.2,
|
|
||||||
std::function<void()>([]{
|
|
||||||
|
|
||||||
}),32),
|
|
||||||
new labeledbutton("OPTIONS",nullptr,clienttheme,0.02,0.75,0.56,0.2,
|
|
||||||
std::function<void()>([]{
|
|
||||||
configmenupage=1;
|
|
||||||
}),32),
|
|
||||||
new labeledbutton("EXIT",nullptr,clienttheme,0.63,0.75,0.35,0.2,
|
|
||||||
std::function<void()>([](){
|
|
||||||
std::exit(1);
|
|
||||||
}),32),
|
|
||||||
};
|
|
||||||
enginend::scene::boot();
|
|
||||||
}
|
|
||||||
void tick() override {
|
|
||||||
switch (configmenupage) {
|
|
||||||
case 0:{
|
|
||||||
for (enginend::nodes::node* n : this->nodes) {
|
|
||||||
n->tick();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1: {this->nodes[0]->tick();
|
|
||||||
for (enginend::nodes::node* n : maincfgpage.children) {
|
|
||||||
n->tick();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {this->nodes[0]->tick();
|
|
||||||
for (enginend::nodes::node* n : graphics.children) {
|
|
||||||
n->tick();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void draw() override {
|
|
||||||
switch (configmenupage) {
|
|
||||||
case 0:{
|
|
||||||
for (enginend::nodes::node* n : this->nodes) {
|
|
||||||
n->draw();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1: {(this->nodes[0])->draw();
|
|
||||||
for (enginend::nodes::node* n : maincfgpage.children) {
|
|
||||||
n->draw();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {this->nodes[0]->draw();
|
|
||||||
for (enginend::nodes::node* n : graphics.children) {
|
|
||||||
n->draw();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void exit() override {
|
|
||||||
enginend::scene::exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
#include "../../../common/world/world.h"
|
#include "../../../common/world/world.h"
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
Camera3D* worldcam;
|
||||||
|
enginend::nodes::trid::billboard* itsame;
|
||||||
void world::boot() {
|
void world::boot() {
|
||||||
|
|
||||||
|
itsame=new enginend::nodes::trid::billboard({0,0,0},{0,0,0},{1,1,1},{1,1,1},"player/kinfuyuki/player.png");
|
||||||
players->boot();
|
players->boot();
|
||||||
entities->boot();
|
entities->boot();
|
||||||
buildings->boot();
|
buildings->boot();
|
||||||
|
|
@ -8,15 +14,19 @@ void world::boot() {
|
||||||
AT("res/shaders/tile.vs"),
|
AT("res/shaders/tile.vs"),
|
||||||
AT("res/shaders/tile.fs")
|
AT("res/shaders/tile.fs")
|
||||||
);
|
);
|
||||||
|
players->children.push_back(itsame);
|
||||||
|
worldcam=new Camera3D;
|
||||||
|
itsame->watcher=worldcam;
|
||||||
}
|
}
|
||||||
void world::draw() {
|
void world::draw() {
|
||||||
|
BeginMode3D(*worldcam);
|
||||||
BeginShaderMode(worldrender);
|
BeginShaderMode(worldrender);
|
||||||
terrain->draw();
|
terrain->draw();
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
players->draw();
|
players->draw();
|
||||||
entities->draw();
|
entities->draw();
|
||||||
buildings->draw();
|
buildings->draw();
|
||||||
|
EndMode3D();
|
||||||
}
|
}
|
||||||
void world::exit() {
|
void world::exit() {
|
||||||
players->exit();
|
players->exit();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue