Skip to content

Commit 962ad44

Browse files
committed
Added TinyFileDialogs
1 parent 47a2219 commit 962ad44

26 files changed

Lines changed: 509 additions & 442 deletions

.gitignore

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Created by https://www.toptal.com/developers/gitignore/api/c++,sublimetext
2-
# Edit at https://www.toptal.com/developers/gitignore?templates=c++,sublimetext
1+
# Created by https://www.toptal.com/developers/gitignore/api/images,sublimetext,c++
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=images,sublimetext,c++
33

44
### C++ ###
55
# Prerequisites
@@ -10,7 +10,6 @@
1010
*.lo
1111
*.o
1212
*.obj
13-
*.res
1413

1514
# Precompiled Headers
1615
*.gch
@@ -36,6 +35,71 @@
3635
*.out
3736
*.app
3837

38+
### Images ###
39+
# JPEG
40+
*.jpg
41+
*.jpeg
42+
*.jpe
43+
*.jif
44+
*.jfif
45+
*.jfi
46+
47+
# JPEG 2000
48+
*.jp2
49+
*.j2k
50+
*.jpf
51+
*.jpx
52+
*.jpm
53+
*.mj2
54+
55+
# JPEG XR
56+
*.jxr
57+
*.hdp
58+
*.wdp
59+
60+
# Graphics Interchange Format
61+
*.gif
62+
63+
# RAW
64+
*.raw
65+
66+
# Web P
67+
*.webp
68+
69+
# Portable Network Graphics
70+
*.png
71+
72+
# Animated Portable Network Graphics
73+
*.apng
74+
75+
# Multiple-image Network Graphics
76+
*.mng
77+
78+
# Tagged Image File Format
79+
*.tiff
80+
*.tif
81+
82+
# Scalable Vector Graphics
83+
*.svg
84+
*.svgz
85+
86+
# Portable Document Format
87+
*.pdf
88+
89+
# X BitMap
90+
*.xbm
91+
92+
# BMP
93+
*.bmp
94+
*.dib
95+
96+
# ICO
97+
*.ico
98+
99+
# 3D Images
100+
*.3dm
101+
*.max
102+
39103
### SublimeText ###
40104
# Cache files for Sublime Text
41105
*.tmlanguage.cache
@@ -69,7 +133,4 @@ bh_unicode_properties.cache
69133
# https://packagecontrol.io/packages/sublime-github
70134
GitHub.sublime-settings
71135

72-
# End of https://www.toptal.com/developers/gitignore/api/c++,sublimetext
73-
74-
*.wren
75-
*.png
136+
# End of https://www.toptal.com/developers/gitignore/api/images,sublimetext,c++

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "wrenbind17"]
22
path = wrenbind17
33
url = https://github.com/matusnovak/wrenbind17
4-
[submodule "Cube2D-Framework"]
5-
path = Cube2D-Framework
6-
url = https://github.com/mastercuber55/Cube2D-Framework
4+
[submodule "libtinyfiledialogs"]
5+
path = libtinyfiledialogs
6+
url = https://github.com/native-toolkit/libtinyfiledialogs

Bindings/Engine.cpp

Lines changed: 0 additions & 133 deletions
This file was deleted.

Bindings/Engine/Engine.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <wrenbind17/wrenbind17.hpp>
2+
#include <raylib.h>
3+
#include "Rect.hpp"
4+
5+
namespace Wren = wrenbind17;
6+
7+
void BindEngine(Wren::VM & VM) {
8+
9+
auto& Module = VM.module("Engine");
10+
11+
auto& RectCls = Module.klass<ForeignRect>("ForeignRect");
12+
RectCls.ctor<float, float, float, float>();
13+
14+
// Transform
15+
RectCls.var<&ForeignRect::PositionAndScale>("PositionAndScale");
16+
RectCls.var<&ForeignRect::Rotation>("Rotation");
17+
18+
RectCls.var<&ForeignRect::TextureFile>("TextureFile");
19+
RectCls.var<&ForeignRect::Source>("Source");
20+
RectCls.var<&ForeignRect::Tint>("Tint");
21+
22+
RectCls.func<&ForeignRect::SetPosition>("SetPosition");
23+
RectCls.func<&ForeignRect::SetTextureFile>("SetTextureFile");
24+
RectCls.func<&ForeignRect::Draw>("Draw");
25+
26+
RectCls.func<&ForeignRect::GetCenter>("GetCenter");
27+
RectCls.func<&ForeignRect::GetPosition>("GetPosition");
28+
29+
RectCls.func<&ForeignRect::IsColliding>("IsColliding");
30+
31+
Module.append("import \"raylib\" for RL, COLOR, Color, KEY, Vector2");
32+
33+
Module.append(
34+
#include "Rect.wren"
35+
#include "Scene.wren"
36+
#include "SceneManager.wren"
37+
#include "Tools.wren"
38+
);
39+
Module.append("var Shared = {}");
40+
}

Bindings/Engine/Rect.hpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#define CGE_WHOLE_FILE { 0, 0, -1, -1 }
2+
std::unordered_map<std::string, Texture> Textures;
3+
4+
struct ForeignRect {
5+
6+
// Transformm
7+
Rectangle PositionAndScale;
8+
double Rotation;
9+
10+
std::string TextureFile;
11+
Rectangle Source;
12+
Color Tint;
13+
14+
// De-Constructers
15+
ForeignRect(float x, float y, float w, float h);
16+
~ForeignRect();
17+
18+
// Setters
19+
void SetTextureFile(std::string TextureFile);
20+
21+
// Getters
22+
Vector2 GetCenter();
23+
void SetPosition(Vector2 NewPosition);
24+
Vector2 GetPosition();
25+
Vector2 GetRectangle();
26+
27+
// Utilities
28+
bool IsColliding(ForeignRect * Other);
29+
void Draw();
30+
};
31+
32+
ForeignRect::ForeignRect(float x, float y, float w, float h) {
33+
this->PositionAndScale.x = x, this->PositionAndScale.y = y;
34+
this->PositionAndScale.width = w, this->PositionAndScale.height = h;
35+
this->Tint = WHITE;
36+
this->Source = CGE_WHOLE_FILE,
37+
this->Rotation = 0.0;
38+
}
39+
ForeignRect::~ForeignRect() {}
40+
void ForeignRect::SetTextureFile(std::string TextureFile) {
41+
42+
this->TextureFile = TextureFile;
43+
if(Textures.find(TextureFile) != Textures.end()) return;
44+
Textures[TextureFile] = LoadTexture(TextureFile.c_str());
45+
46+
if(
47+
this->Source.x == 0 &&
48+
this->Source.y == 0 &&
49+
this->Source.width == -1 &&
50+
this->Source.height == -1
51+
) {
52+
this->Source.width = Textures[TextureFile].width,
53+
this->Source.height = Textures[TextureFile].height;
54+
}
55+
56+
}
57+
void ForeignRect::Draw() {
58+
59+
(this->TextureFile.empty()) ?
60+
DrawRectangleRec(this->PositionAndScale, this->Tint)
61+
:
62+
DrawTexturePro(
63+
Textures[this->TextureFile],
64+
this->Source,
65+
(Rectangle){
66+
this->PositionAndScale.x + this->PositionAndScale.width / 2.0f,
67+
this->PositionAndScale.y + this->PositionAndScale.height / 2.0f,
68+
this->PositionAndScale.width,
69+
this->PositionAndScale.height
70+
},
71+
(Vector2){ this->PositionAndScale.width / 2.0f, this->PositionAndScale.height / 2.0f },
72+
this->Rotation,
73+
this->Tint
74+
);
75+
}
76+
bool ForeignRect::IsColliding(ForeignRect * Other) {
77+
return CheckCollisionRecs(PositionAndScale, Other->PositionAndScale);
78+
}
79+
void ForeignRect::SetPosition(Vector2 Position) {
80+
this->PositionAndScale.x = Position.x, this->PositionAndScale.y = Position.y;
81+
}
82+
Vector2 ForeignRect::GetCenter() {
83+
return {
84+
this->PositionAndScale.x + this->PositionAndScale.width / 2.0f,
85+
this->PositionAndScale.y + this->PositionAndScale.height / 2.0f
86+
};
87+
}
88+
Vector2 ForeignRect::GetPosition() {
89+
return { this->PositionAndScale.x, this->PositionAndScale.y };
90+
}

0 commit comments

Comments
 (0)