emulator: just saving my changes
This commit is contained in:
@@ -14,3 +14,9 @@ eframe = "0.31.1"
|
||||
egui = "0.31.1"
|
||||
rfd = "0.15.3"
|
||||
dirs = "6.0.0"
|
||||
discord-presence = { version = "1.6.0", optional = true }
|
||||
toml = { version = "0.8.23", optional = true }
|
||||
|
||||
[features]
|
||||
discord-rpc = ["dep:discord-presence"]
|
||||
config = ["dep:toml"]
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
//! Loads configuration information from a TOML file in the current working directory.
|
||||
//! Currently doesn't do much but this may be expanded.
|
||||
@@ -0,0 +1,2 @@
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
pub mod rpc;
|
||||
@@ -0,0 +1,56 @@
|
||||
//! Just for fun I thought I would add a Discord RPC client to the emulator.
|
||||
//!
|
||||
//! This will display information like the current value of PCX, architecture name and
|
||||
//! GitHub repo links to show off the ISA. Perhaps in the future if we cross-compile to
|
||||
//! WASM we could include a link to run this software in the browser.
|
||||
//!
|
||||
//!
|
||||
//! # Configuration
|
||||
//!
|
||||
//! This may be disabled like so in your `.dsarc.toml` file:
|
||||
//!
|
||||
//! ```toml
|
||||
//! [misc]
|
||||
//! use_discord_rpc = false
|
||||
//! ```
|
||||
//!
|
||||
//! Alternatively, you can hide this in your Discord settings.
|
||||
|
||||
use discord_presence::{Client, DiscordError};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DiscordRpcError {
|
||||
Client(DiscordError),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DiscordRpcError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Client(why) => write!(f, "discord RPC error: {why}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for DiscordRpcError {}
|
||||
|
||||
impl From<DiscordError> for DiscordRpcError {
|
||||
fn from(err: DiscordError) -> Self {
|
||||
Self::Client(err)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets up the Discord RPC client.
|
||||
#[expect(clippy::unreadable_literal)]
|
||||
pub fn start_rpc() -> Result<Client, DiscordRpcError> {
|
||||
let mut client = discord_presence::Client::new(1384303074088190042);
|
||||
|
||||
_ = client.on_ready(|ctx| {
|
||||
eprintln!("The discord RPC client is ready. Got event {:?}", ctx.event);
|
||||
});
|
||||
|
||||
client.start();
|
||||
|
||||
client.set_activity(|act| act)?;
|
||||
|
||||
Ok(client)
|
||||
}
|
||||
@@ -1,2 +1,5 @@
|
||||
#[cfg(feature = "config")]
|
||||
pub mod config;
|
||||
pub mod misc;
|
||||
pub mod system;
|
||||
pub mod ui;
|
||||
|
||||
Reference in New Issue
Block a user