Skip to content

Commit

Permalink
Add reset HUD layout action, only require fontconfig if libagg is found.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesourcehim committed Feb 3, 2024
1 parent 7252e1c commit 25a5d68
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
21 changes: 19 additions & 2 deletions desmume/src/frontend/posix/gtk/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#include <SDL.h>
#include <X11/Xlib.h>
#include <vector>
#ifdef HAVE_LIBAGG
#include <fontconfig/fontconfig.h>
#endif

#include "types.h"
#include "firmware.h"
Expand Down Expand Up @@ -128,6 +130,7 @@ enum {
SUB_OBJ
};

#ifdef HAVE_LIBAGG
#ifdef AGG2D_USE_VECTORFONTS
#define VECTOR_FONT_BASE_SIZE 16
#endif
Expand All @@ -136,6 +139,7 @@ static FcConfig* fontConfig;
static std::string vectorFontFile;

static std::string FindFontFile(const char* fontName, bool bold);
#endif

gboolean EmuLoop(gpointer data);

Expand Down Expand Up @@ -200,6 +204,7 @@ static void HudLagCounter(GSimpleAction *action, GVariant *parameter, gpointer u
static void HudRtc(GSimpleAction *action, GVariant *parameter, gpointer user_data);
static void HudMic(GSimpleAction *action, GVariant *parameter, gpointer user_data);
static void HudEditor(GSimpleAction *action, GVariant *parameter, gpointer user_data);
static void HudResetLayout(GSimpleAction *action, GVariant *parameter, gpointer user_data);
static void HudSaveLayout();
static void HudLoadLayout();
#endif
Expand Down Expand Up @@ -259,6 +264,7 @@ static const GActionEntry app_entries[] = {
{ "hud_rtc", HudRtc, NULL, "false" },
{ "hud_mic", HudMic, NULL, "false" },
{ "hud_editor", HudEditor, NULL, "false" },
{ "hud_reset_layout", HudResetLayout},
#endif

// Config
Expand Down Expand Up @@ -2829,6 +2835,12 @@ HudMacro(HudRtc, HUD_DISPLAY_RTC)
HudMacro(HudMic, HUD_DISPLAY_MIC)
HudMacro(HudEditor, HUD_DISPLAY_EDITOR)

static void HudResetLayout(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
Hud.reset();
HudSaveLayout();
}

static void HudSaveCoordsToVector(HudCoordinates* pCoords, int* pDest)
{
pDest[0]=pCoords->x;
Expand Down Expand Up @@ -3738,6 +3750,8 @@ handle_open(GApplication *application,
common_gtk_main(application, user_data);
}

#ifdef HAVE_LIBAGG

static std::string FindFontFile(const char* fontName, bool bold)
{
std::string fontFile;
Expand All @@ -3764,13 +3778,16 @@ static std::string FindFontFile(const char* fontName, bool bold)
return fontFile;
}

#endif

int main (int argc, char *argv[])
{
configured_features my_config;


#ifdef HAVE_LIBAGG
fontConfig = FcInitLoadConfigAndFonts();
vectorFontFile = FindFontFile("mono", true);

#endif
// The global menu screws up the window size...
unsetenv("UBUNTU_MENUPROXY");

Expand Down
4 changes: 4 additions & 0 deletions desmume/src/frontend/posix/gtk/menu.ui
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@
<attribute name='label' translatable='yes'>_Editor mode</attribute>
<attribute name='action'>app.hud_editor</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>Reset layout</attribute>
<attribute name='action'>app.hud_reset_layout</attribute>
</item>
</section>
</menu>
<menu id='hud_unsupported'>
Expand Down
8 changes: 6 additions & 2 deletions desmume/src/frontend/posix/gtk/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
dep_gtk3 = dependency('gtk+-3.0', version: '>=3.24')
dep_x11 = dependency('x11')
dep_fontconfig = dependency('fontconfig')

gtk_dependencies = dependencies + [dep_gtk3, dep_x11, dep_fontconfig]
gtk_dependencies = dependencies + [dep_gtk3, dep_x11]

if dep_agg.found()
dep_fontconfig = dependency('fontconfig')
gtk_dependencies = gtk_dependencies + [dep_fontconfig]
endif

gnome = import('gnome')

Expand Down

0 comments on commit 25a5d68

Please sign in to comment.