working on gd.rs and ui and stuff

main
aprzn 2 years ago
parent 8d81adcf0a
commit 5af1552635

18
Cargo.lock generated

@ -114,6 +114,12 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270"
[[package]]
name = "base64"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
[[package]] [[package]]
name = "bindgen" name = "bindgen"
version = "0.61.0" version = "0.61.0"
@ -1018,8 +1024,11 @@ dependencies = [
name = "guider" name = "guider"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"base64",
"flate2",
"home", "home",
"iced", "iced",
"quick-xml",
"rodio", "rodio",
] ]
@ -1943,6 +1952,15 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74605f360ce573babfe43964cbe520294dcb081afbf8c108fc6e23036b4da2df" checksum = "74605f360ce573babfe43964cbe520294dcb081afbf8c108fc6e23036b4da2df"
[[package]]
name = "quick-xml"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc053f057dd768a56f62cd7e434c42c831d296968997e9ac1f76ea7c2d14c41"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.23" version = "1.0.23"

@ -9,3 +9,6 @@ edition = "2021"
iced = {version = "0.7.0"} iced = {version = "0.7.0"}
rodio = {version = "0.16.0"} rodio = {version = "0.16.0"}
home = {version = "0.5.4"} home = {version = "0.5.4"}
base64 = {version = "0.21.0"}
flate2 = {version = "1.0.25"}
quick-xml = {version = "0.27.1"}

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

@ -0,0 +1,61 @@
use std::path::PathBuf;
use std::fs::File;
use std::io::Read;
use base64::engine::{general_purpose::URL_SAFE, Engine};
use flate2::read::GzDecoder;
use quick_xml::Reader;
struct User {
name: String,
id: Option<u64>,
}
struct InnerLevel; // TODO: write this
type Difficulty = u8;
enum Song {
Official{id: i32 /*k8*/},
Newgrounds{id: i32 /*k45*/},
}
struct Level {
name: String, // k2
song: Song,
}
pub fn gd_path() -> PathBuf {
let mut path_buf = home::home_dir().unwrap();
#[cfg(unix)]
path_buf.extend([".local", "share", "Steam", "steamapps",
"compatdata", "322170", "pfx", "drive_c",
"users", "steamuser", "AppData", "Local",
"GeometryDash"].iter());
#[cfg(windows)]
path_buf.extend(["AppData", "Local", "GeometryDash"].iter());
path_buf
}
fn load_levels() -> Vec<Level> {
let raw_save_data = {
let mut save_file = File::open(gd_path().join("CCLocalLevels.dat")).expect("No save file found!");
let mut sd = Vec::new();
save_file.read_to_end(&mut sd);
sd
};
let data_post_xor: Vec<u8> = raw_save_data.iter().map(|b| b ^ 11).collect();
let data_post_b64 = URL_SAFE.decode(data_post_xor).unwrap();
let plist = {
let mut decoder = GzDecoder::<&[u8]>::new(data_post_b64.as_ref());
let mut plist = String::new();
if let Err(_) = decoder.read_to_string(&mut plist) {
println!("Warning: Game save likely corrupted (gzip decode failed)");
}
plist
};
let reader = Reader::from_str(plist.as_ref());
let mut out = vec![];
loop {
break out;
}
}

@ -1,5 +1,15 @@
mod gd;
use iced::{ use iced::{
widget::{button, column, text}, widget::{
button,
column,
row,
text,
scrollable,
radio::Radio,
Column
},
Sandbox, Sandbox,
Settings, Settings,
Element, Element,
@ -16,19 +26,7 @@ use std::{
io::BufReader, io::BufReader,
path::PathBuf, path::PathBuf,
}; };
use gd::gd_path;
fn gd_path() -> PathBuf {
let mut path_buf = home::home_dir().unwrap();
#[cfg(unix)]
path_buf.extend([".local", "share", "Steam", "steamapps",
"compatdata", "322170", "pfx", "drive_c",
"users", "steamuser", "AppData", "Local",
"GeometryDash"].iter());
#[cfg(windows)]
path_buf.extend(["AppData", "Local", "GeometryDash"].iter());
path_buf
}
struct Guider { struct Guider {
@ -47,7 +45,6 @@ impl Sandbox for Guider {
let gd_path = gd_path(); let gd_path = gd_path();
let (_stream, stream_handle) = OutputStream::try_default().unwrap(); let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap(); let sink = Sink::try_new(&stream_handle).unwrap();
println!("{:?}", gd_path.as_os_str());
let music_file = BufReader::new(File::open(gd_path.join("613929.mp3")).unwrap()); let music_file = BufReader::new(File::open(gd_path.join("613929.mp3")).unwrap());
let source = Decoder::new(music_file).unwrap(); let source = Decoder::new(music_file).unwrap();
//sink.append(source); //sink.append(source);
@ -56,7 +53,24 @@ impl Sandbox for Guider {
} }
fn view(&self) -> Element<Message> { fn view(&self) -> Element<Message> {
column![button("pause").on_press(Message::Pause), button("play").on_press(Message::Play)].into() // column![button("pause").on_press(Message::Pause), button("play").on_press(Message::Play)].into()
row![
scrollable(["lvl 1", "lvl 2", "lvl 3"].iter().fold(
Column::new(), |col, item| col.push(button(*item).on_press(Message::Pause))
)),
column![
row![
column![text("Title"), text("Song Title & ID")],
column![
text("G"),
text("Y"),
text("O"),
]
],
row![text("zoom in"), text("zoom out"), text("delete"), text("add"), text("edit")],
text("view canvas"),
]
].into()
} }
fn update(&mut self, message: Message) { fn update(&mut self, message: Message) {

Loading…
Cancel
Save