11#![ windows_subsystem = "windows" ]
22
3+ use iced:: font:: { self , Font } ;
34use iced:: widget:: { Button , Column , Container , Row , Slider , Text } ;
45use iced:: {
56 alignment:: { Horizontal , Vertical } ,
@@ -26,12 +27,21 @@ extern crate dirs;
2627extern crate winapi;
2728
2829mod styling {
30+ pub mod _general_styles;
2931 pub mod button_styles;
3032 pub mod slider_styles;
3133}
34+ use styling:: _general_styles:: text_sizes;
3235use styling:: button_styles;
3336use styling:: slider_styles;
3437
38+ pub const MONOCRAFT : Font = Font {
39+ family : font:: Family :: Name ( "Monocraft" ) ,
40+ weight : font:: Weight :: Normal ,
41+ stretch : font:: Stretch :: Normal ,
42+ style : font:: Style :: Normal ,
43+ } ;
44+
3545#[ cfg( target_os = "windows" ) ]
3646use winapi:: um:: winuser:: { MessageBoxW , MB_ICONINFORMATION , MB_OK } ;
3747
@@ -118,6 +128,7 @@ enum Message {
118128 BackupCompleted ,
119129 BackupError ( String ) ,
120130 Tick ( Instant ) ,
131+ FontLoaded ( Result < ( ) , font:: Error > ) ,
121132}
122133
123134impl RustCraft {
@@ -176,7 +187,10 @@ impl Application for RustCraft {
176187 image_path : "assets/normal.png" . to_string ( ) ,
177188 ..Self :: default ( )
178189 } ,
179- Command :: none ( ) ,
190+ Command :: batch ( vec ! [ font:: load(
191+ include_bytes!( "../fonts/Monocraft.ttc" ) . as_slice( ) ,
192+ )
193+ . map( Message :: FontLoaded ) ] ) ,
180194 )
181195 }
182196
@@ -339,6 +353,8 @@ impl Application for RustCraft {
339353 println ! ( "Selected Backup directory: {:?}" , self . backup_directory) ;
340354 Command :: none ( )
341355 }
356+
357+ _ => Command :: none ( ) ,
342358 }
343359 }
344360
@@ -349,7 +365,7 @@ impl Application for RustCraft {
349365 "Start"
350366 } ;
351367
352- let mut start_button = Button :: new ( Text :: new ( start_button_text) )
368+ let mut start_button = Button :: new ( Text :: new ( start_button_text) . font ( MONOCRAFT ) )
353369 . padding ( 10 )
354370 . style ( button_styles:: MinecraftButton ) ;
355371
@@ -362,10 +378,14 @@ impl Application for RustCraft {
362378
363379 let control_buttons = Row :: new ( ) . spacing ( 10 ) . push ( start_button) ;
364380
365- let mut minecraft_dir_button = Button :: new ( Text :: new ( "Select Minecraft Directory" ) )
366- . padding ( 10 )
367- . width ( Length :: Fixed ( 250f32 ) )
368- . style ( button_styles:: MinecraftButton ) ;
381+ let mut minecraft_dir_button = Button :: new (
382+ Text :: new ( "Select Minecraft Directory" )
383+ . font ( MONOCRAFT )
384+ . size ( text_sizes:: PRIMARY ) ,
385+ )
386+ . padding ( 10 )
387+ . width ( Length :: Fixed ( 370f32 ) )
388+ . style ( button_styles:: MinecraftButton ) ;
369389
370390 if !self . active_schedule {
371391 minecraft_dir_button = minecraft_dir_button. on_press ( Message :: MinecraftDirPressed ) ;
@@ -377,12 +397,17 @@ impl Application for RustCraft {
377397 . unwrap_or ( & "No directory selected" . to_string ( ) )
378398 . clone ( ) ,
379399 )
380- . size ( 16 ) ;
400+ . font ( MONOCRAFT )
401+ . size ( text_sizes:: SECONDARY ) ;
381402
382- let mut backup_dir_button = Button :: new ( Text :: new ( "Select Backup Directory" ) )
383- . padding ( 10 )
384- . width ( Length :: Fixed ( 250f32 ) )
385- . style ( button_styles:: MinecraftButton ) ;
403+ let mut backup_dir_button = Button :: new (
404+ Text :: new ( "Select Backup Directory" )
405+ . font ( MONOCRAFT )
406+ . size ( text_sizes:: PRIMARY ) ,
407+ )
408+ . padding ( 10 )
409+ . width ( Length :: Fixed ( 370f32 ) )
410+ . style ( button_styles:: MinecraftButton ) ;
386411
387412 if !self . active_schedule {
388413 backup_dir_button = backup_dir_button. on_press ( Message :: BackupDirPressed ) ;
@@ -394,17 +419,22 @@ impl Application for RustCraft {
394419 . unwrap_or ( & "No directory selected" . to_string ( ) )
395420 . clone ( ) ,
396421 )
397- . size ( 16 ) ;
422+ . font ( MONOCRAFT )
423+ . size ( text_sizes:: SECONDARY ) ;
398424
399425 let schedule_slider = Slider :: new ( 0 ..=24 , self . schedule_hours , Message :: ScheduleChanged )
400426 . step ( 1 )
401427 . width ( Length :: Fixed ( 200f32 ) )
402428 . style ( slider_styles:: MinecraftSlider ) ;
403429
404430 let schedule_text = if self . schedule_hours == 0 {
405- Text :: new ( "Perform a one-time backup" ) . size ( 16 )
431+ Text :: new ( "Perform a one-time backup" )
432+ . font ( MONOCRAFT )
433+ . size ( text_sizes:: SECONDARY )
406434 } else {
407- Text :: new ( format ! ( "Schedule every {} hours" , self . schedule_hours) ) . size ( 16 )
435+ Text :: new ( format ! ( "Schedule every {} hours" , self . schedule_hours) )
436+ . font ( MONOCRAFT )
437+ . size ( text_sizes:: SECONDARY )
408438 } ;
409439
410440 let minecraft_dir_column = Column :: new ( )
@@ -425,17 +455,10 @@ impl Application for RustCraft {
425455 . padding ( 10 )
426456 . spacing ( 10 )
427457 . align_items ( Alignment :: Center )
428- . push ( Text :: new ( "Select Backup Frequency" ) )
458+ . push ( Text :: new ( "Select Backup Frequency" ) . font ( MONOCRAFT ) )
429459 . push ( schedule_slider)
430460 . push ( schedule_text) ;
431461
432- let image = Image :: new ( self . image_path . clone ( ) ) . width ( Length :: Fill ) ;
433-
434- let image_column = Column :: new ( )
435- . align_items ( Alignment :: Center )
436- . width ( Length :: FillPortion ( 1 ) )
437- . push ( image) ;
438-
439462 let timer_display: Element < Message > = if self . active_schedule {
440463 if let Some ( last_backup_time) = self . last_backup_time {
441464 let elapsed = last_backup_time. elapsed ( ) . as_secs ( ) ;
@@ -450,6 +473,7 @@ impl Application for RustCraft {
450473 . into ( )
451474 } else {
452475 Text :: new ( "Timer not initialized" )
476+ . font ( MONOCRAFT )
453477 . size ( 20 )
454478 . horizontal_alignment ( Horizontal :: Center )
455479 . vertical_alignment ( Vertical :: Center )
@@ -459,9 +483,17 @@ impl Application for RustCraft {
459483 Text :: new ( "" ) . into ( )
460484 } ;
461485
486+ let image = Image :: new ( self . image_path . clone ( ) ) . width ( Length :: Fill ) ;
487+
488+ let image_column = Column :: new ( )
489+ . align_items ( Alignment :: Center )
490+ . width ( Length :: FillPortion ( 1 ) )
491+ . push ( image) ;
492+
462493 let buttons_column = Column :: new ( )
463494 . align_items ( Alignment :: Center )
464495 . spacing ( 20 )
496+ . padding ( 20 )
465497 . push ( minecraft_dir_column)
466498 . push ( backup_dir_column)
467499 . push ( schedule_slider_column)
0 commit comments