Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release prep #223

Merged
merged 1 commit into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kayak_ui"
description = "A UI library built using the bevy game engine!"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
resolver = "2"
authors = ["John Mitchell"]
Expand All @@ -19,9 +19,9 @@ members = ["kayak_ui_macros", "kayak_font"]
bevy = { version = "0.10", default-features = false, features = ["bevy_render", "bevy_asset", "bevy_winit", "bevy_core_pipeline", "bevy_ui"] }
bytemuck = "1.12"
dashmap = "5.4"
kayak_font = { path = "./kayak_font", version = "0.2" }
kayak_font = { path = "./kayak_font", version = "0.3" }
morphorm = "0.3"
kayak_ui_macros = { path = "./kayak_ui_macros", version = "0.2" }
kayak_ui_macros = { path = "./kayak_ui_macros", version = "0.3" }
indexmap = "1.9"
log = "0.4"
bitflags = "1.3.2"
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Kayak UI is in the very early stages of development. Important features are miss
- Custom UI node to ensure UI renders on top of 3D and 2D entities.
- Fully integrated into bevy to capture input events, use bevy assets(images, etc).
- Dpi Scaling
- Batched Rendering

## Missing features
- More default widgets.
Expand All @@ -44,16 +45,17 @@ Kayak UI is in the very early stages of development. Important features are miss
<img src="images/screen1.png" alt="Kayak UI" width="600" />

## Usage
Use bevy `0.9`! Make sure the version of Kayak you are using uses the same version of bevy.
Use bevy `0.10`! Make sure the version of Kayak you are using uses the same version of bevy.

```rust
kayak_ui = "0.2"
bevy = "0.9"
bevy = "0.10"
```

|bevy|kayak_ui|
|---|---|
|`main`|`bevy-track`|
|0.10|0.3|
|0.9|0.2|
|0.9|0.1|

Expand Down
47 changes: 28 additions & 19 deletions book/src/chapter_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,50 @@ Once you've added Kayak UI to your bevy project you can now start to use it! In
Hello World Example:
```rust
use bevy::prelude::*;
use kayak_ui::prelude::{widgets::*, *};
use kayak_ui::{
prelude::{widgets::*, *},
CameraUIKayak,
};

fn startup(
mut commands: Commands,
mut font_mapping: ResMut<FontMapping>,
asset_server: Res<AssetServer>,
) {
font_mapping.set_default(asset_server.load("roboto.kayak_font"));
let camera_entity = commands
.spawn(Camera2dBundle::default())
.insert(CameraUIKayak)
.id();

font_mapping.set_default(asset_server.load("roboto.kttf"));

let mut widget_context = KayakRootContext::new();
let mut widget_context = KayakRootContext::new(camera_entity);
widget_context.add_plugin(KayakWidgetsContextPlugin);
let parent_id = None;

// The rsx! macro expects a parent_id, a widget_context from the user.
// It also expects `Commands` from bevy.
// This can be a little weird at first.
// See the rsx! docs for more info!
rsx! {
<KayakAppBundle>
<TextWidgetBundle
text={TextProps {
content: "Hello World".into(),
size: 20.0,
..Default::default()
}}
/>
</KayakAppBundle>
};
commands.spawn(UICameraBundle::new(widget_context));

commands.spawn((widget_context, EventDispatcher::default()));
}

fn main() {
App::new()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins(DefaultPlugins)
.add_plugin(KayakContextPlugin)
.add_plugin(KayakWidgets)
.add_startup_system(startup)
.run()
}

```

## Wait where is the ECS?
Expand All @@ -64,11 +69,16 @@ fn startup(
mut font_mapping: ResMut<FontMapping>,
asset_server: Res<AssetServer>,
) {
font_mapping.set_default(asset_server.load("roboto.kayak_font"));
commands.spawn(UICameraBundle::new());
let mut widget_context = KayakRootContext::new();
let camera_entity = commands
.spawn(Camera2dBundle::default())
.insert(CameraUIKayak)
.id();

font_mapping.set_default(asset_server.load("roboto.kttf"));
let mut widget_context = KayakRootContext::new(camera_entity);
widget_context.add_plugin(KayakWidgetsContextPlugin);

let app_entity = widget_context.spawn_widget(&mut commands, None);
let app_entity = widget_context.spawn_widget(&mut commands, None, None);
// Create default app bundle
let mut app_bundle = KayakAppBundle {
..Default::default()
Expand All @@ -78,7 +88,7 @@ fn startup(
let mut children = KChildren::new();

// Create the text child
let text_entity = widget_context.spawn_widget(&mut commands, Some(app_entity));
let text_entity = widget_context.spawn_widget(&mut commands, None, None);
commands.entity(text_entity).insert(TextWidgetBundle {
text: TextProps {
content: "Hello World".into(),
Expand All @@ -97,8 +107,8 @@ fn startup(
widget_context.add_widget(None, app_entity);

// Add widget context as resource.
commands.spawn(UICameraBundle::new(widget_context));

commands.spawn((widget_context, EventDispatcher::default()));
}
fn main() {
App::new()
Expand All @@ -108,5 +118,4 @@ fn main() {
.add_startup_system(startup)
.run()
}

```
2 changes: 1 addition & 1 deletion book/src/chapter_6.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The char range is a defined as u32 char values. 0x20 through 0x7f represents mos

Fonts are also stored as an atlased image and a json file which tells Kayak about the font glyphs. These fonts are generated using `msdf-atlas-gen`. Check out `roboto.kayak_font` and `roboto.png` in the `assets` folder. The cached file name will be located next to the kttf file and have the file format of: `{font_name}.kttf-cached.png`.

## Generating new fonts.
### Generating Legacy `*.kayak_font`. WARNING! Does not work in wasm.
In order to create a new font you need to use the `msdf-atlas-gen` tool. This can be found at:
[https://github.com/Chlumsky/msdf-atlas-gen](https://github.com/Chlumsky/msdf-atlas-gen)

Expand Down
2 changes: 1 addition & 1 deletion kayak_font/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kayak_font"
description = "An SDF font renderer for Kayak UI and the Bevy game engine"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
resolver = "2"
authors = ["John Mitchell"]
Expand Down
2 changes: 1 addition & 1 deletion kayak_ui_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kayak_ui_macros"
description = "A proc macro library that provides RSX like syntax for Kayak UI."
version = "0.2.0"
version = "0.3.0"
edition = "2021"
resolver = "2"
authors = ["John Mitchell"]
Expand Down