104 |
107 |
105 int main(int argc, char *argv[]) |
108 int main(int argc, char *argv[]) |
106 { |
109 { |
107 HWApplication app(argc, argv); |
110 HWApplication app(argc, argv); |
108 |
111 |
|
112 FileEngineHandler engine(argv[0]); |
|
113 |
|
114 flib_init(); |
|
115 |
109 app.setAttribute(Qt::AA_DontShowIconsInMenus,false); |
116 app.setAttribute(Qt::AA_DontShowIconsInMenus,false); |
110 |
117 |
111 QStringList arguments = app.arguments(); |
118 QStringList arguments = app.arguments(); |
112 QMap<QString, QString> parsedArgs; |
119 QMap<QString, QString> parsedArgs; |
113 { |
120 { |
145 QFileInfo f(parsedArgs["config-dir"]); |
152 QFileInfo f(parsedArgs["config-dir"]); |
146 *cConfigDir = f.absoluteFilePath(); |
153 *cConfigDir = f.absoluteFilePath(); |
147 custom_config = true; |
154 custom_config = true; |
148 } |
155 } |
149 |
156 |
150 app.setStyle(new QPlastiqueStyle); |
157 app.setStyle(new QPlastiqueStyle()); |
151 |
158 |
152 QDateTime now = QDateTime::currentDateTime(); |
159 QDateTime now = QDateTime::currentDateTime(); |
153 srand(now.toTime_t()); |
160 srand(now.toTime_t()); |
154 rand(); |
161 rand(); |
155 |
162 |
216 missingMsg.setWindowModality(Qt::WindowModal); |
223 missingMsg.setWindowModality(Qt::WindowModal); |
217 missingMsg.exec(); |
224 missingMsg.exec(); |
218 return 1; |
225 return 1; |
219 } |
226 } |
220 |
227 |
221 DataManager & dataMgr = DataManager::instance(); |
228 // setup PhysFS |
|
229 engine.mount(datadir->absolutePath()); |
|
230 engine.mount(cfgdir->absolutePath() + "/Data"); |
|
231 engine.mount(cfgdir->absolutePath(), "/config"); |
|
232 engine.setWriteDir(cfgdir->absolutePath()); |
|
233 engine.mountPacks(); |
222 |
234 |
223 QTranslator Translator; |
235 QTranslator Translator; |
224 { |
236 { |
225 QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); |
237 QSettings settings("physfs://config/hedgewars.ini", QSettings::IniFormat); |
226 QString cc = settings.value("misc/locale", QString()).toString(); |
238 QString cc = settings.value("misc/locale", QString()).toString(); |
227 if(cc.isEmpty()) |
239 if(cc.isEmpty()) |
228 cc = QLocale::system().name(); |
240 cc = QLocale::system().name(); |
229 |
241 |
230 // load locale file into translator |
242 // load locale file into translator |
231 Translator.load( |
243 if(!Translator.load(QString("physfs://Locale/hedgewars_%1").arg(cc))) |
232 dataMgr.findFileForRead( |
244 qWarning("Failed to install translation"); |
233 QString("Locale/hedgewars_" + cc) |
|
234 ) |
|
235 ); |
|
236 app.installTranslator(&Translator); |
245 app.installTranslator(&Translator); |
237 } |
246 } |
238 |
247 |
239 #ifdef _WIN32 |
248 #ifdef _WIN32 |
240 // Win32 registry setup (used for xfire detection etc. - don't set it if we're running in "portable" mode with a custom config dir) |
249 // Win32 registry setup (used for xfire detection etc. - don't set it if we're running in "portable" mode with a custom config dir) |
272 default : |
281 default : |
273 fname = "qt.css"; |
282 fname = "qt.css"; |
274 } |
283 } |
275 |
284 |
276 // load external stylesheet if there is any |
285 // load external stylesheet if there is any |
277 QFile extFile(dataMgr.findFileForRead("css/" + fname)); |
286 QFile extFile("physfs://css/" + fname); |
278 |
287 |
279 QFile resFile(":/res/css/" + fname); |
288 QFile resFile(":/res/css/" + fname); |
280 |
289 |
281 QFile & file = (extFile.exists() ? extFile : resFile); |
290 QFile & file = (extFile.exists() ? extFile : resFile); |
282 |
291 |
283 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
292 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
284 style.append(file.readAll()); |
293 style.append(file.readAll()); |
285 |
294 |
286 app.form = new HWForm(NULL, style); |
295 app.form = new HWForm(NULL, style); |
287 app.form->show(); |
296 app.form->show(); |
288 return app.exec(); |
297 int r = app.exec(); |
|
298 |
|
299 flib_quit(); |
|
300 |
|
301 return r; |
289 } |
302 } |