Minor changes
This commit is contained in:
parent
fcacd91e3a
commit
8a2c24796c
|
@ -68,7 +68,7 @@ fn main() {
|
|||
let frame_time = (time::Duration::seconds(1).num_nanoseconds().unwrap() as f64) / 60.0;
|
||||
|
||||
let mut screen_sys = screen::ScreenSystem::new();
|
||||
screen_sys.add_screen(Box::new(screen::ServerList::new(None)));
|
||||
screen_sys.add_screen(Box::new(screen::Login::new()));
|
||||
|
||||
while !window.should_close() {
|
||||
{ resource_manager.write().unwrap().tick(); }
|
||||
|
|
|
@ -32,7 +32,7 @@ use flate2::read::{ZlibDecoder, ZlibEncoder};
|
|||
use flate2;
|
||||
use time;
|
||||
|
||||
pub const SUPPORTED_PROTOCOL: i32 = 73;
|
||||
pub const SUPPORTED_PROTOCOL: i32 = 74;
|
||||
|
||||
/// Helper macro for defining packets
|
||||
#[macro_export]
|
||||
|
@ -647,7 +647,7 @@ pub struct Conn {
|
|||
cipher: Option<openssl::EVPCipher>,
|
||||
|
||||
compression_threshold: i32,
|
||||
compression_read: Option<ZlibDecoder<io::Cursor<Vec<u8>>>>, // Pending reset support
|
||||
compression_read: Option<ZlibDecoder<io::Cursor<Vec<u8>>>>,
|
||||
compression_write: Option<ZlibEncoder<io::Cursor<Vec<u8>>>>,
|
||||
}
|
||||
|
||||
|
@ -890,7 +890,7 @@ impl Clone for Conn {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait PacketType {
|
||||
pub trait PacketType: Sized {
|
||||
fn packet_id(&self) -> i32;
|
||||
|
||||
fn write(self, buf: &mut io::Write) -> Result<(), io::Error>;
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
use std::fs;
|
||||
use std::thread;
|
||||
use std::sync::mpsc;
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use ui;
|
||||
use render;
|
||||
use format;
|
||||
use format::{Component, TextComponent};
|
||||
use protocol;
|
||||
|
||||
use serde_json;
|
||||
use time;
|
||||
use image;
|
||||
use rustc_serialize::base64::FromBase64;
|
||||
use rand;
|
||||
use rand::{Rng};
|
||||
|
||||
pub struct Login {
|
||||
elements: Option<UIElements>,
|
||||
}
|
||||
|
||||
struct UIElements {
|
||||
logo: ui::logo::Logo,
|
||||
elements: ui::Collection,
|
||||
}
|
||||
|
||||
|
||||
impl Login {
|
||||
pub fn new() -> Login {
|
||||
Login {
|
||||
elements: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl super::Screen for Login {
|
||||
fn on_active(&mut self, renderer: &mut render::Renderer, ui_container: &mut ui::Container) {
|
||||
let logo = ui::logo::Logo::new(renderer.resources.clone(), renderer, ui_container);
|
||||
let mut elements = ui::Collection::new();
|
||||
|
||||
// Disclaimer
|
||||
let mut warn = ui::Text::new(renderer, "Not affiliated with Mojang/Minecraft", 5.0, 5.0, 255, 200, 200);
|
||||
warn.set_v_attach(ui::VAttach::Bottom);
|
||||
warn.set_h_attach(ui::HAttach::Right);
|
||||
elements.add(ui_container.add(warn));
|
||||
|
||||
self.elements = Some(UIElements {
|
||||
logo: logo,
|
||||
elements: elements,
|
||||
});
|
||||
}
|
||||
fn on_deactive(&mut self, _renderer: &mut render::Renderer, ui_container: &mut ui::Container) {
|
||||
// Clean up
|
||||
{
|
||||
let elements = self.elements.as_mut().unwrap();
|
||||
elements.logo.remove(ui_container);
|
||||
elements.elements.remove_all(ui_container);
|
||||
}
|
||||
self.elements = None
|
||||
}
|
||||
|
||||
fn tick(&mut self, delta: f64, renderer: &mut render::Renderer, ui_container: &mut ui::Container) {
|
||||
let elements = self.elements.as_mut().unwrap();
|
||||
|
||||
elements.logo.tick(renderer, ui_container);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
mod server_list;
|
||||
pub use self::server_list::*;
|
||||
mod login;
|
||||
pub use self::login::*;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ impl ServerList {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
send.send(PingInfo {
|
||||
drop(send.send(PingInfo {
|
||||
motd: desc,
|
||||
ping: res.1,
|
||||
exists: true,
|
||||
|
@ -236,13 +236,13 @@ impl ServerList {
|
|||
protocol_version: res.0.version.protocol,
|
||||
protocol_name: res.0.version.name,
|
||||
favicon: favicon,
|
||||
}).unwrap();
|
||||
}));
|
||||
},
|
||||
Err(err) => {
|
||||
let e = format!("{}", err);
|
||||
let mut msg = TextComponent::new(&e);
|
||||
msg.modifier.color = Some(format::Color::Red);
|
||||
send.send(PingInfo {
|
||||
drop(send.send(PingInfo {
|
||||
motd: Component::Text(msg),
|
||||
ping: time::Duration::seconds(99999),
|
||||
exists: false,
|
||||
|
@ -251,7 +251,7 @@ impl ServerList {
|
|||
protocol_version: 0,
|
||||
protocol_name: "".to_owned(),
|
||||
favicon: None,
|
||||
}).unwrap();
|
||||
}));
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
@ -333,7 +333,7 @@ impl Container {
|
|||
self.version = renderer.ui.version;
|
||||
}
|
||||
|
||||
// Borrow rules seems to prevent us from doing this in the first pass
|
||||
// Borrow rules seem to prevent us from doing this in the first pass
|
||||
// so we split it.
|
||||
let regions = self.collect_elements(sw, sh);
|
||||
for re in &self.elements_list {
|
||||
|
|
Loading…
Reference in New Issue