mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Simplified center offset logic to remove extraneous variables.
This commit is contained in:
parent
ff458a7058
commit
bc1ec96857
1 changed files with 6 additions and 7 deletions
|
@ -988,6 +988,7 @@ class Game(object):
|
||||||
self.newGame(restart=1, random=self.random)
|
self.newGame(restart=1, random=self.random)
|
||||||
|
|
||||||
def resizeImages(self, manually=False):
|
def resizeImages(self, manually=False):
|
||||||
|
self.center_offset = (0, 0)
|
||||||
if self.canvas.winfo_ismapped():
|
if self.canvas.winfo_ismapped():
|
||||||
# apparent size of canvas
|
# apparent size of canvas
|
||||||
vw = self.canvas.winfo_width()
|
vw = self.canvas.winfo_width()
|
||||||
|
@ -999,7 +1000,7 @@ class Game(object):
|
||||||
vw, vh = self.app.opt.game_geometry
|
vw, vh = self.app.opt.game_geometry
|
||||||
if not vw:
|
if not vw:
|
||||||
# first run of the game
|
# first run of the game
|
||||||
return 1, 1, 1, 1, 0, 0
|
return 1, 1, 1, 1
|
||||||
# requested size of canvas (createGame -> setSize)
|
# requested size of canvas (createGame -> setSize)
|
||||||
iw, ih = self.init_size
|
iw, ih = self.init_size
|
||||||
|
|
||||||
|
@ -1014,16 +1015,14 @@ class Game(object):
|
||||||
xf = yf = min(xf, yf)
|
xf = yf = min(xf, yf)
|
||||||
else:
|
else:
|
||||||
xf, yf = self.app.opt.scale_x, self.app.opt.scale_y
|
xf, yf = self.app.opt.scale_x, self.app.opt.scale_y
|
||||||
cw, ch = self.getCenterOffset(vw, vh, iw, ih, xf, yf)
|
self.center_offset = self.getCenterOffset(vw, vh, iw, ih, xf, yf)
|
||||||
self.center_offset = (cw, ch)
|
|
||||||
if (not self.app.opt.spread_stacks or manually):
|
if (not self.app.opt.spread_stacks or manually):
|
||||||
# images
|
# images
|
||||||
self.app.images.resize(xf, yf)
|
self.app.images.resize(xf, yf)
|
||||||
# cards
|
# cards
|
||||||
for card in self.cards:
|
for card in self.cards:
|
||||||
card.update(card.id, card.deck, card.suit, card.rank, self)
|
card.update(card.id, card.deck, card.suit, card.rank, self)
|
||||||
return xf, yf, self.app.images._xfactor, self.app.images._yfactor, \
|
return xf, yf, self.app.images._xfactor, self.app.images._yfactor
|
||||||
cw, ch
|
|
||||||
|
|
||||||
def getCenterOffset(self, vw, vh, iw, ih, xf, yf):
|
def getCenterOffset(self, vw, vh, iw, ih, xf, yf):
|
||||||
if (not self.app.opt.center_layout or self.app.opt.spread_stacks or
|
if (not self.app.opt.center_layout or self.app.opt.spread_stacks or
|
||||||
|
@ -1045,9 +1044,9 @@ class Game(object):
|
||||||
if not USE_PIL:
|
if not USE_PIL:
|
||||||
return
|
return
|
||||||
self.deleteStackDesc()
|
self.deleteStackDesc()
|
||||||
xf, yf, xf0, yf0, cw, ch = \
|
xf, yf, xf0, yf0 = \
|
||||||
self.resizeImages(manually=card_size_manually)
|
self.resizeImages(manually=card_size_manually)
|
||||||
self.center_offset = (cw, ch)
|
cw, ch = self.center_offset[0], self.center_offset[1]
|
||||||
for stack in self.allstacks:
|
for stack in self.allstacks:
|
||||||
|
|
||||||
if (self.app.opt.spread_stacks):
|
if (self.app.opt.spread_stacks):
|
||||||
|
|
Loading…
Add table
Reference in a new issue