diff --git a/assets/fonts/open_sans_light.ttf b/assets/fonts/open_sans_light.ttf new file mode 100644 index 0000000..d9a9e27 Binary files /dev/null and b/assets/fonts/open_sans_light.ttf differ diff --git a/assets/fonts/open_sans_medium.ttf b/assets/fonts/open_sans_medium.ttf new file mode 100644 index 0000000..ba6db9b Binary files /dev/null and b/assets/fonts/open_sans_medium.ttf differ diff --git a/assets/fonts/venice_classic.ttf b/assets/fonts/venice_classic.ttf new file mode 100644 index 0000000..03731dd Binary files /dev/null and b/assets/fonts/venice_classic.ttf differ diff --git a/licenses/open_sans/OFL.txt b/licenses/open_sans/OFL.txt new file mode 100644 index 0000000..9b448d4 --- /dev/null +++ b/licenses/open_sans/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/licenses/open_sans/README.txt b/licenses/open_sans/README.txt new file mode 100644 index 0000000..d0ad790 --- /dev/null +++ b/licenses/open_sans/README.txt @@ -0,0 +1,100 @@ +Open Sans Variable Font +======================= + +This download contains Open Sans as both variable fonts and static fonts. + +Open Sans is a variable font with these axes: + wdth + wght + +This means all the styles are contained in these files: + OpenSans-VariableFont_wdth,wght.ttf + OpenSans-Italic-VariableFont_wdth,wght.ttf + +If your app fully supports variable fonts, you can now pick intermediate styles +that aren’t available as static fonts. Not all apps support variable fonts, and +in those cases you can use the static font files for Open Sans: + static/OpenSans_Condensed/OpenSans_Condensed-Light.ttf + static/OpenSans_Condensed/OpenSans_Condensed-Regular.ttf + static/OpenSans_Condensed/OpenSans_Condensed-Medium.ttf + static/OpenSans_Condensed/OpenSans_Condensed-SemiBold.ttf + static/OpenSans_Condensed/OpenSans_Condensed-Bold.ttf + static/OpenSans_Condensed/OpenSans_Condensed-ExtraBold.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Light.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Regular.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Medium.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBold.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Bold.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBold.ttf + static/OpenSans/OpenSans-Light.ttf + static/OpenSans/OpenSans-Regular.ttf + static/OpenSans/OpenSans-Medium.ttf + static/OpenSans/OpenSans-SemiBold.ttf + static/OpenSans/OpenSans-Bold.ttf + static/OpenSans/OpenSans-ExtraBold.ttf + static/OpenSans_Condensed/OpenSans_Condensed-LightItalic.ttf + static/OpenSans_Condensed/OpenSans_Condensed-Italic.ttf + static/OpenSans_Condensed/OpenSans_Condensed-MediumItalic.ttf + static/OpenSans_Condensed/OpenSans_Condensed-SemiBoldItalic.ttf + static/OpenSans_Condensed/OpenSans_Condensed-BoldItalic.ttf + static/OpenSans_Condensed/OpenSans_Condensed-ExtraBoldItalic.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-LightItalic.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Italic.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-MediumItalic.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBoldItalic.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-BoldItalic.ttf + static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBoldItalic.ttf + static/OpenSans/OpenSans-LightItalic.ttf + static/OpenSans/OpenSans-Italic.ttf + static/OpenSans/OpenSans-MediumItalic.ttf + static/OpenSans/OpenSans-SemiBoldItalic.ttf + static/OpenSans/OpenSans-BoldItalic.ttf + static/OpenSans/OpenSans-ExtraBoldItalic.ttf + +Get started +----------- + +1. Install the font files you want to use + +2. Use your app's font picker to view the font family and all the +available styles + +Learn more about variable fonts +------------------------------- + + https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts + https://variablefonts.typenetwork.com + https://medium.com/variable-fonts + +In desktop apps + + https://theblog.adobe.com/can-variable-fonts-illustrator-cc + https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts + +Online + + https://developers.google.com/fonts/docs/getting_started + https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide + https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts + +Installing fonts + + MacOS: https://support.apple.com/en-us/HT201749 + Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux + Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows + +Android Apps + + https://developers.google.com/fonts/docs/android + https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts + +License +------- +Please read the full license text (OFL.txt) to understand the permissions, +restrictions and requirements for usage, redistribution, and modification. + +You can use them in your products & projects – print or digital, +commercial or otherwise. + +This isn't legal advice, please consider consulting a lawyer and see the full +license for all details. diff --git a/licenses/venice_classic/readme.txt b/licenses/venice_classic/readme.txt new file mode 100644 index 0000000..4eb0da3 --- /dev/null +++ b/licenses/venice_classic/readme.txt @@ -0,0 +1,25 @@ +Venice Classic +by soixantedeux +28 December 2006 + + This font is free. It may not be resold for profit; however, it may be +redistributed and sold at cost of redistribution. Distribute this font freely, +on the condition that this notice remain with it unmodified. The font, however, +may be modified on the condition that it is distributed under the same +conditions as above. + + This is a hand-made TrueType version of the out-of-use Apple bitmap font +"Venice." I didn't make the original font; I did, however, make this font, +which is based very heavily on the original font. + + If you like this font, feel free to let me know! My website, which contains +other things I've done, is located at http://www.soixantedeux.co.nr/, or if +that doesn't work, http://www.freewebtown.com/62/. If you have any questions +regarding this font, contact me. Also, if you use this font somewhere and +you're particularly proud of the way you used it, don't hesitate to let me +know. :) I'm interested in what will happen to this font after I put it up for +download on my website. + + Thanks for downloading Venice! + + soixantedeux \ No newline at end of file diff --git a/src/game.rs b/src/game.rs index 10aa043..5e61c60 100644 --- a/src/game.rs +++ b/src/game.rs @@ -21,6 +21,7 @@ pub fn init(app: &mut App) { app.register_type::() .register_type::() .register_type::() + .register_type::() .register_type::() .register_type::() .register_type::() @@ -32,17 +33,21 @@ pub fn init(app: &mut App) { .add_systems( Update, ( + (systems::spawn_items,), ( systems::demo_2d, - systems::work_select, systems::worker_movement, - systems::spawn_items, + systems::change_inventory_ui_font, ), + (systems::work_select,), (systems::do_work,), - (systems::apply_task_result,), + (systems::apply_work_result,), ) .chain(), ) - .add_systems(PostUpdate, item::update_item_sprite) + .add_systems( + PostUpdate, + (systems::update_item_sprite, systems::update_inventory_ui), + ) .add_systems(Update, (systems::draw_job_targets).in_set(debug::DebugSet)); } diff --git a/src/game/item.rs b/src/game/item.rs index b283d97..57ee6a7 100644 --- a/src/game/item.rs +++ b/src/game/item.rs @@ -40,6 +40,12 @@ pub struct ItemSource { pub gather_limit: Option, } +/// Flag component that tells the UI to update according to the inventory contents +#[derive(Clone, Debug, Default, Component, Reflect)] +#[reflect(Component)] +#[require(Text2d)] +pub struct InventoryUi; + #[derive(Clone, Debug, Default, Component, Reflect, PartialEq, Eq)] #[reflect(Component)] pub struct Inventory { @@ -215,19 +221,6 @@ impl Inventory { #[require(Inventory)] pub struct Stockpile; -pub fn update_item_sprite( - mut query: Query<(&mut Sprite, &Item), Changed>, - assets: Res, -) { - for (mut sprite, item) in query.iter_mut() { - sprite.image = assets.load(match item { - Item::Wood => "sprites/wood.png", - Item::Stone => "sprites/stone.png", - // _ => "sprites/missing.png", - }); - } -} - #[derive(Event, Clone, Debug)] pub struct SpawnItem { pub item: Item, diff --git a/src/game/prefab.rs b/src/game/prefab.rs index 6998893..18d6e7d 100644 --- a/src/game/prefab.rs +++ b/src/game/prefab.rs @@ -1,7 +1,7 @@ use bevy::{prelude::*, sprite::Anchor}; use bevy_rapier2d::prelude::*; use creature::{Mover, WeightSlowdown}; -use item::{Inventory, Item, ItemSource, ItemStack, Stockpile}; +use item::{Inventory, InventoryUi, Item, ItemSource, ItemStack, Stockpile}; use work::{WorkDuration, Worker}; use super::*; @@ -18,6 +18,7 @@ use crate::util::SpriteLoader; SpriteLoader(|| SpriteLoader::from("sprites/glorb.png")), Worker, Inventory(|| Inventory::with_capacity(1)), + InventoryUi, WeightSlowdown(|| WeightSlowdown { halfpoint: 50.0 }), RigidBody(|| RigidBody::KinematicPositionBased), Mover, @@ -48,6 +49,7 @@ pub struct Tree; }), SpriteLoader(|| SpriteLoader::from("sprites/box.png")), Inventory, + InventoryUi, Stockpile, )] pub struct Chest; diff --git a/src/game/systems.rs b/src/game/systems.rs index d347879..ca76bce 100644 --- a/src/game/systems.rs +++ b/src/game/systems.rs @@ -1,9 +1,11 @@ mod creature; mod demo; mod item; +mod ui; mod worker; pub use creature::*; pub use demo::*; pub use item::*; +pub use ui::*; pub use worker::*; diff --git a/src/game/systems/item.rs b/src/game/systems/item.rs index a4516a5..66228ad 100644 --- a/src/game/systems/item.rs +++ b/src/game/systems/item.rs @@ -1,7 +1,23 @@ use bevy::prelude::*; use bevy_rapier2d::prelude::{Damping, RigidBody, Velocity}; -use crate::game::{item::SpawnItem, work::WorkDuration}; +use crate::game::{ + item::{Item, SpawnItem}, + work::WorkDuration, +}; + +pub fn update_item_sprite( + mut query: Query<(&mut Sprite, &Item), Changed>, + assets: Res, +) { + for (mut sprite, item) in query.iter_mut() { + sprite.image = assets.load(match item { + Item::Wood => "sprites/wood.png", + Item::Stone => "sprites/stone.png", + // _ => "sprites/missing.png", + }); + } +} pub fn spawn_items(mut spawn_item_events: EventReader, mut commands: Commands) { for event in spawn_item_events.read() { diff --git a/src/game/systems/ui.rs b/src/game/systems/ui.rs new file mode 100644 index 0000000..48543a8 --- /dev/null +++ b/src/game/systems/ui.rs @@ -0,0 +1,35 @@ +use bevy::prelude::*; + +use crate::game::item::{Inventory, InventoryUi}; + +pub fn change_inventory_ui_font( + assets: Res, + mut inventory_ui_added: Query<&mut TextFont, Added>, + mut font: Local>>, +) { + for mut text_font in inventory_ui_added.iter_mut() { + if font.is_none() { + *font = Some(assets.load("fonts/venice_classic.ttf")); + } + if let Some(font) = font.as_ref() { + text_font.font = font.clone(); + } + } +} + +pub fn update_inventory_ui( + mut inventory_changed: Query< + (&mut Text2d, &Inventory), + (Changed, With), + >, +) { + for (mut text_2d, inventory) in inventory_changed.iter_mut() { + let new_string = inventory + .items + .iter() + .map(|stack| format!("{:?}: {}", stack.item, stack.count)) + .collect::>() + .join("\n"); + text_2d.0 = new_string; + } +} diff --git a/src/game/systems/worker.rs b/src/game/systems/worker.rs index b571a7e..0da882f 100644 --- a/src/game/systems/worker.rs +++ b/src/game/systems/worker.rs @@ -190,7 +190,7 @@ pub fn do_work( } } -pub fn apply_task_result( +pub fn apply_work_result( mut commands: Commands, mut spawn_item: EventWriter, mut on_task_finish: EventReader,