Skip to content

Commit eaf77a8

Browse files
committed
v0.8.2: release notes
- add standard sw input joystick - dengitor now loads current font in preferences - update gradle plugin - `-dumpscene` is now an argument for test scene-ecs
1 parent a70cf61 commit eaf77a8

12 files changed

Lines changed: 273 additions & 86 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
project(dengine VERSION 0.8.1)
3+
project(dengine VERSION 0.8.2)
44

55
#this is just a slight nuance with cmake rather than renaming the project
66
set(DENGINE_VERSION "${dengine_VERSION}")

glue/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ set_target_properties(dengine_glue_lib PROPERTIES
1717
POSITION_INDEPENDENT_CODE ON)
1818
target_include_directories(dengine_glue_lib PRIVATE
1919
${CMAKE_CURRENT_BINARY_DIR})
20-
target_link_libraries(dengine_glue_lib PRIVATE dengine-core dengine-utils dengine-gui dengine-script)
20+
set(dengine_glue_lib_links dengine-core dengine-utils dengine-gui dengine-script)
21+
if(UNIX)
22+
list(APPEND dengine_glue_lib_links m)
23+
endif()
24+
target_link_libraries(dengine_glue_lib PRIVATE ${dengine_glue_lib_links})
2125

2226
install(TARGETS dengine_glue_lib DESTINATION lib/dengine-${DENGINE_VERSION})

glue/include/dengine/dengine.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ typedef struct
7272

7373
int android_handlebackbutton;
7474
}DengineInitOpts;
75+
76+
77+
typedef struct
78+
{
79+
int isdown, snap_x, snap_y;
80+
int isregion_ondown;
81+
}SWInput_Joystick;
82+
83+
7584
#ifdef __cplusplus
7685
extern "C" {
7786
#endif
@@ -90,6 +99,26 @@ int dengine_update();
9099
*/
91100
int dengine_load_asset(const char* path, void** mem, size_t* length);
92101

102+
/*!
103+
* \brief software input joystick
104+
* \param x x screen coordinate
105+
* \param y y screen coordinate
106+
* \param dim width and height of joystick. it must be a square after all
107+
* \param snap_lim if > 0, allows the joystick to snap if input is around x and y around the limit region specified
108+
* \param clamp a texture for the clamp limiting the handle. usually a hollow circle
109+
* \param handle a texture for the handle which user operates. usually a filled circle
110+
* \param outx outputs -1 and 1 with how much of the handle has deviated from centre of clamp in x axis
111+
* \param outy outputs -1 and 1 with how much of the handle has deviated from centre of clamp in x axis
112+
* \param store static private datastore which should be init to 0 with memset
113+
*/
114+
void dengine_input_swinput_joystick(
115+
int x, int y, int dim,
116+
int snap_lim,
117+
Texture* clamp, float* clamp_color_vec4,
118+
Texture* handle, float* handle_color_vec4,
119+
float* outx, float* outy,
120+
SWInput_Joystick* joystick);
121+
93122
#ifdef __cplusplus
94123
}
95124
#endif

glue/src/dengine.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,92 @@ int dengine_load_asset(const char* path, void** mem, size_t* length)
406406
return 1;
407407
}
408408

409+
void dengine_input_swinput_joystick(
410+
int x, int y, int dim,
411+
int snap_lim,
412+
Texture* clamp, float* clamp_color_vec4,
413+
Texture* handle, float* handle_color_vec4,
414+
float* outx, float* outy,
415+
SWInput_Joystick* joystick)
416+
{
417+
float hwinput_x, hwinput_y;
418+
vec2 output;
419+
420+
/* TODO: we use mouse for now. use touches too */
421+
joystick->isdown = dengine_input_get_mousebtn(DENGINE_INPUT_MSEBTN_PRIMARY);
422+
hwinput_x = dengine_input_get_mousepos_x();
423+
hwinput_y = dengine_input_get_mousepos_y();
424+
425+
int joyx = x;
426+
int joyy = y;
427+
int joyhanddim = dim / 2;
428+
int joyhandx, joyhandy;
429+
430+
int sqregionoffset =
431+
snap_lim ?
432+
snap_lim : dim;
433+
434+
/*TODO: doesn't consider the center of joystick. the user
435+
* wont notice anyway (0_-), (-_-), (0_-)
436+
*/
437+
int inregion = hwinput_x >= x - sqregionoffset && hwinput_x <= x + sqregionoffset &&
438+
hwinput_y >= y - sqregionoffset && hwinput_y <= y + sqregionoffset;
439+
440+
if(snap_lim)
441+
{
442+
joyx = hwinput_x - (dim / 2.0f);
443+
joyy = hwinput_y - (dim / 2.0f);
444+
if(inregion && !joystick->isregion_ondown)
445+
{
446+
joystick->snap_x = joyx;;
447+
joystick->snap_y = joyy;
448+
joystick->isregion_ondown = 1;
449+
}
450+
451+
if(joystick->isdown)
452+
{
453+
joyx = joystick->snap_x;
454+
joyy = joystick->snap_y;
455+
}
456+
}else {
457+
if(joystick->isdown && inregion)
458+
joystick->isregion_ondown = 1;
459+
}
460+
461+
if(joystick->isdown && joystick->isregion_ondown){
462+
joyhandx = hwinput_x - (joyhanddim / 2.0f);
463+
joyhandy = hwinput_y - (joyhanddim / 2.0f);
464+
vec2 a = {joyhandx + (joyhanddim / 2.0f), joyhandy + (joyhanddim / 2.0f)};
465+
vec2 b = {joyx + (dim / 2.0f), joyy + (dim / 2.0f)};
466+
vec2 c;
467+
glm_vec2_sub(a, b, c);
468+
float mag = glm_vec2_norm(c);
469+
if(mag > dim / 2.0f)
470+
{
471+
glm_vec2_scale_as(c, dim / 2.0f, c);
472+
}
473+
joyhandx = joyx + (joyhanddim / 2.0f) + c[0];
474+
joyhandy = joyy + (joyhanddim / 2.0f) + c[1];
475+
glm_vec2_divs(c, dim / 2.0f, output);
476+
;
477+
}else{
478+
joyx = x;
479+
joyy = y;
480+
joystick->isregion_ondown = 0;
481+
joyhandx = joyx + (dim / 2.0f) - (joyhanddim / 2.0f);
482+
joyhandy = joyy + (dim / 2.0f) - (joyhanddim / 2.0f);
483+
glm_vec2_zero(output);
484+
}
485+
486+
*outx = output[0];
487+
*outy = output[1];
488+
489+
denginegui_set_panel_discard(1);
490+
denginegui_panel(joyx, joyy, dim, dim, clamp, NULL, clamp_color_vec4);
491+
denginegui_panel(joyhandx, joyhandy, joyhanddim, joyhanddim, handle, NULL, handle_color_vec4);
492+
denginegui_set_panel_discard(0);
493+
}
494+
409495
#ifdef DENGINE_ANDROID
410496
void backbutton_func(struct android_app* app)
411497
{

lib/dengine-core/src/window.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,20 +1479,22 @@ int32_t _dengine_window_android_oninput(struct android_app* app, AInputEvent* ev
14791479
stdinput->touches[i].y = h - AMotionEvent_getY(event, i);
14801480
}
14811481

1482-
stdinput->mouse_btns[DENGINE_INPUT_MSEBTN_PRIMARY].state = 1;
1483-
stdinput->mouse_x = stdinput->touches[0].x;
1484-
stdinput->mouse_y = stdinput->touches[0].y;
14851482
if(ptrid < DENGINE_ARY_SZ(stdinput->touches)){
14861483
stdinput->touches[ptrid].isdown = 1;
14871484
if(state == AMOTION_EVENT_ACTION_UP || state == AMOTION_EVENT_ACTION_POINTER_UP){
1488-
stdinput->mouse_btns[DENGINE_INPUT_MSEBTN_PRIMARY].state = 0;
14891485
stdinput->touches[ptrid].isdown = 0;
14901486
stdinput->touches[ptrid].oneshot = 0;
14911487
}
14921488
}
1489+
1490+
/*TODO: touch 0 is very naive as other touches could be down when its 0*/
1491+
stdinput->mouse_x = stdinput->touches[0].x;
1492+
stdinput->mouse_y = stdinput->touches[0].y;
1493+
stdinput->mouse_btns[DENGINE_INPUT_MSEBTN_PRIMARY].state = stdinput->touches[0].isdown;
14931494

14941495

1495-
/*for(size_t i = 0; i < DENGINE_ARY_SZ(stdinput->touches); i++)*/
1496+
1497+
/* for(size_t i = 0; i < DENGINE_ARY_SZ(stdinput->touches); i++)*/
14961498
/*{*/
14971499
/*dengineutils_logging_log("%f %f %d %d",*/
14981500
/*stdinput->touches[i].x,*/

main/dengitor/res/default/dengine-editor-ui.glade

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,9 @@ audio-volume-medium-symbolic</property>
19481948
<object class="GtkTreeView" id="log">
19491949
<property name="visible">True</property>
19501950
<property name="can-focus">True</property>
1951+
<child internal-child="selection">
1952+
<object class="GtkTreeSelection"/>
1953+
</child>
19511954
</object>
19521955
</child>
19531956
</object>
@@ -2156,6 +2159,7 @@ audio-volume-medium-symbolic</property>
21562159
<property name="language">en-gb</property>
21572160
<property name="preview-text"/>
21582161
<signal name="font-set" handler="_dengitor_prefs_fontset" swapped="no"/>
2162+
<signal name="map" handler="_dengitor_prefs_fontset_onmap" swapped="no"/>
21592163
</object>
21602164
<packing>
21612165
<property name="expand">True</property>

main/dengitor/src/prefs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ DENGINE_EXPORT void _dengitor_prefs_fontset(GtkFontButton* btn)
4242
dengitor_redraw();
4343
}
4444

45+
DENGINE_EXPORT void _dengitor_prefs_fontset_onmap(GtkFontButton* btn)
46+
{
47+
GtkFontChooser* font_chooser = GTK_FONT_CHOOSER(btn);
48+
char* font;
49+
GtkSettings* settings = gtk_settings_get_for_screen(gdk_screen_get_default());
50+
51+
g_object_get(settings, "gtk-font-name", &font, NULL);
52+
gtk_font_chooser_set_font(font_chooser, font);
53+
free(font);
54+
}
55+
4556
void dengitor_prefs_setup(GtkBuilder* builder, DengitorPrefs* prefs)
4657
{
4758
prefs->provider = gtk_css_provider_new();

tests/src/testdengine-android/apk/.idea/AndroidProjectSystem.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/src/testdengine-android/apk/.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/src/testdengine-android/apk/.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)