Compare commits
6 Commits
ac3d6e8b15
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7bf93d4d1 | ||
|
|
a05d64a9c6 | ||
|
|
652d6053b7 | ||
|
|
faa3f0eff2 | ||
|
|
f064e3eb9a | ||
|
|
c60c8fee4b |
@@ -7,9 +7,10 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
yew = { version = "0.21", features = ["csr"] }
|
yew = { version = "0.21", features = ["csr"] }
|
||||||
yew-router = "0.18"
|
yew-router = "0.18"
|
||||||
|
walkdir = "2.3.2"
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
wasm-bindgen-futures = "0.4"
|
wasm-bindgen-futures = "0.4"
|
||||||
web-sys = "0.3"
|
toml = "0.5"
|
||||||
js-sys = "0.3"
|
js-sys = "0.3"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde-wasm-bindgen = "0.6"
|
serde-wasm-bindgen = "0.6"
|
||||||
@@ -17,3 +18,8 @@ console_error_panic_hook = "0.1.7"
|
|||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["src-tauri"]
|
members = ["src-tauri"]
|
||||||
|
|
||||||
|
|
||||||
|
[dependencies.web-sys]
|
||||||
|
version = "0.3"
|
||||||
|
features = ["Window", "console", "HtmlSelectElement"]
|
||||||
|
|||||||
17
index.html
17
index.html
@@ -6,6 +6,19 @@
|
|||||||
<link data-trunk rel="css" href="styles.css" />
|
<link data-trunk rel="css" href="styles.css" />
|
||||||
<link data-trunk rel="copy-dir" href="public" />
|
<link data-trunk rel="copy-dir" href="public" />
|
||||||
</head>
|
</head>
|
||||||
<body></body>
|
<body>
|
||||||
d
|
<script>
|
||||||
|
// access the pre-bundled global API functions
|
||||||
|
const { invoke } = window.__TAURI__.tauri
|
||||||
|
|
||||||
|
// now we can call our Command!
|
||||||
|
// You will see "Welcome from Tauri" replaced
|
||||||
|
// by "Hello, World!"!
|
||||||
|
invoke('init_config', { name: 'World' })
|
||||||
|
// `invoke` returns a Promise
|
||||||
|
.then((response) => {
|
||||||
|
window.header.innerHTML = response
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
17
public/glue.js
Normal file
17
public/glue.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const invoke = window.__TAURI__.invoke
|
||||||
|
|
||||||
|
export async function init_config_js() {
|
||||||
|
return await invoke("init_config");
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function write_config_js(config) {
|
||||||
|
return await invoke("write_config", { config: config });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function load_config_js() {
|
||||||
|
return await invoke("load_config");
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function load_champions_js() {
|
||||||
|
return await invoke("load_champions");
|
||||||
|
}
|
||||||
1
src-tauri/.gitignore
vendored
1
src-tauri/.gitignore
vendored
@@ -5,3 +5,4 @@
|
|||||||
# Generated by Tauri
|
# Generated by Tauri
|
||||||
# will have schema files for capabilities auto-completion
|
# will have schema files for capabilities auto-completion
|
||||||
/gen/schemas
|
/gen/schemas
|
||||||
|
|
||||||
|
|||||||
1
src-tauri/.taurignore
Normal file
1
src-tauri/.taurignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
config.toml
|
||||||
@@ -11,9 +11,13 @@ edition = "2021"
|
|||||||
tauri-build = { version = "1", features = [] }
|
tauri-build = { version = "1", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "1", features = ["shell-open"] }
|
tauri = { version = "1", features = [ "api-all"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
toml = "0.5"
|
||||||
|
tokio = "1.38.0"
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
walkdir = "2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
||||||
|
|||||||
3
src-tauri/config.toml
Normal file
3
src-tauri/config.toml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
cslol_dir = ""
|
||||||
|
wad_dir = "C:\\Riot Games\\League of Legends\\Game\\DATA\\FINAL\\Champions"
|
||||||
|
extract_dir = ""
|
||||||
39
src-tauri/src/config_settings.rs
Normal file
39
src-tauri/src/config_settings.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
use std::fs;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub cslol_dir: String,
|
||||||
|
pub wad_dir: String,
|
||||||
|
pub extract_dir: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async 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).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async 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");
|
||||||
|
}
|
||||||
68
src-tauri/src/extractor.rs
Normal file
68
src-tauri/src/extractor.rs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::process::ExitStatus;
|
||||||
|
use serde::de::value::Error;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
use std::ffi::OsString;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use crate::config_settings;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Champion {
|
||||||
|
name: String,
|
||||||
|
location: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn load_champions() -> Vec<Champion> {
|
||||||
|
|
||||||
|
let config = config_settings::load_config().await;
|
||||||
|
|
||||||
|
let champions: Vec<Champion> = WalkDir::new(&config.wad_dir)
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|entry| entry.ok())
|
||||||
|
.filter_map(|entry| {
|
||||||
|
let path = entry.path();
|
||||||
|
let file_name = path.file_name().and_then(|name| name.to_str())?;
|
||||||
|
let extension = path.extension().and_then(|ext| ext.to_str())?;
|
||||||
|
if extension == "client" &&
|
||||||
|
file_name.ends_with(".wad.client") &&
|
||||||
|
file_name.split('.').count() == 3
|
||||||
|
{
|
||||||
|
let name = file_name.split('.').next().unwrap_or("").to_string();
|
||||||
|
let location = path.to_str().unwrap_or("").to_string();
|
||||||
|
Some(Champion {
|
||||||
|
name,
|
||||||
|
location,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
champions
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn extract_wad(champion: Champion) {
|
||||||
|
let config = config_settings::load_config().await;
|
||||||
|
|
||||||
|
|
||||||
|
let current_dir = env::current_dir().expect("Failed to get current directory");
|
||||||
|
let extraction_path = current_dir.join("champions").join(champion.name);
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
let _status = Command::new(&bat_path)
|
||||||
|
.arg(&champion.location)
|
||||||
|
.arg(&extraction_path)
|
||||||
|
.status().unwrap();
|
||||||
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
mod config_settings;
|
||||||
|
mod extractor;
|
||||||
|
|
||||||
|
use config_settings::*;
|
||||||
|
use extractor::*;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn greet(name: &str) -> String {
|
fn greet(name: &str) -> String {
|
||||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||||
@@ -9,7 +14,7 @@ fn greet(name: &str) -> String {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.invoke_handler(tauri::generate_handler![greet])
|
.invoke_handler(tauri::generate_handler![greet, init_config, load_config, write_config, extract_wad, load_champions])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,16 @@
|
|||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
"all": false,
|
"all": true,
|
||||||
"shell": {
|
"shell": {
|
||||||
"all": false,
|
"all": false,
|
||||||
"open": true
|
"open": true
|
||||||
|
},
|
||||||
|
"fs": {
|
||||||
|
"all": true
|
||||||
|
},
|
||||||
|
"window": {
|
||||||
|
"all": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"windows": [
|
"windows": [
|
||||||
|
|||||||
26
src/app.rs
26
src/app.rs
@@ -15,6 +15,8 @@ pub enum Route {
|
|||||||
#[at("/")]
|
#[at("/")]
|
||||||
Home,
|
Home,
|
||||||
#[at("/extract")]
|
#[at("/extract")]
|
||||||
|
ExtractRoot,
|
||||||
|
#[at("/extract/*")]
|
||||||
Extract,
|
Extract,
|
||||||
#[at("/settings")]
|
#[at("/settings")]
|
||||||
Settings,
|
Settings,
|
||||||
@@ -26,20 +28,32 @@ pub enum Route {
|
|||||||
|
|
||||||
#[function_component(App)]
|
#[function_component(App)]
|
||||||
pub fn app() -> Html {
|
pub fn app() -> Html {
|
||||||
|
let fallback = html! {<div class="content" >{"Loading..."}</div>};
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<nav::Nav/>
|
<nav::Nav/>
|
||||||
<Switch<Route> render={switch} />
|
<Suspense {fallback}>
|
||||||
|
<Switch<Route> render={switch} />
|
||||||
|
</Suspense>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn switch(routes: Route) -> Html {
|
fn switch(route: Route) -> Html {
|
||||||
match routes {
|
match route {
|
||||||
Route::Home => html! { <Home/> },
|
Route::Home => html! { <Home/> },
|
||||||
Route::Extract => html! { <Extract/> },
|
Route::ExtractRoot | Route::Extract => html! { <Switch<ExtractRoute> render={switch_extract}/> },
|
||||||
Route::Settings => html! { <Settings/> },
|
Route::Settings => html! { <Settings/> },
|
||||||
Route::NotFound => html! { <h1>{"404 Page Not Found"}</h1> },
|
Route::NotFound => html! { <NotFound/> },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[function_component(NotFound)]
|
||||||
|
pub fn not_found() -> Html {
|
||||||
|
html! {
|
||||||
|
<h2 class={"content"}>
|
||||||
|
{"Not Found"}
|
||||||
|
</h2>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,38 +1,30 @@
|
|||||||
use std::fs;
|
|
||||||
use rocket::config;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_wasm_bindgen::*;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, FromForm)]
|
#[derive(Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub cslol_dir: String,
|
pub cslol_dir: String,
|
||||||
pub wad_dir: String,
|
pub wad_dir: String,
|
||||||
pub extract_dir: String,
|
pub extract_dir: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_config() {
|
#[wasm_bindgen(module = "/public/glue.js")]
|
||||||
if fs::metadata("config.toml").is_err() {
|
extern "C" {
|
||||||
let config = Config {
|
#[wasm_bindgen(js_name = init_config_js, catch)]
|
||||||
cslol_dir: "".to_string(),
|
pub async fn init_config() -> Result<JsValue, JsValue>;
|
||||||
wad_dir: "C:\\Riot Games\\League of Legends\\Game\\DATA\\FINAL\\Champions".to_string(),
|
|
||||||
extract_dir: "".to_string(),
|
#[wasm_bindgen(js_name = write_config_js, catch)]
|
||||||
};
|
pub async fn write_config_js(config: JsValue) -> Result<JsValue, JsValue>;
|
||||||
write_config(&config);
|
|
||||||
}
|
#[wasm_bindgen(js_name = load_config_js, catch)]
|
||||||
|
pub async fn load_config_js() -> Result<JsValue, JsValue>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_config() -> Config {
|
pub async fn write_config(config: Config) -> Result<JsValue, JsValue> {
|
||||||
let config = fs::read_to_string("config.toml")
|
write_config_js(to_value(&config).unwrap()).await
|
||||||
.expect("Failed to read config.toml file");
|
|
||||||
|
|
||||||
toml::from_str(&config)
|
|
||||||
.expect("Failed to parse config.toml file")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_config(config: &Config) {
|
pub async fn load_config() -> Result<Config, Error> {
|
||||||
let config_content = toml::to_string(config)
|
from_value(load_config_js().await.unwrap())
|
||||||
.expect("Failed to serialize config");
|
|
||||||
|
|
||||||
fs::write("config.toml", config_content)
|
|
||||||
.expect("Failed to write to config.toml file");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +1,19 @@
|
|||||||
use std::process::Command;
|
use serde::{Deserialize, Serialize};
|
||||||
use std::env;
|
use serde_wasm_bindgen::*;
|
||||||
use std::fs;
|
use wasm_bindgen::prelude::*;
|
||||||
use walkdir::WalkDir;
|
|
||||||
use std::ffi::OsString;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use crate::config_settings;
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
pub struct Champion {
|
||||||
pub fn extract_wad() {
|
pub name: String,
|
||||||
let config = config_settings::load_config();
|
pub location: String,
|
||||||
let wad_files: Vec<OsString> = WalkDir::new(config.wad_dir)
|
}
|
||||||
.into_iter()
|
|
||||||
.filter_map(|entry| entry.ok())
|
#[wasm_bindgen(module = "/public/glue.js")]
|
||||||
.filter(|entry| {
|
extern "C" {
|
||||||
let path = entry.path();
|
#[wasm_bindgen(js_name = load_champions_js, catch)]
|
||||||
let file_name = path.file_name().and_then(|name| name.to_str()).unwrap_or("");
|
pub async fn load_champions_js() -> Result<JsValue, JsValue>;
|
||||||
let extension = path.extension().and_then(|ext| ext.to_str()).unwrap_or("");
|
}
|
||||||
extension == "client" &&
|
|
||||||
file_name.ends_with(".wad.client") &&
|
pub async fn load_champions() -> Result<Vec<Champion>, Error> {
|
||||||
file_name.split('.').count() == 3
|
from_value(load_champions_js().await.unwrap())
|
||||||
})
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,16 @@
|
|||||||
mod app;
|
mod app;
|
||||||
mod views;
|
mod views;
|
||||||
|
mod extractor;
|
||||||
|
mod config_settings;
|
||||||
|
|
||||||
use app::App;
|
use app::App;
|
||||||
|
use config_settings::init_config;
|
||||||
|
use yew::platform::spawn_local;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
yew::Renderer::<App>::new().render();
|
yew::Renderer::<App>::new().render();
|
||||||
|
spawn_local(async move {
|
||||||
|
let _ = init_config().await;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,76 @@
|
|||||||
use yew::prelude::*;
|
use wasm_bindgen::convert::IntoWasmAbi;
|
||||||
|
use yew::{prelude::*, suspense::use_future};
|
||||||
|
use yew_router::prelude::*;
|
||||||
|
use web_sys::{console, HtmlSelectElement};
|
||||||
|
|
||||||
#[function_component(Extract)]
|
use crate::{app::Route, extractor::load_champions};
|
||||||
pub fn extract() -> Html {
|
|
||||||
html! {
|
|
||||||
<div class="content">
|
|
||||||
<h2>{"Extract"}</h2>
|
|
||||||
<p>{"Exctract shit"}</p>
|
|
||||||
|
|
||||||
<form action="/extract-wads" method="post">
|
#[derive(Clone, Routable, PartialEq)]
|
||||||
<div class="option">
|
pub enum ExtractRoute {
|
||||||
<button type="submit">{"Extract WADs"}</button>
|
#[at("/extract")]
|
||||||
</div>
|
Extract,
|
||||||
</form>
|
#[at("/extract/skinselect")]
|
||||||
|
SkinSelect,
|
||||||
|
#[not_found]
|
||||||
|
#[at("/404")]
|
||||||
|
NotFound,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn switch_extract(route: ExtractRoute) -> Html {
|
||||||
|
match route {
|
||||||
|
ExtractRoute::Extract => html! { <Extract/> },
|
||||||
|
ExtractRoute::SkinSelect => html! { <SkinSelect/> },
|
||||||
|
ExtractRoute::NotFound => html!{ <Redirect<Route> to={Route::NotFound}/> },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[function_component(Extract)]
|
||||||
|
pub fn extract() -> HtmlResult {
|
||||||
|
|
||||||
|
let champions_future = use_future(|| async {load_champions().await})?;
|
||||||
|
|
||||||
|
let champions = champions_future.as_ref().unwrap().clone();
|
||||||
|
|
||||||
|
let champion_selected_handle = use_state(|| champions[0].name.clone());
|
||||||
|
let champion_selected = (*champion_selected_handle).clone();
|
||||||
|
|
||||||
|
let on_submit = {
|
||||||
|
let champion_selected_handle = champion_selected_handle.clone();
|
||||||
|
|
||||||
|
Callback::from(move |event: SubmitEvent| {
|
||||||
|
let champion_selected_event = event.target_unchecked_into::<web_sys::HtmlSelectElement>();
|
||||||
|
|
||||||
|
web_sys::console::log_1(&(*champion_selected_handle).clone().into());
|
||||||
|
champion_selected_handle.set(champion_selected_event.value());
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(
|
||||||
|
html! {
|
||||||
|
<div class="content">
|
||||||
|
<h2>{"Extract"}</h2>
|
||||||
|
<p>{"Exctract shit"}</p>
|
||||||
|
|
||||||
|
<div class="option">
|
||||||
|
<form id="champion" onsubmit={on_submit}>
|
||||||
|
<select id="champion">
|
||||||
|
{ for champions.iter().enumerate().map(|(index, champion)| html! {
|
||||||
|
<option value={champion.name.clone()} selected={champion.name == champion_selected}>{&champion.name}</option>
|
||||||
|
}) }
|
||||||
|
</select>
|
||||||
|
<br/>
|
||||||
|
<button type="submit">{"Select"} </button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[function_component(SkinSelect)]
|
||||||
|
pub fn skinselect() -> Html {
|
||||||
|
html! {
|
||||||
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ pub fn nav() -> Html {
|
|||||||
html! {
|
html! {
|
||||||
<div class="nav">
|
<div class="nav">
|
||||||
<Link<Route> to={Route::Home}>{"Home"}</Link<Route>>
|
<Link<Route> to={Route::Home}>{"Home"}</Link<Route>>
|
||||||
<Link<Route> to={Route::Extract}>{"Extract"}</Link<Route>>
|
<Link<Route> to={Route::ExtractRoot}>{"Extract"}</Link<Route>>
|
||||||
<Link<Route> to={Route::Settings}>{"Settings"}</Link<Route>>
|
<Link<Route> to={Route::Settings}>{"Settings"}</Link<Route>>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,70 @@
|
|||||||
|
use yew::suspense::use_future;
|
||||||
|
use crate::config_settings::*;
|
||||||
|
use wasm_bindgen_futures::spawn_local;
|
||||||
|
use web_sys::HtmlInputElement;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
|
|
||||||
#[function_component(Settings)]
|
#[function_component(Settings)]
|
||||||
pub fn settings() -> Html {
|
pub fn settings() -> HtmlResult {
|
||||||
|
let config_future = use_future(|| async {load_config().await})?;
|
||||||
|
|
||||||
|
let config = config_future.as_ref().unwrap().clone();
|
||||||
|
|
||||||
|
let cslol_dir_ref = use_node_ref();
|
||||||
|
let wad_dir_ref = use_node_ref();
|
||||||
|
let extract_dir_ref = use_node_ref();
|
||||||
|
|
||||||
|
let on_submit = {
|
||||||
|
let cslol_dir_ref = cslol_dir_ref.clone();
|
||||||
|
let wad_dir_ref = wad_dir_ref.clone();
|
||||||
|
let extract_dir_ref = extract_dir_ref.clone();
|
||||||
|
|
||||||
|
Callback::from(move |_event: SubmitEvent| {
|
||||||
|
let cslol_dir = cslol_dir_ref.cast::<HtmlInputElement>().unwrap().value();
|
||||||
|
let wad_dir = wad_dir_ref.cast::<HtmlInputElement>().unwrap().value();
|
||||||
|
let extract_dir = extract_dir_ref.cast::<HtmlInputElement>().unwrap().value();
|
||||||
|
|
||||||
|
let config = Config {
|
||||||
|
cslol_dir,
|
||||||
|
wad_dir,
|
||||||
|
extract_dir,
|
||||||
|
};
|
||||||
|
|
||||||
|
spawn_local(async move {
|
||||||
|
write_config(config).await.unwrap();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(
|
||||||
html! {
|
html! {
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h2>{"Settings"}</h2>
|
<h2>{"Settings"}</h2>
|
||||||
<form action="/write-settings" method="post">
|
|
||||||
<div class="option">
|
<div class="option">
|
||||||
<label for="cslol_dir">{"Location of CSLoL"}</label>
|
<form onsubmit={on_submit}>
|
||||||
<br/>
|
<div>
|
||||||
<input type="text" name="cslol_dir" id="cslol_dir" value="{{ config.cslol_dir }}"/>
|
<label for="cslol_dir">{"Location of CSLoL"}</label>
|
||||||
</div>
|
<br/>
|
||||||
|
<input id="cslol_dir" ref={cslol_dir_ref} value={config.cslol_dir.clone()}/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="option">
|
<div>
|
||||||
<label for="wad_dir">{"Custom location of Champion Wads"}</label>
|
<label for="wad_dir">{"Custom location of Champion Wads"}</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="text" name="wad_dir" id="wad_dir" value="{{ config.wad_dir }}"/>
|
<input id="wad_dir" ref={wad_dir_ref} value={config.wad_dir.clone()}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="option">
|
<div>
|
||||||
<label for="extract_dir">{"Custom location to Extract to"}</label>
|
<label for="extract_dir">{"Custom location to Extract to"}</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="text" name="extract_dir" id="extract_dir" value="{{ config.extract_dir }}"/>
|
<input id="extract_dir" ref={extract_dir_ref} value={config.extract_dir.clone()}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="option">
|
|
||||||
<button type="submit">{"Save Settings"}</button>
|
<button type="submit">{"Save Settings"}</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user