2016-11-18 00:40:14 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 Peter Repukat - FlatspotSoftware
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
2016-11-26 21:57:32 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2016-11-18 00:40:14 +00:00
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
2016-11-18 00:22:07 +00:00
|
|
|
#include "GloSC.h"
|
2017-11-12 06:05:25 +00:00
|
|
|
#include <memory>
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
GloSC::GloSC(QWidget *parent)
|
|
|
|
: QMainWindow(parent)
|
|
|
|
{
|
2017-04-19 06:13:38 +00:00
|
|
|
QDir::setCurrent(QCoreApplication::applicationDirPath());
|
2016-11-18 00:22:07 +00:00
|
|
|
ui.setupUi(this);
|
|
|
|
|
2017-11-12 01:04:24 +00:00
|
|
|
this->setMaximumWidth(small_x);
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
updateEntryList();
|
2016-11-26 21:57:32 +00:00
|
|
|
updateTargetsToNewVersion();
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2016-11-28 10:03:57 +00:00
|
|
|
//Launch the gamelauncher here, just to be safe
|
|
|
|
//Don't need to check if the process already exists as it does it itself
|
|
|
|
QProcess proc;
|
2017-04-19 06:13:38 +00:00
|
|
|
proc.startDetached("GloSC_Gamelauncher.exe", QStringList(), QApplication::applicationDirPath(), nullptr);
|
2016-11-28 10:03:57 +00:00
|
|
|
|
2017-11-12 06:05:25 +00:00
|
|
|
if (first_launch_)
|
|
|
|
showTutorial();
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 06:05:25 +00:00
|
|
|
void GloSC::updateEntryList()
|
2016-11-18 00:22:07 +00:00
|
|
|
{
|
|
|
|
ui.lwInstances->clear();
|
|
|
|
|
2017-04-19 06:13:38 +00:00
|
|
|
QDir dir("./targets");
|
|
|
|
QStringList fileNames = dir.entryList(QDir::Files);
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2017-11-12 06:05:25 +00:00
|
|
|
if (fileNames.isEmpty())
|
|
|
|
first_launch_ = true;
|
|
|
|
|
|
|
|
|
2017-04-19 06:13:38 +00:00
|
|
|
for (auto &fileName : fileNames)
|
2016-11-18 00:22:07 +00:00
|
|
|
{
|
2017-04-19 06:13:38 +00:00
|
|
|
if (fileName.endsWith(".ini"))
|
|
|
|
ui.lwInstances->addItem(fileName.left(fileName.length() - 4));
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-19 13:38:30 +00:00
|
|
|
void GloSC::writeIni(QString entryName) const
|
2016-11-18 00:22:07 +00:00
|
|
|
{
|
2017-04-19 06:13:38 +00:00
|
|
|
QSettings settings("./targets/" + entryName + ".ini", QSettings::IniFormat);
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
settings.beginGroup("BaseConf");
|
|
|
|
|
2016-11-26 21:57:32 +00:00
|
|
|
settings.setValue("bEnableOverlay", 0 + ui.cbOverlay->isChecked());
|
2016-11-18 00:22:07 +00:00
|
|
|
settings.setValue("bEnableControllers", 0 + ui.cbControllers->isChecked());
|
2017-02-15 03:04:27 +00:00
|
|
|
settings.setValue("bUseDesktopConfig", 0 + ui.cbUseDesktop->isChecked());
|
2017-11-12 01:00:15 +00:00
|
|
|
settings.setValue("bHookSteam", hook_steam_);
|
2016-11-29 18:05:36 +00:00
|
|
|
settings.setValue("version", GLOSC_VERSION);
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup("LaunchGame");
|
|
|
|
|
|
|
|
settings.setValue("bLaunchGame", 0 + ui.cbLaunchGame->isChecked());
|
2017-04-19 06:13:38 +00:00
|
|
|
settings.setValue("Path", ui.lePath->text());
|
|
|
|
settings.setValue("Args", ui.leArguments->text());
|
|
|
|
if (ui.lePath->text().contains("\\") || ui.lePath->text().contains("/"))
|
|
|
|
settings.setValue("Type", "Win32");
|
|
|
|
else
|
|
|
|
settings.setValue("Type", "UWP");
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2016-11-19 05:30:48 +00:00
|
|
|
settings.setValue("bCloseWhenDone", 0 + ui.cbCloseWhenDone->isChecked());
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-11-26 21:57:32 +00:00
|
|
|
void GloSC::updateTargetsToNewVersion()
|
|
|
|
{
|
|
|
|
//incredible lazy way to update to this next version but eh...
|
|
|
|
for (int i = 0; i < ui.lwInstances->count(); i++)
|
|
|
|
{
|
|
|
|
on_lwInstances_currentRowChanged(i);
|
|
|
|
QString name = ui.leName->text();
|
|
|
|
|
2017-04-19 06:13:38 +00:00
|
|
|
QSettings settings("./targets/" + name + ".ini", QSettings::IniFormat);
|
2016-11-26 21:57:32 +00:00
|
|
|
settings.beginGroup("BaseConf");
|
2016-11-29 18:05:36 +00:00
|
|
|
unsigned int version = settings.value("version").toInt();
|
2016-11-26 21:57:32 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-11-29 18:05:36 +00:00
|
|
|
if (version < GLOSC_VERSION)
|
2016-11-26 22:12:31 +00:00
|
|
|
on_pbSave_clicked();
|
2016-11-26 21:57:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-19 06:59:56 +00:00
|
|
|
|
2017-02-05 03:02:14 +00:00
|
|
|
void GloSC::animate(int to)
|
|
|
|
{
|
2017-02-05 04:40:29 +00:00
|
|
|
if (to == width())
|
|
|
|
return;
|
2017-02-05 03:02:14 +00:00
|
|
|
QPropertyAnimation* anim = new QPropertyAnimation(this, "size");
|
|
|
|
if (to > width())
|
|
|
|
{
|
|
|
|
anim->setEasingCurve(QEasingCurve::InOutExpo);
|
|
|
|
connect(anim, &QPropertyAnimation::finished, this, [this, to]()
|
|
|
|
{
|
|
|
|
this->setMinimumWidth(to);
|
|
|
|
});
|
|
|
|
this->setMaximumWidth(to);
|
|
|
|
|
|
|
|
QPropertyAnimation* buttonAnim = new QPropertyAnimation(ui.pbCreateNew, "size");
|
|
|
|
buttonAnim->setEasingCurve(QEasingCurve::InOutExpo);
|
|
|
|
buttonAnim->setDuration(360);
|
|
|
|
buttonAnim->setStartValue(QSize(ui.pbCreateNew->width(), ui.pbCreateNew->height()));
|
|
|
|
buttonAnim->setEndValue(QSize(wide_x_create, ui.pbCreateNew->height()));
|
|
|
|
buttonAnim->start(QPropertyAnimation::DeleteWhenStopped);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
anim->setEasingCurve(QEasingCurve::InExpo);
|
|
|
|
connect(anim, &QPropertyAnimation::finished, this, [this, to]()
|
|
|
|
{
|
|
|
|
this->setMaximumWidth(to);
|
|
|
|
});
|
|
|
|
this->setMinimumWidth(to);
|
|
|
|
|
|
|
|
QPropertyAnimation* buttonAnim = new QPropertyAnimation(ui.pbCreateNew, "size");
|
2017-02-05 04:40:29 +00:00
|
|
|
buttonAnim->setEasingCurve(QEasingCurve::InExpo);
|
2017-02-05 03:02:14 +00:00
|
|
|
buttonAnim->setDuration(360);
|
|
|
|
buttonAnim->setStartValue(QSize(ui.pbCreateNew->width(), ui.pbCreateNew->height()));
|
|
|
|
buttonAnim->setEndValue(QSize(small_x_create, ui.pbCreateNew->height()));
|
|
|
|
buttonAnim->start(QPropertyAnimation::DeleteWhenStopped);
|
|
|
|
|
|
|
|
}
|
|
|
|
anim->setDuration(360);
|
|
|
|
anim->setStartValue(QSize(this->width(), this->height()));
|
|
|
|
anim->setEndValue(QSize(to, this->height()));
|
|
|
|
anim->start(QPropertyAnimation::DeleteWhenStopped);
|
|
|
|
}
|
|
|
|
|
2017-11-12 01:00:15 +00:00
|
|
|
void GloSC::on_cbUseDesktop_toggled(bool checked)
|
2017-02-15 03:04:27 +00:00
|
|
|
{
|
2017-11-12 01:00:15 +00:00
|
|
|
hook_steam_ = !checked;
|
2017-02-15 03:04:27 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 06:05:25 +00:00
|
|
|
void GloSC::showTutorial()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
ui.pbTuorialCreate->setVisible(false);
|
|
|
|
ui.pbTuorialCreate->setEnabled(false);
|
2017-11-12 06:25:35 +00:00
|
|
|
ui.tutorialFrame->setGeometry(ui.tutorialFrame->x(), ui.tutorialFrame->y(), ui.tutorialFrame->width(), 386);
|
2017-11-12 06:05:25 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < 14; i++)
|
|
|
|
{
|
|
|
|
QLabel* label = ui.tutorialFrame->findChild<QLabel *>(QString("lTutorialText" + QString::number(i)));
|
|
|
|
if (label != nullptr)
|
|
|
|
label->setVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(ui.pbTutorialNext, &QPushButton::clicked, [this]() {
|
|
|
|
current_slide_++;
|
|
|
|
|
|
|
|
if (current_slide_ >= 14)
|
|
|
|
{
|
|
|
|
ui.tutorialFrame->setGeometry(ui.tutorialFrame->x(), ui.tutorialFrame->y(), ui.tutorialFrame->width(), 0);
|
|
|
|
ui.pbTutorialNext->setVisible(false);
|
|
|
|
ui.pbTutorialNext->setEnabled(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.tutorialFrame->findChild<QLabel *>(QString("lTutorialText" + QString::number(current_slide_ - 1)))->setVisible(false);
|
|
|
|
ui.tutorialFrame->findChild<QLabel *>(QString("lTutorialText" + QString::number(current_slide_)))->setVisible(true);
|
|
|
|
|
|
|
|
QString test = QString(":/Tutorial/tut-assets/Tut" + QString::number(current_slide_) + ".png");
|
|
|
|
ui.lTutorialBackground->setPixmap(QPixmap(test));
|
|
|
|
|
|
|
|
if (current_slide_ == 1)
|
|
|
|
{
|
|
|
|
ui.pbTutorialNext->setVisible(false);
|
|
|
|
ui.pbTutorialNext->setEnabled(false);
|
|
|
|
ui.pbTuorialCreate->setVisible(true);
|
|
|
|
ui.pbTuorialCreate->setEnabled(true);
|
|
|
|
}
|
|
|
|
if (current_slide_ == 2)
|
|
|
|
ui.pbTutorialNext->setGeometry(600, ui.pbTutorialNext->y(), ui.pbTutorialNext->width(), ui.pbTutorialNext->height());
|
|
|
|
|
|
|
|
if (current_slide_ == 13)
|
|
|
|
{
|
|
|
|
animate(small_x);
|
|
|
|
ui.pbTutorialNext->setText("Finish");
|
|
|
|
ui.pbTutorialNext->setGeometry(180, 45, ui.pbTutorialNext->width(), ui.pbTutorialNext->height());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui.pbTuorialCreate, &QPushButton::clicked, [this]()
|
|
|
|
{
|
|
|
|
ui.pbTuorialCreate->setVisible(false);
|
|
|
|
ui.pbTuorialCreate->setEnabled(false);
|
|
|
|
ui.pbTutorialNext->setVisible(true);
|
|
|
|
ui.pbTutorialNext->setEnabled(true);
|
|
|
|
on_pbCreateNew_clicked();
|
|
|
|
ui.pbTutorialNext->click();
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-02-05 03:02:14 +00:00
|
|
|
void GloSC::on_pbCreateNew_clicked()
|
|
|
|
{
|
2017-02-05 04:40:29 +00:00
|
|
|
ui.leName->setText("");
|
|
|
|
|
|
|
|
ui.cbOverlay->setChecked(true);
|
|
|
|
ui.cbControllers->setChecked(true);
|
2017-11-12 01:00:15 +00:00
|
|
|
hook_steam_ = true;
|
2017-02-05 04:40:29 +00:00
|
|
|
|
|
|
|
ui.cbLaunchGame->setChecked(false);
|
|
|
|
ui.lePath->setText("");
|
2017-04-19 06:13:38 +00:00
|
|
|
ui.leArguments->setText("");
|
2017-02-05 04:40:29 +00:00
|
|
|
ui.cbCloseWhenDone->setChecked(false);
|
|
|
|
|
2017-02-05 03:02:14 +00:00
|
|
|
animate(wide_x);
|
|
|
|
}
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
void GloSC::on_pbSave_clicked()
|
|
|
|
{
|
|
|
|
QString name = ui.leName->text();
|
|
|
|
name.remove("\\");
|
|
|
|
name.remove("/");
|
|
|
|
name.remove(":");
|
|
|
|
name.remove(".");
|
|
|
|
|
|
|
|
QString temp = name;
|
|
|
|
if (temp.remove(" ") == "")
|
|
|
|
return;
|
|
|
|
|
2017-04-19 06:13:38 +00:00
|
|
|
QDir dir("targets");
|
2016-11-18 00:22:07 +00:00
|
|
|
if (!dir.exists())
|
|
|
|
dir.mkdir(".");
|
|
|
|
|
|
|
|
writeIni(name);
|
|
|
|
|
|
|
|
updateEntryList();
|
|
|
|
|
2017-02-05 03:02:14 +00:00
|
|
|
animate(small_x);
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GloSC::on_pbDelete_clicked()
|
|
|
|
{
|
|
|
|
QString name = ui.leName->text();
|
|
|
|
|
|
|
|
QString temp = name;
|
|
|
|
if (temp.remove(" ") == "")
|
|
|
|
return;
|
|
|
|
|
2017-04-19 06:13:38 +00:00
|
|
|
QFile file("./targets/" + name + ".ini");
|
|
|
|
if (file.exists())
|
2016-11-18 00:22:07 +00:00
|
|
|
{
|
2017-04-19 06:13:38 +00:00
|
|
|
file.remove();
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
updateEntryList();
|
2017-02-05 03:02:14 +00:00
|
|
|
|
|
|
|
animate(small_x);
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GloSC::on_pbAddToSteam_clicked()
|
|
|
|
{
|
2016-11-26 21:58:02 +00:00
|
|
|
if (ui.lwInstances->count() <= 0)
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, "GloSC", "No shortcuts! Create some shortcuts first for them to be added to Steam!", QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-19 23:57:55 +00:00
|
|
|
QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Valve\\Steam", QSettings::NativeFormat);
|
|
|
|
QString steamPath = settings.value("SteamPath").toString();
|
|
|
|
QString activeUser = settings.value("ActiveProcess/ActiveUser").toString();
|
|
|
|
|
|
|
|
QFile shortcutsFile(steamPath + "/userdata/" + activeUser + "/config/shortcuts.vdf");
|
|
|
|
|
2017-11-12 00:03:14 +00:00
|
|
|
//TODO: FIXME: If User has no shortcuts file, create one!
|
2016-11-19 23:57:55 +00:00
|
|
|
if (!shortcutsFile.exists())
|
|
|
|
{
|
2017-11-12 01:32:40 +00:00
|
|
|
QMessageBox::information(this, "GloSC", "Couldn't detect Steam shortcuts file!\n\
|
|
|
|
Make sure you have at least one non-Steam shortcut for the file to be present\n\
|
|
|
|
Steam must be running for it to be detected", QMessageBox::Ok);
|
2016-11-19 23:57:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!shortcutsFile.open(QFile::ReadWrite))
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, "GloSC", "Couldn't open Steam shortcuts file!", QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//just detect already present paths the easy way and hardcode the actual shortcut structure
|
|
|
|
//will prob. come back to bite me, but for now it should be enough
|
|
|
|
QByteArray shortcutsFileBytes = shortcutsFile.readAll();
|
|
|
|
|
|
|
|
//get shortcutcount
|
|
|
|
QByteArray temp = shortcutsFileBytes;
|
|
|
|
temp.chop(9); //chop off last "tags"
|
|
|
|
temp = temp.mid(temp.lastIndexOf("tags") + 8, temp.size() - 1);
|
|
|
|
int shortcutCount = QString(temp).toInt();
|
|
|
|
|
|
|
|
QString itemName;
|
2017-04-19 06:13:38 +00:00
|
|
|
QDir appDir = QDir::current();
|
2016-11-19 23:57:55 +00:00
|
|
|
for (int i = 0; i < ui.lwInstances->count(); i++)
|
|
|
|
{
|
|
|
|
itemName = ui.lwInstances->item(i)->text();
|
2017-04-19 06:13:38 +00:00
|
|
|
if (!shortcutsFileBytes.contains(("\"" + QDir::toNativeSeparators(appDir.absoluteFilePath("SteamTarget.exe")) + "\"" + " \"./targets/" + itemName + ".ini\"").toStdString().c_str()))
|
2016-11-19 23:57:55 +00:00
|
|
|
{
|
|
|
|
shortcutsFileBytes.chop(2); //chop of end bytes
|
|
|
|
shortcutCount++;
|
|
|
|
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append(QString::number(shortcutCount));
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x01');
|
|
|
|
shortcutsFileBytes.append("appname");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append(itemName);
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x01');
|
|
|
|
shortcutsFileBytes.append("exe");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
2017-04-19 06:13:38 +00:00
|
|
|
shortcutsFileBytes.append("\"" + QDir::toNativeSeparators(appDir.absoluteFilePath("SteamTarget.exe")) + "\"" + " \"./targets/" + itemName + ".ini\"");
|
2016-11-19 23:57:55 +00:00
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x01');
|
|
|
|
shortcutsFileBytes.append("StartDir");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
2017-04-19 06:13:38 +00:00
|
|
|
shortcutsFileBytes.append("\"" + QDir::toNativeSeparators(appDir.absolutePath()) + "\"");
|
2016-11-19 23:57:55 +00:00
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x01');
|
|
|
|
shortcutsFileBytes.append("icon");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x01');
|
|
|
|
shortcutsFileBytes.append("ShortcutPath");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x02');
|
|
|
|
shortcutsFileBytes.append("IsHidden");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x02');
|
|
|
|
shortcutsFileBytes.append("AllowDesktopConfig");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x01');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x02');
|
|
|
|
shortcutsFileBytes.append("OpenVR");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append("tags");
|
|
|
|
shortcutsFileBytes.append('\x00');
|
|
|
|
shortcutsFileBytes.append('\x08');
|
|
|
|
shortcutsFileBytes.append('\x08');
|
|
|
|
|
|
|
|
//append chopped of bytes
|
|
|
|
shortcutsFileBytes.append('\x08');
|
|
|
|
shortcutsFileBytes.append('\x08');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shortcutsFile.close();
|
2017-01-25 16:14:38 +00:00
|
|
|
if (!shortcutsFile.open(QFile::ReadWrite | QIODevice::Truncate))
|
2016-11-19 23:57:55 +00:00
|
|
|
{
|
|
|
|
QMessageBox::information(this, "GloSC", "Couldn't open Steam shortcuts file!", QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shortcutsFile.write(shortcutsFileBytes);
|
|
|
|
|
|
|
|
shortcutsFile.close();
|
|
|
|
QMessageBox::information(this, "GloSC", "Shortcuts were added! Restart Steam for changes to take effect!", QMessageBox::Ok);
|
|
|
|
|
2017-02-05 03:02:14 +00:00
|
|
|
animate(small_x);
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GloSC::on_pbSearchPath_clicked()
|
|
|
|
{
|
|
|
|
QString filePath = QFileDialog::getOpenFileName(this, "Select Game", "", "*.exe");
|
2017-04-19 06:13:38 +00:00
|
|
|
if (!filePath.isEmpty())
|
2016-12-04 21:20:01 +00:00
|
|
|
{
|
2017-04-19 06:13:38 +00:00
|
|
|
QFileInfo fileInfo(filePath);
|
|
|
|
ui.lePath->setText(fileInfo.filePath());
|
|
|
|
QString name = fileInfo.fileName();
|
2016-12-04 21:20:01 +00:00
|
|
|
name.chop(4);
|
|
|
|
ui.leName->setText(name);
|
2017-04-19 06:13:38 +00:00
|
|
|
ui.cbLaunchGame->setChecked(true);
|
2016-12-04 21:20:01 +00:00
|
|
|
}
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GloSC::on_pbUWP_clicked()
|
|
|
|
{
|
|
|
|
QSettings *settings = new QSettings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
|
|
|
|
|
|
|
QStringList childs = settings->childGroups();
|
|
|
|
QStringList packages;
|
|
|
|
|
|
|
|
for (auto& child : childs)
|
|
|
|
{
|
|
|
|
if (child.indexOf("AppX") == 0)
|
|
|
|
{
|
|
|
|
packages << child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete settings;
|
|
|
|
|
2017-11-12 01:29:30 +00:00
|
|
|
QProgressDialog progDialog("Searching for UWP apps...", "Cancel", 0, packages.size(), this);
|
2017-11-12 01:29:02 +00:00
|
|
|
progDialog.setWindowModality(Qt::WindowModal);
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
QList<UWPPair> pairs;
|
|
|
|
|
|
|
|
QString AppName;
|
|
|
|
QString AppUMId;
|
|
|
|
|
|
|
|
QStringList AppNames;
|
|
|
|
QStringList AppUMIds;
|
|
|
|
|
2016-11-19 06:59:56 +00:00
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
for (auto &package : packages)
|
|
|
|
{
|
2017-11-12 01:29:02 +00:00
|
|
|
progDialog.setValue(packages.indexOf(package));
|
|
|
|
|
|
|
|
if (progDialog.wasCanceled())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
settings = new QSettings("HKEY_CLASSES_ROOT\\"+package, QSettings::NativeFormat);
|
|
|
|
|
|
|
|
AppName = settings->value("Application/ApplicationName").toString();
|
|
|
|
AppUMId = settings->value("Application/AppUserModelID").toString();
|
|
|
|
if (!AppNames.contains(AppName) && !AppUMIds.contains(AppUMId) && AppUMId.size() > 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
AppNames << AppName;
|
|
|
|
AppUMIds << AppUMId;
|
|
|
|
|
2016-11-19 06:59:56 +00:00
|
|
|
if (AppName.size() == 0)
|
|
|
|
{
|
2016-11-18 00:22:07 +00:00
|
|
|
AppName = "Unknown";
|
2016-11-19 06:59:56 +00:00
|
|
|
} else if (AppName.at(0) == '@') {
|
|
|
|
QString packageName = AppName.mid(AppName.indexOf('{') + 1, AppName.size() -1);
|
|
|
|
packageName = packageName.mid(0, packageName.indexOf('?'));
|
|
|
|
QStringList cachedNameChildGroups;
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT\\Local Settings\\MrtCache", QSettings::NativeFormat);
|
|
|
|
|
|
|
|
cachedNameChildGroups = settings.childGroups();
|
|
|
|
|
|
|
|
for (auto &childGroup : cachedNameChildGroups)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (childGroup.contains(packageName))
|
|
|
|
{
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT\\Local Settings\\MrtCache\\"+ childGroup, QSettings::NativeFormat);
|
|
|
|
|
|
|
|
QStringList allKeys = settings.allKeys();
|
|
|
|
|
|
|
|
AppName.replace("/", "\\");
|
|
|
|
for (auto &key : allKeys)
|
|
|
|
{
|
|
|
|
if (key.contains(AppName))
|
|
|
|
{
|
|
|
|
AppName = settings.value(key).toString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (AppName.at(0) == '@') {
|
|
|
|
AppName = "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
UWPPair uwpPair = {
|
|
|
|
AppName,
|
|
|
|
AppUMId,
|
|
|
|
};
|
|
|
|
|
|
|
|
pairs.push_back(uwpPair);
|
|
|
|
|
|
|
|
}
|
|
|
|
delete settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
uwpPairs = pairs;
|
|
|
|
|
2017-11-12 01:29:02 +00:00
|
|
|
progDialog.close();
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
UWPSelectDialog dialog(this);
|
|
|
|
dialog.setUWPList(uwpPairs);
|
|
|
|
int selection = dialog.exec();
|
|
|
|
|
|
|
|
if (selection > -1)
|
|
|
|
{
|
|
|
|
ui.lePath->setText(uwpPairs.at(selection).AppUMId);
|
2016-12-04 21:20:01 +00:00
|
|
|
ui.leName->setText(uwpPairs.at(selection).AppName);
|
2017-04-19 06:13:38 +00:00
|
|
|
ui.cbLaunchGame->setChecked(true);
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-11-12 01:00:15 +00:00
|
|
|
void GloSC::on_lwInstances_currentRowChanged(int row)
|
2016-11-18 00:22:07 +00:00
|
|
|
{
|
|
|
|
if (row < 0)
|
|
|
|
return;
|
|
|
|
QString entryName = ui.lwInstances->item(row)->text();
|
|
|
|
ui.leName->setText(entryName);
|
|
|
|
|
2017-04-19 06:13:38 +00:00
|
|
|
QSettings settings("./targets/" + entryName + ".ini", QSettings::IniFormat);
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
settings.beginGroup("BaseConf");
|
|
|
|
|
2016-11-26 21:57:32 +00:00
|
|
|
ui.cbOverlay->setChecked(settings.value("bEnableOverlay").toBool());
|
2016-11-18 00:22:07 +00:00
|
|
|
ui.cbControllers->setChecked(settings.value("bEnableControllers").toBool());
|
2017-02-15 03:04:27 +00:00
|
|
|
ui.cbUseDesktop->setChecked(settings.value("bUseDesktopConfig").toBool());
|
|
|
|
if (ui.cbUseDesktop->isChecked())
|
|
|
|
{
|
2017-11-12 01:00:15 +00:00
|
|
|
hook_steam_ = false;
|
2017-02-15 03:04:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-12 01:00:15 +00:00
|
|
|
hook_steam_ = true;
|
2017-02-15 03:04:27 +00:00
|
|
|
}
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup("LaunchGame");
|
|
|
|
|
|
|
|
ui.cbLaunchGame->setChecked(settings.value("bLaunchGame").toBool());
|
2017-04-19 06:13:38 +00:00
|
|
|
ui.lePath->setText(settings.value("Path").toString());
|
|
|
|
ui.leArguments->setText(settings.value("Args").toString());
|
2016-11-19 05:30:48 +00:00
|
|
|
ui.cbCloseWhenDone->setChecked(settings.value("bCloseWhenDone").toBool());
|
2016-11-18 00:22:07 +00:00
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
|
2017-02-05 03:02:14 +00:00
|
|
|
}
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2017-02-05 03:02:14 +00:00
|
|
|
void GloSC::on_lwInstances_itemSelectionChanged()
|
|
|
|
{
|
|
|
|
if (width() != wide_x)
|
|
|
|
{
|
|
|
|
animate(wide_x);
|
2017-11-12 01:00:15 +00:00
|
|
|
}
|
2016-11-18 00:22:07 +00:00
|
|
|
}
|