From 76f7f4fd989a6ba17f42b07d7c4a88f4c135e4e1 Mon Sep 17 00:00:00 2001 From: Joey Maher Date: Fri, 5 Jun 2020 16:33:39 -0500 Subject: [PATCH] Renaming and adding comments --- voxygen/src/session.rs | 2 +- voxygen/src/window.rs | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index e66fd4b83a..4593e94c22 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -453,7 +453,7 @@ impl PlayState for SessionState { self.scene.handle_input_event(Event::AnalogGameInput(other)); }, }, - Event::ScreenshotSaved(screenshot_message) => self.hud.new_message(Chat { + Event::ScreenshotMessage(screenshot_message) => self.hud.new_message(Chat { chat_type: ChatType::Meta, message: screenshot_message, }), diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index b224f11f78..78f60f3db2 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -188,7 +188,7 @@ pub enum Event { /// Update of the analog inputs recognized by the game AnalogGameInput(AnalogGameInput), /// We tried to save a screenshot - ScreenshotSaved(String), + ScreenshotMessage(String), } pub type MouseButton = winit::MouseButton; @@ -394,8 +394,9 @@ pub struct Window { controller_settings: ControllerSettings, cursor_position: winit::dpi::LogicalPosition, mouse_emulation_vec: Vec2, - message_channel_sender: channel::Sender, - message_channel_receiver: channel::Receiver, + // Currently used to send and receive screenshot result messages + message_sender: channel::Sender, + message_receiver: channel::Receiver, } impl Window { @@ -482,8 +483,9 @@ impl Window { controller_settings, cursor_position: winit::dpi::LogicalPosition::new(0.0, 0.0), mouse_emulation_vec: Vec2::zero(), - message_channel_sender: message_sender, - message_channel_receiver: message_receiver, + // Currently used to send and receive screenshot result messages + message_sender, + message_receiver, }; this.fullscreen(settings.graphics.fullscreen); @@ -505,10 +507,9 @@ impl Window { } // Receive any messages sent through the message channel - match self.message_channel_receiver.try_recv() { - Ok(message_string) => events.push(Event::ScreenshotSaved(message_string)), - Err(_x) => {}, - } + self.message_receiver + .try_iter() + .for_each(|message| events.push(Event::ScreenshotMessage(message))); // Copy data that is needed by the events closure to avoid lifetime errors. // TODO: Remove this if/when the compiler permits it. @@ -946,7 +947,7 @@ impl Window { match self.renderer.create_screenshot() { Ok(img) => { let mut path = settings.screenshots_path.clone(); - let sender = self.message_channel_sender.clone(); + let sender = self.message_sender.clone(); std::thread::spawn(move || { use std::time::SystemTime;