11#include < CatWare.h>
22
3+ #include " CatWare/UI/Widgets.h"
4+
35using namespace CatWare ;
46
57int i = 1 ;
@@ -15,14 +17,11 @@ class TestEntity : public Entity
1517
1618 TextureRef texture = TextureRef( " gato.jpg" );
1719
18- TestEntity ( )
19- {
20- className = " testEntity" ;
21- }
20+ TestEntity ( ) { className = " testEntity" ; }
2221
2322 void Init ( ) override
2423 {
25- pBody = new DynamicBody ( 10 , 1 , new AABBCollider ( transform.position , transform.size ) );
24+ pBody = new DynamicBody ( 10 , 1 , new AABBCollider ( transform.position , transform.size ) );
2625 pBody->position = transform.position ;
2726 SceneManager::GetScene ( )->world .physicsWorld .AddBody ( pBody );
2827
@@ -77,34 +76,29 @@ class TestEntity : public Entity
7776 emmiter.Emit ( );
7877 }
7978
80- void Draw ( )
81- {
82- Renderer::DrawRectTextured ( transform, texture.Get ( ) );
83- }
79+ void Draw ( ) { Renderer::DrawRectTextured ( transform, texture.Get ( ) ); }
8480
85- CW_ENTITY_CREATE ( tags )
86- {
87- return new TestEntity ( );
88- }
81+ CW_ENTITY_CREATE ( tags ) { return new TestEntity ( ); }
8982};
9083
84+ void OnPress ( ) { CW_LOG->Error ( " Pressed a button" ); }
85+
9186class InGame : public Scene
9287{
9388public:
89+ UI::Button button = UI::Button( " Hello world" , &OnPress );
90+
9491 InGame ( )
9592 {
9693 world.physicsWorld .gravity = 400 ;
97- }
9894
99- void OnEnter ( ) override
100- {
101- world.LoadFromMapFile ( " testMap.yaml" );
95+ button.position = { 20 , 20 };
96+ button.size = { 300 , 100 };
10297 }
10398
104- void Update ( ) override
105- {
99+ void OnEnter ( ) override { world.LoadFromMapFile ( " testMap.yaml" ); }
106100
107- }
101+ void Update ( ) override { }
108102
109103 void Tick ( ) override
110104 {
@@ -124,15 +118,17 @@ class InGame : public Scene
124118 }
125119 }
126120
127- void Draw ( ) override
128- {
129- Renderer::Clear ( { 40 , 40 , 40 , 255 } );
130- }
121+ void Draw ( ) override { Renderer::Clear ( { 40 , 40 , 40 , 255 } ); }
131122
132123 void DrawGUI ( ) override
133124 {
134- Renderer::DrawString ( " FPS: " + std::to_string ( 1.0 / Time::GetDeltaTime ( ) ), { 22 , 22 }, 1 , font, { 0 , 0 , 0 , 255 } );
135- Renderer::DrawString ( " FPS: " + std::to_string ( 1.0 / Time::GetDeltaTime ( ) ), { 20 , 20 }, 1 , font, { 255 , 255 , 255 , 255 } );
125+ Renderer::DrawString (
126+ " FPS: " + std::to_string ( 1.0 / Time::GetDeltaTime ( ) ), { 22 , 22 }, 1 , font, { 0 , 0 , 0 , 255 } );
127+ Renderer::DrawString (
128+ " FPS: " + std::to_string ( 1.0 / Time::GetDeltaTime ( ) ), { 20 , 20 }, 1 , font, { 255 , 255 , 255 , 255 } );
129+
130+ button.Draw ( );
131+ button.Update ( );
136132 }
137133};
138134
@@ -141,7 +137,7 @@ InGame* inGame;
141137class Game : Script
142138{
143139public:
144- void PreInit (CatWare::InitConfig* initConfig) override
140+ void PreInit ( CatWare::InitConfig* initConfig ) override
145141 {
146142 initConfig->windowWidth = 1920 ;
147143 initConfig->windowHeight = 1080 ;
@@ -151,14 +147,15 @@ class Game : Script
151147 Time::modifier = 1.0 ;
152148 }
153149
154- void Start () override
150+ void Start ( ) override
155151 {
156152 font = new Text::Font ( " EngineRes/Fonts/Jura-Regular.ttf" , 30 );
153+ UI::Style::font = font;
157154
158155 Time::frameRateLimited = false ;
159156 Time::maxFPS = 240 ;
160157
161- EntityRegistry::RegisterEntity<TestEntity>( " testEntity" );
158+ EntityRegistry::RegisterEntity< TestEntity >( " testEntity" );
162159
163160 TextureManager::AddTexture ( " gato.jpg" , Rendering::TextureFilter::LINEAR );
164161 TextureManager::AddTexture ( " whitePuff00.png" , Rendering::TextureFilter::LINEAR );
@@ -169,15 +166,9 @@ class Game : Script
169166 SceneManager::SetScene ( inGame );
170167 }
171168
172- void Activate () override
173- {
174-
175- }
169+ void Activate ( ) override {}
176170
177- void Exit () override
178- {
179- delete font;
180- }
171+ void Exit ( ) override { delete font; }
181172};
182173
183- CW_REGISTER_SCRIPT ( Game );
174+ CW_REGISTER_SCRIPT ( Game );
0 commit comments