commit d2992c9e2ccb08bafef64521da714c6c8eb7ac08 Author: poslop Date: Tue Jun 4 16:42:49 2024 -0500 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d00da71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/dist/ +/target/ +/Cargo.lock +.vscode/extensions.json +.vscode/settings.json +public/tauri.svg +public/yew.png diff --git a/.taurignore b/.taurignore new file mode 100644 index 0000000..1ebdc6d --- /dev/null +++ b/.taurignore @@ -0,0 +1,3 @@ +/src +/public +/Cargo.toml \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..1fa9c00 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "kaihai-ui" +version = "0.0.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies] +yew = { version = "0.21", features = ["csr"] } +yew-router = "0.18" +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4" +web-sys = "0.3" +js-sys = "0.3" +serde = { version = "1", features = ["derive"] } +serde-wasm-bindgen = "0.6" +console_error_panic_hook = "0.1.7" + +[workspace] +members = ["src-tauri"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..4eee105 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Tauri + Yew + +This template should help get you started developing with Tauri and Yew. + +## Recommended IDE Setup + +[VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). diff --git a/Trunk.toml b/Trunk.toml new file mode 100644 index 0000000..27a1f84 --- /dev/null +++ b/Trunk.toml @@ -0,0 +1,10 @@ +[build] +target = "./index.html" + +[watch] +ignore = ["./src-tauri"] + +[serve] +address = "127.0.0.1" +port = 1420 +open = false diff --git a/index.html b/index.html new file mode 100644 index 0000000..2666354 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + Tauri + Yew App + + + + + d + diff --git a/src-tauri/.gitignore b/src-tauri/.gitignore new file mode 100644 index 0000000..b21bd68 --- /dev/null +++ b/src-tauri/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml new file mode 100644 index 0000000..a7cb50e --- /dev/null +++ b/src-tauri/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "kaihai" +version = "0.0.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = { version = "1", features = [] } + +[dependencies] +tauri = { version = "1", features = ["shell-open"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" + +[features] +# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!! +custom-protocol = ["tauri/custom-protocol"] diff --git a/src-tauri/build.rs b/src-tauri/build.rs new file mode 100644 index 0000000..d860e1e --- /dev/null +++ b/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png new file mode 100644 index 0000000..6be5e50 Binary files /dev/null and b/src-tauri/icons/128x128.png differ diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png new file mode 100644 index 0000000..e81bece Binary files /dev/null and b/src-tauri/icons/128x128@2x.png differ diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png new file mode 100644 index 0000000..a437dd5 Binary files /dev/null and b/src-tauri/icons/32x32.png differ diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 0000000..0ca4f27 Binary files /dev/null and b/src-tauri/icons/Square107x107Logo.png differ diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 0000000..b81f820 Binary files /dev/null and b/src-tauri/icons/Square142x142Logo.png differ diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 0000000..624c7bf Binary files /dev/null and b/src-tauri/icons/Square150x150Logo.png differ diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 0000000..c021d2b Binary files /dev/null and b/src-tauri/icons/Square284x284Logo.png differ diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 0000000..6219700 Binary files /dev/null and b/src-tauri/icons/Square30x30Logo.png differ diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 0000000..f9bc048 Binary files /dev/null and b/src-tauri/icons/Square310x310Logo.png differ diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 0000000..d5fbfb2 Binary files /dev/null and b/src-tauri/icons/Square44x44Logo.png differ diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 0000000..63440d7 Binary files /dev/null and b/src-tauri/icons/Square71x71Logo.png differ diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 0000000..f3f705a Binary files /dev/null and b/src-tauri/icons/Square89x89Logo.png differ diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png new file mode 100644 index 0000000..4556388 Binary files /dev/null and b/src-tauri/icons/StoreLogo.png differ diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns new file mode 100644 index 0000000..12a5bce Binary files /dev/null and b/src-tauri/icons/icon.icns differ diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico new file mode 100644 index 0000000..b3636e4 Binary files /dev/null and b/src-tauri/icons/icon.ico differ diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png new file mode 100644 index 0000000..e1cd261 Binary files /dev/null and b/src-tauri/icons/icon.png differ diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs new file mode 100644 index 0000000..523550d --- /dev/null +++ b/src-tauri/src/main.rs @@ -0,0 +1,15 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +fn main() { + tauri::Builder::default() + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json new file mode 100644 index 0000000..5283c8b --- /dev/null +++ b/src-tauri/tauri.conf.json @@ -0,0 +1,44 @@ +{ + "build": { + "beforeDevCommand": "trunk serve", + "beforeBuildCommand": "trunk build", + "devPath": "http://localhost:1420", + "distDir": "../dist", + "withGlobalTauri": true + }, + "package": { + "productName": "kaihai", + "version": "0.0.0" + }, + "tauri": { + "allowlist": { + "all": false, + "shell": { + "all": false, + "open": true + } + }, + "windows": [ + { + "title": "kaihai", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + }, + "bundle": { + "active": true, + "targets": "all", + "identifier": "com.tauri.dev", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } + } +} diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..77d2312 --- /dev/null +++ b/src/app.rs @@ -0,0 +1,45 @@ +use wasm_bindgen::prelude::*; +use yew::prelude::*; +use yew_router::prelude::*; + +use crate::views::*; + +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(js_namespace = ["window", "__TAURI__", "tauri"])] + async fn invoke(cmd: &str, args: JsValue) -> JsValue; +} + +#[derive(Clone, Routable, PartialEq)] +pub enum Route { + #[at("/")] + Home, + #[at("/extract")] + Extract, + #[at("/settings")] + Settings, + #[not_found] + #[at("/404")] + NotFound, +} + + +#[function_component(App)] +pub fn app() -> Html { + html! { + + + render={switch} /> + + } +} + +fn switch(routes: Route) -> Html { + match routes { + Route::Home => html! { }, + Route::Extract => html! { }, + Route::Settings => html! { }, + Route::NotFound => html! {

{"404 Page Not Found"}

}, + } +} + diff --git a/src/config_settings.rs b/src/config_settings.rs new file mode 100644 index 0000000..dc1dc27 --- /dev/null +++ b/src/config_settings.rs @@ -0,0 +1,38 @@ +use std::fs; +use rocket::config; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Deserialize, Serialize, FromForm)] +pub struct Config { + pub cslol_dir: String, + pub wad_dir: String, + pub extract_dir: String, +} + +pub fn init_config() { + if fs::metadata("config.toml").is_err() { + let config = Config { + cslol_dir: "".to_string(), + wad_dir: "C:\\Riot Games\\League of Legends\\Game\\DATA\\FINAL\\Champions".to_string(), + extract_dir: "".to_string(), + }; + write_config(&config); + } +} + +pub fn load_config() -> Config { + let config = fs::read_to_string("config.toml") + .expect("Failed to read config.toml file"); + + toml::from_str(&config) + .expect("Failed to parse config.toml file") +} + +pub fn write_config(config: &Config) { + let config_content = toml::to_string(config) + .expect("Failed to serialize config"); + + fs::write("config.toml", config_content) + .expect("Failed to write to config.toml file"); +} + diff --git a/src/extractor.rs b/src/extractor.rs new file mode 100644 index 0000000..0da6524 --- /dev/null +++ b/src/extractor.rs @@ -0,0 +1,56 @@ +use std::process::Command; +use std::env; +use std::fs; +use walkdir::WalkDir; +use std::ffi::OsString; +use std::path::PathBuf; + +use crate::config_settings; + +pub fn extract_wad() { + let config = config_settings::load_config(); + let wad_files: Vec = WalkDir::new(config.wad_dir) + .into_iter() + .filter_map(|entry| entry.ok()) + .filter(|entry| { + let path = entry.path(); + let file_name = path.file_name().and_then(|name| name.to_str()).unwrap_or(""); + let extension = path.extension().and_then(|ext| ext.to_str()).unwrap_or(""); + extension == "client" && + file_name.ends_with(".wad.client") && + file_name.split('.').count() == 3 + }) + .map(|entry| entry.path().to_owned().into_os_string()) + .collect(); + + if wad_files.is_empty() { + eprintln!("No valid .wad.client files found in the directory"); + return; + } + + let current_dir = env::current_dir().expect("Failed to get current directory"); + let extraction_path = current_dir.join("wads"); + let bat_path = PathBuf::from(config.cslol_dir).join("cslol-tools\\wad-extract.exe"); + + if !extraction_path.exists() { + fs::create_dir_all(&extraction_path).expect("Failed to create extraction folder"); + } + + for (i, wad_file) in wad_files.iter().enumerate() { + let status = Command::new(&bat_path) + .arg(&wad_file) + .arg(&extraction_path) + .status() + .expect("Failed to execute command"); + + if status.success() { + println!("Successfully executed wad-extract.bat for {:?}", wad_file); + } else { + eprintln!("wad-extract.bat returned a non-zero status for {:?}", wad_file); + } + + if i >= 3 { + break; + } + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a15bbb5 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,10 @@ +mod app; +mod views; + +use app::App; + + +fn main() { + console_error_panic_hook::set_once(); + yew::Renderer::::new().render(); +} diff --git a/src/views/extract.rs b/src/views/extract.rs new file mode 100644 index 0000000..653cd15 --- /dev/null +++ b/src/views/extract.rs @@ -0,0 +1,18 @@ +use yew::prelude::*; + +#[function_component(Extract)] +pub fn extract() -> Html { + html! { +
+

{"Extract"}

+

{"Exctract shit"}

+ +
+
+ +
+
+ +
+ } +} \ No newline at end of file diff --git a/src/views/home.rs b/src/views/home.rs new file mode 100644 index 0000000..c985c04 --- /dev/null +++ b/src/views/home.rs @@ -0,0 +1,11 @@ +use yew::prelude::*; + +#[function_component(Home)] +pub fn home() -> Html { + html! { +
+

{"Home Page"}

+

{"Welcome to the Home page!"}

+
+ } +} diff --git a/src/views/mod.rs b/src/views/mod.rs new file mode 100644 index 0000000..6eec0ff --- /dev/null +++ b/src/views/mod.rs @@ -0,0 +1,8 @@ +pub mod extract; +pub mod home; +pub mod nav; +pub mod settings; + +pub use extract::*; +pub use home::*; +pub use settings::*; \ No newline at end of file diff --git a/src/views/nav.rs b/src/views/nav.rs new file mode 100644 index 0000000..4b7b0f1 --- /dev/null +++ b/src/views/nav.rs @@ -0,0 +1,14 @@ +use yew::prelude::*; +use yew_router::prelude::*; +use crate::app::Route; + +#[function_component(Nav)] +pub fn nav() -> Html { + html! { + + } +} \ No newline at end of file diff --git a/src/views/settings.rs b/src/views/settings.rs new file mode 100644 index 0000000..72d7e5a --- /dev/null +++ b/src/views/settings.rs @@ -0,0 +1,34 @@ +use yew::prelude::*; + + +#[function_component(Settings)] +pub fn settings() -> Html { + html! { +
+

{"Settings"}

+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ } +} diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..4ca75b3 --- /dev/null +++ b/styles.css @@ -0,0 +1,86 @@ +* { + box-sizing: border-box; +} + +body { + margin: 0; + color: white; + background-color: #181a1b; + font-family: Arial, Helvetica, sans-serif; +} + +/* Style the side navigation */ +.nav { + height: 100%; + width: 200px; + position: fixed; + z-index: 1; + top: 0; + left: 0; + background-color: #111; + overflow-x: hidden; +} + + +/* Side navigation links */ +.nav a { + color: white; + padding: 16px; + text-decoration: none; + display: block; +} + +/* Change color on hover */ +.nav a:hover { + background-color: #363b3d; +} + +/* Style the content */ +.content { + margin-left: 200px; + padding-left: 20px; +} + +.option { + margin-bottom: 10px; + /* Adds space below each option group */ + padding: 10px 0px; + /* Adds padding inside each option group */ + border-radius: 5px; + /* Rounds the corners of the option group */ +} + +.option label { + margin: 5px 0px; +} + +.option input { + outline: none; + border: 2px solid #111; + background-color: #111; + color: white; + width: 50%; + padding: 10px 20px; + margin: 10px 0px; + border-radius: 6px; +} + +.option input:focus { + background-color: #363b3d; + border: 2px solid #111; +} + +.option button { + background-color: #111; + border: 2px solid #111; + color: white; + padding: 16px 32px; + margin: 10px 0px; + border-radius: 6px; + +} + +.option button:hover { + background-color: #363b3d; + border: 2px solid #111; +} \ No newline at end of file