mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ new mouse option: `point-n-click'
git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@66 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
parent
08ced9f908
commit
7faf866e25
15 changed files with 205 additions and 60 deletions
12
MANIFEST.in
12
MANIFEST.in
|
@ -30,14 +30,14 @@ include data/pysol.xbm data/pysol.xpm data/pysol.ico
|
||||||
#graft data/music
|
#graft data/music
|
||||||
#include data/music/Astral_Dreams.COPYRIGHT
|
#include data/music/Astral_Dreams.COPYRIGHT
|
||||||
#include data/music/Astral_Dreams.it
|
#include data/music/Astral_Dreams.it
|
||||||
include data/music/Bye_For_Now.COPYRIGHT
|
#include data/music/Bye_For_Now.COPYRIGHT
|
||||||
include data/music/Bye_For_Now.s3m
|
#include data/music/Bye_For_Now.s3m
|
||||||
#include data/music/Past_and_Future.COPYRIGHT
|
#include data/music/Past_and_Future.COPYRIGHT
|
||||||
#include data/music/Past_and_Future.it
|
#include data/music/Past_and_Future.it
|
||||||
include data/music/Ranger_Song.COPYRIGHT
|
#include data/music/Ranger_Song.COPYRIGHT
|
||||||
include data/music/Ranger_Song.s3m
|
#include data/music/Ranger_Song.s3m
|
||||||
include data/music/Subsequential.COPYRIGHT
|
#include data/music/Subsequential.COPYRIGHT
|
||||||
include data/music/Subsequential.mod
|
#include data/music/Subsequential.mod
|
||||||
graft data/sound
|
graft data/sound
|
||||||
##
|
##
|
||||||
## data - i18n
|
## data - i18n
|
||||||
|
|
|
@ -200,7 +200,7 @@ class Options:
|
||||||
self.games_geometry = {} # saved games geometry (gameid: (width, height))
|
self.games_geometry = {} # saved games geometry (gameid: (width, height))
|
||||||
#
|
#
|
||||||
self.splashscreen = True
|
self.splashscreen = True
|
||||||
self.sticky_mouse = False
|
self.mouse_type = 'drag-n-drop' # or 'sticky-mouse' or 'point-n-click'
|
||||||
self.mouse_undo = False # use mouse for undo/redo
|
self.mouse_undo = False # use mouse for undo/redo
|
||||||
self.negative_bottom = False
|
self.negative_bottom = False
|
||||||
self.randomize_place = False
|
self.randomize_place = False
|
||||||
|
|
|
@ -64,7 +64,7 @@ class PushPin_Talon(DealRowTalonStack):
|
||||||
return self.dealRowAvail(rows=[r], sound=sound)
|
return self.dealRowAvail(rows=[r], sound=sound)
|
||||||
return self.dealRowAvail(rows=[self.game.s.rows[0]], sound=sound)
|
return self.dealRowAvail(rows=[self.game.s.rows[0]], sound=sound)
|
||||||
def getBottomImage(self):
|
def getBottomImage(self):
|
||||||
return None
|
return self.game.app.images.getBlankBottom()
|
||||||
|
|
||||||
class PushPin_RowStack(ReserveStack):
|
class PushPin_RowStack(ReserveStack):
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class PushPin_RowStack(ReserveStack):
|
||||||
game.leaveState(old_state)
|
game.leaveState(old_state)
|
||||||
|
|
||||||
def getBottomImage(self):
|
def getBottomImage(self):
|
||||||
return None
|
return self.game.app.images.getBlankBottom()
|
||||||
|
|
||||||
|
|
||||||
class PushPin(Game):
|
class PushPin(Game):
|
||||||
|
|
|
@ -103,7 +103,7 @@ class Matrix_RowStack(OpenStack):
|
||||||
bind(self.group, "<Control-1>", self._Stack__controlclickEventHandler)
|
bind(self.group, "<Control-1>", self._Stack__controlclickEventHandler)
|
||||||
|
|
||||||
def getBottomImage(self):
|
def getBottomImage(self):
|
||||||
return None
|
return self.game.app.images.getBlankBottom()
|
||||||
|
|
||||||
def blockMap(self):
|
def blockMap(self):
|
||||||
ncards = self.game.gameinfo.ncards
|
ncards = self.game.gameinfo.ncards
|
||||||
|
|
|
@ -86,6 +86,7 @@ class Images:
|
||||||
self._bottom = []
|
self._bottom = []
|
||||||
self._bottom_negative = []
|
self._bottom_negative = []
|
||||||
self._bottom_positive = []
|
self._bottom_positive = []
|
||||||
|
self._blank_bottom = None
|
||||||
self._letter = []
|
self._letter = []
|
||||||
self._letter_negative = []
|
self._letter_negative = []
|
||||||
self._letter_positive = []
|
self._letter_positive = []
|
||||||
|
@ -139,6 +140,7 @@ class Images:
|
||||||
if bottom is None:
|
if bottom is None:
|
||||||
bottom = createImage(self.CARDW, self.CARDH, fill=None, outline="#ffffff")
|
bottom = createImage(self.CARDW, self.CARDH, fill=None, outline="#ffffff")
|
||||||
self._letter_negative.append(bottom)
|
self._letter_negative.append(bottom)
|
||||||
|
self._blank_bottom = createImage(self.CARDW, self.CARDH, fill=None, outline=None)
|
||||||
|
|
||||||
def load(self, app, progress=None, fast=0):
|
def load(self, app, progress=None, fast=0):
|
||||||
##fast = 1
|
##fast = 1
|
||||||
|
@ -240,6 +242,9 @@ class Images:
|
||||||
def getReserveBottom(self):
|
def getReserveBottom(self):
|
||||||
return self._bottom[0]
|
return self._bottom[0]
|
||||||
|
|
||||||
|
def getBlankBottom(self):
|
||||||
|
return self._blank_bottom
|
||||||
|
|
||||||
def getSuitBottom(self, suit=-1):
|
def getSuitBottom(self, suit=-1):
|
||||||
assert type(suit) is types.IntType
|
assert type(suit) is types.IntType
|
||||||
if suit == -1: return self._bottom[1] # any suit
|
if suit == -1: return self._bottom[1] # any suit
|
||||||
|
|
|
@ -495,7 +495,7 @@ class PyGameAudioClient(AbstractAudioClient):
|
||||||
if self.time:
|
if self.time:
|
||||||
self.time.wait(300)
|
self.time.wait(300)
|
||||||
except:
|
except:
|
||||||
if traceback: traceback.print_exc()
|
##if traceback: traceback.print_exc()
|
||||||
self.time.wait(1000)
|
self.time.wait(1000)
|
||||||
|
|
||||||
def _destroy(self):
|
def _destroy(self):
|
||||||
|
|
|
@ -156,6 +156,7 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
('assistlevel', None, ltk2gtk('Assist &level')),
|
('assistlevel', None, ltk2gtk('Assist &level')),
|
||||||
('automaticplay', None, ltk2gtk('&Automatic play')),
|
('automaticplay', None, ltk2gtk('&Automatic play')),
|
||||||
('animations', None, ltk2gtk('A&nimations')),
|
('animations', None, ltk2gtk('A&nimations')),
|
||||||
|
('mouse', None, ltk2gtk('&Mouse')),
|
||||||
('cardview', None, ltk2gtk('Card &view')),
|
('cardview', None, ltk2gtk('Card &view')),
|
||||||
('toolbar', None, ltk2gtk('&Toolbar')),
|
('toolbar', None, ltk2gtk('&Toolbar')),
|
||||||
('statusbar', None, ltk2gtk('Stat&usbar')),
|
('statusbar', None, ltk2gtk('Stat&usbar')),
|
||||||
|
@ -269,7 +270,6 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
('Shade &legal moves', '', 'shade', False),
|
('Shade &legal moves', '', 'shade', False),
|
||||||
('Shrink face-down cards', '', 'shrink_face_down', True),
|
('Shrink face-down cards', '', 'shrink_face_down', True),
|
||||||
('Shade &filled stacks', '', 'shade_filled_stacks', True),
|
('Shade &filled stacks', '', 'shade_filled_stacks', True),
|
||||||
('Stick&y mouse', '', 'sticky_mouse', False),
|
|
||||||
('Show &number of cards', '', 'num_cards', False),
|
('Show &number of cards', '', 'num_cards', False),
|
||||||
('&Demo logo', '', 'demo_logo', False),
|
('&Demo logo', '', 'demo_logo', False),
|
||||||
('Startup splash sc&reen', '', 'splashscreen', False),
|
('Startup splash sc&reen', '', 'splashscreen', False),
|
||||||
|
@ -293,6 +293,11 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
('animationslow', None, ltk2gtk('&Slow'), None, None, 3),
|
('animationslow', None, ltk2gtk('&Slow'), None, None, 3),
|
||||||
('animationveryslow', None, ltk2gtk('&Very slow'), None, None, 4),
|
('animationveryslow', None, ltk2gtk('&Very slow'), None, None, 4),
|
||||||
)
|
)
|
||||||
|
mouse_entries = (
|
||||||
|
('draganddrop', None, ltk2gtk('&Drag-and-Drop'), None, None, 0),
|
||||||
|
('pointandclick', None, ltk2gtk('&Point-and-Click'), None, None, 1),
|
||||||
|
('stickymouse', None, ltk2gtk('&Sticky mouse'), None, None, 2),
|
||||||
|
)
|
||||||
toolbar_side_entries = (
|
toolbar_side_entries = (
|
||||||
('toolbarhide', None, ltk2gtk('Hide'), None, None, 0),
|
('toolbarhide', None, ltk2gtk('Hide'), None, None, 0),
|
||||||
('toolbartop', None, ltk2gtk('Top'), None, None, 1),
|
('toolbartop', None, ltk2gtk('Top'), None, None, 1),
|
||||||
|
@ -394,7 +399,11 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
<menuitem action='shrinkfacedowncards'/>
|
<menuitem action='shrinkfacedowncards'/>
|
||||||
<menuitem action='shadefilledstacks'/>
|
<menuitem action='shadefilledstacks'/>
|
||||||
</menu>
|
</menu>
|
||||||
<menuitem action='stickymouse'/>
|
<menu action='mouse'>
|
||||||
|
<menuitem action='draganddrop'/>
|
||||||
|
<menuitem action='pointandclick'/>
|
||||||
|
<menuitem action='stickymouse'/>
|
||||||
|
</menu>
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem action='fonts'/>
|
<menuitem action='fonts'/>
|
||||||
<menuitem action='colors'/>
|
<menuitem action='colors'/>
|
||||||
|
@ -434,6 +443,10 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
action_group.add_radio_actions(animations_entries,
|
action_group.add_radio_actions(animations_entries,
|
||||||
self.app.opt.animations,
|
self.app.opt.animations,
|
||||||
self.mOptAnimations)
|
self.mOptAnimations)
|
||||||
|
t = ['drag-n-drop', 'point-n-click', 'sticky-mouse'].index(self.app.opt.mouse_type)
|
||||||
|
action_group.add_radio_actions(mouse_entries,
|
||||||
|
t,
|
||||||
|
self.mOptMouseType)
|
||||||
action_group.add_radio_actions(toolbar_side_entries,
|
action_group.add_radio_actions(toolbar_side_entries,
|
||||||
self.app.opt.toolbar,
|
self.app.opt.toolbar,
|
||||||
self.mOptToolbar)
|
self.mOptToolbar)
|
||||||
|
@ -837,6 +850,12 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
self.app.opt.animations = w1.get_current_value()
|
self.app.opt.animations = w1.get_current_value()
|
||||||
|
|
||||||
|
|
||||||
|
def mOptMouseType(self, w1, w2):
|
||||||
|
v = w1.get_current_value()
|
||||||
|
t = ('drag-n-drop', 'point-n-click', 'sticky-mouse')[v]
|
||||||
|
self.app.opt.mouse_type = t
|
||||||
|
|
||||||
|
|
||||||
def mOptToolbar(self, w1, w2):
|
def mOptToolbar(self, w1, w2):
|
||||||
if self._cancelDrag(break_pause=False): return
|
if self._cancelDrag(break_pause=False): return
|
||||||
side = w1.get_current_value()
|
side = w1.get_current_value()
|
||||||
|
|
|
@ -368,6 +368,8 @@ class MfxCanvas(gnome.canvas.Canvas):
|
||||||
elif k == 'cursor':
|
elif k == 'cursor':
|
||||||
if not self.window:
|
if not self.window:
|
||||||
self.realize()
|
self.realize()
|
||||||
|
if v == '':
|
||||||
|
v = gdk.LEFT_PTR
|
||||||
self.window.set_cursor(gdk.Cursor(v))
|
self.window.set_cursor(gdk.Cursor(v))
|
||||||
elif k == 'height':
|
elif k == 'height':
|
||||||
height = v
|
height = v
|
||||||
|
|
|
@ -48,8 +48,9 @@ tkversion = (0, 0, 0, 0)
|
||||||
EVENT_HANDLED = 1
|
EVENT_HANDLED = 1
|
||||||
EVENT_PROPAGATE = 0
|
EVENT_PROPAGATE = 0
|
||||||
|
|
||||||
CURSOR_DRAG = gdk.HAND1
|
CURSOR_DRAG = gdk.HAND1
|
||||||
CURSOR_WATCH = gdk.WATCH
|
CURSOR_WATCH = gdk.WATCH
|
||||||
|
CURSOR_UP_ARROW = gdk.SB_UP_ARROW
|
||||||
|
|
||||||
TOOLBAR_BUTTONS = (
|
TOOLBAR_BUTTONS = (
|
||||||
"new",
|
"new",
|
||||||
|
|
|
@ -100,10 +100,10 @@ from util import ACE, KING, SUITS
|
||||||
from util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK
|
from util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK
|
||||||
from util import NO_REDEAL, UNLIMITED_REDEALS, VARIABLE_REDEALS
|
from util import NO_REDEAL, UNLIMITED_REDEALS, VARIABLE_REDEALS
|
||||||
from pysoltk import EVENT_HANDLED, EVENT_PROPAGATE
|
from pysoltk import EVENT_HANDLED, EVENT_PROPAGATE
|
||||||
from pysoltk import CURSOR_DRAG, ANCHOR_NW, ANCHOR_SE
|
from pysoltk import CURSOR_DRAG, CURSOR_UP_ARROW, ANCHOR_NW, ANCHOR_SE
|
||||||
from pysoltk import bind, unbind_destroy
|
from pysoltk import bind, unbind_destroy
|
||||||
from pysoltk import after, after_idle, after_cancel
|
from pysoltk import after, after_idle, after_cancel
|
||||||
from pysoltk import MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle, MfxCanvasText
|
from pysoltk import MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle, MfxCanvasText, MfxCanvasLine
|
||||||
from pysoltk import Card
|
from pysoltk import Card
|
||||||
from pysoltk import get_text_width
|
from pysoltk import get_text_width
|
||||||
from settings import TOOLKIT
|
from settings import TOOLKIT
|
||||||
|
@ -315,6 +315,7 @@ class Stack:
|
||||||
view.is_open = -1
|
view.is_open = -1
|
||||||
view.can_hide_cards = -1
|
view.can_hide_cards = -1
|
||||||
view.max_shadow_cards = -1
|
view.max_shadow_cards = -1
|
||||||
|
view.cursor_changed = False
|
||||||
|
|
||||||
def destruct(self):
|
def destruct(self):
|
||||||
# help breaking circular references
|
# help breaking circular references
|
||||||
|
@ -396,8 +397,8 @@ class Stack:
|
||||||
assert self.is_visible and self.images.bottom is None
|
assert self.is_visible and self.images.bottom is None
|
||||||
img = self.getBottomImage()
|
img = self.getBottomImage()
|
||||||
if img is not None:
|
if img is not None:
|
||||||
self.images.bottom = MfxCanvasImage(self.canvas,self.x, self.y,
|
self.images.bottom = MfxCanvasImage(self.canvas, self.x, self.y,
|
||||||
image=img,anchor=ANCHOR_NW,
|
image=img, anchor=ANCHOR_NW,
|
||||||
group=self.group)
|
group=self.group)
|
||||||
self.top_bottom = self.images.bottom
|
self.top_bottom = self.images.bottom
|
||||||
|
|
||||||
|
@ -697,7 +698,7 @@ class Stack:
|
||||||
#
|
#
|
||||||
|
|
||||||
def getBottomImage(self):
|
def getBottomImage(self):
|
||||||
return None
|
return self.game.app.images.getBlankBottom()
|
||||||
|
|
||||||
def getPositionFor(self, card):
|
def getPositionFor(self, card):
|
||||||
model, view = self, self
|
model, view = self, self
|
||||||
|
@ -920,7 +921,8 @@ class Stack:
|
||||||
if drag.cards:
|
if drag.cards:
|
||||||
if sound:
|
if sound:
|
||||||
self.game.playSample("nomove")
|
self.game.playSample("nomove")
|
||||||
self.moveCardsBackHandler(event, drag)
|
if not self.game.app.opt.mouse_type == 'point-n-click':
|
||||||
|
self.moveCardsBackHandler(event, drag)
|
||||||
|
|
||||||
def moveCardsBackHandler(self, event, drag):
|
def moveCardsBackHandler(self, event, drag):
|
||||||
for card in drag.cards:
|
for card in drag.cards:
|
||||||
|
@ -950,17 +952,17 @@ class Stack:
|
||||||
return EVENT_HANDLED
|
return EVENT_HANDLED
|
||||||
|
|
||||||
def __clickEventHandler(self, event):
|
def __clickEventHandler(self, event):
|
||||||
if self.game.app.opt.sticky_mouse:
|
if self.game.app.opt.mouse_type == 'drag-n-drop':
|
||||||
|
cancel_drag = 1
|
||||||
|
start_drag = 1
|
||||||
|
handler = self.clickHandler
|
||||||
|
else: # sticky-mouse or point-n-click
|
||||||
cancel_drag = 0
|
cancel_drag = 0
|
||||||
start_drag = not self.game.drag.stack
|
start_drag = not self.game.drag.stack
|
||||||
if start_drag:
|
if start_drag:
|
||||||
handler = self.clickHandler
|
handler = self.clickHandler
|
||||||
else:
|
else:
|
||||||
handler = self.finishDrag
|
handler = self.finishDrag
|
||||||
else:
|
|
||||||
cancel_drag = 1
|
|
||||||
start_drag = 1
|
|
||||||
handler = self.clickHandler
|
|
||||||
return self.__defaultClickEventHandler(event, handler, start_drag, cancel_drag)
|
return self.__defaultClickEventHandler(event, handler, start_drag, cancel_drag)
|
||||||
|
|
||||||
def __doubleclickEventHandler(self, event):
|
def __doubleclickEventHandler(self, event):
|
||||||
|
@ -986,8 +988,11 @@ class Stack:
|
||||||
return EVENT_PROPAGATE
|
return EVENT_PROPAGATE
|
||||||
if self.game.demo:
|
if self.game.demo:
|
||||||
self.game.stopDemo(event)
|
self.game.stopDemo(event)
|
||||||
if self.game.busy: return EVENT_HANDLED
|
if self.game.busy:
|
||||||
if not self.game.app.opt.sticky_mouse and TOOLKIT == 'tk':
|
return EVENT_HANDLED
|
||||||
|
if self.game.app.opt.mouse_type == 'point-n-click':
|
||||||
|
return EVENT_HANDLED
|
||||||
|
if self.game.app.opt.mouse_type == 'drag-n-drop' and TOOLKIT == 'tk':
|
||||||
# use a timer to update the drag
|
# use a timer to update the drag
|
||||||
# this allows us to skip redraws on slow machines
|
# this allows us to skip redraws on slow machines
|
||||||
drag = self.game.drag
|
drag = self.game.drag
|
||||||
|
@ -1003,14 +1008,21 @@ class Stack:
|
||||||
if self.game.demo:
|
if self.game.demo:
|
||||||
self.game.stopDemo(event)
|
self.game.stopDemo(event)
|
||||||
self.game.interruptSleep()
|
self.game.interruptSleep()
|
||||||
if self.game.busy: return EVENT_HANDLED
|
if self.game.busy:
|
||||||
if not self.game.app.opt.sticky_mouse:
|
return EVENT_HANDLED
|
||||||
|
if self.game.app.opt.mouse_type == 'drag-n-drop':
|
||||||
self.keepDrag(event)
|
self.keepDrag(event)
|
||||||
self.finishDrag(event)
|
self.finishDrag(event)
|
||||||
return EVENT_HANDLED
|
return EVENT_HANDLED
|
||||||
|
|
||||||
def __enterEventHandler(self, event):
|
def __enterEventHandler(self, event):
|
||||||
if not self.game.drag.stack:
|
if self.game.drag.stack:
|
||||||
|
if self.game.app.opt.mouse_type == 'point-n-click':
|
||||||
|
if self.acceptsCards(self.game.drag.stack,
|
||||||
|
self.game.drag.cards):
|
||||||
|
self.game.canvas.config(cursor=CURSOR_UP_ARROW)
|
||||||
|
self.cursor_changed = True
|
||||||
|
else:
|
||||||
after_idle(self.canvas, self.game.showHelp,
|
after_idle(self.canvas, self.game.showHelp,
|
||||||
'help', self.getHelp(), ##+' '+self.getBaseCard(),
|
'help', self.getHelp(), ##+' '+self.getBaseCard(),
|
||||||
'info', self.getNumCards())
|
'info', self.getNumCards())
|
||||||
|
@ -1019,8 +1031,11 @@ class Stack:
|
||||||
def __leaveEventHandler(self, event):
|
def __leaveEventHandler(self, event):
|
||||||
if not self.game.drag.stack:
|
if not self.game.drag.stack:
|
||||||
after_idle(self.canvas, self.game.showHelp)
|
after_idle(self.canvas, self.game.showHelp)
|
||||||
if not self.game.app.opt.sticky_mouse:
|
if self.game.app.opt.mouse_type == 'drag-n-drop':
|
||||||
return EVENT_HANDLED
|
return EVENT_HANDLED
|
||||||
|
if self.cursor_changed:
|
||||||
|
self.game.canvas.config(cursor='')
|
||||||
|
self.cursor_changed = False
|
||||||
drag_stack = self.game.drag.stack
|
drag_stack = self.game.drag.stack
|
||||||
if self is drag_stack:
|
if self is drag_stack:
|
||||||
x, y = event.x, event.y
|
x, y = event.x, event.y
|
||||||
|
@ -1066,6 +1081,9 @@ class Stack:
|
||||||
drag.noshade_stacks = [ self ]
|
drag.noshade_stacks = [ self ]
|
||||||
drag.cards = self.getDragCards(i)
|
drag.cards = self.getDragCards(i)
|
||||||
drag.index = i
|
drag.index = i
|
||||||
|
if self.game.app.opt.mouse_type == 'point-n-click':
|
||||||
|
self._markCards(drag)
|
||||||
|
return
|
||||||
##if TOOLKIT == 'gtk':
|
##if TOOLKIT == 'gtk':
|
||||||
## drag.stack.group.tkraise()
|
## drag.stack.group.tkraise()
|
||||||
images = game.app.images
|
images = game.app.images
|
||||||
|
@ -1073,7 +1091,7 @@ class Stack:
|
||||||
##sx, sy = 0, 0
|
##sx, sy = 0, 0
|
||||||
sx, sy = -images.SHADOW_XOFFSET, -images.SHADOW_YOFFSET
|
sx, sy = -images.SHADOW_XOFFSET, -images.SHADOW_YOFFSET
|
||||||
dx, dy = 0, 0
|
dx, dy = 0, 0
|
||||||
if game.app.opt.sticky_mouse:
|
if game.app.opt.mouse_type == 'sticky-mouse':
|
||||||
# return cards under mouse
|
# return cards under mouse
|
||||||
dx = event.x - (x_offset+images.CARDW+sx) - game.canvas.xmargin
|
dx = event.x - (x_offset+images.CARDW+sx) - game.canvas.xmargin
|
||||||
dy = event.y - (y_offset+images.CARDH+sy) - game.canvas.ymargin
|
dy = event.y - (y_offset+images.CARDH+sy) - game.canvas.ymargin
|
||||||
|
@ -1271,6 +1289,79 @@ class Stack:
|
||||||
self.items.shade_item.delete()
|
self.items.shade_item.delete()
|
||||||
self.items.shade_item = None
|
self.items.shade_item = None
|
||||||
|
|
||||||
|
|
||||||
|
def _markCards(self, drag):
|
||||||
|
cards = drag.cards
|
||||||
|
drag.stack.group.tkraise()
|
||||||
|
#
|
||||||
|
x0, y0 = self.getPositionFor(cards[0])
|
||||||
|
x1, y1 = self.getPositionFor(cards[-1])
|
||||||
|
x1 = x1 + self.game.app.images.CARDW
|
||||||
|
y1 = y1 + self.game.app.images.CARDH
|
||||||
|
xx0, yy0 = x0, y0
|
||||||
|
w, h = x1-x0, y1-y0
|
||||||
|
m = max(w, h)
|
||||||
|
#
|
||||||
|
Image = None
|
||||||
|
if TOOLKIT == 'tk':
|
||||||
|
try:
|
||||||
|
import Image, ImageTk
|
||||||
|
from ImageDraw import ImageDraw
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
##Image = None
|
||||||
|
if TOOLKIT == 'gtk' or not Image:
|
||||||
|
color = self.game.app.opt.colors['cards_1']
|
||||||
|
r = MfxCanvasRectangle(self.canvas, xx0, yy0, xx0+w, yy0+h,
|
||||||
|
fill="", outline=color, width=4,
|
||||||
|
group=self.group)
|
||||||
|
drag.shadows.append(r)
|
||||||
|
## l = MfxCanvasLine(self.canvas, xx0, yy0, xx0+w, yy0+h,
|
||||||
|
## fill=color, width=4)
|
||||||
|
## drag.shadows.append(l)
|
||||||
|
## l = MfxCanvasLine(self.canvas, xx0, yy0+h, xx0+w, yy0,
|
||||||
|
## fill=color, width=4)
|
||||||
|
## drag.shadows.append(l)
|
||||||
|
return
|
||||||
|
#
|
||||||
|
mask = Image.new('RGBA', (w, h))
|
||||||
|
for c in cards:
|
||||||
|
x, y = self.getPositionFor(c)
|
||||||
|
x, y = x-xx0, y-yy0
|
||||||
|
im = c.item._image._pil_image
|
||||||
|
mask.paste(im, (x, y), im)
|
||||||
|
#
|
||||||
|
shade = Image.new('RGBA', (w, h))
|
||||||
|
draw = ImageDraw(shade, 'RGBA')
|
||||||
|
color = 'black'
|
||||||
|
d = 8
|
||||||
|
## y0, y1 = 0, h
|
||||||
|
## for x0 in range(-m, m, d):
|
||||||
|
## x1 = x0+h
|
||||||
|
## draw.line((x0, y0, x1, y1), fill=color, width=1)
|
||||||
|
## draw.line((x1, y0, x0, y1), fill=color, width=1)
|
||||||
|
for i in xrange(0, m, d):
|
||||||
|
x0, x1 = i, m
|
||||||
|
y0, y1 = 0, m-i
|
||||||
|
draw.line((x0, y0, x1, y1), fill=color, width=1)
|
||||||
|
x0, x1 = 0, m-i
|
||||||
|
y0, y1 = i, m
|
||||||
|
draw.line((x0, y0, x1, y1), fill=color, width=1)
|
||||||
|
x0, x1 = m-i, 0
|
||||||
|
y0, y1 = 0, m-i
|
||||||
|
draw.line((x0, y0, x1, y1), fill=color, width=1)
|
||||||
|
x0, x1 = m, i
|
||||||
|
y0, y1 = i, m
|
||||||
|
draw.line((x0, y0, x1, y1), fill=color, width=1)
|
||||||
|
|
||||||
|
sh2 = Image.composite(shade, mask, mask)
|
||||||
|
tkshade = ImageTk.PhotoImage(sh2)
|
||||||
|
im = MfxCanvasImage(self.game.canvas, xx0, yy0,
|
||||||
|
image=tkshade, anchor=ANCHOR_NW,
|
||||||
|
group=self.group)
|
||||||
|
drag.shadows.append(im)
|
||||||
|
|
||||||
|
|
||||||
def _stopDrag(self):
|
def _stopDrag(self):
|
||||||
drag = self.game.drag
|
drag = self.game.drag
|
||||||
after_cancel(drag.timer)
|
after_cancel(drag.timer)
|
||||||
|
@ -1294,8 +1385,11 @@ class Stack:
|
||||||
drag = self.game.drag.copy()
|
drag = self.game.drag.copy()
|
||||||
self._stopDrag()
|
self._stopDrag()
|
||||||
if drag.cards:
|
if drag.cards:
|
||||||
assert drag.stack is self
|
if self.game.app.opt.mouse_type == 'point-n-click':
|
||||||
self.releaseHandler(event, drag)
|
self.releaseHandler(event, drag)
|
||||||
|
else:
|
||||||
|
assert drag.stack is self
|
||||||
|
self.releaseHandler(event, drag)
|
||||||
|
|
||||||
# cancel a drag operation
|
# cancel a drag operation
|
||||||
def cancelDrag(self, event=None):
|
def cancelDrag(self, event=None):
|
||||||
|
@ -1771,7 +1865,10 @@ class OpenStack(Stack):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def dragMove(self, drag, stack, sound=1):
|
def dragMove(self, drag, stack, sound=1):
|
||||||
self.playMoveMove(len(drag.cards), stack, frames=0, sound=sound)
|
if self.game.app.opt.mouse_type == 'point-n-click':
|
||||||
|
self.playMoveMove(len(drag.cards), stack, sound=sound)
|
||||||
|
else:
|
||||||
|
self.playMoveMove(len(drag.cards), stack, frames=0, sound=sound)
|
||||||
|
|
||||||
def releaseHandler(self, event, drag, sound=1):
|
def releaseHandler(self, event, drag, sound=1):
|
||||||
cards = drag.cards
|
cards = drag.cards
|
||||||
|
@ -1784,15 +1881,21 @@ class OpenStack(Stack):
|
||||||
return
|
return
|
||||||
##print dx, dy
|
##print dx, dy
|
||||||
# get destination stack
|
# get destination stack
|
||||||
stack = self.game.getClosestStack(cards[0], self)
|
if self.game.app.opt.mouse_type == 'point-n-click':
|
||||||
|
from_stack = drag.stack
|
||||||
|
to_stack = self
|
||||||
|
else:
|
||||||
|
from_stack = self
|
||||||
|
to_stack = self.game.getClosestStack(cards[0], self)
|
||||||
# move cards
|
# move cards
|
||||||
if not stack or stack is self or not stack.acceptsCards(self, cards):
|
if (not to_stack or from_stack is to_stack or
|
||||||
|
not to_stack.acceptsCards(from_stack, cards)):
|
||||||
# move cards back to their origin stack
|
# move cards back to their origin stack
|
||||||
Stack.releaseHandler(self, event, drag, sound=sound)
|
Stack.releaseHandler(self, event, drag, sound=sound)
|
||||||
else:
|
else:
|
||||||
# this code actually moves the cards to the new stack
|
# this code actually moves the cards to the new stack
|
||||||
##self.playMoveMove(len(cards), stack, frames=0, sound=sound)
|
##self.playMoveMove(len(cards), stack, frames=0, sound=sound)
|
||||||
self.dragMove(drag, stack, sound=sound)
|
from_stack.dragMove(drag, to_stack, sound=sound)
|
||||||
|
|
||||||
def quickPlayHandler(self, event, from_stacks=None, to_stacks=None):
|
def quickPlayHandler(self, event, from_stacks=None, to_stacks=None):
|
||||||
# from_stacks and to_stacks are meant for possible
|
# from_stacks and to_stacks are meant for possible
|
||||||
|
|
|
@ -258,7 +258,7 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
save_games_geometry = MfxCheckMenuItem(self),
|
save_games_geometry = MfxCheckMenuItem(self),
|
||||||
splashscreen = MfxCheckMenuItem(self),
|
splashscreen = MfxCheckMenuItem(self),
|
||||||
demo_logo = MfxCheckMenuItem(self),
|
demo_logo = MfxCheckMenuItem(self),
|
||||||
sticky_mouse = MfxCheckMenuItem(self),
|
mouse_type = StringVar(),
|
||||||
mouse_undo = MfxCheckMenuItem(self),
|
mouse_undo = MfxCheckMenuItem(self),
|
||||||
negative_bottom = MfxCheckMenuItem(self),
|
negative_bottom = MfxCheckMenuItem(self),
|
||||||
pause = MfxCheckMenuItem(self),
|
pause = MfxCheckMenuItem(self),
|
||||||
|
@ -303,7 +303,7 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
tkopt.save_games_geometry.set(opt.save_games_geometry)
|
tkopt.save_games_geometry.set(opt.save_games_geometry)
|
||||||
tkopt.demo_logo.set(opt.demo_logo)
|
tkopt.demo_logo.set(opt.demo_logo)
|
||||||
tkopt.splashscreen.set(opt.splashscreen)
|
tkopt.splashscreen.set(opt.splashscreen)
|
||||||
tkopt.sticky_mouse.set(opt.sticky_mouse)
|
tkopt.mouse_type.set(opt.mouse_type)
|
||||||
tkopt.mouse_undo.set(opt.mouse_undo)
|
tkopt.mouse_undo.set(opt.mouse_undo)
|
||||||
tkopt.negative_bottom.set(opt.negative_bottom)
|
tkopt.negative_bottom.set(opt.negative_bottom)
|
||||||
for w in TOOLBAR_BUTTONS:
|
for w in TOOLBAR_BUTTONS:
|
||||||
|
@ -485,8 +485,12 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
submenu.add_radiobutton(label=n_("&Fast"), variable=self.tkopt.animations, value=1, command=self.mOptAnimations)
|
submenu.add_radiobutton(label=n_("&Fast"), variable=self.tkopt.animations, value=1, command=self.mOptAnimations)
|
||||||
submenu.add_radiobutton(label=n_("&Slow"), variable=self.tkopt.animations, value=3, command=self.mOptAnimations)
|
submenu.add_radiobutton(label=n_("&Slow"), variable=self.tkopt.animations, value=3, command=self.mOptAnimations)
|
||||||
submenu.add_radiobutton(label=n_("&Very slow"), variable=self.tkopt.animations, value=4, command=self.mOptAnimations)
|
submenu.add_radiobutton(label=n_("&Very slow"), variable=self.tkopt.animations, value=4, command=self.mOptAnimations)
|
||||||
menu.add_checkbutton(label=n_("Stick&y mouse"), variable=self.tkopt.sticky_mouse, command=self.mOptStickyMouse)
|
submenu = MfxMenu(menu, label=n_("&Mouse"))
|
||||||
menu.add_checkbutton(label=n_("Use mouse for undo/redo"), variable=self.tkopt.mouse_undo, command=self.mOptMouseUndo)
|
submenu.add_radiobutton(label=n_("&Drag-and-Drop"), variable=self.tkopt.mouse_type, value='drag-n-drop', command=self.mOptMouseType)
|
||||||
|
submenu.add_radiobutton(label=n_("&Point-and-Click"), variable=self.tkopt.mouse_type, value='point-n-click', command=self.mOptMouseType)
|
||||||
|
submenu.add_radiobutton(label=n_("&Sticky mouse"), variable=self.tkopt.mouse_type, value='sticky-mouse', command=self.mOptMouseType)
|
||||||
|
submenu.add_separator()
|
||||||
|
submenu.add_checkbutton(label=n_("Use mouse for undo/redo"), variable=self.tkopt.mouse_undo, command=self.mOptMouseUndo)
|
||||||
menu.add_separator()
|
menu.add_separator()
|
||||||
menu.add_command(label=n_("&Fonts..."), command=self.mOptFonts)
|
menu.add_command(label=n_("&Fonts..."), command=self.mOptFonts)
|
||||||
menu.add_command(label=n_("&Colors..."), command=self.mOptColors)
|
menu.add_command(label=n_("&Colors..."), command=self.mOptColors)
|
||||||
|
@ -1242,9 +1246,9 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
if self._cancelDrag(break_pause=False): return
|
if self._cancelDrag(break_pause=False): return
|
||||||
self.app.opt.splashscreen = self.tkopt.splashscreen.get()
|
self.app.opt.splashscreen = self.tkopt.splashscreen.get()
|
||||||
|
|
||||||
def mOptStickyMouse(self, *event):
|
def mOptMouseType(self, *event):
|
||||||
if self._cancelDrag(break_pause=False): return
|
if self._cancelDrag(break_pause=False): return
|
||||||
self.app.opt.sticky_mouse = self.tkopt.sticky_mouse.get()
|
self.app.opt.mouse_type = self.tkopt.mouse_type.get()
|
||||||
|
|
||||||
def mOptMouseUndo(self, *event):
|
def mOptMouseUndo(self, *event):
|
||||||
if self._cancelDrag(break_pause=False): return
|
if self._cancelDrag(break_pause=False): return
|
||||||
|
|
|
@ -82,6 +82,8 @@ class MfxCanvasImage(Canvas.ImageItem):
|
||||||
if kwargs.has_key('group'):
|
if kwargs.has_key('group'):
|
||||||
group = kwargs['group']
|
group = kwargs['group']
|
||||||
del kwargs['group']
|
del kwargs['group']
|
||||||
|
if kwargs.has_key('image'):
|
||||||
|
self._image = kwargs['image']
|
||||||
Canvas.ImageItem.__init__(self, canvas, *args, **kwargs)
|
Canvas.ImageItem.__init__(self, canvas, *args, **kwargs)
|
||||||
if group:
|
if group:
|
||||||
self.addtag(group)
|
self.addtag(group)
|
||||||
|
@ -262,7 +264,8 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
## for i in range(len(stack.cards)):
|
## for i in range(len(stack.cards)):
|
||||||
## if stack.cards[i].item.id in current:
|
## if stack.cards[i].item.id in current:
|
||||||
## return i
|
## return i
|
||||||
x, y = event.x-self.xmargin, event.y-self.ymargin
|
x = event.x-self.xmargin+self.xview()[0]*int(self.cget('width'))
|
||||||
|
y = event.y-self.ymargin+self.yview()[0]*int(self.cget('height'))
|
||||||
##x, y = event.x, event.y
|
##x, y = event.x, event.y
|
||||||
items = list(self.find_overlapping(x,y,x,y))
|
items = list(self.find_overlapping(x,y,x,y))
|
||||||
items.reverse()
|
items.reverse()
|
||||||
|
@ -334,8 +337,8 @@ class MfxCanvas(Tkinter.Canvas):
|
||||||
##ch = max(int(self.cget("height")), self.winfo_height())
|
##ch = max(int(self.cget("height")), self.winfo_height())
|
||||||
ch = self.winfo_height()
|
ch = self.winfo_height()
|
||||||
###print iw, ih, cw, ch
|
###print iw, ih, cw, ch
|
||||||
x = (cw - iw) / 2
|
x = (cw-iw)/2-self.xmargin+self.xview()[0]*int(self.cget('width'))
|
||||||
y = (ch - ih) / 2
|
y = (ch-ih)/2-self.ymargin+self.yview()[0]*int(self.cget('height'))
|
||||||
id = self._x_create("image", x, y, image=image, anchor="nw")
|
id = self._x_create("image", x, y, image=image, anchor="nw")
|
||||||
self.tk.call(self._w, "raise", id)
|
self.tk.call(self._w, "raise", id)
|
||||||
self.__tops.append(id)
|
self.__tops.append(id)
|
||||||
|
|
|
@ -39,6 +39,7 @@ __all__ = ['tkversion',
|
||||||
'EVENT_PROPAGATE',
|
'EVENT_PROPAGATE',
|
||||||
'CURSOR_DRAG',
|
'CURSOR_DRAG',
|
||||||
'CURSOR_WATCH',
|
'CURSOR_WATCH',
|
||||||
|
'CURSOR_UP_ARROW',
|
||||||
'ANCHOR_CENTER',
|
'ANCHOR_CENTER',
|
||||||
'ANCHOR_N',
|
'ANCHOR_N',
|
||||||
'ANCHOR_NW',
|
'ANCHOR_NW',
|
||||||
|
@ -81,8 +82,9 @@ TK_DASH_PATCH = 0
|
||||||
EVENT_HANDLED = "break"
|
EVENT_HANDLED = "break"
|
||||||
EVENT_PROPAGATE = None
|
EVENT_PROPAGATE = None
|
||||||
|
|
||||||
CURSOR_DRAG = "hand1"
|
CURSOR_DRAG = "hand1"
|
||||||
CURSOR_WATCH = "watch"
|
CURSOR_WATCH = "watch"
|
||||||
|
CURSOR_UP_ARROW = 'sb_up_arrow'
|
||||||
|
|
||||||
ANCHOR_CENTER = Tkinter.CENTER
|
ANCHOR_CENTER = Tkinter.CENTER
|
||||||
ANCHOR_N = Tkinter.N
|
ANCHOR_N = Tkinter.N
|
||||||
|
|
|
@ -5,11 +5,11 @@ rm -rf dist
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cp -r locale dist
|
cp -r locale dist
|
||||||
cp fc-solve.exe dist
|
cp fc-solve.exe dist
|
||||||
cp smpeg.dll dist
|
cp smpeg.dll ogg.dll vorbis.dll vorbisfile.dll dist
|
||||||
cp ogg.dll dist
|
|
||||||
cp vorbis.dll dist
|
|
||||||
cp vorbisfile.dll dist
|
|
||||||
python setup.py py2exe
|
python setup.py py2exe
|
||||||
|
cp -r data\music dist\data
|
||||||
|
rem rm -rf dist\tcl\tcl8.4\encoding
|
||||||
|
rem rm -rf dist\tcl\tk8.4\demos dist\tcl\tk8.4\images
|
||||||
python scripts\create_iss.py
|
python scripts\create_iss.py
|
||||||
"d:\Program Files\Inno Setup 5\ISCC.exe" setup.iss
|
"d:\Program Files\Inno Setup 5\ISCC.exe" setup.iss
|
||||||
pause
|
pause
|
||||||
|
|
18
setup.py
18
setup.py
|
@ -24,28 +24,34 @@ datas = [
|
||||||
for s in file('MANIFEST.in'):
|
for s in file('MANIFEST.in'):
|
||||||
if s.startswith('graft data/cardset-'):
|
if s.startswith('graft data/cardset-'):
|
||||||
datas.append(s[11:].strip())
|
datas.append(s[11:].strip())
|
||||||
elif s.startswith('include data/music/'):
|
|
||||||
datas.append(s[19:].strip())
|
|
||||||
data_files = []
|
data_files = []
|
||||||
|
|
||||||
for d in datas:
|
for d in datas:
|
||||||
for root, dirs, files in os.walk(os.path.join('data', d)):
|
for root, dirs, files in os.walk(os.path.join('data', d)):
|
||||||
|
if root.find('.svn') >= 0:
|
||||||
|
continue
|
||||||
if files:
|
if files:
|
||||||
#files = map(lambda f: os.path.join(root, f), files)
|
#files = map(lambda f: os.path.join(root, f), files)
|
||||||
files = [os.path.join(root, f) for f in files]
|
files = [os.path.join(root, f) for f in files]
|
||||||
data_files.append((os.path.join(data_dir, root[5:]), files))
|
data_files.append((os.path.join(data_dir, root[5:]), files))
|
||||||
|
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
data_files.append(('share/pixmaps', ['data/pysol.xbm', 'data/pysol.xpm']))
|
data_files.append(('share/pixmaps', ['data/pysol.xbm', 'data/pysol.xpm']))
|
||||||
for l in ('ru', 'ru_RU'):
|
for l in ('ru', 'ru_RU'):
|
||||||
data_files.append(('share/locale/%s/LC_MESSAGES' % l,
|
data_files.append(('share/locale/%s/LC_MESSAGES' % l,
|
||||||
['locale/%s/LC_MESSAGES/pysol.mo' % l]))
|
['locale/%s/LC_MESSAGES/pysol.mo' % l]))
|
||||||
|
|
||||||
long_description = """\
|
##from pprint import pprint; pprint(data_files)
|
||||||
|
|
||||||
|
long_description = '''\
|
||||||
PySol is a solitaire card game. Its features include support for many
|
PySol is a solitaire card game. Its features include support for many
|
||||||
different games, very nice look and feel, multiple cardsets and
|
different games, very nice look and feel, multiple cardsets and
|
||||||
backgrounds, unlimited undo & redo, load & save games, player
|
backgrounds, unlimited undo & redo, load & save games, player
|
||||||
statistics, hint system, demo games, support for user written plug-ins,
|
statistics, hint system, demo games, support for user written plug-ins,
|
||||||
integrated HTML help browser, and it's free Open Source software.
|
integrated HTML help browser, and it\'s free Open Source software.
|
||||||
"""
|
'''
|
||||||
|
|
||||||
kw = {
|
kw = {
|
||||||
'name' : 'PySolFC',
|
'name' : 'PySolFC',
|
||||||
'version' : VERSION,
|
'version' : VERSION,
|
||||||
|
@ -68,7 +74,7 @@ kw = {
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
kw['windows'] = [{'script': 'pysol',
|
kw['windows'] = [{'script': 'pysol',
|
||||||
'icon_resources': [(1, "data/pysol.ico")], }]
|
'icon_resources': [(1, 'data/pysol.ico')], }]
|
||||||
kw['packages'].remove('pysollib.pysolgtk')
|
kw['packages'].remove('pysollib.pysolgtk')
|
||||||
|
|
||||||
setup(**kw)
|
setup(**kw)
|
||||||
|
|
Loading…
Add table
Reference in a new issue