help window, chat padding, font colours

Former-commit-id: 8d42f8e05cd11f669e4e56873e31a8530272b3b2
This commit is contained in:
Pfauenauge90 2019-04-10 22:23:49 +02:00
parent a45e9e708c
commit bc420e41d6
5 changed files with 52 additions and 50 deletions

View File

@ -3,7 +3,7 @@ use conrod_core::{
input::Key, input::Key,
position::Dimension, position::Dimension,
text::font::Id as FontId, text::font::Id as FontId,
widget::{Id, Button, List, Rectangle, Text, TextEdit}, widget::{Button, Id, List, Rectangle, Text, TextEdit},
widget_ids, Color, Colorable, Positionable, Sizeable, UiCell, Widget, widget_ids, Color, Colorable, Positionable, Sizeable, UiCell, Widget,
}; };
use std::collections::VecDeque; use std::collections::VecDeque;
@ -70,7 +70,12 @@ impl Chat {
fn scroll_to_bottom(&self, ui_widgets: &mut UiCell) { fn scroll_to_bottom(&self, ui_widgets: &mut UiCell) {
ui_widgets.scroll_widget(self.ids.message_box, [0.0, std::f64::MAX]); ui_widgets.scroll_widget(self.ids.message_box, [0.0, std::f64::MAX]);
} }
pub(super) fn update_layout(&mut self, ui_widgets: &mut UiCell, font: FontId, imgs: &super::Imgs) -> Option<String> { pub(super) fn update_layout(
&mut self,
ui_widgets: &mut UiCell,
font: FontId,
imgs: &super::Imgs,
) -> Option<String> {
// Maintain scrolling // Maintain scrolling
if self.new_messages { if self.new_messages {
self.scroll_new_messages(ui_widgets); self.scroll_new_messages(ui_widgets);
@ -81,7 +86,7 @@ impl Chat {
let text_edit = TextEdit::new(&self.input) let text_edit = TextEdit::new(&self.input)
.w(470.0) .w(470.0)
.restrict_to_height(false) .restrict_to_height(false)
.font_size(14) .font_size(15)
.font_id(font) .font_id(font)
.bottom_left_with_margins_on(ui_widgets.window, 10.0, 10.0); .bottom_left_with_margins_on(ui_widgets.window, 10.0, 10.0);
let dims = match ( let dims = match (
@ -102,12 +107,13 @@ impl Chat {
} }
// Message box // Message box
Rectangle::fill([470.0, 180.0]) Rectangle::fill([470.0, 160.0])
.rgba(0.0, 0.0, 0.0, 0.4) .rgba(0.0, 0.0, 0.0, 0.4)
.up_from(self.ids.input, 0.0) .up_from(self.ids.input, 0.0)
.set(self.ids.message_box_bg, ui_widgets); .set(self.ids.message_box_bg, ui_widgets);
let (mut items, scrollbar) = List::flow_down(self.messages.len()) let (mut items, scrollbar) = List::flow_down(self.messages.len())
.middle_of(self.ids.message_box_bg) .top_left_with_margins_on(self.ids.message_box_bg, 0.0, 5.0)
.w_h(460.0, 160.0)
.scrollbar_next_to() .scrollbar_next_to()
.scrollbar_thickness(18.0) .scrollbar_thickness(18.0)
.scrollbar_color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) .scrollbar_color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
@ -115,9 +121,9 @@ impl Chat {
while let Some(item) = items.next(ui_widgets) { while let Some(item) = items.next(ui_widgets) {
item.set( item.set(
Text::new(&self.messages[item.i]) Text::new(&self.messages[item.i])
.font_size(14) .font_size(15)
.font_id(font) .font_id(font)
.rgba(0.86 , 0.86, 0.86, 1.0), .rgba(1.0, 1.0, 1.0, 1.0),
ui_widgets, ui_widgets,
) )
} }

View File

@ -7,11 +7,11 @@ use crate::{
}; };
use common::assets; use common::assets;
use conrod_core::{ use conrod_core::{
color, Color, color,
image::Id as ImgId, image::Id as ImgId,
text::font::Id as FontId, text::font::Id as FontId,
widget::{Button, Image, Rectangle, Scrollbar, Text}, widget::{Button, Image, Rectangle, Scrollbar, Text},
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget,
}; };
widget_ids! { widget_ids! {
@ -459,7 +459,7 @@ impl Hud {
typing: false, typing: false,
cursor_grabbed: true, cursor_grabbed: true,
settings_tab: SettingsTab::Interface, settings_tab: SettingsTab::Interface,
show_help: false, show_help: true,
bag_open: false, bag_open: false,
menu_open: false, menu_open: false,
map_open: false, map_open: false,
@ -479,12 +479,11 @@ impl Hud {
let mut events = Vec::new(); let mut events = Vec::new();
let ref mut ui_widgets = self.ui.set_widgets(); let ref mut ui_widgets = self.ui.set_widgets();
const TEXT_COLOR: Color = Color::Rgba(0.86, 0.86, 0.86, 0.8); const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0); const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0);
const MANA_COLOR: Color = Color::Rgba(0.42, 0.41, 0.66, 1.0); const MANA_COLOR: Color = Color::Rgba(0.42, 0.41, 0.66, 1.0);
const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0); const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0);
if self.show_ui { if self.show_ui {
// Add Bag-Space Button // Add Bag-Space Button
if self.inventorytest_button { if self.inventorytest_button {
@ -512,7 +511,7 @@ impl Hud {
if self.show_help { if self.show_help {
Image::new(self.imgs.window_frame_2) Image::new(self.imgs.window_frame_2)
.top_left_with_margins_on(ui_widgets.window, 5.0, 5.0) .top_left_with_margins_on(ui_widgets.window, 5.0, 5.0)
.w_h(300.0, 300.0) .w_h(300.0, 370.0)
.set(self.ids.help_bg, ui_widgets); .set(self.ids.help_bg, ui_widgets);
Text::new( Text::new(
@ -523,6 +522,9 @@ impl Hud {
F1 = Toggle this Window \n\ F1 = Toggle this Window \n\
F2 = Toggle Interface \n\ F2 = Toggle Interface \n\
\n\ \n\
Enter = Open Chat \n\
Mouse Wheel = Scroll Chat\n\
\n\
M = Map \n\ M = Map \n\
B = Bag \n\ B = Bag \n\
L = Quest-Log \n\ L = Quest-Log \n\
@ -753,7 +755,6 @@ impl Hud {
.top_right_with_margins_on(self.ids.health_bar, 5.0, 0.0) .top_right_with_margins_on(self.ids.health_bar, 5.0, 0.0)
.set(self.ids.health_bar_color, ui_widgets); .set(self.ids.health_bar_color, ui_widgets);
// Mana Bar // Mana Bar
Image::new(self.imgs.mana_bar) Image::new(self.imgs.mana_bar)
.w_h(1120.0 / 6.0, 96.0 / 6.0) .w_h(1120.0 / 6.0, 96.0 / 6.0)
@ -766,7 +767,6 @@ impl Hud {
.top_left_with_margins_on(self.ids.mana_bar, 5.0, 0.0) .top_left_with_margins_on(self.ids.mana_bar, 5.0, 0.0)
.set(self.ids.mana_bar_color, ui_widgets); .set(self.ids.mana_bar_color, ui_widgets);
// Buffs/Debuffs // Buffs/Debuffs
// Buffs // Buffs
@ -778,14 +778,14 @@ impl Hud {
// Insert actual Level here // Insert actual Level here
Text::new("1") Text::new("1")
.left_from(self.ids.xp_bar, -15.0) .left_from(self.ids.xp_bar, -15.0)
.font_size(14) .font_size(10)
.color(TEXT_COLOR) .color(TEXT_COLOR)
.set(self.ids.level_text, ui_widgets); .set(self.ids.level_text, ui_widgets);
// Insert next Level here // Insert next Level here
Text::new("2") Text::new("2")
.right_from(self.ids.xp_bar, -15.0) .right_from(self.ids.xp_bar, -15.0)
.font_size(14) .font_size(10)
.color(TEXT_COLOR) .color(TEXT_COLOR)
.set(self.ids.next_level_text, ui_widgets); .set(self.ids.next_level_text, ui_widgets);

View File

@ -345,7 +345,7 @@ pub enum Event {
Play, Play,
} }
const TEXT_COLOR: Color = Color::Rgba(0.86, 0.86, 0.86, 0.8); const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
pub struct CharSelectionUi { pub struct CharSelectionUi {
ui: Ui, ui: Ui,
@ -495,7 +495,6 @@ impl CharSelectionUi {
.color(TEXT_COLOR) .color(TEXT_COLOR)
.set(self.ids.char_level, ui_widgets); .set(self.ids.char_level, ui_widgets);
// Selected Character // Selected Character
if no == 1 { if no == 1 {
Image::new(self.imgs.test_char_l_big) Image::new(self.imgs.test_char_l_big)

View File

@ -6,10 +6,7 @@ use crate::{
GlobalState, PlayState, PlayStateResult, GlobalState, PlayState, PlayStateResult,
}; };
use client::{self, Client}; use client::{self, Client};
use common::{ use common::clock::Clock;
comp,
clock::Clock,
};
use std::time::Duration; use std::time::Duration;
use ui::{Event as MainMenuEvent, MainMenuUi}; use ui::{Event as MainMenuEvent, MainMenuUi};
use vek::*; use vek::*;
@ -70,12 +67,12 @@ impl PlayState for MainMenuState {
Ok(mut socket_adders) => { Ok(mut socket_adders) => {
while let Some(socket_addr) = socket_adders.next() { while let Some(socket_addr) = socket_adders.next() {
// TODO: handle error // TODO: handle error
match Client::new(socket_addr, comp::Player::new(username.clone()), Some(comp::Character::test())) { match Client::new(socket_addr) {
Ok(client) => { Ok(client) => {
return PlayStateResult::Push( return PlayStateResult::Push(
Box::new(CharSelectionState::new( Box::new(CharSelectionState::new(
&mut global_state.window, &mut global_state.window,
std::rc::Rc::new(std::cell::RefCell::new(client)) // <--- TODO: Remove this std::rc::Rc::new(std::cell::RefCell::new(client.with_test_state())) // <--- TODO: Remove this
)) ))
); );
} }

View File

@ -169,7 +169,7 @@ impl MainMenuUi {
}); });
}; };
} }
const TEXT_COLOR: Color = Color::Rgba(0.94, 0.94, 0.94, 0.8); const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
// Username // Username
// TODO: get a lower resolution and cleaner input_bg.png // TODO: get a lower resolution and cleaner input_bg.png
Image::new(self.imgs.input_bg) Image::new(self.imgs.input_bg)
@ -249,7 +249,7 @@ impl MainMenuUi {
.align_middle_x_of(self.ids.address_bg) .align_middle_x_of(self.ids.address_bg)
.label("Login") .label("Login")
.label_color(TEXT_COLOR) .label_color(TEXT_COLOR)
.label_font_size(28) .label_font_size(26)
.label_y(conrod_core::position::Relative::Scalar(5.0)) .label_y(conrod_core::position::Relative::Scalar(5.0))
.set(self.ids.login_button, ui_widgets) .set(self.ids.login_button, ui_widgets)
.was_clicked() .was_clicked()