emulator: cut down on cfg directives
This commit is contained in:
+1
-12
@@ -1,4 +1,3 @@
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
path::Path,
|
||||
@@ -6,7 +5,6 @@ use std::{
|
||||
thread,
|
||||
};
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
use dsa_rs::emulator::misc::rpc::{RpcClient, get_rpc_client_or_none};
|
||||
|
||||
use dsa_rs::emulator::{
|
||||
@@ -31,17 +29,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = Config::load(Path::new(".dsa.emulator.toml"))?;
|
||||
|
||||
// Setup RPC if enabled.
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
let (rpc_sender, rpc_reciever) = std::sync::mpsc::channel();
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
let rpc_client =
|
||||
get_rpc_client_or_none(&config, rpc_sender, rpc_reciever)?.map(Arc::new);
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
setup_emulator(cmd_receiver, state_sender, rpc_client);
|
||||
#[cfg(not(feature = "discord-rpc"))]
|
||||
setup_emulator(cmd_receiver, state_sender);
|
||||
|
||||
let ui = setup_ui(cmd_sender, state_reciever);
|
||||
|
||||
@@ -66,17 +59,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn setup_emulator(
|
||||
cmd_receiver: Receiver<Command>,
|
||||
state_sender: Sender<State>,
|
||||
#[cfg(feature = "discord-rpc")] rpc_client: Option<Arc<RpcClient>>,
|
||||
rpc_client: Option<Arc<RpcClient>>,
|
||||
) {
|
||||
let main_store = MainStore::new();
|
||||
let processor = Processor::new(Box::new(main_store), vec![]);
|
||||
|
||||
thread::spawn(move || {
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
run_emulator(&cmd_receiver, &state_sender, processor, rpc_client.as_ref());
|
||||
|
||||
#[cfg(not(feature = "discord-rpc"))]
|
||||
run_emulator(&cmd_receiver, &state_sender, processor);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user