summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2024-07-30 22:13:07 +1200
committerBen Bridle <ben@derelict.engineering>2024-07-30 22:13:23 +1200
commitc3ff1b843a486832b739803d113558d7ee7144c1 (patch)
treed7f4be3141da65fb8e94092906282e78a26e6bce
parent820666fbbb10e4f8a288c738fa97af402eea9c06 (diff)
downloadbedrock-pc-c3ff1b843a486832b739803d113558d7ee7144c1.zip
Expose window title of emulator
The window title of the emulator can be set when constructing a new instance of the emulator. This is useful when a Bedrock program is baked into the emulator for distribution.
-rw-r--r--src/emulator.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/emulator.rs b/src/emulator.rs
index 606704d..195b8c8 100644
--- a/src/emulator.rs
+++ b/src/emulator.rs
@@ -16,6 +16,7 @@ macro_rules! u16 { ($u32:expr) => { $u32.try_into().unwrap_or(u16::MAX) }; }
pub struct BedrockEmulator {
vm: Processor<StandardDevices>,
+ title: String,
initialising: bool,
sleeping: bool,
pixel_scale: u32,
@@ -35,6 +36,7 @@ impl BedrockEmulator {
Self {
vm,
+ title: String::from("Bedrock emulator"),
initialising: true,
sleeping: false,
pixel_scale: 3,
@@ -46,6 +48,11 @@ impl BedrockEmulator {
}
}
+ pub fn with_title(mut self, title: &str) -> Self {
+ self.title = title.to_string();
+ self
+ }
+
pub fn run(self) -> ! {
let mut wm = WindowManager::new();
wm.add_window(Box::new(self));
@@ -95,7 +102,7 @@ impl BedrockEmulator {
impl WindowController for BedrockEmulator {
fn title(&self) -> String {
- String::from("Bedrock emulator")
+ self.title.clone()
}
fn exact_size(&self) -> Option<Dimensions> {