app name and no terminal
This commit is contained in:
3
.cargo/config.toml
Normal file
3
.cargo/config.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
[target.x86_64-pc-windows-gnu]
|
||||
rustflags = ["-C", "link-args=-mwindows"]
|
||||
|
||||
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2845,6 +2845,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"smol_str 0.3.2",
|
||||
"tokio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
13
Cargo.toml
13
Cargo.toml
@@ -14,8 +14,13 @@ regex = "1.11.1"
|
||||
iced_aw = {version = "0.12.2", default-features = true}
|
||||
iced_fonts = "0.2.1"
|
||||
smol_str = "0.3.2"
|
||||
winapi = {version = "0.3", features = ["wincon", "winuser"]}
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3 # optimisation maximale (0 à 3)
|
||||
lto = true # Link Time Optimization, optimise le binaire final
|
||||
codegen-units = 1 # pour meilleure optimisation (par défaut c'est plus pour vitesse de compilation)
|
||||
panic = 'abort' # pour binaire plus petit et rapide, abandonne unwind
|
||||
opt-level = 3
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
panic = 'abort'
|
||||
|
||||
|
||||
|
||||
|
||||
6
build.rs
6
build.rs
@@ -22,6 +22,12 @@ fn main() {
|
||||
let _ = fs::remove_dir_all(target_dir.join("fonts"));
|
||||
fs::create_dir_all(target_dir.join("fonts")).unwrap();
|
||||
copy_dir("fonts", target_dir.join("fonts"));
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let mut res = winres::WindowsResource::new();
|
||||
res.set("SubSystem", "Windows");
|
||||
res.compile().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_dir(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
|
||||
|
||||
@@ -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