QTfrontend/hwform.cpp
changeset 8302 a7934cd12469
parent 8299 ef2e284255cd
child 8304 620560c89284
child 8307 8d7c52b24e28
equal deleted inserted replaced
8301:8bf36d368291 8302:a7934cd12469
  1877 }
  1877 }
  1878 
  1878 
  1879 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
  1879 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
  1880 QString HWForm::getDemoArguments()
  1880 QString HWForm::getDemoArguments()
  1881 {
  1881 {
       
  1882 #ifdef Q_WS_WIN
       
  1883     QString userdir = cfgdir->absolutePath().replace("/","\\");
       
  1884 #else
       
  1885     QString userdir = cfgdir->absolutePath();
       
  1886 #endif
       
  1887 
  1882     QRect resolution = config->vid_Resolution();
  1888     QRect resolution = config->vid_Resolution();
  1883     return QString(QString::number(resolution.width()) + " "
  1889     return QString("--user-dir " + userdir
  1884                    + QString::number(resolution.height()) + " "
  1890                    + " --width " + QString::number(resolution.width())
  1885                    + QString::number(config->bitDepth()) + " " // bpp
  1891                    + " --height " + QString::number(resolution.height())
  1886                    + QString::number(config->volume()) + " " // sound volume
  1892                    + " --volume " + QString::number(config->volume())
  1887                    + (config->isMusicEnabled() ? "1" : "0") + " "
  1893                    + (config->isMusicEnabled() ? "" : " --nomusic")
  1888                    + (config->isSoundEnabled() ? "1" : "0") + " "
  1894                    + (config->isSoundEnabled() ? "" : " --nosound")
  1889                    + config->language() + ".txt "
  1895                    + " --locale " + config->language() + ".txt"
  1890                    + (config->vid_Fullscreen() ? "1" : "0") + " "
  1896                    + (config->vid_Fullscreen() ? " --fullscreen" : "")
  1891                    + (config->isShowFPSEnabled() ? "1" : "0") + " "
  1897                    + (config->isShowFPSEnabled() ? " --showfps" : "")
  1892                    + (config->isAltDamageEnabled() ? "1" : "0") + " "
  1898                    + (config->isAltDamageEnabled() ? " --altdmg" : "")
  1893                    + QString::number(config->timerInterval()) + " "
  1899                    + " --frame-interval " + QString::number(config->timerInterval())
  1894                    + QString::number(config->translateQuality()));
  1900                    + " --raw-quality " + QString::number(config->translateQuality()));
  1895 }
  1901 }
  1896 
  1902 
  1897 void HWForm::AssociateFiles()
  1903 void HWForm::AssociateFiles()
  1898 {
  1904 {
  1899     bool success = true;
  1905     bool success = true;
  1904     registry_hkcr.setValue(".hws/Default", "Hedgewars.Save");
  1910     registry_hkcr.setValue(".hws/Default", "Hedgewars.Save");
  1905     registry_hkcr.setValue("Hedgewars.Demo/Default", tr("Hedgewars Demo File", "File Types"));
  1911     registry_hkcr.setValue("Hedgewars.Demo/Default", tr("Hedgewars Demo File", "File Types"));
  1906     registry_hkcr.setValue("Hedgewars.Save/Default", tr("Hedgewars Save File", "File Types"));
  1912     registry_hkcr.setValue("Hedgewars.Save/Default", tr("Hedgewars Save File", "File Types"));
  1907     registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0");
  1913     registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0");
  1908     registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0");
  1914     registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0");
  1909     registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments);
  1915     registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
  1910     registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments);
  1916     registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
  1911 #elif defined __APPLE__
  1917 #elif defined __APPLE__
  1912     // only useful when other apps have taken precedence over our file extensions and you want to reset it
  1918     // only useful when other apps have taken precedence over our file extensions and you want to reset it
  1913     system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hwd</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'");
  1919     system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hwd</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'");
  1914     system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hws</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'");
  1920     system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hws</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'");
  1915     system("/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -domain local -domain system -domain user");
  1921     system("/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -domain local -domain system -domain user");
  1926     if (success) success = system(("cp "+datadir->absolutePath()+"/misc/hwengine.desktop "+QDir::home().absolutePath()+"/.local/share/applications").toLocal8Bit().constData())==0;
  1932     if (success) success = system(("cp "+datadir->absolutePath()+"/misc/hwengine.desktop "+QDir::home().absolutePath()+"/.local/share/applications").toLocal8Bit().constData())==0;
  1927     if (success) success = system(("update-mime-database "+QDir::home().absolutePath()+"/.local/share/mime").toLocal8Bit().constData())==0;
  1933     if (success) success = system(("update-mime-database "+QDir::home().absolutePath()+"/.local/share/mime").toLocal8Bit().constData())==0;
  1928     if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-demo")==0;
  1934     if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-demo")==0;
  1929     if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-save")==0;
  1935     if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-save")==0;
  1930     // hack to add user's settings to hwengine. might be better at this point to read in the file, append it, and write it out to its new home.  This assumes no spaces in the data dir path
  1936     // hack to add user's settings to hwengine. might be better at this point to read in the file, append it, and write it out to its new home.  This assumes no spaces in the data dir path
  1931     if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 "+cfgdir->absolutePath().replace(" ","\\\\ ").replace("/","\\/")+" \\2 --set-everything "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0;
  1937     if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 \\2 "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0;
  1932 #endif
  1938 #endif
  1933     if (success)
  1939     if (success)
  1934     {
  1940     {
  1935         QMessageBox infoMsg(this);
  1941         QMessageBox infoMsg(this);
  1936         infoMsg.setIcon(QMessageBox::Information);
  1942         infoMsg.setIcon(QMessageBox::Information);