Added SkinneableTheme::reload_skin() to reload the skin sheet.png file when you press F5.

This commit is contained in:
David Capello 2010-04-23 19:03:09 -03:00
parent e555f78996
commit 2c49990420
3 changed files with 44 additions and 19 deletions

View File

@ -25,10 +25,12 @@
#include <psapi.h>
#endif
#include "jinete/jtheme.h"
#include "jinete/jsystem.h"
#include "commands/command.h"
#include "app.h"
#include "commands/command.h"
#include "modules/skinneable_theme.h"
#include "widgets/statebar.h"
#include "sprite_wrappers.h"
@ -58,12 +60,19 @@ void RefreshCommand::execute(Context* context)
clear_to_color(screen, makecol(0, 0, 0));
jmouse_show();
// Reload skin
{
SkinneableTheme* theme = (SkinneableTheme*)ji_get_theme();
theme->reload_skin();
ji_regen_theme();
}
{
const CurrentSpriteReader sprite(context);
app_refresh_screen(sprite);
}
/* print memory information */
// Print memory information
#if defined ALLEGRO_WINDOWS && defined DEBUGMODE
{
PROCESS_MEMORY_COUNTERS pmc;

View File

@ -133,6 +133,34 @@ SkinneableTheme::SkinneableTheme()
sheet_mapping["colorbar_border_fg"] = PART_COLORBAR_BORDER_FG_NW;
sheet_mapping["colorbar_border_bg"] = PART_COLORBAR_BORDER_BG_NW;
reload_skin();
}
SkinneableTheme::~SkinneableTheme()
{
for (int c=0; c<JI_CURSORS; ++c)
if (m_cursors[c])
destroy_bitmap(m_cursors[c]);
for (int c=0; c<PARTS; ++c)
destroy_bitmap(m_part[c]);
for (std::map<std::string, BITMAP*>::iterator
it = m_toolicon.begin(); it != m_toolicon.end(); ++it) {
destroy_bitmap(it->second);
}
destroy_bitmap(m_sheet_bmp);
}
// Call ji_regen_theme after this
void SkinneableTheme::reload_skin()
{
if (m_sheet_bmp) {
destroy_bitmap(m_sheet_bmp);
m_sheet_bmp = NULL;
}
// Load the skin sheet
std::string sheet_filename = ("skins/" + m_selected_skin + "/sheet.png");
{
@ -155,23 +183,6 @@ SkinneableTheme::SkinneableTheme()
throw ase_exception("Error loading %s file", sheet_filename.c_str());
}
SkinneableTheme::~SkinneableTheme()
{
for (int c=0; c<JI_CURSORS; ++c)
if (m_cursors[c])
destroy_bitmap(m_cursors[c]);
for (int c=0; c<PARTS; ++c)
destroy_bitmap(m_part[c]);
for (std::map<std::string, BITMAP*>::iterator
it = m_toolicon.begin(); it != m_toolicon.end(); ++it) {
destroy_bitmap(it->second);
}
destroy_bitmap(m_sheet_bmp);
}
std::string SkinneableTheme::get_font_filename() const
{
return "skins/" + m_selected_skin + "/font.pcx";

View File

@ -25,6 +25,9 @@
#include "jinete/jtheme.h"
#include "jinete/jrect.h"
#include "Vaca/Property.h"
#include "Vaca/Rect.h"
using Vaca::Rect;
class SkinProperty : public Vaca::Property
{
@ -420,6 +423,8 @@ public:
SkinneableTheme();
~SkinneableTheme();
void reload_skin();
std::string get_font_filename() const;
void regen();