1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use raylib::prelude::*;

use crate::{discord::{DiscordChannel, DiscordRpcSignal}, project_constants::ProjectConstants};

#[derive(Debug)]
pub struct SmFailureScreen {
    has_updated_discord_status: bool,
}

impl SmFailureScreen {
    /// Construct a new `SmFailureScreen`
    pub fn new() -> Self {
        Self {
            has_updated_discord_status: false,
        }
    }

    pub async fn render(
        &mut self,
        raylib: &mut RaylibHandle,
        rl_thread: &RaylibThread,
        discord: &DiscordChannel,
        constants: &ProjectConstants,
    ) -> bool {
        // Handle updating the Discord status
        if !self.has_updated_discord_status {
            discord
                .send(DiscordRpcSignal::ChangeDetails {
                    details: constants
                        .discord
                        .strings
                        .get("details.sm_failure")
                        .unwrap()
                        .to_owned(),
                    party_status: None,
                })
                .await
                .unwrap();
            self.has_updated_discord_status = true;
        }

        // Render the error message
        let mut d = raylib.begin_drawing(&rl_thread);
        d.clear_background(raylib::color::Color::RED);
        d.draw_text(
            "Backend Rendering Broke.\nYou should not be seeing this!",
            10,
            10,
            40,
            raylib::color::Color::WHITE,
        );

        false
    }
}