# HG changeset patch # User mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1218124006 0 # Node ID 9a1529f9625ea3615e43ced8c7fd165e1022345d # Parent 6e1fd35714409c3c947aa7936a1a2625e4fa1d9a * Indentation patch by GreyGhost diff -r 6e1fd3571440 -r 9a1529f9625e clients/rio_de_hola/scripts/agents/agent.py --- a/clients/rio_de_hola/scripts/agents/agent.py Wed Aug 06 22:35:27 2008 +0000 +++ b/clients/rio_de_hola/scripts/agents/agent.py Thu Aug 07 15:46:46 2008 +0000 @@ -16,7 +16,7 @@ def start(self): raise ProgrammingError('No start defined for Agent') - + def create_anonymous_agents(model, objectName, layer, agentClass): agents = [] diff -r 6e1fd3571440 -r 9a1529f9625e clients/rio_de_hola/scripts/agents/beekeeper.py --- a/clients/rio_de_hola/scripts/agents/beekeeper.py Wed Aug 06 22:35:27 2008 +0000 +++ b/clients/rio_de_hola/scripts/agents/beekeeper.py Thu Aug 07 15:46:46 2008 +0000 @@ -17,7 +17,7 @@ c.x += random.randint(-1, 1) c.y += random.randint(-1, 1) self.talk() - + def talk(self): self.state = _STATE_TALK self.agent.act('talk', self.facingLoc, True) # never calls back diff -r 6e1fd3571440 -r 9a1529f9625e clients/rio_de_hola/scripts/agents/cloud.py --- a/clients/rio_de_hola/scripts/agents/cloud.py Wed Aug 06 22:35:27 2008 +0000 +++ b/clients/rio_de_hola/scripts/agents/cloud.py Thu Aug 07 15:46:46 2008 +0000 @@ -8,7 +8,7 @@ def __init__(self, model, agentName, layer, uniqInMap=False): super(Cloud, self).__init__(model, agentName, layer, uniqInMap) self.state = _STATE_NONE - + def isOutOfBounds(self, c): return (c.x < 0) or (c.x > 100) or (c.y < 0) or (c.y > 100) @@ -33,16 +33,15 @@ self.loc = self.agent.getLocation() self.initialCoords = self.agent.getLocation().getExactLayerCoordinates() self.appear() - + def appear(self): self.state = _STATE_APPEAR self.agent.act('appear', self.loc, False) - + def disappear(self): self.state = _STATE_DISAPPEAR self.agent.act('disappear', self.loc, False) - + def move(self): self.state = _STATE_FLOATING self.agent.act('default', self.loc, False) - diff -r 6e1fd3571440 -r 9a1529f9625e clients/rio_de_hola/scripts/agents/girl.py --- a/clients/rio_de_hola/scripts/agents/girl.py Wed Aug 06 22:35:27 2008 +0000 +++ b/clients/rio_de_hola/scripts/agents/girl.py Thu Aug 07 15:46:46 2008 +0000 @@ -30,19 +30,18 @@ l = fife.Location(self.layer) l.setLayerCoordinates(fife.ModelCoordinate(*self.waypoints[self.waypoint_counter % len(self.waypoints)])) return l - + def start(self): self.follow_hero() - + def idle(self): self.state = _STATE_IDLE self.agent.act('stand', self.agent.getFacingLocation(), False) - + def follow_hero(self): self.state = _STATE_FOLLOW self.agent.follow('run', self.hero, GIRL_SPEED) - + def run(self, location): self.state = _STATE_RUN self.agent.move('run', location, GIRL_SPEED) - diff -r 6e1fd3571440 -r 9a1529f9625e clients/rio_de_hola/scripts/agents/hero.py --- a/clients/rio_de_hola/scripts/agents/hero.py Wed Aug 06 22:35:27 2008 +0000 +++ b/clients/rio_de_hola/scripts/agents/hero.py Thu Aug 07 15:46:46 2008 +0000 @@ -22,22 +22,22 @@ heroTexts = TDS.readSetting("heroTexts", type='list', text=True) txtindex = random.randint(0, len(heroTexts) - 1) instance.say(heroTexts[txtindex], 2500) - + def start(self): self.idle() - + def idle(self): self.state = _STATE_IDLE self.agent.act('stand', self.agent.getFacingLocation()) - + def run(self, location): self.state = _STATE_RUN self.agent.move('run', location, 4 * float(TDS.readSetting("TestAgentSpeed"))) - + def kick(self, target): self.state = _STATE_KICK self.agent.act('kick', target) - + def talk(self, target): self.state = _STATE_TALK self.agent.act('talk', target) diff -r 6e1fd3571440 -r 9a1529f9625e clients/rio_de_hola/scripts/common/eventlistenerbase.py --- a/clients/rio_de_hola/scripts/common/eventlistenerbase.py Wed Aug 06 22:35:27 2008 +0000 +++ b/clients/rio_de_hola/scripts/common/eventlistenerbase.py Thu Aug 07 15:46:46 2008 +0000 @@ -1,10 +1,9 @@ import fife -class EventListenerBase(fife.IKeyListener, fife.ICommandListener, fife.IMouseListener, - fife.ConsoleExecuter, fife.IWidgetListener): +class EventListenerBase(fife.IKeyListener, fife.ICommandListener, fife.IMouseListener, fife.ConsoleExecuter, fife.IWidgetListener): def __init__(self, engine, regKeys=False, regCmd=False, regMouse=False, regConsole=False, regWidget=False): self.eventmanager = engine.getEventManager() - + fife.IKeyListener.__init__(self) if regKeys: self.eventmanager.addKeyListener(self) @@ -20,8 +19,8 @@ fife.IWidgetListener.__init__(self) if regWidget: self.eventmanager.addWidgetListener(self) - - + + def mousePressed(self, evt): pass def mouseReleased(self, evt): diff -r 6e1fd3571440 -r 9a1529f9625e clients/rio_de_hola/scripts/world.py --- a/clients/rio_de_hola/scripts/world.py Wed Aug 06 22:35:27 2008 +0000 +++ b/clients/rio_de_hola/scripts/world.py Thu Aug 07 15:46:46 2008 +0000 @@ -18,17 +18,17 @@ def __init__(self, map): fife.MapChangeListener.__init__(self) map.addChangeListener(self) - + def onMapChanged(self, map, changedLayers): return print "Changes on map ", map.getId() for layer in map.getLayers(): print layer.getId() print " ", ["%s, %x" % (i.getObject().getId(), i.getChangeInfo()) for i in layer.getChangedInstances()] - + def onLayerCreate(self, map, layer): pass - + def onLayerDelete(self, map, layer): pass @@ -46,11 +46,11 @@ self.instancemenu = None self.instance_to_agent = {} self.dynamic_widgets = {} - + def show_instancemenu(self, clickpoint, instance): if instance.getFifeId() == self.hero.agent.getFifeId(): return - + dynamicbuttons = ('moveButton', 'talkButton', 'kickButton', 'inspectButton') if not self.instancemenu: self.instancemenu = pychan.loadXML('gui/instancemenu.xml') @@ -67,10 +67,10 @@ self.instancemenu.removeChild(self.dynamic_widgets[btn]) except pychan.exceptions.RuntimeError: pass - + self.instancemenu.clickpoint = clickpoint self.instancemenu.instance = instance - + self.instancemenu.addChild(self.dynamic_widgets['inspectButton']) target_distance = self.hero.agent.getLocationRef().getLayerDistanceTo(instance.getLocationRef()) if target_distance > 3.0: @@ -81,11 +81,11 @@ self.instancemenu.addChild(self.dynamic_widgets['kickButton']) self.instancemenu.position = (clickpoint.x, clickpoint.y) self.instancemenu.show() - + def hide_instancemenu(self): if self.instancemenu: self.instancemenu.hide() - + def reset(self): self.map, self.agentlayer = None, None self.cameras = {} @@ -99,16 +99,16 @@ self.reset() self.map = loadMapFile(filename, self.engine) self.maplistener = MapListener(self.map) - + self.agentlayer = self.map.getLayer('TechdemoMapGroundObjectLayer') self.hero = Hero(self.model, 'PC', self.agentlayer) self.instance_to_agent[self.hero.agent.getFifeId()] = self.hero self.hero.start() - + self.girl = Girl(self.model, 'NPC:girl', self.agentlayer) self.instance_to_agent[self.girl.agent.getFifeId()] = self.girl self.girl.start() - + self.beekeepers = create_anonymous_agents(self.model, 'beekeeper', self.agentlayer, Beekeeper) for beekeeper in self.beekeepers: self.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper @@ -118,37 +118,37 @@ self.clouds = create_anonymous_agents(self.model, 'Cloud', cloudlayer, Cloud) for cloud in self.clouds: cloud.start(0.1, 0.05) - + for cam in self.view.getCameras(): self.cameras[cam.getId()] = cam self.cameras['main'].attach(self.hero.agent) - + self.view.resetRenderers() renderer = fife.FloatingTextRenderer.getInstance(self.cameras['main']) textfont = self.engine.getGuiManager().createFont('fonts/rpgfont.png', 0, str(TDS.readSetting("FontGlyphs", strip=False))); renderer.changeDefaultFont(textfont) - + renderer = fife.FloatingTextRenderer.getInstance(self.cameras['small']) renderer.changeDefaultFont(None) - + renderer = self.cameras['main'].getRenderer('CoordinateRenderer') renderer.clearActiveLayers() renderer.addActiveLayer(self.map.getLayer(str(TDS.readSetting("CoordinateLayerName")))) - + renderer = self.cameras['main'].getRenderer('QuadTreeRenderer') renderer.setEnabled(True) renderer.clearActiveLayers() if str(TDS.readSetting("QuadTreeLayerName")): renderer.addActiveLayer(self.map.getLayer(str(TDS.readSetting("QuadTreeLayerName")))) - + self.cameras['small'].getLocationRef().setExactLayerCoordinates( fife.ExactModelCoordinate( 40.0, 40.0, 0.0 )) self.initial_cam2_x = self.cameras['small'].getLocation().getExactLayerCoordinates().x self.cur_cam2_x = self.initial_cam2_x self.cam2_scrolling_right = True self.cameras['small'].setEnabled(False) - + self.target_rotation = self.cameras['main'].getRotation() - + def save(self, filename): saveMapFile(filename, self.engine, self.map) @@ -174,29 +174,29 @@ self.target_rotation = (self.target_rotation + 90) % 360 elif keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL): self.ctrldown = True - + def keyReleased(self, evt): keyval = evt.getKey().getValue() if keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL): self.ctrldown = False - + def mouseWheelMovedUp(self, evt): if self.ctrldown: self.cameras['main'].setZoom(self.cameras['main'].getZoom() * 1.05) - + def mouseWheelMovedDown(self, evt): if self.ctrldown: self.cameras['main'].setZoom(self.cameras['main'].getZoom() / 1.05) - + def changeRotation(self): currot = self.cameras['main'].getRotation() if self.target_rotation != currot: self.cameras['main'].setRotation((currot + 5) % 360) - + def mousePressed(self, evt): if evt.isConsumedByWidgets(): return - + clickpoint = fife.ScreenPoint(evt.getX(), evt.getY()) if (evt.getButton() == fife.MouseEvent.LEFT): self.hide_instancemenu() @@ -205,13 +205,13 @@ l = fife.Location(self.agentlayer) l.setMapCoordinates(target_mapcoord) self.hero.run(l) - + if (evt.getButton() == fife.MouseEvent.RIGHT): instances = self.cameras['main'].getMatchingInstances(clickpoint, self.agentlayer) print "selected instances on agent layer: ", [i.getObject().getId() for i in instances] if instances: self.show_instancemenu(clickpoint, instances[0]) - + def mouseMoved(self, evt): renderer = fife.InstanceRenderer.getInstance(self.cameras['main']) renderer.removeAllOutlines() @@ -221,7 +221,7 @@ for i in instances: if i.getObject().getId() in ('girl', 'beekeeper'): renderer.addOutlined(i, 173, 255, 47, 2) - + def onConsoleCommand(self, command): result = '' try: @@ -233,7 +233,7 @@ def onMoveButtonPress(self): self.hide_instancemenu() self.hero.run(self.instancemenu.instance.getLocationRef()) - + def onTalkButtonPress(self): self.hide_instancemenu() instance = self.instancemenu.instance @@ -246,12 +246,12 @@ girlTexts = TDS.readSetting("girlTexts", type='list', text=True) txtindex = random.randint(0, len(girlTexts) - 1) instance.say(girlTexts[txtindex], 5000) - + def onKickButtonPress(self): self.hide_instancemenu() self.hero.kick(self.instancemenu.instance.getLocationRef()) self.instancemenu.instance.say('Hey!', 1000) - + def onInspectButtonPress(self): self.hide_instancemenu() inst = self.instancemenu.instance @@ -261,7 +261,7 @@ saytext.append(' ID %s and' % inst.getFifeId()) saytext.append(' object name %s' % inst.getObject().getId()) self.hero.agent.say('\n'.join(saytext), 3500) - + def pump(self): if self.cameras['small'].isEnabled(): loc = self.cameras['small'].getLocation() diff -r 6e1fd3571440 -r 9a1529f9625e engine/extensions/basicapplication.py --- a/engine/extensions/basicapplication.py Wed Aug 06 22:35:27 2008 +0000 +++ b/engine/extensions/basicapplication.py Thu Aug 07 15:46:46 2008 +0000 @@ -13,7 +13,7 @@ class ExitEventListener(fife.IKeyListener): """ Default, rudimentary event listener. - + Will cause the application to quit on pressing ESC. """ def __init__(self, app): @@ -29,32 +29,32 @@ keyval = evt.getKey().getValue() if keyval == fife.Key.ESCAPE: self.app.quit() - + def keyReleased(self, evt): pass class ApplicationBase(object): """ ApplicationBase is an extendable class that provides a basic environment for a FIFE-based client. - + The unextended application reads in and initializes engine settings, sets up a simple event listener, and pumps the engine while listening for a quit message. Specialized applications can modify settings.py to change initial engine settings. They can provide their own event listener by overriding L{createListener}. And they can override the L{_pump} method to define runtime behavior of the application. - + """ def __init__(self): self.engine = fife.Engine() self.loadSettings() self.initLogging() - + self.engine.init() - + self._animationloader = XMLAnimationLoader(self.engine.getImagePool(), self.engine.getVFS()) self.engine.getAnimationPool().addResourceLoader(self._animationloader) - + self.quitRequested = False self.breakRequested = False self.returnValues = [] @@ -66,7 +66,7 @@ """ import settings self.settings = settings - + engineSetting = self.engine.getSettings() engineSetting.setDefaultFontGlyphs(settings.FontGlyphs) engineSetting.setDefaultFontPath(settings.Font) @@ -89,7 +89,7 @@ engineSetting.setImageChunkingSize(settings.ImageChunkSize) except: pass - + def initLogging(self): """ Initialize the LogManager. @@ -102,7 +102,7 @@ """ This creates a default event listener, which will just close the program after pressing ESC. - + You should override this method to provide your own event handling. """ return ExitEventListener(self) @@ -116,11 +116,11 @@ retval = self.mainLoop() self.engine.finalizePumping() return retval - + def mainLoop(self): """ The programs main loop. - + Do not override this, instead provide your own L{_pump} method. You can call this recursively, e.g. to provide synchronous Dialogs :-) and break out of the current mainLoop by calling @@ -139,23 +139,23 @@ if self.breakRequested: self.breakRequested = False break - + return self.returnValues.pop() def breakFromMainLoop(self,returnValue): """ Break from the currently running L{mainLoop}. - + The passed argument will be returned by the mainLoop. """ self.returnValues[-1] = returnValue self.breakRequested = True - + def _pump(self): """ Application pump. - + Derived classes can specialize this for unique behavior. This is called every frame. """ diff -r 6e1fd3571440 -r 9a1529f9625e engine/extensions/fife_utils.py --- a/engine/extensions/fife_utils.py Wed Aug 06 22:35:27 2008 +0000 +++ b/engine/extensions/fife_utils.py Thu Aug 07 15:46:46 2008 +0000 @@ -11,5 +11,3 @@ if m.group(1) == type('').getTypeStr(): ret = True return ret - - diff -r 6e1fd3571440 -r 9a1529f9625e engine/extensions/fifelog.py --- a/engine/extensions/fifelog.py Wed Aug 06 22:35:27 2008 +0000 +++ b/engine/extensions/fifelog.py Thu Aug 07 15:46:46 2008 +0000 @@ -6,7 +6,7 @@ You can set log targets individually (prompt, file). You can also adjust things like visible modules through log manager. ''' - + def __init__(self, engine, promptlog=True, filelog=False): ''' Constructs new log manager @@ -23,7 +23,7 @@ if k.startswith('LM_') and k not in ('LM_CORE', 'LM_MODULE_MAX'): self.mod2name[v] = self.lm.getModuleName(v) self.name2mod = dict([(v.lower(), k) for k, v in self.mod2name.items()]) - + def addVisibleModules(self, *names): ''' Adds modules that are visible in logs. By default, all modules @@ -41,7 +41,7 @@ self.lm.addVisibleModule(self.name2mod[m]) except KeyError: print 'Tried to enable non-existing log module "%s"' % m - + def removeVisibleModules(self, *names): ''' Removes modules that are visible in logs. By default, all modules @@ -56,7 +56,7 @@ else: for m in names: self.lm.removeVisibleModule(self.name2mod[m]) - + def getVisibleModules(self): ''' Gets currently visible modules @@ -75,4 +75,3 @@ ''' self.lm.clearVisibleModules() self.addVisibleModules(*names) - diff -r 6e1fd3571440 -r 9a1529f9625e engine/extensions/pychan/__init__.py --- a/engine/extensions/pychan/__init__.py Wed Aug 06 22:35:27 2008 +0000 +++ b/engine/extensions/pychan/__init__.py Thu Aug 07 15:46:46 2008 +0000 @@ -247,11 +247,10 @@ @param engine: The FIFE engine object. """ - from manager import Manager + from manager import Manager global manager manager = Manager(engine,debug) - # XML Loader from xml.sax import saxutils, handler @@ -327,7 +326,7 @@ if self.root: self.root.addChild( obj ) self.root = obj - + def _createSpacer(self,cls,name,attrs): obj = cls(parent=self.root) if hasattr(self.root,'add'): @@ -345,33 +344,33 @@ def loadXML(filename_or_stream): """ Loads a PyChan XML file and generates a widget from it. - + @param filename_or_stream: A filename or a file-like object (for example using StringIO). - + The XML format is very dynamic, in the sense, that the actual allowed tags and attributes depend on the PyChan code. - + So when a tag C{Button} is encountered, an instance of class Button will be generated, and added to the parent object. All attributes will then be parsed and then set in the following way: - + - position,size,min_size,max_size,margins - These are assumed to be comma separated tuples of integers. - foreground_color,base_color,background_color - These are assumed to be triples of comma separated integers. - opaque,border_size,padding - These are assumed to be simple integers. - + All other attributes are set verbatim as strings on the generated instance. In case a Widget does not accept an attribute to be set or the attribute can not be parsed correctly, the function will raise a GuiXMLError. - + In short::