Commit 996e04ec authored by twanvl's avatar twanvl

exception/error handling

parent 8909655c
......@@ -269,8 +269,8 @@ void CardListBase::rebuild() {
FOR_EACH(f, new_column_fields) {
ColumnSettings& cs = settings.columnSettingsFor(*set->game, *f.second);
int align;
if (f.second->card_list_align == ALIGN_RIGHT) align = wxLIST_FORMAT_RIGHT;
else if (f.second->card_list_align == ALIGN_CENTER) align = wxLIST_FORMAT_CENTRE;
if (f.second->card_list_align & ALIGN_RIGHT) align = wxLIST_FORMAT_RIGHT;
else if (f.second->card_list_align & ALIGN_CENTER) align = wxLIST_FORMAT_CENTRE;
else align = wxLIST_FORMAT_LEFT;
InsertColumn((long)column_fields.size(), capitalize(f.second->card_list_name), align, cs.width);
column_fields.push_back(f.second);
......
......@@ -57,6 +57,7 @@ class CardThumbnailRequest : public ThumbnailRequest {
, filename(filename)
{}
virtual Image generate() {
try {
ImageCardList* parent = (ImageCardList*)owner;
Image image;
if (image.LoadFile(*parent->set->openIn(filename))) {
......@@ -68,6 +69,9 @@ class CardThumbnailRequest : public ThumbnailRequest {
} else {
return Image();
}
} catch (...) {
return Image();
}
}
virtual void store(const Image& img) {
// add finished bitmap to the imagelist
......
......@@ -153,11 +153,13 @@ bool ThumbnailThread::done(void* owner) {
// store image
r.first->store(r.second);
// store in cache
if (r.second.Ok()) {
String filename = image_cache_dir() + safeFilename(r.first->cache_name) + _(".png");
r.second.SaveFile(filename, wxBITMAP_TYPE_PNG);
// set modification time
wxFileName fn(filename);
fn.SetTimes(0, &r.first->modified, 0);
}
// remove from name list
request_names.erase(r.first);
}
......
......@@ -142,6 +142,14 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
TYPE_CASE_(action, ScriptValueEvent) {
return; // Don't go into an infinite loop because of our own events
}
TYPE_CASE(action, AddCardAction) {
// update the added card specificly
Context& ctx = getContext(action.card);
FOR_EACH(v, action.card->data) {
v->update(ctx);
}
// note: fallthrough
}
TYPE_CASE_(action, CardListAction) {
updateAllDependend(set.game->dependent_scripts_cards);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment