Skip to content

Commit

Permalink
Merge pull request #584 from rparrett/remove-font
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBiscardi authored Dec 23, 2024
2 parents 56dc41b + bf7025e commit 1a4d7ef
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 62 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ features = [
"bevy_sprite",
#"file_watcher",
"multi_threaded",
"default_font",
"webgl2",
]

Expand All @@ -68,6 +69,7 @@ features = [
"bevy_text",
"bevy_sprite",
"multi_threaded",
"default_font",
"webgl2",
]

Expand Down
Binary file removed assets/fonts/FiraSans-Bold.ttf
Binary file not shown.
12 changes: 0 additions & 12 deletions examples/frustum_cull_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ pub struct TileHandleSquare(Handle<Image>);
#[derive(Deref, Resource)]
pub struct TileHandleIso(Handle<Image>);

#[derive(Deref, Resource)]
pub struct FontHandle(Handle<Font>);

impl FromWorld for TileHandleHexCol {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Expand All @@ -66,12 +63,6 @@ impl FromWorld for TileHandleSquare {
Self(asset_server.load("bw-tile-square.png"))
}
}
impl FromWorld for FontHandle {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Self(asset_server.load("fonts/FiraSans-Bold.ttf"))
}
}

// Generates the initial tilemap, which is a square grid.
fn spawn_tilemap(mut commands: Commands, tile_handle_square: Res<TileHandleSquare>) {
Expand Down Expand Up @@ -118,7 +109,6 @@ pub struct MapTypeLabel;
// Generates the map type label: e.g. `Square { diagonal_neighbors: false }`
fn spawn_map_type_label(
mut commands: Commands,
font_handle: Res<FontHandle>,
windows: Query<&Window>,
map_type_q: Query<&TilemapType>,
) {
Expand All @@ -133,7 +123,6 @@ fn spawn_map_type_label(
commands.spawn((
Text2d::new(format!("{map_type:?}")),
TextFont {
font: font_handle.clone(),
font_size: 20.0,
..default()
},
Expand Down Expand Up @@ -244,7 +233,6 @@ fn main() {
.init_resource::<TileHandleHexCol>()
.init_resource::<TileHandleHexRow>()
.init_resource::<TileHandleSquare>()
.init_resource::<FontHandle>()
.add_systems(
Startup,
(spawn_tilemap, apply_deferred, spawn_map_type_label).chain(),
Expand Down
13 changes: 0 additions & 13 deletions examples/hex_neighbors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ pub struct TileHandleHexRow(Handle<Image>);

#[derive(Deref, Resource)]
pub struct TileHandleHexCol(Handle<Image>);
#[derive(Deref, Resource)]
pub struct FontHandle(Handle<Font>);

impl FromWorld for TileHandleHexCol {
fn from_world(world: &mut World) -> Self {
Expand All @@ -39,12 +37,6 @@ impl FromWorld for TileHandleHexRow {
Self(asset_server.load("bw-tile-hex-row.png"))
}
}
impl FromWorld for FontHandle {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Self(asset_server.load("fonts/FiraSans-Bold.ttf"))
}
}

// Generates the initial tilemap, which is a hex grid.
fn spawn_tilemap(mut commands: Commands, tile_handle_hex_row: Res<TileHandleHexRow>) {
Expand Down Expand Up @@ -91,7 +83,6 @@ fn spawn_tile_labels(
mut commands: Commands,
tilemap_q: Query<(&Transform, &TilemapType, &TilemapGridSize, &TileStorage)>,
tile_q: Query<&mut TilePos>,
font_handle: Res<FontHandle>,
) {
for (map_transform, map_type, grid_size, tilemap_storage) in tilemap_q.iter() {
for tile_entity in tilemap_storage.iter().flatten() {
Expand All @@ -103,7 +94,6 @@ fn spawn_tile_labels(
.spawn((
Text2d::new(format!("{}, {}", tile_pos.x, tile_pos.y)),
TextFont {
font: font_handle.clone(),
font_size: 20.0,
..default()
},
Expand All @@ -125,7 +115,6 @@ pub struct MapTypeLabel;
// Generates the map type label: e.g. `Square { diagonal_neighbors: false }`
fn spawn_map_type_label(
mut commands: Commands,
font_handle: Res<FontHandle>,
windows: Query<&Window>,
map_type_q: Query<&TilemapType>,
) {
Expand All @@ -140,7 +129,6 @@ fn spawn_map_type_label(
commands.spawn((
Text2d::new(format!("{map_type:?}")),
TextFont {
font: font_handle.clone(),
font_size: 20.0,
..default()
},
Expand Down Expand Up @@ -427,7 +415,6 @@ fn main() {
.init_resource::<CursorPos>()
.init_resource::<TileHandleHexCol>()
.init_resource::<TileHandleHexRow>()
.init_resource::<FontHandle>()
.add_systems(Startup, (spawn_tilemap, apply_deferred).chain().in_set(SpawnTilemapSet))
.add_systems(Startup, (spawn_tile_labels, spawn_map_type_label).after(SpawnTilemapSet))
.add_systems(First, (camera_movement, update_cursor_pos).chain())
Expand Down
11 changes: 0 additions & 11 deletions examples/hex_neighbors_radius_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ pub struct TileHandleHexRow(Handle<Image>);

#[derive(Deref, Resource)]
pub struct TileHandleHexCol(Handle<Image>);
#[derive(Deref, Resource)]
pub struct FontHandle(Handle<Font>);

impl FromWorld for TileHandleHexCol {
fn from_world(world: &mut World) -> Self {
Expand All @@ -36,12 +34,6 @@ impl FromWorld for TileHandleHexRow {
Self(asset_server.load("bw-tile-hex-row.png"))
}
}
impl FromWorld for FontHandle {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Self(asset_server.load("fonts/FiraSans-Bold.ttf"))
}
}

#[derive(Deref, Component, Clone, Copy)]
pub struct ChunkPos(IVec2);
Expand Down Expand Up @@ -324,7 +316,6 @@ fn spawn_tile_labels(
mut commands: Commands,
tilemap_q: Query<(&Transform, &TilemapType, &TilemapGridSize, &TileStorage)>,
tile_q: Query<&TilePos>,
font_handle: Res<FontHandle>,
) {
for (map_transform, map_type, grid_size, tilemap_storage) in tilemap_q.iter() {
for tile_entity in tilemap_storage.iter().flatten() {
Expand All @@ -338,7 +329,6 @@ fn spawn_tile_labels(
.spawn((
Text2d(format!("{}, {}", hex_pos.x, hex_pos.y)),
TextFont {
font: font_handle.clone(),
font_size: 20.0,
..default()
},
Expand Down Expand Up @@ -533,7 +523,6 @@ fn main() {
.init_resource::<HighlightRadius>()
.init_resource::<TileHandleHexCol>()
.init_resource::<TileHandleHexRow>()
.init_resource::<FontHandle>()
.add_systems(Startup, (spawn_chunks, apply_deferred).chain().in_set(SpawnChunksSet))
.add_systems(Startup, spawn_tile_labels.after(SpawnChunksSet))
.add_systems(First, (camera_movement, update_cursor_pos).chain())
Expand Down
12 changes: 0 additions & 12 deletions examples/hexagon_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ pub struct TileHandleHexRow(Handle<Image>);
#[derive(Deref, Resource)]
pub struct TileHandleHexCol(Handle<Image>);

#[derive(Deref, Resource)]
pub struct FontHandle(Handle<Font>);

impl FromWorld for TileHandleHexCol {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Expand All @@ -37,12 +34,6 @@ impl FromWorld for TileHandleHexRow {
Self(asset_server.load("bw-tile-hex-row.png"))
}
}
impl FromWorld for FontHandle {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Self(asset_server.load("fonts/FiraSans-Bold.ttf"))
}
}

// Generates the initial tilemap, which is a square grid.
fn spawn_tilemap(mut commands: Commands, tile_handle_hex_row: Res<TileHandleHexRow>) {
Expand Down Expand Up @@ -94,7 +85,6 @@ pub struct MapTypeLabel;
// Generates the map type label: e.g. `Square { diagonal_neighbors: false }`
fn spawn_map_type_label(
mut commands: Commands,
font_handle: Res<FontHandle>,
windows: Query<&Window>,
map_type_q: Query<&TilemapType>,
) {
Expand All @@ -109,7 +99,6 @@ fn spawn_map_type_label(
commands.spawn((
Text2d::new(format!("{map_type:?}")),
TextFont {
font: font_handle.clone(),
font_size: 20.0,
..default()
},
Expand Down Expand Up @@ -219,7 +208,6 @@ fn main() {
.add_plugins(TilemapPlugin)
.init_resource::<TileHandleHexCol>()
.init_resource::<TileHandleHexRow>()
.init_resource::<FontHandle>()
.add_systems(
Startup,
(spawn_tilemap, apply_deferred, spawn_map_type_label).chain(),
Expand Down
14 changes: 0 additions & 14 deletions examples/mouse_to_tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ pub struct TileHandleSquare(Handle<Image>);
#[derive(Deref, Resource)]
pub struct TileHandleIso(Handle<Image>);

#[derive(Deref, Resource)]
pub struct FontHandle(Handle<Font>);

impl FromWorld for TileHandleHexCol {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Expand All @@ -63,12 +60,6 @@ impl FromWorld for TileHandleSquare {
Self(asset_server.load("bw-tile-square.png"))
}
}
impl FromWorld for FontHandle {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
Self(asset_server.load("fonts/FiraSans-Bold.ttf"))
}
}

// Generates the initial tilemap, which is a square grid.
fn spawn_tilemap(mut commands: Commands, tile_handle_square: Res<TileHandleSquare>) {
Expand Down Expand Up @@ -115,7 +106,6 @@ fn spawn_tile_labels(
mut commands: Commands,
tilemap_q: Query<(&Transform, &TilemapType, &TilemapGridSize, &TileStorage)>,
tile_q: Query<&mut TilePos>,
font_handle: Res<FontHandle>,
) {
for (map_transform, map_type, grid_size, tilemap_storage) in tilemap_q.iter() {
for tile_entity in tilemap_storage.iter().flatten() {
Expand All @@ -127,7 +117,6 @@ fn spawn_tile_labels(
.spawn((
Text2d::new(format!("{}, {}", tile_pos.x, tile_pos.y)),
TextFont {
font: font_handle.clone(),
font_size: 20.0,
..default()
},
Expand All @@ -149,7 +138,6 @@ pub struct MapTypeLabel;
// Generates the map type label: e.g. `Square { diagonal_neighbors: false }`
fn spawn_map_type_label(
mut commands: Commands,
font_handle: Res<FontHandle>,
windows: Query<&Window>,
map_type_q: Query<&TilemapType>,
) {
Expand All @@ -164,7 +152,6 @@ fn spawn_map_type_label(
commands.spawn((
Text2d::new(format!("{map_type:?}")),
TextFont {
font: font_handle.clone(),
font_size: 20.0,
..default()
},
Expand Down Expand Up @@ -379,7 +366,6 @@ fn main() {
.init_resource::<TileHandleHexCol>()
.init_resource::<TileHandleHexRow>()
.init_resource::<TileHandleSquare>()
.init_resource::<FontHandle>()
.add_plugins(TilemapPlugin)
.add_systems(
Startup,
Expand Down

0 comments on commit 1a4d7ef

Please sign in to comment.