Added SkinneableTheme::m_selected_skin member and "[Skin]/Selected" configuration variable to change the selected skin.

This commit is contained in:
David Capello 2010-04-06 22:30:18 -03:00
parent c5442abcba
commit 50f4cd8a9d
7 changed files with 18 additions and 6 deletions

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -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<SkinneableTheme*>(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) {

View File

@ -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"
"<cursor id='%s' ... />\n", id.c_str());
throw ase_exception("Unknown cursor specified in '%s':\n"
"<cursor id='%s' ... />\n", xml_filename.c_str(), id.c_str());
}
xmlCursor = xmlCursor->NextSiblingElement();

View File

@ -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);