Merge remote-tracking branch 'origin/master' into develop
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
commit
d34d2ee2cc
|
@ -1,4 +1,9 @@
|
|||
pipeline:
|
||||
audit:
|
||||
image: dbrgn/cargo-audit
|
||||
commands:
|
||||
- cargo audit
|
||||
|
||||
build:
|
||||
image: sebastian/apt-decoder-ci
|
||||
commands:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "apt-decoder"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
authors = ["Sebastian <sebastian@sebastians-site.de>"]
|
||||
|
||||
[dependencies]
|
||||
|
@ -8,7 +8,7 @@ clap = {version = "3.1.8", features = ["cargo"]}
|
|||
indicatif = "0.16.2"
|
||||
hound = "3.4.0"
|
||||
image = "0.24.0"
|
||||
eframe = {version = "0.16.0", optional = true}
|
||||
eframe = {version = "0.18.0", optional = true}
|
||||
rfd = "0.7.0"
|
||||
thiserror = "1.0.30"
|
||||
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -76,18 +76,24 @@ fn main() {
|
|||
.value_of_os("wavfile")
|
||||
.expect("No input file given")
|
||||
.to_str()
|
||||
.unwrap();
|
||||
.unwrap()
|
||||
.to_string();
|
||||
let output_file = matches
|
||||
.value_of_os("pngfile")
|
||||
.expect("No output file given")
|
||||
.to_str()
|
||||
.unwrap();
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
if matches.is_present("nogui") {
|
||||
cli::decode(input_file, output_file);
|
||||
cli::decode(&input_file, &output_file);
|
||||
} else {
|
||||
let app = DecoderApp::new(input_file, output_file);
|
||||
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 eframe::egui;
|
||||
use eframe::egui::text_edit::TextEdit;
|
||||
use eframe::egui::widgets::{Button, ProgressBar};
|
||||
use eframe::egui::ColorImage;
|
||||
use eframe::egui::Visuals;
|
||||
use eframe::egui::{Color32, RichText};
|
||||
use eframe::{egui, epi};
|
||||
|
||||
use decoder;
|
||||
use errors::DecoderError;
|
||||
|
@ -18,7 +20,7 @@ enum DecoderRunState {
|
|||
struct DecoderJobState {
|
||||
update_steps: u32,
|
||||
progress: f32,
|
||||
texture: Option<egui::TextureId>,
|
||||
texture: Option<egui::TextureHandle>,
|
||||
run_state: DecoderRunState,
|
||||
error: Option<DecoderError>,
|
||||
}
|
||||
|
@ -57,23 +59,10 @@ impl DecoderApp {
|
|||
}
|
||||
}
|
||||
|
||||
impl epi::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>,
|
||||
) {
|
||||
}
|
||||
|
||||
impl eframe::App for DecoderApp {
|
||||
/// 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`.
|
||||
fn update(&mut self, ctx: &egui::CtxRef, frame: &epi::Frame) {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
let Self {
|
||||
input_path,
|
||||
output_path,
|
||||
|
@ -89,6 +78,7 @@ impl epi::App for DecoderApp {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.set_visuals(Visuals::dark());
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("APT-Decoder");
|
||||
|
||||
|
@ -130,16 +120,13 @@ impl epi::App for DecoderApp {
|
|||
.add_enabled(!state.is_running(), Button::new("Decode"))
|
||||
.clicked()
|
||||
{
|
||||
let frame = frame.clone();
|
||||
let ctx = ctx.clone();
|
||||
let decoding_state = decoding_state.clone();
|
||||
let input_path = input_path.clone();
|
||||
let output_path = output_path.clone();
|
||||
|
||||
state.error = None;
|
||||
state.run_state = DecoderRunState::RUNNING;
|
||||
if let Some(old_texture) = state.texture {
|
||||
frame.free_texture(old_texture);
|
||||
}
|
||||
state.texture = None;
|
||||
|
||||
std::thread::spawn(move || {
|
||||
|
@ -150,17 +137,15 @@ impl epi::App for DecoderApp {
|
|||
state.progress = progress;
|
||||
|
||||
let size = [image.width() as _, image.height() as _];
|
||||
let epi_img = epi::Image::from_rgba_unmultiplied(
|
||||
let color_img = ColorImage::from_rgba_unmultiplied(
|
||||
size,
|
||||
image.as_flat_samples().as_slice(),
|
||||
);
|
||||
|
||||
if let Some(old_texture) = state.texture {
|
||||
frame.free_texture(old_texture);
|
||||
}
|
||||
state.texture = Some(frame.alloc_texture(epi_img));
|
||||
state.texture =
|
||||
Some(ctx.load_texture("decoded-image", color_img));
|
||||
|
||||
frame.request_repaint();
|
||||
ctx.request_repaint();
|
||||
|
||||
return (state.is_running(), state.update_steps);
|
||||
});
|
||||
|
@ -172,7 +157,7 @@ impl epi::App for DecoderApp {
|
|||
_ => None,
|
||||
};
|
||||
|
||||
frame.request_repaint();
|
||||
ctx.request_repaint();
|
||||
});
|
||||
}
|
||||
if ui
|
||||
|
@ -199,7 +184,7 @@ impl epi::App for DecoderApp {
|
|||
let image_size = ui.available_size();
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue