emulator: just saving my changes

This commit is contained in:
2025-06-17 19:19:49 +01:00
parent ae10249616
commit a6be668328
7 changed files with 247 additions and 2 deletions
+6
View File
@@ -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"]
+2
View File
@@ -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.
+2
View File
@@ -0,0 +1,2 @@
#[cfg(feature = "discord-rpc")]
pub mod rpc;
+56
View File
@@ -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)
}
+3
View File
@@ -1,2 +1,5 @@
#[cfg(feature = "config")]
pub mod config;
pub mod misc;
pub mod system;
pub mod ui;