Skip to content

Commit

Permalink
Fix some wasm things
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Jul 11, 2024
1 parent f4bf52b commit a2bb7f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/config/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#[cfg(not(target_arch = "wasm32"))]
use crate::terminal;
use crate::CodeTheme;

use indexmap::IndexMap;
use std::collections::VecDeque;

/// The state saved by Luminol between sessions.
Expand All @@ -44,7 +42,8 @@ pub struct Config {

/// The current code theme
pub theme: CodeTheme,
pub rtp_paths: IndexMap<String, String>,
#[cfg(not(target_arch = "wasm32"))]
pub rtp_paths: indexmap::IndexMap<String, String>,
}

impl Default for Config {
Expand All @@ -58,7 +57,8 @@ impl Config {
Self {
recent_projects: VecDeque::new(),
theme: CodeTheme::dark(),
rtp_paths: IndexMap::new(),
#[cfg(not(target_arch = "wasm32"))]
rtp_paths: indexmap::IndexMap::new(),
#[cfg(not(target_arch = "wasm32"))]
terminal: terminal::Config::default(),
}
Expand Down
11 changes: 10 additions & 1 deletion crates/ui/src/windows/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
// it with Steamworks API by Valve Corporation, containing parts covered by
// terms of the Steamworks API by Valve Corporation, the licensors of this
// Program grant you additional permission to convey the resulting work.
#[cfg(not(target_arch = "wasm32"))]
use egui::Widget;
use strum::IntoEnumIterator;

#[derive(Default)]
pub struct Window {
#[cfg(not(target_arch = "wasm32"))]
edit_rtp_path_name: String,
#[cfg(not(target_arch = "wasm32"))]
edit_rtp_path_path: String,

tab: Tab,
Expand All @@ -36,10 +39,13 @@ pub struct Window {
#[derive(Default, PartialEq, Eq)]
#[derive(strum::EnumIter, strum::Display)]
enum Tab {
#[default]
#[cfg_attr(not(target_arch = "wasm32"), default)]
#[strum(to_string = "Editor Settings")]
#[cfg(not(target_arch = "wasm32"))]
// only setting right now is editing rtp paths, which is not supported on wasm
EditorSettings,
#[strum(to_string = "Egui Visuals")]
#[cfg_attr(target_arch = "wasm32", default)]
EguiVisuals,
#[strum(to_string = "Preset Visuals")]
PresetVisuals,
Expand Down Expand Up @@ -209,6 +215,7 @@ impl luminol_core::Window for Window {
});
});
}
#[cfg(not(target_arch = "wasm32"))]
Tab::EditorSettings => {
ui.label("RTP Paths");
ui.separator();
Expand Down Expand Up @@ -458,10 +465,12 @@ fn gallery_grid_contents(ui: &mut egui::Ui) {
ui.end_row();
}

#[allow(dead_code)]
fn color_to_rgb(color: egui::Color32) -> [u8; 3] {
let [r, g, b, _] = color.to_array();
[r, g, b]
}
#[allow(dead_code)]
fn color_from_rgb([r, g, b]: [u8; 3]) -> egui::Color32 {
egui::Color32::from_rgb(r, g, b)
}

0 comments on commit a2bb7f3

Please sign in to comment.