almost can run from mac ui
This commit is contained in:
parent
adf2bee84c
commit
f7e3f2b6e9
2 changed files with 37 additions and 1 deletions
|
@ -1,8 +1,10 @@
|
|||
use std::path::PathBuf;
|
||||
use std::sync::RwLock;
|
||||
|
||||
use cacao::appkit::menu::{Menu, MenuItem};
|
||||
use cacao::appkit::window::{Window, WindowConfig, WindowStyle, WindowToolbarStyle};
|
||||
use cacao::appkit::{App, AppDelegate};
|
||||
use cacao::filesystem::FileSelectPanel;
|
||||
use cacao::notification_center::Dispatcher;
|
||||
|
||||
use self::preferences::{PreferencesMessage, PreferencesUi};
|
||||
|
@ -23,6 +25,25 @@ pub(crate) struct TwincUiApp {
|
|||
preferences: RwLock<Window<PreferencesUi>>,
|
||||
}
|
||||
|
||||
impl TwincUiApp {
|
||||
fn open_dialog(&self) {
|
||||
let mut file_select_panel = FileSelectPanel::new();
|
||||
file_select_panel.set_can_choose_directories(false);
|
||||
file_select_panel.set_can_choose_files(true);
|
||||
file_select_panel.set_allows_multiple_selection(false);
|
||||
file_select_panel.show(move |v| {
|
||||
if let Some(path) = v.first() {
|
||||
open_file(path.pathbuf());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn open_file(path: PathBuf) {
|
||||
println!("open {path:?}");
|
||||
// gb_emu::run(gb_emu::RunOptions::new(path));
|
||||
}
|
||||
|
||||
impl Default for TwincUiApp {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
@ -59,7 +80,7 @@ impl Dispatcher for TwincUiApp {
|
|||
|
||||
fn on_ui_message(&self, message: Self::Message) {
|
||||
match message {
|
||||
AppMessage::Core(CoreMessage::Open) => println!("open"),
|
||||
AppMessage::Core(CoreMessage::Open) => self.open_dialog(),
|
||||
AppMessage::Core(CoreMessage::OpenPreferences) => {
|
||||
self.preferences.read().unwrap().show();
|
||||
}
|
||||
|
|
|
@ -81,6 +81,21 @@ pub struct RunOptions {
|
|||
pub record: bool,
|
||||
}
|
||||
|
||||
impl RunOptions {
|
||||
pub fn new(rom: PathBuf) -> Self {
|
||||
Self {
|
||||
rom,
|
||||
save: SramType::Auto,
|
||||
serial: SerialTarget::None,
|
||||
tile_window: false,
|
||||
layer_window: false,
|
||||
mute: false,
|
||||
debug: false,
|
||||
record: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(options: RunOptions) -> ! {
|
||||
let (sender, receiver) = channel::<EmulatorMessage>();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue