mirror of
https://github.com/touchHLE/touchHLE.git
synced 2026-01-31 01:25:24 +01:00
Implement stub singleton for UIScreen
This commit is contained in:
@@ -10,12 +10,14 @@ use crate::export_c_func;
|
||||
pub mod ui_application;
|
||||
pub mod ui_nib;
|
||||
pub mod ui_responder;
|
||||
pub mod ui_screen;
|
||||
pub mod ui_view;
|
||||
pub mod ui_window;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct State {
|
||||
ui_application: ui_application::State,
|
||||
ui_screen: ui_screen::State,
|
||||
}
|
||||
|
||||
pub const FUNCTIONS: FunctionExports = {
|
||||
|
||||
38
src/frameworks/uikit/ui_screen.rs
Normal file
38
src/frameworks/uikit/ui_screen.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
//! `UIScreen`.
|
||||
|
||||
use crate::objc::{id, objc_classes, ClassExports, TrivialHostObject};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct State {
|
||||
main_screen: Option<id>,
|
||||
}
|
||||
|
||||
pub const CLASSES: ClassExports = objc_classes! {
|
||||
|
||||
(env, this, _cmd);
|
||||
|
||||
@implementation UIScreen: NSObject
|
||||
|
||||
// For now this is a singleton (the only instance is returned by mainScreen)
|
||||
+ (id)mainScreen {
|
||||
if let Some(screen) = env.framework_state.uikit.ui_screen.main_screen {
|
||||
screen
|
||||
} else {
|
||||
let new = env.objc.alloc_static_object(
|
||||
this,
|
||||
Box::new(TrivialHostObject),
|
||||
&mut env.mem
|
||||
);
|
||||
env.framework_state.uikit.ui_screen.main_screen = Some(new);
|
||||
new
|
||||
}
|
||||
}
|
||||
- (id)retain { this }
|
||||
- (())release {}
|
||||
- (id)autorelease { this }
|
||||
|
||||
// TODO: accessors
|
||||
|
||||
@end
|
||||
|
||||
};
|
||||
@@ -19,6 +19,7 @@ pub const CLASS_LISTS: &[super::ClassExports] = &[
|
||||
uikit::ui_application::CLASSES,
|
||||
uikit::ui_nib::CLASSES,
|
||||
uikit::ui_responder::CLASSES,
|
||||
uikit::ui_screen::CLASSES,
|
||||
uikit::ui_view::CLASSES,
|
||||
uikit::ui_window::CLASSES,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user