Mercurial > fife-parpg
annotate demos/pychan_demo/sliders.py @ 645:291ba2946c73
* Added the ability to normalize a 2D and 3D point.
* You can now rotate a 2D point around the origin or a specific point.
* Modified the shooter demo to use the new point functionality.
* Removed the fife_math extension.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 12 Oct 2010 18:58:47 +0000 |
parents | c770794d0a4a |
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 |
395
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
3 # #################################################################### |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
4 # Copyright (C) 2005-2009 by the FIFE team |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
5 # http://www.fifengine.de |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
6 # This file is part of FIFE. |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
7 # |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
12 # |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
16 # Lesser General Public License for more details. |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
17 # |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
19 # License along with this library; if not, write to the |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
20 # Free Software Foundation, Inc., |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
22 # #################################################################### |
70697641fca3
Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
378
diff
changeset
|
23 |
613
8c9cdcc9bc4f
Renaming pychan_test.py to pychan_demo.py to make it a bit more obvious which file to execute.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
395
diff
changeset
|
24 from pychan_demo import PyChanExample |
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
|
25 from fife.extensions import pychan |
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 class SliderExample(PyChanExample): |
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 def __init__(self): |
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
|
29 super(SliderExample,self).__init__('gui/slider.xml') |
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
|
30 def start(self): |
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
|
31 self.widget = pychan.loadXML(self.xmlFile) |
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
|
32 self.widget.mapEvents({ |
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 'xslider': self.update, |
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 'yslider': self.update, |
616
c770794d0a4a
Added a simple percentage bar widget along with a quick demo in the sliders portion of the pychan_demo. Note: I have not tested the foreground image feature yet. fixes[t:411]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
613
diff
changeset
|
35 'pbarslider' : self.update, |
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
|
36 'closeButton':self.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
|
37 }) |
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 self.update() |
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 self.widget.show() |
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 def update(self): |
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
|
41 """ |
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
|
42 Update Icon position from the sliders. |
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 icon = self.widget.findChild(name="icon") |
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 # sliders have floats, guichan is picky and wants ints |
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
|
46 # so we convert here. |
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 icon.position = map(int, self.widget.collectData('xslider','yslider')) |
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
|
48 # we distribute to the labels with the x,y value. |
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 # That's user visible 'text' - so pychan wants unicode. |
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 self.widget.distributeInitialData({ |
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 'xvalue' : unicode(icon.x), |
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 'yvalue' : unicode(icon.y), |
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 }) |
616
c770794d0a4a
Added a simple percentage bar widget along with a quick demo in the sliders portion of the pychan_demo. Note: I have not tested the foreground image feature yet. fixes[t:411]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
613
diff
changeset
|
54 |
c770794d0a4a
Added a simple percentage bar widget along with a quick demo in the sliders portion of the pychan_demo. Note: I have not tested the foreground image feature yet. fixes[t:411]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
613
diff
changeset
|
55 #quick demo to show the percentage bar in action |
c770794d0a4a
Added a simple percentage bar widget along with a quick demo in the sliders portion of the pychan_demo. Note: I have not tested the foreground image feature yet. fixes[t:411]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
613
diff
changeset
|
56 pbarslider = self.widget.findChild(name="pbarslider") |
c770794d0a4a
Added a simple percentage bar widget along with a quick demo in the sliders portion of the pychan_demo. Note: I have not tested the foreground image feature yet. fixes[t:411]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
613
diff
changeset
|
57 pbar = self.widget.findChild(name="pbar") |
c770794d0a4a
Added a simple percentage bar widget along with a quick demo in the sliders portion of the pychan_demo. Note: I have not tested the foreground image feature yet. fixes[t:411]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
613
diff
changeset
|
58 |
c770794d0a4a
Added a simple percentage bar widget along with a quick demo in the sliders portion of the pychan_demo. Note: I have not tested the foreground image feature yet. fixes[t:411]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
613
diff
changeset
|
59 pbar.value = int(pbarslider.getValue()) |