@@ -23,29 +23,30 @@ void HandlerStorage::clear()
2323 m_Handlers.clear ();
2424}
2525
26- void HandlerStorage::registerProxy (const QString& proxyPath)
26+ void HandlerStorage::registerSchemaProxy (const QString& proxyPath,
27+ const QString& schema)
2728{
28- QSettings settings (" HKEY_CURRENT_USER\\ Software\\ Classes\\ nxm \\ " ,
29+ QSettings settings (" HKEY_CURRENT_USER\\ Software\\ Classes\\ " + schema + " \\ " ,
2930 QSettings::NativeFormat);
3031 QString myExe =
3132 QString (" \" %1\" " ).arg (QDir::toNativeSeparators (proxyPath)).append (" \" %1\" " );
32- settings.setValue (" Default" , " URL:NXM Protocol" );
33+ settings.setValue (" Default" , " URL:" + schema. toUpper () + " Protocol" );
3334 settings.setValue (" URL Protocol" , " " );
3435 settings.setValue (" shell/open/command/Default" , myExe);
3536 settings.sync ();
3637}
3738
38- void HandlerStorage::registerHandler (const QString& executable,
39+ void HandlerStorage::registerHandler (const QString& schema, const QString& executable,
3940 const QString& arguments, bool prepend)
4041{
4142 QStringList games;
4243 for (const auto & game : this ->knownGames ()) {
4344 games.append (std::get<1 >(game));
4445 }
45- registerHandler (games, executable, arguments, prepend, false );
46+ registerHandler (games, schema, executable, arguments, prepend, false );
4647}
4748
48- void HandlerStorage::registerHandler (const QStringList& games,
49+ void HandlerStorage::registerHandler (const QStringList& games, const QString& schema,
4950 const QString& executable,
5051 const QString& arguments, bool prepend, bool rereg)
5152{
@@ -54,12 +55,14 @@ void HandlerStorage::registerHandler(const QStringList& games,
5455 gamesLower.append (game.toLower ());
5556 }
5657 for (auto iter = m_Handlers.begin (); iter != m_Handlers.end (); ++iter) {
57- if (iter->executable .compare (executable, Qt::CaseInsensitive) == 0 ) {
58- // executable already registered, update supported games and move it to top if
59- // requested
58+ if (iter->executable .compare (executable, Qt::CaseInsensitive) == 0 &&
59+ iter->schema .compare (schema, Qt::CaseInsensitive) == 0 ) {
60+ // executable already registered, update supported games and move it to
61+ // top if requested
6062 if (rereg) {
6163 HandlerInfo info = *iter;
6264 info.games = gamesLower;
65+ info.arguments = arguments;
6366 m_Handlers.erase (iter);
6467 if (prepend) {
6568 m_Handlers.push_front (info);
@@ -69,6 +72,7 @@ void HandlerStorage::registerHandler(const QStringList& games,
6972 } else {
7073 iter->games .append (gamesLower);
7174 iter->games .removeDuplicates ();
75+ iter->arguments = arguments;
7276 }
7377 return ; // important: in the rereg-case we changed the list thus screwing up the
7478 // iterator
@@ -79,6 +83,7 @@ void HandlerStorage::registerHandler(const QStringList& games,
7983 HandlerInfo info;
8084 info.ID = static_cast <int >(m_Handlers.size ());
8185 info.games = gamesLower;
86+ info.schema = schema;
8287 info.executable = executable;
8388 info.arguments = arguments;
8489 if (prepend) {
@@ -88,7 +93,7 @@ void HandlerStorage::registerHandler(const QStringList& games,
8893 }
8994}
9095
91- QStringList HandlerStorage::getHandler (const QString& game) const
96+ QStringList HandlerStorage::getHandler (const QString& game, const QString& schema ) const
9297{
9398 QString gameKey;
9499 QStringList results;
@@ -102,23 +107,27 @@ QStringList HandlerStorage::getHandler(const QString& game) const
102107 }
103108 // look for an explictly registered handler
104109 for (const HandlerInfo& info : m_Handlers) {
105- for (auto handler : info.games ) {
106- if (game.compare (handler, Qt::CaseInsensitive) == 0 ||
107- gameKey.compare (handler, Qt::CaseInsensitive) == 0 ) {
108- results << info.executable ;
109- results << info.arguments ;
110- return results;
110+ if (info.schema == schema) {
111+ for (auto handler : info.games ) {
112+ if (game.compare (handler, Qt::CaseInsensitive) == 0 ||
113+ gameKey.compare (handler, Qt::CaseInsensitive) == 0 ) {
114+ results << info.executable ;
115+ results << info.arguments ;
116+ return results;
117+ }
111118 }
112119 }
113120 }
114121
115122 // if no registered handler, look for the first "other" entry
116123 if (results.length () == 0 ) {
117124 for (const HandlerInfo& info : m_Handlers) {
118- if (info.games .contains (" other" , Qt::CaseInsensitive)) {
119- results << info.executable ;
120- results << info.arguments ;
121- return results;
125+ if (info.schema == schema) {
126+ if (info.games .contains (" other" , Qt::CaseInsensitive)) {
127+ results << info.executable ;
128+ results << info.arguments ;
129+ return results;
130+ }
122131 }
123132 }
124133 }
@@ -136,18 +145,26 @@ std::vector<std::tuple<QString, QString, QString>> HandlerStorage::knownGames()
136145 return {
137146 std::make_tuple<QString, QString, QString>(" Morrowind" , " morrowind" , " morrowind" ),
138147 std::make_tuple<QString, QString, QString>(" Oblivion" , " oblivion" , " oblivion" ),
148+ std::make_tuple<QString, QString, QString>(
149+ " Oblivion Remastered" , " oblivionremastered" , " oblivionremastered" ),
139150 std::make_tuple<QString, QString, QString>(" Fallout 3" , " fallout3" , " fallout3" ),
140151 std::make_tuple<QString, QString, QString>(" Fallout 4" , " fallout4" , " fallout4" ),
141152 std::make_tuple<QString, QString, QString>(" Fallout NV" , " falloutnv" , " newvegas" ),
142153 std::make_tuple<QString, QString, QString>(" Skyrim" , " skyrim" , " skyrim" ),
143154 std::make_tuple<QString, QString, QString>(" SkyrimSE" , " skyrimse" ,
144155 " skyrimspecialedition" ),
156+ std::make_tuple<QString, QString, QString>(" Starfield" , " starfield" , " starfield" ),
145157 std::make_tuple<QString, QString, QString>(" Enderal" , " enderal" , " enderal" ),
146158 std::make_tuple<QString, QString, QString>(" EnderalSE" , " enderalse" ,
147159 " enderalspecialedition" ),
148160 std::make_tuple<QString, QString, QString>(" Other" , " other" , " other" )};
149161}
150162
163+ QStringList HandlerStorage::availableSchemas () const
164+ {
165+ return {" nxm" , " modl" };
166+ }
167+
151168QStringList HandlerStorage::stripCall (const QString& call)
152169{
153170 // results[0] is binary, results[1..n] are optional arguments
@@ -213,6 +230,7 @@ void HandlerStorage::loadStore()
213230 if (!gameList.isEmpty ()) {
214231 info.games = gameList.split (" ," );
215232 }
233+ info.schema = settings.value (" schema" , " nxm" ).toString ();
216234 info.executable = settings.value (" executable" ).toString ();
217235 info.arguments = settings.value (" arguments" ).toString ();
218236 if (QFile::exists (info.executable )) {
@@ -234,6 +252,7 @@ void HandlerStorage::loadStore()
234252 ids.append (std::get<1 >(*iter));
235253 }
236254 info.games = QStringList () << ids;
255+ info.schema = " nxm" ;
237256 info.executable = handlerValues.front ();
238257 handlerValues.pop_front ();
239258 info.arguments = handlerValues.join (" " );
@@ -261,6 +280,7 @@ void HandlerStorage::saveStore()
261280 for (auto iter = m_Handlers.begin (); iter != m_Handlers.end (); ++iter) {
262281 settings.setArrayIndex (i++);
263282 settings.setValue (" games" , iter->games .join (" ," ));
283+ settings.setValue (" schema" , iter->schema );
264284 settings.setValue (" executable" , iter->executable );
265285 settings.setValue (" arguments" , iter->arguments );
266286 }
0 commit comments