Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe766efcdc | ||
|
|
acb8856dd0 | ||
|
|
e2c25cbae5 | ||
|
|
7d517e932e |
Generated
+540
-480
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -4,24 +4,24 @@ description = "An emulator for the Virtual Boy."
|
|||||||
repository = "https://git.virtual-boy.com/PVB/lemur"
|
repository = "https://git.virtual-boy.com/PVB/lemur"
|
||||||
publish = false
|
publish = false
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.15.0"
|
version = "0.15.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
atoi = "3"
|
atoi = "3"
|
||||||
audioadapter-buffers = "4"
|
audioadapter-buffers = "5"
|
||||||
atomic = "0.6"
|
atomic = "0.6"
|
||||||
bitflags = { version = "2", features = ["serde"] }
|
bitflags = { version = "2", features = ["serde"] }
|
||||||
bytemuck = { version = "1", features = ["derive"] }
|
bytemuck = { version = "1", features = ["derive"] }
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
cpal = "0.18"
|
cpal = "0.18"
|
||||||
directories = "6"
|
directories = "6"
|
||||||
egui = { version = "0.34", features = ["persistence", "serde"] }
|
egui = { version = "0.36", features = ["persistence", "serde"] }
|
||||||
egui_extras = { version = "0.34", features = ["image"] }
|
egui_extras = { version = "0.36", features = ["image"] }
|
||||||
egui-notify = "0.22"
|
egui-notify = "0.23"
|
||||||
egui-winit = "0.34"
|
egui-winit = "0.36"
|
||||||
egui-wgpu = { version = "0.34", features = ["winit"] }
|
egui-wgpu = { version = "0.36", features = ["winit"] }
|
||||||
fxprof-processed-profile = "0.8"
|
fxprof-processed-profile = "0.8"
|
||||||
fixed = { version = "1.28", features = ["num-traits"] }
|
fixed = { version = "1.28", features = ["num-traits"] }
|
||||||
gilrs = { version = "0.11", features = ["serde-serialize"] }
|
gilrs = { version = "0.11", features = ["serde-serialize"] }
|
||||||
@@ -31,22 +31,22 @@ image = { version = "0.25", default-features = false, features = ["png"] }
|
|||||||
itertools = "0.15"
|
itertools = "0.15"
|
||||||
normpath = "1"
|
normpath = "1"
|
||||||
notify = "8"
|
notify = "8"
|
||||||
num-derive = "0.4"
|
num-derive = "0.5"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
object = "0.39"
|
object = "0.40"
|
||||||
oneshot = { version = "0.2", features = ["async", "std"] }
|
oneshot = { version = "0.2", features = ["async", "std"] }
|
||||||
pollster = "1"
|
pollster = "1"
|
||||||
rand = "0.10"
|
rand = "0.10"
|
||||||
rfd = "0.17"
|
rfd = "0.17"
|
||||||
rtrb = "0.3"
|
rtrb = "0.4"
|
||||||
rubato = "4"
|
rubato = "5"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
thread-priority = "3"
|
thread-priority = "3"
|
||||||
tokio = { version = "1", features = ["io-util", "macros", "net", "rt", "sync", "time"] }
|
tokio = { version = "1", features = ["io-util", "macros", "net", "rt", "sync", "time"] }
|
||||||
tracing = { version = "0.1", features = ["release_max_level_debug"] }
|
tracing = { version = "0.1", features = ["release_max_level_debug"] }
|
||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
wgpu = { version = "29", features = ["serde"] }
|
wgpu = { version = "30", features = ["serde"] }
|
||||||
wholesym = "0.8"
|
wholesym = "0.8"
|
||||||
winit = { version = "0.30", features = ["serde"] }
|
winit = { version = "0.30", features = ["serde"] }
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ RUN apt-get update && \
|
|||||||
ln -s $(which ld64.lld-22) /usr/bin/ld64.lld && \
|
ln -s $(which ld64.lld-22) /usr/bin/ld64.lld && \
|
||||||
SDK_VERSION=14.5 UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 TARGET_DIR=/osxcross ./build.sh
|
SDK_VERSION=14.5 UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 TARGET_DIR=/osxcross ./build.sh
|
||||||
|
|
||||||
FROM rust:1.97-trixie
|
FROM rust:1.98-trixie
|
||||||
ADD --chmod=644 "https://apt.llvm.org/llvm-snapshot.gpg.key" /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
ADD --chmod=644 "https://apt.llvm.org/llvm-snapshot.gpg.key" /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
||||||
COPY llvm.sources /etc/apt/sources.list.d/llvm.sources
|
COPY llvm.sources /etc/apt/sources.list.d/llvm.sources
|
||||||
RUN rustup target add x86_64-pc-windows-msvc && \
|
RUN rustup target add x86_64-pc-windows-msvc && \
|
||||||
|
|||||||
+6
-4
@@ -26,10 +26,10 @@ use crate::{
|
|||||||
config::{AppConfig, CliArgs},
|
config::{AppConfig, CliArgs},
|
||||||
controller::ControllerManager,
|
controller::ControllerManager,
|
||||||
emulator::{EmulatorClient, EmulatorCommand, SimId},
|
emulator::{EmulatorClient, EmulatorCommand, SimId},
|
||||||
|
filesystem::Persistence,
|
||||||
images::ImageTextureLoader,
|
images::ImageTextureLoader,
|
||||||
input::{MappingProvider, ShortcutProvider},
|
input::{MappingProvider, ShortcutProvider},
|
||||||
memory::MemoryClient,
|
memory::MemoryClient,
|
||||||
persistence::Persistence,
|
|
||||||
window::{AppWindow, ChildWindow, GameScreen, GameWindow, InitArgs},
|
window::{AppWindow, ChildWindow, GameScreen, GameWindow, InitArgs},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ impl SharedViewportState {
|
|||||||
fn init_painter(&mut self, ctx: &Context, window: &Window) -> &mut Painter {
|
fn init_painter(&mut self, ctx: &Context, window: &Window) -> &mut Painter {
|
||||||
if self.painter.is_none() {
|
if self.painter.is_none() {
|
||||||
let wgpu_config = egui_wgpu::WgpuConfiguration {
|
let wgpu_config = egui_wgpu::WgpuConfiguration {
|
||||||
present_mode: wgpu::PresentMode::AutoVsync,
|
surface: egui_wgpu::SurfaceConfig::HIGH_THROUGHPUT,
|
||||||
wgpu_setup: egui_wgpu::WgpuSetup::Existing(self.wgpu.init(window)),
|
wgpu_setup: egui_wgpu::WgpuSetup::Existing(self.wgpu.init(window)),
|
||||||
..egui_wgpu::WgpuConfiguration::default()
|
..egui_wgpu::WgpuConfiguration::default()
|
||||||
};
|
};
|
||||||
@@ -257,7 +257,7 @@ impl Application {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
input.viewports = self.shared.viewport_info.clone();
|
input.viewports = self.shared.viewport_info.clone();
|
||||||
let output = self.ctx.run_ui(input, |ui| {
|
let mut output = self.ctx.run_ui(input, |ui| {
|
||||||
if viewport.id == ViewportId::ROOT {
|
if viewport.id == ViewportId::ROOT {
|
||||||
self.app.show(ui);
|
self.app.show(ui);
|
||||||
} else if let Some(cb) = ui.viewport(|v| v.viewport_ui_cb.clone()) {
|
} else if let Some(cb) = ui.viewport(|v| v.viewport_ui_cb.clone()) {
|
||||||
@@ -304,8 +304,9 @@ impl Application {
|
|||||||
output.pixels_per_point,
|
output.pixels_per_point,
|
||||||
[0.0, 0.0, 0.0, 0.0],
|
[0.0, 0.0, 0.0, 0.0],
|
||||||
&clipped_primitives,
|
&clipped_primitives,
|
||||||
&output.textures_delta,
|
&mut output.textures_delta,
|
||||||
vec![],
|
vec![],
|
||||||
|
&viewport.window,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let mut active_viewports = ViewportIdSet::default();
|
let mut active_viewports = ViewportIdSet::default();
|
||||||
@@ -550,6 +551,7 @@ impl WgpuState {
|
|||||||
power_preference,
|
power_preference,
|
||||||
compatible_surface: Some(&surface),
|
compatible_surface: Some(&surface),
|
||||||
force_fallback_adapter,
|
force_fallback_adapter,
|
||||||
|
apply_limit_buckets: false,
|
||||||
}))
|
}))
|
||||||
.expect("could not create adapter");
|
.expect("could not create adapter");
|
||||||
debug!("selected adapter: {:?}", adapter.get_info());
|
debug!("selected adapter: {:?}", adapter.get_info());
|
||||||
|
|||||||
+25
-1
@@ -1,9 +1,10 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use bytemuck::NoUninit;
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::{Parser, ValueEnum};
|
||||||
use egui::{Color32, Pos2, Vec2};
|
use egui::{Color32, Pos2, Vec2};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{emulator::SimId, persistence::Persistence, window::DisplayMode};
|
use crate::{emulator::SimId, filesystem::Persistence, window::DisplayMode};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
@@ -53,6 +54,9 @@ pub struct CliArgs {
|
|||||||
/// Set a preference for whether to use a low-power or high-performance GPU adapter
|
/// Set a preference for whether to use a low-power or high-performance GPU adapter
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub wgpu_power_preference: Option<PowerPreferenceWrapper>,
|
pub wgpu_power_preference: Option<PowerPreferenceWrapper>,
|
||||||
|
/// Choose whether save files are kept in the rom or the data directory
|
||||||
|
#[arg(long)]
|
||||||
|
pub save_data_location: Option<SaveDataLocation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ValueEnum, Clone, Copy)]
|
#[derive(ValueEnum, Clone, Copy)]
|
||||||
@@ -90,12 +94,27 @@ const fn default_power_preference() -> wgpu::PowerPreference {
|
|||||||
wgpu::PowerPreference::LowPower
|
wgpu::PowerPreference::LowPower
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, ValueEnum, Debug, NoUninit)]
|
||||||
|
#[repr(usize)]
|
||||||
|
pub enum SaveDataLocation {
|
||||||
|
/// The same directory as the ROM
|
||||||
|
RomDirectory,
|
||||||
|
/// This application's data directory
|
||||||
|
DataDirectory,
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn default_save_data_location() -> SaveDataLocation {
|
||||||
|
SaveDataLocation::RomDirectory
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||||
pub struct AppConfig {
|
pub struct AppConfig {
|
||||||
#[serde(default = "default_power_preference")]
|
#[serde(default = "default_power_preference")]
|
||||||
pub power_preference: wgpu::PowerPreference,
|
pub power_preference: wgpu::PowerPreference,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub force_fallback: bool,
|
pub force_fallback: bool,
|
||||||
|
#[serde(default = "default_save_data_location")]
|
||||||
|
pub save_data_location: SaveDataLocation,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppConfig {
|
impl AppConfig {
|
||||||
@@ -106,6 +125,7 @@ impl AppConfig {
|
|||||||
Self {
|
Self {
|
||||||
power_preference: default_power_preference(),
|
power_preference: default_power_preference(),
|
||||||
force_fallback: false,
|
force_fallback: false,
|
||||||
|
save_data_location: default_save_data_location(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +143,10 @@ impl AppConfig {
|
|||||||
self.force_fallback = force_fallback;
|
self.force_fallback = force_fallback;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
|
if let Some(save_data_location) = args.save_data_location {
|
||||||
|
self.save_data_location = save_data_location;
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
updated
|
updated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+72
-44
@@ -18,6 +18,7 @@ use tracing::{error, warn};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
audio::Audio,
|
audio::Audio,
|
||||||
|
config::SaveDataLocation,
|
||||||
graphics::TextureSink,
|
graphics::TextureSink,
|
||||||
memory::{MemoryRange, MemoryRegion},
|
memory::{MemoryRange, MemoryRegion},
|
||||||
};
|
};
|
||||||
@@ -74,12 +75,13 @@ pub struct EmulatorBuilder {
|
|||||||
state: Arc<Atomic<EmulatorState>>,
|
state: Arc<Atomic<EmulatorState>>,
|
||||||
audio_on: Arc<[AtomicBool; 2]>,
|
audio_on: Arc<[AtomicBool; 2]>,
|
||||||
linked: Arc<AtomicBool>,
|
linked: Arc<AtomicBool>,
|
||||||
|
save_data_location: Arc<Atomic<SaveDataLocation>>,
|
||||||
start_paused: bool,
|
start_paused: bool,
|
||||||
watch_rom: Arc<[AtomicBool; 2]>,
|
watch_rom: Arc<[AtomicBool; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmulatorBuilder {
|
impl EmulatorBuilder {
|
||||||
pub fn new() -> (Self, EmulatorClient) {
|
pub fn new(save_data_location: SaveDataLocation) -> (Self, EmulatorClient) {
|
||||||
let (queue, commands) = mpsc::channel();
|
let (queue, commands) = mpsc::channel();
|
||||||
let builder = Self {
|
let builder = Self {
|
||||||
rom: None,
|
rom: None,
|
||||||
@@ -91,6 +93,7 @@ impl EmulatorBuilder {
|
|||||||
state: Arc::new(Atomic::new(EmulatorState::Paused)),
|
state: Arc::new(Atomic::new(EmulatorState::Paused)),
|
||||||
audio_on: Arc::new([AtomicBool::new(true), AtomicBool::new(true)]),
|
audio_on: Arc::new([AtomicBool::new(true), AtomicBool::new(true)]),
|
||||||
linked: Arc::new(AtomicBool::new(false)),
|
linked: Arc::new(AtomicBool::new(false)),
|
||||||
|
save_data_location: Arc::new(Atomic::new(save_data_location)),
|
||||||
start_paused: false,
|
start_paused: false,
|
||||||
watch_rom: Arc::new([AtomicBool::new(false), AtomicBool::new(false)]),
|
watch_rom: Arc::new([AtomicBool::new(false), AtomicBool::new(false)]),
|
||||||
};
|
};
|
||||||
@@ -98,8 +101,9 @@ impl EmulatorBuilder {
|
|||||||
queue,
|
queue,
|
||||||
sim_state: builder.sim_state.clone(),
|
sim_state: builder.sim_state.clone(),
|
||||||
state: builder.state.clone(),
|
state: builder.state.clone(),
|
||||||
watch_rom: builder.watch_rom.clone(),
|
|
||||||
linked: builder.linked.clone(),
|
linked: builder.linked.clone(),
|
||||||
|
save_data_location: builder.save_data_location.clone(),
|
||||||
|
watch_rom: builder.watch_rom.clone(),
|
||||||
};
|
};
|
||||||
(builder, client)
|
(builder, client)
|
||||||
}
|
}
|
||||||
@@ -131,18 +135,42 @@ impl EmulatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Result<Emulator> {
|
pub fn build(self) -> Result<Emulator> {
|
||||||
let mut emulator = Emulator::new(
|
let Self {
|
||||||
self.commands,
|
rom,
|
||||||
self.sim_state,
|
commands,
|
||||||
self.state,
|
sim_state,
|
||||||
self.audio_on,
|
state,
|
||||||
self.watch_rom,
|
audio_on,
|
||||||
self.linked,
|
watch_rom,
|
||||||
);
|
linked,
|
||||||
if let Some(path) = self.rom {
|
save_data_location,
|
||||||
|
start_paused,
|
||||||
|
} = self;
|
||||||
|
let mut emulator = Emulator {
|
||||||
|
sims: vec![],
|
||||||
|
carts: [None, None],
|
||||||
|
audio: Audio::init(),
|
||||||
|
commands,
|
||||||
|
sim_state,
|
||||||
|
state,
|
||||||
|
audio_on,
|
||||||
|
watch_rom,
|
||||||
|
linked,
|
||||||
|
save_data_location,
|
||||||
|
profilers: [None, None],
|
||||||
|
renderers: HashMap::new(),
|
||||||
|
messages: HashMap::new(),
|
||||||
|
debuggers: HashMap::new(),
|
||||||
|
stdouts: HashMap::new(),
|
||||||
|
watched_regions: HashMap::new(),
|
||||||
|
eye_contents: [vec![0u8; 384 * 224 * 2], vec![0u8; 384 * 224 * 2]],
|
||||||
|
audio_samples: Vec::with_capacity(EXPECTED_FRAME_SIZE),
|
||||||
|
buffer: vec![],
|
||||||
|
};
|
||||||
|
if let Some(path) = rom {
|
||||||
emulator.load_cart(SimId::Player1, &path)?;
|
emulator.load_cart(SimId::Player1, &path)?;
|
||||||
}
|
}
|
||||||
if self.start_paused {
|
if start_paused {
|
||||||
emulator.pause_sims()?;
|
emulator.pause_sims()?;
|
||||||
}
|
}
|
||||||
Ok(emulator)
|
Ok(emulator)
|
||||||
@@ -159,6 +187,7 @@ pub struct Emulator {
|
|||||||
audio_on: Arc<[AtomicBool; 2]>,
|
audio_on: Arc<[AtomicBool; 2]>,
|
||||||
watch_rom: Arc<[AtomicBool; 2]>,
|
watch_rom: Arc<[AtomicBool; 2]>,
|
||||||
linked: Arc<AtomicBool>,
|
linked: Arc<AtomicBool>,
|
||||||
|
save_data_location: Arc<Atomic<SaveDataLocation>>,
|
||||||
profilers: [Option<ProfileSender>; 2],
|
profilers: [Option<ProfileSender>; 2],
|
||||||
renderers: HashMap<SimId, TextureSink>,
|
renderers: HashMap<SimId, TextureSink>,
|
||||||
messages: HashMap<SimId, mpsc::Sender<Toast>>,
|
messages: HashMap<SimId, mpsc::Sender<Toast>>,
|
||||||
@@ -171,36 +200,6 @@ pub struct Emulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Emulator {
|
impl Emulator {
|
||||||
fn new(
|
|
||||||
commands: mpsc::Receiver<EmulatorCommand>,
|
|
||||||
sim_state: Arc<[Atomic<SimState>; 2]>,
|
|
||||||
state: Arc<Atomic<EmulatorState>>,
|
|
||||||
audio_on: Arc<[AtomicBool; 2]>,
|
|
||||||
watch_rom: Arc<[AtomicBool; 2]>,
|
|
||||||
linked: Arc<AtomicBool>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
sims: vec![],
|
|
||||||
carts: [None, None],
|
|
||||||
audio: Audio::init(),
|
|
||||||
commands,
|
|
||||||
sim_state,
|
|
||||||
state,
|
|
||||||
audio_on,
|
|
||||||
watch_rom,
|
|
||||||
linked,
|
|
||||||
profilers: [None, None],
|
|
||||||
renderers: HashMap::new(),
|
|
||||||
messages: HashMap::new(),
|
|
||||||
debuggers: HashMap::new(),
|
|
||||||
stdouts: HashMap::new(),
|
|
||||||
watched_regions: HashMap::new(),
|
|
||||||
eye_contents: [vec![0u8; 384 * 224 * 2], vec![0u8; 384 * 224 * 2]],
|
|
||||||
audio_samples: Vec::with_capacity(EXPECTED_FRAME_SIZE),
|
|
||||||
buffer: vec![],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn reload_cart(&mut self, sim_id: SimId) -> Result<()> {
|
pub fn reload_cart(&mut self, sim_id: SimId) -> Result<()> {
|
||||||
let Some(cart) = &self.carts[sim_id.to_index()] else {
|
let Some(cart) = &self.carts[sim_id.to_index()] else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -211,7 +210,12 @@ impl Emulator {
|
|||||||
|
|
||||||
pub fn load_cart(&mut self, sim_id: SimId, path: &Path) -> Result<()> {
|
pub fn load_cart(&mut self, sim_id: SimId, path: &Path) -> Result<()> {
|
||||||
let watch = self.watch_rom[sim_id.to_index()].load(Ordering::Acquire);
|
let watch = self.watch_rom[sim_id.to_index()].load(Ordering::Acquire);
|
||||||
let cart = Cart::load(path, sim_id, watch)?;
|
let cart = Cart::load(
|
||||||
|
path,
|
||||||
|
sim_id,
|
||||||
|
self.save_data_location.load(Ordering::Acquire),
|
||||||
|
watch,
|
||||||
|
)?;
|
||||||
self.try_reset_sim(sim_id, Some(cart))?;
|
self.try_reset_sim(sim_id, Some(cart))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -224,7 +228,12 @@ impl Emulator {
|
|||||||
};
|
};
|
||||||
let watch = self.watch_rom[SimId::Player2.to_index()].load(Ordering::Acquire);
|
let watch = self.watch_rom[SimId::Player2.to_index()].load(Ordering::Acquire);
|
||||||
let cart = match file_path {
|
let cart = match file_path {
|
||||||
Some(rom_path) => Some(Cart::load(&rom_path, SimId::Player2, watch)?),
|
Some(rom_path) => Some(Cart::load(
|
||||||
|
&rom_path,
|
||||||
|
SimId::Player2,
|
||||||
|
self.save_data_location.load(Ordering::Acquire),
|
||||||
|
watch,
|
||||||
|
)?),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
self.try_reset_sim(SimId::Player2, cart)?;
|
self.try_reset_sim(SimId::Player2, cart)?;
|
||||||
@@ -687,6 +696,20 @@ impl Emulator {
|
|||||||
cart.stop_watching();
|
cart.stop_watching();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EmulatorCommand::SetSaveDataLocation(save_data_location) => {
|
||||||
|
self.save_data_location
|
||||||
|
.store(save_data_location, Ordering::Release);
|
||||||
|
for sim_id in SimId::values() {
|
||||||
|
if let Some(cart) = self.carts[sim_id.to_index()].as_mut()
|
||||||
|
&& let Err(error) = cart.change_save_data_location(save_data_location)
|
||||||
|
{
|
||||||
|
self.report_error(
|
||||||
|
sim_id,
|
||||||
|
format!("Error changing save data location: {error}"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
EmulatorCommand::StartSecondSim(path) => {
|
EmulatorCommand::StartSecondSim(path) => {
|
||||||
if let Err(error) = self.start_second_sim(path) {
|
if let Err(error) = self.start_second_sim(path) {
|
||||||
self.report_error(
|
self.report_error(
|
||||||
@@ -854,6 +877,7 @@ pub enum EmulatorCommand {
|
|||||||
LoadGame(SimId, PathBuf),
|
LoadGame(SimId, PathBuf),
|
||||||
ReloadRom(SimId),
|
ReloadRom(SimId),
|
||||||
WatchRom(SimId, bool),
|
WatchRom(SimId, bool),
|
||||||
|
SetSaveDataLocation(SaveDataLocation),
|
||||||
StartSecondSim(Option<PathBuf>),
|
StartSecondSim(Option<PathBuf>),
|
||||||
StopSecondSim,
|
StopSecondSim,
|
||||||
Pause,
|
Pause,
|
||||||
@@ -943,6 +967,7 @@ pub struct EmulatorClient {
|
|||||||
sim_state: Arc<[Atomic<SimState>; 2]>,
|
sim_state: Arc<[Atomic<SimState>; 2]>,
|
||||||
state: Arc<Atomic<EmulatorState>>,
|
state: Arc<Atomic<EmulatorState>>,
|
||||||
linked: Arc<AtomicBool>,
|
linked: Arc<AtomicBool>,
|
||||||
|
save_data_location: Arc<Atomic<SaveDataLocation>>,
|
||||||
watch_rom: Arc<[AtomicBool; 2]>,
|
watch_rom: Arc<[AtomicBool; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -959,6 +984,9 @@ impl EmulatorClient {
|
|||||||
pub fn are_sims_linked(&self) -> bool {
|
pub fn are_sims_linked(&self) -> bool {
|
||||||
self.linked.load(Ordering::Acquire)
|
self.linked.load(Ordering::Acquire)
|
||||||
}
|
}
|
||||||
|
pub fn save_data_location(&self) -> SaveDataLocation {
|
||||||
|
self.save_data_location.load(Ordering::Acquire)
|
||||||
|
}
|
||||||
pub fn is_rom_watched(&self, sim_id: SimId) -> bool {
|
pub fn is_rom_watched(&self, sim_id: SimId) -> bool {
|
||||||
self.watch_rom[sim_id.to_index()].load(Ordering::Acquire)
|
self.watch_rom[sim_id.to_index()].load(Ordering::Acquire)
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-7
@@ -8,10 +8,15 @@ use std::{
|
|||||||
sync::{Arc, atomic::AtomicBool},
|
sync::{Arc, atomic::AtomicBool},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::emulator::{SimId, game_info::GameInfo, shrooms_vb_util::rom_from_isx};
|
use crate::{
|
||||||
|
config::SaveDataLocation,
|
||||||
|
emulator::{SimId, game_info::GameInfo, shrooms_vb_util::rom_from_isx},
|
||||||
|
filesystem,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct Cart {
|
pub struct Cart {
|
||||||
pub file_path: PathBuf,
|
pub file_path: PathBuf,
|
||||||
|
sim_id: SimId,
|
||||||
pub rom: Vec<u8>,
|
pub rom: Vec<u8>,
|
||||||
sram_file: File,
|
sram_file: File,
|
||||||
pub sram: Vec<u8>,
|
pub sram: Vec<u8>,
|
||||||
@@ -21,7 +26,12 @@ pub struct Cart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Cart {
|
impl Cart {
|
||||||
pub fn load(file_path: &Path, sim_id: SimId, watch: bool) -> Result<Self> {
|
pub fn load(
|
||||||
|
file_path: &Path,
|
||||||
|
sim_id: SimId,
|
||||||
|
save_data_location: SaveDataLocation,
|
||||||
|
watch: bool,
|
||||||
|
) -> Result<Self> {
|
||||||
let (rom, info) = Self::read_rom(file_path)?;
|
let (rom, info) = Self::read_rom(file_path)?;
|
||||||
|
|
||||||
let mut sram_file = File::options()
|
let mut sram_file = File::options()
|
||||||
@@ -29,7 +39,7 @@ impl Cart {
|
|||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
.truncate(false)
|
.truncate(false)
|
||||||
.open(sram_path(file_path, sim_id))?;
|
.open(sram_path(file_path, sim_id, save_data_location))?;
|
||||||
|
|
||||||
let sram = if sram_file.metadata()?.len() == 0 {
|
let sram = if sram_file.metadata()?.len() == 0 {
|
||||||
// new SRAM file, randomize the contents
|
// new SRAM file, randomize the contents
|
||||||
@@ -54,6 +64,7 @@ impl Cart {
|
|||||||
|
|
||||||
Ok(Cart {
|
Ok(Cart {
|
||||||
file_path: file_path.to_path_buf(),
|
file_path: file_path.to_path_buf(),
|
||||||
|
sim_id,
|
||||||
rom,
|
rom,
|
||||||
sram_file,
|
sram_file,
|
||||||
sram,
|
sram,
|
||||||
@@ -73,6 +84,19 @@ impl Cart {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn change_save_data_location(
|
||||||
|
&mut self,
|
||||||
|
save_data_location: SaveDataLocation,
|
||||||
|
) -> Result<()> {
|
||||||
|
self.sram_file = File::options()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(false)
|
||||||
|
.open(sram_path(&self.file_path, self.sim_id, save_data_location))?;
|
||||||
|
self.save_sram()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn save_sram(&mut self) -> Result<()> {
|
pub fn save_sram(&mut self) -> Result<()> {
|
||||||
self.sram_file.seek(SeekFrom::Start(0))?;
|
self.sram_file.seek(SeekFrom::Start(0))?;
|
||||||
self.sram_file.write_all(&self.sram)?;
|
self.sram_file.write_all(&self.sram)?;
|
||||||
@@ -177,9 +201,17 @@ fn parse_elf_program<Elf: object::read::elf::FileHeader<Endian = object::Endiann
|
|||||||
Some(bytes)
|
Some(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sram_path(file_path: &Path, sim_id: SimId) -> PathBuf {
|
fn sram_path(file_path: &Path, sim_id: SimId, save_data_location: SaveDataLocation) -> PathBuf {
|
||||||
match sim_id {
|
let extension = match sim_id {
|
||||||
SimId::Player1 => file_path.with_extension("p1.sram"),
|
SimId::Player1 => "p1.sram",
|
||||||
SimId::Player2 => file_path.with_extension("p2.sram"),
|
SimId::Player2 => "p2.sram",
|
||||||
|
};
|
||||||
|
if let SaveDataLocation::DataDirectory = save_data_location
|
||||||
|
&& let Some(data_dir) = filesystem::init_data_dir()
|
||||||
|
&& let Some(rom_name) = file_path.file_name()
|
||||||
|
{
|
||||||
|
data_dir.join(rom_name).with_extension(extension)
|
||||||
|
} else {
|
||||||
|
file_path.with_extension(extension)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
|
use anyhow::{Result, bail};
|
||||||
|
use directories::ProjectDirs;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Persistence {
|
||||||
|
config_dir: Option<PathBuf>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Persistence {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
config_dir: init_config_dir(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save_config<T: Serialize>(&self, file: &str, data: &T) -> Result<()> {
|
||||||
|
if let Some(config_dir) = self.config_dir.as_ref() {
|
||||||
|
let bytes = serde_json::to_vec_pretty(data)?;
|
||||||
|
let filename = config_dir.join(file).with_extension("json");
|
||||||
|
fs::write(&filename, bytes)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load_config<T: for<'a> Deserialize<'a>>(&self, file: &str) -> Result<T> {
|
||||||
|
let Some(config_dir) = self.config_dir.as_ref() else {
|
||||||
|
bail!("config directory not found");
|
||||||
|
};
|
||||||
|
let filename = config_dir.join(file).with_extension("json");
|
||||||
|
let bytes = fs::read(filename)?;
|
||||||
|
Ok(serde_json::from_slice(&bytes)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_config_dir() -> Option<PathBuf> {
|
||||||
|
let config_dir = project_dirs()?.config_dir().to_path_buf();
|
||||||
|
fs::create_dir_all(&config_dir).ok()?;
|
||||||
|
Some(config_dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_data_dir() -> Option<PathBuf> {
|
||||||
|
let data_dir = project_dirs()?.data_dir().to_path_buf();
|
||||||
|
fs::create_dir_all(&data_dir).ok()?;
|
||||||
|
Some(data_dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn project_dirs() -> Option<ProjectDirs> {
|
||||||
|
ProjectDirs::from("com", "virtual-boy", "Lemur")
|
||||||
|
}
|
||||||
+1
-1
@@ -14,7 +14,7 @@ use winit::keyboard::{KeyCode, PhysicalKey};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
emulator::{SimId, VBKey},
|
emulator::{SimId, VBKey},
|
||||||
persistence::Persistence,
|
filesystem::Persistence,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||||
|
|||||||
+11
-15
@@ -15,7 +15,7 @@ use winit::event_loop::{ControlFlow, EventLoop};
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::{AppConfig, CliArgs, SimConfig},
|
config::{AppConfig, CliArgs, SimConfig},
|
||||||
emulator::SimId,
|
emulator::SimId,
|
||||||
persistence::Persistence,
|
filesystem::Persistence,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
@@ -24,12 +24,12 @@ mod config;
|
|||||||
mod controller;
|
mod controller;
|
||||||
mod emulator;
|
mod emulator;
|
||||||
mod filepicker;
|
mod filepicker;
|
||||||
|
mod filesystem;
|
||||||
mod gdbserver;
|
mod gdbserver;
|
||||||
mod graphics;
|
mod graphics;
|
||||||
mod images;
|
mod images;
|
||||||
mod input;
|
mod input;
|
||||||
mod memory;
|
mod memory;
|
||||||
mod persistence;
|
|
||||||
mod profiler;
|
mod profiler;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
@@ -60,14 +60,9 @@ fn set_panic_handler() {
|
|||||||
|
|
||||||
eprint!("{message}");
|
eprint!("{message}");
|
||||||
|
|
||||||
let Some(project_dirs) = directories::ProjectDirs::from("com", "virtual-boy", "Lemur")
|
let Some(data_dir) = filesystem::init_data_dir() else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let data_dir = project_dirs.data_dir();
|
|
||||||
if std::fs::create_dir_all(data_dir).is_err() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let timestamp = SystemTime::now()
|
let timestamp = SystemTime::now()
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -98,7 +93,14 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let persistence = Persistence::new();
|
let persistence = Persistence::new();
|
||||||
|
|
||||||
let (mut builder, client) = EmulatorBuilder::new();
|
let mut config = AppConfig::load(&persistence);
|
||||||
|
if config.update(&args) {
|
||||||
|
let _ = config.save(&persistence);
|
||||||
|
}
|
||||||
|
let p1 = SimConfig::load(&persistence, SimId::Player1);
|
||||||
|
let p2 = SimConfig::load(&persistence, SimId::Player2);
|
||||||
|
|
||||||
|
let (mut builder, client) = EmulatorBuilder::new(config.save_data_location);
|
||||||
if let Some(path) = &args.rom {
|
if let Some(path) = &args.rom {
|
||||||
builder = builder.with_rom(path);
|
builder = builder.with_rom(path);
|
||||||
}
|
}
|
||||||
@@ -111,12 +113,6 @@ fn main() -> Result<()> {
|
|||||||
if args.profile {
|
if args.profile {
|
||||||
builder = builder.start_paused(true)
|
builder = builder.start_paused(true)
|
||||||
}
|
}
|
||||||
let mut config = AppConfig::load(&persistence);
|
|
||||||
if config.update(&args) {
|
|
||||||
let _ = config.save(&persistence);
|
|
||||||
}
|
|
||||||
let p1 = SimConfig::load(&persistence, SimId::Player1);
|
|
||||||
let p2 = SimConfig::load(&persistence, SimId::Player2);
|
|
||||||
|
|
||||||
let watch = args.watch;
|
let watch = args.watch;
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
use std::{fs, path::PathBuf};
|
|
||||||
|
|
||||||
use anyhow::{Result, bail};
|
|
||||||
use directories::ProjectDirs;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Persistence {
|
|
||||||
dirs: Option<Dirs>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Persistence {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self { dirs: init_dirs() }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn save_config<T: Serialize>(&self, file: &str, data: &T) -> Result<()> {
|
|
||||||
if let Some(dirs) = self.dirs.as_ref() {
|
|
||||||
let bytes = serde_json::to_vec_pretty(data)?;
|
|
||||||
let filename = dirs.config_dir.join(file).with_extension("json");
|
|
||||||
fs::write(&filename, bytes)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn load_config<T: for<'a> Deserialize<'a>>(&self, file: &str) -> Result<T> {
|
|
||||||
let Some(dirs) = self.dirs.as_ref() else {
|
|
||||||
bail!("config directory not found");
|
|
||||||
};
|
|
||||||
let filename = dirs.config_dir.join(file).with_extension("json");
|
|
||||||
let bytes = fs::read(filename)?;
|
|
||||||
Ok(serde_json::from_slice(&bytes)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct Dirs {
|
|
||||||
config_dir: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn init_dirs() -> Option<Dirs> {
|
|
||||||
let dirs = ProjectDirs::from("com", "virtual-boy", "Lemur")?;
|
|
||||||
let config_dir = dirs.config_dir().to_path_buf();
|
|
||||||
fs::create_dir_all(&config_dir).ok()?;
|
|
||||||
Some(Dirs { config_dir })
|
|
||||||
}
|
|
||||||
+1
-1
@@ -12,7 +12,7 @@ impl AppWindow for AboutWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.vertical_centered(|ui| {
|
ui.vertical_centered(|ui| {
|
||||||
ui.label("Lemur Virtual Boy Emulator");
|
ui.label("Lemur Virtual Boy Emulator");
|
||||||
ui.label(format!("Version {}", env!("CARGO_PKG_VERSION")));
|
ui.label(format!("Version {}", env!("CARGO_PKG_VERSION")));
|
||||||
|
|||||||
+35
-6
@@ -7,13 +7,13 @@ use std::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::UserEvent,
|
app::UserEvent,
|
||||||
config::{COLOR_PRESETS, SimConfig},
|
config::{AppConfig, COLOR_PRESETS, SaveDataLocation, SimConfig},
|
||||||
emulator::{EmulatorClient, EmulatorCommand, EmulatorState, SimId, SimState},
|
emulator::{EmulatorClient, EmulatorCommand, EmulatorState, SimId, SimState},
|
||||||
filepicker::FilePicker,
|
filepicker::FilePicker,
|
||||||
|
filesystem::Persistence,
|
||||||
images::ImageTextureLoader,
|
images::ImageTextureLoader,
|
||||||
input::{Command, MappingProvider, ShortcutProvider},
|
input::{Command, MappingProvider, ShortcutProvider},
|
||||||
memory::MemoryClient,
|
memory::MemoryClient,
|
||||||
persistence::Persistence,
|
|
||||||
window::{
|
window::{
|
||||||
AboutWindow, BgMapWindow, CharacterDataWindow, FrameBufferWindow, GdbServerWindow,
|
AboutWindow, BgMapWindow, CharacterDataWindow, FrameBufferWindow, GdbServerWindow,
|
||||||
HotkeysWindow, InitArgs, InputWindow, ObjectWindow, ProfileWindow, RegisterWindow,
|
HotkeysWindow, InitArgs, InputWindow, ObjectWindow, ProfileWindow, RegisterWindow,
|
||||||
@@ -604,6 +604,37 @@ impl GameWindow {
|
|||||||
if ui.button("Hotkeys").clicked() {
|
if ui.button("Hotkeys").clicked() {
|
||||||
self.open(ChildWindow::Hotkeys);
|
self.open(ChildWindow::Hotkeys);
|
||||||
}
|
}
|
||||||
|
ui.menu_button("Save Data Location", |ui| {
|
||||||
|
let save_data_location = self.client.save_data_location();
|
||||||
|
let update_save_data_location = |new_location: SaveDataLocation| {
|
||||||
|
if new_location == save_data_location {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let mut app_config = AppConfig::load(&self.persistence);
|
||||||
|
app_config.save_data_location = new_location;
|
||||||
|
let _ = app_config.save(&self.persistence);
|
||||||
|
self.client
|
||||||
|
.send_command(EmulatorCommand::SetSaveDataLocation(new_location));
|
||||||
|
};
|
||||||
|
if ui
|
||||||
|
.selectable_button(
|
||||||
|
save_data_location == SaveDataLocation::RomDirectory,
|
||||||
|
"Same Directory as ROM",
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
update_save_data_location(SaveDataLocation::RomDirectory);
|
||||||
|
}
|
||||||
|
if ui
|
||||||
|
.selectable_button(
|
||||||
|
save_data_location == SaveDataLocation::DataDirectory,
|
||||||
|
"App Data Directory",
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
update_save_data_location(SaveDataLocation::DataDirectory);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_color_picker(&mut self, ui: &mut Ui) {
|
fn show_color_picker(&mut self, ui: &mut Ui) {
|
||||||
@@ -708,9 +739,7 @@ impl AppWindow for GameWindow {
|
|||||||
while let Ok(toast) = self.messages.try_recv() {
|
while let Ok(toast) = self.messages.try_recv() {
|
||||||
self.toasts.add(toast);
|
self.toasts.add(toast);
|
||||||
}
|
}
|
||||||
Panel::top("menubar")
|
Panel::top("menubar").exact_size(22.0).show(ui, |ui| {
|
||||||
.exact_size(22.0)
|
|
||||||
.show_inside(ui, |ui| {
|
|
||||||
MenuBar::new().ui(ui, |ui| {
|
MenuBar::new().ui(ui, |ui| {
|
||||||
self.show_menu(ui);
|
self.show_menu(ui);
|
||||||
});
|
});
|
||||||
@@ -725,7 +754,7 @@ impl AppWindow for GameWindow {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
let frame = Frame::central_panel(ui.style()).fill(Color32::BLACK);
|
let frame = Frame::central_panel(ui.style()).fill(Color32::BLACK);
|
||||||
CentralPanel::default().frame(frame).show_inside(ui, |ui| {
|
CentralPanel::default().frame(frame).show(ui, |ui| {
|
||||||
if let Some(screen) = self.screen.as_mut() {
|
if let Some(screen) = self.screen.as_mut() {
|
||||||
screen.update(self.config.display_mode, self.config.colors);
|
screen.update(self.config.display_mode, self.config.colors);
|
||||||
ui.add(screen);
|
ui.add(screen);
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ impl AppWindow for GdbServerWindow {
|
|||||||
fn show(&mut self, ui: &mut egui::Ui) {
|
fn show(&mut self, ui: &mut egui::Ui) {
|
||||||
let port_num: Option<u16> = self.port_str.parse().ok();
|
let port_num: Option<u16> = self.port_str.parse().ok();
|
||||||
let status = self.server.status();
|
let status = self.server.status();
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if port_num.is_none() {
|
if port_num.is_none() {
|
||||||
let style = ui.style_mut();
|
let style = ui.style_mut();
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ impl AppWindow for HotkeysWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if ui.button("Use defaults").clicked() {
|
if ui.button("Use defaults").clicked() {
|
||||||
self.shortcuts.reset();
|
self.shortcuts.reset();
|
||||||
|
|||||||
+3
-3
@@ -70,7 +70,7 @@ impl InputWindow {
|
|||||||
.column(Column::remainder())
|
.column(Column::remainder())
|
||||||
.cell_layout(Layout::left_to_right(egui::Align::Center))
|
.cell_layout(Layout::left_to_right(egui::Align::Center))
|
||||||
.body(|mut body| {
|
.body(|mut body| {
|
||||||
for keys in KEY_NAMES.chunks_exact(2) {
|
for keys in KEY_NAMES.as_chunks::<2>().0 {
|
||||||
body.row(20.0, |mut row| {
|
body.row(20.0, |mut row| {
|
||||||
for (key, name) in keys {
|
for (key, name) in keys {
|
||||||
let binding = names.remove(key).map(|mut s| {
|
let binding = names.remove(key).map(|mut s| {
|
||||||
@@ -167,7 +167,7 @@ impl AppWindow for InputWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
Panel::top("options").show_inside(ui, |ui| {
|
Panel::top("options").show(ui, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let old_active_tab = self.active_tab;
|
let old_active_tab = self.active_tab;
|
||||||
ui.selectable_value(&mut self.active_tab, InputTab::Player1, "Player 1");
|
ui.selectable_value(&mut self.active_tab, InputTab::Player1, "Player 1");
|
||||||
@@ -182,7 +182,7 @@ impl AppWindow for InputWindow {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
match self.active_tab {
|
match self.active_tab {
|
||||||
InputTab::Player1 => self.show_key_bindings(ui, SimId::Player1),
|
InputTab::Player1 => self.show_key_bindings(ui, SimId::Player1),
|
||||||
InputTab::Player2 => self.show_key_bindings(ui, SimId::Player2),
|
InputTab::Player2 => self.show_key_bindings(ui, SimId::Player2),
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ impl AppWindow for ProfileWindow {
|
|||||||
fn show(&mut self, ui: &mut egui::Ui) {
|
fn show(&mut self, ui: &mut egui::Ui) {
|
||||||
let status = self.profiler.status();
|
let status = self.profiler.status();
|
||||||
let recording = matches!(status, ProfilerStatus::Recording);
|
let recording = matches!(status, ProfilerStatus::Recording);
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal_wrapped(|ui| {
|
ui.horizontal_wrapped(|ui| {
|
||||||
ui.spacing_mut().item_spacing.x = 0.0;
|
ui.spacing_mut().item_spacing.x = 0.0;
|
||||||
ui.add(
|
ui.add(
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ impl AppWindow for TerminalWindow {
|
|||||||
}
|
}
|
||||||
self.lines.back_mut().unwrap().push_str(rest);
|
self.lines.back_mut().unwrap().push_str(rest);
|
||||||
}
|
}
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ScrollArea::vertical()
|
ScrollArea::vertical()
|
||||||
.stick_to_bottom(true)
|
.stick_to_bottom(true)
|
||||||
.auto_shrink([false, false])
|
.auto_shrink([false, false])
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ impl AppWindow for BgMapWindow {
|
|||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
self.state.load(ui);
|
self.state.load(ui);
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::relative(0.3).at_most(200.0))
|
.size(Size::relative(0.3).at_most(200.0))
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ impl AppWindow for CharacterDataWindow {
|
|||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
self.state.load(ui);
|
self.state.load(ui);
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::relative(0.3).at_most(200.0))
|
.size(Size::relative(0.3).at_most(200.0))
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ impl AppWindow for FrameBufferWindow {
|
|||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
self.state.load(ui);
|
self.state.load(ui);
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::relative(0.3).at_most(200.0))
|
.size(Size::relative(0.3).at_most(200.0))
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ impl AppWindow for ObjectWindow {
|
|||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
self.state.load(ui);
|
self.state.load(ui);
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::relative(0.3).at_most(200.0))
|
.size(Size::relative(0.3).at_most(200.0))
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ impl AppWindow for RegisterWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ScrollArea::vertical().show(ui, |ui| {
|
ScrollArea::vertical().show(ui, |ui| {
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
let width = ui.available_width();
|
let width = ui.available_width();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use egui::{Color32, Image, ImageSource, Response, Sense, TextureOptions, Ui, Widget};
|
use egui::{Color32, Image, ImageSource, Response, Sense, TextureOptions, Ui, Widget};
|
||||||
|
|
||||||
pub const GENERIC_PALETTE: [u8; 4] = [0, 32, 64, 128];
|
pub const GENERIC_PALETTE: [u8; 4] = [0, 32, 64, 128];
|
||||||
|
const COLOR_TRANSPARENT: Color32 = Color32::from_rgb(0x25, 0x25, 0x25);
|
||||||
|
|
||||||
pub fn shade(brt: u8, color: Color32) -> Color32 {
|
pub fn shade(brt: u8, color: Color32) -> Color32 {
|
||||||
let corrected = if brt > 132 {
|
let corrected = if brt > 132 {
|
||||||
@@ -44,7 +45,9 @@ pub fn parse_brts(brts: &[u16; 3], color: Color32) -> [Color32; 4] {
|
|||||||
|
|
||||||
pub fn palette_colors(palette: u8, brts: &[u8; 8], color: Color32) -> [Color32; 4] {
|
pub fn palette_colors(palette: u8, brts: &[u8; 8], color: Color32) -> [Color32; 4] {
|
||||||
let colors = parse_shades(brts).map(|s| shade(s, color));
|
let colors = parse_shades(brts).map(|s| shade(s, color));
|
||||||
parse_palette(palette).map(|p| colors[p as usize])
|
let mut palette_colors = parse_palette(palette).map(|p| colors[p as usize]);
|
||||||
|
palette_colors[0] = COLOR_TRANSPARENT;
|
||||||
|
palette_colors
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Object {
|
pub struct Object {
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ impl AppWindow for WorldWindow {
|
|||||||
|
|
||||||
fn show(&mut self, ui: &mut Ui) {
|
fn show(&mut self, ui: &mut Ui) {
|
||||||
self.state.load(ui);
|
self.state.load(ui);
|
||||||
CentralPanel::default().show_inside(ui, |ui| {
|
CentralPanel::default().show(ui, |ui| {
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::relative(0.3).at_most(200.0))
|
.size(Size::relative(0.3).at_most(200.0))
|
||||||
|
|||||||
Reference in New Issue
Block a user