1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

+ save aspect for background image

* minor fixes


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@250 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2009-08-13 22:23:38 +00:00
parent 1ac67d54c4
commit 2f22c2f528
10 changed files with 35 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

View file

@ -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

View file

@ -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)

View file

@ -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()

View file

@ -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"),
):

View file

@ -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)

View file

@ -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:

View file

@ -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

View file

@ -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:

View file

@ -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