mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-03-15 06:28:27 +03:00
0.6.1
- added ability to edit game running command
This commit is contained in:
parent
2d520f5e40
commit
0990340a2b
5 changed files with 39 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "anime-game-launcher"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
description = "Anime Game launcher"
|
||||
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
|
||||
license = "GPL-3.0"
|
||||
|
|
|
@ -2,6 +2,14 @@ using Gtk 4.0;
|
|||
using Adw 1;
|
||||
|
||||
Adw.PreferencesPage page {
|
||||
Adw.PreferencesGroup {
|
||||
title: "Game command";
|
||||
|
||||
Gtk.Entry command {
|
||||
placeholder-text: "%command%";
|
||||
}
|
||||
}
|
||||
|
||||
Adw.PreferencesGroup {
|
||||
title: "New variable";
|
||||
|
||||
|
|
|
@ -240,7 +240,8 @@ pub struct Game {
|
|||
pub wine: Wine,
|
||||
pub dxvk: Dxvk,
|
||||
pub enhancements: Enhancements,
|
||||
pub environment: HashMap<String, String>
|
||||
pub environment: HashMap<String, String>,
|
||||
pub command: Option<String>
|
||||
}
|
||||
|
||||
impl Default for Game {
|
||||
|
@ -256,7 +257,8 @@ impl Default for Game {
|
|||
wine: Wine::default(),
|
||||
dxvk: Dxvk::default(),
|
||||
enhancements: Enhancements::default(),
|
||||
environment: HashMap::new()
|
||||
environment: HashMap::new(),
|
||||
command: None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,11 @@ pub fn run(debug: bool) -> std::io::Result<()> {
|
|||
bash_chain += "launcher.bat";
|
||||
}
|
||||
|
||||
let bash_chain = match config.game.command {
|
||||
Some(command) => command.replace("%command%", &bash_chain),
|
||||
None => bash_chain
|
||||
};
|
||||
|
||||
let mut command = Command::new("bash");
|
||||
|
||||
command.arg("-c");
|
||||
|
|
|
@ -21,6 +21,8 @@ use crate::lib::config;
|
|||
pub struct AppWidgets {
|
||||
pub page: adw::PreferencesPage,
|
||||
|
||||
pub command: gtk::Entry,
|
||||
|
||||
pub variables: adw::PreferencesGroup,
|
||||
|
||||
pub name: gtk::Entry,
|
||||
|
@ -35,6 +37,8 @@ impl AppWidgets {
|
|||
let result = Self {
|
||||
page: get_object(&builder, "page")?,
|
||||
|
||||
command: get_object(&builder, "command")?,
|
||||
|
||||
variables: get_object(&builder, "variables")?,
|
||||
|
||||
name: get_object(&builder, "name")?,
|
||||
|
@ -100,12 +104,26 @@ impl App {
|
|||
let this = self.clone();
|
||||
|
||||
self.widgets.add.connect_clicked(move |_| {
|
||||
let name = this.widgets.name.text().as_str().to_string();
|
||||
let value = this.widgets.value.text().as_str().to_string();
|
||||
let name = this.widgets.name.text().to_string();
|
||||
let value = this.widgets.value.text().to_string();
|
||||
|
||||
this.update(Actions::Add(Rc::new((name, value)))).unwrap();
|
||||
});
|
||||
|
||||
self.widgets.command.connect_changed(move |entry| {
|
||||
if let Ok(mut config) = config::get() {
|
||||
let command = entry.text().to_string();
|
||||
|
||||
config.game.command = if command.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(command)
|
||||
};
|
||||
|
||||
config::update(config);
|
||||
}
|
||||
});
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -129,7 +147,7 @@ impl App {
|
|||
Actions::Add(strs) => {
|
||||
let (name, value) = &*strs;
|
||||
|
||||
if name.len() > 0 && value.len() > 0 {
|
||||
if !name.is_empty() && !value.is_empty() {
|
||||
if !values.rows.contains_key(name) {
|
||||
config.game.environment.insert(name.clone(), value.clone());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue