mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2025-12-12 23:48:52 +00:00
added the foundation to transition from Flutter to GTK
This commit is contained in:
parent
b1248fdb05
commit
f6247cee5a
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,5 +1,7 @@
|
||||
set_github_env.sh
|
||||
|
||||
babylonia-terminal-cli/TDData-data.db
|
||||
|
||||
babylonia-terminal-cli/backtrace.txt
|
||||
babylonia-terminal-cli/target
|
||||
babylonia-terminal-gui/target
|
||||
babylonia-terminal/target
|
||||
|
||||
@ -8,9 +8,6 @@ repository = "https://github.com/ALEZ-DEV/Babylonia-terminal"
|
||||
license = "LGPL-3.0-or-later"
|
||||
keywords = ["launcher", "game"]
|
||||
|
||||
[[bin]]
|
||||
name = "babylonia-terminal-cli"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -16,4 +16,8 @@ pub struct Args {
|
||||
/// Show the logs direcly to the stdout of your terminal
|
||||
#[arg(long, default_value = "false")]
|
||||
pub logs: bool,
|
||||
|
||||
/// Launch the GUI version
|
||||
#[arg(long, default_value = "false")]
|
||||
pub gui: bool,
|
||||
}
|
||||
|
||||
29
babylonia-terminal-cli/src/lib.rs
Normal file
29
babylonia-terminal-cli/src/lib.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use arguments::Args;
|
||||
use babylonia_terminal_sdk::game_config::GameConfig;
|
||||
use clap::Parser;
|
||||
use log::debug;
|
||||
|
||||
pub mod arguments;
|
||||
pub mod game;
|
||||
pub mod reporter;
|
||||
pub mod utils;
|
||||
|
||||
pub fn run() {
|
||||
let args = Args::parse();
|
||||
|
||||
debug!("Launch option -> {:?}", args.options);
|
||||
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
if let Some(command) = args.set_options {
|
||||
GameConfig::set_launch_options(Some(command))
|
||||
.await
|
||||
.expect("Failed to save launch options into the config file");
|
||||
}
|
||||
|
||||
game::run(args.options, args.logs).await;
|
||||
});
|
||||
}
|
||||
2875
babylonia-terminal-gui/Cargo.lock
generated
Normal file
2875
babylonia-terminal-gui/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
babylonia-terminal-gui/Cargo.toml
Normal file
11
babylonia-terminal-gui/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "babylonia-terminal-gui"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
babylonia-terminal-sdk = { path = "./../babylonia-terminal-sdk" }
|
||||
anyhow = "1.0.94"
|
||||
log = "0.4.22"
|
||||
relm4 = "0.9.1"
|
||||
relm4-components = "0.9.1"
|
||||
87
babylonia-terminal-gui/src/lib.rs
Normal file
87
babylonia-terminal-gui/src/lib.rs
Normal file
@ -0,0 +1,87 @@
|
||||
use log::debug;
|
||||
use relm4::RelmApp;
|
||||
use relm4::{
|
||||
gtk::{
|
||||
self,
|
||||
prelude::{BoxExt, ButtonExt, GtkWindowExt, OrientableExt},
|
||||
},
|
||||
ComponentParts, RelmWidgetExt, SimpleComponent,
|
||||
};
|
||||
|
||||
pub fn run() {
|
||||
debug!("Start GUI!");
|
||||
let app = RelmApp::new("moe.celica.BabyloniaTerminal").with_args(vec![]);
|
||||
app.run::<AppModel>(0);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum AppMsg {
|
||||
Increment,
|
||||
Decrement,
|
||||
}
|
||||
|
||||
struct AppModel {
|
||||
counter: u8,
|
||||
}
|
||||
|
||||
#[relm4::component]
|
||||
impl SimpleComponent for AppModel {
|
||||
type Input = AppMsg;
|
||||
|
||||
type Output = ();
|
||||
|
||||
type Init = u8;
|
||||
|
||||
view! {
|
||||
gtk::Window {
|
||||
set_title: Some("Babylonia Terminal"),
|
||||
set_default_width: 700,
|
||||
set_default_height: 300,
|
||||
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_spacing: 5,
|
||||
set_margin_all: 5,
|
||||
|
||||
gtk::Button {
|
||||
set_label: "Increment",
|
||||
connect_clicked => AppMsg::Increment,
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: "Decrement",
|
||||
connect_clicked => AppMsg::Decrement,
|
||||
},
|
||||
|
||||
gtk::Label {
|
||||
#[watch]
|
||||
set_label: &format!("Counter : {}", model.counter),
|
||||
set_margin_all: 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
counter: Self::Init,
|
||||
window: Self::Root,
|
||||
sender: relm4::ComponentSender<Self>,
|
||||
) -> relm4::ComponentParts<Self> {
|
||||
let model = AppModel { counter };
|
||||
|
||||
let widgets = view_output!();
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Self::Input, _sender: relm4::ComponentSender<Self>) {
|
||||
match message {
|
||||
AppMsg::Increment => {
|
||||
self.counter = self.counter.wrapping_add(1);
|
||||
}
|
||||
AppMsg::Decrement => {
|
||||
self.counter = self.counter.wrapping_sub(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3257
babylonia-terminal/Cargo.lock
generated
Normal file
3257
babylonia-terminal/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
babylonia-terminal/Cargo.toml
Normal file
12
babylonia-terminal/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "babylonia-terminal"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
babylonia-terminal-cli = { path = "./../babylonia-terminal-cli" }
|
||||
babylonia-terminal-gui = { path = "./../babylonia-terminal-gui" }
|
||||
log = "0.4.22"
|
||||
simple_logger = "5.0.0"
|
||||
tokio = { version = "1.37.0", features = ["full"] }
|
||||
clap = "4.5.23"
|
||||
@ -1,17 +1,8 @@
|
||||
use babylonia_terminal_sdk::game_config::GameConfig;
|
||||
use clap::Parser;
|
||||
use log::{debug, LevelFilter};
|
||||
use log::LevelFilter;
|
||||
use simple_logger::SimpleLogger;
|
||||
|
||||
mod arguments;
|
||||
pub mod game;
|
||||
pub mod reporter;
|
||||
pub mod utils;
|
||||
|
||||
use crate::arguments::Args;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
fn main() {
|
||||
let simple_logger = SimpleLogger::new()
|
||||
.with_module_level("hyper", LevelFilter::Off)
|
||||
.with_module_level("hyper_util", LevelFilter::Off)
|
||||
@ -26,14 +17,11 @@ async fn main() {
|
||||
simple_logger.with_level(LevelFilter::Info).init().unwrap();
|
||||
}
|
||||
|
||||
let args = Args::parse();
|
||||
debug!("Launch option -> {:?}", args.options);
|
||||
let args = babylonia_terminal_cli::arguments::Args::parse();
|
||||
|
||||
if let Some(command) = args.set_options {
|
||||
GameConfig::set_launch_options(Some(command))
|
||||
.await
|
||||
.expect("Failed to save launch options into the config file");
|
||||
if args.gui {
|
||||
babylonia_terminal_gui::run();
|
||||
} else {
|
||||
babylonia_terminal_cli::run();
|
||||
}
|
||||
|
||||
game::run(args.options, args.logs).await;
|
||||
}
|
||||
41
flake.lock
generated
41
flake.lock
generated
@ -2,23 +2,42 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1726642912,
|
||||
"narHash": "sha256-wiZzKGHRAhItEuoE599Wm3ic+Lg/NykuBvhb+awf7N8=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "395c52d142ec1df377acd67db6d4a22950b02a98",
|
||||
"type": "github"
|
||||
"lastModified": 1733940404,
|
||||
"narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=",
|
||||
"rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713",
|
||||
"revCount": 720697,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.720697%2Brev-5d67ea6b4b63378b9c13be21e2ec9d1afc921713/0193beb2-e6fa-7337-96e3-cfa8c3818a9e/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1734143514,
|
||||
"narHash": "sha256-1+r8wYucn8kp9d/IBW1uYGs31QQmSZURElsiOTx65xM=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "81fe5c27cb281a9b796d7ad05ad9179e5bd0c78d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
119
flake.nix
119
flake.nix
@ -2,74 +2,57 @@
|
||||
description = "Flake to manage the babylonia-terminal dependecies";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages."x86_64-linux";
|
||||
in
|
||||
{
|
||||
|
||||
devShells."x86_64-linux".default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
rustup
|
||||
rustfmt
|
||||
clippy
|
||||
rust-analyzer
|
||||
gcc
|
||||
pkg-config
|
||||
flutter
|
||||
protoc-gen-prost
|
||||
|
||||
wayland
|
||||
openssl
|
||||
cabextract
|
||||
|
||||
#mpv dependecies
|
||||
mpv
|
||||
mpv-unwrapped
|
||||
libass
|
||||
libplacebo
|
||||
libunwind
|
||||
shaderc
|
||||
vulkan-loader
|
||||
lcms
|
||||
libdovi
|
||||
libdvdnav
|
||||
libdvdread
|
||||
libGL
|
||||
mujs
|
||||
libbluray
|
||||
lua
|
||||
rubberband
|
||||
SDL2
|
||||
libuchardet
|
||||
zimg
|
||||
alsa-lib
|
||||
openal
|
||||
ffmpeg
|
||||
libcaca
|
||||
libdrm
|
||||
libpulseaudio
|
||||
libva
|
||||
libvdpau
|
||||
mesa
|
||||
nv-codec-headers-11
|
||||
pipewire
|
||||
xorg.libXpresent
|
||||
xorg.libXScrnSaver
|
||||
xorg.libXv
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export OPENSSL_DIR="${pkgs.openssl.dev}"
|
||||
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig:${pkgs.mpv-unwrapped.dev}/lib/pkgconfig:${pkgs.libass.dev}/lib/pkgconfig:${pkgs.ffmpeg.dev}/lib/pkgconfig:${pkgs.libplacebo}/lib/pkgconfig:${pkgs.libunwind.dev}/lib/pkgconfig:${pkgs.shaderc.dev}/lib/pkgconfig:${pkgs.vulkan-loader.dev}/lib/pkgconfig:${pkgs.lcms.dev}/lib/pkgconfig:${pkgs.libdovi}/lib/pkgconfig:${pkgs.libdvdnav}/lib/pkgconfig:${pkgs.libdvdread}/lib/pkgconfig:${pkgs.mujs}/lib/pkgconfig:${pkgs.pipewire.dev}/lib/pkgconfig:${pkgs.libbluray}/lib/pkgconfig:${pkgs.lua}/lib/pkgconfig:${pkgs.rubberband}/lib/pkgconfig:${pkgs.SDL2.dev}/lib/pkgconfig:${pkgs.libuchardet.dev}/lib/pkgconfig:${pkgs.zimg.dev}/lib/pkgconfig:${pkgs.alsa-lib.dev}/lib/pkgconfig:${pkgs.openal}/lib/pkgconfig:${pkgs.libcaca.dev}/lib/pkgconfig:${pkgs.libdrm.dev}/lib/pkgconfig:${pkgs.libpulseaudio.dev}/lib/pkgconfig:${pkgs.libva.dev}/lib/pkgconfig:${pkgs.libvdpau.dev}/lib/pkgconfig:${pkgs.mesa.dev}/lib/pkgconfig:${pkgs.nv-codec-headers-11}/lib/pkgconfig:${pkgs.pipewire.dev}/lib/pkgconfig:${pkgs.xorg.libXpresent}/lib/pkgconfig:${pkgs.xorg.libXpresent}/lib/pkgconfig:${pkgs.xorg.libXScrnSaver}/lib/pkgconfig:${pkgs.xorg.libXv.dev}/lib/pkgconfig"
|
||||
export OPENSSL_NO_VENDOR=1
|
||||
export OPENSSL_LIB_DIR="${pkgs.lib.getLib pkgs.openssl}/lib"
|
||||
export FLUTTER_ROOT="${pkgs.flutter}"
|
||||
export LD_LIBRARY_PATH="${pkgs.wayland}:$LD_LIBRARY_PATH"
|
||||
'';
|
||||
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay }:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ rust-overlay.overlays.default self.overlays.default ];
|
||||
};
|
||||
});
|
||||
in
|
||||
{
|
||||
overlays.default = final: prev: {
|
||||
rustToolchain =
|
||||
let
|
||||
rust = prev.rust-bin;
|
||||
in
|
||||
if builtins.pathExists ./rust-toolchain.toml then
|
||||
rust.fromRustupToolchainFile ./rust-toolchain.toml
|
||||
else if builtins.pathExists ./rust-toolchain then
|
||||
rust.fromRustupToolchainFile ./rust-toolchain
|
||||
else
|
||||
rust.stable.latest.default.override {
|
||||
extensions = [ "rust-src" "rustfmt" ];
|
||||
};
|
||||
};
|
||||
|
||||
devShells = forEachSupportedSystem ({ pkgs }: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
rustToolchain
|
||||
openssl
|
||||
pkg-config
|
||||
cargo-deny
|
||||
cargo-edit
|
||||
cargo-watch
|
||||
rust-analyzer
|
||||
gtk4
|
||||
];
|
||||
|
||||
env = {
|
||||
# Required by rust-analyzer
|
||||
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user