mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Updated compatible cardset check to run when selecting cardsets.
This commit is contained in:
parent
040d546174
commit
080b0043e3
2 changed files with 46 additions and 29 deletions
pysollib
|
@ -773,56 +773,60 @@ class Application:
|
||||||
t0 = t1 = "Unknown"
|
t0 = t1 = "Unknown"
|
||||||
return t0, t1
|
return t0, t1
|
||||||
|
|
||||||
def getCompatibleCardset(self, gi, cs):
|
def getCompatibleCardset(self, gi, cs, trychange=True):
|
||||||
if gi is None:
|
if gi is None:
|
||||||
return cs, 1
|
return cs, 1, None
|
||||||
|
t = self.checkCompatibleCardsetType(gi, cs)
|
||||||
# try current
|
# try current
|
||||||
if cs:
|
if cs:
|
||||||
t = self.checkCompatibleCardsetType(gi, cs)
|
|
||||||
if not t[1]:
|
if not t[1]:
|
||||||
return cs, 1
|
return cs, 1, t
|
||||||
# try by gameid / category
|
if trychange:
|
||||||
for key, flag in (((1, gi.id), 8), (gi.category, 4)):
|
# try by gameid / category
|
||||||
c = self.opt.cardset.get(key)
|
for key, flag in (((1, gi.id), 8), (gi.category, 4)):
|
||||||
if not c or len(c) != 2:
|
c = self.opt.cardset.get(key)
|
||||||
continue
|
if not c or len(c) != 2:
|
||||||
cs = self.cardset_manager.getByName(c[0])
|
continue
|
||||||
if not cs:
|
cs = self.cardset_manager.getByName(c[0])
|
||||||
continue
|
if not cs:
|
||||||
t = self.checkCompatibleCardsetType(gi, cs)
|
continue
|
||||||
if not t[1]:
|
t = self.checkCompatibleCardsetType(gi, cs)
|
||||||
cs.updateCardback(backname=c[1])
|
if not t[1]:
|
||||||
return cs, flag
|
cs.updateCardback(backname=c[1])
|
||||||
|
return cs, flag, t
|
||||||
# ask
|
# ask
|
||||||
return None, 0
|
return None, 0, t
|
||||||
|
|
||||||
def requestCompatibleCardsetType(self, id):
|
def requestCompatibleCardsetType(self, id):
|
||||||
gi = self.getGameInfo(id)
|
gi = self.getGameInfo(id)
|
||||||
#
|
#
|
||||||
cs, cs_update_flag = self.getCompatibleCardset(gi, self.cardset)
|
cs, cs_update_flag, t = self.getCompatibleCardset(gi, self.cardset)
|
||||||
if cs is self.cardset:
|
if cs is self.cardset:
|
||||||
return 0
|
return 0
|
||||||
if cs is not None:
|
if cs is not None:
|
||||||
self.loadCardset(cs, update=1)
|
self.loadCardset(cs, update=1)
|
||||||
return 1
|
return 1
|
||||||
#
|
|
||||||
t = self.checkCompatibleCardsetType(gi, self.cardset)
|
|
||||||
MfxMessageDialog(
|
|
||||||
self.top, title=_("Incompatible cardset"),
|
|
||||||
bitmap="warning",
|
|
||||||
text=_('''The currently selected cardset %(cardset)s
|
|
||||||
is not compatible with the game
|
|
||||||
%(game)s
|
|
||||||
|
|
||||||
Please select a %(correct_type)s type cardset.
|
self.requestCompatibleCardsetTypeDialog(self.cardset, gi, t)
|
||||||
''') % {'cardset': self.cardset.name, 'game': gi.name, 'correct_type': t[0]},
|
|
||||||
strings=(_("&OK"),), default=0)
|
|
||||||
cs = self.__selectCardsetDialog(t)
|
cs = self.__selectCardsetDialog(t)
|
||||||
if cs is None:
|
if cs is None:
|
||||||
return -1
|
return -1
|
||||||
self.loadCardset(cs, id=id)
|
self.loadCardset(cs, id=id)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
def requestCompatibleCardsetTypeDialog(self, cardset, gi, t):
|
||||||
|
MfxMessageDialog(
|
||||||
|
self.top, title=_("Incompatible cardset"),
|
||||||
|
bitmap="warning",
|
||||||
|
text=_('''The currently selected cardset %(cardset)s
|
||||||
|
is not compatible with the game
|
||||||
|
%(game)s
|
||||||
|
|
||||||
|
Please select a %(correct_type)s type cardset.
|
||||||
|
''') % {'cardset': cardset.name, 'game': gi.name,
|
||||||
|
'correct_type': t[0]}, strings=(_("&OK"),), default=0)
|
||||||
|
|
||||||
def selectCardset(self, title, key):
|
def selectCardset(self, title, key):
|
||||||
d = SelectCardsetDialogWithPreview(
|
d = SelectCardsetDialogWithPreview(
|
||||||
self.top, title=title, app=self,
|
self.top, title=title, app=self,
|
||||||
|
|
|
@ -354,6 +354,19 @@ class SelectCardsetDialogWithPreview(MfxDialog):
|
||||||
self.key = self.tree.selection_key
|
self.key = self.tree.selection_key
|
||||||
self.tree.n_expansions = 1 # save xyview in any case
|
self.tree.n_expansions = 1 # save xyview in any case
|
||||||
|
|
||||||
|
if button == 0:
|
||||||
|
cardset = self.app.cardset_manager.get(self.key)
|
||||||
|
if self.app.game is not None:
|
||||||
|
gi = self.app.getGameInfo(self.app.game.id)
|
||||||
|
else:
|
||||||
|
gi = self.app.getGameInfo(self.app.nextgame.id)
|
||||||
|
cs, cs_update_flag, t = \
|
||||||
|
self.app.getCompatibleCardset(gi, cardset, trychange=False)
|
||||||
|
|
||||||
|
if cs is None:
|
||||||
|
self.app.requestCompatibleCardsetTypeDialog(cardset, gi, t)
|
||||||
|
return
|
||||||
|
|
||||||
# save the values
|
# save the values
|
||||||
try:
|
try:
|
||||||
self.cardset_values = self.x_offset.get(), self.y_offset.get()
|
self.cardset_values = self.x_offset.get(), self.y_offset.get()
|
||||||
|
|
Loading…
Add table
Reference in a new issue