annotate demos/pychan_demo/sliders.py @ 546:8fee2d2286e9

Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 03 Jun 2010 21:35:06 +0000
parents 70697641fca3
children 8c9cdcc9bc4f
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
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
24 from pychan_test import 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
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,
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
35 '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
36 })
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 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
38 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
39 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
40 """
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 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
42 """
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 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
44 # 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
45 # 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
46 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
47 # 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
48 # 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
49 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
50 '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
51 '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
52 })