Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental GTK3-based quick level browser #183

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ if(NOT SCREENSHOT_BUILD)
include_directories(
${GLEW_INCLUDE_DIRS}
${GTK3_INCLUDE_DIRS})

# Only requrired by the level browser
# TODO: make the gtk3 level browser optional
find_package(nlohmann_json 3.2.0 REQUIRED)
include_directories(${NLOHMANN_JSON_INCLUDE_DIRS})
endif()

find_package(CURL REQUIRED)
Expand Down
7 changes: 3 additions & 4 deletions src/src/menu_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ menu_main::widget_clicked(principia_wdg *w, uint8_t button_id, int pid)
P.add_action(ACTION_GOTO_CREATE, 1);
break;

case BTN_BROWSE_COMMUNITY: {
COMMUNITY_URL("");
ui::open_url(url);
} break;
case BTN_BROWSE_COMMUNITY:
ui::open_dialog(DIALOG_HC_LEVEL_BROWSER);
break;

case BTN_UPDATE: {
COMMUNITY_URL("download");
Expand Down
5 changes: 5 additions & 0 deletions src/src/ui.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
#define DIALOG_DECORATION 161
#define DIALOG_SFXEMITTER_2 162

// Open native level browser dialog
// ..or open community host if it's not
// supported by the current backend
#define DIALOG_HC_LEVEL_BROWSER 163

#define CLOSE_ALL_DIALOGS 200
#define CLOSE_ABSOLUTELY_ALL_DIALOGS 201
#define CLOSE_REGISTER_DIALOG 202
Expand Down
15 changes: 15 additions & 0 deletions src/src/ui_gtk3.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include "main.hh"
#ifdef TMS_BACKEND_PC

// fuckgtk3
Expand All @@ -8,6 +9,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

#include "ui_gtk3_levelbrowser.hh"

#ifdef USE_GTK_SOURCE_VIEW
#include <gtksourceview/gtksource.h>
#endif
Expand Down Expand Up @@ -6277,6 +6280,10 @@ int _gtk_loop(void *p)
//Load CSS themes
load_gtk_css();

#ifdef GTK3_LEVEL_BROWSER_ENABLE
init_community_level_browser();
#endif

g_object_set(
gtk_settings_get_default(),
"gtk-application-prefer-dark-theme", true,
Expand Down Expand Up @@ -11603,6 +11610,14 @@ ui::open_dialog(int num, void *data/*=0*/)
break;
case DIALOG_PROMPT_SETTINGS: gdk_threads_add_idle(_open_prompt_settings_dialog, 0); break;

case DIALOG_HC_LEVEL_BROWSER:
#ifdef GTK3_LEVEL_BROWSER_ENABLE
gdk_threads_add_idle(open_community_level_browser, 0);
#else
ui::open_url(P.community_host);
#endif
break;

default:
tms_warnf("Unhandled dialog ID: %d", num);
break;
Expand Down
Loading
Loading