equal
deleted
inserted
replaced
88 season = SEASON_NONE; |
88 season = SEASON_NONE; |
89 } |
89 } |
90 |
90 |
91 bool checkForDir(const QString & dir) |
91 bool checkForDir(const QString & dir) |
92 { |
92 { |
93 QDir tmpdir; |
93 QDir tmpdir(dir); |
94 if (!tmpdir.exists(dir)) |
94 if (!tmpdir.exists()) |
95 if (!tmpdir.mkdir(dir)) |
95 if (!tmpdir.mkpath(dir)) |
96 { |
96 { |
97 QMessageBox directoryMsg(QApplication::activeWindow()); |
97 QMessageBox directoryMsg(QApplication::activeWindow()); |
98 directoryMsg.setIcon(QMessageBox::Warning); |
98 directoryMsg.setIcon(QMessageBox::Warning); |
99 directoryMsg.setWindowTitle(QMessageBox::tr("Main - Error")); |
99 directoryMsg.setWindowTitle(QMessageBox::tr("Main - Error")); |
100 directoryMsg.setText(QMessageBox::tr("Cannot create directory %1").arg(dir)); |
100 directoryMsg.setText(QMessageBox::tr("Cannot create directory %1").arg(dir)); |
103 return false; |
103 return false; |
104 } |
104 } |
105 return true; |
105 return true; |
106 } |
106 } |
107 |
107 |
|
108 bool checkForFile(const QString & file) |
|
109 { |
|
110 QFile tmpfile(file); |
|
111 if (!tmpfile.exists()) |
|
112 return tmpfile.open(QFile::WriteOnly); |
|
113 else |
|
114 return true; |
|
115 } |
|
116 |
|
117 #ifdef __APPLE__ |
|
118 static CocoaInitializer *cocoaInit = NULL; |
|
119 // Function to be called at end of program's termination on OS X to release |
|
120 // the NSAutoReleasePool contained within the CocoaInitializer. |
|
121 void releaseCocoaPool(void) |
|
122 { |
|
123 if (cocoaInit != NULL) |
|
124 { |
|
125 delete cocoaInit; |
|
126 cocoaInit = NULL; |
|
127 } |
|
128 } |
|
129 #endif |
|
130 |
108 int main(int argc, char *argv[]) |
131 int main(int argc, char *argv[]) |
109 { |
132 { |
|
133 #ifdef __APPLE__ |
|
134 // This creates the autoreleasepool that prevents leaking, and destroys it only on exit |
|
135 cocoaInit = new CocoaInitializer(); |
|
136 atexit(releaseCocoaPool); |
|
137 #endif |
|
138 |
110 HWApplication app(argc, argv); |
139 HWApplication app(argc, argv); |
111 |
140 |
112 FileEngineHandler engine(argv[0]); |
141 FileEngineHandler engine(argv[0]); |
113 |
142 |
114 flib_init(); |
143 flib_init(); |
230 engine.mount(cfgdir->absolutePath() + "/Data"); |
259 engine.mount(cfgdir->absolutePath() + "/Data"); |
231 engine.mount(cfgdir->absolutePath()); |
260 engine.mount(cfgdir->absolutePath()); |
232 engine.setWriteDir(cfgdir->absolutePath()); |
261 engine.setWriteDir(cfgdir->absolutePath()); |
233 engine.mountPacks(); |
262 engine.mountPacks(); |
234 |
263 |
|
264 checkForFile("physfs://hedgewars.ini"); |
|
265 |
235 QTranslator Translator; |
266 QTranslator Translator; |
236 { |
267 { |
237 QSettings settings("physfs://hedgewars.ini", QSettings::IniFormat); |
268 QSettings settings("physfs://hedgewars.ini", QSettings::IniFormat); |
238 QString cc = settings.value("misc/locale", QString()).toString(); |
269 QString cc = settings.value("misc/locale", QString()).toString(); |
239 if(cc.isEmpty()) |
270 if(cc.isEmpty()) |
251 { |
282 { |
252 QSettings registry_hklm("HKEY_LOCAL_MACHINE", QSettings::NativeFormat); |
283 QSettings registry_hklm("HKEY_LOCAL_MACHINE", QSettings::NativeFormat); |
253 registry_hklm.setValue("Software/Hedgewars/Frontend", bindir->absolutePath().replace("/", "\\") + "\\hedgewars.exe"); |
284 registry_hklm.setValue("Software/Hedgewars/Frontend", bindir->absolutePath().replace("/", "\\") + "\\hedgewars.exe"); |
254 registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\")); |
285 registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\")); |
255 } |
286 } |
256 #endif |
|
257 #ifdef __APPLE__ |
|
258 // this creates the autoreleasepool that prevents leaking |
|
259 CocoaInitializer initializer; |
|
260 #endif |
287 #endif |
261 |
288 |
262 QString style = ""; |
289 QString style = ""; |
263 QString fname; |
290 QString fname; |
264 |
291 |