first commit
This commit is contained in:
45
src/app.rs
Normal file
45
src/app.rs
Normal file
@@ -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! {
|
||||
<BrowserRouter>
|
||||
<nav::Nav/>
|
||||
<Switch<Route> render={switch} />
|
||||
</BrowserRouter>
|
||||
}
|
||||
}
|
||||
|
||||
fn switch(routes: Route) -> Html {
|
||||
match routes {
|
||||
Route::Home => html! { <Home/> },
|
||||
Route::Extract => html! { <Extract/> },
|
||||
Route::Settings => html! { <Settings/> },
|
||||
Route::NotFound => html! { <h1>{"404 Page Not Found"}</h1> },
|
||||
}
|
||||
}
|
||||
|
||||
38
src/config_settings.rs
Normal file
38
src/config_settings.rs
Normal file
@@ -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");
|
||||
}
|
||||
|
||||
56
src/extractor.rs
Normal file
56
src/extractor.rs
Normal file
@@ -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<OsString> = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/main.rs
Normal file
10
src/main.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
mod app;
|
||||
mod views;
|
||||
|
||||
use app::App;
|
||||
|
||||
|
||||
fn main() {
|
||||
console_error_panic_hook::set_once();
|
||||
yew::Renderer::<App>::new().render();
|
||||
}
|
||||
18
src/views/extract.rs
Normal file
18
src/views/extract.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(Extract)]
|
||||
pub fn extract() -> Html {
|
||||
html! {
|
||||
<div class="content">
|
||||
<h2>{"Extract"}</h2>
|
||||
<p>{"Exctract shit"}</p>
|
||||
|
||||
<form action="/extract-wads" method="post">
|
||||
<div class="option">
|
||||
<button type="submit">{"Extract WADs"}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
}
|
||||
}
|
||||
11
src/views/home.rs
Normal file
11
src/views/home.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(Home)]
|
||||
pub fn home() -> Html {
|
||||
html! {
|
||||
<div class="content">
|
||||
<h2>{"Home Page"}</h2>
|
||||
<p>{"Welcome to the Home page!"}</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
8
src/views/mod.rs
Normal file
8
src/views/mod.rs
Normal file
@@ -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::*;
|
||||
14
src/views/nav.rs
Normal file
14
src/views/nav.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use yew::prelude::*;
|
||||
use yew_router::prelude::*;
|
||||
use crate::app::Route;
|
||||
|
||||
#[function_component(Nav)]
|
||||
pub fn nav() -> Html {
|
||||
html! {
|
||||
<div class="nav">
|
||||
<Link<Route> to={Route::Home}>{"Home"}</Link<Route>>
|
||||
<Link<Route> to={Route::Extract}>{"Extract"}</Link<Route>>
|
||||
<Link<Route> to={Route::Settings}>{"Settings"}</Link<Route>>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
34
src/views/settings.rs
Normal file
34
src/views/settings.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use yew::prelude::*;
|
||||
|
||||
|
||||
#[function_component(Settings)]
|
||||
pub fn settings() -> Html {
|
||||
html! {
|
||||
<div class="content">
|
||||
<h2>{"Settings"}</h2>
|
||||
<form action="/write-settings" method="post">
|
||||
<div class="option">
|
||||
<label for="cslol_dir">{"Location of CSLoL"}</label>
|
||||
<br/>
|
||||
<input type="text" name="cslol_dir" id="cslol_dir" value="{{ config.cslol_dir }}"/>
|
||||
</div>
|
||||
|
||||
<div class="option">
|
||||
<label for="wad_dir">{"Custom location of Champion Wads"}</label>
|
||||
<br/>
|
||||
<input type="text" name="wad_dir" id="wad_dir" value="{{ config.wad_dir }}"/>
|
||||
</div>
|
||||
|
||||
<div class="option">
|
||||
<label for="extract_dir">{"Custom location to Extract to"}</label>
|
||||
<br/>
|
||||
<input type="text" name="extract_dir" id="extract_dir" value="{{ config.extract_dir }}"/>
|
||||
</div>
|
||||
|
||||
<div class="option">
|
||||
<button type="submit">{"Save Settings"}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user