1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """
25 The basic application and main loop.
26
27 See the L{ApplicationBase} documentation.
28 """
29
30 from builtins import map
31 from fife import fife
32 from fife.extensions.basicapplication import ApplicationBase
33
34 import PyCEGUI
35
37 """
38 Default, rudimentary event listener.
39
40 Will cause the application to quit on pressing ESC.
41 """
53
59
62
67
68 DEFAULT_GUI_DIR = "gui/"
69
76
78 settings = self.engine.getSettings()
79
80 major_v, minor_v = list(map(int, PyCEGUI.Version__.split('.')[:2]))
81
82
83 if major_v == 0 and minor_v <= 7:
84 guimanager = fife.CEGuiManager()
85 else:
86 guimanager = fife.CEGuiManager()
87
88
89 guimanager.thisown = 0
90
91 self.guimanager = guimanager
92 self.engine.setGuiManager(self.guimanager)
93 self.engine.getEventManager().addSdlEventListener(self.guimanager)
94
97
99
100 resourceprovider = PyCEGUI.System.getSingleton().getResourceProvider()
101
102 major_v, minor_v = list(map(int, PyCEGUI.Version__.split('.')[:2]))
103 if major_v == 0 and minor_v <= 7:
104 resourcetypemap = { "schemes" : PyCEGUI.Scheme.setDefaultResourceGroup,
105 "imagesets" : PyCEGUI.Imageset.setDefaultResourceGroup,
106 "fonts" : PyCEGUI.Font.setDefaultResourceGroup,
107 "layouts" : PyCEGUI.WindowManager.setDefaultResourceGroup,
108 "looksnfeels" : PyCEGUI.WidgetLookManager.setDefaultResourceGroup,
109 }
110 else:
111 resourcetypemap = { "schemes" : PyCEGUI.Scheme.setDefaultResourceGroup,
112 "imagesets" : PyCEGUI.ImageManager.setImagesetDefaultResourceGroup,
113 "fonts" : PyCEGUI.Font.setDefaultResourceGroup,
114 "layouts" : PyCEGUI.WindowManager.setDefaultResourceGroup,
115 "looksnfeels" : PyCEGUI.WidgetLookManager.setDefaultResourceGroup,
116 }
117
118
119 if not self._setting:
120 for restype, res_setfunc in resourcetypemap.items():
121 resourceprovider.setResourceGroupDirectory(restype, DEFAULT_GUI_DIR + restype)
122 res_setfunc(restype)
123 else:
124 for restype, res_setfunc in resourcetypemap.items():
125 path = self._setting.get("CEGUI", restype)
126 if path:
127 resourceprovider.setResourceGroupDirectory(restype, path)
128 res_setfunc(restype)
129 else:
130
131 resourceprovider.setResourceGroupDirectory(restype, DEFAULT_GUI_DIR + restype)
132 res_setfunc(restype)
133
134 parser = PyCEGUI.System.getSingleton().getXMLParser()
135 if parser.isPropertyPresent("SchemaDefaultResourceGroup"):
136 path = self._setting.get("CEGUI", "schemas")
137 if path:
138 rp.setResourceGroupDirectory("schemas", path)
139 else:
140 rp.setResourceGroupDirectory("schemas", DEFAULT_GUI_DIR + "schemas")
141
142 parser.setProperty("SchemaDefaultResourceGroup", "schemas")
143
144
148