Bundle assets into the appimage build
This commit is contained in:
parent
7bbcf2e5f3
commit
1217903703
2 changed files with 48 additions and 1 deletions
|
|
@ -33,6 +33,14 @@ mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
|
||||||
cp passport-c-media-player AppDir/usr/bin/
|
cp passport-c-media-player AppDir/usr/bin/
|
||||||
chmod +x AppDir/usr/bin/passport-c-media-player
|
chmod +x AppDir/usr/bin/passport-c-media-player
|
||||||
|
|
||||||
|
# Copy bundled resources (font and logo for AppImage)
|
||||||
|
if [ -f "BigBlueTermPlusNerdFontMono-Regular.ttf" ]; then
|
||||||
|
cp BigBlueTermPlusNerdFontMono-Regular.ttf AppDir/usr/bin/
|
||||||
|
fi
|
||||||
|
if [ -f "logo.png" ]; then
|
||||||
|
cp logo.png AppDir/usr/bin/
|
||||||
|
fi
|
||||||
|
|
||||||
# Create desktop file directly in script (avoids copy conflicts)
|
# Create desktop file directly in script (avoids copy conflicts)
|
||||||
cat > AppDir/passport-c-media-player.desktop << 'EOF'
|
cat > AppDir/passport-c-media-player.desktop << 'EOF'
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
|
|
|
||||||
39
src/ui.c
39
src/ui.c
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
|
#include <SDL2/SDL_filesystem.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
@ -1198,6 +1199,8 @@ void ui_render_theme_picker(SDL_Renderer *renderer,
|
||||||
active_theme->panel_text);
|
active_theme->panel_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *get_exe_dir(void);
|
||||||
|
|
||||||
int ui_cache_init(UiCache *cache, SDL_Renderer *renderer, const UiFonts *fonts, const ChannelList *channels) {
|
int ui_cache_init(UiCache *cache, SDL_Renderer *renderer, const UiFonts *fonts, const ChannelList *channels) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
|
|
@ -1227,7 +1230,19 @@ int ui_cache_init(UiCache *cache, SDL_Renderer *renderer, const UiFonts *fonts,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *exe_dir = get_exe_dir();
|
||||||
|
if (exe_dir) {
|
||||||
|
char logo_path[512];
|
||||||
|
snprintf(logo_path, sizeof(logo_path), "%slogo.png", exe_dir);
|
||||||
|
cache->logo_texture = load_png_texture(renderer, logo_path, NULL, NULL);
|
||||||
|
SDL_free(exe_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cache->logo_texture) {
|
||||||
cache->logo_texture = load_png_texture(renderer, "logo.png", NULL, NULL);
|
cache->logo_texture = load_png_texture(renderer, "logo.png", NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (channels && channels->count > 0) {
|
if (channels && channels->count > 0) {
|
||||||
cache->channels = calloc((size_t) channels->count, sizeof(UiChannelCache));
|
cache->channels = calloc((size_t) channels->count, sizeof(UiChannelCache));
|
||||||
|
|
@ -1302,12 +1317,36 @@ void ui_cache_destroy(UiCache *cache) {
|
||||||
memset(cache, 0, sizeof(*cache));
|
memset(cache, 0, sizeof(*cache));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *get_exe_dir(void) {
|
||||||
|
return SDL_GetBasePath();
|
||||||
|
}
|
||||||
|
|
||||||
int ui_load_fonts(UiFonts *fonts) {
|
int ui_load_fonts(UiFonts *fonts) {
|
||||||
|
char *exe_dir;
|
||||||
|
|
||||||
if (!fonts) {
|
if (!fonts) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(fonts, 0, sizeof(*fonts));
|
memset(fonts, 0, sizeof(*fonts));
|
||||||
|
|
||||||
|
exe_dir = get_exe_dir();
|
||||||
|
if (exe_dir) {
|
||||||
|
char font_path[512];
|
||||||
|
snprintf(font_path, sizeof(font_path), "%sBigBlueTermPlusNerdFontMono-Regular.ttf", exe_dir);
|
||||||
|
|
||||||
|
fonts->small = TTF_OpenFont(font_path, 13);
|
||||||
|
fonts->medium = TTF_OpenFont(font_path, 17);
|
||||||
|
fonts->large = TTF_OpenFont(font_path, 22);
|
||||||
|
|
||||||
|
SDL_free(exe_dir);
|
||||||
|
|
||||||
|
if (fonts->small && fonts->medium && fonts->large) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ui_destroy_fonts(fonts);
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(FONT_CANDIDATES) / sizeof(FONT_CANDIDATES[0]); ++i) {
|
for (size_t i = 0; i < sizeof(FONT_CANDIDATES) / sizeof(FONT_CANDIDATES[0]); ++i) {
|
||||||
fonts->small = TTF_OpenFont(FONT_CANDIDATES[i], 13);
|
fonts->small = TTF_OpenFont(FONT_CANDIDATES[i], 13);
|
||||||
fonts->medium = TTF_OpenFont(FONT_CANDIDATES[i], 17);
|
fonts->medium = TTF_OpenFont(FONT_CANDIDATES[i], 17);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue