diff options
author | Stelios Tsampas | 2023-09-09 01:37:07 +0300 |
---|---|---|
committer | Stelios Tsampas | 2023-09-09 01:37:07 +0300 |
commit | 5bb2bd3886383ed0d49921129db45851f3dab8cd (patch) | |
tree | a3b1c7d16927374f5412a3d606e6cf974db1ead5 | |
parent | e7a70202dba8c4e1d58369a44f0f6b0190837321 (diff) | |
download | aur-5bb2bd3886383ed0d49921129db45851f3dab8cd.tar.gz |
[rbdoom-3-bfg] Rewrite launcher in pyside6
-rw-r--r-- | .SRCINFO | 8 | ||||
-rw-r--r-- | PKGBUILD | 8 | ||||
-rw-r--r-- | PKGBUILD.live | 6 | ||||
-rw-r--r-- | rbdoom-3-bfg-launcher | 172 |
4 files changed, 105 insertions, 89 deletions
@@ -1,7 +1,7 @@ pkgbase = rbdoom-3-bfg pkgdesc = Doom 3 BFG Edition with modern engine features like PBR, Baked Global Illumination, Soft Shadows pkgver = 1.5.1 - pkgrel = 5 + pkgrel = 6 url = https://github.com/RobertBeckebans/RBDOOM-3-BFG install = rbdoom-3-bfg.install arch = x86_64 @@ -16,9 +16,9 @@ pkgbase = rbdoom-3-bfg depends = openal depends = sdl2 optdepends = doom3bfg-data: packaged game data files + optdepends = pyside6: for the included launcher script + optdepends = python-pyxdg: for the included launcher script optdepends = mergerfs: required by the included launcher script to setup the correct file structure - optdepends = zenity: UI for the included launcher script - optdepends = yad: alternative UI for the included launcher script options = !lto source = git+https://github.com/RobertBeckebans/RBDOOM-3-BFG.git#tag=v1.5.1 source = rbdoom-3-bfg.png @@ -28,7 +28,7 @@ pkgbase = rbdoom-3-bfg sha256sums = SKIP sha256sums = 0fb6a3bb9b47cad65d5012ba20dc9de3b1487f4ac1908ee847e6087511b7f09e sha256sums = f317d503d30ecc6e0a70e353cb020d2ea78ecb05d8d2e0250f39cfd8a4fe16a5 - sha256sums = a7b8d1631f5b66bdba9b76cf0700122b2d6eaa5d670e33675e300103b7a379e2 + sha256sums = bcb5a2c7032e38469647123156f20dbe5b1560c9c328669e9def3e94257416a8 sha256sums = c083d028b5dd6f7c0d13d8d3f7a4b73a0d57d414890fea454eecbbf2dbcdac6d pkgname = rbdoom-3-bfg @@ -5,7 +5,7 @@ pkgname=rbdoom-3-bfg _srctag=1.5.1 pkgver=${_srctag//-/.} -pkgrel=5 +pkgrel=6 pkgdesc="Doom 3 BFG Edition with modern engine features like PBR, Baked Global Illumination, Soft Shadows" arch=('x86_64') url="https://github.com/RobertBeckebans/RBDOOM-3-BFG" @@ -25,9 +25,9 @@ makedepends=( ) optdepends=( 'doom3bfg-data: packaged game data files' + 'pyside6: for the included launcher script' + 'python-pyxdg: for the included launcher script' 'mergerfs: required by the included launcher script to setup the correct file structure' - 'zenity: UI for the included launcher script' - 'yad: alternative UI for the included launcher script' ) install=$pkgname.install options=(!lto) @@ -77,5 +77,5 @@ package() { sha256sums=('SKIP' '0fb6a3bb9b47cad65d5012ba20dc9de3b1487f4ac1908ee847e6087511b7f09e' 'f317d503d30ecc6e0a70e353cb020d2ea78ecb05d8d2e0250f39cfd8a4fe16a5' - 'a7b8d1631f5b66bdba9b76cf0700122b2d6eaa5d670e33675e300103b7a379e2' + 'bcb5a2c7032e38469647123156f20dbe5b1560c9c328669e9def3e94257416a8' 'c083d028b5dd6f7c0d13d8d3f7a4b73a0d57d414890fea454eecbbf2dbcdac6d') diff --git a/PKGBUILD.live b/PKGBUILD.live index c562e484e4ef..e2171e0398ad 100644 --- a/PKGBUILD.live +++ b/PKGBUILD.live @@ -24,9 +24,9 @@ makedepends=( ) optdepends=( 'doom3bfg-data: packaged game data files' + 'pyside6: for the included launcher script' + 'python-pyxdg: for the included launcher script' 'mergerfs: required by the included launcher script to setup the correct file structure' - 'zenity: UI for the included launcher script' - 'yad: alternative UI for the included launcher script' ) install=$pkgname.install options=(!lto) @@ -81,5 +81,5 @@ package() { sha256sums=('SKIP' '0fb6a3bb9b47cad65d5012ba20dc9de3b1487f4ac1908ee847e6087511b7f09e' 'f317d503d30ecc6e0a70e353cb020d2ea78ecb05d8d2e0250f39cfd8a4fe16a5' - 'a7b8d1631f5b66bdba9b76cf0700122b2d6eaa5d670e33675e300103b7a379e2' + 'bcb5a2c7032e38469647123156f20dbe5b1560c9c328669e9def3e94257416a8' 'c083d028b5dd6f7c0d13d8d3f7a4b73a0d57d414890fea454eecbbf2dbcdac6d') diff --git a/rbdoom-3-bfg-launcher b/rbdoom-3-bfg-launcher index 749ad1119730..6c5b5687d420 100644 --- a/rbdoom-3-bfg-launcher +++ b/rbdoom-3-bfg-launcher @@ -1,78 +1,94 @@ -#!/usr/bin/bash - -base_name="$(basename "$0")" -path_name=rbdoom3bfg-launcher -conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}"/"$path_name" -data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"/"$path_name" - -if [ -f "$(which yad)" ]; then - gui="$(which yad) --splash --class=$base_name --name=$base_name --title=$base_name" - file_select="$gui --file --directory" -fi -if [ -f "$(which zenity)" ]; then - gui="$(which zenity) --class=$base_name --name=$base_name --title=$base_name" - file_select="$gui --file-selection --directory" -fi - -if [ ! -f "$(which mergerfs)" ]; then - error_text="mergerfs is not installed." - if [ -z "$gui" ]; then - printf "%s: %s" "$(basename "$0")" "$error_text" - else - $gui --error --text="$error_text" - fi - exit 1 -fi - -if [ ! -d "$conf_dir" ]; then - mkdir -p "$conf_dir" -fi - -conf="$conf_dir"/launcher.conf -old_conf="$HOME"/.rbdoom3bfg/launcher.conf -if [ ! -f "$conf" ] && [ -f "$old_conf" ]; then - mv "$old_conf" "$conf" -fi -if [ -f "$conf" ]; then - source "$conf" -else - echo "install_dir=\"\"" > "$conf" -fi - -basepath="" -if [ -z "$install_dir" ]; then - if [ -z "$gui" ]; then - printf "%s: install_dir is not set." "$base_name" - printf "\n\n" - printf "\tThe default install locations will be searched.\n" - printf "\tIf RBDoom3BFG fails to start, specify the Doom 3 BFG\n" - printf "\tinstallation directory in %s.\n\n" "$conf" - else - info_text="install_dir is not set in the configuration file \n$conf\n" - info_text+="Without it, the default locations will be searched for game files.\n" - info_text+="\nDo you want to set it now?\n" - if $gui --question --text="$info_text"; then - install_dir="$($file_select)" - if [ -n "$install_dir" ]; then - echo "install_dir=\"$install_dir\"" >> "$conf" - fi - fi - fi -fi - -if [ -n "$install_dir" ]; then - if [ ! -d "$data_dir" ]; then - mkdir -p "$data_dir" - fi - mergerfs -o fsname=RBDoom3BFG /usr/share/games/doom3bfg:"$install_dir" "$data_dir" - basepath="+set fs_basepath $data_dir" -fi - -# Disable terminal support too, if the user knows -# what they are doing, they don't need the launcher anyways -RBDoom3BFG +set in_tty 0 $basepath "$@" - -if mountpoint -q "$data_dir"; then - umount "$data_dir" -fi -exit 0 +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import configparser +import os +import shutil +import subprocess +import sys + +from PySide6.QtCore import Qt +from PySide6.QtWidgets import QApplication, QFileDialog, QMessageBox +from xdg import BaseDirectory + +# exe_name = "dhewm3" +# doom_dir = "/usr/share/games/doom3" + +exe_name = "RBDoom3BFG" +doom_dir = "/usr/share/games/doom3bfg" + +base_name = f"{exe_name.lower()}-launcher" +conf_dir = BaseDirectory.save_config_path(base_name) +data_dir = BaseDirectory.save_data_path(base_name) + + +def fix_config(parser, path): + with open(path, "r+") as f: + contents = f.read() + f.seek(0, 0) + f.write(f"[{base_name}]\n" + contents) + parser.read(path) + for section in parser.sections(): + for key, val in parser.items(section): + parser.set(section, key, val.replace('"', "")) + + +def main() -> int: + app = QApplication(sys.argv) + app.setAttribute(Qt.AA_DontUseNativeDialogs, True) + app.setApplicationName(base_name) + app.setOrganizationName(base_name) + + mergerfs = shutil.which("mergerfs") + if not mergerfs: + QMessageBox.critical(None, f"{base_name}", "<b>mergerfs</b> is not installed.") + app.exit() + return 1 + + conf_path = os.path.join(conf_dir, "launcher.conf") + config = configparser.ConfigParser() + if os.path.exists(conf_path): + try: + config.read(conf_path) + except configparser.MissingSectionHeaderError: + fix_config(config, conf_path) + config.read(conf_path) + else: + config.add_section(base_name) + + install_dir = config.get(base_name, "install_dir", fallback=None) + if not install_dir: + ans = QMessageBox.question( + None, f"{base_name}", + f"install_dir is not set in the configuration file \n" + f"{conf_path}\n" + f"Without it, the default locations will be searched for game files.\n\n" + f"Do you want to set it now?\n" + ) + if ans == QMessageBox.Yes: + install_dir = QFileDialog().getExistingDirectory(None, base_name) + config.set(base_name, "install_dir", install_dir) + + with open(conf_path, 'w') as conf_file: + config.write(conf_file) + + base_path = [] + if install_dir is not None: + subprocess.run( + [mergerfs, "-o", f"fsname={exe_name}", f"{doom_dir}:{install_dir}", data_dir] + ) + base_path = ["+set", "fs_basepath", data_dir] + + subprocess.run( + [shutil.which(exe_name), "+set", "in_tty", "0", *base_path, *sys.argv] + ) + + if os.path.ismount(data_dir): + subprocess.run(["umount", data_dir]) + + app.exit() + return 0 + + +if __name__ == '__main__': + sys.exit(main()) |