mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Division sanitize.
This commit is contained in:
parent
e1fa5b2adc
commit
e90b48104d
11 changed files with 37 additions and 37 deletions
|
@ -56,7 +56,7 @@ class BuffaloBill(Game):
|
||||||
self.setSize(w, h)
|
self.setSize(w, h)
|
||||||
|
|
||||||
# create stacks
|
# create stacks
|
||||||
x, y = l.XM+(w-l.XM-8*l.XS)/2, l.YM
|
x, y = l.XM+(w-l.XM-8*l.XS)//2, l.YM
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
|
@ -76,7 +76,7 @@ class BuffaloBill(Game):
|
||||||
n += 1
|
n += 1
|
||||||
y += l.YS
|
y += l.YS
|
||||||
|
|
||||||
x, y = l.XM+(w-l.XM-8*l.XS)/2, h-l.YS
|
x, y = l.XM+(w-l.XM-8*l.XS)//2, h-l.YS
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
s.reserves.append(ReserveStack(x, y, self))
|
s.reserves.append(ReserveStack(x, y, self))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
|
|
|
@ -258,16 +258,16 @@ class TripleFreecell(FreeCell):
|
||||||
# create stacks
|
# create stacks
|
||||||
s.talon = self.Talon_Class(l.XM, h-l.YS, self)
|
s.talon = self.Talon_Class(l.XM, h-l.YS, self)
|
||||||
|
|
||||||
x, y = l.XM+(max_rows-decks*4)*l.XS/2, l.YM
|
x, y = l.XM+(max_rows-decks*4)*l.XS//2, l.YM
|
||||||
for j in range(4):
|
for j in range(4):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
s.foundations.append(self.Foundation_Class(x, y, self, suit=j))
|
s.foundations.append(self.Foundation_Class(x, y, self, suit=j))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
x, y = l.XM+(max_rows-reserves)*l.XS/2, l.YM+l.YS
|
x, y = l.XM+(max_rows-reserves)*l.XS//2, l.YM+l.YS
|
||||||
for i in range(reserves):
|
for i in range(reserves):
|
||||||
s.reserves.append(ReserveStack(x, y, self))
|
s.reserves.append(ReserveStack(x, y, self))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
x, y = l.XM+(max_rows-rows)*l.XS/2, l.YM+2*l.YS
|
x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+2*l.YS
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
s.rows.append(self.RowStack_Class(x, y, self))
|
s.rows.append(self.RowStack_Class(x, y, self))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
|
@ -573,7 +573,7 @@ class Headquarters(Game):
|
||||||
l, s = Layout(self), self.s
|
l, s = Layout(self), self.s
|
||||||
w, h = l.XM+(rows+reserves+1)*l.XS, l.YM+3*l.YS+16*l.YOFFSET
|
w, h = l.XM+(rows+reserves+1)*l.XS, l.YM+3*l.YS+16*l.YOFFSET
|
||||||
self.setSize(w, h)
|
self.setSize(w, h)
|
||||||
x, y = l.XM+(rows+reserves+1-8)*l.XS/2, l.YM
|
x, y = l.XM+(rows+reserves+1-8)*l.XS//2, l.YM
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4))
|
s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
|
|
|
@ -365,8 +365,8 @@ class Images:
|
||||||
return
|
return
|
||||||
r = self.reduced
|
r = self.reduced
|
||||||
if r > 1:
|
if r > 1:
|
||||||
self.CARD_XOFFSET = max(10/r, cs.CARD_XOFFSET)
|
self.CARD_XOFFSET = max(10//r, cs.CARD_XOFFSET)
|
||||||
self.CARD_YOFFSET = max(10/r, cs.CARD_YOFFSET)
|
self.CARD_YOFFSET = max(10//r, cs.CARD_YOFFSET)
|
||||||
else:
|
else:
|
||||||
self.CARD_XOFFSET = cs.CARD_XOFFSET
|
self.CARD_XOFFSET = cs.CARD_XOFFSET
|
||||||
self.CARD_YOFFSET = cs.CARD_YOFFSET
|
self.CARD_YOFFSET = cs.CARD_YOFFSET
|
||||||
|
|
|
@ -109,7 +109,7 @@ class PysolProgressBar:
|
||||||
def update(self, percent=None, step=1):
|
def update(self, percent=None, step=1):
|
||||||
# self.steps_sum += step
|
# self.steps_sum += step
|
||||||
# print self.steps_sum, self.norm
|
# print self.steps_sum, self.norm
|
||||||
step = step/self.norm
|
step /= self.norm
|
||||||
if percent is None:
|
if percent is None:
|
||||||
self.percent += step
|
self.percent += step
|
||||||
elif percent > self.percent:
|
elif percent > self.percent:
|
||||||
|
|
|
@ -168,7 +168,7 @@ class SelectTileDialogWithPreview(MfxDialog):
|
||||||
|
|
||||||
def _colorselOkClicked(self, w, d):
|
def _colorselOkClicked(self, w, d):
|
||||||
c = d.colorsel.get_current_color()
|
c = d.colorsel.get_current_color()
|
||||||
c = '#%02x%02x%02x' % (c.red/256, c.green/256, c.blue/256)
|
c = '#%02x%02x%02x' % (c.red//256, c.green//256, c.blue//256)
|
||||||
d.destroy()
|
d.destroy()
|
||||||
self.updatePreview(c)
|
self.updatePreview(c)
|
||||||
self.treeview.unselectAll()
|
self.treeview.unselectAll()
|
||||||
|
|
|
@ -298,7 +298,7 @@ class MfxCanvas(gnomecanvas.Canvas):
|
||||||
#
|
#
|
||||||
gnomecanvas.Canvas.__init__(self)
|
gnomecanvas.Canvas.__init__(self)
|
||||||
c = top.style.bg[gtk.STATE_NORMAL]
|
c = top.style.bg[gtk.STATE_NORMAL]
|
||||||
c = '#%02x%02x%02x' % (c.red/256, c.green/256, c.blue/256)
|
c = '#%02x%02x%02x' % (c.red//256, c.green//256, c.blue//256)
|
||||||
self.top_bg = c
|
self.top_bg = c
|
||||||
if bg is not None:
|
if bg is not None:
|
||||||
self.modify_bg(gtk.STATE_NORMAL, gdk.color_parse(bg))
|
self.modify_bg(gtk.STATE_NORMAL, gdk.color_parse(bg))
|
||||||
|
@ -520,7 +520,7 @@ class MfxCanvas(gnomecanvas.Canvas):
|
||||||
pixbuf = image.pixbuf
|
pixbuf = image.pixbuf
|
||||||
w, h = self.get_size()
|
w, h = self.get_size()
|
||||||
iw, ih = pixbuf.get_width(), pixbuf.get_height()
|
iw, ih = pixbuf.get_width(), pixbuf.get_height()
|
||||||
x, y = (w-iw)/2, (h-ih)/2
|
x, y = (w-iw)//2, (h-ih)//2
|
||||||
dx, dy = self.world_to_window(0, 0)
|
dx, dy = self.world_to_window(0, 0)
|
||||||
dx, dy = int(dx), int(dy)
|
dx, dy = int(dx), int(dy)
|
||||||
self.__topimage = self.root().add(gnomecanvas.CanvasPixbuf,
|
self.__topimage = self.root().add(gnomecanvas.CanvasPixbuf,
|
||||||
|
|
|
@ -295,9 +295,9 @@ class Game_StatsDialog:
|
||||||
width, height = alloc.width, alloc.height
|
width, height = alloc.width, alloc.height
|
||||||
w, h = 90, 50
|
w, h = 90, 50
|
||||||
# x, y = 10, 10
|
# x, y = 10, 10
|
||||||
x, y = (width-w)/2, (height-h)/2
|
x, y = (width-w)//2, (height-h)//2
|
||||||
dy = 9
|
dy = 9
|
||||||
y = y-dy/2
|
y -= dy//2
|
||||||
|
|
||||||
if won+lost > 0:
|
if won+lost > 0:
|
||||||
gc.set_foreground(colormap.alloc_color('#008000'))
|
gc.set_foreground(colormap.alloc_color('#008000'))
|
||||||
|
@ -328,8 +328,8 @@ class Game_StatsDialog:
|
||||||
gc.set_foreground(colormap.alloc_color('#a0a0a0'))
|
gc.set_foreground(colormap.alloc_color('#a0a0a0'))
|
||||||
pangolayout = drawing.create_pango_layout(_('No games'))
|
pangolayout = drawing.create_pango_layout(_('No games'))
|
||||||
ext = pangolayout.get_extents()
|
ext = pangolayout.get_extents()
|
||||||
tw, th = ext[1][2]/pango.SCALE, ext[1][3]/pango.SCALE
|
tw, th = ext[1][2]//pango.SCALE, ext[1][3]//pango.SCALE
|
||||||
win.draw_layout(gc, x+w/2-tw/2, y+h/2-th/2, pangolayout)
|
win.draw_layout(gc, x+w//2-tw//2, y+h//2-th//2, pangolayout)
|
||||||
|
|
||||||
def _createTop(self):
|
def _createTop(self):
|
||||||
for n in ('top_10_time_treeview',
|
for n in ('top_10_time_treeview',
|
||||||
|
|
|
@ -72,7 +72,7 @@ class _MfxToplevel(gtk.Window):
|
||||||
# return self.get_window().get_cursor(v)
|
# return self.get_window().get_cursor(v)
|
||||||
elif attr in ("background", "bg"):
|
elif attr in ("background", "bg"):
|
||||||
c = self.style.bg[gtk.STATE_NORMAL]
|
c = self.style.bg[gtk.STATE_NORMAL]
|
||||||
c = '#%02x%02x%02x' % (c.red/256, c.green/256, c.blue/256)
|
c = '#%02x%02x%02x' % (c.red//256, c.green//256, c.blue//256)
|
||||||
return c
|
return c
|
||||||
print("Toplevel cget:", attr)
|
print("Toplevel cget:", attr)
|
||||||
# ~ raise AttributeError, attr
|
# ~ raise AttributeError, attr
|
||||||
|
|
|
@ -242,7 +242,7 @@ class SingleGameFrame(ttk.Frame):
|
||||||
#
|
#
|
||||||
x = tx[0]
|
x = tx[0]
|
||||||
dy = int(self.dialog.font_metrics['ascent']) - 10
|
dy = int(self.dialog.font_metrics['ascent']) - 10
|
||||||
dy = dy/2
|
dy //= 2
|
||||||
c.create_text(x, ty[0]-dy, text=_("Won:"),
|
c.create_text(x, ty[0]-dy, text=_("Won:"),
|
||||||
anchor="nw", font=tfont, fill=fg)
|
anchor="nw", font=tfont, fill=fg)
|
||||||
c.create_text(x, ty[1]-dy, text=_("Lost:"),
|
c.create_text(x, ty[1]-dy, text=_("Lost:"),
|
||||||
|
@ -299,7 +299,7 @@ class SingleGameFrame(ttk.Frame):
|
||||||
else:
|
else:
|
||||||
c.create_oval(x0, y0+d, x0+w, y0+h+d, fill="#7f7f7f")
|
c.create_oval(x0, y0+d, x0+w, y0+h+d, fill="#7f7f7f")
|
||||||
c.create_oval(x0, y0, x0+w, y0+h, fill="#f0f0f0")
|
c.create_oval(x0, y0, x0+w, y0+h, fill="#f0f0f0")
|
||||||
c.create_text(x0+w/2, y0+h/2, text=_("No games"),
|
c.create_text(x0+w//2, y0+h//2, text=_("No games"),
|
||||||
anchor="center", font=tfont, fill="#bfbfbf")
|
anchor="center", font=tfont, fill="#bfbfbf")
|
||||||
#
|
#
|
||||||
self._createChartTexts(tx, ty, won, lost)
|
self._createChartTexts(tx, ty, won, lost)
|
||||||
|
@ -960,8 +960,8 @@ class ProgressionFrame(ttk.Frame):
|
||||||
tw = max(measure(_('Games/day')),
|
tw = max(measure(_('Games/day')),
|
||||||
measure(_('Games/week')),
|
measure(_('Games/week')),
|
||||||
measure(_('% won')))
|
measure(_('% won')))
|
||||||
self.left_margin = self.xmargin+tw/2
|
self.left_margin = self.xmargin+tw//2
|
||||||
self.right_margin = self.xmargin+tw/2
|
self.right_margin = self.xmargin+tw//2
|
||||||
self.top_margin = 15+self.text_height
|
self.top_margin = 15+self.text_height
|
||||||
self.bottom_margin = 15+self.text_height+10+self.text_height
|
self.bottom_margin = 15+self.text_height+10+self.text_height
|
||||||
#
|
#
|
||||||
|
@ -1018,12 +1018,12 @@ class ProgressionFrame(ttk.Frame):
|
||||||
|
|
||||||
graph_width = self.canvas_width-self.left_margin-self.right_margin
|
graph_width = self.canvas_width-self.left_margin-self.right_margin
|
||||||
graph_height = self.canvas_height-self.top_margin-self.bottom_margin
|
graph_height = self.canvas_height-self.top_margin-self.bottom_margin
|
||||||
dx = (graph_width-2*self.graph_dx)/(len(result)-1)
|
dx = (graph_width-2*self.graph_dx)//(len(result)-1)
|
||||||
graph_dx = (graph_width-(len(result)-1)*dx)/2
|
graph_dx = (graph_width-(len(result)-1)*dx)//2
|
||||||
dy = (graph_height-self.graph_dy)/5
|
dy = (graph_height-self.graph_dy)//5
|
||||||
x0, y0 = self.left_margin, self.canvas_height-self.bottom_margin
|
x0, y0 = self.left_margin, self.canvas_height-self.bottom_margin
|
||||||
x1, y1 = self.canvas_width-self.right_margin, self.top_margin
|
x1, y1 = self.canvas_width-self.right_margin, self.top_margin
|
||||||
td = self.text_height/2
|
td = self.text_height//2
|
||||||
|
|
||||||
# vertical scale
|
# vertical scale
|
||||||
x = x0+graph_dx
|
x = x0+graph_dx
|
||||||
|
@ -1051,7 +1051,7 @@ class ProgressionFrame(ttk.Frame):
|
||||||
|
|
||||||
# horizontal scale
|
# horizontal scale
|
||||||
max_games = max([i[1] for i in result])
|
max_games = max([i[1] for i in result])
|
||||||
games_delta = max_games/5+1
|
games_delta = max_games//5+1
|
||||||
percent = 0
|
percent = 0
|
||||||
games = 0
|
games = 0
|
||||||
for y in range(y0, y1, -dy):
|
for y in range(y0, y1, -dy):
|
||||||
|
|
|
@ -63,7 +63,7 @@ class MfxTreeBaseNode:
|
||||||
def draw(self, x, y, lastx=None, lasty=None):
|
def draw(self, x, y, lastx=None, lasty=None):
|
||||||
canvas, style = self.tree.canvas, self.tree.style
|
canvas, style = self.tree.canvas, self.tree.style
|
||||||
topleftx = x + style.distx
|
topleftx = x + style.distx
|
||||||
toplefty = y - style.height / 2 # +++
|
toplefty = y - style.height // 2 # +++
|
||||||
# draw the horizontal line
|
# draw the horizontal line
|
||||||
if lastx is not None:
|
if lastx is not None:
|
||||||
canvas.create_line(
|
canvas.create_line(
|
||||||
|
@ -175,8 +175,8 @@ class MfxTreeNode(MfxTreeBaseNode):
|
||||||
# draw the vertical line
|
# draw the vertical line
|
||||||
if self.subnodes:
|
if self.subnodes:
|
||||||
style = self.tree.style
|
style = self.tree.style
|
||||||
dy = (style.disty-style.width)/2
|
dy = (style.disty-style.width)//2
|
||||||
y = y-style.disty/2-dy
|
y = y-style.disty//2-dy
|
||||||
self.tree.canvas.create_line(x, y, nx, ly,
|
self.tree.canvas.create_line(x, y, nx, ly,
|
||||||
stipple=style.linestyle,
|
stipple=style.linestyle,
|
||||||
fill=style.linecolor)
|
fill=style.linecolor)
|
||||||
|
@ -187,10 +187,10 @@ class MfxTreeNode(MfxTreeBaseNode):
|
||||||
lx, ly, nx, ny = MfxTreeBaseNode.draw(self, x, y, ilastx, ilasty)
|
lx, ly, nx, ny = MfxTreeBaseNode.draw(self, x, y, ilastx, ilasty)
|
||||||
if self.expanded:
|
if self.expanded:
|
||||||
style = self.tree.style
|
style = self.tree.style
|
||||||
childx = nx + style.distx + style.width / 2
|
childx = nx + style.distx + style.width // 2
|
||||||
childy = ny
|
childy = ny
|
||||||
clastx = nx + style.distx + style.width / 2
|
clastx = nx + style.distx + style.width // 2
|
||||||
clasty = ly + style.height / 2
|
clasty = ly + style.height // 2
|
||||||
ny = self.drawChildren(childx, childy, clastx, clasty)
|
ny = self.drawChildren(childx, childy, clastx, clasty)
|
||||||
return lx, ly, x, ny
|
return lx, ly, x, ny
|
||||||
|
|
||||||
|
@ -273,8 +273,8 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
|
||||||
# Account for initial offsets, see topleft[xy] in BaseNode.draw().
|
# Account for initial offsets, see topleft[xy] in BaseNode.draw().
|
||||||
# We do this so that our bounding box always starts at (0,0)
|
# We do this so that our bounding box always starts at (0,0)
|
||||||
# and the yscrollincrement works nicely.
|
# and the yscrollincrement works nicely.
|
||||||
nx = nx - self.style.distx
|
nx -= self.style.distx
|
||||||
ny = ny + self.style.height / 2
|
ny += self.style.height // 2
|
||||||
for node in self.rootnodes:
|
for node in self.rootnodes:
|
||||||
# update tree
|
# update tree
|
||||||
node.tree = self
|
node.tree = self
|
||||||
|
|
|
@ -708,7 +708,7 @@ class StackDesc:
|
||||||
font = game.app.getFont('canvas_small')
|
font = game.app.getFont('canvas_small')
|
||||||
# print self.app.cardset.CARDW, self.app.images.CARDW
|
# print self.app.cardset.CARDW, self.app.images.CARDW
|
||||||
cardw = game.app.images.getSize()[0]
|
cardw = game.app.images.getSize()[0]
|
||||||
x, y = stack.x+cardw/2, stack.y
|
x, y = stack.x+cardw//2, stack.y
|
||||||
text = stack.getHelp()+'\n'+stack.getBaseCard()
|
text = stack.getHelp()+'\n'+stack.getBaseCard()
|
||||||
text = text.strip()
|
text = text.strip()
|
||||||
if text:
|
if text:
|
||||||
|
@ -752,9 +752,9 @@ class MyPysolScale:
|
||||||
else:
|
else:
|
||||||
self.resolution = 1
|
self.resolution = 1
|
||||||
if 'from_' in kw:
|
if 'from_' in kw:
|
||||||
kw['from_'] = kw['from_']/self.resolution
|
kw['from_'] //= self.resolution
|
||||||
if 'to' in kw:
|
if 'to' in kw:
|
||||||
kw['to'] = kw['to']/self.resolution
|
kw['to'] //= self.resolution
|
||||||
if 'variable' in kw:
|
if 'variable' in kw:
|
||||||
self.variable = kw['variable']
|
self.variable = kw['variable']
|
||||||
del kw['variable']
|
del kw['variable']
|
||||||
|
|
Loading…
Add table
Reference in a new issue