app name and no terminal
This commit is contained in:
@@ -15,9 +15,9 @@ use iced_aw::widget::menu::Menu;
|
||||
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use crate::MyApp;
|
||||
use crate::Polymusic;
|
||||
|
||||
pub fn music_view(app: &MyApp) -> iced::Element<Message> {
|
||||
pub fn music_view(app: &Polymusic) -> iced::Element<Message> {
|
||||
let mut i = 0;
|
||||
let entries = app.all_sounds.clone();
|
||||
//Create all polygon options
|
||||
@@ -203,7 +203,7 @@ pub fn music_view(app: &MyApp) -> iced::Element<Message> {
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn load_file_view(app: &MyApp) -> iced::Element<Message> {
|
||||
pub fn load_file_view(app: &Polymusic) -> iced::Element<Message> {
|
||||
Container::new(
|
||||
column![
|
||||
text("Polymusic").size(42),
|
||||
|
||||
26
src/main.rs
26
src/main.rs
@@ -54,17 +54,19 @@ fn main() -> iced::Result {
|
||||
},
|
||||
)
|
||||
};
|
||||
iced::application("My App", MyApp::update, MyApp::view)
|
||||
#[cfg(windows)]
|
||||
hide_console_window();
|
||||
iced::application("Polymusic", Polymusic::update, Polymusic::view)
|
||||
.theme(move |_| polytheme.clone())
|
||||
.font(iced_fonts::REQUIRED_FONT_BYTES)
|
||||
.font(FONT_BYTES)
|
||||
.default_font(FONT)
|
||||
.antialiasing(true)
|
||||
.subscription(MyApp::subscription)
|
||||
.run_with(MyApp::new)
|
||||
.subscription(Polymusic::subscription)
|
||||
.run_with(Polymusic::new)
|
||||
}
|
||||
|
||||
struct MyApp {
|
||||
struct Polymusic {
|
||||
music: Music,
|
||||
time_last_frame: Instant,
|
||||
paused: bool,
|
||||
@@ -82,7 +84,7 @@ struct MyApp {
|
||||
historic: Historic,
|
||||
}
|
||||
|
||||
impl MyApp {
|
||||
impl Polymusic {
|
||||
fn new() -> (Self, Task<Message>) {
|
||||
let manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())
|
||||
.expect("Error to load AudioManager");
|
||||
@@ -474,3 +476,17 @@ fn load_path_saves() -> Vec<String> {
|
||||
saves.sort();
|
||||
saves
|
||||
}
|
||||
#[cfg(windows)]
|
||||
fn hide_console_window() {
|
||||
use std::ptr;
|
||||
use winapi::um::wincon::GetConsoleWindow;
|
||||
use winapi::um::winuser::{SW_HIDE, ShowWindow};
|
||||
|
||||
let window = unsafe { GetConsoleWindow() };
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow
|
||||
if window != ptr::null_mut() {
|
||||
unsafe {
|
||||
ShowWindow(window, SW_HIDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user