Ticket #1810: gamePatch4s.patch
File gamePatch4s.patch, 66.6 KB (added by , 17 years ago) |
---|
-
mythgame/gamehandler.cpp
3 3 #include "rom_metadata.h" 4 4 5 5 #include <qobject.h> 6 #include <qapplication.h> 7 #include <qtimer.h> 8 #include <qprocess.h> 6 9 #include <qptrlist.h> 7 10 #include <qstringlist.h> 8 11 #include <iostream> … … 14 17 #include <mythtv/mythdialogs.h> 15 18 #include <mythtv/util.h> 16 19 20 QProcess *process; 21 QString screencmd; 22 17 23 using namespace std; 18 24 19 25 static QPtrList<GameHandler> *handlers = 0; … … 64 70 void GameHandler::updateSettings(GameHandler *handler) 65 71 { 66 72 MSqlQuery query(MSqlQuery::InitCon()); 67 query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks 73 query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks, screenshotenabled, screenshotcmd FROM gameplayers WHERE playername = \"" + handler->SystemName() + "\";"); 68 74 69 75 query.next(); 70 76 handler->rompath = query.value(0).toString(); … … 75 81 handler->gametype = query.value(5).toString(); 76 82 handler->validextensions = QStringList::split(",", query.value(6).toString().stripWhiteSpace().remove(" ")); 77 83 handler->spandisks = query.value(7).toInt(); 84 handler->screenshotenabled = query.value(8).toInt(); 85 handler->screenshotcmd = query.value(9).toInt(); 78 86 79 87 } 80 88 … … 131 139 cerr << "No romDB data read from database. Not imported?" << endl; 132 140 else 133 141 cerr << "Loaded " << romDB.count() << " items from romDB Database" << endl; 134 135 142 } 136 143 137 144 void GameHandler::GetMetadata(GameHandler *handler, QString rom, QString* Genre, QString* Year, … … 227 234 228 235 } 229 236 237 230 238 void updateDisplayRom(QString romname, int display, QString Systemname) 231 239 { 232 240 MSqlQuery query(MSqlQuery::InitCon()); … … 481 489 int filecount = 0; 482 490 QDir RomDir(directory); 483 491 484 492 // If we can't read it's contents move on 485 493 if (!RomDir.isReadable()) 486 494 return 0; 487 495 … … 647 655 buildFileList(handler->SystemRomPath(),handler,&pdial, &filecount); 648 656 VerifyGameDB(handler); 649 657 650 658 // If we still have some games in the list then update the database 651 659 if (!m_GameMap.empty()) 652 660 { 653 661 InitMetaDataMap(handler->GameType()); … … 674 682 675 683 while(handler) 676 684 { 677 685 updateSettings(handler); 678 686 handler->processGames(handler); 679 687 680 688 if (handler->needRebuild()) … … 731 739 else if (!(handler = GetHandler(romdata))) 732 740 { 733 741 // Couldn't get handler so abort. 734 return ;742 return ; 735 743 } 736 744 QString exec = handler->SystemCmdLine(); 737 745 … … 755 763 { 756 764 if (romdata->DiskCount() > 1) 757 765 { 758 766 // Chop off the extension, . and last character of the name which we are assuming is the disk # 759 767 QString basename = romdata->Romname().left(romdata->Romname().length() - (romdata->getExtension().length() + 2)); 760 768 QString extension = romdata->getExtension(); 761 769 QString rom; … … 824 832 handlers->append(handler); 825 833 } 826 834 835 bool GameHandler::promptShouldOverwrite() 836 { 837 QStringList buttonText; 838 buttonText += QObject::tr("No"); 839 buttonText += QObject::tr("Yes"); 840 841 842 int result = MythPopupBox::showButtonPopup(gContext->GetMainWindow(), 843 QObject::tr("Overwrite existing screenshots?"), 844 QString(QObject::tr("Would you like to overwrite any existing screenshots?")), 845 buttonText, 0 ); 846 switch (result) 847 { 848 case 0: 849 return false; 850 case 1: 851 return true; 852 }; 853 854 return false; 855 } 856 857 void GameHandler::generateScreenshots(void) 858 { 859 checkHandlers(); 860 861 GameHandler *handler = handlers->first(); 862 863 MSqlQuery query(MSqlQuery::InitCon()); 864 // MSqlQuery squery(MSqlQuery::InitCon()); 865 866 867 while(handler) 868 { 869 updateSettings(handler); 870 871 if (handler->ScreenShotEnabled()) 872 { 873 874 875 876 QString thequery; 877 thequery = QString("SELECT romname, rompath, gamename, diskcount " 878 "FROM gamemetadata WHERE system = '%1';") 879 .arg(handler->SystemName()); 880 881 query.exec(thequery); 882 883 // display a dialog box to show the number of roms left to process as it flashes by. 884 MythProgressDialog screenshotDlg(QString("Generating %1(%2) screenshots") 885 .arg(handler->SystemName()) 886 .arg(handler->GameType()), 887 query.numRowsAffected()); 888 889 //QString screenquery; 890 //screenquery = QString("SELECT screenshots FROM gameplayers WHERE playername = '%1';").arg(handler->PlayerName()); 891 //squery.exec(screenquery); 892 893 //QString screenpath = query.value(0).toString(); 894 895 // boolean value to skip existing screenshots from being generated again. 896 bool should_overwrite = promptShouldOverwrite(); 897 898 899 if (should_overwrite) 900 cout << "Screenshot generation started. Overwriting existing screenshots." << endl; 901 else 902 cout << "Screenshot generation started. NOT Overwriting existing screenshots." << endl; 903 904 // start at -1 so we can pre-increment the screenshot counter as the 905 // first step in the loop - thus letting us break out of the loop 906 // and go to the next iteration without having to worry about the 907 // progress bar 908 int counter = -1; 909 910 911 if (query.isActive() && query.size() >0) 912 { 913 914 while (query.next()) 915 { 916 917 screenshotDlg.setProgress(++counter); 918 919 QString romname = query.value(0).toString(); 920 QString rompath = query.value(1).toString(); 921 int diskcount = query.value(3).toInt(); 922 //Get the Extension via the RomInfo Class 923 RomInfo temp; 924 temp.setRomname(romname); 925 QString extension = temp.getExtension(); 926 927 QString basename = romname.left(romname.length() - (extension.length() + 1)); 928 929 QString exec = handler->SystemCmdLine(); 930 931 932 933 if (handler->GameType() != "PC") 934 { 935 QString arg = "\"" + rompath + "/" + romname + "\""; 936 937 // only bother checking if a screenshot exists if the user specified they care to keep them 938 // - doing this saves time at execution. 939 if (!should_overwrite) { 940 QString ImageCheck(romname); 941 //cout << "Searching for existing screenshot for rom: " << ImageCheck << " at " << handler->SystemScreenShots() << "/" << romname << endl; 942 943 if (RomInfo::FindImage(handler->SystemScreenShots() + "/" + romname, &ImageCheck)) { 944 //cout << "\tFound at: " << ImageCheck << endl; 945 continue; 946 } 947 948 } 949 950 // If they specified a %s in the commandline place the romname 951 // in that location, otherwise tack it on to the end of 952 // the command. 953 if (exec.contains("%s") || handler->SpanDisks()) 954 { 955 exec = exec.replace(QRegExp("%s"),arg); 956 957 if (handler->SpanDisks()) 958 { 959 QRegExp rxp = QRegExp( "%d[0-4]", TRUE, FALSE ); 960 961 if (exec.contains(rxp)) 962 { 963 if (diskcount > 1) 964 { 965 // Chop off the extension, . and last character of the name which we are assuming is the disk # 966 QString rom; 967 QString diskid[] = { "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6" }; 968 969 for (int disk = 1; disk <= diskcount; disk++) 970 { 971 rom = QString("\"%1/%2%3.%4\"") 972 .arg(rompath) 973 .arg(basename) 974 .arg(disk) 975 .arg(extension); 976 exec = exec.replace(QRegExp(diskid[disk]),rom); 977 } 978 } 979 980 else 981 { // If there is only one disk make sure we replace %d1 just like %s 982 exec = exec.replace(QRegExp("%d1"),arg); 983 } 984 } 985 } 986 } 987 else 988 { 989 exec = exec + " \"" + 990 rompath + "/" + 991 romname + "\""; 992 } 993 } 994 995 QString savedir = QDir::currentDirPath (); 996 QDir d; 997 if (handler->SystemWorkingPath()) { 998 if (!d.cd(handler->SystemWorkingPath())) 999 { 1000 cout << "Failed to change to specified Working Directory : " << handler->SystemWorkingPath() << endl; 1001 } 1002 } 1003 1004 if (handler->ScreenShotCmd().length() < 2) 1005 screencmd = gContext->GetSetting("GameScreenshotCmd"); 1006 else 1007 screencmd = handler->ScreenShotCmd(); 1008 1009 if (screencmd.contains("%p")) 1010 { 1011 QString reptxt = handler->SystemScreenShots() + "/" + basename; 1012 screencmd = screencmd.replace(QRegExp("%p"),reptxt); 1013 } 1014 1015 if (screencmd.contains("%s")) 1016 { 1017 QString reptxt = rompath + "/" + romname; 1018 screencmd = screencmd.replace(QRegExp("%s"),reptxt); 1019 } 1020 1021 process = new QProcess(); 1022 1023 // We need to pass separate args to QProcess. Rather than split 1024 // "exec" up, (which would require parsing the user-supplied 1025 // command), get sh to do it 1026 QStringList shellCmd; 1027 1028 shellCmd.append("sh"); 1029 shellCmd.append("-c"); 1030 shellCmd.append(exec); 1031 1032 process->setArguments(shellCmd); 1033 1034 QString ShotTime = gContext->GetSetting("GameScreenshotTime"); 1035 int myShotTime = ShotTime.toInt() * 1000; 1036 1037 m_TimerDone = false; 1038 1039 QTimer::singleShot( myShotTime, this, SLOT( screenshotTimeout() ) ); 1040 1041 if (!process->start()) 1042 cout << "Error running Process:" << exec << endl; 1043 1044 // some emulators such as xmame or sdlmess will 1045 // quit prematurely if it is fed a bad ROM file. The m_TimerDone 1046 // variable is set to true when the timer kills the process. 1047 // if this is not done, the program can trip over itself because 1048 // it would iterate throuh the next step in the loop, and then then 1049 // when the timer is run out - it would kill whatever process happened 1050 // to be pointing to. 1051 while (process->isRunning() | !m_TimerDone){ 1052 qApp->processEvents(); 1053 } 1054 1055 delete process; 1056 } 1057 } 1058 1059 screenshotDlg.Close(); 1060 } 1061 1062 handler = handlers->next(); 1063 1064 } 1065 } 1066 void GameHandler::screenshotTimeout(void) 1067 { 1068 // there is a chance the process already killed itself... 1069 // in which case we don't need to take a screenshot of the MythTV Gui 1070 if (process->isRunning()) { 1071 myth_system(screencmd); 1072 process->kill(); 1073 } 1074 m_TimerDone = true; 1075 } -
mythgame/game_settings.xml
24 24 <text>Game Players</text> 25 25 <text lang="IT">Impostazioni generali</text> 26 26 <text lang="ES">Opciones Reproductores</text> 27 <text lang="CA"> Opcions Generals</text>28 <text lang="DE"> Grundeinstellungen</text>27 <text lang="CA"></text> 28 <text lang="DE">Spielestarter</text> 29 29 <text lang="DK">Spil Systemer</text> 30 30 <text lang="NL">Algemeen</text> 31 31 <text lang="PT">Jogadores</text> … … 59 59 <text>Clear Game Data</text> 60 60 <text lang="IT">Impostazioni generali</text> 61 61 <text lang="ES">Borrar Datos</text> 62 <text lang="CA"> Opcions Generals</text>63 <text lang="DE"> Grundeinstellungen</text>62 <text lang="CA"></text> 63 <text lang="DE">Loesche Spieleliste</text> 64 64 <text lang="DK">Slet spil data</text> 65 <text lang="NL"> Algemeen</text>65 <text lang="NL"></text> 66 66 <text lang="PT">Apagar Dados de Jogos</text> 67 67 <text lang="SV">Generella instÀllningar</text> 68 68 <text lang="SI">SploÅ¡ne nastavitve</text> … … 73 73 <action>CLEAR_GAME_DATA</action> 74 74 </button> 75 75 76 <button> 77 <type>GAME_SETTINGS_GENERAL</type> 78 <text>Generate Screenshots</text> 79 <text lang="IT"></text> 80 <text lang="ES"></text> 81 <text lang="CA"></text> 82 <text lang="DE">Screenshots erzeugen</text> 83 <text lang="DK"></text> 84 <text lang="NL"></text> 85 <text lang="PT"></text> 86 <text lang="SV"></text> 87 <text lang="SI"></text> 88 <text lang="FI"></text> 89 <action>GENERATE_SCREENSHOTS</action> 90 </button> 76 91 77 92 </mythmenu> -
mythgame/gamehandler.h
53 53 54 54 typedef QMap <QString, GameScan> GameScanMap; 55 55 56 class GameHandler 57 { 56 class GameHandler : public QObject 57 { 58 59 Q_OBJECT 60 58 61 public: 59 62 GameHandler() 60 63 { 61 64 m_RemoveAll = false; 62 65 m_KeepAll = false; 66 m_TimerDone = false; 63 67 rebuild = false; 64 68 } 65 69 … … 78 82 void VerifyGameDB(GameHandler *handler); 79 83 80 84 static void clearAllGameData(void); 85 void generateScreenshots(void); 81 86 82 87 static int buildFileCount(QString directory, GameHandler *handler); 83 88 void buildFileList(QString directory, GameHandler *handler, … … 96 101 97 102 static RomInfo* create_rominfo(RomInfo* parent); 98 103 int SpanDisks() const { return spandisks; } 104 105 int ScreenShotEnabled() const { return screenshotenabled; } 106 bool promptShouldOverwrite(); 107 99 108 QString SystemName() const { return systemname; } 100 109 QString SystemCmdLine() const { return commandline; } 101 110 QString SystemRomPath() const { return rompath; } … … 103 112 QString SystemScreenShots() const { return screenshots; } 104 113 uint GamePlayerID() const { return gameplayerid; } 105 114 QString GameType() const { return gametype; } 115 QString ScreenShotCmd() const { return screenshotcmd; } 116 117 public slots: 118 void screenshotTimeout(void); 106 119 107 120 protected: 108 121 static GameHandler* GetHandler(RomInfo *rominfo); … … 110 123 111 124 bool rebuild; 112 125 int spandisks; 126 int screenshotenabled; 113 127 QString systemname; 114 128 QString rompath; 115 129 QString commandline; … … 117 131 QString screenshots; 118 132 uint gameplayerid; 119 133 QString gametype; 134 QString screenshotcmd; 120 135 QStringList validextensions; 121 136 122 137 RomDBMap romDB; … … 124 139 125 140 bool m_RemoveAll; 126 141 bool m_KeepAll; 127 142 bool m_TimerDone; 143 128 144 private: 129 145 static GameHandler* newInstance; 130 146 -
mythgame/rominfo.h
52 52 53 53 virtual ~RomInfo() {} 54 54 55 bool FindImage(QString BaseFileName, QString *result);55 static bool FindImage(QString BaseFileName, QString *result); 56 56 57 57 QString Rompath() const { return rompath; } 58 58 void setRompath(const QString &lrompath) { rompath = lrompath; } -
mythgame/dbcheck.cpp
10 10 11 11 #include "gamesettings.h" 12 12 13 const QString currentDatabaseVersion = "101 2";13 const QString currentDatabaseVersion = "1013"; 14 14 15 15 static bool UpdateDBVersionNumber(const QString &newnumber) 16 16 { … … 320 320 } 321 321 322 322 323 if (dbver == "1012") 324 { 325 const QString updates[] = { 326 "ALTER TABLE gameplayers ADD COLUMN screenshotcmd text NOT NULL default ''; ", 327 "ALTER TABLE gameplayers ADD COLUMN screenshotenabled tinyint(1) NOT NULL default '0'; ", 328 "" 329 }; 323 330 331 if (!performActualUpdate(updates, "1013", dbver)) 332 return false; 333 } 324 334 325 335 336 337 338 326 339 return true; 327 340 } -
mythgame/main.cpp
34 34 settings.exec(); 35 35 } 36 36 37 if (sel == "game_players")37 else if (sel == "game_players") 38 38 { 39 40 39 MythGamePlayerEditor mgpe; 40 mgpe.exec(); 41 41 } 42 42 else if (sel == "search_for_games") 43 43 { 44 44 GameHandler::processAllGames(); 45 45 } 46 if (sel == "clear_game_data") 46 47 else if (sel == "clear_game_data") 47 48 { 48 49 GameHandler::clearAllGameData(); 49 50 } 50 51 52 else if (sel == "generate_screenshots") 53 { 54 GameHandler myHandler; 55 myHandler.generateScreenshots(); 56 } 57 51 58 } 52 59 53 60 void runMenu(QString which_menu) -
mythgame/gamesettings.cpp
75 75 gc->setHelpText(QObject::tr("Enabling this causes the filenames to be displayed in the game tree rather than the trimmed/looked up gamename")); 76 76 return gc; 77 77 } 78 static HostLineEdit *GameScreenshotCmd() 79 { 80 HostLineEdit *gc = new HostLineEdit("GameScreenshotCmd"); 81 gc->setLabel(QObject::tr("Screenshot Command")); 82 gc->setValue("/usr/bin/scrot --quality 1 \"%p.png\""); 83 gc->setHelpText(QObject::tr("Program which generates Screenshots " 84 "when the Rom is started in Background " 85 "use %s for romname and %p for the imagename without extension.")); 86 return gc; 87 } 78 88 89 static HostLineEdit *GameScreenshotTime() 90 { 91 HostLineEdit *gc = new HostLineEdit("GameScreenshotTime"); 92 gc->setLabel(QObject::tr("Screenshot Timeout:")); 93 gc->setValue("10"); 94 gc->setHelpText(QObject::tr("Enter Time (in seconds) after which a Screenshot is taken")); 95 return gc; 96 } 97 79 98 static HostCheckBox *GameTreeView() 80 99 { 81 100 HostCheckBox *gc = new HostCheckBox("GameTreeView"); … … 95 114 general->addChild(GameRemovalPrompt()); 96 115 general->addChild(GameShowFileNames()); 97 116 general->addChild(GameTreeView()); 117 VerticalConfigurationGroup *screenshot = new VerticalConfigurationGroup(false); 118 screenshot->setLabel(QObject::tr("MythGame Settings -- Screenshots")); 119 screenshot->addChild(GameScreenshotCmd()); 120 screenshot->addChild(GameScreenshotTime()); 121 98 122 addChild(general); 123 addChild(screenshot); 99 124 } 100 125 101 126 // Player Settings … … 190 215 }; 191 216 }; 192 217 218 class GenerateScreenshots: virtual public MGSetting, virtual public CheckBoxSetting { 219 public: 220 GenerateScreenshots(const MythGamePlayerSettings& parent): 221 MGSetting(parent, "screenshotenabled") { 222 setLabel(QObject::tr("Generate screenshots")); 223 setHelpText(QObject::tr("This setting means that this Gameplayer is included in the generation of screenshots.")); 224 }; 225 }; 226 227 class GenerateScreenshotsCmd: virtual public MGSetting, virtual public LineEditSetting { 228 public: 229 GenerateScreenshotsCmd(const MythGamePlayerSettings& parent): 230 MGSetting(parent, "screenshotcmd") { 231 setLabel(QObject::tr("Screenshot Command")); 232 setHelpText(QObject::tr("If you want another Command then the global to Generate Screenshots, Enter it here!")); 233 }; 234 }; 235 193 236 MythGamePlayerSettings::MythGamePlayerSettings() 194 237 { 195 238 // must be first … … 205 248 group->addChild(new WorkingDirPath(*this)); 206 249 group->addChild(new Extensions(*this)); 207 250 group->addChild(new AllowMultipleRoms(*this)); 251 group->addChild(new GenerateScreenshots(*this)); 252 group->addChild(new GenerateScreenshotsCmd(*this)); 208 253 addChild(group); 209 254 }; 210 255 -
mythgame/gamehandler.cpp
3 3 #include "rom_metadata.h" 4 4 5 5 #include <qobject.h> 6 #include <qapplication.h> 7 #include <qtimer.h> 8 #include <qprocess.h> 6 9 #include <qptrlist.h> 7 10 #include <qstringlist.h> 8 11 #include <iostream> … … 14 17 #include <mythtv/mythdialogs.h> 15 18 #include <mythtv/util.h> 16 19 20 QProcess *process; 21 QString screencmd; 22 17 23 using namespace std; 18 24 19 25 static QPtrList<GameHandler> *handlers = 0; … … 64 70 void GameHandler::updateSettings(GameHandler *handler) 65 71 { 66 72 MSqlQuery query(MSqlQuery::InitCon()); 67 query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks 73 query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks, screenshotenabled, screenshotcmd FROM gameplayers WHERE playername = \"" + handler->SystemName() + "\";"); 68 74 69 75 query.next(); 70 76 handler->rompath = query.value(0).toString(); … … 75 81 handler->gametype = query.value(5).toString(); 76 82 handler->validextensions = QStringList::split(",", query.value(6).toString().stripWhiteSpace().remove(" ")); 77 83 handler->spandisks = query.value(7).toInt(); 84 handler->screenshotenabled = query.value(8).toInt(); 85 handler->screenshotcmd = query.value(9).toInt(); 78 86 79 87 } 80 88 … … 131 139 cerr << "No romDB data read from database. Not imported?" << endl; 132 140 else 133 141 cerr << "Loaded " << romDB.count() << " items from romDB Database" << endl; 134 135 142 } 136 143 137 144 void GameHandler::GetMetadata(GameHandler *handler, QString rom, QString* Genre, QString* Year, … … 227 234 228 235 } 229 236 237 230 238 void updateDisplayRom(QString romname, int display, QString Systemname) 231 239 { 232 240 MSqlQuery query(MSqlQuery::InitCon()); … … 481 489 int filecount = 0; 482 490 QDir RomDir(directory); 483 491 484 492 // If we can't read it's contents move on 485 493 if (!RomDir.isReadable()) 486 494 return 0; 487 495 … … 647 655 buildFileList(handler->SystemRomPath(),handler,&pdial, &filecount); 648 656 VerifyGameDB(handler); 649 657 650 658 // If we still have some games in the list then update the database 651 659 if (!m_GameMap.empty()) 652 660 { 653 661 InitMetaDataMap(handler->GameType()); … … 674 682 675 683 while(handler) 676 684 { 677 685 updateSettings(handler); 678 686 handler->processGames(handler); 679 687 680 688 if (handler->needRebuild()) … … 731 739 else if (!(handler = GetHandler(romdata))) 732 740 { 733 741 // Couldn't get handler so abort. 734 return ;742 return ; 735 743 } 736 744 QString exec = handler->SystemCmdLine(); 737 745 … … 755 763 { 756 764 if (romdata->DiskCount() > 1) 757 765 { 758 766 // Chop off the extension, . and last character of the name which we are assuming is the disk # 759 767 QString basename = romdata->Romname().left(romdata->Romname().length() - (romdata->getExtension().length() + 2)); 760 768 QString extension = romdata->getExtension(); 761 769 QString rom; … … 824 832 handlers->append(handler); 825 833 } 826 834 835 bool GameHandler::promptShouldOverwrite() 836 { 837 QStringList buttonText; 838 buttonText += QObject::tr("No"); 839 buttonText += QObject::tr("Yes"); 840 841 842 int result = MythPopupBox::showButtonPopup(gContext->GetMainWindow(), 843 QObject::tr("Overwrite existing screenshots?"), 844 QString(QObject::tr("Would you like to overwrite any existing screenshots?")), 845 buttonText, 0 ); 846 switch (result) 847 { 848 case 0: 849 return false; 850 case 1: 851 return true; 852 }; 853 854 return false; 855 } 856 857 void GameHandler::generateScreenshots(void) 858 { 859 checkHandlers(); 860 861 GameHandler *handler = handlers->first(); 862 863 MSqlQuery query(MSqlQuery::InitCon()); 864 // MSqlQuery squery(MSqlQuery::InitCon()); 865 866 867 while(handler) 868 { 869 updateSettings(handler); 870 871 if (handler->ScreenShotEnabled()) 872 { 873 874 875 876 QString thequery; 877 thequery = QString("SELECT romname, rompath, gamename, diskcount " 878 "FROM gamemetadata WHERE system = '%1';") 879 .arg(handler->SystemName()); 880 881 query.exec(thequery); 882 883 // display a dialog box to show the number of roms left to process as it flashes by. 884 MythProgressDialog screenshotDlg(QString("Generating %1(%2) screenshots") 885 .arg(handler->SystemName()) 886 .arg(handler->GameType()), 887 query.numRowsAffected()); 888 889 //QString screenquery; 890 //screenquery = QString("SELECT screenshots FROM gameplayers WHERE playername = '%1';").arg(handler->PlayerName()); 891 //squery.exec(screenquery); 892 893 //QString screenpath = query.value(0).toString(); 894 895 // boolean value to skip existing screenshots from being generated again. 896 bool should_overwrite = promptShouldOverwrite(); 897 898 899 if (should_overwrite) 900 cout << "Screenshot generation started. Overwriting existing screenshots." << endl; 901 else 902 cout << "Screenshot generation started. NOT Overwriting existing screenshots." << endl; 903 904 // start at -1 so we can pre-increment the screenshot counter as the 905 // first step in the loop - thus letting us break out of the loop 906 // and go to the next iteration without having to worry about the 907 // progress bar 908 int counter = -1; 909 910 911 if (query.isActive() && query.size() >0) 912 { 913 914 while (query.next()) 915 { 916 917 screenshotDlg.setProgress(++counter); 918 919 QString romname = query.value(0).toString(); 920 QString rompath = query.value(1).toString(); 921 int diskcount = query.value(3).toInt(); 922 //Get the Extension via the RomInfo Class 923 RomInfo temp; 924 temp.setRomname(romname); 925 QString extension = temp.getExtension(); 926 927 QString basename = romname.left(romname.length() - (extension.length() + 1)); 928 929 QString exec = handler->SystemCmdLine(); 930 931 932 933 if (handler->GameType() != "PC") 934 { 935 QString arg = "\"" + rompath + "/" + romname + "\""; 936 937 // only bother checking if a screenshot exists if the user specified they care to keep them 938 // - doing this saves time at execution. 939 if (!should_overwrite) { 940 QString ImageCheck(romname); 941 //cout << "Searching for existing screenshot for rom: " << ImageCheck << " at " << handler->SystemScreenShots() << "/" << romname << endl; 942 943 if (RomInfo::FindImage(handler->SystemScreenShots() + "/" + romname, &ImageCheck)) { 944 //cout << "\tFound at: " << ImageCheck << endl; 945 continue; 946 } 947 948 } 949 950 // If they specified a %s in the commandline place the romname 951 // in that location, otherwise tack it on to the end of 952 // the command. 953 if (exec.contains("%s") || handler->SpanDisks()) 954 { 955 exec = exec.replace(QRegExp("%s"),arg); 956 957 if (handler->SpanDisks()) 958 { 959 QRegExp rxp = QRegExp( "%d[0-4]", TRUE, FALSE ); 960 961 if (exec.contains(rxp)) 962 { 963 if (diskcount > 1) 964 { 965 // Chop off the extension, . and last character of the name which we are assuming is the disk # 966 QString rom; 967 QString diskid[] = { "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6" }; 968 969 for (int disk = 1; disk <= diskcount; disk++) 970 { 971 rom = QString("\"%1/%2%3.%4\"") 972 .arg(rompath) 973 .arg(basename) 974 .arg(disk) 975 .arg(extension); 976 exec = exec.replace(QRegExp(diskid[disk]),rom); 977 } 978 } 979 980 else 981 { // If there is only one disk make sure we replace %d1 just like %s 982 exec = exec.replace(QRegExp("%d1"),arg); 983 } 984 } 985 } 986 } 987 else 988 { 989 exec = exec + " \"" + 990 rompath + "/" + 991 romname + "\""; 992 } 993 } 994 995 QString savedir = QDir::currentDirPath (); 996 QDir d; 997 if (handler->SystemWorkingPath()) { 998 if (!d.cd(handler->SystemWorkingPath())) 999 { 1000 cout << "Failed to change to specified Working Directory : " << handler->SystemWorkingPath() << endl; 1001 } 1002 } 1003 1004 if (handler->ScreenShotCmd().length() < 2) 1005 screencmd = gContext->GetSetting("GameScreenshotCmd"); 1006 else 1007 screencmd = handler->ScreenShotCmd(); 1008 1009 if (screencmd.contains("%p")) 1010 { 1011 QString reptxt = handler->SystemScreenShots() + "/" + basename; 1012 screencmd = screencmd.replace(QRegExp("%p"),reptxt); 1013 } 1014 1015 if (screencmd.contains("%s")) 1016 { 1017 QString reptxt = rompath + "/" + romname; 1018 screencmd = screencmd.replace(QRegExp("%s"),reptxt); 1019 } 1020 1021 process = new QProcess(); 1022 1023 // We need to pass separate args to QProcess. Rather than split 1024 // "exec" up, (which would require parsing the user-supplied 1025 // command), get sh to do it 1026 QStringList shellCmd; 1027 1028 shellCmd.append("sh"); 1029 shellCmd.append("-c"); 1030 shellCmd.append(exec); 1031 1032 process->setArguments(shellCmd); 1033 1034 QString ShotTime = gContext->GetSetting("GameScreenshotTime"); 1035 int myShotTime = ShotTime.toInt() * 1000; 1036 1037 m_TimerDone = false; 1038 1039 QTimer::singleShot( myShotTime, this, SLOT( screenshotTimeout() ) ); 1040 1041 if (!process->start()) 1042 cout << "Error running Process:" << exec << endl; 1043 1044 // some emulators such as xmame or sdlmess will 1045 // quit prematurely if it is fed a bad ROM file. The m_TimerDone 1046 // variable is set to true when the timer kills the process. 1047 // if this is not done, the program can trip over itself because 1048 // it would iterate throuh the next step in the loop, and then then 1049 // when the timer is run out - it would kill whatever process happened 1050 // to be pointing to. 1051 while (process->isRunning() | !m_TimerDone){ 1052 qApp->processEvents(); 1053 } 1054 1055 delete process; 1056 } 1057 } 1058 1059 screenshotDlg.Close(); 1060 } 1061 1062 handler = handlers->next(); 1063 1064 } 1065 } 1066 void GameHandler::screenshotTimeout(void) 1067 { 1068 // there is a chance the process already killed itself... 1069 // in which case we don't need to take a screenshot of the MythTV Gui 1070 if (process->isRunning()) { 1071 myth_system(screencmd); 1072 process->kill(); 1073 } 1074 m_TimerDone = true; 1075 } -
mythgame/game_settings.xml
24 24 <text>Game Players</text> 25 25 <text lang="IT">Impostazioni generali</text> 26 26 <text lang="ES">Opciones Reproductores</text> 27 <text lang="CA"> Opcions Generals</text>28 <text lang="DE"> Grundeinstellungen</text>27 <text lang="CA"></text> 28 <text lang="DE">Spielestarter</text> 29 29 <text lang="DK">Spil Systemer</text> 30 30 <text lang="NL">Algemeen</text> 31 31 <text lang="PT">Jogadores</text> … … 59 59 <text>Clear Game Data</text> 60 60 <text lang="IT">Impostazioni generali</text> 61 61 <text lang="ES">Borrar Datos</text> 62 <text lang="CA"> Opcions Generals</text>63 <text lang="DE"> Grundeinstellungen</text>62 <text lang="CA"></text> 63 <text lang="DE">Loesche Spieleliste</text> 64 64 <text lang="DK">Slet spil data</text> 65 <text lang="NL"> Algemeen</text>65 <text lang="NL"></text> 66 66 <text lang="PT">Apagar Dados de Jogos</text> 67 67 <text lang="SV">Generella instÀllningar</text> 68 68 <text lang="SI">SploÅ¡ne nastavitve</text> … … 73 73 <action>CLEAR_GAME_DATA</action> 74 74 </button> 75 75 76 <button> 77 <type>GAME_SETTINGS_GENERAL</type> 78 <text>Generate Screenshots</text> 79 <text lang="IT"></text> 80 <text lang="ES"></text> 81 <text lang="CA"></text> 82 <text lang="DE">Screenshots erzeugen</text> 83 <text lang="DK"></text> 84 <text lang="NL"></text> 85 <text lang="PT"></text> 86 <text lang="SV"></text> 87 <text lang="SI"></text> 88 <text lang="FI"></text> 89 <action>GENERATE_SCREENSHOTS</action> 90 </button> 76 91 77 92 </mythmenu> -
mythgame/gamehandler.h
53 53 54 54 typedef QMap <QString, GameScan> GameScanMap; 55 55 56 class GameHandler 57 { 56 class GameHandler : public QObject 57 { 58 59 Q_OBJECT 60 58 61 public: 59 62 GameHandler() 60 63 { 61 64 m_RemoveAll = false; 62 65 m_KeepAll = false; 66 m_TimerDone = false; 63 67 rebuild = false; 64 68 } 65 69 … … 78 82 void VerifyGameDB(GameHandler *handler); 79 83 80 84 static void clearAllGameData(void); 85 void generateScreenshots(void); 81 86 82 87 static int buildFileCount(QString directory, GameHandler *handler); 83 88 void buildFileList(QString directory, GameHandler *handler, … … 96 101 97 102 static RomInfo* create_rominfo(RomInfo* parent); 98 103 int SpanDisks() const { return spandisks; } 104 105 int ScreenShotEnabled() const { return screenshotenabled; } 106 bool promptShouldOverwrite(); 107 99 108 QString SystemName() const { return systemname; } 100 109 QString SystemCmdLine() const { return commandline; } 101 110 QString SystemRomPath() const { return rompath; } … … 103 112 QString SystemScreenShots() const { return screenshots; } 104 113 uint GamePlayerID() const { return gameplayerid; } 105 114 QString GameType() const { return gametype; } 115 QString ScreenShotCmd() const { return screenshotcmd; } 116 117 public slots: 118 void screenshotTimeout(void); 106 119 107 120 protected: 108 121 static GameHandler* GetHandler(RomInfo *rominfo); … … 110 123 111 124 bool rebuild; 112 125 int spandisks; 126 int screenshotenabled; 113 127 QString systemname; 114 128 QString rompath; 115 129 QString commandline; … … 117 131 QString screenshots; 118 132 uint gameplayerid; 119 133 QString gametype; 134 QString screenshotcmd; 120 135 QStringList validextensions; 121 136 122 137 RomDBMap romDB; … … 124 139 125 140 bool m_RemoveAll; 126 141 bool m_KeepAll; 127 142 bool m_TimerDone; 143 128 144 private: 129 145 static GameHandler* newInstance; 130 146 -
mythgame/rominfo.h
52 52 53 53 virtual ~RomInfo() {} 54 54 55 bool FindImage(QString BaseFileName, QString *result);55 static bool FindImage(QString BaseFileName, QString *result); 56 56 57 57 QString Rompath() const { return rompath; } 58 58 void setRompath(const QString &lrompath) { rompath = lrompath; } -
mythgame/dbcheck.cpp
10 10 11 11 #include "gamesettings.h" 12 12 13 const QString currentDatabaseVersion = "101 2";13 const QString currentDatabaseVersion = "1013"; 14 14 15 15 static bool UpdateDBVersionNumber(const QString &newnumber) 16 16 { … … 320 320 } 321 321 322 322 323 if (dbver == "1012") 324 { 325 const QString updates[] = { 326 "ALTER TABLE gameplayers ADD COLUMN screenshotcmd text NOT NULL default ''; ", 327 "ALTER TABLE gameplayers ADD COLUMN screenshotenabled tinyint(1) NOT NULL default '0'; ", 328 "" 329 }; 330 331 if (!performActualUpdate(updates, "1013", dbver)) 332 return false; 333 } 334 335 323 336 324 337 325 338 -
mythgame/main.cpp
34 34 settings.exec(); 35 35 } 36 36 37 if (sel == "game_players")37 else if (sel == "game_players") 38 38 { 39 40 39 MythGamePlayerEditor mgpe; 40 mgpe.exec(); 41 41 } 42 42 else if (sel == "search_for_games") 43 43 { 44 44 GameHandler::processAllGames(); 45 45 } 46 if (sel == "clear_game_data") 46 47 else if (sel == "clear_game_data") 47 48 { 48 49 GameHandler::clearAllGameData(); 49 50 } 50 51 52 else if (sel == "generate_screenshots") 53 { 54 GameHandler myHandler; 55 myHandler.generateScreenshots(); 56 } 57 51 58 } 52 59 53 60 void runMenu(QString which_menu) -
mythgame/gamesettings.cpp
75 75 gc->setHelpText(QObject::tr("Enabling this causes the filenames to be displayed in the game tree rather than the trimmed/looked up gamename")); 76 76 return gc; 77 77 } 78 static HostLineEdit *GameScreenshotCmd() 79 { 80 HostLineEdit *gc = new HostLineEdit("GameScreenshotCmd"); 81 gc->setLabel(QObject::tr("Screenshot Command")); 82 gc->setValue("/usr/bin/scrot --quality 1 \"%p.png\""); 83 gc->setHelpText(QObject::tr("Program which generates Screenshots " 84 "when the Rom is started in Background " 85 "use %s for romname and %p for the imagename without extension.")); 86 return gc; 87 } 88 89 static HostLineEdit *GameScreenshotTime() 90 { 91 HostLineEdit *gc = new HostLineEdit("GameScreenshotTime"); 92 gc->setLabel(QObject::tr("Screenshot Timeout:")); 93 gc->setValue("10"); 94 gc->setHelpText(QObject::tr("Enter Time (in seconds) after which a Screenshot is taken")); 95 return gc; 96 } 78 97 79 98 static HostCheckBox *GameTreeView() 80 99 { … … 95 114 general->addChild(GameRemovalPrompt()); 96 115 general->addChild(GameShowFileNames()); 97 116 general->addChild(GameTreeView()); 117 VerticalConfigurationGroup *screenshot = new VerticalConfigurationGroup(false); 118 screenshot->setLabel(QObject::tr("MythGame Settings -- Screenshots")); 119 screenshot->addChild(GameScreenshotCmd()); 120 screenshot->addChild(GameScreenshotTime()); 121 98 122 addChild(general); 123 addChild(screenshot); 99 124 } 100 125 101 126 // Player Settings … … 190 215 }; 191 216 }; 192 217 218 class GenerateScreenshots: virtual public MGSetting, virtual public CheckBoxSetting { 219 public: 220 GenerateScreenshots(const MythGamePlayerSettings& parent): 221 MGSetting(parent, "screenshotenabled") { 222 setLabel(QObject::tr("Generate screenshots")); 223 setHelpText(QObject::tr("This setting means that this Gameplayer is included in the generation of screenshots.")); 224 }; 225 }; 226 227 class GenerateScreenshotsCmd: virtual public MGSetting, virtual public LineEditSetting { 228 public: 229 GenerateScreenshotsCmd(const MythGamePlayerSettings& parent): 230 MGSetting(parent, "screenshotcmd") { 231 setLabel(QObject::tr("Screenshot Command")); 232 setHelpText(QObject::tr("If you want another Command then the global to Generate Screenshots, Enter it here!")); 233 }; 234 }; 235 193 236 MythGamePlayerSettings::MythGamePlayerSettings() 194 237 { 195 238 // must be first … … 205 248 group->addChild(new WorkingDirPath(*this)); 206 249 group->addChild(new Extensions(*this)); 207 250 group->addChild(new AllowMultipleRoms(*this)); 251 group->addChild(new GenerateScreenshots(*this)); 252 group->addChild(new GenerateScreenshotsCmd(*this)); 208 253 addChild(group); 209 254 }; 210 255 -
mythgame/gamehandler.cpp
3 3 #include "rom_metadata.h" 4 4 5 5 #include <qobject.h> 6 #include <qapplication.h> 7 #include <qtimer.h> 8 #include <qprocess.h> 6 9 #include <qptrlist.h> 7 10 #include <qstringlist.h> 8 11 #include <iostream> … … 14 17 #include <mythtv/mythdialogs.h> 15 18 #include <mythtv/util.h> 16 19 20 QProcess *process; 21 QString screencmd; 22 17 23 using namespace std; 18 24 19 25 static QPtrList<GameHandler> *handlers = 0; … … 64 70 void GameHandler::updateSettings(GameHandler *handler) 65 71 { 66 72 MSqlQuery query(MSqlQuery::InitCon()); 67 query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks 73 query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks, screenshotenabled, screenshotcmd FROM gameplayers WHERE playername = \"" + handler->SystemName() + "\";"); 68 74 69 75 query.next(); 70 76 handler->rompath = query.value(0).toString(); … … 75 81 handler->gametype = query.value(5).toString(); 76 82 handler->validextensions = QStringList::split(",", query.value(6).toString().stripWhiteSpace().remove(" ")); 77 83 handler->spandisks = query.value(7).toInt(); 84 handler->screenshotenabled = query.value(8).toInt(); 85 handler->screenshotcmd = query.value(9).toInt(); 78 86 79 87 } 80 88 … … 131 139 cerr << "No romDB data read from database. Not imported?" << endl; 132 140 else 133 141 cerr << "Loaded " << romDB.count() << " items from romDB Database" << endl; 134 135 142 } 136 143 137 144 void GameHandler::GetMetadata(GameHandler *handler, QString rom, QString* Genre, QString* Year, … … 227 234 228 235 } 229 236 237 230 238 void updateDisplayRom(QString romname, int display, QString Systemname) 231 239 { 232 240 MSqlQuery query(MSqlQuery::InitCon()); … … 481 489 int filecount = 0; 482 490 QDir RomDir(directory); 483 491 484 492 // If we can't read it's contents move on 485 493 if (!RomDir.isReadable()) 486 494 return 0; 487 495 … … 647 655 buildFileList(handler->SystemRomPath(),handler,&pdial, &filecount); 648 656 VerifyGameDB(handler); 649 657 650 658 // If we still have some games in the list then update the database 651 659 if (!m_GameMap.empty()) 652 660 { 653 661 InitMetaDataMap(handler->GameType()); … … 674 682 675 683 while(handler) 676 684 { 677 685 updateSettings(handler); 678 686 handler->processGames(handler); 679 687 680 688 if (handler->needRebuild()) … … 731 739 else if (!(handler = GetHandler(romdata))) 732 740 { 733 741 // Couldn't get handler so abort. 734 return ;742 return ; 735 743 } 736 744 QString exec = handler->SystemCmdLine(); 737 745 … … 755 763 { 756 764 if (romdata->DiskCount() > 1) 757 765 { 758 766 // Chop off the extension, . and last character of the name which we are assuming is the disk # 759 767 QString basename = romdata->Romname().left(romdata->Romname().length() - (romdata->getExtension().length() + 2)); 760 768 QString extension = romdata->getExtension(); 761 769 QString rom; … … 824 832 handlers->append(handler); 825 833 } 826 834 835 bool GameHandler::promptShouldOverwrite() 836 { 837 QStringList buttonText; 838 buttonText += QObject::tr("No"); 839 buttonText += QObject::tr("Yes"); 840 841 842 int result = MythPopupBox::showButtonPopup(gContext->GetMainWindow(), 843 QObject::tr("Overwrite existing screenshots?"), 844 QString(QObject::tr("Would you like to overwrite any existing screenshots?")), 845 buttonText, 0 ); 846 switch (result) 847 { 848 case 0: 849 return false; 850 case 1: 851 return true; 852 }; 853 854 return false; 855 } 856 857 void GameHandler::generateScreenshots(void) 858 { 859 checkHandlers(); 860 861 GameHandler *handler = handlers->first(); 862 863 MSqlQuery query(MSqlQuery::InitCon()); 864 // MSqlQuery squery(MSqlQuery::InitCon()); 865 866 867 while(handler) 868 { 869 updateSettings(handler); 870 871 if (handler->ScreenShotEnabled()) 872 { 873 874 875 876 QString thequery; 877 thequery = QString("SELECT romname, rompath, gamename, diskcount " 878 "FROM gamemetadata WHERE system = '%1';") 879 .arg(handler->SystemName()); 880 881 query.exec(thequery); 882 883 // display a dialog box to show the number of roms left to process as it flashes by. 884 MythProgressDialog screenshotDlg(QString("Generating %1(%2) screenshots") 885 .arg(handler->SystemName()) 886 .arg(handler->GameType()), 887 query.numRowsAffected()); 888 889 //QString screenquery; 890 //screenquery = QString("SELECT screenshots FROM gameplayers WHERE playername = '%1';").arg(handler->PlayerName()); 891 //squery.exec(screenquery); 892 893 //QString screenpath = query.value(0).toString(); 894 895 // boolean value to skip existing screenshots from being generated again. 896 bool should_overwrite = promptShouldOverwrite(); 897 898 899 if (should_overwrite) 900 cout << "Screenshot generation started. Overwriting existing screenshots." << endl; 901 else 902 cout << "Screenshot generation started. NOT Overwriting existing screenshots." << endl; 903 904 // start at -1 so we can pre-increment the screenshot counter as the 905 // first step in the loop - thus letting us break out of the loop 906 // and go to the next iteration without having to worry about the 907 // progress bar 908 int counter = -1; 909 910 911 if (query.isActive() && query.size() >0) 912 { 913 914 while (query.next()) 915 { 916 917 screenshotDlg.setProgress(++counter); 918 919 QString romname = query.value(0).toString(); 920 QString rompath = query.value(1).toString(); 921 int diskcount = query.value(3).toInt(); 922 //Get the Extension via the RomInfo Class 923 RomInfo temp; 924 temp.setRomname(romname); 925 QString extension = temp.getExtension(); 926 927 QString basename = romname.left(romname.length() - (extension.length() + 1)); 928 929 QString exec = handler->SystemCmdLine(); 930 931 932 933 if (handler->GameType() != "PC") 934 { 935 QString arg = "\"" + rompath + "/" + romname + "\""; 936 937 // only bother checking if a screenshot exists if the user specified they care to keep them 938 // - doing this saves time at execution. 939 if (!should_overwrite) { 940 QString ImageCheck(romname); 941 //cout << "Searching for existing screenshot for rom: " << ImageCheck << " at " << handler->SystemScreenShots() << "/" << romname << endl; 942 943 if (RomInfo::FindImage(handler->SystemScreenShots() + "/" + romname, &ImageCheck)) { 944 //cout << "\tFound at: " << ImageCheck << endl; 945 continue; 946 } 947 948 } 949 950 // If they specified a %s in the commandline place the romname 951 // in that location, otherwise tack it on to the end of 952 // the command. 953 if (exec.contains("%s") || handler->SpanDisks()) 954 { 955 exec = exec.replace(QRegExp("%s"),arg); 956 957 if (handler->SpanDisks()) 958 { 959 QRegExp rxp = QRegExp( "%d[0-4]", TRUE, FALSE ); 960 961 if (exec.contains(rxp)) 962 { 963 if (diskcount > 1) 964 { 965 // Chop off the extension, . and last character of the name which we are assuming is the disk # 966 QString rom; 967 QString diskid[] = { "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6" }; 968 969 for (int disk = 1; disk <= diskcount; disk++) 970 { 971 rom = QString("\"%1/%2%3.%4\"") 972 .arg(rompath) 973 .arg(basename) 974 .arg(disk) 975 .arg(extension); 976 exec = exec.replace(QRegExp(diskid[disk]),rom); 977 } 978 } 979 980 else 981 { // If there is only one disk make sure we replace %d1 just like %s 982 exec = exec.replace(QRegExp("%d1"),arg); 983 } 984 } 985 } 986 } 987 else 988 { 989 exec = exec + " \"" + 990 rompath + "/" + 991 romname + "\""; 992 } 993 } 994 995 QString savedir = QDir::currentDirPath (); 996 QDir d; 997 if (handler->SystemWorkingPath()) { 998 if (!d.cd(handler->SystemWorkingPath())) 999 { 1000 cout << "Failed to change to specified Working Directory : " << handler->SystemWorkingPath() << endl; 1001 } 1002 } 1003 1004 if (handler->ScreenShotCmd().length() < 2) 1005 screencmd = gContext->GetSetting("GameScreenshotCmd"); 1006 else 1007 screencmd = handler->ScreenShotCmd(); 1008 1009 if (screencmd.contains("%p")) 1010 { 1011 QString reptxt = handler->SystemScreenShots() + "/" + basename; 1012 screencmd = screencmd.replace(QRegExp("%p"),reptxt); 1013 } 1014 1015 if (screencmd.contains("%s")) 1016 { 1017 QString reptxt = rompath + "/" + romname; 1018 screencmd = screencmd.replace(QRegExp("%s"),reptxt); 1019 } 1020 1021 process = new QProcess(); 1022 1023 // We need to pass separate args to QProcess. Rather than split 1024 // "exec" up, (which would require parsing the user-supplied 1025 // command), get sh to do it 1026 QStringList shellCmd; 1027 1028 shellCmd.append("sh"); 1029 shellCmd.append("-c"); 1030 shellCmd.append(exec); 1031 1032 process->setArguments(shellCmd); 1033 1034 QString ShotTime = gContext->GetSetting("GameScreenshotTime"); 1035 int myShotTime = ShotTime.toInt() * 1000; 1036 1037 m_TimerDone = false; 1038 1039 QTimer::singleShot( myShotTime, this, SLOT( screenshotTimeout() ) ); 1040 1041 if (!process->start()) 1042 cout << "Error running Process:" << exec << endl; 1043 1044 // some emulators such as xmame or sdlmess will 1045 // quit prematurely if it is fed a bad ROM file. The m_TimerDone 1046 // variable is set to true when the timer kills the process. 1047 // if this is not done, the program can trip over itself because 1048 // it would iterate throuh the next step in the loop, and then then 1049 // when the timer is run out - it would kill whatever process happened 1050 // to be pointing to. 1051 while (process->isRunning() | !m_TimerDone){ 1052 qApp->processEvents(); 1053 } 1054 1055 delete process; 1056 } 1057 } 1058 1059 screenshotDlg.Close(); 1060 } 1061 1062 handler = handlers->next(); 1063 1064 } 1065 } 1066 void GameHandler::screenshotTimeout(void) 1067 { 1068 // there is a chance the process already killed itself... 1069 // in which case we don't need to take a screenshot of the MythTV Gui 1070 if (process->isRunning()) { 1071 myth_system(screencmd); 1072 process->kill(); 1073 } 1074 m_TimerDone = true; 1075 } -
mythgame/game_settings.xml
24 24 <text>Game Players</text> 25 25 <text lang="IT">Impostazioni generali</text> 26 26 <text lang="ES">Opciones Reproductores</text> 27 <text lang="CA"> Opcions Generals</text>28 <text lang="DE"> Grundeinstellungen</text>27 <text lang="CA"></text> 28 <text lang="DE">Spielestarter</text> 29 29 <text lang="DK">Spil Systemer</text> 30 30 <text lang="NL">Algemeen</text> 31 31 <text lang="PT">Jogadores</text> … … 59 59 <text>Clear Game Data</text> 60 60 <text lang="IT">Impostazioni generali</text> 61 61 <text lang="ES">Borrar Datos</text> 62 <text lang="CA"> Opcions Generals</text>63 <text lang="DE"> Grundeinstellungen</text>62 <text lang="CA"></text> 63 <text lang="DE">Loesche Spieleliste</text> 64 64 <text lang="DK">Slet spil data</text> 65 <text lang="NL"> Algemeen</text>65 <text lang="NL"></text> 66 66 <text lang="PT">Apagar Dados de Jogos</text> 67 67 <text lang="SV">Generella instÀllningar</text> 68 68 <text lang="SI">SploÅ¡ne nastavitve</text> … … 73 73 <action>CLEAR_GAME_DATA</action> 74 74 </button> 75 75 76 <button> 77 <type>GAME_SETTINGS_GENERAL</type> 78 <text>Generate Screenshots</text> 79 <text lang="IT"></text> 80 <text lang="ES"></text> 81 <text lang="CA"></text> 82 <text lang="DE">Screenshots erzeugen</text> 83 <text lang="DK"></text> 84 <text lang="NL"></text> 85 <text lang="PT"></text> 86 <text lang="SV"></text> 87 <text lang="SI"></text> 88 <text lang="FI"></text> 89 <action>GENERATE_SCREENSHOTS</action> 90 </button> 76 91 77 92 </mythmenu> -
mythgame/gamehandler.h
53 53 54 54 typedef QMap <QString, GameScan> GameScanMap; 55 55 56 class GameHandler 57 { 56 class GameHandler : public QObject 57 { 58 59 Q_OBJECT 60 58 61 public: 59 62 GameHandler() 60 63 { 61 64 m_RemoveAll = false; 62 65 m_KeepAll = false; 66 m_TimerDone = false; 63 67 rebuild = false; 64 68 } 65 69 … … 78 82 void VerifyGameDB(GameHandler *handler); 79 83 80 84 static void clearAllGameData(void); 85 void generateScreenshots(void); 81 86 82 87 static int buildFileCount(QString directory, GameHandler *handler); 83 88 void buildFileList(QString directory, GameHandler *handler, … … 96 101 97 102 static RomInfo* create_rominfo(RomInfo* parent); 98 103 int SpanDisks() const { return spandisks; } 104 105 int ScreenShotEnabled() const { return screenshotenabled; } 106 bool promptShouldOverwrite(); 107 99 108 QString SystemName() const { return systemname; } 100 109 QString SystemCmdLine() const { return commandline; } 101 110 QString SystemRomPath() const { return rompath; } … … 103 112 QString SystemScreenShots() const { return screenshots; } 104 113 uint GamePlayerID() const { return gameplayerid; } 105 114 QString GameType() const { return gametype; } 115 QString ScreenShotCmd() const { return screenshotcmd; } 116 117 public slots: 118 void screenshotTimeout(void); 106 119 107 120 protected: 108 121 static GameHandler* GetHandler(RomInfo *rominfo); … … 110 123 111 124 bool rebuild; 112 125 int spandisks; 126 int screenshotenabled; 113 127 QString systemname; 114 128 QString rompath; 115 129 QString commandline; … … 117 131 QString screenshots; 118 132 uint gameplayerid; 119 133 QString gametype; 134 QString screenshotcmd; 120 135 QStringList validextensions; 121 136 122 137 RomDBMap romDB; … … 124 139 125 140 bool m_RemoveAll; 126 141 bool m_KeepAll; 127 142 bool m_TimerDone; 143 128 144 private: 129 145 static GameHandler* newInstance; 130 146 -
mythgame/rominfo.h
52 52 53 53 virtual ~RomInfo() {} 54 54 55 bool FindImage(QString BaseFileName, QString *result);55 static bool FindImage(QString BaseFileName, QString *result); 56 56 57 57 QString Rompath() const { return rompath; } 58 58 void setRompath(const QString &lrompath) { rompath = lrompath; } -
mythgame/dbcheck.cpp
10 10 11 11 #include "gamesettings.h" 12 12 13 const QString currentDatabaseVersion = "101 2";13 const QString currentDatabaseVersion = "1013"; 14 14 15 15 static bool UpdateDBVersionNumber(const QString &newnumber) 16 16 { … … 320 320 } 321 321 322 322 323 if (dbver == "1012") 324 { 325 const QString updates[] = { 326 "ALTER TABLE gameplayers ADD COLUMN screenshotcmd text NOT NULL default ''; ", 327 "ALTER TABLE gameplayers ADD COLUMN screenshotenabled tinyint(1) NOT NULL default '0'; ", 328 "" 329 }; 330 331 if (!performActualUpdate(updates, "1013", dbver)) 332 return false; 333 } 334 335 323 336 324 337 325 338 -
mythgame/main.cpp
34 34 settings.exec(); 35 35 } 36 36 37 if (sel == "game_players")37 else if (sel == "game_players") 38 38 { 39 40 39 MythGamePlayerEditor mgpe; 40 mgpe.exec(); 41 41 } 42 42 else if (sel == "search_for_games") 43 43 { 44 44 GameHandler::processAllGames(); 45 45 } 46 if (sel == "clear_game_data") 46 47 else if (sel == "clear_game_data") 47 48 { 48 49 GameHandler::clearAllGameData(); 49 50 } 50 51 52 else if (sel == "generate_screenshots") 53 { 54 GameHandler myHandler; 55 myHandler.generateScreenshots(); 56 } 57 51 58 } 52 59 53 60 void runMenu(QString which_menu) -
mythgame/gamesettings.cpp
75 75 gc->setHelpText(QObject::tr("Enabling this causes the filenames to be displayed in the game tree rather than the trimmed/looked up gamename")); 76 76 return gc; 77 77 } 78 static HostLineEdit *GameScreenshotCmd() 79 { 80 HostLineEdit *gc = new HostLineEdit("GameScreenshotCmd"); 81 gc->setLabel(QObject::tr("Screenshot Command")); 82 gc->setValue("/usr/bin/scrot --quality 1 \"%p.png\""); 83 gc->setHelpText(QObject::tr("Programm which generates Screenshots " 84 "when the Rom ist started in Background " 85 "use %s for romname and %p for the imagename without extension.")); 86 return gc; 87 } 88 89 static HostLineEdit *GameScreenshotTime() 90 { 91 HostLineEdit *gc = new HostLineEdit("GameScreenshotTime"); 92 gc->setLabel(QObject::tr("Screenshot Timeout:")); 93 gc->setValue("10"); 94 gc->setHelpText(QObject::tr("Enter Time (in seconds) after which a Screenshot is taken")); 95 return gc; 96 } 78 97 79 98 static HostCheckBox *GameTreeView() 80 99 { … … 95 114 general->addChild(GameRemovalPrompt()); 96 115 general->addChild(GameShowFileNames()); 97 116 general->addChild(GameTreeView()); 117 VerticalConfigurationGroup *screenshot = new VerticalConfigurationGroup(false); 118 screenshot->setLabel(QObject::tr("MythGame Settings -- Screenshots")); 119 screenshot->addChild(GameScreenshotCmd()); 120 screenshot->addChild(GameScreenshotTime()); 121 98 122 addChild(general); 123 addChild(screenshot); 99 124 } 100 125 101 126 // Player Settings … … 190 215 }; 191 216 }; 192 217 218 class GenerateScreenshots: virtual public MGSetting, virtual public CheckBoxSetting { 219 public: 220 GenerateScreenshots(const MythGamePlayerSettings& parent): 221 MGSetting(parent, "screenshotenabled") { 222 setLabel(QObject::tr("Generate screenshots")); 223 setHelpText(QObject::tr("This setting means that this Gameplayer is included in the generation of screenshots.")); 224 }; 225 }; 226 227 class GenerateScreenshotsCmd: virtual public MGSetting, virtual public LineEditSetting { 228 public: 229 GenerateScreenshotsCmd(const MythGamePlayerSettings& parent): 230 MGSetting(parent, "screenshotcmd") { 231 setLabel(QObject::tr("Screenshot Command")); 232 setHelpText(QObject::tr("If you want another Command then the global to Generate Screenshots, Enter it here!")); 233 }; 234 }; 235 193 236 MythGamePlayerSettings::MythGamePlayerSettings() 194 237 { 195 238 // must be first … … 205 248 group->addChild(new WorkingDirPath(*this)); 206 249 group->addChild(new Extensions(*this)); 207 250 group->addChild(new AllowMultipleRoms(*this)); 251 group->addChild(new GenerateScreenshots(*this)); 252 group->addChild(new GenerateScreenshotsCmd(*this)); 208 253 addChild(group); 209 254 }; 210 255 … … 262 307 else 263 308 { 264 309 int val = MythPopupBox::show2ButtonPopup(gContext->GetMainWindow(), 265 "", 266 tr("Game Player Menu"), 267 tr("Edit.."), tr("Delete.."), 1); 310 "", 311 tr("Game Player Menu"), 312 tr("Edit.."), 313 tr("Delete.."), 1); 268 314 269 315 if (val == 0) 270 316 edit(); … … 273 319 } 274 320 } 275 321 276 void MythGamePlayerEditor::edit(void) 322 void MythGamePlayerEditor::edit(void) { 277 323 MythGamePlayerSettings gp; 278 324 if (getValue().toInt() != 0) 279 325 gp.loadByID(getValue().toInt());