mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-03-15 06:28:27 +03:00
commit
0a7ec00c4e
11 changed files with 181 additions and 147 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed check button style for newly made sessions
|
||||
- Fixed repairer's NaN progress
|
||||
- Fixed game session selection when current one is removed
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated Spanish
|
||||
- Updated Hungarian (fixed #194)
|
||||
|
||||
## [3.7.1] - 11.06.2023
|
||||
|
||||
### Added
|
||||
|
|
55
Cargo.lock
generated
55
Cargo.lock
generated
|
@ -582,22 +582,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.14"
|
||||
version = "0.9.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
|
||||
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"memoffset 0.8.0",
|
||||
"memoffset 0.9.0",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.15"
|
||||
version = "0.8.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b"
|
||||
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
@ -1549,9 +1549,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.63"
|
||||
version = "0.3.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790"
|
||||
checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
@ -1695,15 +1695,6 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.0"
|
||||
|
@ -2304,9 +2295,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.37.19"
|
||||
version = "0.37.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
|
||||
checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
|
@ -3034,9 +3025,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.86"
|
||||
version = "0.2.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73"
|
||||
checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
|
@ -3044,9 +3035,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.86"
|
||||
version = "0.2.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb"
|
||||
checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
|
@ -3059,9 +3050,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.36"
|
||||
version = "0.4.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e"
|
||||
checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
|
@ -3071,9 +3062,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.86"
|
||||
version = "0.2.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258"
|
||||
checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
|
@ -3081,9 +3072,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.86"
|
||||
version = "0.2.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8"
|
||||
checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -3094,15 +3085,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.86"
|
||||
version = "0.2.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93"
|
||||
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.63"
|
||||
version = "0.3.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2"
|
||||
checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
|
|
@ -33,7 +33,7 @@ gamescope-description = Gamescope es una herramienta de Valve que permite que lo
|
|||
|
||||
discord-rpc = RPC de Discord
|
||||
discord-rpc-description = RPC de Discord permite que Discord muestre públicamente que estás jugando al juego.
|
||||
icon = Icon
|
||||
icon = Ícono
|
||||
title = Título
|
||||
description = Descripción
|
||||
|
||||
|
|
|
@ -56,5 +56,5 @@ game-session-apply-failed = Fallo al aplicar sesión de juego
|
|||
|
||||
# Enhancements
|
||||
|
||||
discord-rpc-icons-fetch-failed = Failed to fetch Discord RPC icons
|
||||
discord-rpc-icon-download-failed = Failed to download Discord RPC icon
|
||||
discord-rpc-icons-fetch-failed = Fallo al traer íconos para RPC de Discord
|
||||
discord-rpc-icon-download-failed = Fallo al descargar ícono para RPC de Discord
|
||||
|
|
|
@ -33,7 +33,7 @@ gamescope-description = A Gamescope-al egy külön Xwayland folyamatban fut a j
|
|||
|
||||
discord-rpc = Discord RPC
|
||||
discord-rpc-description = Kiírja a Discord profilod alá hogy játszol a játékkal
|
||||
icon = Icon
|
||||
icon = Ikon
|
||||
title = Title
|
||||
description = Description
|
||||
|
||||
|
|
|
@ -56,5 +56,5 @@ game-session-apply-failed = Játékmenet alkalmazása sikertelen
|
|||
|
||||
# Enhancements
|
||||
|
||||
discord-rpc-icons-fetch-failed = Failed to fetch Discord RPC icons
|
||||
discord-rpc-icon-download-failed = Failed to download Discord RPC icon
|
||||
discord-rpc-icons-fetch-failed = Discord RPC ikonok beszerzése sikertelen
|
||||
discord-rpc-icon-download-failed = Discord RPC ikon letöltése sikertelen
|
||||
|
|
|
@ -9,7 +9,7 @@ welcome-page-message =
|
|||
tos-violation-warning = ToS megszegési figyelmeztetés
|
||||
|
||||
tos-violation-warning-message =
|
||||
Ez a launcher egy nem hivatalos eszköz, semmi köze {company-name} és {comapny-alter-name}-hez.
|
||||
Ez a launcher egy nem hivatalos eszköz, semmi köze {company-name} és {company-alter-name}-hez.
|
||||
|
||||
Ez az eszköz arra készült, hogy lehetővé tegye {game-name} használatát Linux-on, és hogy megegyszerűsítse a telepítését és futtatását.
|
||||
|
||||
|
|
181
fluentscan.py
181
fluentscan.py
|
@ -7,21 +7,23 @@ import os
|
|||
import sys
|
||||
import glob
|
||||
import re
|
||||
import pydoc
|
||||
|
||||
valid_commands = ["diff", "unused", "missing"]
|
||||
if len(sys.argv) >= 2 and sys.argv[1] != "diff":
|
||||
path = "assets/locales/en/"
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
elif len(sys.argv) < 3:
|
||||
print(f"Command format: ./fluentscan.py [command] [locale]\nAvailable commands: {valid_commands}")
|
||||
|
||||
sys.exit()
|
||||
|
||||
if sys.argv[1] not in valid_commands:
|
||||
print(f"Invalid command \"{sys.argv[1]}\". Available commands: {valid_commands}")
|
||||
else: path = "assets/locales/" + sys.argv[2] + "/"
|
||||
|
||||
command = sys.argv[1]
|
||||
if command not in valid_commands:
|
||||
print(f"Invalid command \"{command}\". Available commands: {valid_commands}")
|
||||
sys.exit()
|
||||
|
||||
path = "assets/locales/" + sys.argv[2] + "/"
|
||||
|
||||
try:
|
||||
open(path + "/main.ftl", "r").close()
|
||||
|
||||
|
@ -30,8 +32,6 @@ except:
|
|||
|
||||
sys.exit()
|
||||
|
||||
all_entries = {}
|
||||
|
||||
def dict_compare(d1, d2):
|
||||
d1_keys = set(d1.keys())
|
||||
d2_keys = set(d2.keys())
|
||||
|
@ -61,92 +61,135 @@ def to_dict(text):
|
|||
|
||||
return result
|
||||
|
||||
def get_line_num(text,pattern):
|
||||
def get_line_num(file,pattern):
|
||||
line = 1
|
||||
|
||||
file.seek(0)
|
||||
text = file.read()
|
||||
|
||||
for i in text.split("\n"):
|
||||
if sys.argv[1] == "diff":
|
||||
if i == pattern:
|
||||
return line
|
||||
|
||||
if pattern in i:
|
||||
return line
|
||||
|
||||
line += 1
|
||||
|
||||
# format = {variable : file name}
|
||||
used_entries = {}
|
||||
unused_entries = {}
|
||||
missing_entries = {}
|
||||
# format = {variable : [file name, line number]}
|
||||
script_entries = {}
|
||||
all_entries = {}
|
||||
|
||||
# format = {variable : definition}
|
||||
every_variable = {}
|
||||
|
||||
files = glob.glob("src/**/*.rs", recursive=True)
|
||||
|
||||
output=""
|
||||
|
||||
for filename in os.listdir("assets/locales/en"):
|
||||
with open(os.path.join("assets/locales/en", filename), 'r') as locale_file:
|
||||
created_locale = open(path + filename)
|
||||
|
||||
expected = to_dict(locale_file)
|
||||
expected2 = to_dict(created_locale)
|
||||
en_variables = to_dict(locale_file)
|
||||
every_variable.update(en_variables)
|
||||
|
||||
all_entries.update(expected)
|
||||
for i in en_variables:
|
||||
all_entries[i] = [filename, get_line_num(locale_file, i)]
|
||||
# resets the file read
|
||||
locale_file.seek(0)
|
||||
|
||||
added, removed, same = dict_compare(expected, expected2)
|
||||
locale_variables = to_dict(created_locale)
|
||||
|
||||
if sys.argv[1] == "unused" or sys.argv[1] == "missing":
|
||||
files = glob.glob("src/**/*.rs", recursive=True)
|
||||
|
||||
used = []
|
||||
vars = {}
|
||||
|
||||
for i in files:
|
||||
with open(i, "r") as script:
|
||||
text = script.read()
|
||||
|
||||
if sys.argv[1] == "unused":
|
||||
for j in expected:
|
||||
if f"\"{j}\"" in text:
|
||||
used.append(j)
|
||||
|
||||
elif sys.argv[1] == "missing":
|
||||
for j in text.split():
|
||||
# TODO: ignore comments
|
||||
if 'tr("' in j:
|
||||
index = j.find('tr("')
|
||||
|
||||
var_name = re.sub('[^\\w-]+', '', j[index:].replace('tr("', '').replace("Some", ""))
|
||||
|
||||
# TODO: index multiple matches
|
||||
vars[var_name] = [script.name, get_line_num(text,var_name)]
|
||||
|
||||
if sys.argv[1] == "unused":
|
||||
for i in expected:
|
||||
if i not in used:
|
||||
print(f"[{locale_file.name}]\n"
|
||||
" [Unused]\n"
|
||||
f" {i}")
|
||||
|
||||
continue
|
||||
|
||||
if (added or removed or same) and sys.argv[1] == "diff":
|
||||
print(f"[{created_locale.name[15:]}]")
|
||||
added, removed, same = dict_compare(en_variables, locale_variables)
|
||||
|
||||
# perhaps theres a better way to do this
|
||||
# FIXME : output isn't sorted
|
||||
if command == "diff" and (added or removed or same):
|
||||
output += f"[{created_locale.name[15:]}]\n"
|
||||
if added:
|
||||
print(" [Added]")
|
||||
|
||||
output += " [Added]\n"
|
||||
for i in added:
|
||||
print(f" {i} = {expected[i]}")
|
||||
output += f" {get_line_num(locale_file,i)} | {i} = {en_variables[i].strip()}\n"
|
||||
|
||||
if removed:
|
||||
print(" [Removed]")
|
||||
|
||||
output += " [Removed]\n"
|
||||
for i in removed:
|
||||
print(f" {i} = {expected2[i]}")
|
||||
|
||||
#workaround
|
||||
if same and same != "set()":
|
||||
print(" [Untranslated]")
|
||||
output += f" {get_line_num(created_locale,i)} | {i} = {locale_variables[i].strip()}\n"
|
||||
|
||||
if same:
|
||||
output += " [Untranslated]\n"
|
||||
for i in same:
|
||||
print(f" {i} = {expected[i]}")
|
||||
output += f" {get_line_num(locale_file,i)} | {i} = {en_variables[i].strip()}\n"
|
||||
output += "\n"
|
||||
continue
|
||||
# on some cycles the code below runs, even if there are differences
|
||||
#else:
|
||||
#print(f"No differences spotted between \"en\" and \"{sys.argv[2]}\" locale")
|
||||
#sys.exit()
|
||||
|
||||
print("")
|
||||
# for "missing" and "unused" command
|
||||
for i in files:
|
||||
with open(i, "r") as script:
|
||||
# for unused entries
|
||||
for j in list(en_variables.keys()):
|
||||
script.seek(0)
|
||||
|
||||
if sys.argv[1] == "missing":
|
||||
added, removed, same = dict_compare(vars, all_entries)
|
||||
if f"\"{j}\"" in script.read():
|
||||
used_entries[j] = script.name
|
||||
|
||||
if not added:
|
||||
script.seek(0)
|
||||
# forgive me for my programming war crimes, this is 6 indentations!!!!!!
|
||||
# FIXME: it only indexes the first match
|
||||
for line in script.read().split("\n"):
|
||||
if ("tr(\"" in line) and ("#" not in line):
|
||||
index = line.find('tr("')
|
||||
indexLast = line.find('")',index)
|
||||
var_name = re.sub('[^\\w-]+', '', line[index:indexLast].replace('tr("', '').replace("Some", ""))
|
||||
|
||||
script_entries[var_name] = [script.name, get_line_num(script, var_name)]
|
||||
|
||||
## results stage ##
|
||||
|
||||
if command == "unused":
|
||||
printed = []
|
||||
for i in all_entries:
|
||||
if i not in used_entries:
|
||||
unused_entries[i] = all_entries[i]
|
||||
|
||||
for i in unused_entries:
|
||||
if all_entries[i][0] not in printed:
|
||||
printed.append(all_entries[i][0])
|
||||
output += f"[en/{all_entries[i][0]}]\n [Unused]\n"
|
||||
output += f" {all_entries[i][1]} | {i} = {every_variable[i].strip()}\n"
|
||||
|
||||
output = re.sub("\[en", "\n[en", output)
|
||||
|
||||
if not output:
|
||||
print("Nothing is unused")
|
||||
sys.exit()
|
||||
|
||||
# The way "unused" and "missing" process the data is very similar, perhaps it will be possible to do this in a function instead?
|
||||
elif command == "missing":
|
||||
printed = []
|
||||
for i in script_entries:
|
||||
if i not in all_entries:
|
||||
missing_entries[i] = script_entries[i][0]
|
||||
|
||||
for i in missing_entries:
|
||||
if script_entries[i][0] not in printed:
|
||||
printed.append(script_entries[i][0])
|
||||
output += f"[{missing_entries[i]}]\n [Missing]\n"
|
||||
output += f" {script_entries[i][1]} | {i}\n"
|
||||
|
||||
output = re.sub("\[src/", "\n[src/", output)
|
||||
if not output:
|
||||
print("Nothing is missing")
|
||||
sys.exit()
|
||||
|
||||
for i in added:
|
||||
print(f"[{vars[i][0]}, line {vars[i][1]}]\n"
|
||||
" [Missing]\n"
|
||||
f" {i}")
|
||||
pydoc.pager(output)
|
||||
|
|
|
@ -104,38 +104,19 @@ impl SimpleComponent for AboutDialog {
|
|||
|
||||
set_release_notes_version: &APP_VERSION,
|
||||
set_release_notes: &[
|
||||
"<p>Added</p>",
|
||||
|
||||
"<ul>",
|
||||
"<li>Added Discord RPC icon selection</li>",
|
||||
"<li>Added Japanese</li>",
|
||||
"<li>Added Hungarian</li>",
|
||||
"</ul>",
|
||||
|
||||
"<p>Fixed</p>",
|
||||
|
||||
"<ul>",
|
||||
"<li>Fixed progress bar style after running game repairer</li>",
|
||||
"<li>Fixed repair button functionality</li>",
|
||||
"<li>Fixed default launcher language selection at the first start</li>",
|
||||
"<li>Fixed some installer updates reporting (including \"checking free space\")</li>",
|
||||
"<li>Fixed check button style for newly made sessions</li>",
|
||||
"<li>Fixed repairer's NaN progress</li>",
|
||||
"<li>Fixed game session selection when current one is removed</li>",
|
||||
"</ul>",
|
||||
|
||||
"<p>Changed</p>",
|
||||
|
||||
"<ul>",
|
||||
"<li>Reworked game sessions selection</li>",
|
||||
"<li>Updated Indonesian</li>",
|
||||
"<li>Updated French</li>",
|
||||
"<li>Made initial tasks async which has decreased startup time</li>",
|
||||
"<li>Updated fps unlocker to 2.1.1</li>",
|
||||
"</ul>",
|
||||
|
||||
"<p>Removed</p>",
|
||||
|
||||
"<ul>",
|
||||
"<li>Removed 3.7.0 workaround</li>",
|
||||
"<li>Removed patch mirror migration</li>",
|
||||
"<li>Updated Spanish</li>",
|
||||
"<li>Updated Hungarian</li>",
|
||||
"</ul>",
|
||||
].join("\n"),
|
||||
|
||||
|
|
|
@ -98,14 +98,14 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
|
|||
}
|
||||
|
||||
if !broken.is_empty() {
|
||||
let total = broken.len() as u64;
|
||||
|
||||
progress_bar_input.send(ProgressBarMsg::UpdateCaption(Some(tr("repairing-files"))));
|
||||
progress_bar_input.send(ProgressBarMsg::DisplayFraction(false));
|
||||
progress_bar_input.send(ProgressBarMsg::UpdateProgress(0, 0));
|
||||
progress_bar_input.send(ProgressBarMsg::UpdateProgress(0, total));
|
||||
|
||||
tracing::warn!("Found broken files:\n{}", broken.iter().fold(String::new(), |acc, file| acc + &format!("- {}\n", file.path.to_string_lossy())));
|
||||
|
||||
let total = broken.len() as f64;
|
||||
|
||||
// Get main patch status
|
||||
|
||||
let player_patch = UnityPlayerPatch::from_folder(&config.patch.path, config.launcher.edition)
|
||||
|
@ -175,7 +175,7 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
|
|||
tracing::debug!("Skipped file: {}", file.path.to_string_lossy());
|
||||
}
|
||||
|
||||
progress_bar_input.send(ProgressBarMsg::UpdateProgress(i as u64, total as u64));
|
||||
progress_bar_input.send(ProgressBarMsg::UpdateProgress(i as u64 + 1, total));
|
||||
}
|
||||
|
||||
progress_bar_input.send(ProgressBarMsg::DisplayFraction(true));
|
||||
|
|
|
@ -49,7 +49,7 @@ impl AsyncFactoryComponent for GameSession {
|
|||
set_valign: gtk::Align::Center,
|
||||
|
||||
connect_clicked[sender, index] => move |_| {
|
||||
sender.output(GamePageMsg::UpdateSession(index.clone()));
|
||||
sender.output(GamePageMsg::UpdateSession(index.current_index()));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -62,14 +62,14 @@ impl AsyncFactoryComponent for GameSession {
|
|||
set_valign: gtk::Align::Center,
|
||||
|
||||
connect_clicked[sender, index] => move |_| {
|
||||
sender.output(GamePageMsg::RemoveSession(index.clone()));
|
||||
sender.output(GamePageMsg::RemoveSession(index.current_index()));
|
||||
}
|
||||
},
|
||||
|
||||
set_activatable: true,
|
||||
|
||||
connect_activated[sender, index] => move |_| {
|
||||
sender.output(GamePageMsg::SetCurrent(index.clone()));
|
||||
sender.output(GamePageMsg::SetCurrent(index.current_index()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,9 +97,9 @@ pub struct GamePage {
|
|||
#[derive(Debug, Clone)]
|
||||
pub enum GamePageMsg {
|
||||
AddSession,
|
||||
UpdateSession(DynamicIndex),
|
||||
RemoveSession(DynamicIndex),
|
||||
SetCurrent(DynamicIndex)
|
||||
UpdateSession(usize),
|
||||
RemoveSession(usize),
|
||||
SetCurrent(usize)
|
||||
}
|
||||
|
||||
#[relm4::component(async, pub)]
|
||||
|
@ -207,10 +207,14 @@ impl SimpleAsyncComponent for GamePage {
|
|||
|
||||
match Sessions::update(name.clone(), config.get_wine_prefix_path()) {
|
||||
Ok(()) => {
|
||||
let check_button = gtk::CheckButton::new();
|
||||
|
||||
check_button.set_group(Some(&self.sessions_root_widget));
|
||||
|
||||
self.sessions.guard().push_back(GameSession {
|
||||
name,
|
||||
description: None,
|
||||
check_button: gtk::CheckButton::new()
|
||||
check_button
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -226,7 +230,7 @@ impl SimpleAsyncComponent for GamePage {
|
|||
}
|
||||
|
||||
GamePageMsg::UpdateSession(index) => {
|
||||
if let Some(session) = self.sessions.guard().get(index.current_index()) {
|
||||
if let Some(session) = self.sessions.guard().get(index) {
|
||||
if let Ok(config) = Config::get() {
|
||||
if let Err(err) = Sessions::update(session.name.clone(), config.get_wine_prefix_path()) {
|
||||
sender.output(EnhancementsAppMsg::Toast {
|
||||
|
@ -239,7 +243,7 @@ impl SimpleAsyncComponent for GamePage {
|
|||
}
|
||||
|
||||
GamePageMsg::RemoveSession(index) => {
|
||||
if let Some(session) = self.sessions.guard().get(index.current_index()) {
|
||||
if let Some(session) = self.sessions.guard().get(index) {
|
||||
if let Err(err) = Sessions::remove(&session.name) {
|
||||
sender.output(EnhancementsAppMsg::Toast {
|
||||
title: tr("game-session-remove-failed"),
|
||||
|
@ -250,11 +254,15 @@ impl SimpleAsyncComponent for GamePage {
|
|||
}
|
||||
}
|
||||
|
||||
self.sessions.guard().remove(index.current_index());
|
||||
self.sessions.guard().remove(index);
|
||||
|
||||
if !self.sessions.is_empty() {
|
||||
sender.input(GamePageMsg::SetCurrent(0));
|
||||
}
|
||||
}
|
||||
|
||||
GamePageMsg::SetCurrent(index) => {
|
||||
if let Some(session) = self.sessions.guard().get(index.current_index()) {
|
||||
if let Some(session) = self.sessions.guard().get(index) {
|
||||
if let Ok(config) = Config::get() {
|
||||
if let Err(err) = Sessions::set_current(session.name.clone()) {
|
||||
sender.output(EnhancementsAppMsg::Toast {
|
||||
|
|
Loading…
Add table
Reference in a new issue