mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
separate implementation code from generic UI code
Former-commit-id: 9c77ca03c4d834188ef863645ab2c26f31763b6c
This commit is contained in:
parent
3f052cae1c
commit
e68fa6b579
@ -1 +1,3 @@
|
||||
pub mod title;
|
||||
mod title_ui;
|
||||
pub mod test_hud;
|
||||
|
@ -1,3 +1,5 @@
|
||||
// TODO: figure out where exactly this code should be located
|
||||
|
||||
// Library
|
||||
use conrod_core::{
|
||||
Positionable,
|
||||
@ -18,11 +20,9 @@ use conrod_core::{
|
||||
use crate::{
|
||||
window::Window,
|
||||
render::Renderer,
|
||||
ui::Ui,
|
||||
};
|
||||
|
||||
// Local
|
||||
use super::Ui;
|
||||
|
||||
widget_ids!{
|
||||
struct Ids {
|
||||
menu_buttons[],
|
||||
@ -71,14 +71,14 @@ impl Imgs {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestUi {
|
||||
pub struct TestHud {
|
||||
ui: Ui,
|
||||
ids: Ids,
|
||||
imgs: Imgs,
|
||||
bag_open: bool,
|
||||
}
|
||||
|
||||
impl TestUi {
|
||||
impl TestHud {
|
||||
pub fn new(window: &mut Window) -> Self {
|
||||
let mut ui = Ui::new(window).unwrap();
|
||||
// Generate ids
|
@ -13,9 +13,10 @@ use crate::{
|
||||
Window,
|
||||
},
|
||||
session::SessionState,
|
||||
ui::title::TitleUi,
|
||||
};
|
||||
|
||||
// Local
|
||||
use super::title_ui::TitleUi;
|
||||
|
||||
pub struct TitleState {
|
||||
title_ui: TitleUi,
|
||||
|
@ -16,11 +16,9 @@ use conrod_core::{
|
||||
use crate::{
|
||||
window::Window,
|
||||
render::Renderer,
|
||||
ui::Ui
|
||||
};
|
||||
|
||||
// Local
|
||||
use super::Ui;
|
||||
|
||||
pub struct TitleUi {
|
||||
ui: Ui,
|
||||
widget_id: WidgId,
|
@ -21,7 +21,7 @@ use crate::{
|
||||
window::{Event, Key, Window},
|
||||
render::Renderer,
|
||||
scene::Scene,
|
||||
ui::test::TestUi,
|
||||
menu::test_hud::TestHud,
|
||||
};
|
||||
|
||||
const FPS: u64 = 60;
|
||||
@ -31,7 +31,7 @@ pub struct SessionState {
|
||||
client: Client,
|
||||
key_state: KeyState,
|
||||
// TODO: remove this
|
||||
test_ui: TestUi,
|
||||
test_hud: TestHud,
|
||||
}
|
||||
|
||||
/// Represents an active game session (i.e: one that is being played)
|
||||
@ -44,7 +44,7 @@ impl SessionState {
|
||||
scene: Scene::new(window.renderer_mut(), &client),
|
||||
client,
|
||||
key_state: KeyState::new(),
|
||||
test_ui: TestUi::new(window),
|
||||
test_hud: TestHud::new(window),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -83,7 +83,7 @@ impl SessionState {
|
||||
// Render the screen using the global renderer
|
||||
self.scene.render_to(renderer);
|
||||
// Draw the UI to the screen
|
||||
self.test_ui.render(renderer);
|
||||
self.test_hud.render(renderer);
|
||||
|
||||
// Finish the frame
|
||||
renderer.flush();
|
||||
@ -131,7 +131,7 @@ impl PlayState for SessionState {
|
||||
Event::KeyUp(Key::MoveRight) => self.key_state.right = false,
|
||||
// Pass events to ui
|
||||
Event::UiEvent(input) => {
|
||||
self.test_ui.handle_event(input);
|
||||
self.test_hud.handle_event(input);
|
||||
}
|
||||
// Pass all other events to the scene
|
||||
event => { self.scene.handle_input_event(event); },
|
||||
@ -146,7 +146,7 @@ impl PlayState for SessionState {
|
||||
// Maintain the scene
|
||||
self.scene.maintain(global_state.window.renderer_mut(), &self.client);
|
||||
// Maintain the UI
|
||||
self.test_ui.maintain(global_state.window.renderer_mut());
|
||||
self.test_hud.maintain(global_state.window.renderer_mut());
|
||||
|
||||
// Render the session
|
||||
self.render(global_state.window.renderer_mut());
|
||||
|
@ -1,5 +1,3 @@
|
||||
pub mod title;
|
||||
pub mod test;
|
||||
// TODO: cache entire UI render (would be somewhat pointless if we are planning on constantly animated ui)
|
||||
// TODO: figure out proper way to propagate events down to the ui
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user