Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ fn main() {
}
}

let (sender, receiver) =
channel::<(Recipe, Arguments, Option<windows::Win32::Foundation::HWND>)>();
#[cfg(windows)]
type WinHWND = Option<windows::Win32::Foundation::HWND>;
#[cfg(not(windows))]
type WinHWND = ();

let (sender, receiver) = channel::<(Recipe, Arguments, WinHWND)>();

let _ret = smgui::sm_gui(recipe.clone(), _metadata, args, sender);

Expand Down
11 changes: 10 additions & 1 deletion src/portable.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use homedir;
use std::{env, fs, os::windows::fs::FileTypeExt, path::PathBuf};
use std::{env, fs, path::PathBuf};

#[cfg(windows)]
use std::os::windows::fs::FileTypeExt;

const DEFAULT_RECIPE: &str = include_str!("../target/recipe.ini");
const DEFAULT_ENCODING_PRESETS: &str = include_str!("../target/encoding_presets.ini");
Expand Down Expand Up @@ -75,10 +78,16 @@ pub fn get_config_filepaths() -> Vec<PathBuf> {
continue;
}

#[cfg(windows)]
if filetype.is_symlink() || filetype.is_symlink_file() {
panic!("implement recipe file symlink parsing yourself :)")
}

#[cfg(not(windows))]
if filetype.is_symlink() {
panic!("implement recipe file symlink parsing yourself :)")
}

ret.push(config_folder.join(filename_str.to_string()));
}

Expand Down
32 changes: 13 additions & 19 deletions src/recipe.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::cli::Arguments;
use crate::portable;
use crate::verb;
use crate::{NO, YES};
use crate::portable;
use indexmap::map::Entry;
use indexmap::map::IndexMap;
use indexmap::map::Keys;
Expand Down Expand Up @@ -394,35 +394,29 @@ pub fn export_recipe(
}

pub fn get_recipe(args: &mut Arguments) -> (Recipe, WidgetMetadata) {
let exe = match env::current_exe() {
Ok(exe) => exe,
Err(e) => panic!("Could not resolve Smoothie's binary path: {}", e),
};

let bin_dir = match exe.parent() {
Some(bin_dir) => bin_dir.parent().unwrap(),
None => panic!("Could not resolve Smoothie's binary directory `{exe:?}`"),
};

let rc_path = if PathBuf::from(&args.recipe).exists() {
PathBuf::from(&args.recipe)
} else {
let cur_dir_rc = portable::get_recipe_path_custom(&args.recipe);
if !cur_dir_rc.exists() {
panic!(
"Recipe filepath does not exist (expected at {})",
cur_dir_rc.display()
)
if args.recipe == "recipe.ini" {
portable::get_recipe_path()
} else {
let cur_dir_rc = portable::get_recipe_path_custom(&args.recipe);
if !cur_dir_rc.exists() {
panic!(
"Recipe filepath does not exist (expected at {})",
cur_dir_rc.display()
)
}
cur_dir_rc
}
cur_dir_rc
};
args.recipe = rc_path.display().to_string();

let mut rc: Recipe = Recipe::new();
let mut metadata = Some(WidgetMetadata::new());

parse_recipe(
Path::join(bin_dir, "defaults.ini"),
portable::get_defaults_path(),
None,
&mut rc,
&mut metadata,
Expand Down
19 changes: 12 additions & 7 deletions src/smgui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ use std::{
};
use copypasta::{ClipboardContext, ClipboardProvider};
use eframe::egui;
#[cfg(windows)]
use winit::raw_window_handle::HasWindowHandle;
use indexmap::map::IndexMap;

#[cfg(windows)]
type WinHWND = Option<windows::Win32::Foundation::HWND>;
#[cfg(not(windows))]
type WinHWND = ();

struct SmApp {
first_frame: bool,
save_new_recipe: bool,
Expand All @@ -28,7 +34,7 @@ struct SmApp {
start_rendering: bool,
// yeah that's the damn typename
recipe_saved: String,
sender: Sender<(Recipe, Arguments, Option<windows::Win32::Foundation::HWND>)>,
sender: Sender<(Recipe, Arguments, WinHWND)>,
make_new_recipe: bool,
new_recipe_filename: String,
}
Expand Down Expand Up @@ -83,7 +89,7 @@ pub fn sm_gui<'gui>(
recipe: Recipe,
metadata: WidgetMetadata,
args: Arguments,
sender: Sender<(Recipe, Arguments, Option<windows::Win32::Foundation::HWND>)>,
sender: Sender<(Recipe, Arguments, WinHWND)>,
) -> Result<(), eframe::Error> {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

Expand Down Expand Up @@ -137,18 +143,17 @@ impl eframe::App for SmApp {
let mut scoped_args = self.args.clone();
scoped_args.input = self.selected_files.clone();


let hwnd: Option<windows::Win32::Foundation::HWND> = if cfg!(windows) {
#[cfg(windows)]
let hwnd: Option<windows::Win32::Foundation::HWND> = {
let winit::raw_window_handle::RawWindowHandle::Win32(handle) = frame.window_handle().unwrap().as_raw() else {
panic!("Unsupported platform");
};
let ptr = handle.hwnd.get() as *mut std::ffi::c_void;
Some(windows::Win32::Foundation::HWND(ptr))

} else {
None
};

#[cfg(not(windows))]
let hwnd: WinHWND = ();
let send_result = self.sender.send((self.recipe.clone(), scoped_args, hwnd));

if let Err(e) = send_result {
Expand Down
4 changes: 4 additions & 0 deletions target/jamba.vpy
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ def Masking(
if (pi := rc['pre-interp'])['enabled'].lower() in YES:

model_path = pi['model'].strip('"')

if model_path == "auto":
print("\n\n\033[31mERR:\033[0m Default Model has been removed, please set pre-interp:model to the models directory\n\n", file=sys.stderr)
sys.exit(-1)

if not path.isdir(model_path):

Expand Down