# HG changeset patch # User nemo # Date 1286410880 14400 # Node ID 8cdbc0505f1850a7093306ef5e9ffa73bfc8ebbb # Parent fd04228971b32dfb46652aa297a388504c8dfc67# Parent 2fc211f600159d4a1a67b4d24d536692e05da331 merge diff -r fd04228971b3 -r 8cdbc0505f18 QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Wed Oct 06 20:20:54 2010 -0400 +++ b/QTfrontend/hwconsts.cpp.in Wed Oct 06 20:21:20 2010 -0400 @@ -30,6 +30,9 @@ QStringList * Themes; QStringList * mapList; +bool custom_config = false; +bool custom_data = false; + int cMaxTeams = 6; QString * cDefaultAmmoStore = new QString( diff -r fd04228971b3 -r 8cdbc0505f18 QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Wed Oct 06 20:20:54 2010 -0400 +++ b/QTfrontend/hwconsts.h Wed Oct 06 20:21:20 2010 -0400 @@ -31,6 +31,9 @@ extern QDir * cfgdir; extern QDir * datadir; +extern bool custom_config; +extern bool custom_data; + extern int cMaxTeams; extern QStringList * Themes; diff -r fd04228971b3 -r 8cdbc0505f18 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Wed Oct 06 20:20:54 2010 -0400 +++ b/QTfrontend/hwform.cpp Wed Oct 06 20:21:20 2010 -0400 @@ -141,6 +141,9 @@ connect(ui.pageOptions->BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(DeleteTeam())); connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); +#ifdef _WIN32 + connect(ui.pageOptions->BtnAssociateFiles, SIGNAL(clicked()), this, SLOT(AssociateFiles())); +#endif connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon())); @@ -1110,3 +1113,17 @@ for(int i = 0; (i < entries.count()) && (i <= team.CampaignProgress); i++) ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2"), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); } + +void HWForm::AssociateFiles() +{ + QSettings registry_hkcr("HKEY_CLASSES_ROOT", QSettings::NativeFormat); + registry_hkcr.setValue(".hwd/Default", "Hedgewars.Demo"); + registry_hkcr.setValue(".hws/Default", "Hedgewars.Save"); + registry_hkcr.setValue("Hedgewars.Demo/Default", tr("Hedgewars Demo File", "File Types")); + registry_hkcr.setValue("Hedgewars.Save/Default", tr("Hedgewars Save File", "File Types")); + registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0"); + registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0"); + registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\""); + registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\""); + QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set.")); +} diff -r fd04228971b3 -r 8cdbc0505f18 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Wed Oct 06 20:20:54 2010 -0400 +++ b/QTfrontend/hwform.h Wed Oct 06 20:21:20 2010 -0400 @@ -78,6 +78,7 @@ void GoToAdmin(); void GoToPage(quint8 id); void GoBack(); + void AssociateFiles(); void btnExitPressed(); void btnExitClicked(); void IntermediateSetup(); diff -r fd04228971b3 -r 8cdbc0505f18 QTfrontend/main.cpp --- a/QTfrontend/main.cpp Wed Oct 06 20:20:54 2010 -0400 +++ b/QTfrontend/main.cpp Wed Oct 06 20:21:20 2010 -0400 @@ -73,11 +73,13 @@ qWarning() << "WARNING: Cannot open DATA_PATH=" << f.absoluteFilePath(); } *cDataDir = f.absoluteFilePath(); + custom_data = true; } if(parsedArgs.contains("config-dir")) { QFileInfo f(parsedArgs["config-dir"]); *cConfigDir = f.absoluteFilePath(); + custom_config = true; } app.setStyle(new QPlastiqueStyle); @@ -410,12 +412,11 @@ // Win32 registry setup (used for xfire detection etc. - don't set it if we're running in "portable" mode with a custom config dir) #ifdef _WIN32 - if(cConfigDir->length() == 0) + if(!custom_config) { - QSettings registry(QSettings::NativeFormat, QSettings::UserScope, "Hedgewars Project", "Hedgewars"); - QFileInfo f(argv[0]); - registry.setValue("file", f.absoluteFilePath()); - registry.setValue("path", f.absolutePath()); + QSettings registry_hklm("HKEY_LOCAL_MACHINE", QSettings::NativeFormat); + registry_hklm.setValue("Software/Hedgewars/Frontend", bindir->absolutePath().replace("/", "\\") + "\\hedgewars.exe"); + registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\")); } #endif diff -r fd04228971b3 -r 8cdbc0505f18 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Wed Oct 06 20:20:54 2010 -0400 +++ b/QTfrontend/pages.cpp Wed Oct 06 20:21:20 2010 -0400 @@ -147,6 +147,7 @@ //Tips << tr("", "Tips"); #ifdef _WIN32 Tips << tr("You can find your Hedgewars configuration files under \"My Documents\\Hedgewars\". Create backups or take the files with you, but don't edit them by hand.", "Tips"); + Tips << tr("You're able to associate Hedgewars related files (savegames and demo recordings) with the game to launch them right from your favorite file or internet browser.", "Tips"); #else Tips << tr("You can find your Hedgewars configuration files under \"Hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); #endif @@ -610,7 +611,12 @@ CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); MiscLayout->addWidget(CBAutoUpdate, 4, 0, 1, 2); #endif - +#ifdef _WIN32 + BtnAssociateFiles = new QPushButton(groupMisc); + BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions")); + BtnAssociateFiles->setEnabled(!custom_data && !custom_config); + MiscLayout->addWidget(BtnAssociateFiles, 4, 0, 1, 2); +#endif gbTBLayout->addWidget(groupMisc, 2, 0); } @@ -735,6 +741,8 @@ BtnBack->setFixedHeight(BtnSaveOptions->height()); BtnBack->setFixedWidth(BtnBack->width()+2); BtnBack->setStyleSheet("QPushButton{margin: 22px 0 9px 2px;}"); + +// BtnAssociateFiles = addButton(""); } PageNet::PageNet(QWidget* parent) : AbstractPage(parent) diff -r fd04228971b3 -r 8cdbc0505f18 QTfrontend/pages.h --- a/QTfrontend/pages.h Wed Oct 06 20:20:54 2010 -0400 +++ b/QTfrontend/pages.h Wed Oct 06 20:21:20 2010 -0400 @@ -216,6 +216,7 @@ QPushButton *BtnNewTeam; QPushButton *BtnEditTeam; QPushButton *BtnDeleteTeam; + QPushButton *BtnAssociateFiles; QLabel *LblNoEditTeam; QComboBox *CBTeamName; IconedGroupBox *AGGroupBox; diff -r fd04228971b3 -r 8cdbc0505f18 bin/hwdfile.ico Binary file bin/hwdfile.ico has changed diff -r fd04228971b3 -r 8cdbc0505f18 bin/hwsfile.ico Binary file bin/hwsfile.ico has changed diff -r fd04228971b3 -r 8cdbc0505f18 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Wed Oct 06 20:20:54 2010 -0400 +++ b/hedgewars/uMisc.pas Wed Oct 06 20:21:20 2010 -0400 @@ -822,7 +822,7 @@ begin for i:= 0 to 7 do begin - assign(f, ExtractFileDir(ParamStr(2)) + '/Logs/' + cLogfileBase + inttostr(i) + '.log'); + assign(f, ExtractFileDir(ParamStr(2)) + '/' + cLogfileBase + inttostr(i) + '.log'); rewrite(f); if IOResult = 0 then break; end;