annotate gamescenecontroller.py @ 189:4381be70e1bb tip

Fixed incompatibility with latest changes to bgrease.
author Beliar <KarstenBock@gmx.net>
date Sun, 08 Apr 2012 20:30:43 +0200
parents 2a12e2843984
children
rev   line source
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
1 # This file is part of PARPG.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
2
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
3 # PARPG is free software: you can redistribute it and/or modify
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
5 # the Free Software Foundation, either version 3 of the License, or
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
6 # (at your option) any later version.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
7
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
8 # PARPG is distributed in the hope that it will be useful,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
11 # GNU General Public License for more details.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
12
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
15 """This file contains the GameSceneController that handles input when the game
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
16 is exploring a scene"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
17
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
18
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
19 from datetime import datetime
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
20 import random
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
21 import glob
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
22 import os
57
ba85e5aff370 Removed the pos value from the fifeagent component. getItemActions of Gamescenecontroller gets the position by calling a method of the behaviour.
KarstenBock@gmx.net
parents: 53
diff changeset
23 import logging
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
24
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
25 from fife import fife
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
26 from fife import extensions
177
62aed6388159 Fixed showing the console.
Beliar
parents: 167
diff changeset
27 from fife.extensions import pychan
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
28
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
29 from controllerbase import ControllerBase
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
30 from parpg.gui.hud import Hud
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
31 from parpg.gui import drag_drop_data as data_drag
148
2241722311bf Moved the action module into the entities package.
KarstenBock@gmx.net
parents: 129
diff changeset
32 from entities.action import (ChangeMapAction, ExamineAction, TalkAction,
104
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
33 OpenAction, CloseAction, UnlockAction, LockAction,
107
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
34 PickUpAction, DropItemAction,
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
35 ExamineContentsAction,
104
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
36 )
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
37
188
2a12e2843984 Removed bGrease, which is in a seperate repository, here: https://github.com/Beliaar/bGrease
Beliar <KarstenBock@gmx.net>
parents: 187
diff changeset
38 from parpg.world import PARPGWorld
88
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
39
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40 #For debugging/code analysis
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41 if False:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 from gamesceneview import GameSceneView
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43 from gamemodel import GameModel
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
44 from parpg import PARPGApplication
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
45
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
46
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
47 logger = logging.getLogger('gamescenecontroller')
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
48
188
2a12e2843984 Removed bGrease, which is in a seperate repository, here: https://github.com/Beliaar/bGrease
Beliar <KarstenBock@gmx.net>
parents: 187
diff changeset
49 class GameSceneController(PARPGWorld, ControllerBase):
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
50 '''
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
51 This controller handles inputs when the game is in "scene" state.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
52 "Scene" state is when the player can move around and interact
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53 with objects. Like, talking to a npc or examining the contents of a box.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 '''
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
55
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
56
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
57 def __init__(self, engine, view, model, application):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58 '''
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59 Constructor
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
60 @param engine: Instance of the active fife engine
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
61 @type engine: fife.Engine
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
62 @param view: Instance of a GameSceneView
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
63 @param type: parpg.GameSceneView
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
64 @param model: The model that has the current gamestate
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
65 @type model: parpg.GameModel
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
66 @param application: The application that created this controller
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
67 @type application: parpg.PARPGApplication
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
68 @param settings: The current settings of the application
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
69 @type settings: fife.extensions.fife_settings.Setting
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
70 '''
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
71 ControllerBase.__init__(self,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
72 engine,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
73 view,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
74 model,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
75 application)
189
4381be70e1bb Fixed incompatibility with latest changes to bgrease.
Beliar <KarstenBock@gmx.net>
parents: 188
diff changeset
76 PARPGWorld.__init__(self, engine)
187
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
77
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
78 #setup functions for the GameEnvironment
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
79 createItemByID = lambda identifier : (
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
80 self.model.createItemByID(
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
81 identifier=identifier,
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
82 world=self)
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
83 )
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
84 createItemByType = lambda item_type, identifier: (
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
85 self.model.createItemByType(
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
86 item_type=item_type,
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
87 identifier=identifier,
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
88 world=self)
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
89 )
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
90 funcs = {
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
91 "createItemByID": createItemByID,
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
92 "createItemByType": createItemByType,
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
93 }
ab6a0fd1668a Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment.
Beliar <KarstenBock@gmx.net>
parents: 177
diff changeset
94 self.model.game_state.funcs.update(funcs)
160
75c0b728ccf3 Further work on the scripting system.
KarstenBock@gmx.net
parents: 158
diff changeset
95 self.systems.scripting.game_state = self.model.game_state
75c0b728ccf3 Further work on the scripting system.
KarstenBock@gmx.net
parents: 158
diff changeset
96
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
97 #this can be helpful for IDEs code analysis
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
98 if False:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
99 assert(isinstance(self.engine, fife.Engine))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
100 assert(isinstance(self.view, GameSceneView))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
101 assert(isinstance(self.view, GameModel))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
102 assert(isinstance(self.application, PARPGApplication))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
103 assert(isinstance(self.event_manager, fife.EventManager))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
104
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
105 # Last saved mouse coords
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
106 self.action_number = 1
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
107
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
108 self.has_mouse_focus = True
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
109 self.last_mousecoords = None
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
110 self.mouse_callback = None
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
111 self.original_cursor_id = self.engine.getCursor().getId()
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
112 self.scroll_data = {"mouse":[], "kb":[], "offset":[0,0]}
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
113 self.scroll_timer = extensions.fife_timer.Timer(
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
114 100,
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
115 lambda: self.view.moveCamera(self.scroll_data["offset"]),
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
116 )
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
117
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
118 #this is temporary until we can set the native cursor
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
119 self.resetMouseCursor()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
120 self.paused = False
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
121
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 161
diff changeset
122 if model.settings.get("fife", "PlaySounds"):
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
123 if not self.view.sounds.music_init:
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
124 music_path = 'music'
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
125 music_file = random.choice(
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
126 glob.glob('/'.join([music_path, '*.ogg']))
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
127 )
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
128 self.view.sounds.playMusic(music_file)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
129 self.initHud()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
130
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
131
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
132 def initHud(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
133 """Initialize the hud member
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
134 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
135 hud_callbacks = {
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
136 'saveGame': self.saveGame,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
137 'loadGame': self.loadGame,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
138 'quitGame': self.quitGame,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
139 }
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
140 self.view.hud = Hud(self,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
141 self.model.settings,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
142 hud_callbacks)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
143
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
144 def keyPressed(self, evt):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
145 """Whenever a key is pressed, fife calls this routine.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
146 @type evt: fife.event
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
147 @param evt: The event that fife caught
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
148 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
149 key = evt.getKey()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
150 key_val = key.getValue()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
151
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
152 if(key_val == key.Q):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
153 # we need to quit the game
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
154 self.view.hud.quitGame()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
155 if(key_val == key.T):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
156 self.model.active_map.toggleRenderer('GridRenderer')
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
157 if(key_val == key.F1):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
158 # display the help screen and pause the game
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
159 self.view.hud.displayHelp()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
160 if(key_val == key.F5):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
161 self.model.active_map.toggleRenderer('CoordinateRenderer')
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
162 if(key_val == key.F7):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
163 # F7 saves a screenshot to screenshots directory
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
164
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
165 settings = self.model.settings
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
166 # FIXME M. George Hansen 2011-06-06: Not sure that user_path is set
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
167 # correctly atm.
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
168 screenshot_directory = os.path.join(settings.user_path,
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
169 'screenshots')
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
170 # try to create the screenshots directory
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
171 try:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
172 os.mkdir(screenshot_directory)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
173 #TODO: distinguish between already existing permissions error
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
174 except OSError:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
175 logger.warning("screenshot directory wasn't created.")
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
176
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
177 screenshot_file = os.path.join(screenshot_directory,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
178 'screen-{0}.png'.format(
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
179 datetime.now().strftime(
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
180 '%Y-%m-%d-%H-%M-%S')))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
181 self.engine.getRenderBackend().captureScreen(screenshot_file)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
182 logger.info("PARPG: Saved: {0}".format(screenshot_file))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
183 if(key_val == key.F10):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
184 # F10 shows/hides the console
177
62aed6388159 Fixed showing the console.
Beliar
parents: 167
diff changeset
185 pychan.manager.hook.guimanager.getConsole().toggleShowHide()
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
186 if(key_val == key.C):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
187 # C opens and closes the character screen.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
188 self.view.hud.toggleCharacterScreen()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
189 if(key_val == key.I):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
190 # I opens and closes the inventory
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
191 self.view.hud.toggleInventory()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
192 if(key_val == key.A):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
193 # A adds a test action to the action box
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
194 # The test actions will follow this format: Action 1,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
195 # Action 2, etc.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
196 self.view.hud.addAction("Action " + str(self.action_number))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
197 self.action_number += 1
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
198 if(key_val == key.ESCAPE):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
199 # Escape brings up the main menu
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
200 self.view.hud.displayMenu()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
201 # Hide the quit menu
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
202 self.view.hud.quit_window.hide()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
203 if(key_val == key.M):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
204 self.view.sounds.toggleMusic()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
205 if(key_val == key.PAUSE):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
206 # Pause pause/unpause the game
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
207 self.model.togglePause()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
208 self.pause(False)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
209 if(key_val == key.SPACE):
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
210 self.model.active_map.centerCameraOnPlayer()
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
211
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
212 #alter scroll data if a directional key is hit
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
213 if(key_val == key.UP):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
214 if not "up" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
215 self.scroll_data["kb"].append("up")
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
216
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
217 if(key_val == key.RIGHT):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
218 if not "right" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
219 self.scroll_data["kb"].append("right")
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
220
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
221 if(key_val == key.DOWN):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
222 if not "down" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
223 self.scroll_data["kb"].append("down")
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
224
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
225 if(key_val == key.LEFT):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
226 if not "left" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
227 self.scroll_data["kb"].append("left")
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
228
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
229 def keyReleased(self, evt):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
230 """Whenever a key is pressed, fife calls this routine.
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
231 @type evt: fife.event
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
232 @param evt: The event that fife caught
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
233 @return: None"""
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
234 key = evt.getKey()
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
235 key_val = key.getValue()
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
236
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
237 #alter scroll data if a directional key is released
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
238 if(key_val == key.UP):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
239 if "up" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
240 self.scroll_data["kb"].remove("up")
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
241
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
242 if(key_val == key.RIGHT):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
243 if "right" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
244 self.scroll_data["kb"].remove("right")
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
245
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
246 if(key_val == key.DOWN):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
247 if "down" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
248 self.scroll_data["kb"].remove("down")
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
249
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
250 if(key_val == key.LEFT):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
251 if "left" in self.scroll_data["kb"]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
252 self.scroll_data["kb"].remove("left")
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
253
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
254 def mouseReleased(self, evt):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
255 """If a mouse button is released, fife calls this routine.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
256 We want to wait until the button is released, because otherwise
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
257 pychan captures the release if a menu is opened.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
258 @type evt: fife.event
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
259 @param evt: The event that fife caught
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
260 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
261 self.view.hud.hideContextMenu()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
262 scr_point = fife.ScreenPoint(evt.getX(), evt.getY())
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
263 if(evt.getButton() == fife.MouseEvent.LEFT):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
264 if(data_drag.dragging):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
265 coord = self.model.getCoords(scr_point)\
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
266 .getExactLayerCoordinates()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
267 commands = ({"Command": "ResetMouseCursor"},
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
268 {"Command": "StopDragging"})
116
7f7f54c4077b Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 115
diff changeset
269 player_char = (self.model.game_state.
7f7f54c4077b Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 115
diff changeset
270 getObjectById("PlayerCharacter"))
7f7f54c4077b Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 115
diff changeset
271 action = DropItemAction(self,
7f7f54c4077b Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 115
diff changeset
272 data_drag.dragged_item,
7f7f54c4077b Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 115
diff changeset
273 commands)
7f7f54c4077b Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 115
diff changeset
274 player_char.fifeagent.behaviour.approach([coord.x, coord.y],
7f7f54c4077b Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 115
diff changeset
275 action)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
276 else:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
277 self.model.movePlayer(self.model.getCoords(scr_point))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
278 elif(evt.getButton() == fife.MouseEvent.RIGHT):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
279 # is there an object here?
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
280 tmp_active_map = self.model.active_map
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
281 instances = tmp_active_map.cameras[tmp_active_map.my_cam_id].\
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
282 getMatchingInstances(scr_point,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
283 tmp_active_map.agent_layer)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
284 info = None
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
285 for inst in instances:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
286 # check to see if this is an active item
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
287 if(self.model.objectActive(inst.getId())):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
288 # yes, get the model
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
289 info = self.getItemActions(inst.getId())
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
290 break
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
291
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
292 # take the menu items returned by the engine or show a
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
293 # default menu if no items
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
294 data = info or \
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
295 [["Walk", "Walk here", self.view.onWalk,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
296 self.model.getCoords(scr_point)]]
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
297 # show the menu
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
298 self.view.hud.showContextMenu(data, (scr_point.x, scr_point.y))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
299
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
300
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
301 def updateMouse(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
302 """Updates the mouse values"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
303 if self.paused:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
304 return
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
305 cursor = self.engine.getCursor()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
306 #this can be helpful for IDEs code analysis
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
307 if False:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
308 assert(isinstance(cursor, fife.Cursor))
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
309 self.last_mousecoords = fife.ScreenPoint(cursor.getX(), cursor.getY())
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
310 self.view.highlightFrontObject(self.last_mousecoords)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
311
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
312 #set the trigger area in pixles
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
313 pixle_edge = 20
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
314
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
315 mouse_x = self.last_mousecoords.x
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
316 screen_width = self.model.engine.getSettings().getScreenWidth()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
317 mouse_y = self.last_mousecoords.y
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
318 screen_height = self.model.engine.getSettings().getScreenHeight()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
319
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
320 image = None
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
321 settings = self.model.settings
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
322
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
323
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
324 #edge logic
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
325 if self.has_mouse_focus:
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
326 direction = self.scroll_data["mouse"] = []
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
327
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
328 #up
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
329 if mouse_y <= pixle_edge:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
330 direction.append("up")
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 161
diff changeset
331 image = '/'.join(['gui/cursors', settings.get("parpg", "CursorUp")])
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
332
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
333 #right
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
334 if mouse_x >= screen_width - pixle_edge:
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
335 direction.append("right")
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 161
diff changeset
336 image = '/'.join(['gui/cursors', settings.get("parpg", "CursorRight")])
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
337
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
338 #down
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
339 if mouse_y >= screen_height - pixle_edge:
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
340 direction.append("down")
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 161
diff changeset
341 image = '/'.join(['gui/cursors', settings.get("parpg", "CursorDown")])
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
342
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
343 #left
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
344 if mouse_x <= pixle_edge:
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
345 direction.append("left")
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 161
diff changeset
346 image = '/'.join(['gui/cursors', settings.get("parpg", "CursorLeft")])
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
347
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
348 if image is not None and not data_drag.dragging:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
349 self.setMouseCursor(image, image)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
350
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
351
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
352 def handleCommands(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
353 """Check if a command is to be executed
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
354 """
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
355 if self.model.map_change:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
356 self.pause(True)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
357 if self.model.active_map:
88
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
358 self.model.updateObjectDB(self)
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
359 player_char = self.model.game_state.\
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
360 getObjectById("PlayerCharacter").fifeagent
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
361 pc_agent = self.model.agents\
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
362 [self.model.ALL_AGENTS_KEY]["PlayerCharacter"]
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
363 pc_agent["Map"] = self.model.target_map_name
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
364 pc_agent["Position"] = (self.model.target_position or
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
365 pc_agent["Position"])
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
366 player_agent = self.model.active_map.\
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
367 agent_layer.getInstance("PlayerCharacter")
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
368 self.model.game_state.deleteObject("PlayerCharacter").delete()
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
369 deleted = self.model.game_state.deleteObjectsFromMap(
88
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
370 self.model.game_state.current_map_name
0411a4bcceee Fixed moving between maps.
KarstenBock@gmx.net
parents: 86
diff changeset
371 )
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
372 deleted.extend(
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
373 self.model.game_state.deleteObjectsFromMap(None)
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
374 )
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
375 for obj in deleted:
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
376 obj.delete()
161
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
377 self.model.loadMap(self.model.target_map_name)
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
378 self.setupScripts(self.model.target_map_name)
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
379
161
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
380 self.model.setActiveMap(self.model.target_map_name, self)
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
381
39
3011bc71ab20 Added funcionality to load Entities from file
KarstenBock@gmx.net
parents: 8
diff changeset
382 self.model.placeAgents(self)
44
98f26f7636d8 Changes to make PARPG "runable" with grease. (With the correct modified assets)
KarstenBock@gmx.net
parents: 39
diff changeset
383 self.model.placePC(self)
125
452bbc3d915d Fixed that items in the player characters inventory could not be dropped.
KarstenBock@gmx.net
parents: 116
diff changeset
384 self.model.updateObjectDB(self)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
385 self.model.map_change = False
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
386 # The PlayerCharacter has an inventory, and also some
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
387 # filling of the ready slots in the HUD.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
388 # At this point we sync the contents of the ready slots
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
389 # with the contents of the inventory.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
390 self.view.hud.inventory = None
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
391 self.view.hud.initializeInventory()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
392 self.pause(False)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
393
161
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
394 def setupScripts(self, map_name):
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
395 """Read scripts for the current map"""
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
396 self.systems.scripting.reset()
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
397 self.model.readScriptsOfMap(map_name, self)
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
398
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
399 def handleScrolling(self):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
400 """
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
401 Merge kb and mouse related scroll data, limit the speed and
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
402 move the camera.
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
403 """
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
404 #this is how many pxls the camera is moved in one time frame
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
405 scroll_offset = self.scroll_data["offset"] = [0,0]
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
406
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
407 mouse = self.scroll_data["mouse"]
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
408 keyboard = self.scroll_data["kb"]
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 161
diff changeset
409 speed = self.model.settings.get("parpg", "ScrollSpeed")
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
410
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
411 #adds a value to the offset depending on the contents of each
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
412 # of the controllers: set() removes doubles
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
413 scroll_direction = set(mouse+keyboard)
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
414 for direction in scroll_direction:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
415 if direction == "up":
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
416 scroll_offset[0] +=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
417 scroll_offset[1] -=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
418 elif direction == "right":
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
419 scroll_offset[0] +=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
420 scroll_offset[1] +=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
421 elif direction == "down":
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
422 scroll_offset[0] -=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
423 scroll_offset[1] +=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
424 elif direction == "left":
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
425 scroll_offset[0] -=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
426 scroll_offset[1] -=1
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
427
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
428 #keep the speed within bounds
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
429 if scroll_offset[0] > 0: scroll_offset[0] = speed
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
430 if scroll_offset[0] < 0: scroll_offset[0] = -speed
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
431
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
432 if scroll_offset[1] > 0: scroll_offset[1] = speed
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
433 if scroll_offset[1] < 0: scroll_offset[1] = -speed
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
434
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
435 #de/activate scrolling
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
436 if scroll_offset != [0, 0]:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
437 self.scroll_timer.start()
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
438 else:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
439 self.scroll_timer.stop()
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
440 if not data_drag.dragging:
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
441 self.resetMouseCursor()
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
442
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
443 def nullFunc(self, userdata):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
444 """Sample callback for the context menus."""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
445 logger.info(userdata)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
446
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
447 def initTalk(self, npc_info):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
448 """ Starts the PlayerCharacter talking to an NPC. """
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
449 # TODO: work more on this when we get NPCData and HeroData straightened
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
450 # out
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
451 npc = self.model.game_state.getObjectById(
86
a9cc5559ec2a Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents: 82
diff changeset
452 npc_info.general.identifier,
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
453 self.model.game_state.current_map_name
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
454 )
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
455 npc_behaviour = npc.fifeagent.behaviour
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
456 npc_pos = npc_behaviour.getLocation().getLayerCoordinates()
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
457 self.model.game_state.getObjectById("PlayerCharacter").fifeagent.\
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
458 behaviour.approach(npc_behaviour.agent,
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
459 TalkAction(self, npc))
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
460
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
461 def getItemActions(self, obj_id):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
462 """Given the objects ID, return the text strings and callbacks.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
463 @type obj_id: string
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
464 @param obj_id: ID of object
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
465 @rtype: list
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
466 @return: List of text and callbacks"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
467 actions = []
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
468 obj = self.model.game_state.\
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
469 getObjectById(obj_id,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
470 self.model.game_state.current_map_name)
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
471 #obj_pos = obj.fifeagent.behaviour.getLocation().getLayerCoordinates()
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
472 agent = obj.fifeagent.behaviour.agent
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
473 player = self.model.game_state.getObjectById("PlayerCharacter")
86
a9cc5559ec2a Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents: 82
diff changeset
474 is_player = obj.general.identifier == player.general.identifier
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
475
57
ba85e5aff370 Removed the pos value from the fifeagent component. getItemActions of Gamescenecontroller gets the position by calling a method of the behaviour.
KarstenBock@gmx.net
parents: 53
diff changeset
476
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
477 #TODO: Check all actions to be compatible with the grease components
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
478 if obj is not None:
53
7b9f6e3513d4 Added code that checks if the object is the player so certain actions (talk, attack) will not appear in the menu.
KarstenBock@gmx.net
parents: 51
diff changeset
479 if obj.dialogue and not is_player:
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
480 actions.append(["Talk", "Talk", self.initTalk, obj])
53
7b9f6e3513d4 Added code that checks if the object is the player so certain actions (talk, attack) will not appear in the menu.
KarstenBock@gmx.net
parents: 51
diff changeset
481 if obj.characterstats and not is_player:
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
482 actions.append(["Attack", "Attack", self.nullFunc, obj])
82
e864b704dd59 The Examine action in the context menu will now only be shown when the Entity actually has a description text.
KarstenBock@gmx.net
parents: 81
diff changeset
483 if obj.description and obj.description.desc:
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
484 actions.append(["Examine", "Examine",
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
485 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
486 agent,
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
487 ExamineAction(self,
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
488 obj_id, obj.description.view_name,
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
489 obj.description.desc)])
81
28561412c7e7 Fixed bug in "getItemActions" when the Entity has a change_map component.
KarstenBock@gmx.net
parents: 57
diff changeset
490
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
491 if obj.change_map:
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
492 actions.append(["Change Map", "Change Map",
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
493 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
494 agent,
81
28561412c7e7 Fixed bug in "getItemActions" when the Entity has a change_map component.
KarstenBock@gmx.net
parents: 57
diff changeset
495 ChangeMapAction(self, obj.change_map.target_map,
28561412c7e7 Fixed bug in "getItemActions" when the Entity has a change_map component.
KarstenBock@gmx.net
parents: 57
diff changeset
496 obj.change_map.target_position)])
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
497
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
498 if obj.lockable:
104
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
499 if obj.lockable.closed:
115
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
500 if not obj.lockable.locked:
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
501 actions.append(["Open", "Open",
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
502 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
503 agent,
115
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
504 OpenAction(self, obj)])
104
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
505 else:
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
506 actions.append(["Close", "Close",
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
507 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
508 agent,
104
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
509 CloseAction(self, obj)])
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
510 if obj.lockable.locked:
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
511 actions.append(["Unlock", "Unlock",
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
512 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
513 agent,
104
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
514 UnlockAction(self, obj)])
c9afad46091b Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 101
diff changeset
515 else:
115
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
516 if obj.lockable.closed:
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
517 actions.append(["Lock", "Lock",
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
518 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
519 agent,
115
26e65f27dbd7 "Open" will now not be shown in the context menu when the lockable is locked.
KarstenBock@gmx.net
parents: 108
diff changeset
520 LockAction(self, obj)])
107
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
521 if obj.container:
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
522 if obj.characterstats:
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
523 #TODO: This is reserved for a possible "Steal" action.
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
524 pass
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
525 elif not obj.lockable or not obj.lockable.closed:
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
526 actions.append(["Examine contents", "Examine Contents",
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
527 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
528 agent,
107
100a39fa64a2 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 104
diff changeset
529 ExamineContentsAction(self, obj)])
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
530 if obj.containable:
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
531 actions.append(["Pick Up", "Pick Up",
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
532 player.fifeagent.behaviour.approach,
158
04854cf6e1ac The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 148
diff changeset
533 agent,
51
d3a9caba067b Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 44
diff changeset
534 PickUpAction(self, obj)])
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
535
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
536 return actions
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
537
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
538 def saveGame(self, *args, **kwargs):
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
539 """Saves the game state, delegates call to gamemodel.GameModel
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
540 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
541 self.model.pause(False)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
542 self.pause(False)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
543 self.view.hud.enabled = True
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
544 self.model.updateObjectDB(self)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
545 self.model.save(*args, **kwargs)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
546
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
547 def loadGame(self, *args, **kwargs):
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
548 """Loads the game state, delegates call to gamemodel.GameModel
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
549 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
550 # Remove all currently loaded maps so we can start fresh
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
551 self.model.pause(False)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
552 self.pause(False)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
553 self.view.hud.enabled = True
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
554 self.model.deleteMaps()
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
555 for entity in self.entities.copy():
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
556 entity.delete()
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
557 self.view.hud.inventory = None
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
558
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
559 self.model.load(*args, **kwargs)
101
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
560 # Load the current map
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
561 if self.model.game_state.current_map_name:
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
562 self.model.loadMap(self.model.game_state.current_map_name)
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
563 self.model.placeAgents(self)
824f3068ef2a Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 100
diff changeset
564 self.model.placePC(self)
161
d224bbce512a Implemented loading scripts from files.
KarstenBock@gmx.net
parents: 160
diff changeset
565 self.setupScripts(self.model.game_state.current_map_name)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
566 self.view.hud.initializeInventory()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
567
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
568 def quitGame(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
569 """Quits the game
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
570 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
571 self.application.listener.quitGame()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
572
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
573 def pause(self, paused):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
574 """Pauses the controller"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
575 super(GameSceneController, self).pause(paused)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
576 self.paused = paused
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
577 if paused:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
578 self.scroll_timer.stop()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
579
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
580 def onCommand(self, command):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
581 if(command.getCommandType() == fife.CMD_MOUSE_FOCUS_GAINED):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
582 self.has_mouse_focus = True
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
583 elif(command.getCommandType() == fife.CMD_MOUSE_FOCUS_LOST):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
584 self.has_mouse_focus = False
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
585
8
708a6f651c31 Modifications to use the grease manager and modes
KarstenBock@gmx.net
parents: 4
diff changeset
586 def pump(self, dt):
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
587 """Routine called during each frame. Our main loop is in ./run.py"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
588 # uncomment to instrument
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
589 # t0 = time.time()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
590 if self.paused:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
591 return
8
708a6f651c31 Modifications to use the grease manager and modes
KarstenBock@gmx.net
parents: 4
diff changeset
592 ControllerBase.pump(self, dt)
188
2a12e2843984 Removed bGrease, which is in a seperate repository, here: https://github.com/Beliaar/bGrease
Beliar <KarstenBock@gmx.net>
parents: 187
diff changeset
593 PARPGWorld.pump(self, dt)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
594 self.updateMouse()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
595 if self.model.active_map:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
596 self.view.highlightFrontObject(self.last_mousecoords)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
597 self.view.refreshTopLayerTransparencies()
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
598 self.handleScrolling()
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
599 self.handleCommands()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
600 # print "%05f" % (time.time()-t0,)