Skip to content

Commit

Permalink
proof that UI can work
Browse files Browse the repository at this point in the history
  • Loading branch information
ezpuzz committed Dec 25, 2020
1 parent 104fdca commit 2a9324d
Show file tree
Hide file tree
Showing 12 changed files with 623 additions and 565 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ serde-diff = { git = "https://github.com/amethyst/serde-diff", branch = "v0.4.0"

[features]
default = ["parallel", "renderer"]
optional = ["audio", "network", "locale", "ui"]
optional = ["audio", "network", "locale", "ui", "utils"]

vulkan = ["amethyst_rendy/vulkan"]
metal = ["amethyst_rendy/metal"]
Expand All @@ -41,6 +41,7 @@ audio = ["amethyst_audio"]
#gltf = ["amethyst_gltf", "amethyst_animation"]
locale = ["amethyst_locale"]
network = ["amethyst_network"]
utils = ["amethyst_utils"]

renderer = ["amethyst_rendy"]

Expand Down Expand Up @@ -95,7 +96,7 @@ amethyst_locale = { path = "amethyst_locale", version = "0.15.3", optional = tru
amethyst_rendy = { path = "amethyst_rendy", version = "0.15.3", features = ["window"], optional = true }
amethyst_input = { path = "amethyst_input", version = "0.15.3" }
amethyst_ui = { path = "amethyst_ui", version = "0.15.3", optional = true }
amethyst_utils = { path = "amethyst_utils", version = "0.15.3" }
amethyst_utils = { path = "amethyst_utils", version = "0.15.3", optional = true }
amethyst_window = { path = "amethyst_window", version = "0.15.3" }
#amethyst_tiles = { path = "amethyst_tiles", version = "0.15.3", optional = true }
winit = { git = "https://[email protected]/rust-windowing/winit", rev = "38fccebe1fbc4226c75d6180e5317bd93c024951", features = ["serde"] }
Expand Down
5 changes: 4 additions & 1 deletion amethyst_assets/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ pub struct LoaderWithStorage {
ref_sender: Sender<RefOp>,
ref_receiver: Receiver<RefOp>,
handle_allocator: Arc<AtomicHandleAllocator>,
indirection_table: IndirectionTable,
pub indirection_table: IndirectionTable,
}

impl LoaderWithStorage {}

impl Default for LoaderWithStorage {
fn default() -> Self {
let (tx, rx) = unbounded();
Expand Down Expand Up @@ -509,6 +511,7 @@ where
for<'a> Intermediate: 'static + Deserialize<'a> + TypeUuid + Send,
ProcessorSystem: System<'static> + Default + 'static,
{
log::debug!("Creating asset type: {:x?}", Asset::UUID);
AssetType {
data_uuid: AssetTypeId(Intermediate::UUID),
asset_uuid: AssetTypeId(Asset::UUID),
Expand Down
1 change: 1 addition & 0 deletions amethyst_core/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl<'a> DispatcherBuilder {
/// Adds a system to the schedule.
pub fn add_system<S: System<'a> + 'a>(&mut self, system: Box<S>) -> &mut Self {
let s: &'a mut S = Box::leak(system);
log::debug!("Building system");
self.items.push(DispatcherItem::System(s.build()));
self
}
Expand Down
3 changes: 0 additions & 3 deletions amethyst_rendy/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ impl<B: Backend> SystemBundle for RenderingBundle<B> {
) -> Result<(), Error> {
resources.insert(ActiveCamera::default());

// TODO: make sure that all renderer-specific systems run after game code
//builder.flush(); TODO: flush legion here?

for plugin in &mut self.plugins {
plugin.on_build(world, resources, builder)?;
}
Expand Down
27 changes: 25 additions & 2 deletions amethyst_ui/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
use std::marker::PhantomData;

use amethyst_assets::{AssetProcessorSystem, AssetStorage, DefaultLoader, ProcessingQueue};
use amethyst_core::{ecs::*, shrev::EventChannel};
use amethyst_error::Error;
use amethyst_rendy::types::DefaultBackend;
use derive_new::new;
use winit::event::Event;

use crate::{
button::{ui_button_action_retrigger_event_system, UiButtonSystem},
drag::DragWidgetSystem,
event::UiMouseSystem,
format::FontData,
glyphs::{GlyphTextureData, GlyphTextureProcessorSystem},
layout::UiTransformSystem,
resize::ResizeSystem,
selection::{SelectionKeyboardSystem, SelectionMouseSystem},
selection_order_cache::CacheSelectionSystem,
sound::{ui_sound_event_retrigger_system, UiSoundSystem},
text::TextEditingMouseSystem,
text_editing::TextEditingInputSystem,
BlinkSystem, CachedSelectionOrderResource, UiButtonAction, UiEvent, UiLabel, UiPlaySoundAction,
WidgetId, Widgets,
BlinkSystem, CachedSelectionOrderResource, FontAsset, UiButtonAction, UiEvent, UiLabel,
UiPlaySoundAction, WidgetId, Widgets,
};

/// UI bundle
Expand All @@ -46,11 +50,28 @@ where
resources: &mut Resources,
builder: &mut DispatcherBuilder,
) -> Result<(), Error> {
log::debug!("Adding UI Resources");
resources.insert(EventChannel::<UiButtonAction>::new());
resources.insert(EventChannel::<UiEvent>::new());
resources.insert(Widgets::<UiLabel, W>::new());
resources.insert(CachedSelectionOrderResource::default());

resources.insert(ProcessingQueue::<FontData>::default());
let storage = {
let loader = resources.get::<DefaultLoader>().unwrap();

AssetStorage::<FontAsset>::new(loader.indirection_table.clone())
};
builder.add_system(Box::new(AssetProcessorSystem::<FontAsset>::default()));

resources.insert(ProcessingQueue::<GlyphTextureData>::default());
builder.add_system(Box::new(
GlyphTextureProcessorSystem::<DefaultBackend>::default(),
));

resources.insert(storage);

log::debug!("Creating UI EventChannel Readers");
let ui_btn_reader = resources
.get_mut::<EventChannel<UiButtonAction>>()
.unwrap()
Expand Down Expand Up @@ -83,6 +104,8 @@ where
.get_mut::<EventChannel<UiEvent>>()
.unwrap()
.register_reader();

log::debug!("Adding UI Systems to Dispatcher");
builder
.add_system(Box::new(UiTransformSystem::new()))
.add_system(Box::new(UiMouseSystem::new()))
Expand Down
2 changes: 1 addition & 1 deletion amethyst_ui/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use amethyst_assets::{Asset, Format, Handle, ProcessableAsset, ProcessingState};
use amethyst_assets::{Asset, Format, ProcessableAsset, ProcessingState};
use amethyst_error::{format_err, Error, ResultExt};
use glyph_brush::rusttype::Font;
use serde::{Deserialize, Serialize};
Expand Down
Loading

0 comments on commit 2a9324d

Please sign in to comment.