Skip to content

Commit ae5da0d

Browse files
fix: linux use native frame and add test mode
1 parent f001db6 commit ae5da0d

File tree

4 files changed

+49
-24
lines changed

4 files changed

+49
-24
lines changed

resources/dist.rc

5 Bytes
Binary file not shown.

src/celemod-ui/src/context/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export const createThemeContext = () => {
4040

4141
useEffect(() => {
4242
if (!storage) return;
43-
// @ts-ignore
4443
console.log("set blur behind", enableAcrylic);
44+
// @ts-ignore
4545
Window.this.blurBehind = enableAcrylic
4646
? "dark ultra source-desktop"
4747
: "none";

src/celemod-ui/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<link rel="stylesheet" href="./index.scss" />
6666
<link rel="stylesheet" href="i2.css" />
6767
<script>
68-
if (env.PLATFORM === "OSX")
68+
if (env.PLATFORM !== "Windows")
6969
document.querySelector(".win-ctrl").style.display = "none";
7070

7171
Window.this.isResizable = true;

src/main.rs

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,32 @@ use serde::{Deserialize, Serialize};
66

77
use anyhow::{Context, bail};
88
use aria2c::DownloadCallbackInfo;
9+
use dirs;
910
use everest::get_mod_cached_new;
1011
use game_scanner::prelude::Game;
1112
use std::{
1213
cell::RefCell,
1314
fs,
1415
path::{Path, PathBuf},
1516
rc::Rc,
17+
sync::atomic::{AtomicBool, Ordering},
1618
};
17-
use dirs;
19+
20+
static TEST_MODE: AtomicBool = AtomicBool::new(false);
21+
22+
fn is_test_mode() -> bool {
23+
TEST_MODE.load(Ordering::Relaxed)
24+
}
25+
26+
fn get_test_game_path() -> PathBuf {
27+
let path = std::env::temp_dir().join("celemod_test_game");
28+
let _ = std::fs::create_dir_all(path.join("Mods"));
29+
#[cfg(windows)]
30+
let _ = std::fs::write(path.join("Celeste.exe"), b"");
31+
#[cfg(unix)]
32+
let _ = std::fs::write(path.join("Celeste"), b"");
33+
path
34+
}
1835

1936
extern crate msgbox;
2037

@@ -526,6 +543,9 @@ impl Handler {
526543
}
527544

528545
fn get_celeste_dirs(&self) -> String {
546+
if is_test_mode() {
547+
return get_test_game_path().to_string_lossy().to_string();
548+
}
529549
get_celestes()
530550
.iter()
531551
.map(|game| game.path.clone().unwrap().to_str().unwrap().to_string())
@@ -732,18 +752,16 @@ impl Handler {
732752
// Migrate old database to new location
733753
println!("Migrating database from {:?} to {:?}", old_path, new_path);
734754
match std::fs::read(&old_path) {
735-
Ok(data) => {
736-
match std::fs::write(&new_path, &data) {
737-
Ok(_) => {
738-
let _ = std::fs::remove_file(&old_path);
739-
println!("Database migration completed");
740-
}
741-
Err(e) => {
742-
eprintln!("Failed to write new database: {}", e);
743-
return old_path.to_string_lossy().to_string();
744-
}
755+
Ok(data) => match std::fs::write(&new_path, &data) {
756+
Ok(_) => {
757+
let _ = std::fs::remove_file(&old_path);
758+
println!("Database migration completed");
745759
}
746-
}
760+
Err(e) => {
761+
eprintln!("Failed to write new database: {}", e);
762+
return old_path.to_string_lossy().to_string();
763+
}
764+
},
747765
Err(e) => {
748766
eprintln!("Failed to read old database: {}", e);
749767
return old_path.to_string_lossy().to_string();
@@ -932,6 +950,9 @@ impl Handler {
932950
}
933951

934952
fn verify_celeste_install(&self, path: String) -> bool {
953+
if is_test_mode() && path == get_test_game_path().to_string_lossy() {
954+
return true;
955+
}
935956
let path = Path::new(&path);
936957
let checklist = vec!["Celeste.exe", "Celeste"];
937958
for file in checklist {
@@ -991,8 +1012,14 @@ impl sciter::EventHandler for Handler {
9911012
}
9921013

9931014
fn main() {
994-
// parse /update command line argument
1015+
// parse command line arguments
9951016
let args: Vec<String> = std::env::args().collect();
1017+
1018+
if args.contains(&"--test-mode".to_string()) {
1019+
TEST_MODE.store(true, Ordering::Relaxed);
1020+
println!("Running in test mode (no game required)");
1021+
}
1022+
9961023
if args.len() == 3 && args[1] == "/update" {
9971024
// sleep for a bit to let the old process exit
9981025
std::thread::sleep(std::time::Duration::from_secs_f32(0.5));
@@ -1031,7 +1058,8 @@ fn main() {
10311058
println!("Extracting {}...", lib_name);
10321059
let lib_bytes = include_bytes_zstd::include_bytes_zstd!("resources/libsciter.so", 19);
10331060
let mut file = std::fs::File::create(&lib_path).expect("Failed to create libsciter.so");
1034-
file.write_all(&lib_bytes).expect("Failed to write libsciter.so");
1061+
file.write_all(&lib_bytes)
1062+
.expect("Failed to write libsciter.so");
10351063

10361064
// Set library file permissions
10371065
#[cfg(unix)]
@@ -1092,17 +1120,14 @@ fn main() {
10921120
// #[cfg(target_os = "macos")]
10931121
// let _ = sciter::set_options(sciter::RuntimeOptions::GfxLayer(GFX_LAYER::SKIA_VULKAN));
10941122

1095-
let mut builder = sciter::WindowBuilder::main()
1096-
.with_size((800, 600));
1097-
1098-
#[cfg(target_os = "macos")]
1123+
let mut builder = sciter::WindowBuilder::main().with_size((800, 600));
1124+
1125+
#[cfg(not(target_os = "windows"))]
10991126
{
1100-
builder = builder.with_title()
1101-
.resizeable()
1102-
.closeable();
1127+
builder = builder.with_title().resizeable().closeable();
11031128
}
11041129

1105-
#[cfg(not(target_os = "macos"))]
1130+
#[cfg(target_os = "windows")]
11061131
{
11071132
builder = builder.glassy().alpha();
11081133
}

0 commit comments

Comments
 (0)