diff --git a/data/tiles/save-aspect/Paradise_Wide.jpg b/data/tiles/save-aspect/Paradise_Wide.jpg new file mode 100644 index 00000000..9ee0ceee Binary files /dev/null and b/data/tiles/save-aspect/Paradise_Wide.jpg differ diff --git a/pysollib/app.py b/pysollib/app.py index e724a3a0..63b4277e 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -1433,7 +1433,9 @@ Please select a %s type %s. manager = self.tabletile_manager # find all available tiles dirs = manager.getSearchDirs(self, - ("tiles-*", os.path.join("tiles", "stretch")), + ("tiles-*", + os.path.join("tiles", "stretch"), + os.path.join("tiles", "save-aspect")), "PYSOL_TILES") ##print dirs s = "((\\" + ")|(\\".join(IMAGE_EXTENSIONS) + "))$" @@ -1455,6 +1457,9 @@ Please select a %s type %s. n = ext_re.sub("", name) if os.path.split(dir)[-1] == 'stretch': tile.stretch = 1 + if os.path.split(dir)[-1] == 'save-aspect': + tile.stretch = 1 + tile.save_aspect = 1 #n = re.sub("[-_]", " ", n) n = n.replace('_', ' ') tile.name = n diff --git a/pysollib/games/spider.py b/pysollib/games/spider.py index 09c24281..77e4a4ba 100644 --- a/pysollib/games/spider.py +++ b/pysollib/games/spider.py @@ -289,7 +289,7 @@ class SimpleSimonII(SimpleSimon): class Rachel(RelaxedSpider): Talon_Class = StackWrapper(WasteTalonStack, max_rounds=1) - RowStack_Class = RK_RowStack + RowStack_Class = BlackWidow_RowStack def createGame(self): RelaxedSpider.createGame(self, waste=1, rows=6, texts=1) diff --git a/pysollib/games/sultan.py b/pysollib/games/sultan.py index 27e1850d..2f3e4c2d 100644 --- a/pysollib/games/sultan.py +++ b/pysollib/games/sultan.py @@ -802,7 +802,7 @@ class RoyalAids(Game): def createGame(self): l, s = Layout(self), self.s - self.setSize(l.XM+8*l.XS, l.YM+4*l.YS) + self.setSize(l.XM+8*l.XS, l.YM+4*l.YS+l.TEXT_HEIGHT) x0 = l.XM+1.5*l.XS for k in (0,1): @@ -832,6 +832,7 @@ class RoyalAids(Game): stack = BasicRowStack(x, y, self) s.reserves.append(stack) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0 + l.createText(stack, 's') x += l.XS l.defaultStackGroups() diff --git a/pysollib/main.py b/pysollib/main.py index a6ff9dd0..3700ee6b 100644 --- a/pysollib/main.py +++ b/pysollib/main.py @@ -162,6 +162,7 @@ def pysol_init(app, args): ##os.path.join(app.dn.config, "screenshots"), os.path.join(app.dn.config, "tiles"), os.path.join(app.dn.config, "tiles", "stretch"), + os.path.join(app.dn.config, "tiles", "save-aspect"), os.path.join(app.dn.config, "cardsets"), os.path.join(app.dn.config, "plugins"), ): diff --git a/pysollib/resource.py b/pysollib/resource.py index 26625a3c..b3f2b5ca 100644 --- a/pysollib/resource.py +++ b/pysollib/resource.py @@ -499,6 +499,7 @@ class Tile(Resource): def __init__(self, **kw): kw['color'] = None kw['stretch'] = 0 + kw['save_aspect'] = 0 Resource.__init__(self, **kw) diff --git a/pysollib/tile/tkcanvas.py b/pysollib/tile/tkcanvas.py index a8f19500..846e88b3 100644 --- a/pysollib/tile/tkcanvas.py +++ b/pysollib/tile/tkcanvas.py @@ -126,6 +126,7 @@ class MfxCanvas(Tkinter.Canvas): # friend MfxCanvasText self._text_color = "#000000" self._stretch_bg_image = 0 + self._save_aspect_bg_image = 0 self._text_items = [] # self.xmargin, self.ymargin = 10, 10 @@ -139,10 +140,17 @@ class MfxCanvas(Tkinter.Canvas): if not self._bg_img: # solid color return stretch = self._stretch_bg_image + save_aspect = self._save_aspect_bg_image if Image: if stretch: w, h = self._geometry() - im = self._bg_img.resize((w, h)) + if save_aspect: + w0, h0 = self._bg_img.size + a = min(float(w0)/w, float(h0)/h) + w0, h0 = int(w0/a), int(h0/a) + im = self._bg_img.resize((w0, h0)) + else: + im = self._bg_img.resize((w, h)) image = ImageTk.PhotoImage(im) else: image = ImageTk.PhotoImage(self._bg_img) @@ -289,7 +297,7 @@ class MfxCanvas(Tkinter.Canvas): for item in self._text_items: item.config(fill=self._text_color) - def setTile(self, image, stretch=0): + def setTile(self, image, stretch=0, save_aspect=0): ##print 'setTile:', image, stretch if image: if Image: @@ -303,6 +311,7 @@ class MfxCanvas(Tkinter.Canvas): except: return 0 self._stretch_bg_image = stretch + self._save_aspect_bg_image = save_aspect self.setBackgroundImage() else: for id in self.__tiles: diff --git a/pysollib/tile/tkwidget.py b/pysollib/tile/tkwidget.py index afcc4c75..8e6e3f8d 100644 --- a/pysollib/tile/tkwidget.py +++ b/pysollib/tile/tkwidget.py @@ -519,7 +519,7 @@ class MfxScrolledCanvas: tile.color == app.opt.colors['table']): return False # - if not self.canvas.setTile(tile.filename, tile.stretch): + if not self.canvas.setTile(tile.filename, tile.stretch, tile.save_aspect): tile.error = True return False diff --git a/pysollib/tk/tkcanvas.py b/pysollib/tk/tkcanvas.py index 57f62a3f..fc195a06 100644 --- a/pysollib/tk/tkcanvas.py +++ b/pysollib/tk/tkcanvas.py @@ -125,6 +125,7 @@ class MfxCanvas(Tkinter.Canvas): # friend MfxCanvasText self._text_color = "#000000" self._stretch_bg_image = 0 + self._save_aspect_bg_image = 0 self._text_items = [] # self.xmargin, self.ymargin = 10, 10 @@ -138,10 +139,17 @@ class MfxCanvas(Tkinter.Canvas): if not self._bg_img: # solid color return stretch = self._stretch_bg_image + save_aspect = self._save_aspect_bg_image if Image: if stretch: w, h = self._geometry() - im = self._bg_img.resize((w, h)) + if save_aspect: + w0, h0 = self._bg_img.size + a = min(float(w0)/w, float(h0)/h) + w0, h0 = int(w0/a), int(h0/a) + im = self._bg_img.resize((w0, h0)) + else: + im = self._bg_img.resize((w, h)) image = ImageTk.PhotoImage(im) else: image = ImageTk.PhotoImage(self._bg_img) @@ -288,7 +296,7 @@ class MfxCanvas(Tkinter.Canvas): for item in self._text_items: item.config(fill=self._text_color) - def setTile(self, image, stretch=0): + def setTile(self, image, stretch=0, save_aspect=0): ##print 'setTile:', image, stretch if image: if Image: @@ -302,6 +310,7 @@ class MfxCanvas(Tkinter.Canvas): except: return 0 self._stretch_bg_image = stretch + self._save_aspect_bg_image = save_aspect self.setBackgroundImage() else: for id in self.__tiles: diff --git a/pysollib/tk/tkwidget.py b/pysollib/tk/tkwidget.py index 47a53090..91694560 100644 --- a/pysollib/tk/tkwidget.py +++ b/pysollib/tk/tkwidget.py @@ -509,7 +509,7 @@ class MfxScrolledCanvas: tile.color == app.opt.colors['table']): return False # - if not self.canvas.setTile(tile.filename, tile.stretch): + if not self.canvas.setTile(tile.filename, tile.stretch, tile.save_aspect): tile.error = True return False