diff --git a/data/skins/default_skin_font.pcx b/data/skins/default_skin/font.pcx similarity index 100% rename from data/skins/default_skin_font.pcx rename to data/skins/default_skin/font.pcx diff --git a/data/skins/default_skin_palette.png b/data/skins/default_skin/palette.png similarity index 100% rename from data/skins/default_skin_palette.png rename to data/skins/default_skin/palette.png diff --git a/data/skins/default_skin_sheet.png b/data/skins/default_skin/sheet.png similarity index 100% rename from data/skins/default_skin_sheet.png rename to data/skins/default_skin/sheet.png diff --git a/data/skins/default_skin.xml b/data/skins/default_skin/skin.xml similarity index 100% rename from data/skins/default_skin.xml rename to data/skins/default_skin/skin.xml diff --git a/src/modules/gui.cpp b/src/modules/gui.cpp index 11e3a3f13..7413cf379 100644 --- a/src/modules/gui.cpp +++ b/src/modules/gui.cpp @@ -596,6 +596,7 @@ void gui_setup_screen(bool reload_font) static void reload_default_font() { JTheme theme = ji_get_theme(); + SkinneableTheme* skinneable_theme = static_cast(theme); const char *user_font; DIRS *dirs, *dir; @@ -613,7 +614,7 @@ static void reload_default_font() dirs_add_path(dirs, user_font); // TODO This should be in SkinneableTheme class - dirs_cat_dirs(dirs, filename_in_datadir("skins/default_skin_font.pcx")); + dirs_cat_dirs(dirs, filename_in_datadir(skinneable_theme->get_font_filename().c_str())); // Try to load the font for (dir=dirs; dir; dir=dir->next) { diff --git a/src/modules/skinneable_theme.cpp b/src/modules/skinneable_theme.cpp index ea3b9af8d..553964f91 100644 --- a/src/modules/skinneable_theme.cpp +++ b/src/modules/skinneable_theme.cpp @@ -72,6 +72,7 @@ static struct SkinneableTheme::SkinneableTheme() { this->name = "Skinneable Theme"; + m_selected_skin = get_config_string("Skin", "Selected", "default_skin"); // Initialize all graphics in NULL (these bitmaps are loaded from the skin) m_sheet_bmp = NULL; @@ -133,8 +134,9 @@ SkinneableTheme::SkinneableTheme() sheet_mapping["colorbar_border_bg"] = PART_COLORBAR_BORDER_BG_NW; // Load the skin sheet + std::string sheet_filename = ("skins/" + m_selected_skin + "/sheet.png"); { - DIRS* dirs = filename_in_datadir("skins/default_skin_sheet.png"); + DIRS* dirs = filename_in_datadir(sheet_filename.c_str()); for (DIRS* dir=dirs; dir; dir=dir->next) { if ((dir->path) && exists(dir->path)) { int old_color_conv = _color_conv; @@ -150,7 +152,7 @@ SkinneableTheme::SkinneableTheme() dirs_free(dirs); } if (!m_sheet_bmp) - throw ase_exception("Error loading data/skins/default_skin_sheet.png file"); + throw ase_exception("Error loading %s file", sheet_filename.c_str()); } SkinneableTheme::~SkinneableTheme() @@ -170,6 +172,11 @@ SkinneableTheme::~SkinneableTheme() destroy_bitmap(m_sheet_bmp); } +std::string SkinneableTheme::get_font_filename() const +{ + return "skins/" + m_selected_skin + "/font.pcx"; +} + void SkinneableTheme::regen() { check_icon_size = 8 * jguiscale(); @@ -181,7 +188,8 @@ void SkinneableTheme::regen() textbox_bg_color = COLOR_BACKGROUND; // Load the skin XML - DIRS* dirs = filename_in_datadir("skins/default_skin.xml"); + std::string xml_filename = "skins/" + m_selected_skin + "/skin.xml"; + DIRS* dirs = filename_in_datadir(xml_filename.c_str()); for (DIRS* dir=dirs; dir; dir=dir->next) { if (!dir->path || !exists(dir->path)) continue; @@ -220,8 +228,8 @@ void SkinneableTheme::regen() } if (c == JI_CURSORS) { - throw ase_exception("Unknown cursor specified in data/skins/default_skin.xml:\n" - "\n", id.c_str()); + throw ase_exception("Unknown cursor specified in '%s':\n" + "\n", xml_filename.c_str(), id.c_str()); } xmlCursor = xmlCursor->NextSiblingElement(); diff --git a/src/modules/skinneable_theme.h b/src/modules/skinneable_theme.h index a7e2d65fe..c73026c49 100644 --- a/src/modules/skinneable_theme.h +++ b/src/modules/skinneable_theme.h @@ -410,6 +410,7 @@ enum { class SkinneableTheme : public jtheme { + std::string m_selected_skin; BITMAP* m_sheet_bmp; BITMAP* m_cursors[JI_CURSORS]; BITMAP* m_part[PARTS]; @@ -419,6 +420,8 @@ public: SkinneableTheme(); ~SkinneableTheme(); + std::string get_font_filename() const; + void regen(); BITMAP* set_cursor(int type, int* focus_x, int* focus_y); void init_widget(JWidget widget);