From aeb1251b77388ee299dc1e3baae2770f60507a95 Mon Sep 17 00:00:00 2001 From: Philip Kristoffersen Date: Mon, 27 Sep 2021 22:28:52 +0200 Subject: [PATCH] Setup UI within feature UI The feature is not enabled yet. It will be enabled by default later when ui is ready. --- Cargo.lock | 7 ++++ Cargo.toml | 7 ++++ build.rs | 9 +++++ gui/mainview.fl | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 13 +++---- src/mainview.rs | 4 +++ 6 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 build.rs create mode 100644 gui/mainview.fl create mode 100644 src/mainview.rs diff --git a/Cargo.lock b/Cargo.lock index 658f43c..44acbec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,6 +194,12 @@ dependencies = [ "synstructure", ] +[[package]] +name = "fl2rust" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cf52a69f51e16cffda2993f68b33a0fafd0d664163f87fa80e5e4fec2fc232" + [[package]] name = "fltk" version = "1.2.3" @@ -1084,6 +1090,7 @@ version = "0.2.0" dependencies = [ "config", "failure", + "fl2rust", "fltk", "reqwest", "serde 1.0.130", diff --git a/Cargo.toml b/Cargo.toml index deac21d..66d6548 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,10 @@ config = "0.11.0" failure = "0.1.8" #https://fltk-rs.github.io/fltk-rs/ fltk = { version = "^1.2", features = ["fltk-bundled"] } + + +[build-dependencies] +fl2rust = "0.4" + +[features] +ui=[] \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..ee360ea --- /dev/null +++ b/build.rs @@ -0,0 +1,9 @@ +use std::path::PathBuf; +use std::env; + +fn main() { + println!("cargo:rerun-if-changed=gui/mainview.fl"); + let g = fl2rust::Generator::default(); + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + g.in_out("gui/mainview.fl", out_path.join("mainview.rs").to_str().unwrap()).expect("Failed to generate rust from fl file!"); +} \ No newline at end of file diff --git a/gui/mainview.fl b/gui/mainview.fl new file mode 100644 index 0000000..8e47a97 --- /dev/null +++ b/gui/mainview.fl @@ -0,0 +1,91 @@ +# data file for the Fltk User Interface Designer (fluid) +version 1.0305 +header_name {.h} +code_name {.cxx} +class UserInterface {open +} { + Function {make_window()} {open + } { + Fl_Window win { + label {Main View} open + xywh {768 846 660 730} type Double visible + } { + Fl_Group {} { + label {Steam Shortcut Sync} open selected + xywh {25 65 635 650} labelsize 26 labelcolor 35 align 5 + } {} + Fl_Group {} { + label Steam open + xywh {40 126 575 39} align 5 + } { + Fl_Input steam_location_input { + label {Steam Location} + xywh {40 126 445 26} align 5 + } + Fl_Button browse_steam_location_button { + label Browse + xywh {485 126 120 26} + } + } + Fl_Group {} { + label {Steamgrid DB} open + xywh {40 220 600 83} align 5 + } { + Fl_Check_Button enable_steamgrid_db_checkbox { + label {Download Images} + tooltip {Download coverart for games from www.steamgriddb.com} xywh {40 230 155 26} down_box DOWN_BOX + } + Fl_Input steamgrid_db_auth_key_input { + label {Authentication Key} + xywh {40 275 445 26} align 5 + } + } + Fl_Group {} { + label {Epic Games Store} open + xywh {40 350 575 108} align 5 + } { + Fl_Check_Button enable_egs_checkbox { + label Synchronize + xywh {40 360 560 26} down_box DOWN_BOX + } + Fl_Input epic_location_input { + label {Epic Location} + xywh {40 405 445 26} align 5 + } + Fl_Button browse_egs_location_button { + label Browse + xywh {485 405 120 26} + } + } + Fl_Group {} { + label Legendary open + xywh {40 480 580 104} align 5 + } { + Fl_Check_Button enable_legendary_checkbox { + label Enable + xywh {40 490 570 26} down_box DOWN_BOX + } + Fl_Input legendary_executable_input { + label {Legendary Executable} + xywh {40 535 445 26} align 5 + } + Fl_Button browse_legendary_executable_button { + label Browse + xywh {485 535 120 26} + } + } + Fl_Group action_buttons {open + xywh {37 652 495 50} + } { + Fl_Button save_settings_button { + label {Save Settings} + xywh {40 660 120 40} + } + Fl_Button synchronize_button { + label {Synchronize Games} + xywh {170 660 160 40} + } + } + } + } +} diff --git a/src/main.rs b/src/main.rs index 5e42fa1..96b2b2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ mod settings; mod steam; mod steamgriddb; use fltk::{app, prelude::*, window::Window}; - +mod mainview; use crate::{ egs::EpicPlatform, @@ -21,12 +21,13 @@ use steam_shortcuts_util::{shortcut::ShortcutOwned, shortcuts_to_bytes, Shortcut #[tokio::main] async fn main() -> Result<(), Box> { - let app = app::App::default(); - let mut wind = Window::new(100, 100, 400, 300, "Hello from rust"); - wind.end(); - wind.show(); - app.run().unwrap(); + #[cfg(feature = "ui")] + { + let app = app::App::default().with_scheme(app::Scheme::Gtk); + let mut ui = mainview::UserInterface::make_window(); + app.run().unwrap(); + } let settings = Settings::new()?; diff --git a/src/mainview.rs b/src/mainview.rs new file mode 100644 index 0000000..2cd8136 --- /dev/null +++ b/src/mainview.rs @@ -0,0 +1,4 @@ +#![allow(unused_variables)] +#![allow(unused_mut)] +#![allow(unused_imports)] +include!(concat!(env!("OUT_DIR"), "/mainview.rs")); \ No newline at end of file