aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-client/src/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'games/rstnode/rst-client/src/window.rs')
-rw-r--r--games/rstnode/rst-client/src/window.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/games/rstnode/rst-client/src/window.rs b/games/rstnode/rst-client/src/window.rs
index ad58c38e0ffb..3dcf375a9009 100644
--- a/games/rstnode/rst-client/src/window.rs
+++ b/games/rstnode/rst-client/src/window.rs
@@ -1,10 +1,28 @@
//! Basic window setup code
use crate::{ctx, state::ClientState, GameSettings};
-use ggez::event;
+use ggez::{
+ event::{self, EventLoop},
+ Context,
+};
+
+pub struct Window {
+ ctx: Context,
+ eloop: EventLoop<()>,
+}
+
+impl Window {
+ pub fn ctx(&mut self) -> &mut Context {
+ &mut self.ctx
+ }
+
+ pub fn run(self, state: ClientState) -> ! {
+ event::run(self.ctx, self.eloop, state)
+ }
+}
/// Start the main event loop with game settings and state
-pub fn run(settings: &GameSettings, state: ClientState) -> ! {
+pub fn create(settings: &GameSettings) -> Window {
let (ctx, eloop) = ctx::build(settings).build().unwrap();
- event::run(ctx, eloop, state)
+ Window { ctx, eloop }
}