Updated eframe to fix cargo audit issues
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
1f8249dead
commit
a26ff950c1
|
@ -1,4 +1,9 @@
|
||||||
pipeline:
|
pipeline:
|
||||||
|
audit:
|
||||||
|
image: dbrgn/cargo-audit
|
||||||
|
commands:
|
||||||
|
- cargo audit
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: rust:bullseye
|
image: rust:bullseye
|
||||||
commands:
|
commands:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@ clap = {version = "3.1.8", features = ["cargo"]}
|
||||||
indicatif = "0.16.2"
|
indicatif = "0.16.2"
|
||||||
hound = "3.4.0"
|
hound = "3.4.0"
|
||||||
image = "0.24.0"
|
image = "0.24.0"
|
||||||
eframe = {version = "0.16.0", optional = true}
|
eframe = {version = "0.18.0", optional = true}
|
||||||
rfd = "0.7.0"
|
rfd = "0.7.0"
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
|
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -76,18 +76,24 @@ fn main() {
|
||||||
.value_of_os("wavfile")
|
.value_of_os("wavfile")
|
||||||
.expect("No input file given")
|
.expect("No input file given")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
.to_string();
|
||||||
let output_file = matches
|
let output_file = matches
|
||||||
.value_of_os("pngfile")
|
.value_of_os("pngfile")
|
||||||
.expect("No output file given")
|
.expect("No output file given")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
if matches.is_present("nogui") {
|
if matches.is_present("nogui") {
|
||||||
cli::decode(input_file, output_file);
|
cli::decode(&input_file, &output_file);
|
||||||
} else {
|
} else {
|
||||||
let app = DecoderApp::new(input_file, output_file);
|
|
||||||
let native_options = eframe::NativeOptions::default();
|
let native_options = eframe::NativeOptions::default();
|
||||||
eframe::run_native(Box::new(app), native_options);
|
|
||||||
|
eframe::run_native(
|
||||||
|
"APT-Decoder",
|
||||||
|
native_options,
|
||||||
|
Box::new(move |_cc| Box::new(DecoderApp::new(&input_file, &output_file))),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
43
src/ui.rs
43
src/ui.rs
|
@ -1,9 +1,11 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
use eframe::egui;
|
||||||
use eframe::egui::text_edit::TextEdit;
|
use eframe::egui::text_edit::TextEdit;
|
||||||
use eframe::egui::widgets::{Button, ProgressBar};
|
use eframe::egui::widgets::{Button, ProgressBar};
|
||||||
|
use eframe::egui::ColorImage;
|
||||||
|
use eframe::egui::Visuals;
|
||||||
use eframe::egui::{Color32, RichText};
|
use eframe::egui::{Color32, RichText};
|
||||||
use eframe::{egui, epi};
|
|
||||||
|
|
||||||
use decoder;
|
use decoder;
|
||||||
use errors::DecoderError;
|
use errors::DecoderError;
|
||||||
|
@ -18,7 +20,7 @@ enum DecoderRunState {
|
||||||
struct DecoderJobState {
|
struct DecoderJobState {
|
||||||
update_steps: u32,
|
update_steps: u32,
|
||||||
progress: f32,
|
progress: f32,
|
||||||
texture: Option<egui::TextureId>,
|
texture: Option<egui::TextureHandle>,
|
||||||
run_state: DecoderRunState,
|
run_state: DecoderRunState,
|
||||||
error: Option<DecoderError>,
|
error: Option<DecoderError>,
|
||||||
}
|
}
|
||||||
|
@ -57,23 +59,10 @@ impl DecoderApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl epi::App for DecoderApp {
|
impl eframe::App for DecoderApp {
|
||||||
fn name(&self) -> &str {
|
|
||||||
"APT Decoder"
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Called once before the first frame.
|
|
||||||
fn setup(
|
|
||||||
&mut self,
|
|
||||||
_ctx: &egui::CtxRef,
|
|
||||||
_frame: &epi::Frame,
|
|
||||||
_storage: Option<&dyn epi::Storage>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Called each time the UI needs repainting, which may be many times per second.
|
/// Called each time the UI needs repainting, which may be many times per second.
|
||||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||||
fn update(&mut self, ctx: &egui::CtxRef, frame: &epi::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
let Self {
|
let Self {
|
||||||
input_path,
|
input_path,
|
||||||
output_path,
|
output_path,
|
||||||
|
@ -89,6 +78,7 @@ impl epi::App for DecoderApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.set_visuals(Visuals::dark());
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.heading("APT-Decoder");
|
ui.heading("APT-Decoder");
|
||||||
|
|
||||||
|
@ -130,16 +120,13 @@ impl epi::App for DecoderApp {
|
||||||
.add_enabled(!state.is_running(), Button::new("Decode"))
|
.add_enabled(!state.is_running(), Button::new("Decode"))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
let frame = frame.clone();
|
let ctx = ctx.clone();
|
||||||
let decoding_state = decoding_state.clone();
|
let decoding_state = decoding_state.clone();
|
||||||
let input_path = input_path.clone();
|
let input_path = input_path.clone();
|
||||||
let output_path = output_path.clone();
|
let output_path = output_path.clone();
|
||||||
|
|
||||||
state.error = None;
|
state.error = None;
|
||||||
state.run_state = DecoderRunState::RUNNING;
|
state.run_state = DecoderRunState::RUNNING;
|
||||||
if let Some(old_texture) = state.texture {
|
|
||||||
frame.free_texture(old_texture);
|
|
||||||
}
|
|
||||||
state.texture = None;
|
state.texture = None;
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
|
@ -150,17 +137,15 @@ impl epi::App for DecoderApp {
|
||||||
state.progress = progress;
|
state.progress = progress;
|
||||||
|
|
||||||
let size = [image.width() as _, image.height() as _];
|
let size = [image.width() as _, image.height() as _];
|
||||||
let epi_img = epi::Image::from_rgba_unmultiplied(
|
let color_img = ColorImage::from_rgba_unmultiplied(
|
||||||
size,
|
size,
|
||||||
image.as_flat_samples().as_slice(),
|
image.as_flat_samples().as_slice(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(old_texture) = state.texture {
|
state.texture =
|
||||||
frame.free_texture(old_texture);
|
Some(ctx.load_texture("decoded-image", color_img));
|
||||||
}
|
|
||||||
state.texture = Some(frame.alloc_texture(epi_img));
|
|
||||||
|
|
||||||
frame.request_repaint();
|
ctx.request_repaint();
|
||||||
|
|
||||||
return (state.is_running(), state.update_steps);
|
return (state.is_running(), state.update_steps);
|
||||||
});
|
});
|
||||||
|
@ -172,7 +157,7 @@ impl epi::App for DecoderApp {
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
frame.request_repaint();
|
ctx.request_repaint();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ui
|
if ui
|
||||||
|
@ -199,7 +184,7 @@ impl epi::App for DecoderApp {
|
||||||
let image_size = ui.available_size();
|
let image_size = ui.available_size();
|
||||||
state.update_steps = image_size[1] as u32;
|
state.update_steps = image_size[1] as u32;
|
||||||
|
|
||||||
if let Some(texture) = state.texture {
|
if let Some(texture) = &state.texture {
|
||||||
ui.image(texture, image_size);
|
ui.image(texture, image_size);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue