Skip to content

Commit

Permalink
feat: modular ui 💕
Browse files Browse the repository at this point in the history
fix: upload to itch
change: now the binary contains asset files
  • Loading branch information
eerii committed Dec 1, 2023
1 parent 64cafab commit 3bc6d4d
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 178 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ jobs:
mkdir linux
cp target/x86_64-unknown-linux-gnu/release/${{ env.binary }} linux/
strip linux/${{ env.binary }}
cp -r assets linux/
- name: Package as a zip
working-directory: ./linux
Expand Down Expand Up @@ -168,7 +167,6 @@ jobs:
run: |
mkdir windows
cp target/x86_64-pc-windows-msvc/release/${{ env.binary }}.exe windows/
cp -r assets windows/
- name: Package as a zip
run: |
Expand Down Expand Up @@ -231,7 +229,6 @@ jobs:
run: |
mkdir -p ${{ env.binary }}.app/Contents/MacOS
cp target/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/
cp -r assets ${{ env.binary }}.app/Contents/MacOS/
strip ${{ env.binary }}.app/Contents/MacOS/${{ env.binary }}
hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ env.binary }}.dmg
Expand Down Expand Up @@ -259,20 +256,19 @@ jobs:
- id: check-env
run: |
if [[ -z "$itch_target" ]]; then
echo "has-itch-target == no >> $GITHUB_OUTPUT"
echo "has-itch-target=no" >> $GITHUB_OUTPUT
else
echo "has-itch-target == yes >> $GITHUB_OUTPUT"
echo "has-itch-target=yes" >> $GITHUB_OUTPUT
fi
upload-to-itch:
runs-on: ubuntu-latest
needs:
- get-version
- check-upload-to-itch
- release-wasm
- release-linux
- release-windows
- release-macos
# - release-windows # [CHANGE]: Uncomment this if you want to automaticall deploy mac and windows builds to itch
# - release-macos # It is disabled by default because they take a loong time
if: ${{ needs.check-upload-to-itch.outputs.should-upload == 'yes' }}

env:
Expand All @@ -282,7 +278,8 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./builds
name: wasm
path: ./builds/wasm

- name: Install butler
run: |
Expand Down
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bevy = { version = "0.12", default-features = false, features = [
"tonemapping_luts", "default_font", "webgl2",
]}
bevy_asset_loader = { version = "0.18", features = [ "progress_tracking" ] } # Better asset loader
bevy_embedded_assets = { version = "0.9" } # Embed assets in binary
bevy_kira_audio = { version = "0.18" } # Improved audio library
iyes_progress = { version = "0.10", features = [ "assets" ] } # Track loading and game state
bevy-inspector-egui = { version = "0.21" } # Inspector
Expand Down
3 changes: 1 addition & 2 deletions build/wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta charset="utf-8"/>
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no" />

<title>Game</title> <!-- [CHANGE]: Write your game name -->
<title>Hello Bevy</title> <!-- [CHANGE]: Write your game name -->

<link data-trunk rel="copy-dir" href="../../assets"/>
<link data-trunk rel="inline" href="style.css"/>
<link data-trunk rel="rust" href="../../Cargo.toml"/>
</head>
Expand Down
15 changes: 13 additions & 2 deletions examples/dvd.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
use bevy::{prelude::*, window::WindowResolution};
use bevy_embedded_assets::{EmbeddedAssetPlugin, PluginMode};
use bevy_kira_audio::prelude::*;
use bevy_persistent::Persistent;
use hello_bevy::{
config::GameOptions,
load::{GameAssets, SampleAssets},
GamePlugin, GameState,
};

fn main() {
App::new()
.add_plugins((
EmbeddedAssetPlugin {
mode: PluginMode::ReplaceDefault,
},
DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "DVD Screensaver".to_string(),
Expand Down Expand Up @@ -75,7 +81,12 @@ struct CollisionEvent(Entity);
// Systems
// ·······

fn init_sample(mut cmd: Commands, assets: Res<GameAssets>, info: Option<Res<GameInfo>>) {
fn init_sample(
mut cmd: Commands,
assets: Res<GameAssets>,
opts: Res<Persistent<GameOptions>>,
info: Option<Res<GameInfo>>,
) {
cmd.spawn((Camera2dBundle::default(), GameCamera));

if info.is_some() {
Expand Down Expand Up @@ -110,7 +121,7 @@ fn init_sample(mut cmd: Commands, assets: Res<GameAssets>, info: Option<Res<Game
TextStyle {
font: assets.font.clone(),
font_size: 192.,
color: Color::WHITE,
color: opts.color.mid,
},
),
..default()
Expand Down
20 changes: 17 additions & 3 deletions examples/jump.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
use bevy::{prelude::*, window::WindowResolution};
use bevy_embedded_assets::{EmbeddedAssetPlugin, PluginMode};
use bevy_persistent::Persistent;
use hello_bevy::{config::Keybinds, input::InputState, load::GameAssets, GamePlugin, GameState};
use hello_bevy::{
config::{GameOptions, Keybinds},
input::InputState,
load::GameAssets,
GamePlugin, GameState,
};

fn main() {
App::new()
.add_plugins((
EmbeddedAssetPlugin {
mode: PluginMode::ReplaceDefault,
},
DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Endless jump".to_string(),
Expand Down Expand Up @@ -73,7 +82,12 @@ struct GameCamera;
// Systems
// ·······

fn init_sample(mut cmd: Commands, assets: Res<GameAssets>, info: Option<Res<GameInfo>>) {
fn init_sample(
mut cmd: Commands,
assets: Res<GameAssets>,
opts: Res<Persistent<GameOptions>>,
info: Option<Res<GameInfo>>,
) {
cmd.spawn((Camera2dBundle::default(), GameCamera));

if info.is_some() {
Expand Down Expand Up @@ -104,7 +118,7 @@ fn init_sample(mut cmd: Commands, assets: Res<GameAssets>, info: Option<Res<Game
TextStyle {
font: assets.font.clone(),
font_size: 192.,
color: Color::WHITE,
color: opts.color.mid,
},
),
..default()
Expand Down
6 changes: 2 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ use crate::{input::Bind, GameState};

pub use bevy_persistent::prelude::*;

// TODO: Accesibility
// - Change font size
// - Change color palette

// ······
// Plugin
// ······
Expand All @@ -35,13 +31,15 @@ impl Plugin for ConfigPlugin {
pub struct FontSize {
pub title: f32,
pub text: f32,
pub button_text: f32,
}

impl Default for FontSize {
fn default() -> Self {
Self {
title: 48.0,
text: 24.0,
button_text: 20.0,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod only_in_debug {

cmd.spawn((Camera2dBundle {
camera_2d: Camera2d {
clear_color: ClearColorConfig::Custom(Color::rgba(0., 0., 0., 0.)),
clear_color: ClearColorConfig::Custom(Color::WHITE),
},
camera: Camera {
order: -10,
Expand Down
4 changes: 2 additions & 2 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub enum Bind {
Gamepad(GamepadButton),
}

impl Bind {
pub fn name(&self) -> String {
impl ToString for Bind {
fn to_string(&self) -> String {
match self {
Bind::Key(key) => format!("{:?}", key),
Bind::Mouse(button) => format!("{:?}", button),
Expand Down
8 changes: 3 additions & 5 deletions src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ impl Plugin for LoadPlugin {
app.add_loading_state(LoadingState::new(GameState::Loading))
.init_collection::<GameAssets>()
.add_collection_to_loading_state::<_, SampleAssets>(GameState::Loading)
.add_plugins(
ProgressPlugin::new(GameState::Loading)
.continue_to(GameState::Menu)
.track_assets(),
)
.add_plugins((ProgressPlugin::new(GameState::Loading)
.continue_to(GameState::Menu)
.track_assets(),))
.add_systems(OnEnter(GameState::Loading), init_splash)
.add_systems(OnExit(GameState::Loading), clear_loading)
.add_systems(
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
use bevy::{prelude::*, window::WindowResolution};
use bevy_embedded_assets::{EmbeddedAssetPlugin, PluginMode};
use hello_bevy::GamePlugin;

fn main() {
App::new()
.add_plugins((
EmbeddedAssetPlugin {
// Embed assets in binary (else itch.io is broken right now)
mode: PluginMode::ReplaceDefault,
},
DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Hello Bevy!".to_string(), // [CHANGE]: Game title
resolution: WindowResolution::new(600., 600.),
resizable: false, // or use fit_canvas_to_parent: true for resizing on the web
resizable: false, // Or use fit_canvas_to_parent: true for resizing on the web
canvas: Some("#bevy".to_string()),
prevent_default_event_handling: false,
..default()
Expand Down
Loading

0 comments on commit 3bc6d4d

Please sign in to comment.