Mercurial > fife-parpg
comparison demos/shooter/run.py @ 505:ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 18 May 2010 19:37:31 +0000 |
parents | 3dff106b945b |
children | 520bd1621644 |
comparison
equal
deleted
inserted
replaced
504:0196c83c7270 | 505:ee65aa323457 |
---|---|
65 if self._quit: | 65 if self._quit: |
66 command.consume() | 66 command.consume() |
67 | 67 |
68 class Shooter(ApplicationBase): | 68 class Shooter(ApplicationBase): |
69 def __init__(self): | 69 def __init__(self): |
70 super(Shooter,self).__init__() | 70 super(Shooter,self).__init__(TDS) |
71 pychan.init(self.engine, debug=False) | 71 pychan.init(self.engine, debug=False) |
72 | 72 |
73 #This is requred if you want to use modal dialog boxes | 73 #This is requred if you want to use modal dialog boxes |
74 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) | 74 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) |
75 | |
76 self._setting = TDS | |
77 | 75 |
78 self._world = world.World(self, self.engine, self._setting) | 76 self._world = world.World(self, self.engine, self._setting) |
79 self._listener = ApplicationListener(self.engine, self._world) | 77 self._listener = ApplicationListener(self.engine, self._world) |
80 | 78 |
81 def requestQuit(self): | 79 def requestQuit(self): |
82 cmd = fife.Command() | 80 cmd = fife.Command() |
83 cmd.setSource(None) | 81 cmd.setSource(None) |
84 cmd.setCommandType(fife.CMD_QUIT_GAME) | 82 cmd.setCommandType(fife.CMD_QUIT_GAME) |
85 self.engine.getEventManager().dispatchCommand(cmd) | 83 self.engine.getEventManager().dispatchCommand(cmd) |
86 | 84 |
87 def loadSettings(self): | |
88 """ | |
89 Load the settings from a python file and load them into the engine. | |
90 Called in the ApplicationBase constructor. I hard coded all the | |
91 settings in here to remove the complexity of loading settings from | |
92 an XML file which would be out of scope of this demo. | |
93 """ | |
94 | |
95 self._setting = TDS | |
96 | |
97 glyphDft = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\\\"" | |
98 engineSetting = self.engine.getSettings() | |
99 engineSetting.setDefaultFontGlyphs(self._setting.get("FIFE", "FontGlyphs", glyphDft)) | |
100 engineSetting.setDefaultFontPath(self._setting.get("FIFE", "Font", "fonts/FreeSans.ttf")) | |
101 engineSetting.setDefaultFontSize(self._setting.get("FIFE", "DefaultFontSize", 12)) | |
102 engineSetting.setBitsPerPixel(self._setting.get("FIFE", "BitsPerPixel", 0)) | |
103 engineSetting.setInitialVolume(self._setting.get("FIFE", "InitialVolume", 5.0)) | |
104 engineSetting.setSDLRemoveFakeAlpha(self._setting.get("FIFE", "SDLRemoveFakeAlpha", 1)) | |
105 engineSetting.setScreenWidth(self._setting.get("FIFE", "ScreenWidth", 1024)) | |
106 engineSetting.setScreenHeight(self._setting.get("FIFE", "ScreenHeight", 768)) | |
107 engineSetting.setRenderBackend(self._setting.get("FIFE", "RenderBackend", "OpenGL")) | |
108 engineSetting.setFullScreen(self._setting.get("FIFE", "FullScreen", 0)) | |
109 | |
110 engineSetting.setWindowTitle(self._setting.get("FIFE", "WindowTitle", "No window title set")) | |
111 engineSetting.setWindowIcon(self._setting.get("FIFE", "WindowIcon", "")) | |
112 engineSetting.setImageChunkingSize(self._setting.get("FIFE", "ImageChunkSize", 256)) | |
113 | |
114 def initLogging(self): | |
115 """ | |
116 Initialize the LogManager. | |
117 """ | |
118 | |
119 engineSetting = self.engine.getSettings() | |
120 logmodules = self._setting.get("FIFE", "LogModules", "controller") | |
121 | |
122 #log to both the console and log file | |
123 self._log = fifelog.LogManager(self.engine, | |
124 self._setting.get("FIFE", "LogToPrompt", "0"), | |
125 self._setting.get("FIFE", "LogToFile", "0")) | |
126 | |
127 self._log.setLevelFilter(fife.LogManager.LEVEL_DEBUG) | |
128 | |
129 if logmodules: | |
130 self._log.setVisibleModules(*logmodules) | |
131 | 85 |
132 def createListener(self): | 86 def createListener(self): |
133 pass # already created in constructor | 87 pass # already created in constructor |
134 | 88 |
135 def _pump(self): | 89 def _pump(self): |