Skip to content

Commit

Permalink
Fix: compile without default features
Browse files Browse the repository at this point in the history
  • Loading branch information
ur-fault committed May 28, 2024
1 parent 546bb7f commit 5038d73
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion tmaze/examples/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ use tmaze::{
Activity, ActivityHandler,
},
ui::Popup,
updates::UpdateCheckerActivity,
};

#[cfg(feature = "updates")]
use tmaze::updates::UpdateCheckerActivity;

#[cfg(feature = "updates")]
fn main() {
let mut app = App::new(Activity::new_base(
"activity",
Expand All @@ -19,8 +22,15 @@ fn main() {
app.run();
}

#[cfg(not(feature = "updates"))]
fn main() {
panic!("Cannot run `updates` example without the `updates` feature");
}

#[cfg(feature = "updates")]
struct MyActivity(bool, Popup);

#[cfg(feature = "updates")]
impl ActivityHandler for MyActivity {
fn update(
&mut self,
Expand Down
4 changes: 3 additions & 1 deletion tmaze/src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::time::{Duration, Instant};
use cmaze::core::Dims;

use crossterm::event::{read, KeyCode, KeyEvent, KeyEventKind};
use rodio::Source;

use crate::{
data::SaveData,
Expand All @@ -15,6 +14,9 @@ use crate::{
#[cfg(feature = "sound")]
use crate::sound::{track::MusicTrack, SoundPlayer};

#[cfg(feature = "sound")]
use rodio::Source;

use super::{
activity::{Activities, Activity, ActivityResult, Change},
event::Event,
Expand Down
8 changes: 6 additions & 2 deletions tmaze/src/app/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::{
renderer::Frame,
settings::{CameraMode, ColorScheme, Offset, Settings},
ui::{self, draw_box, multisize_string, Menu, Popup, ProgressBar, Screen},
updates::UpdateCheckerActivity,
};

#[cfg(feature = "sound")]
Expand All @@ -26,7 +25,7 @@ use crate::sound::{track::MusicTrack, SoundPlayer};

#[cfg(feature = "updates")]
#[allow(unused_imports)]
use crate::updates;
use crate::updates::UpdateCheckerActivity;

use crossterm::event::{Event as TermEvent, KeyCode, KeyEvent};

Expand Down Expand Up @@ -66,6 +65,8 @@ pub fn create_controls_popup() -> Activity {

pub struct MainMenu {
menu: Menu,

#[cfg(feature = "updates")]
update_checked: bool,
}

Expand All @@ -89,6 +90,8 @@ impl MainMenu {
.box_style(color_scheme.normals())
.text_style(color_scheme.texts()),
),

#[cfg(feature = "updates")]
update_checked: false,
}
}
Expand Down Expand Up @@ -148,6 +151,7 @@ impl ActivityHandler for MainMenu {
#[cfg(feature = "sound")]
Self::play_menu_bgm(data);

#[cfg(feature = "updates")]
if !self.update_checked {
self.update_checked = true;
return Some(Change::push(Activity::new_base(
Expand Down

0 comments on commit 5038d73

Please sign in to comment.