implements PLN-0081 shell hub packet migration
This commit is contained in:
@@ -5,7 +5,7 @@ use prometeu_hal::glyph_bank::GlyphBank;
|
||||
use prometeu_hal::scene_viewport_cache::{CachedTileEntry, SceneViewportCache};
|
||||
use prometeu_hal::scene_viewport_resolver::{LayerCopyRequest, ResolverUpdate};
|
||||
use prometeu_hal::sprite::Sprite;
|
||||
use prometeu_hal::{Game2DFramePacket, Gfx2dCommand, GfxBridge};
|
||||
use prometeu_hal::{Game2DFramePacket, Gfx2dCommand, GfxBridge, GfxUiCommand, ShellUiFramePacket};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Blending modes inspired by classic 16-bit hardware.
|
||||
@@ -714,6 +714,12 @@ impl Gfx {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_shell_ui_frame_packet(&mut self, packet: &ShellUiFramePacket) {
|
||||
for command in &packet.commands {
|
||||
self.apply_gfxui_command(command);
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_gfx2d_command(&mut self, command: &Gfx2dCommand) {
|
||||
match command {
|
||||
Gfx2dCommand::Clear { color } => self.clear(*color),
|
||||
@@ -738,6 +744,30 @@ impl Gfx {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_gfxui_command(&mut self, command: &GfxUiCommand) {
|
||||
match command {
|
||||
GfxUiCommand::Clear { color } => self.clear(*color),
|
||||
GfxUiCommand::FillRect { rect, color } => {
|
||||
self.fill_rect(rect.x, rect.y, rect.w, rect.h, *color);
|
||||
}
|
||||
GfxUiCommand::DrawLine { x0, y0, x1, y1, color } => {
|
||||
self.draw_line(*x0, *y0, *x1, *y1, *color);
|
||||
}
|
||||
GfxUiCommand::DrawCircle { x, y, radius, color } => {
|
||||
self.draw_circle(*x, *y, *radius, *color);
|
||||
}
|
||||
GfxUiCommand::DrawDisc { x, y, radius, border_color, fill_color } => {
|
||||
self.draw_disc(*x, *y, *radius, *border_color, *fill_color);
|
||||
}
|
||||
GfxUiCommand::DrawSquare { rect, border_color, fill_color } => {
|
||||
self.draw_square(rect.x, rect.y, rect.w, rect.h, *border_color, *fill_color);
|
||||
}
|
||||
GfxUiCommand::DrawText { x, y, text, color } => {
|
||||
self.draw_text(*x, *y, text, *color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn populate_layer_buckets(&mut self) {
|
||||
for bucket in self.layer_buckets.iter_mut() {
|
||||
bucket.clear();
|
||||
|
||||
@@ -8,10 +8,10 @@ use crate::memory_banks::{
|
||||
};
|
||||
use crate::pad::Pad;
|
||||
use crate::touch::Touch;
|
||||
use prometeu_hal::Game2DFramePacket;
|
||||
use prometeu_hal::cartridge::AssetsPayloadSource;
|
||||
use prometeu_hal::sprite::Sprite;
|
||||
use prometeu_hal::{AssetBridge, AudioBridge, GfxBridge, HardwareBridge, PadBridge, TouchBridge};
|
||||
use prometeu_hal::{Game2DFramePacket, ShellUiFramePacket};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Aggregate structure for all virtual hardware peripherals.
|
||||
@@ -72,6 +72,10 @@ impl HardwareBridge for Hardware {
|
||||
self.frame_composer.close_game2d_packet()
|
||||
}
|
||||
|
||||
fn render_shell_ui_packet(&mut self, packet: &ShellUiFramePacket) {
|
||||
self.gfx.render_shell_ui_frame_packet(packet);
|
||||
}
|
||||
|
||||
fn render_frame(&mut self) {
|
||||
if self.frame_composer.active_scene_id().is_none() {
|
||||
let packet = self.frame_composer.close_game2d_packet();
|
||||
@@ -81,6 +85,10 @@ impl HardwareBridge for Hardware {
|
||||
}
|
||||
}
|
||||
|
||||
fn present(&mut self) {
|
||||
self.gfx.present();
|
||||
}
|
||||
|
||||
fn has_glyph_bank(&self, bank_id: usize) -> bool {
|
||||
self.gfx.glyph_banks.glyph_bank_slot(bank_id).is_some()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user