Mercurial > fife-parpg
annotate clients/rio_de_hola/scripts/world.py @ 363:714673208050
Adding the CameraEdit plugin to the editor. You must enable it in your settings.xml file. Still not fully tested.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 21 Oct 2009 15:19:59 +0000 |
parents | 51cc05d862f2 |
children |
rev | line source |
---|---|
245
ed1565a5a2a0
Fixed second camera in rio.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
129
diff
changeset
|
1 # -*- coding: utf-8 -*- |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 import fife, math, random |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 import pychan |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 import pychan.widgets as widgets |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 |
98
214e3eb81eb2
better structure for techdemo scripts + svn:ignore fixes
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
48
diff
changeset
|
6 from scripts.common.eventlistenerbase import EventListenerBase |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 from loaders import loadMapFile |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 from savers import saveMapFile |
98
214e3eb81eb2
better structure for techdemo scripts + svn:ignore fixes
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
48
diff
changeset
|
9 from agents.hero import Hero |
214e3eb81eb2
better structure for techdemo scripts + svn:ignore fixes
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
48
diff
changeset
|
10 from agents.girl import Girl |
214e3eb81eb2
better structure for techdemo scripts + svn:ignore fixes
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
48
diff
changeset
|
11 from agents.cloud import Cloud |
214e3eb81eb2
better structure for techdemo scripts + svn:ignore fixes
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
48
diff
changeset
|
12 from agents.beekeeper import Beekeeper |
214e3eb81eb2
better structure for techdemo scripts + svn:ignore fixes
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
48
diff
changeset
|
13 from agents.agent import create_anonymous_agents |
121
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
14 from settings import Setting |
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
15 |
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
16 TDS = Setting() |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 class MapListener(fife.MapChangeListener): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 def __init__(self, map): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 fife.MapChangeListener.__init__(self) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 map.addChangeListener(self) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
22 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 def onMapChanged(self, map, changedLayers): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 return |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 print "Changes on map ", map.getId() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 for layer in map.getLayers(): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 print layer.getId() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 print " ", ["%s, %x" % (i.getObject().getId(), i.getChangeInfo()) for i in layer.getChangedInstances()] |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
29 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 def onLayerCreate(self, map, layer): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 pass |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
32 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 def onLayerDelete(self, map, layer): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 pass |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 class World(EventListenerBase): |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
38 """ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
39 The world! |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
40 |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
41 This class handles: |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
42 setup of map view (cameras ...) |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
43 loading the map |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
44 GUI for right clicks |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
45 handles mouse/key events which aren't handled by the GUI. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
46 ( by inheriting from EventlistenerBase ) |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
47 |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
48 That's obviously too much, and should get factored out. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
49 """ |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 def __init__(self, engine): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 super(World, self).__init__(engine, regMouse=True, regKeys=True) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 self.engine = engine |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 self.eventmanager = engine.getEventManager() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 self.model = engine.getModel() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 self.view = self.engine.getView() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 self.filename = '' |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 self.pump_ctr = 0 # for testing purposis |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 self.ctrldown = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 self.instancemenu = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 self.instance_to_agent = {} |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 self.dynamic_widgets = {} |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
62 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 def show_instancemenu(self, clickpoint, instance): |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
64 """ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
65 Build and show a popupmenu for an instance that the player |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
66 clicked on. The available actions are dynamically added to |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
67 the menu (and mapped to the onXYZ functions). |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
68 """ |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 if instance.getFifeId() == self.hero.agent.getFifeId(): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 return |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
71 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
72 # Create the popup. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
73 self.build_instancemenu() |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 self.instancemenu.clickpoint = clickpoint |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 self.instancemenu.instance = instance |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
76 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
77 # Add the buttons according to circumstances. |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 self.instancemenu.addChild(self.dynamic_widgets['inspectButton']) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 target_distance = self.hero.agent.getLocationRef().getLayerDistanceTo(instance.getLocationRef()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 if target_distance > 3.0: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 self.instancemenu.addChild(self.dynamic_widgets['moveButton']) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 if self.instance_to_agent.has_key(instance.getFifeId()): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 self.instancemenu.addChild(self.dynamic_widgets['talkButton']) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 self.instancemenu.addChild(self.dynamic_widgets['kickButton']) |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
86 # And show it :) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 self.instancemenu.position = (clickpoint.x, clickpoint.y) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 self.instancemenu.show() |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
89 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
90 def build_instancemenu(self): |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
91 """ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
92 Just loads the menu from an XML file |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
93 and hooks the events up. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
94 The buttons are removed and later re-added if appropiate. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
95 """ |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
96 self.hide_instancemenu() |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
97 dynamicbuttons = ('moveButton', 'talkButton', 'kickButton', 'inspectButton') |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
98 self.instancemenu = pychan.loadXML('gui/instancemenu.xml') |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
99 self.instancemenu.mapEvents({ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
100 'moveButton' : self.onMoveButtonPress, |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
101 'talkButton' : self.onTalkButtonPress, |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
102 'kickButton' : self.onKickButtonPress, |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
103 'inspectButton' : self.onInspectButtonPress, |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
104 }) |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
105 for btn in dynamicbuttons: |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
106 self.dynamic_widgets[btn] = self.instancemenu.findChild(name=btn) |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
107 self.instancemenu.removeAllChildren() |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
108 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 def hide_instancemenu(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 if self.instancemenu: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 self.instancemenu.hide() |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
112 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 def reset(self): |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
114 """ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
115 Clear the agent information and reset the moving secondary camera state. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
116 """ |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 self.map, self.agentlayer = None, None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 self.cameras = {} |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 self.hero, self.girl, self.clouds, self.beekeepers = None, None, [], [] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 self.cur_cam2_x, self.initial_cam2_x, self.cam2_scrolling_right = 0, 0, True |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 self.target_rotation = 0 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 self.instance_to_agent = {} |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 def load(self, filename): |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
125 """ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
126 Load a xml map and setup agents and cameras. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
127 """ |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 self.filename = filename |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 self.reset() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 self.map = loadMapFile(filename, self.engine) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 self.maplistener = MapListener(self.map) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
132 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
133 self.initAgents() |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
134 self.initCameras() |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
135 |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
136 def initAgents(self): |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
137 """ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
138 Setup agents. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
139 |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
140 For this techdemo we have a very simple 'active things on the map' model, |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
141 which is called agents. All rio maps will have a separate layer for them. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
142 |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
143 Note that we keep a mapping from map instances (C++ model of stuff on the map) |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
144 to the python agents for later reference. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
145 """ |
5
427bb0de3e29
small fixes to techdemo to enable usage of beach map. Still segfaults when enabled from settings.py
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
146 self.agentlayer = self.map.getLayer('TechdemoMapGroundObjectLayer') |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
147 self.hero = Hero(self.model, 'PC', self.agentlayer) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
148 self.instance_to_agent[self.hero.agent.getFifeId()] = self.hero |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
149 self.hero.start() |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
150 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
151 self.girl = Girl(self.model, 'NPC:girl', self.agentlayer) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
152 self.instance_to_agent[self.girl.agent.getFifeId()] = self.girl |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
153 self.girl.start() |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
154 |
48
097996ee0b3d
fixed talk functionality in techdemo
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
20
diff
changeset
|
155 self.beekeepers = create_anonymous_agents(self.model, 'beekeeper', self.agentlayer, Beekeeper) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
156 for beekeeper in self.beekeepers: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
157 self.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
158 beekeeper.start() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
159 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
160 # Clouds are currently defunct. |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
161 cloudlayer = self.map.getLayer('TechdemoMapTileLayer') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
162 self.clouds = create_anonymous_agents(self.model, 'Cloud', cloudlayer, Cloud) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
163 for cloud in self.clouds: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
164 cloud.start(0.1, 0.05) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
165 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
166 |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
167 def initCameras(self): |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
168 """ |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
169 Before we can actually see something on screen we have to specify the render setup. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
170 This is done through Camera objects which offer a viewport on the map. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
171 |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
172 For this techdemo two cameras are used. One follows the hero(!) via 'attach' |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
173 the other one scrolls around a bit (see the pump function). |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
174 """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
247
diff
changeset
|
175 camera_prefix = self.filename.rpartition('.')[0] # Remove file extension |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
247
diff
changeset
|
176 camera_prefix = camera_prefix.rpartition('/')[2] # Remove path |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
247
diff
changeset
|
177 camera_prefix += '_' |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
247
diff
changeset
|
178 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 for cam in self.view.getCameras(): |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
247
diff
changeset
|
180 camera_id = cam.getId().replace(camera_prefix, '') |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
247
diff
changeset
|
181 self.cameras[camera_id] = cam |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
247
diff
changeset
|
182 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
183 self.cameras['main'].attach(self.hero.agent) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
184 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 self.view.resetRenderers() |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
186 # Floating text renderers currntly only support one font. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
187 # ... so we set that up. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
188 # You'll se that for our demo we use a image font, so we have to specify the font glyphs |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
189 # for that one. |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
190 renderer = fife.FloatingTextRenderer.getInstance(self.cameras['main']) |
121
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
191 textfont = self.engine.getGuiManager().createFont('fonts/rpgfont.png', 0, str(TDS.readSetting("FontGlyphs", strip=False))); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
192 renderer.changeDefaultFont(textfont) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
193 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
194 # The small camera shouldn't be cluttered by the 'humm di dums' of our hero. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
195 # So we disable the renderer simply by setting its font to None. |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
196 renderer = fife.FloatingTextRenderer.getInstance(self.cameras['small']) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
197 renderer.changeDefaultFont(None) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
198 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
199 # The following renderers are used for debugging. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
200 # Note that by default ( that is after calling View.resetRenderers or Camera.resetRenderers ) |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
201 # renderers will be handed all layers. That's handled here. |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 renderer = self.cameras['main'].getRenderer('CoordinateRenderer') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 renderer.clearActiveLayers() |
121
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
204 renderer.addActiveLayer(self.map.getLayer(str(TDS.readSetting("CoordinateLayerName")))) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
205 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
206 renderer = self.cameras['main'].getRenderer('QuadTreeRenderer') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
207 renderer.setEnabled(True) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 renderer.clearActiveLayers() |
121
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
209 if str(TDS.readSetting("QuadTreeLayerName")): |
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
210 renderer.addActiveLayer(self.map.getLayer(str(TDS.readSetting("QuadTreeLayerName")))) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
211 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
212 # Set up the second camera |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
213 # NOTE: We need to explicitly call setLocation, there's a bit of a messup in the Camera code. |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
214 self.cameras['small'].setLocation(self.hero.agent.getLocation()) |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
215 #self.cameras['small'].getLocationRef().setExactLayerCoordinates( fife.ExactModelCoordinate( 40.0, 40.0, 0.0 )) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
216 self.initial_cam2_x = self.cameras['small'].getLocation().getExactLayerCoordinates().x |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 self.cur_cam2_x = self.initial_cam2_x |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 self.cam2_scrolling_right = True |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
219 self.target_rotation = self.cameras['main'].getRotation() |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
220 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 def save(self, filename): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
222 saveMapFile(filename, self.engine, self.map) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
224 def getInstancesAt(self, clickpoint): |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
225 """ |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
226 Query the main camera for instances on our active(agent) layer. |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
227 """ |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
228 return self.cameras['main'].getMatchingInstances(clickpoint, self.agentlayer) |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
229 |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
230 def getLocationAt(self, clickpoint): |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
231 """ |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
232 Query the main camera for the Map location (on the agent layer) |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
233 that a screen point refers to. |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
234 """ |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
235 target_mapcoord = self.cameras['main'].toMapCoordinates(clickpoint, False) |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
236 target_mapcoord.z = 0 |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
237 location = fife.Location(self.agentlayer) |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
238 location.setMapCoordinates(target_mapcoord) |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
239 return location |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
240 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 def keyPressed(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
242 keyval = evt.getKey().getValue() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 keystr = evt.getKey().getAsString().lower() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 if keystr == 't': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 r = self.cameras['main'].getRenderer('GridRenderer') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
246 r.setEnabled(not r.isEnabled()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 elif keystr == 'c': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
248 r = self.cameras['main'].getRenderer('CoordinateRenderer') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 r.setEnabled(not r.isEnabled()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 elif keystr == 's': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 c = self.cameras['small'] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 c.setEnabled(not c.isEnabled()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 elif keystr == 'r': |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
254 self.model.deleteMaps() |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
255 self.view.clearCameras() |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
256 self.load(self.filename) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
257 elif keystr == 'o': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
258 self.target_rotation = (self.target_rotation + 90) % 360 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
259 elif keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 self.ctrldown = True |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
261 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
262 def keyReleased(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
263 keyval = evt.getKey().getValue() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 if keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
265 self.ctrldown = False |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
266 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 def mouseWheelMovedUp(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
268 if self.ctrldown: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
269 self.cameras['main'].setZoom(self.cameras['main'].getZoom() * 1.05) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
270 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
271 def mouseWheelMovedDown(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
272 if self.ctrldown: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
273 self.cameras['main'].setZoom(self.cameras['main'].getZoom() / 1.05) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
274 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
275 def changeRotation(self): |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
276 """ |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
277 Smoothly change the main cameras rotation until |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
278 the current target rotation is reached. |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
279 """ |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
280 currot = self.cameras['main'].getRotation() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
281 if self.target_rotation != currot: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
282 self.cameras['main'].setRotation((currot + 5) % 360) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
283 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
284 def mousePressed(self, evt): |
20
47fff0eee32e
event consumption fix for techdemo, pop-menu now works and gui clicks do not cause agent movement
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
11
diff
changeset
|
285 if evt.isConsumedByWidgets(): |
47fff0eee32e
event consumption fix for techdemo, pop-menu now works and gui clicks do not cause agent movement
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
11
diff
changeset
|
286 return |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
287 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
288 clickpoint = fife.ScreenPoint(evt.getX(), evt.getY()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
289 if (evt.getButton() == fife.MouseEvent.LEFT): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
290 self.hide_instancemenu() |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
291 self.hero.run( self.getLocationAt(clickpoint) ) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
292 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
293 if (evt.getButton() == fife.MouseEvent.RIGHT): |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
294 instances = self.getInstancesAt(clickpoint) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
295 print "selected instances on agent layer: ", [i.getObject().getId() for i in instances] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
296 if instances: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
297 self.show_instancemenu(clickpoint, instances[0]) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
298 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
299 def mouseMoved(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
300 renderer = fife.InstanceRenderer.getInstance(self.cameras['main']) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
301 renderer.removeAllOutlines() |
11
b153abbd9900
Fixed instance outlining for rio_de_hola.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
5
diff
changeset
|
302 |
b153abbd9900
Fixed instance outlining for rio_de_hola.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
5
diff
changeset
|
303 pt = fife.ScreenPoint(evt.getX(), evt.getY()) |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
304 instances = self.getInstancesAt(pt); |
11
b153abbd9900
Fixed instance outlining for rio_de_hola.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
5
diff
changeset
|
305 for i in instances: |
b153abbd9900
Fixed instance outlining for rio_de_hola.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
5
diff
changeset
|
306 if i.getObject().getId() in ('girl', 'beekeeper'): |
b153abbd9900
Fixed instance outlining for rio_de_hola.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
5
diff
changeset
|
307 renderer.addOutlined(i, 173, 255, 47, 2) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
308 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
309 def onConsoleCommand(self, command): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
310 result = '' |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
311 try: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
312 result = str(eval(command)) |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
313 except Exception, e: |
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
314 result = str(e) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
315 return result |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
316 |
246
8156de05a544
Documentation for the World
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
245
diff
changeset
|
317 # Callbacks from the popupmenu |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
318 def onMoveButtonPress(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
319 self.hide_instancemenu() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
320 self.hero.run(self.instancemenu.instance.getLocationRef()) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
321 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
322 def onTalkButtonPress(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
323 self.hide_instancemenu() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
324 instance = self.instancemenu.instance |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
325 self.hero.talk(instance.getLocationRef()) |
48
097996ee0b3d
fixed talk functionality in techdemo
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
20
diff
changeset
|
326 if instance.getObject().getId() == 'beekeeper': |
121
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
327 beekeeperTexts = TDS.readSetting("beekeeperTexts", type='list', text=True) |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
328 instance.say(random.choice(beekeeperTexts), 5000) |
48
097996ee0b3d
fixed talk functionality in techdemo
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
20
diff
changeset
|
329 if instance.getObject().getId() == 'girl': |
121
ae3b8139c7c7
* Applying settings patch by greyghost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
98
diff
changeset
|
330 girlTexts = TDS.readSetting("girlTexts", type='list', text=True) |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
331 instance.say(random.choice(girlTexts), 5000) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
332 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
333 def onKickButtonPress(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
334 self.hide_instancemenu() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
335 self.hero.kick(self.instancemenu.instance.getLocationRef()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
336 self.instancemenu.instance.say('Hey!', 1000) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
337 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
338 def onInspectButtonPress(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
339 self.hide_instancemenu() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
340 inst = self.instancemenu.instance |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
341 saytext = ['Engine told me that this instance has'] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
342 if inst.getId(): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
343 saytext.append(' name %s,' % inst.getId()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
344 saytext.append(' ID %s and' % inst.getFifeId()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
345 saytext.append(' object name %s' % inst.getObject().getId()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
346 self.hero.agent.say('\n'.join(saytext), 3500) |
129
9a1529f9625e
* Indentation patch by GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
121
diff
changeset
|
347 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
348 def pump(self): |
247
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
349 """ |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
350 Called every frame. |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
351 |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
352 Scroll the small demo camera and |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
353 (smoothly) update the rotation. |
040387b7167f
More documentation.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
246
diff
changeset
|
354 """ |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
355 if self.cameras['small'].isEnabled(): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
356 loc = self.cameras['small'].getLocation() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
357 c = loc.getExactLayerCoordinatesRef() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
358 if self.cam2_scrolling_right: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
359 self.cur_cam2_x = c.x = c.x+0.1 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
360 if self.cur_cam2_x > self.initial_cam2_x+10: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
361 self.cam2_scrolling_right = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
362 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
363 self.cur_cam2_x = c.x = c.x-0.1 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
364 if self.cur_cam2_x < self.initial_cam2_x-10: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
365 self.cam2_scrolling_right = True |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
366 self.cameras['small'].setLocation(loc) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
367 self.changeRotation() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
368 self.pump_ctr += 1 |