diff options
| author | LLLL Colonq <llll@colonq> | 2026-08-17 20:14:16 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-08-17 20:14:16 -0400 |
| commit | de99c5f7636a952025ea13de02bafd25bcb6bdec (patch) | |
| tree | be359424af4f6717103e3b667b6529ae5a4b4e6a /2026/games/rpc2dot0/src/computer/os.rs | |
| parent | 4d4d1f24721f27fbf37e1070be6414de130ace61 (diff) | |
Fix broken
Diffstat (limited to '2026/games/rpc2dot0/src/computer/os.rs')
| -rw-r--r-- | 2026/games/rpc2dot0/src/computer/os.rs | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/2026/games/rpc2dot0/src/computer/os.rs b/2026/games/rpc2dot0/src/computer/os.rs deleted file mode 100644 index 797e07e..0000000 --- a/2026/games/rpc2dot0/src/computer/os.rs +++ /dev/null @@ -1,117 +0,0 @@ -use std::fmt::Debug;
-
-use crate::computer::ComputerPhase;
-use crate::message::Message;
-use crate::{assets::VIDEO_ASSETS, random::RandomState};
-use crate::{constants::*, game};
-use teleia::context;
-use web_sys::{Blob, BlobPropertyBag, Url};
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub struct Os {
- state: OsState,
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum OsState {
- Booting,
- On,
- ShutDown,
- Off,
-}
-
-// TODO ???
-impl From<OsState> for ComputerPhase {
- fn from(value: OsState) -> Self {
- match value {
- OsState::Booting => ComputerPhase::Booting,
- OsState::On => ComputerPhase::On,
- OsState::ShutDown => ComputerPhase::ShutDown,
- OsState::Off => ComputerPhase::Off,
- }
- }
-}
-
-impl From<ComputerPhase> for OsState {
- fn from(value: ComputerPhase) -> Self {
- match value {
- ComputerPhase::Off => OsState::Off,
- ComputerPhase::Booting => OsState::Booting,
- ComputerPhase::On => OsState::On,
- ComputerPhase::ShutDown => OsState::ShutDown,
- }
- }
-}
-
-impl Os {
- pub fn new() -> Self {
- Self {
- state: OsState::Off,
- }
- }
- pub fn from(phase: ComputerPhase) -> Self {
- Self {
- state: OsState::from(phase),
- }
- }
-
- pub fn set(&mut self, phase: ComputerPhase) {
- self.state = OsState::from(phase);
- }
-}
-
-impl Default for Os {
- fn default() -> Self {
- Self {
- state: OsState::Off,
- }
- }
-}
-
-impl Os {
- pub fn boot(rng: &mut RandomState) {
- let idx = rng.next_range(0.0, VIDEO_ASSETS.len() as f32) as usize;
- let bytes = VIDEO_ASSETS[idx].1;
-
- // huh ? `of1` nice api name
- let parts = js_sys::Array::of1(&js_sys::Uint8Array::from(bytes));
- let blob_props = BlobPropertyBag::new();
- blob_props.set_type("video/mp4");
-
- let blob = match Blob::new_with_u8_array_sequence_and_options(&parts, &blob_props) {
- Ok(b) => b,
- Err(_) => {
- log::error!("eatyourgreens:: failed to create blob");
- return;
- }
- };
-
- let url = match Url::create_object_url_with_blob(&blob) {
- Ok(s) => s,
- Err(_) => {
- log::error!("eatyourgreens:: failed to create object URL");
- return;
- }
- };
- if let Some(window) = web_sys::window() {
- let msg = Message {
- op: "play_video",
- verb: None,
- win: None,
- score: None,
- video_url: Some(url),
- };
- Message::post(&window, &msg);
- } else {
- log::error!("eatyourgreens:: failed to get window and send os msg");
- }
- }
-
- pub fn os_play(&self, ctx: &context::Context) {
- log::debug!("eatyourgreens:: os play game:");
- }
-
- pub fn os_quit() {
- log::debug!("eatyourgreens:: os quit");
- }
-}
|
