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:
parent
1ac67d54c4
commit
2f22c2f528
10 changed files with 35 additions and 9 deletions
BIN
data/tiles/save-aspect/Paradise_Wide.jpg
Normal file
BIN
data/tiles/save-aspect/Paradise_Wide.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 470 KiB |
|
@ -1433,7 +1433,9 @@ Please select a %s type %s.
|
||||||
manager = self.tabletile_manager
|
manager = self.tabletile_manager
|
||||||
# find all available tiles
|
# find all available tiles
|
||||||
dirs = manager.getSearchDirs(self,
|
dirs = manager.getSearchDirs(self,
|
||||||
("tiles-*", os.path.join("tiles", "stretch")),
|
("tiles-*",
|
||||||
|
os.path.join("tiles", "stretch"),
|
||||||
|
os.path.join("tiles", "save-aspect")),
|
||||||
"PYSOL_TILES")
|
"PYSOL_TILES")
|
||||||
##print dirs
|
##print dirs
|
||||||
s = "((\\" + ")|(\\".join(IMAGE_EXTENSIONS) + "))$"
|
s = "((\\" + ")|(\\".join(IMAGE_EXTENSIONS) + "))$"
|
||||||
|
@ -1455,6 +1457,9 @@ Please select a %s type %s.
|
||||||
n = ext_re.sub("", name)
|
n = ext_re.sub("", name)
|
||||||
if os.path.split(dir)[-1] == 'stretch':
|
if os.path.split(dir)[-1] == 'stretch':
|
||||||
tile.stretch = 1
|
tile.stretch = 1
|
||||||
|
if os.path.split(dir)[-1] == 'save-aspect':
|
||||||
|
tile.stretch = 1
|
||||||
|
tile.save_aspect = 1
|
||||||
#n = re.sub("[-_]", " ", n)
|
#n = re.sub("[-_]", " ", n)
|
||||||
n = n.replace('_', ' ')
|
n = n.replace('_', ' ')
|
||||||
tile.name = n
|
tile.name = n
|
||||||
|
|
|
@ -289,7 +289,7 @@ class SimpleSimonII(SimpleSimon):
|
||||||
|
|
||||||
class Rachel(RelaxedSpider):
|
class Rachel(RelaxedSpider):
|
||||||
Talon_Class = StackWrapper(WasteTalonStack, max_rounds=1)
|
Talon_Class = StackWrapper(WasteTalonStack, max_rounds=1)
|
||||||
RowStack_Class = RK_RowStack
|
RowStack_Class = BlackWidow_RowStack
|
||||||
|
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
RelaxedSpider.createGame(self, waste=1, rows=6, texts=1)
|
RelaxedSpider.createGame(self, waste=1, rows=6, texts=1)
|
||||||
|
|
|
@ -802,7 +802,7 @@ class RoyalAids(Game):
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
|
|
||||||
l, s = Layout(self), self.s
|
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
|
x0 = l.XM+1.5*l.XS
|
||||||
for k in (0,1):
|
for k in (0,1):
|
||||||
|
@ -832,6 +832,7 @@ class RoyalAids(Game):
|
||||||
stack = BasicRowStack(x, y, self)
|
stack = BasicRowStack(x, y, self)
|
||||||
s.reserves.append(stack)
|
s.reserves.append(stack)
|
||||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
|
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
|
||||||
|
l.createText(stack, 's')
|
||||||
x += l.XS
|
x += l.XS
|
||||||
|
|
||||||
l.defaultStackGroups()
|
l.defaultStackGroups()
|
||||||
|
|
|
@ -162,6 +162,7 @@ def pysol_init(app, args):
|
||||||
##os.path.join(app.dn.config, "screenshots"),
|
##os.path.join(app.dn.config, "screenshots"),
|
||||||
os.path.join(app.dn.config, "tiles"),
|
os.path.join(app.dn.config, "tiles"),
|
||||||
os.path.join(app.dn.config, "tiles", "stretch"),
|
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, "cardsets"),
|
||||||
os.path.join(app.dn.config, "plugins"),
|
os.path.join(app.dn.config, "plugins"),
|
||||||
):
|
):
|
||||||
|
|
|
@ -499,6 +499,7 @@ class Tile(Resource):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
kw['color'] = None
|
kw['color'] = None
|
||||||
kw['stretch'] = 0
|
kw['stretch'] = 0
|
||||||
|
kw['save_aspect'] = 0
|
||||||
Resource.__init__(self, **kw)
|
Resource.__init__(self, **kw)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
# friend MfxCanvasText
|
# friend MfxCanvasText
|
||||||
self._text_color = "#000000"
|
self._text_color = "#000000"
|
||||||
self._stretch_bg_image = 0
|
self._stretch_bg_image = 0
|
||||||
|
self._save_aspect_bg_image = 0
|
||||||
self._text_items = []
|
self._text_items = []
|
||||||
#
|
#
|
||||||
self.xmargin, self.ymargin = 10, 10
|
self.xmargin, self.ymargin = 10, 10
|
||||||
|
@ -139,10 +140,17 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
if not self._bg_img: # solid color
|
if not self._bg_img: # solid color
|
||||||
return
|
return
|
||||||
stretch = self._stretch_bg_image
|
stretch = self._stretch_bg_image
|
||||||
|
save_aspect = self._save_aspect_bg_image
|
||||||
if Image:
|
if Image:
|
||||||
if stretch:
|
if stretch:
|
||||||
w, h = self._geometry()
|
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)
|
image = ImageTk.PhotoImage(im)
|
||||||
else:
|
else:
|
||||||
image = ImageTk.PhotoImage(self._bg_img)
|
image = ImageTk.PhotoImage(self._bg_img)
|
||||||
|
@ -289,7 +297,7 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
for item in self._text_items:
|
for item in self._text_items:
|
||||||
item.config(fill=self._text_color)
|
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
|
##print 'setTile:', image, stretch
|
||||||
if image:
|
if image:
|
||||||
if Image:
|
if Image:
|
||||||
|
@ -303,6 +311,7 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
except:
|
except:
|
||||||
return 0
|
return 0
|
||||||
self._stretch_bg_image = stretch
|
self._stretch_bg_image = stretch
|
||||||
|
self._save_aspect_bg_image = save_aspect
|
||||||
self.setBackgroundImage()
|
self.setBackgroundImage()
|
||||||
else:
|
else:
|
||||||
for id in self.__tiles:
|
for id in self.__tiles:
|
||||||
|
|
|
@ -519,7 +519,7 @@ class MfxScrolledCanvas:
|
||||||
tile.color == app.opt.colors['table']):
|
tile.color == app.opt.colors['table']):
|
||||||
return False
|
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
|
tile.error = True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
# friend MfxCanvasText
|
# friend MfxCanvasText
|
||||||
self._text_color = "#000000"
|
self._text_color = "#000000"
|
||||||
self._stretch_bg_image = 0
|
self._stretch_bg_image = 0
|
||||||
|
self._save_aspect_bg_image = 0
|
||||||
self._text_items = []
|
self._text_items = []
|
||||||
#
|
#
|
||||||
self.xmargin, self.ymargin = 10, 10
|
self.xmargin, self.ymargin = 10, 10
|
||||||
|
@ -138,10 +139,17 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
if not self._bg_img: # solid color
|
if not self._bg_img: # solid color
|
||||||
return
|
return
|
||||||
stretch = self._stretch_bg_image
|
stretch = self._stretch_bg_image
|
||||||
|
save_aspect = self._save_aspect_bg_image
|
||||||
if Image:
|
if Image:
|
||||||
if stretch:
|
if stretch:
|
||||||
w, h = self._geometry()
|
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)
|
image = ImageTk.PhotoImage(im)
|
||||||
else:
|
else:
|
||||||
image = ImageTk.PhotoImage(self._bg_img)
|
image = ImageTk.PhotoImage(self._bg_img)
|
||||||
|
@ -288,7 +296,7 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
for item in self._text_items:
|
for item in self._text_items:
|
||||||
item.config(fill=self._text_color)
|
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
|
##print 'setTile:', image, stretch
|
||||||
if image:
|
if image:
|
||||||
if Image:
|
if Image:
|
||||||
|
@ -302,6 +310,7 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
except:
|
except:
|
||||||
return 0
|
return 0
|
||||||
self._stretch_bg_image = stretch
|
self._stretch_bg_image = stretch
|
||||||
|
self._save_aspect_bg_image = save_aspect
|
||||||
self.setBackgroundImage()
|
self.setBackgroundImage()
|
||||||
else:
|
else:
|
||||||
for id in self.__tiles:
|
for id in self.__tiles:
|
||||||
|
|
|
@ -509,7 +509,7 @@ class MfxScrolledCanvas:
|
||||||
tile.color == app.opt.colors['table']):
|
tile.color == app.opt.colors['table']):
|
||||||
return False
|
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
|
tile.error = True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue