Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Commit

Permalink
Merge #1243 #1246 #1248
Browse files Browse the repository at this point in the history
1243: Removed unnecessary code. r=Xaeroxe,jojolepro ,TimonPost a=TimonPost

Removed some unnecessary code. 

1246: Fix reported ScreenDimension and wrong DisplayConfig sizes. r=happenslol,azriel91,udoprog a=jojolepro

fixes #1241


1248: Add example Ron configs to docs r=Xaeroxe ,LucioFranco ,jojolepro udoprog ,azriel91 a=Sogomn



Co-authored-by: Timon <timonpost@hotmail.nl>
Co-authored-by: Joël Lupien (Jojolepro) <jojolepromain@gmail.com>
Co-authored-by: Johannes Boczek <johannes.boczek@web.de>
  • Loading branch information
4 people committed Dec 13, 2018
4 parents a510bc9 + d04c9a3 + 1953845 + 0e393dc commit 5192291
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
22 changes: 22 additions & 0 deletions amethyst_input/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ use super::{Axis, Button};
/// Used for saving and loading input settings.
///
/// An action can either be a single button or a combination of them.
///
/// # Examples
///
/// Example Ron config file:
/// ```ron
/// (
/// axes: {
/// "updown": Emulated(
/// pos: Key(Up),
/// neg: Key(Down)
/// ),
/// "leftright": Emulated(
/// pos: Key(Right),
/// neg: Key(Left)
/// )
/// },
/// actions: {
/// "fire": [ [Mouse(Left)], [Key(X)] ], // Multiple bindings for one action
/// "reload": [ [Key(LControl), Key(R)] ] // Combinations of multiple bindings possible
/// }
/// )
/// ```
#[derive(Derivative, Serialize, Deserialize, Clone)]
#[derivative(Default(bound = ""))]
pub struct Bindings<AX, AC>
Expand Down
7 changes: 2 additions & 5 deletions amethyst_network/src/network_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,10 @@ where
}

for raw_event in self.rx.try_iter() {
let mut matched = false;
// Get the NetConnection from the source
for net_connection in (&mut net_connections).join() {
// We found the origin
if net_connection.target == raw_event.source {
matched = true;
// Get the event
let net_event = deserialize_event::<E>(raw_event.data.as_slice());
match net_event {
Expand All @@ -204,9 +202,8 @@ where
e, raw_event.source
),
}
}
if !matched {
println!("Received packet from unknown source");
} else {
warn!("Received packet from unknown source");
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions amethyst_renderer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
use winit::{self, dpi::LogicalSize, WindowBuilder};

/// Structure for holding the renderer configuration.
///
/// # Examples
///
/// Example Ron config file:
/// ```ron
/// (
/// title: "Game title",
/// dimensions: Some((640, 480)),
/// max_dimensions: None,
/// min_dimensions: None,
/// fullscreen: false,
/// multisampling: 0,
/// visibility: true,
/// vsync: true
/// )
/// ```
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct DisplayConfig {
/// Name of the application window.
Expand Down
8 changes: 5 additions & 3 deletions amethyst_renderer/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,18 @@ impl RendererBuilder {
wb = wb.with_fullscreen(Some(self.events.get_primary_monitor()));
}

let hidpi = self.events.get_primary_monitor().get_hidpi_factor();

if let Some(dimensions) = self.config.dimensions {
wb = wb.with_dimensions(dimensions.into());
wb = wb.with_dimensions(LogicalSize::from_physical(dimensions, hidpi));
}

if let Some(dimensions) = self.config.min_dimensions {
wb = wb.with_min_dimensions(dimensions.into());
wb = wb.with_min_dimensions(LogicalSize::from_physical(dimensions, hidpi));
}

if let Some(dimensions) = self.config.max_dimensions {
wb = wb.with_max_dimensions(dimensions.into());
wb = wb.with_max_dimensions(LogicalSize::from_physical(dimensions, hidpi));
}

self.winit_builder = wb;
Expand Down
6 changes: 4 additions & 2 deletions amethyst_renderer/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ where
screen_dimensions.dirty = false;
}

let hidpi = self.renderer.window().get_hidpi_factor();

if let Some(size) = self.renderer.window().get_inner_size() {
let (window_width, window_height): (f64, f64) = size.into();
let (window_width, window_height): (f64, f64) = size.to_physical(hidpi).into();

// Send window size changes to the resource
if (window_width, window_height) != (width, height) {
Expand All @@ -139,7 +141,7 @@ where
screen_dimensions.dirty = false;
}
}
screen_dimensions.update_hidpi_factor(self.renderer.window().get_hidpi_factor());
screen_dimensions.update_hidpi_factor(hidpi);
}

fn render(&mut self, (mut event_handler, data): RenderData<'_, P>) {
Expand Down

0 comments on commit 5192291

Please sign in to comment.