mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Playable preview now loads and uses cardsets of the correct type for each game.
This commit is contained in:
parent
ea897ab8dc
commit
e927d60a25
5 changed files with 70 additions and 32 deletions
|
@ -646,13 +646,15 @@ class Application:
|
||||||
self.opt.cardset[(1, gi.id)] = (cs.name, cs.backname)
|
self.opt.cardset[(1, gi.id)] = (cs.name, cs.backname)
|
||||||
# from pprint import pprint; pprint(self.opt.cardset)
|
# from pprint import pprint; pprint(self.opt.cardset)
|
||||||
|
|
||||||
def loadCardset(self, cs, id=0, update=7, progress=None):
|
def loadCardset(self, cs, id=0, update=7, progress=None,
|
||||||
|
tocache=False, noprogress=False):
|
||||||
# print 'loadCardset', cs.ident
|
# print 'loadCardset', cs.ident
|
||||||
r = 0
|
r = 0
|
||||||
if cs is None or cs.error:
|
if cs is None or cs.error:
|
||||||
return 0
|
return 0
|
||||||
if cs is self.cardset:
|
if cs is self.cardset:
|
||||||
self.updateCardset(id, update=update)
|
if not tocache:
|
||||||
|
self.updateCardset(id, update=update)
|
||||||
return 1
|
return 1
|
||||||
# cache carsets
|
# cache carsets
|
||||||
# self.cardsets_cache:
|
# self.cardsets_cache:
|
||||||
|
@ -662,12 +664,13 @@ class Application:
|
||||||
if c and c[0] == cs.ident:
|
if c and c[0] == cs.ident:
|
||||||
# print 'load from cache', c
|
# print 'load from cache', c
|
||||||
self.images, self.subsampled_images = c[1], c[2]
|
self.images, self.subsampled_images = c[1], c[2]
|
||||||
self.updateCardset(id, update=update)
|
if not tocache:
|
||||||
if self.menubar is not None:
|
self.updateCardset(id, update=update)
|
||||||
self.menubar.updateBackgroundImagesMenu()
|
if self.menubar is not None:
|
||||||
|
self.menubar.updateBackgroundImagesMenu()
|
||||||
return 1
|
return 1
|
||||||
#
|
#
|
||||||
if progress is None:
|
if progress is None and not noprogress:
|
||||||
self.wm_save_state()
|
self.wm_save_state()
|
||||||
self.wm_withdraw()
|
self.wm_withdraw()
|
||||||
title = _("Loading cardset %s...") % cs.name
|
title = _("Loading cardset %s...") % cs.name
|
||||||
|
@ -682,25 +685,31 @@ class Application:
|
||||||
if not images.load(app=self, progress=progress):
|
if not images.load(app=self, progress=progress):
|
||||||
raise Exception("Invalid or damaged cardset")
|
raise Exception("Invalid or damaged cardset")
|
||||||
simages = SubsampledImages(images)
|
simages = SubsampledImages(images)
|
||||||
if self.opt.save_cardsets:
|
if tocache:
|
||||||
c = self.cardsets_cache.get(cs.type)
|
simages.setNegative(self.opt.negative_bottom)
|
||||||
if c:
|
# The save cardsets option is deprecated, and its existence
|
||||||
# c[1].destruct()
|
# directly conflicts with the ability to allow previews of
|
||||||
destruct(c[1])
|
# other cardset types.
|
||||||
self.cardsets_cache[cs.type] = (cs.ident, images, simages)
|
# if self.opt.save_cardsets:
|
||||||
elif self.images is not None:
|
c = self.cardsets_cache.get(cs.type)
|
||||||
# self.images.destruct()
|
if c:
|
||||||
destruct(self.images)
|
# c[1].destruct()
|
||||||
#
|
destruct(c[1])
|
||||||
if self.cardset:
|
self.cardsets_cache[cs.type] = (cs.ident, images, simages)
|
||||||
if self.cardset.ident != cs.ident:
|
if not tocache:
|
||||||
if self.cardset.type == cs.type:
|
# elif self.images is not None:
|
||||||
# clear saved games geometry
|
# # self.images.destruct()
|
||||||
self.opt.games_geometry = {}
|
# destruct(self.images)
|
||||||
# update
|
#
|
||||||
self.images = images
|
if self.cardset:
|
||||||
self.subsampled_images = simages
|
if self.cardset.ident != cs.ident:
|
||||||
self.updateCardset(id, update=update)
|
if self.cardset.type == cs.type:
|
||||||
|
# clear saved games geometry
|
||||||
|
self.opt.games_geometry = {}
|
||||||
|
# update
|
||||||
|
self.images = images
|
||||||
|
self.subsampled_images = simages
|
||||||
|
self.updateCardset(id, update=update)
|
||||||
r = 1
|
r = 1
|
||||||
except (Exception, TclError, UnpicklingError) as ex:
|
except (Exception, TclError, UnpicklingError) as ex:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -715,7 +724,7 @@ class Application:
|
||||||
self.top, ex, title=_("Cardset load error"),
|
self.top, ex, title=_("Cardset load error"),
|
||||||
text=_("Error while loading cardset"))
|
text=_("Error while loading cardset"))
|
||||||
self.intro.progress = progress
|
self.intro.progress = progress
|
||||||
if r and self.menubar is not None:
|
if r and not tocache and self.menubar is not None:
|
||||||
self.menubar.updateBackgroundImagesMenu()
|
self.menubar.updateBackgroundImagesMenu()
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,6 @@ mouse_type = string
|
||||||
mouse_undo = boolean
|
mouse_undo = boolean
|
||||||
negative_bottom = boolean
|
negative_bottom = boolean
|
||||||
randomize_place = boolean
|
randomize_place = boolean
|
||||||
save_cardsets = boolean
|
|
||||||
dragcursor = boolean
|
dragcursor = boolean
|
||||||
save_games_geometry = boolean
|
save_games_geometry = boolean
|
||||||
game_geometry = int_list(min=2, max=2)
|
game_geometry = int_list(min=2, max=2)
|
||||||
|
@ -258,7 +257,7 @@ class Options:
|
||||||
('mouse_undo', 'bool'),
|
('mouse_undo', 'bool'),
|
||||||
('negative_bottom', 'bool'),
|
('negative_bottom', 'bool'),
|
||||||
('randomize_place', 'bool'),
|
('randomize_place', 'bool'),
|
||||||
('save_cardsets', 'bool'),
|
# ('save_cardsets', 'bool'),
|
||||||
('dragcursor', 'bool'),
|
('dragcursor', 'bool'),
|
||||||
('save_games_geometry', 'bool'),
|
('save_games_geometry', 'bool'),
|
||||||
('sound', 'bool'),
|
('sound', 'bool'),
|
||||||
|
@ -437,7 +436,7 @@ class Options:
|
||||||
self.offsets = {} # cards offsets
|
self.offsets = {} # cards offsets
|
||||||
#
|
#
|
||||||
self.randomize_place = False
|
self.randomize_place = False
|
||||||
self.save_cardsets = True
|
# self.save_cardsets = True
|
||||||
self.dragcursor = True
|
self.dragcursor = True
|
||||||
#
|
#
|
||||||
self.scale_cards = False
|
self.scale_cards = False
|
||||||
|
|
|
@ -396,7 +396,7 @@ class SelectGameDialogWithPreview(MfxDialog):
|
||||||
gamerandom=self.app.gamerandom,
|
gamerandom=self.app.gamerandom,
|
||||||
gdb=self.app.gdb,
|
gdb=self.app.gdb,
|
||||||
gimages=self.app.gimages,
|
gimages=self.app.gimages,
|
||||||
images=self.app.subsampled_images,
|
images=None,
|
||||||
menubar=None,
|
menubar=None,
|
||||||
miscrandom=self.app.miscrandom,
|
miscrandom=self.app.miscrandom,
|
||||||
opt=self.app.opt.copy(),
|
opt=self.app.opt.copy(),
|
||||||
|
@ -412,6 +412,16 @@ class SelectGameDialogWithPreview(MfxDialog):
|
||||||
self.preview_app.opt.shadow = 0
|
self.preview_app.opt.shadow = 0
|
||||||
self.preview_app.opt.shade = 0
|
self.preview_app.opt.shade = 0
|
||||||
#
|
#
|
||||||
|
|
||||||
|
c = self.app.cardsets_cache.get(gi.category)
|
||||||
|
if not c:
|
||||||
|
cardset = self.app.cardset_manager.getByName(
|
||||||
|
self.app.opt.cardset[gi.category][0])
|
||||||
|
self.app.loadCardset(cardset, id=gi.category,
|
||||||
|
tocache=True, noprogress=True)
|
||||||
|
c = self.app.cardsets_cache.get(gi.category)
|
||||||
|
self.preview_app.images = c[2]
|
||||||
|
|
||||||
self.preview_app.audio = None # turn off audio for initial dealing
|
self.preview_app.audio = None # turn off audio for initial dealing
|
||||||
if animations >= 0:
|
if animations >= 0:
|
||||||
self.preview_app.opt.animations = animations
|
self.preview_app.opt.animations = animations
|
||||||
|
|
|
@ -485,7 +485,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
|
||||||
gamerandom=self.app.gamerandom,
|
gamerandom=self.app.gamerandom,
|
||||||
gdb=self.app.gdb,
|
gdb=self.app.gdb,
|
||||||
gimages=self.app.gimages,
|
gimages=self.app.gimages,
|
||||||
images=self.app.subsampled_images,
|
images=None,
|
||||||
menubar=None,
|
menubar=None,
|
||||||
miscrandom=self.app.miscrandom,
|
miscrandom=self.app.miscrandom,
|
||||||
opt=self.app.opt.copy(),
|
opt=self.app.opt.copy(),
|
||||||
|
@ -501,6 +501,16 @@ class SelectGameDialogWithPreview(SelectGameDialog):
|
||||||
self.preview_app.opt.shadow = 0
|
self.preview_app.opt.shadow = 0
|
||||||
self.preview_app.opt.shade = 0
|
self.preview_app.opt.shade = 0
|
||||||
#
|
#
|
||||||
|
|
||||||
|
c = self.app.cardsets_cache.get(gi.category)
|
||||||
|
if not c:
|
||||||
|
cardset = self.app.cardset_manager.getByName(
|
||||||
|
self.app.opt.cardset[gi.category][0])
|
||||||
|
self.app.loadCardset(cardset, id=gi.category,
|
||||||
|
tocache=True, noprogress=True)
|
||||||
|
c = self.app.cardsets_cache.get(gi.category)
|
||||||
|
self.preview_app.images = c[2]
|
||||||
|
|
||||||
self.preview_app.audio = None # turn off audio for initial dealing
|
self.preview_app.audio = None # turn off audio for initial dealing
|
||||||
if animations >= 0:
|
if animations >= 0:
|
||||||
self.preview_app.opt.animations = animations
|
self.preview_app.opt.animations = animations
|
||||||
|
|
|
@ -487,7 +487,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
|
||||||
gamerandom=self.app.gamerandom,
|
gamerandom=self.app.gamerandom,
|
||||||
gdb=self.app.gdb,
|
gdb=self.app.gdb,
|
||||||
gimages=self.app.gimages,
|
gimages=self.app.gimages,
|
||||||
images=self.app.subsampled_images,
|
images=None,
|
||||||
menubar=None,
|
menubar=None,
|
||||||
miscrandom=self.app.miscrandom,
|
miscrandom=self.app.miscrandom,
|
||||||
opt=self.app.opt.copy(),
|
opt=self.app.opt.copy(),
|
||||||
|
@ -503,6 +503,16 @@ class SelectGameDialogWithPreview(SelectGameDialog):
|
||||||
self.preview_app.opt.shadow = 0
|
self.preview_app.opt.shadow = 0
|
||||||
self.preview_app.opt.shade = 0
|
self.preview_app.opt.shade = 0
|
||||||
#
|
#
|
||||||
|
|
||||||
|
c = self.app.cardsets_cache.get(gi.category)
|
||||||
|
if not c:
|
||||||
|
cardset = self.app.cardset_manager.getByName(
|
||||||
|
self.app.opt.cardset[gi.category][0])
|
||||||
|
self.app.loadCardset(cardset, id=gi.category,
|
||||||
|
tocache=True, noprogress=True)
|
||||||
|
c = self.app.cardsets_cache.get(gi.category)
|
||||||
|
self.preview_app.images = c[2]
|
||||||
|
|
||||||
self.preview_app.audio = None # turn off audio for initial dealing
|
self.preview_app.audio = None # turn off audio for initial dealing
|
||||||
if animations >= 0:
|
if animations >= 0:
|
||||||
self.preview_app.opt.animations = animations
|
self.preview_app.opt.animations = animations
|
||||||
|
|
Loading…
Add table
Reference in a new issue