Skip to content

Commit

Permalink
Merge pull request #273 from DrymarchonShaun/profiles-dir
Browse files Browse the repository at this point in the history
Add support for custom profiles directory
  • Loading branch information
muttleyxd authored Jul 11, 2024
2 parents ceee0de + be5a026 commit 61865cd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/arma3-unix-launcher/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ try
if (StringUtils::trim(parameter_file).empty())
throw std::invalid_argument("Parameters -> Parameter file cannot be empty");
}
if (parameters["profiles"].is_string())
{
std::string profiles_dir = parameters["profiles"];
if (StringUtils::trim(profiles_dir).empty())
throw std::invalid_argument("Parameters -> Profiles Directory cannot be empty");
}

std::vector<std::filesystem::path> mods;
for (auto const &mod : ui->table_mods->get_mods())
Expand Down Expand Up @@ -228,7 +234,13 @@ try
spdlog::trace("Mod list: ");
for (auto const &mod : mods)
spdlog::trace("path: {}", mod.string());
client->CreateArmaCfg(mods);
if (!parameters["profiles"].is_null()) {
std::string profiles = parameters["profiles"];
std::filesystem::path profiles_dir = profiles + "/Users/steamuser/Arma3.cfg";
client->CreateArmaCfg(mods, profiles_dir);
}
else
client->CreateArmaCfg(mods);
client->Start(manager.get_launch_parameters(), environment_variables, steam_integration->is_initialized(),
parameters["protonDisableEsync"]);
}
Expand Down Expand Up @@ -484,6 +496,11 @@ void MainWindow::on_checkbox_parameter_file_stateChanged(int arg1)
ui->button_parameter_file_open->setEnabled(value);
}

void MainWindow::on_checkbox_profiles_stateChanged(int arg1)
{
ui->textbox_profiles->setEnabled(arg1 == Qt::CheckState::Checked);
}

void MainWindow::on_checkbox_world_stateChanged(int arg1)
{
ui->textbox_world->setEnabled(arg1 == Qt::CheckState::Checked);
Expand Down
1 change: 1 addition & 0 deletions src/arma3-unix-launcher/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class MainWindow : public QMainWindow
void on_checkbox_extra_threads_stateChanged(int arg1);
void on_checkbox_cpu_count_stateChanged(int arg1);
void on_checkbox_parameter_file_stateChanged(int arg1);
void on_checkbox_profiles_stateChanged(int arg1);
void on_checkbox_world_stateChanged(int arg1);
void on_checkbox_custom_parameters_stateChanged(int arg1);
void on_checkbox_server_address_stateChanged(int arg1);
Expand Down
18 changes: 18 additions & 0 deletions src/arma3-unix-launcher/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,24 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_horizontal_parameters_advanced_profiles">
<item>
<widget class="QCheckBox" name="checkbox_profiles">
<property name="text">
<string>Profiles Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="textbox_profiles">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_horizontal_parameters_advanced_world">
<item>
Expand Down
10 changes: 9 additions & 1 deletion src/arma3-unix-launcher/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ namespace
"port": null,
"skipIntro": false,
"window": false,
"world": null
"world": null,
"profiles": null
},
"settings": {
"checkForUpdates": null,
Expand Down Expand Up @@ -105,6 +106,11 @@ std::string Settings::get_launch_parameters()
ret += fmt::format(" {}", std::string(parameter.value()));
else if (parameter.value().type() == nlohmann::json::value_t::boolean && parameter.value())
ret += fmt::format(" -{}", parameter.key());
else if ((parameter.key() == "profiles") && parameter.value().is_string())
{
std::string value = StringUtils::ToWindowsPath(parameter.value(), 'Z' );
ret += fmt::format(" -{}=\"{}\"", parameter.key(), value);
}
else if (parameter.value().type() == nlohmann::json::value_t::string)
{
std::string value = parameter.value();
Expand Down Expand Up @@ -147,6 +153,7 @@ void Settings::load_settings_to_ui(Ui::MainWindow *ui)
read_setting("enableHT", ui->checkbox_enable_hyper_threading);
read_setting("filePatching", ui->checkbox_enable_file_patching);
read_setting("noLogs", ui->checkbox_no_logs);
read_setting("profiles", ui->checkbox_profiles, ui->textbox_profiles);
read_setting("world", ui->checkbox_world, ui->textbox_world);
read_setting("noPause", ui->checkbox_no_pause);
read_setting("hugepages", ui->checkbox_hugepages);
Expand Down Expand Up @@ -230,6 +237,7 @@ void Settings::save_settings_from_ui(Ui::MainWindow *ui)
write_setting("enableHT", ui->checkbox_enable_hyper_threading);
write_setting("filePatching", ui->checkbox_enable_file_patching);
write_setting("noLogs", ui->checkbox_no_logs);
write_setting("profiles", ui->checkbox_profiles, ui->textbox_profiles);
write_setting("world", ui->checkbox_world, ui->textbox_world);
write_setting("noPause", ui->checkbox_no_pause);
write_setting("hugepages", ui->checkbox_hugepages);
Expand Down

0 comments on commit 61865cd

Please sign in to comment.