Skip to content

Commit

Permalink
Update dependencies (#28)
Browse files Browse the repository at this point in the history
* Update dependencies
* Clippy
  • Loading branch information
parasyte authored Jan 25, 2022
1 parent f6c7181 commit 0e6b0e6
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 650 deletions.
912 changes: 312 additions & 600 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ optimize = ["log/release_max_level_warn"]
[dependencies]
copypasta = "0.7"
directories = "4.0"
egui = { version = "0.15", default-features = false, features = ["single_threaded"] }
egui_wgpu_backend = "0.14"
egui-winit = "0.15"
egui = { version = "0.16", default-features = false, features = ["single_threaded"] }
egui_wgpu_backend = "0.16"
egui-winit = "0.16"
encoding_rs = "0.8"
env_logger = { version = "0.9", default-features = false, features = ["atty", "humantime", "termcolor"] }
epaint = { version = "0.15", default-features = false, features = ["single_threaded"] }
epaint = { version = "0.16", default-features = false, features = ["single_threaded"] }
font-loader = "0.11"
human-sort = "0.2"
hotwatch = "0.4"
Expand All @@ -30,19 +30,19 @@ log = "0.4"
ordered-multimap = "0.4"
patricia_tree = "0.3"
pollster = "0.2"
raw-window-handle = "0.3"
rfd = "0.5"
raw-window-handle = "0.4"
rfd = "0.6"
semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
toml_edit = "0.12"
toml_edit = "0.13"
unicode-segmentation = "1.7"
ureq = { version = "2.3", features = ["json"] }
walkdir = "2.3"
webbrowser = "0.5"
wgpu = "0.11"
winit = "0.25"
winit_input_helper = "0.10"
wgpu = "0.12"
winit = "0.26"
winit_input_helper = "0.11"

[target.'cfg(windows)'.build-dependencies]
embed-resource = "1.6"
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl Config {
.as_str()
.ok_or_else(|| Error::type_error(&format!("tracks.{}", id), "string"))?;

self.track_ids.insert(id.to_string());
self.track_ids.insert(id);
self.tracks.insert(id.to_string(), name.to_string());
}
} else if !table.is_none() {
Expand Down
23 changes: 10 additions & 13 deletions src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use directories::ProjectDirs;
use egui::{ClippedMesh, CtxRef};
use egui_wgpu_backend::{BackendError, RenderPass, ScreenDescriptor};
use font_loader::system_fonts::{self, FontPropertyBuilder};
use std::borrow::Cow;
use std::collections::VecDeque;
use std::path::PathBuf;
use thiserror::Error;
Expand Down Expand Up @@ -139,17 +138,15 @@ impl Framework {

/// Prepare egui.
pub(crate) fn prepare(&mut self, window: &Window) {
// Begin the egui frame.
let raw_input = self.egui_state.take_egui_input(window);
self.egui_ctx.begin_frame(raw_input);

// Draw the application GUI.
update_theme(&mut self.theme, &self.egui_ctx);
self.gui.ui(&self.egui_ctx, window);

// End the egui frame and create all paint jobs to prepare for rendering.
// TODO: Handle output.needs_repaint to avoid game-mode continuous redraws.
let (output, paint_commands) = self.egui_ctx.end_frame();
// Run the egui frame and create all paint jobs to prepare for rendering.
let raw_input = self.egui_state.take_egui_input(window);
let (output, paint_commands) = self.egui_ctx.run(raw_input, |egui_ctx| {
// Draw the application GUI.
self.gui.ui(egui_ctx, window);
});

self.egui_state
.handle_output(window, &self.egui_ctx, output);
self.paint_jobs = self.egui_ctx.tessellate(paint_commands);
Expand All @@ -164,7 +161,7 @@ impl Framework {
) -> Result<(), BackendError> {
// Upload all resources to the GPU.
self.rpass
.update_texture(&gpu.device, &gpu.queue, &self.egui_ctx.texture());
.update_texture(&gpu.device, &gpu.queue, &self.egui_ctx.font_image());
self.rpass.update_user_textures(&gpu.device, &gpu.queue);
self.rpass.update_buffers(
&gpu.device,
Expand Down Expand Up @@ -365,7 +362,7 @@ fn create_fonts() -> egui::FontDefinitions {
.0;
fonts
.font_data
.insert("MonoSpace".to_owned(), Cow::from(font));
.insert("MonoSpace".to_owned(), egui::FontData::from_owned(font));

let props = FontPropertyBuilder::new().family("sans-serif").build();
let font = system_fonts::get(&props)
Expand All @@ -377,7 +374,7 @@ fn create_fonts() -> egui::FontDefinitions {
.0;
fonts
.font_data
.insert("SansSerif".to_owned(), Cow::from(font));
.insert("SansSerif".to_owned(), egui::FontData::from_owned(font));

// Set font families
fonts
Expand Down
56 changes: 33 additions & 23 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use copypasta::{ClipboardContext, ClipboardProvider};
use egui::widgets::color_picker::{color_edit_button_srgba, Alpha};
use egui::{CtxRef, Widget};
use hotwatch::Hotwatch;
use std::borrow::Cow;
use std::collections::{HashMap, VecDeque};
use std::path::Path;
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -146,18 +145,21 @@ impl Gui {
egui::TopBottomPanel::top("menubar-container").show(ctx, |ui| {
ui.set_enabled(enabled);
egui::menu::bar(ui, |ui| {
egui::menu::menu(ui, "File", |ui| {
ui.menu_button("File", |ui| {
ui.set_min_width(200.0);
if ui.button("Preferences").clicked() {
ui.close_menu();
self.preferences = true;
}
});
egui::menu::menu(ui, "Help", |ui| {
ui.menu_button("Help", |ui| {
ui.set_min_width(200.0);
if ui.button("About CarTunes...").clicked() {
ui.close_menu();
self.about = true;
}
if ui.button("Support CarTunes on Patreon").clicked() {
ui.close_menu();
if let Err(err) = webbrowser::open("https://www.patreon.com/blipjoy") {
let warning = ShowWarning::new(err, "Unable to open web browser.");
self.show_warnings.push_front(warning);
Expand Down Expand Up @@ -482,14 +484,15 @@ impl Gui {
let position = selected_setups.iter().position(|&v| v == i);
let mut checked = position.is_some();
let color = position
.map(|i| colors.iter().cycle().nth(i))
.flatten()
.and_then(|i| colors.iter().cycle().nth(i))
.cloned()
.unwrap_or_else(|| ui.visuals().text_color());

let checkbox = egui::Checkbox::new(&mut checked, info.name())
.text_color(color)
.ui(ui);
let checkbox = egui::Checkbox::new(
&mut checked,
egui::RichText::new(info.name()).color(color),
)
.ui(ui);
if checkbox.clicked() {
if checked {
selected_setups.push(i);
Expand Down Expand Up @@ -548,12 +551,12 @@ impl Gui {

ui.label("Theme:");
egui::ComboBox::from_id_source("theme-preference")
.selected_text(current_theme)
.selected_text(current_theme.to_string())
.show_ui(ui, |ui| {
let choices = [UserTheme::Auto, UserTheme::Dark, UserTheme::Light];
for choice in &choices {
let checked = current_theme == *choice;
let response = ui.selectable_label(checked, format!("{}", choice));
let response = ui.selectable_label(checked, choice.to_string());
if response.clicked() {
self.config.update_theme(*choice);
self.event_loop_proxy
Expand All @@ -570,7 +573,7 @@ impl Gui {

ui.label("Update checks:");
egui::ComboBox::from_id_source("update-check-preference")
.selected_text(update_check)
.selected_text(update_check.to_string())
.show_ui(ui, |ui| {
let choices = [
UpdateFrequency::Never,
Expand All @@ -579,7 +582,7 @@ impl Gui {
];
for choice in &choices {
let checked = update_check == *choice;
let response = ui.selectable_label(checked, format!("{}", choice));
let response = ui.selectable_label(checked, choice.to_string());
if response.clicked() {
self.config.set_update_check(*choice);
self.event_loop_proxy
Expand All @@ -592,14 +595,19 @@ impl Gui {

// Setup exports path selection
ui.horizontal(|ui| {
// XXX: Workaround for https://github.com/PolyMeilex/rfd/issues/32
let setups_path = self.config.get_setups_path().to_string_lossy();
let setups_path = setups_path.strip_prefix(r"\\?\").unwrap_or(&setups_path);
let label = Cow::Borrowed(setups_path).ellipsis(50);
let setups_path = self.config.get_setups_path();

// Strip Windows path prefixes for display in the GUI
let label = setups_path.to_string_lossy();
let label = label
.strip_prefix(r"\\?\UNC\")
.or_else(|| label.strip_prefix(r"\\?\"))
.or_else(|| label.strip_prefix(r"\??\"))
.unwrap_or(&label)
.ellipsis(50);

ui.label("Setup exports path:");
if egui::Label::new(label)
.code()
if egui::Label::new(egui::RichText::new(label).code())
.sense(egui::Sense::click())
.ui(ui)
.clicked()
Expand Down Expand Up @@ -736,11 +744,13 @@ impl Gui {
let action = err.buttons.0.action;
action();
result = false;
} else if egui::Button::new(&err.buttons.1.label)
.text_color(egui::Color32::BLACK)
.fill(red)
.ui(ui)
.clicked()
} else if egui::Button::new(
egui::RichText::new(&err.buttons.1.label)
.color(egui::Color32::BLACK),
)
.fill(red)
.ui(ui)
.clicked()
{
let action = err.buttons.1.action;
action();
Expand Down
4 changes: 2 additions & 2 deletions src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ fn setup_from_html<P: AsRef<Path>>(
.split(" setup: ")
.next()
.ok_or(Error::MissingCar)?
.replace(" ", "_");
.replace(' ', "_");

// Map car ID to a human-readable name
let car_name = config
Expand All @@ -405,7 +405,7 @@ fn setup_from_html<P: AsRef<Path>>(
.ok_or(Error::MissingTrack)?
.1
.trim()
.replace(" ", "_");
.replace(' ', "_");

// Get the track unique identifier
let track_id = config
Expand Down
6 changes: 6 additions & 0 deletions src/str_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ impl<'a> Ellipsis<'a> for Cow<'a, str> {
}
}

impl<'a> Ellipsis<'a> for &'a str {
fn ellipsis(self, max_length: usize) -> Cow<'a, str> {
Cow::Borrowed(self).ellipsis(max_length)
}
}

/// An extension trait for strings that adds a sentence capitalization method.
pub(crate) trait Capitalize<'a> {
/// Capitalize words using ASCII uppercase/lowercase.
Expand Down
2 changes: 1 addition & 1 deletion src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl UpdateCheckerThread {
// Update persistence
self.persist.update_last_version(version);
self.persist
.update_release_notes(body.body.replace("\r", ""));
.update_release_notes(body.body.replace('\r', ""));
self.persist.update_url(body.html_url);

// Write persistence to the file system
Expand Down

0 comments on commit 0e6b0e6

Please sign in to comment.