omori locator
This commit is contained in:
parent
9f4ee0bf5b
commit
62a6b38b33
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
//"rust-analyzer.cargo.target": "x86_64-pc-windows-gnu"
|
||||||
|
}
|
4567
Cargo.lock
generated
4567
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,3 +4,12 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
egui = "0.31.1"
|
||||||
|
eframe = "0.31.1"
|
||||||
|
env_logger = "0.11.8"
|
||||||
|
anyhow = "1.0.97"
|
||||||
|
mundy = "0.1.8"
|
||||||
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
registry = "1.3.0"
|
||||||
|
dirs = "6.0.0"
|
||||||
|
keyvalues-parser = "0.2.0"
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
inherit system overlays;
|
inherit system overlays;
|
||||||
};
|
};
|
||||||
native-deps = with pkgs; [
|
native-deps = with pkgs; [
|
||||||
pkg-config pipewire lld clang libclang alsa-lib openssl taglib zlib
|
pkg-config pipewire lld clang libclang alsa-lib openssl taglib zlib libxkbcommon libGL wayland mangohud
|
||||||
|
pkgs.pkgsCross.mingwW64.buildPackages.gcc
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
with pkgs;
|
with pkgs;
|
||||||
@ -22,7 +23,7 @@
|
|||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
(rust-bin.stable.latest.default.override {
|
(rust-bin.stable.latest.default.override {
|
||||||
extensions = [ "rust-src" ];
|
extensions = [ "rust-src" ];
|
||||||
targets = ["x86_64-unknown-linux-gnu"];
|
targets = ["x86_64-unknown-linux-gnu" "x86_64-pc-windows-gnu"];
|
||||||
})
|
})
|
||||||
cargo-bloat
|
cargo-bloat
|
||||||
] ++ native-deps;
|
] ++ native-deps;
|
||||||
|
61
src/main.rs
61
src/main.rs
@ -1,3 +1,60 @@
|
|||||||
fn main() {
|
mod omori_locator;
|
||||||
println!("Hello, world!");
|
|
||||||
|
use std::{thread, time::Duration};
|
||||||
|
|
||||||
|
use eframe::egui;
|
||||||
|
use egui::{RichText, ThemePreference};
|
||||||
|
use omori_locator::get_omori_path;
|
||||||
|
|
||||||
|
fn main() -> anyhow::Result<()> {
|
||||||
|
env_logger::init();
|
||||||
|
|
||||||
|
let options = eframe::NativeOptions {
|
||||||
|
viewport: egui::ViewportBuilder::default()
|
||||||
|
.with_min_inner_size([640.0, 480.0]),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
println!("{:?}", get_omori_path().unwrap());
|
||||||
|
|
||||||
|
eframe::run_native("TundleBool", options, Box::new(|cc| {
|
||||||
|
cc.egui_ctx.set_theme(ThemePreference::System);
|
||||||
|
|
||||||
|
Ok(Box::<Application>::default())
|
||||||
|
})).unwrap();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct Application {
|
||||||
|
updates: u32
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Application {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
updates: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl eframe::App for Application {
|
||||||
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||||
|
ctx.request_repaint();
|
||||||
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
|
ui.vertical_centered(|ui| {
|
||||||
|
ui.label(RichText::new("Welcome to BundleTool").size(32.0));
|
||||||
|
ui.label(RichText::new(format!("{}", self.updates)).size(32.0));
|
||||||
|
});
|
||||||
|
self.updates += 1;
|
||||||
|
ui.separator();
|
||||||
|
egui::ScrollArea::vertical().max_width(300.0).auto_shrink(false).show(ui, |ui| {
|
||||||
|
for i in 1..3000 {
|
||||||
|
ui.add(egui::Label::new("Meow"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
79
src/omori_locator.rs
Normal file
79
src/omori_locator.rs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
use anyhow::Context;
|
||||||
|
use std::{fs::File, io::Read, path::PathBuf};
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
|
fn get_steam_root() -> anyhow::Result<PathBuf> {
|
||||||
|
let mut base = dirs::home_dir().with_context(|| "Couldn't figure out your home directory")?;
|
||||||
|
|
||||||
|
#[cfg(target_os="linux")]
|
||||||
|
base.push(".steam/root");
|
||||||
|
|
||||||
|
#[cfg(target_os="macos")]
|
||||||
|
base.push("Library/Application Support/Steam");
|
||||||
|
|
||||||
|
Ok(base)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn get_steam_root() -> anyhow::Result<PathBuf> {
|
||||||
|
use registry::{self, Security, Data};
|
||||||
|
|
||||||
|
let key = registry::Hive::LocalMachine.open(r"\SOFTWARE\Wow6432Node\Valve\Steam", Security::Read)?;
|
||||||
|
let value = match key.value("InstallPath")? {
|
||||||
|
Data::String(s) => Some(s.to_string_lossy()),
|
||||||
|
Data::ExpandString(s) => Some(s.to_string_lossy()),
|
||||||
|
_ => None
|
||||||
|
}.with_context(|| "Couldn't read the steam install path from registry")?;
|
||||||
|
|
||||||
|
let mut base = PathBuf::from(value);
|
||||||
|
|
||||||
|
Ok(base)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_omori_path() -> anyhow::Result<PathBuf> {
|
||||||
|
let mut base = get_steam_root()?;
|
||||||
|
|
||||||
|
base.push("steamapps/libraryfolders.vdf");
|
||||||
|
|
||||||
|
let mut buffer = Vec::new();
|
||||||
|
|
||||||
|
let mut fd = File::open(base)?;
|
||||||
|
fd.read_to_end(&mut buffer)?;
|
||||||
|
|
||||||
|
let data = String::from_utf8(buffer)?;
|
||||||
|
let data = keyvalues_parser::Vdf::parse(&data.as_str())?;
|
||||||
|
let data = data.value.get_obj().with_context(|| "Couldn't get the steam library libraryfolders object.")?;
|
||||||
|
let keys = data.keys();
|
||||||
|
|
||||||
|
let mut omori_path: Option<PathBuf> = None;
|
||||||
|
for key in keys {
|
||||||
|
println!("{:?}", key);
|
||||||
|
let entry = data.get(key).with_context(|| "Couldn't read specific steam library libraryfolders object.")?;
|
||||||
|
let entry = entry.get(0).with_context(|| "Couldn't read specific steam library libraryfolders object.")?;
|
||||||
|
let entry = entry.get_obj().with_context(|| "libraryfolders parsing failed: Not an object")?;
|
||||||
|
|
||||||
|
let apps = entry.get("apps").with_context(|| "libraryfolders parsing failed: No apps")?;
|
||||||
|
let apps = apps.get(0).with_context(|| "libraryfolders parsing failed: No apps")?;
|
||||||
|
let apps = apps.get_obj().with_context(|| "libraryfolders parsing failed: No apps")?;
|
||||||
|
let apps: Vec<_> = apps.keys().collect();
|
||||||
|
|
||||||
|
let path = entry.get("path").with_context(|| "libraryfolders parsing failed: No path")?;
|
||||||
|
let path = path.get(0).with_context(|| "libraryfolders parsing failed: No path")?;
|
||||||
|
let path = path.get_str().with_context(|| "libraryfolders parsing failed: No path")?;
|
||||||
|
|
||||||
|
if apps.iter().find(|x| (**x).eq("1150690")).is_some() {
|
||||||
|
let mut base = PathBuf::from(path);
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
base.push("steamapps/common/OMORI/www");
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
base.push("steamapps/common/OMORI/OMORI.app/Contents/Resources/app.nw");
|
||||||
|
|
||||||
|
omori_path = Some(base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
omori_path.with_context(|| "Failed to find omori")
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user