Mercurial > fife-parpg
annotate engine/python/fife/extensions/fife_timer.py @ 642:6e2151325017
* Added the ability to query the current running screen mode
* Added a method to detect the closest supported screen mode (not complete yet). If no matching screen modes are detected an exception is thrown.
* Small change to the way the screen is initialized. The screen mode now MUST be in the supported screen mode list before the screen will initialize.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 08 Oct 2010 21:22:02 +0000 |
parents | eab690c748a3 |
children |
rev | line source |
---|---|
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # #################################################################### |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
4 # Copyright (C) 2005-2010 by the FIFE team |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
5 # http://www.fifengine.net |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 """ |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 Convenient timers |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 ================= |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 Usage:: |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
29 import fife.extensions.fife_timer |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
30 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
31 fife_timer.init( my_fife_engine.getTimeManager() ) |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
32 |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 def spam(): |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 print "SPAM SPAM ", |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
35 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
36 repeater = fife_timer.repeatCall(500,spam) |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
37 |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 def stop_spam(): |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 repeater.stop() |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 print "BACON EGGS AND SPAM" |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
41 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
42 delayed = fife_timer.delayCall(50000,stop_spam) |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 """ |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 |
495
ae9f5383f5b1
Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
494
diff
changeset
|
46 from fife import fife |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
48 #global time manager |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 _manager = None |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 def init(timemanager): |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 """ |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 Initialize timers. |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 @param timemanager: A L{fife.TimeManager} as retuned by L{fife.Engine.getTimeManager}. |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 """ |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 global _manager |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 _manager = timemanager |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 class Timer(fife.TimeEvent): |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
61 """ |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
62 Timer |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
63 |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
64 This class wraps the fife.TimeEvent class to make it easily usable from Python |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
65 It allows for a TimeEvent to be executed once or multiple times. |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
66 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
67 Remember FIFE::TimeManager does NOT delete the timer so make sure you keep a reference |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
68 to this timer to ensure python doesnt delete the timer prematurely. |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
69 """ |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
70 def __init__(self,delay=0,callback=None,repeat=0): |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
71 """ |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
72 @param delay: The delay in milliseconds to execute the callback |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
73 @param callback: The function to execute when the time delay has passed |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
74 @param repeat: The number of times to execute the callback. 1=once, 0=forever |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
75 """ |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
76 super(Timer,self).__init__(delay) |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
77 self._active = False |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
78 self._callback = callback |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
79 self._manager = _manager |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 self.setPeriod(delay) |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
81 self._repeat = repeat |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
82 self._executed = 0 |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
83 |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 def start(self): |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
85 """ |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
86 Call this to start the timer. |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
87 |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
88 This registers the timer with the time manager. The time manger then |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
89 calls the timers updateEvent() function when the delay time has passed. |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
90 """ |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
91 if self._active: |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 return |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
93 self._active = True |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
94 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
95 self._executed = 0 |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
96 |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
97 self.setLastUpdateTime(self._manager.getTime()) |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
98 self._manager.registerEvent(self) |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
99 |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 def stop(self): |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
101 """ |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
102 Stops the timer |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
103 |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
104 This unregisters the timer from the time manager. |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
105 """ |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
106 if not self._active: |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 return |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
108 |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
109 self._active = False |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
110 self._manager.unregisterEvent(self) |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
111 |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 def updateEvent(self,delta): |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
113 """ |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
114 This is called by FIFE::TimeManager when the delay has passed. |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
115 |
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
116 Should not be called directly. |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
117 """ |
606
a5c890f0e757
This is a temporary fix for the timer issue which causes random segfaults. Timers are no longer deleted prematurely.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
508
diff
changeset
|
118 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
119 if self._repeat != 0: |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
120 self._executed += 1 |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
121 if self._executed >= self._repeat: |
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
122 self.stop() |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 |
507
d6de9ab3ce2a
Fixed a small problem with the fife timer library. There was a problem with UH when clicking on certain buttons on the main menu which cased a hang/crash. The timer now stops itself before executing the callback.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
495
diff
changeset
|
124 if callable(self._callback): |
d6de9ab3ce2a
Fixed a small problem with the fife timer library. There was a problem with UH when clicking on certain buttons on the main menu which cased a hang/crash. The timer now stops itself before executing the callback.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
495
diff
changeset
|
125 self._callback() |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
126 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
127 def _setDelay(self, delay): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
128 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
129 Sets how many milliseconds to wait before executing the callback. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
130 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
131 The timer must not be active to change this value |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
132 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
133 @param delay: Number of milliseconds to wait before executing the callback. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
134 @type delay: C{integer} |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
135 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
136 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
137 if not self._active: |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
138 self.setPeriod(delay) |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
139 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
140 def _getDelay(self): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
141 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
142 Returns the number of milliseconds to wait before executing the callback. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
143 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
144 @return: Number of milliseconds. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
145 @rtype: C{integer} |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
146 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
147 return self.getPeriod() |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
148 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
149 def _setCallback(self, callback): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
150 self._callback = callback |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
151 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
152 def _getCallback(self): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
153 return self._callback |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
154 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
155 def _setRepeat(self, repeat): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
156 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
157 Sets how many times the timer should be repeated. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
158 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
159 The timer must not be active to change it's repeat value. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
160 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
161 @param repeat: Number of times to repeat the timer. 0=forever, 1=once. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
162 @type repeat: C{integer} |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
163 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
164 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
165 if not self._active: |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
166 self._repeat = repeat |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
167 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
168 def _getRepeat(self, repeat): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
169 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
170 Returns the number of times the timer will be executed. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
171 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
172 @return: Number of times the timer will be executed. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
173 @rtype: C{integer} |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
174 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
175 return self._repeat |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
176 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
177 def _getActive(self): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
178 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
179 Returns True if the timer is active and False if it is not. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
180 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
181 @return: True if timer is active, False if it is not. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
182 @rtype: C{boolean} |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
183 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
184 return self._active |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
185 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
186 def _getNumExecuted(self): |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
187 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
188 Returns the number of times the timer has been executed |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
189 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
190 @return: Number of times the timer has been executed |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
191 @rtype: C{integer} |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
192 """ |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
193 return self._executed |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
194 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
195 delay = property(_getDelay, _setDelay) |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
196 callback = property(_getCallback, _setCallback) |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
197 repeat = property(_getRepeat, _setRepeat) |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
198 active = property(_getActive) |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
199 numexecuted = property(_getNumExecuted) |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
200 |
507
d6de9ab3ce2a
Fixed a small problem with the fife timer library. There was a problem with UH when clicking on certain buttons on the main menu which cased a hang/crash. The timer now stops itself before executing the callback.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
495
diff
changeset
|
201 |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 def delayCall(delay,callback): |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 """ |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
204 Delay a function call by a number of milliseconds. |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
205 |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
206 Remember to keep a reference to the timer this function returns. If you |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
207 do not python will delete the timer prematurely which may case a segfault. |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
209 @param delay: Delay in milliseconds. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
210 @param callback: The function to call. |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
211 |
495
ae9f5383f5b1
Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
494
diff
changeset
|
212 @return: The timer. |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
213 @rtype: L{Timer} |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
214 """ |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
215 timer = Timer(delay, callback, 1) |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
216 timer.start() |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 return timer |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
219 |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
220 def repeatCall(period,callback): |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 """ |
495
ae9f5383f5b1
Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
494
diff
changeset
|
222 Repeat a function call. The call is repeated until the timer is stopped. |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 |
607
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
224 Remember to keep a reference to the timer this function returns. If you |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
225 do not python will delete the timer prematurely which may case a segfault. |
eab690c748a3
This is a more permanent fix for the timer issues. Pychan was using the timers incorrectly. This has now been fixed. It has eliminated the need to have global lists of timers in fife_timer. This has not been tested extensivly.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
606
diff
changeset
|
226 |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
227 @param period: Period between calls in milliseconds. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
228 @param callback: The function to call. |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
229 |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
230 @return: The timer. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
231 @rtype: L{Timer} |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
232 """ |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
233 timer = Timer(period, callback, 0) |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
234 timer.start() |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
235 return timer |
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
236 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
488
diff
changeset
|
237 __all__ = ['init','Timer','delayCall','repeatCall'] |
378
64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
238 |