Skip to content

Commit

Permalink
add lang & time exts
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed Sep 15, 2023
1 parent 9d014ac commit 69faa92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
9 changes: 4 additions & 5 deletions api/system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ High-level system API built on-top of [playdate-sys][].
## Usage

```rust
use playdate_system::System;
use playdate_sys::ffi::PDLanguage;
use playdate_system::*;
use playdate_sys::println;

let system = System::new();

match system.language() {
PDLanguage::kPDLanguageEnglish => println!("Hello"),
PDLanguage::kPDLanguageJapanese => println!("こんにちは"),
PDLanguage::kPDLanguageUnknown => println!("Привет"),
PDLanguage::English => println!("Hello"),
PDLanguage::Japanese => println!("こんにちは"),
PDLanguage::Unknown => println!("Привет"),
}
system.draw_fps(20, 20);
```
Expand Down
11 changes: 11 additions & 0 deletions api/system/src/lang.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub use sys::ffi::PDLanguage;

pub trait PDLanguageExt {
#![allow(non_upper_case_globals)]
const English: PDLanguage = PDLanguage::kPDLanguageEnglish;
const Japanese: PDLanguage = PDLanguage::kPDLanguageJapanese;
const Unknown: PDLanguage = PDLanguage::kPDLanguageUnknown;
}


impl PDLanguageExt for PDLanguage {}
8 changes: 4 additions & 4 deletions api/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use core::marker::PhantomData;
use core::pin::Pin;
use core::time::Duration;

use sys::ffi::PDDateTime;
use sys::ffi::PDLanguage;


pub mod time;
pub mod lang;

pub use time::*;
pub use lang::*;


#[derive(Debug, Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion api/system/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sys::ffi::PDDateTime;
pub use sys::ffi::PDDateTime;

use crate::api::Api;

Expand Down

0 comments on commit 69faa92

Please sign in to comment.