Skip to content

Commit

Permalink
upgrade to wgpu 0.17 and egui 0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Oct 3, 2023
1 parent 40fc7e0 commit bfc0d01
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 74 deletions.
221 changes: 169 additions & 52 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ resolver = "2"
default-members = ["native_app"]

[workspace.dependencies]
egui = "0.22.0"
egui = "0.23.0"
flat_spatial = "0.6"
egui_extras = "0.22.0"
egui-winit = { version = "0.22.0", default-features = false }
egui_extras = "0.23.0"
egui-winit = { version = "0.23.0", default-features = false }
egui_plot = "0.23.0"
ordered-float = { version = "3.4.0", default-features = false }
winit = "0.28.6"
oddio = "0.6.2"
Expand Down
2 changes: 1 addition & 1 deletion assets_gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ engine = { path = "../engine" }
egui-inspect = { path = "../egui-inspect" }
log = { version = "0.4.11", features=["max_level_info", "release_max_level_info"] }
inline_tweak = "1.0.8"
egui_dock = "0.6.3"
egui_dock = "0.8"
egui = { workspace = true }
40 changes: 33 additions & 7 deletions assets_gui/src/gui.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use common::descriptions::{BuildingGen, CompanyKind};
use egui::{Color32, Ui};
use egui_dock::{DockArea, NodeIndex, Style, TabStyle, Tree};
use egui_dock::{
DockArea, DockState, NodeIndex, Style, TabBodyStyle, TabInteractionStyle, TabStyle,
};
use egui_inspect::{Inspect, InspectArgs};

use engine::meshload::MeshProperties;
Expand Down Expand Up @@ -34,20 +36,25 @@ pub enum Shown {
}

pub struct Gui {
pub tree: Option<Tree<Tab>>,
pub tree: Option<DockState<Tab>>,
pub companies: Companies,
pub inspected: Inspected,
pub shown: Shown,
}

impl Gui {
pub fn new() -> Self {
let mut tree = Tree::new(vec![Tab::View]);
let mut tree = DockState::new(vec![Tab::View]);

let view = NodeIndex::root();
let [view, _] = tree.split_left(view, 0.2, vec![Tab::Explorer]);
let [view, _] = tree.split_right(view, 0.8, vec![Tab::Properties]);
tree.split_below(view, 0.8, vec![Tab::ModelProperties]);
let [view, _] = tree
.main_surface_mut()
.split_left(view, 0.2, vec![Tab::Explorer]);
let [view, _] = tree
.main_surface_mut()
.split_right(view, 0.8, vec![Tab::Properties]);
tree.main_surface_mut()
.split_below(view, 0.8, vec![Tab::ModelProperties]);

Self {
tree: Some(tree),
Expand Down Expand Up @@ -299,7 +306,26 @@ impl<'a> egui_dock::TabViewer for TabViewer<'a> {
fn tab_style_override(&self, tab: &Self::Tab, global_style: &TabStyle) -> Option<TabStyle> {
if matches!(tab, Tab::View) {
return Some(TabStyle {
bg_fill: Color32::TRANSPARENT,
active: TabInteractionStyle {
bg_fill: Color32::TRANSPARENT,
..global_style.active
},
focused: TabInteractionStyle {
bg_fill: Color32::TRANSPARENT,
..global_style.focused
},
hovered: TabInteractionStyle {
bg_fill: Color32::TRANSPARENT,
..global_style.hovered
},
inactive: TabInteractionStyle {
bg_fill: Color32::TRANSPARENT,
..global_style.inactive
},
tab_body: TabBodyStyle {
bg_fill: Color32::TRANSPARENT,
..global_style.tab_body
},
hline_below_active_tab_name: false,
..global_style.clone()
});
Expand Down
4 changes: 2 additions & 2 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ egui = { workspace = true }
winit = { workspace = true }
oddio = { workspace = true }
derive_more = { workspace = true }
wgpu = { version = "0.16.0", default-features = false, features=["wgsl"] }
wgpu = { version = "0.17.0", default-features = false, features=["wgsl"] }
bytemuck = "1.7.2"
image = { version = "0.24.3", default-features = false, features = ["png"] }
log = "0.4.11"
Expand All @@ -28,7 +28,7 @@ beul = "1.0.0"
slotmapd = "1.0"
smallvec = "1.10.0"
inline_tweak = "1.0.8"
egui-wgpu = { version = "0.22.0" }
egui-wgpu = { version = "0.23.0" }
cpal = "0.15.0"
lewton = "0.10.2"
serde = { version = "1.0.183", features = ["derive"] }
1 change: 1 addition & 0 deletions native_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ networking = { path = "../networking", optional=true }
egui-inspect = { path = "../egui-inspect" }
egui = { workspace = true }
egui_extras = { workspace = true }
egui_plot = { workspace = true }
flat_spatial = { workspace = true }
ordered-float = { workspace = true }
winit = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions native_app/src/gui/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use common::FastMap;
use std::borrow::Cow;
use std::path::Path;
use std::sync::Arc;

use egui::{ColorImage, ImageData, TextureHandle, TextureId, TextureOptions};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -159,10 +160,10 @@ impl UiTextures {

let h = ctx.load_texture(
&name,
ImageData::Color(ColorImage::from_rgba_unmultiplied(
ImageData::Color(Arc::new(ColorImage::from_rgba_unmultiplied(
[width as usize, height as usize],
&img,
)),
))),
TextureOptions::LINEAR,
);

Expand Down
11 changes: 6 additions & 5 deletions native_app/src/gui/topgui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::inputmap::{InputAction, InputMap};
use crate::uiworld::{SaveLoadState, UiWorld};
use common::descriptions::BuildingGen;
use common::saveload::Encoder;
use egui::load::SizedTexture;
use egui::{
Align2, Color32, Context, Frame, Id, LayerId, Response, RichText, Rounding, Stroke, Style, Ui,
Widget, Window,
Expand Down Expand Up @@ -205,10 +206,10 @@ impl Gui {
let cur_tab = *uiworld.read::<Tab>();

for (name, tab, default_tool) in &tools {
if egui::ImageButton::new(
if egui::ImageButton::new(SizedTexture::new(
uiworld.read::<UiTextures>().get(name),
[toolbox_w, 30.0],
)
))
.selected(std::mem::discriminant(tab) == std::mem::discriminant(&cur_tab))
.ui(ui)
.clicked()
Expand Down Expand Up @@ -629,7 +630,7 @@ impl Gui {
let p = ui.layer_painter(LayerId::background());
p.rect(
ui.screen_rect(),
Rounding::none(),
Rounding::ZERO,
Color32::from_rgba_premultiplied(0, 0, 0, 0),
Stroke {
width: 7.0,
Expand Down Expand Up @@ -785,9 +786,9 @@ pub fn item_icon(ui: &mut Ui, uiworld: &UiWorld, item: &Item, multiplier: i32) -
.read::<UiTextures>()
.try_get(&format!("icon/{}", item.name))
{
if ui.image(id, (32.0, 32.0)).hovered() {
if ui.image(SizedTexture::new(id, (32.0, 32.0))).hovered() {
egui::show_tooltip(ui.ctx(), ui.make_persistent_id("icon tooltip"), |ui| {
ui.image(id, (64.0, 64.0));
ui.image(SizedTexture::new(id, (64.0, 64.0)));
ui.label(format!("{} x{}", item.name, multiplier));
});
}
Expand Down
4 changes: 2 additions & 2 deletions native_app/src/gui/windows/economy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::uiworld::UiWorld;
use common::timestep::UP_DT;
use egui::plot::{Line, PlotPoints};
use egui::{Align2, Color32, Ui};
use egui_plot::{Line, PlotPoints};
use geom::Color;
use simulation::economy::{
EcoStats, ItemHistories, ItemRegistry, Market, HISTORY_SIZE, LEVEL_FREQS, LEVEL_NAMES,
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn economy(window: egui::Window<'_>, ui: &egui::Context, uiw: &mut UiWorld,
d.get_temp_mut_or_insert_with(filterid, HashSet::new)
.clone()
});
egui::plot::Plot::new("ecoplot")
egui_plot::Plot::new("ecoplot")
.height(200.0)
.allow_boxed_zoom(false)
.include_y(0.0)
Expand Down

0 comments on commit bfc0d01

Please sign in to comment.