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

- removed app.debug variable

git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@95 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-11-13 23:59:28 +00:00
parent 7cd1031851
commit 7c17688df7
12 changed files with 51 additions and 69 deletions

View file

@ -43,6 +43,7 @@ from mfxutil import Struct, destruct, openURL
from pysolrandom import constructRandom from pysolrandom import constructRandom
from settings import PACKAGE, PACKAGE_URL from settings import PACKAGE, PACKAGE_URL
from settings import TOP_TITLE from settings import TOP_TITLE
from settings import DEBUG
from gamedb import GI from gamedb import GI
# stats imports # stats imports
@ -804,7 +805,7 @@ class PysolMenubarActions:
if self._cancelDrag(break_pause=False): return if self._cancelDrag(break_pause=False): return
if self.app.audio and self.app.opt.sound_music_volume > 0: if self.app.audio and self.app.opt.sound_music_volume > 0:
self.app.audio.playNextMusic() self.app.audio.playNextMusic()
if 1 and self.app.debug: if 1 and DEBUG:
index = self.app.audio.getMusicInfo() index = self.app.audio.getMusicInfo()
music = self.app.music_manager.get(index) music = self.app.music_manager.get(index)
if music: if music:

View file

@ -55,6 +55,7 @@ from pysolrandom import PysolRandom
from game import Game from game import Game
from gamedb import GI, GAME_DB, loadGame from gamedb import GI, GAME_DB, loadGame
from settings import TOP_SIZE, TOP_TITLE, TOOLKIT from settings import TOP_SIZE, TOP_TITLE, TOOLKIT
from settings import DEBUG
# Toolkit imports # Toolkit imports
from pysoltk import wm_withdraw, loadImage from pysoltk import wm_withdraw, loadImage
@ -499,7 +500,6 @@ class Application:
self.stats = Statistics() self.stats = Statistics()
self.comments = Comments() self.comments = Comments()
self.splashscreen = 1 self.splashscreen = 1
self.debug = 0
# visual components # visual components
self.top = None # the root toplevel window self.top = None # the root toplevel window
self.top_bg = None # default background self.top_bg = None # default background
@ -1509,7 +1509,7 @@ Please select a %s type %s.
manager = self.cardset_manager manager = self.cardset_manager
# find all available cardsets # find all available cardsets
dirs = manager.getSearchDirs(self, ("cardsets", ""), "PYSOL_CARDSETS") dirs = manager.getSearchDirs(self, ("cardsets", ""), "PYSOL_CARDSETS")
if self.debug: if DEBUG:
dirs = dirs + manager.getSearchDirs(self, "cardsets-*") dirs = dirs + manager.getSearchDirs(self, "cardsets-*")
##print dirs ##print dirs
found, t = [], {} found, t = [], {}

View file

@ -46,6 +46,7 @@ from mfxutil import format_time
from util import get_version_tuple, Timer from util import get_version_tuple, Timer
from util import ACE, QUEEN, KING from util import ACE, QUEEN, KING
from settings import PACKAGE, TOOLKIT, TOP_TITLE, VERSION, VERSION_TUPLE from settings import PACKAGE, TOOLKIT, TOP_TITLE, VERSION, VERSION_TUPLE
from settings import DEBUG
from gamedb import GI from gamedb import GI
from resource import CSI from resource import CSI
from pysolrandom import PysolRandom, LCRandom31 from pysolrandom import PysolRandom, LCRandom31
@ -178,7 +179,7 @@ class Game:
if self.s.talon: if self.s.talon:
assert hasattr(self.s.talon, "round") assert hasattr(self.s.talon, "round")
assert hasattr(self.s.talon, "max_rounds") assert hasattr(self.s.talon, "max_rounds")
if self.app.debug: if DEBUG:
self._checkGame() self._checkGame()
# optimize regions # optimize regions
self.optimizeRegions() self.optimizeRegions()
@ -193,7 +194,7 @@ class Game:
# update display properties # update display properties
self.top.wm_geometry("") # cancel user-specified geometry self.top.wm_geometry("") # cancel user-specified geometry
self.canvas.setInitialSize(self.width, self.height) self.canvas.setInitialSize(self.width, self.height)
if self.app.debug >= 4: if DEBUG >= 4:
MfxCanvasRectangle(self.canvas, 0, 0, self.width, self.height, MfxCanvasRectangle(self.canvas, 0, 0, self.width, self.height,
width=2, fill=None, outline='green') width=2, fill=None, outline='green')
# restore game geometry # restore game geometry
@ -941,8 +942,6 @@ class Game:
def animatedMoveTo(self, from_stack, to_stack, cards, x, y, tkraise=1, frames=-1, shadow=-1): def animatedMoveTo(self, from_stack, to_stack, cards, x, y, tkraise=1, frames=-1, shadow=-1):
if self.app.opt.animations == 0 or frames == 0: if self.app.opt.animations == 0 or frames == 0:
return return
if self.app.debug and not self.top.winfo_ismapped():
return
# init timer - need a high resolution for this to work # init timer - need a high resolution for this to work
clock, delay, skip = None, 1, 1 clock, delay, skip = None, 1, 1
if self.app.opt.animations >= 2: if self.app.opt.animations >= 2:
@ -1016,8 +1015,6 @@ class Game:
### return ### return
if not self.app.opt.animations: if not self.app.opt.animations:
return return
if self.app.debug and not self.top.winfo_ismapped():
return
self.top.busyUpdate() self.top.busyUpdate()
self.canvas.update_idletasks() self.canvas.update_idletasks()
old_a = self.app.opt.animations old_a = self.app.opt.animations
@ -1108,7 +1105,7 @@ class Game:
def setRegion(self, stacks, rect, priority=0): def setRegion(self, stacks, rect, priority=0):
assert len(stacks) > 0 assert len(stacks) > 0
assert len(rect) == 4 and rect[0] < rect[2] and rect[1] < rect[3] assert len(rect) == 4 and rect[0] < rect[2] and rect[1] < rect[3]
if self.app.debug >= 2: if DEBUG >= 2:
MfxCanvasRectangle(self.canvas, rect[0], rect[1], rect[2], rect[3], MfxCanvasRectangle(self.canvas, rect[0], rect[1], rect[2], rect[3],
width=2, fill=None, outline='red') width=2, fill=None, outline='red')
for s in stacks: for s in stacks:
@ -1751,7 +1748,7 @@ for %d moves.
assert to_stack.acceptsCards(from_stack, from_stack.cards[-ncards:]) assert to_stack.acceptsCards(from_stack, from_stack.cards[-ncards:])
if sleep <= 0.0: if sleep <= 0.0:
return h return h
info = (level == 1) or (level > 1 and self.app.debug >= 3) info = (level == 1) or (level > 1 and DEBUG >= 3)
if info and self.app.statusbar and self.app.opt.statusbar: if info and self.app.statusbar and self.app.opt.statusbar:
self.app.statusbar.configLabel("info", text=_("Score %6d") % (score), fg=text_color) self.app.statusbar.configLabel("info", text=_("Score %6d") % (score), fg=text_color)
else: else:
@ -1843,8 +1840,8 @@ for %d moves.
timeout = 10000 timeout = 10000
if player_moves == 0: if player_moves == 0:
timeout = 5000 timeout = 5000
if 0 and self.app.debug and self.demo.mixed: ## if 0 and DEBUG and self.demo.mixed:
timeout = 1000 ## timeout = 1000
if self.isGameWon(): if self.isGameWon():
finished = 1 finished = 1
self.stopPlayTimer() self.stopPlayTimer()
@ -1863,7 +1860,7 @@ for %d moves.
##s = self.app.miscrandom.choice((_("&OK"), _("&OK"))) ##s = self.app.miscrandom.choice((_("&OK"), _("&OK")))
s = _("&OK") s = _("&OK")
text = _("\nGame finished\n") text = _("\nGame finished\n")
if self.app.debug: if DEBUG:
text += "\nplayer_moves: %d\ndemo_moves: %d\n" % (self.stats.player_moves, self.stats.demo_moves) text += "\nplayer_moves: %d\ndemo_moves: %d\n" % (self.stats.player_moves, self.stats.demo_moves)
d = MfxMessageDialog(self.top, title=PACKAGE+_(" Autopilot"), d = MfxMessageDialog(self.top, title=PACKAGE+_(" Autopilot"),
text=text, bitmap=bitmap, strings=(s,), text=text, bitmap=bitmap, strings=(s,),
@ -1885,7 +1882,7 @@ for %d moves.
status = d.status status = d.status
if finished: if finished:
self.updateStats(demo=1) self.updateStats(demo=1)
if self.demo and status == 2 and not self.app.debug: if self.demo and status == 2:
# timeout in dialog # timeout in dialog
if self.stats.demo_moves > self.demo.start_demo_moves: if self.stats.demo_moves > self.demo.start_demo_moves:
# we only increase the splash-screen counter if the last # we only increase the splash-screen counter if the last
@ -1898,7 +1895,7 @@ for %d moves.
# timeout in dialog - start another demo # timeout in dialog - start another demo
demo = self.demo demo = self.demo
id = self.id id = self.id
if 1 and demo.mixed and self.app.debug: if 1 and demo.mixed and DEBUG:
# debug - advance game id to make sure we hit all games # debug - advance game id to make sure we hit all games
gl = self.app.gdb.getGamesIdSortedById() gl = self.app.gdb.getGamesIdSortedById()
##gl = self.app.gdb.getGamesIdSortedByName() ##gl = self.app.gdb.getGamesIdSortedByName()
@ -1922,7 +1919,7 @@ for %d moves.
self.quitGame(id, startdemo=1) self.quitGame(id, startdemo=1)
else: else:
self.stopDemo() self.stopDemo()
if 0 and self.app.debug: if DEBUG >= 10:
# debug - only for testing winAnimation() # debug - only for testing winAnimation()
self.endGame() self.endGame()
self.winAnimation() self.winAnimation()
@ -1939,9 +1936,6 @@ for %d moves.
# we're probably looping because of some bug in the hint code # we're probably looping because of some bug in the hint code
return 1 return 1
sleep = demo.sleep sleep = demo.sleep
if self.app.debug:
if not self.top.winfo_ismapped():
sleep = -1.0
# first try to deal cards to the Waste (unless there was a forced move) # first try to deal cards to the Waste (unless there was a forced move)
if not demo.hint or not demo.hint[6]: if not demo.hint or not demo.hint[6]:
if self._autoDeal(sound=0): if self._autoDeal(sound=0):

View file

@ -109,9 +109,6 @@ class VegasKlondike(Klondike):
b1, b2 = self.app.stats.gameid_balance, 0 b1, b2 = self.app.stats.gameid_balance, 0
if self.shallUpdateBalance(): if self.shallUpdateBalance():
b2 = self.getGameBalance() b2 = self.getGameBalance()
if 0 and self.app.debug:
t = "Balance %d/%d" % (b1, b2)
else:
t = _("Balance $%d") % (b1 + b2) t = _("Balance $%d") % (b1 + b2)
self.texts.score.config(text=t) self.texts.score.config(text=t)

View file

@ -48,8 +48,7 @@ from app import Application
from pysolaudio import thread, pysolsoundserver from pysolaudio import thread, pysolsoundserver
from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient
from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient
import settings from settings import PACKAGE, SOUND_MOD
PACKAGE, SOUND_MOD = settings.PACKAGE, settings.SOUND_MOD
# Toolkit imports # Toolkit imports
from pysoltk import wm_withdraw, loadImage from pysoltk import wm_withdraw, loadImage
@ -92,7 +91,6 @@ def parse_option(argv):
"french-only", "french-only",
"noplugins", "noplugins",
"nosound", "nosound",
"debug=",
"sound-mod=", "sound-mod=",
"help"]) "help"])
except getopt.GetoptError, err: except getopt.GetoptError, err:
@ -110,7 +108,6 @@ def parse_option(argv):
"noplugins" : False, "noplugins" : False,
"nosound" : False, "nosound" : False,
"sound-mod" : None, "sound-mod" : None,
"debug" : None,
} }
for i in optlist: for i in optlist:
if i[0] in ("-h", "--help"): if i[0] in ("-h", "--help"):
@ -136,11 +133,6 @@ def parse_option(argv):
elif i[0] == "--sound-mod": elif i[0] == "--sound-mod":
assert i[1] in ('pss', 'pygame', 'oss', 'win') assert i[1] in ('pss', 'pygame', 'oss', 'win')
opts["sound-mod"] = i[1] opts["sound-mod"] = i[1]
elif i[0] in ("-D", "--debug"):
try:
opts["debug"] = int(i[1])
except:
print >> sys.stderr, 'WARNING: invalid argument for debug'
if opts["help"]: if opts["help"]:
print _("""Usage: %s [OPTIONS] [FILE] print _("""Usage: %s [OPTIONS] [FILE]
@ -206,9 +198,6 @@ def pysol_init(app, args):
app.commandline.gameid = int(opts['gameid']) app.commandline.gameid = int(opts['gameid'])
except: except:
print >> sys.stderr, 'WARNING: invalid game id:', opts['gameid'] print >> sys.stderr, 'WARNING: invalid game id:', opts['gameid']
if not opts['debug'] is None:
settings.DEBUG = opts['debug']
app.debug = settings.DEBUG
# init games database # init games database
import games import games
@ -341,7 +330,7 @@ Please check your %s installation.
if music: if music:
app.music_playlist = list(music)[:] app.music_playlist = list(music)[:]
app.miscrandom.shuffle(app.music_playlist) app.miscrandom.shuffle(app.music_playlist)
if 1: ## and not app.debug: if 1:
for m in app.music_playlist: for m in app.music_playlist:
if m.name.lower() == "bye_for_now": if m.name.lower() == "bye_for_now":
app.music_playlist.remove(m) app.music_playlist.remove(m)

View file

@ -209,8 +209,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
r = self.cmd("protocol 6") r = self.cmd("protocol 6")
if r != 0: if r != 0:
return 0 return 0
if 0 and self.app.debug: ##self.cmd("debug 1")
self.cmd("debug 1")
return 1 return 1
# disconnect and stop server # disconnect and stop server

View file

@ -407,7 +407,6 @@ class SelectGameDialogWithPreview(MfxDialog):
canvas = canvas, canvas = canvas,
cardset = self.app.cardset.copy(), cardset = self.app.cardset.copy(),
comments = self.app.comments.new(), comments = self.app.comments.new(),
debug = 0,
gamerandom = self.app.gamerandom, gamerandom = self.app.gamerandom,
gdb = self.app.gdb, gdb = self.app.gdb,
gimages = self.app.gimages, gimages = self.app.gimages,

View file

@ -41,6 +41,7 @@ import sys, os, glob, operator, types
# PySol imports # PySol imports
from mfxutil import Struct, KwStruct, EnvError, latin1_to_ascii from mfxutil import Struct, KwStruct, EnvError, latin1_to_ascii
from settings import PACKAGE, VERSION from settings import PACKAGE, VERSION
from settings import DEBUG
# /*********************************************************************** # /***********************************************************************
@ -159,7 +160,7 @@ class ResourceManager:
self._addDir(result, os.path.join(dir, s)) self._addDir(result, os.path.join(dir, s))
except EnvError, ex: except EnvError, ex:
pass pass
if app.debug >= 5: if DEBUG >= 5:
print "getSearchDirs", env, search, "->", result print "getSearchDirs", env, search, "->", result
return result return result
@ -289,18 +290,6 @@ class CSI:
22: "2200 - 2299", 22: "2200 - 2299",
} }
## #
## TYPE_NAME = {}
## def create_csi_type_name():
## for id, type in CSI.TYPE.items():
## i = type.find('type')
## if i > 0:
## CSI.TYPE_NAME[id] = type[:i-1]
## else:
## CSI.TYPE_NAME[id] = type
## if not CSI.TYPE_NAME:
## create_csi_type_name()
class CardsetConfig(Struct): class CardsetConfig(Struct):
# see config.txt and _readCardsetConfig() # see config.txt and _readCardsetConfig()

View file

@ -29,15 +29,29 @@ PACKAGE = 'PySol'
PACKAGE_URL = 'http://sourceforge.net/projects/pysolfc/' PACKAGE_URL = 'http://sourceforge.net/projects/pysolfc/'
VERSION = '4.82' VERSION = '4.82'
FC_VERSION = '0.9.4' FC_VERSION = '0.9.5'
VERSION_TUPLE = (4, 82) VERSION_TUPLE = (4, 82)
# toolkit
TOOLKIT = 'tk' # or 'gtk' TOOLKIT = 'tk' # or 'gtk'
USE_TILE = 'auto' # or True or False USE_TILE = 'auto' # or True or False
TILE_THEME = 'default' # name of tile's theme # name of tile's theme
# available values:
# 'default', 'alt', 'classic', 'clam', 'step', 'blue' (all)
# 'winnative', 'xpnative' (windows)
# 'aqua' (macosx)
TILE_THEME = 'default'
if os.name == 'nt': if os.name == 'nt':
TILE_THEME = 'winnative' TILE_THEME = 'winnative'
SOUND_MOD = 'auto' # or 'pss', 'pygame', 'oss', 'win', 'none'
# sound
# available values:
# 'pss' - PySol-Sound-Server (all)
# 'pygame' - PyGame (all)
# 'oss' (*nix)
# 'win' (windows)
# 'none' - disable
SOUND_MOD = 'auto'
# data dirs # data dirs
DATA_DIRS = [] DATA_DIRS = []
@ -57,5 +71,6 @@ if os.name == 'mac':
TOP_SIZE = 10 TOP_SIZE = 10
TOP_TITLE = n_('Top 10') TOP_TITLE = n_('Top 10')
# debug
DEBUG = 0 # must be integer DEBUG = 0 # must be integer
CHECK_GAMES = False CHECK_GAMES = False # check duplicated names and classes

View file

@ -107,6 +107,7 @@ from pysoltk import MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle, MfxCanva
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
from settings import DEBUG
# /*********************************************************************** # /***********************************************************************
@ -777,15 +778,15 @@ class Stack:
format = "%d" format = "%d"
if format: if format:
t = format % len(self.cards) t = format % len(self.cards)
if 0 and self.game.app.debug >= 4: ## if 0:
visible = 0 ## visible = 0
for c in self.cards: ## for c in self.cards:
if c.isHidden(): ## if c.isHidden():
assert c.hide_stack is not None ## assert c.hide_stack is not None
else: ## else:
visible = visible + 1 ## visible = visible + 1
assert c.hide_stack is None ## assert c.hide_stack is None
t = t + " (%d)" % visible ## t = t + " (%d)" % visible
self.texts.ncards.config(text=t) self.texts.ncards.config(text=t)
def basicShallHighlightSameRank(self, card): def basicShallHighlightSameRank(self, card):
@ -1412,7 +1413,7 @@ class Stack:
return s return s
def getNumCards(self): def getNumCards(self):
if self.game.app.debug >= 5: if DEBUG >= 5:
t = repr(self)+' ' t = repr(self)+' '
else: else:
t = '' t = ''

View file

@ -454,7 +454,6 @@ class SelectGameDialogWithPreview(SelectGameDialog):
canvas = canvas, canvas = canvas,
cardset = self.app.cardset.copy(), cardset = self.app.cardset.copy(),
comments = self.app.comments.new(), comments = self.app.comments.new(),
debug = 0,
gamerandom = self.app.gamerandom, gamerandom = self.app.gamerandom,
gdb = self.app.gdb, gdb = self.app.gdb,
gimages = self.app.gimages, gimages = self.app.gimages,

View file

@ -455,7 +455,6 @@ class SelectGameDialogWithPreview(SelectGameDialog):
canvas = canvas, canvas = canvas,
cardset = self.app.cardset.copy(), cardset = self.app.cardset.copy(),
comments = self.app.comments.new(), comments = self.app.comments.new(),
debug = 0,
gamerandom = self.app.gamerandom, gamerandom = self.app.gamerandom,
gdb = self.app.gdb, gdb = self.app.gdb,
gimages = self.app.gimages, gimages = self.app.gimages,