Skip to content

Commit e7e21ef

Browse files
committed
Format code.
1 parent 179af8d commit e7e21ef

54 files changed

Lines changed: 1472 additions & 786 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/editor/include/editor.h

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,40 @@ void editor_create_game_world(te_editor* editor, struct te_game_manager* game_ma
1616

1717
// window callbacks -------------------------------------------------------------------------------
1818
void editor_on_game_started(void* game_instance, struct te_game_manager* game_manager);
19-
void editor_on_game_tick(void* game_instance, struct te_game_manager* game_manager, float delta_time_sec);
19+
void editor_on_game_tick(
20+
void* game_instance, struct te_game_manager* game_manager, float delta_time_sec);
2021
void editor_on_keyboard_button_pressed(
21-
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button, te_keyboard_modifiers modifiers);
22+
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button,
23+
te_keyboard_modifiers modifiers);
2224
void editor_on_keyboard_button_released(
23-
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button, te_keyboard_modifiers modifiers);
24-
void editor_on_keyboard_input_text(void* game_instance, struct te_game_manager* game_manager, const char* text);
25-
void editor_on_gamepad_button_pressed(void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button);
26-
void editor_on_gamepad_button_released(void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button);
27-
void
28-
editor_on_gamepad_axis_moved(void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_axis axis, float new_pos);
25+
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button,
26+
te_keyboard_modifiers modifiers);
27+
void editor_on_keyboard_input_text(
28+
void* game_instance, struct te_game_manager* game_manager, const char* text);
29+
void editor_on_gamepad_button_pressed(
30+
void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button);
31+
void editor_on_gamepad_button_released(
32+
void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button);
33+
void editor_on_gamepad_axis_moved(
34+
void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_axis axis,
35+
float new_pos);
2936
void editor_on_mouse_button_pressed(
30-
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button, bool was_handled_by_widget);
37+
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button,
38+
bool was_handled_by_widget);
3139
void editor_on_mouse_button_released(
32-
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button, bool was_handled_by_widget);
33-
void editor_on_mouse_moved(void* game_instance, struct te_game_manager* game_manager, float x_offset, float y_offset);
34-
void editor_on_mouse_scroll_moved(void* game_instance, struct te_game_manager* game_manager, float offset);
35-
void editor_on_gamepad_connected(void* game_instance, struct te_game_manager* game_manager, const char* gamepad_name);
40+
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button,
41+
bool was_handled_by_widget);
42+
void editor_on_mouse_moved(
43+
void* game_instance, struct te_game_manager* game_manager, float x_offset, float y_offset);
44+
void editor_on_mouse_scroll_moved(
45+
void* game_instance, struct te_game_manager* game_manager, float offset);
46+
void editor_on_gamepad_connected(
47+
void* game_instance, struct te_game_manager* game_manager, const char* gamepad_name);
3648
void editor_on_gamepad_disconnected(void* game_instance, struct te_game_manager* game_manager);
37-
void editor_on_input_source_changed(void* game_instance, struct te_game_manager* game_manager, bool is_gamepad_current);
38-
void editor_on_window_received_focus(void* game_instance, struct te_game_manager* game_manager);
49+
void editor_on_input_source_changed(
50+
void* game_instance, struct te_game_manager* game_manager, bool is_gamepad_current);
51+
void
52+
editor_on_window_received_focus(void* game_instance, struct te_game_manager* game_manager);
3953
void editor_on_window_lost_focus(void* game_instance, struct te_game_manager* game_manager);
4054
void editor_on_window_close(void* game_instance, struct te_game_manager* game_manager);
4155
// ------------------------------------------------------------------------------------------------

src/editor/include/editor_camera.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ void editor_camera_enable_input(te_editor_camera* editor_camera, bool enable);
2525
struct te_camera* editor_camera_get_camera(te_editor_camera* editor_camera);
2626

2727
// callbacks -------------------------------------------------------------------------------
28-
void editor_camera_on_mouse_moved(te_editor_camera* editor_camera, float x_offset, float y_offset);
29-
void editor_camera_on_gamepad_axis_moved(te_editor_camera* editor_camera, enum te_gamepad_axis axis, float new_pos);
30-
void editor_camera_on_keyboard_button_pressed(te_editor_camera* editor_camera, enum te_keyboard_button button);
31-
void editor_camera_on_keyboard_button_released(te_editor_camera* editor_camera, enum te_keyboard_button button);
28+
void
29+
editor_camera_on_mouse_moved(te_editor_camera* editor_camera, float x_offset, float y_offset);
30+
void editor_camera_on_gamepad_axis_moved(
31+
te_editor_camera* editor_camera, enum te_gamepad_axis axis, float new_pos);
32+
void editor_camera_on_keyboard_button_pressed(
33+
te_editor_camera* editor_camera, enum te_keyboard_button button);
34+
void editor_camera_on_keyboard_button_released(
35+
te_editor_camera* editor_camera, enum te_keyboard_button button);
3236
void editor_camera_on_game_tick(te_editor_camera* editor_camera, float delta_time_sec);
3337
void editor_camera_on_gamepad_connected(te_editor_camera* editor_camera);
3438
void editor_camera_on_gamepad_disconnected(te_editor_camera* editor_camera);

src/editor/src/editor.c

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ editor_create_game_world(te_editor* editor, te_game_manager* game_manager) {
9292

9393
// Prepare stats widget.
9494
editor->game_world_stats_widget = text_widget_create();
95-
widget_set_relative_position(text_widget_get_widget(editor->game_world_stats_widget), (vec2){0.01f, 0.01f});
96-
widget_set_relative_size(text_widget_get_widget(editor->game_world_stats_widget), (vec2){0.4f, 0.2f});
97-
widget_set_is_serialization_allowed(text_widget_get_widget(editor->game_world_stats_widget), false);
95+
widget_set_relative_position(
96+
text_widget_get_widget(editor->game_world_stats_widget), (vec2){0.01f, 0.01f});
97+
widget_set_relative_size(
98+
text_widget_get_widget(editor->game_world_stats_widget), (vec2){0.4f, 0.2f});
99+
widget_set_is_serialization_allowed(
100+
text_widget_get_widget(editor->game_world_stats_widget), false);
98101
text_widget_set_is_multiline(editor->game_world_stats_widget, true);
99102
editor->time_since_stats_update_sec = 10.0f;
100103

@@ -103,7 +106,8 @@ editor_create_game_world(te_editor* editor, te_game_manager* game_manager) {
103106
text_widget_set_text_own(editor->game_world_stats_widget, stats_text, text_len);
104107

105108
// Spawn stats widget.
106-
world_spawn_widget(editor->game_world, text_widget_get_widget(editor->game_world_stats_widget));
109+
world_spawn_widget(
110+
editor->game_world, text_widget_get_widget(editor->game_world_stats_widget));
107111
}
108112

109113
void
@@ -115,29 +119,36 @@ editor_on_game_tick(void* game_instance, te_game_manager* game_manager, float de
115119

116120
// Update stats.
117121
editor->time_since_stats_update_sec += delta_time_sec;
118-
if (editor->game_world_stats_widget != NULL && editor->time_since_stats_update_sec >= 2.0f) {
122+
if (editor->game_world_stats_widget != NULL
123+
&& editor->time_since_stats_update_sec >= 2.0f) {
119124
editor->time_since_stats_update_sec = 0.0f;
120125

121126
te_renderer* renderer = game_manager_get_renderer(game_manager);
122127
const unsigned int fps = renderer_get_fps(renderer);
123128
const unsigned int fps_limit = renderer_get_fps_limit(renderer);
124129

125-
const unsigned int process_mem = (unsigned int)(memory_usage_get_process_used_memory() / 1024 / 1024);
126-
const unsigned int total_used_mem = (unsigned int)(memory_usage_get_total_used_memory() / 1024 / 1024);
127-
const unsigned int total_mem = (unsigned int)(memory_usage_get_total_memory() / 1024 / 1024);
130+
const unsigned int process_mem =
131+
(unsigned int)(memory_usage_get_process_used_memory() / 1024 / 1024);
132+
const unsigned int total_used_mem =
133+
(unsigned int)(memory_usage_get_total_used_memory() / 1024 / 1024);
134+
const unsigned int total_mem =
135+
(unsigned int)(memory_usage_get_total_memory() / 1024 / 1024);
128136

129137
const char* fmt = "FPS: %u (limit: %u)\nRAM used (MB): %u (%u/%u)";
130138
#if defined(ENGINE_ASAN_ENABLED)
131139
fmt = "FPS: %u (limit: %u)\nRAM used (MB): %u (%u/%u) (ASan enabled)";
132140
#endif
133141

134-
int len = snprintf(NULL, 0, fmt, fps, fps_limit, process_mem, total_used_mem, total_mem);
142+
int len =
143+
snprintf(NULL, 0, fmt, fps, fps_limit, process_mem, total_used_mem, total_mem);
135144
if (len < 0) {
136145
log_error("snprintf error");
137146
abort();
138147
}
139148
char* src_text = malloc(sizeof(char) * (size_t)(len + 1));
140-
snprintf(src_text, (size_t)len + 1, fmt, fps, fps_limit, process_mem, total_used_mem, total_mem);
149+
snprintf(
150+
src_text, (size_t)len + 1, fmt, fps, fps_limit, process_mem, total_used_mem,
151+
total_mem);
141152

142153
unsigned int text_len;
143154
wchar_t* stats_text = wchar_from_char(src_text, &text_len);
@@ -149,7 +160,8 @@ editor_on_game_tick(void* game_instance, te_game_manager* game_manager, float de
149160

150161
void
151162
editor_on_keyboard_button_pressed(
152-
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button, te_keyboard_modifiers modifiers) {
163+
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button,
164+
te_keyboard_modifiers modifiers) {
153165
(void)game_manager;
154166
(void)modifiers;
155167

@@ -159,7 +171,8 @@ editor_on_keyboard_button_pressed(
159171

160172
void
161173
editor_on_keyboard_button_released(
162-
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button, te_keyboard_modifiers modifiers) {
174+
void* game_instance, struct te_game_manager* game_manager, enum te_keyboard_button button,
175+
te_keyboard_modifiers modifiers) {
163176
(void)modifiers;
164177

165178
te_editor* editor = game_instance;
@@ -171,21 +184,24 @@ editor_on_keyboard_button_released(
171184
}
172185

173186
void
174-
editor_on_keyboard_input_text(void* game_instance, struct te_game_manager* game_manager, const char* text) {
187+
editor_on_keyboard_input_text(
188+
void* game_instance, struct te_game_manager* game_manager, const char* text) {
175189
(void)game_instance;
176190
(void)game_manager;
177191
(void)text;
178192
}
179193

180194
void
181-
editor_on_gamepad_button_pressed(void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button) {
195+
editor_on_gamepad_button_pressed(
196+
void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button) {
182197
(void)game_instance;
183198
(void)game_manager;
184199
(void)button;
185200
}
186201

187202
void
188-
editor_on_gamepad_button_released(void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button) {
203+
editor_on_gamepad_button_released(
204+
void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_button button) {
189205
(void)game_instance;
190206

191207
if (button == TE_GB_BUTTON_RIGHT) {
@@ -195,7 +211,8 @@ editor_on_gamepad_button_released(void* game_instance, struct te_game_manager* g
195211

196212
void
197213
editor_on_gamepad_axis_moved(
198-
void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_axis axis, float new_pos) {
214+
void* game_instance, struct te_game_manager* game_manager, enum te_gamepad_axis axis,
215+
float new_pos) {
199216
(void)game_manager;
200217

201218
te_editor* editor = game_instance;
@@ -204,7 +221,8 @@ editor_on_gamepad_axis_moved(
204221

205222
void
206223
editor_on_mouse_button_pressed(
207-
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button, bool was_handled_by_widget) {
224+
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button,
225+
bool was_handled_by_widget) {
208226
(void)was_handled_by_widget;
209227
te_editor* editor = game_instance;
210228

@@ -223,7 +241,8 @@ editor_on_mouse_button_pressed(
223241

224242
void
225243
editor_on_mouse_button_released(
226-
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button, bool was_handled_by_widget) {
244+
void* game_instance, struct te_game_manager* game_manager, enum te_mouse_button button,
245+
bool was_handled_by_widget) {
227246
(void)was_handled_by_widget;
228247
te_editor* editor = game_instance;
229248

@@ -241,22 +260,26 @@ editor_on_mouse_button_released(
241260
}
242261

243262
void
244-
editor_on_mouse_moved(void* game_instance, struct te_game_manager* game_manager, float x_offset, float y_offset) {
263+
editor_on_mouse_moved(
264+
void* game_instance, struct te_game_manager* game_manager, float x_offset,
265+
float y_offset) {
245266
(void)game_manager;
246267

247268
te_editor* editor = game_instance;
248269
editor_camera_on_mouse_moved(editor->editor_camera, x_offset, y_offset);
249270
}
250271

251272
void
252-
editor_on_mouse_scroll_moved(void* game_instance, struct te_game_manager* game_manager, float offset) {
273+
editor_on_mouse_scroll_moved(
274+
void* game_instance, struct te_game_manager* game_manager, float offset) {
253275
(void)game_instance;
254276
(void)game_manager;
255277
(void)offset;
256278
}
257279

258280
void
259-
editor_on_gamepad_connected(void* game_instance, struct te_game_manager* game_manager, const char* gamepad_name) {
281+
editor_on_gamepad_connected(
282+
void* game_instance, struct te_game_manager* game_manager, const char* gamepad_name) {
260283
(void)game_manager;
261284
(void)gamepad_name;
262285

@@ -273,7 +296,8 @@ editor_on_gamepad_disconnected(void* game_instance, struct te_game_manager* game
273296
}
274297

275298
void
276-
editor_on_input_source_changed(void* game_instance, struct te_game_manager* game_manager, bool is_gamepad_current) {
299+
editor_on_input_source_changed(
300+
void* game_instance, struct te_game_manager* game_manager, bool is_gamepad_current) {
277301
(void)game_instance;
278302
(void)game_manager;
279303
(void)is_gamepad_current;

src/editor/src/editor_camera.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ editor_camera_get_camera(te_editor_camera* editor_camera) {
7979
}
8080

8181
void
82-
editor_camera_apply_look_input(te_editor_camera* editor_camera, float x_offset, float y_offset) {
82+
editor_camera_apply_look_input(
83+
te_editor_camera* editor_camera, float x_offset, float y_offset) {
8384
vec3 rotation;
8485
camera_get_rotation(editor_camera->camera, rotation);
8586

@@ -99,7 +100,8 @@ editor_camera_on_mouse_moved(te_editor_camera* editor_camera, float x_offset, fl
99100
}
100101

101102
void
102-
editor_camera_on_gamepad_axis_moved(te_editor_camera* editor_camera, enum te_gamepad_axis axis, float new_pos) {
103+
editor_camera_on_gamepad_axis_moved(
104+
te_editor_camera* editor_camera, enum te_gamepad_axis axis, float new_pos) {
103105
if (axis == TE_GA_RIGHT_STICK_X) {
104106
editor_camera->gamepad_look[0] = new_pos;
105107
} else if (axis == TE_GA_RIGHT_STICK_Y) {
@@ -116,7 +118,8 @@ editor_camera_on_gamepad_axis_moved(te_editor_camera* editor_camera, enum te_gam
116118
}
117119

118120
void
119-
editor_camera_on_keyboard_button_pressed(te_editor_camera* editor_camera, enum te_keyboard_button button) {
121+
editor_camera_on_keyboard_button_pressed(
122+
te_editor_camera* editor_camera, enum te_keyboard_button button) {
120123
if (!editor_camera->is_input_enabled) {
121124
return;
122125
}
@@ -143,7 +146,8 @@ editor_camera_on_keyboard_button_pressed(te_editor_camera* editor_camera, enum t
143146
}
144147

145148
void
146-
editor_camera_on_keyboard_button_released(te_editor_camera* editor_camera, enum te_keyboard_button button) {
149+
editor_camera_on_keyboard_button_released(
150+
te_editor_camera* editor_camera, enum te_keyboard_button button) {
147151
if (!editor_camera->is_input_enabled) {
148152
return;
149153
}
@@ -186,7 +190,8 @@ editor_camera_on_game_tick(te_editor_camera* editor_camera, float delta_time_sec
186190
if (editor_camera->gamepad_look[0] != 0.0f || editor_camera->gamepad_look[1] != 0.0f) {
187191
const float mult = 2000.0f * delta_time_sec;
188192
editor_camera_apply_look_input(
189-
editor_camera, editor_camera->gamepad_look[0] * mult, editor_camera->gamepad_look[1] * mult);
193+
editor_camera, editor_camera->gamepad_look[0] * mult,
194+
editor_camera->gamepad_look[1] * mult);
190195
}
191196

192197
if (editor_camera->movement_input[0] == 0.0f && editor_camera->movement_input[1] == 0.0f

src/engine_lib/include/debug_console.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ void prv_debug_console_hide(void);
4040

4141
bool prv_debug_console_is_shown(void);
4242

43-
void prv_debug_console_on_keyboard_input(struct te_game_manager* game_manager, enum te_keyboard_button button);
43+
void prv_debug_console_on_keyboard_input(
44+
struct te_game_manager* game_manager, enum te_keyboard_button button);
4445
void prv_debug_console_on_keyboard_input_text(const char* text);
4546

4647
void prv_debug_console_draw(float delta_time_sec);

src/engine_lib/include/game/camera.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ void camera_register_type(void);
7272

7373
// Sets size (in pixels) of the render target (used to calculate aspect ratio for the projection matrix).
7474
// Does nothing if the specified render target size is already set to the same value.
75-
void prv_camera_set_render_target_size(te_camera* camera, unsigned int width, unsigned int height);
75+
void
76+
prv_camera_set_render_target_size(te_camera* camera, unsigned int width, unsigned int height);
7677

7778
// Sets world the camera is spawned in (specify NULL to mark despawn).
7879
void prv_camera_set_world(te_camera* camera, struct te_world* world);

src/engine_lib/include/game_manager.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ struct te_renderer* game_manager_get_renderer(te_game_manager* game_manager);
2828

2929
// Returns array of currently existing worlds.
3030
// Do not free/destroy returned pointer.
31-
struct te_world** game_manager_get_worlds(te_game_manager* game_manager, unsigned int* world_count);
31+
struct te_world**
32+
game_manager_get_worlds(te_game_manager* game_manager, unsigned int* world_count);
3233

3334
// Returns user's main game system that was specified after window creation.
3435
void* game_manager_get_game_instance(te_game_manager* game_manager);
@@ -51,11 +52,14 @@ void prv_game_manager_on_window_size_changed(te_game_manager* game_manager);
5152

5253
// Transfers the event to UI.
5354
// Returns `true` if the event was handled by some widget.
54-
bool prv_game_manager_on_mouse_button_pressed(te_game_manager* game_manager, enum te_mouse_button button);
55-
bool prv_game_manager_on_mouse_button_released(te_game_manager* game_manager, enum te_mouse_button button);
55+
bool prv_game_manager_on_mouse_button_pressed(
56+
te_game_manager* game_manager, enum te_mouse_button button);
57+
bool prv_game_manager_on_mouse_button_released(
58+
te_game_manager* game_manager, enum te_mouse_button button);
5659
void prv_game_manager_on_mouse_moved(te_game_manager* game_manager);
5760
void prv_game_manager_on_keyboard_input_text(te_game_manager* game_manager, const char* text);
58-
void prv_game_manager_on_keyboard_input(te_game_manager* game_manager, enum te_keyboard_button button, bool is_repeat);
61+
void prv_game_manager_on_keyboard_input(
62+
te_game_manager* game_manager, enum te_keyboard_button button, bool is_repeat);
5963

6064
// Called by window after user input device was changed (keyboard+mouse/gamepad).
6165
void prv_game_manager_on_input_source_changed(te_game_manager* game_manager);

0 commit comments

Comments
 (0)