Skip to content

Commit

Permalink
Merge branch develop into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
fn2006 committed Jul 23, 2022
2 parents cc27c3b + f984cab commit c0f0822
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 31 deletions.
33 changes: 10 additions & 23 deletions launcher/launch/LaunchTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,35 +282,22 @@ void LaunchTask::emitFailed(QString reason)
Task::emitFailed(reason);
}

void LaunchTask::substituteVariables(const QStringList &args) const
void LaunchTask::substituteVariables(QStringList &args) const
{
auto variables = m_instance->getVariables();
auto envVariables = QProcessEnvironment::systemEnvironment();
auto env = m_instance->createEnvironment();

for (auto arg : args) {
for (auto key : variables)
{
arg.replace("$" + key, variables.value(key));
}
for (auto env : envVariables.keys())
{
arg.replace("$" + env, envVariables.value(env));
}
for (auto key : env.keys())
{
args.replaceInStrings("$" + key, env.value(key));
}
}

QString LaunchTask::substituteVariables(const QString &cmd) const
void LaunchTask::substituteVariables(QString &cmd) const
{
QString out = cmd;
auto variables = m_instance->getVariables();
for (auto it = variables.begin(); it != variables.end(); ++it)
{
out.replace("$" + it.key(), it.value());
}
auto env = QProcessEnvironment::systemEnvironment();
for (auto var : env.keys())
auto env = m_instance->createEnvironment();

for (auto key : env.keys())
{
out.replace("$" + var, env.value(var));
cmd.replace("$" + key, env.value(key));
}
return out;
}
4 changes: 2 additions & 2 deletions launcher/launch/LaunchTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class LaunchTask: public Task
shared_qobject_ptr<LogModel> getLogModel();

public:
void substituteVariables(const QStringList &args) const;
QString substituteVariables(const QString &cmd) const;
void substituteVariables(QStringList &args) const;
void substituteVariables(QString &cmd) const;
QString censorPrivateInfo(QString in);

protected: /* methods */
Expand Down
7 changes: 4 additions & 3 deletions launcher/launch/steps/PostLaunchCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ void PostLaunchCommand::executeTask()
const QString program = args.takeFirst();
m_process.start(program, args);
#else
QString postlaunch_cmd = m_parent->substituteVariables(m_command);
emit logLine(tr("Running Post-Launch command: %1").arg(postlaunch_cmd), MessageLevel::Launcher);
m_process.start(postlaunch_cmd);
m_parent->substituteVariables(m_command);

emit logLine(tr("Running Post-Launch command: %1").arg(m_command), MessageLevel::Launcher);
m_process.start(m_command);
#endif
}

Expand Down
7 changes: 4 additions & 3 deletions launcher/launch/steps/PreLaunchCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ void PreLaunchCommand::executeTask()
const QString program = args.takeFirst();
m_process.start(program, args);
#else
QString prelaunch_cmd = m_parent->substituteVariables(m_command);
emit logLine(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd), MessageLevel::Launcher);
m_process.start(prelaunch_cmd);
m_parent->substituteVariables(m_command);

emit logLine(tr("Running Pre-Launch command: %1").arg(m_command), MessageLevel::Launcher);
m_process.start(m_command);
#endif
}

Expand Down

0 comments on commit c0f0822

Please sign in to comment.