Skip to content

Commit dd5adcc

Browse files
FIRST USABLE BUILD - v0.1.0
1 parent 4227ce9 commit dd5adcc

File tree

5 files changed

+55
-14
lines changed

5 files changed

+55
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "boxedmino"
3-
version = "0.0.2"
3+
version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]

src/injected.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ do
66
identity = new_identity;
77
end
88
love.filesystem.getIdentity = function()
9+
print("getIdentity call intercepted, identity masked; running under sandboxed environment");
910
return identity;
1011
end
11-
end
12+
end
13+

src/main.rs

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ fn run_game(cfg: &Config) {
103103

104104
if cfg.sandboxed {
105105
let script = include_str!("injected.lua");
106-
let main_lua = path.join("main.lua");
106+
let main_lua = path.join("conf.lua");
107107
let mut main_lua_contents = fs::read_to_string(&main_lua)
108-
.expect("Failed to read Techmino's main.lua file");
108+
.expect("Failed to read Techmino's conf.lua file");
109109
main_lua_contents = format!("{}\n{}", script, main_lua_contents);
110110
fs::write(main_lua, main_lua_contents)
111-
.expect("Failed to write to Techmino's main.lua file");
111+
.expect("Failed to write to Techmino's conf.lua file");
112112
}
113113

114114
if cfg.clear_temp_dir {
@@ -133,13 +133,13 @@ fn run_game(cfg: &Config) {
133133
);
134134
}
135135

136-
// Restore main.lua
136+
// Restore conf.lua
137137
let mut command = Command::new("git");
138-
command.args(["restore", "main.lua"])
138+
command.args(["restore", "conf.lua"])
139139
.current_dir(&path);
140140

141141
command.status()
142-
.expect("Failed to restore main.lua using git");
142+
.expect("Failed to restore conf.lua using git");
143143
}
144144

145145
fn mutate_config_with_cli_args(cfg: &mut Config) {
@@ -149,6 +149,7 @@ fn mutate_config_with_cli_args(cfg: &mut Config) {
149149
let arg = args[i].as_str();
150150
match arg {
151151
// TODO: simplify cli arg processing using the `clap` crate
152+
// TODO: --use-version <version> to specify version to run
152153
"--help" => {
153154
println!("{}", include_str!("help.txt"));
154155
std::process::exit(0);
@@ -307,9 +308,47 @@ fn safe_todo(feature: Option<&str>) {
307308

308309
fn open_main_window(cfg: &Config) -> Result<MainWindow, slint::PlatformError> {
309310
let main_window = MainWindow::new()?;
310-
main_window.on_open_game(|_| {
311-
run_game(&Config::load());
311+
main_window.on_open_game(|version| {
312+
let cfg = Config::load();
313+
314+
if !version.is_empty() {
315+
316+
let mut reset_cmd = Command::new("git")
317+
.args(["restore", "."])
318+
.current_dir(cfg.game_repo_path.clone())
319+
.status();
320+
321+
if let Err(e) = reset_cmd {
322+
open_error_window_safe(
323+
Some("Failed to reset repository".to_string()),
324+
Some("Failed to reset repository before switching versions".to_string()),
325+
Some(format!("Git: {e}"))
326+
);
327+
return;
328+
}
329+
330+
331+
let mut cmd = Command::new("git");
332+
let status = cmd
333+
.args(["checkout", version.as_str()])
334+
.current_dir(cfg.game_repo_path.clone())
335+
.status();
336+
337+
if let Err(e) = status {
338+
open_error_window_safe(
339+
Some("Failed to switch versions".to_string()),
340+
Some(
341+
format!("Failed to switch to version '{version}'")
342+
),
343+
Some(format!("Git: {e}"))
344+
);
345+
return;
346+
}
347+
}
348+
349+
run_game(&cfg);
312350
});
351+
main_window.set_selected_version("".into());
313352
main_window.set_sandbox_path(
314353
consts::paths::get_sandboxed_save_path()
315354
.to_string_lossy()
@@ -498,7 +537,7 @@ fn is_repo_valid(path: &str) -> bool {
498537

499538
let files = files.unwrap();
500539

501-
// Check for .git and main.lua
540+
// Check for .git and conf.lua
502541
let mut has_git = false;
503542
let mut has_main_lua = false;
504543

@@ -508,7 +547,7 @@ fn is_repo_valid(path: &str) -> bool {
508547
let file_name = file_name.to_str().unwrap_or("");
509548
if file_name == ".git" {
510549
has_git = true;
511-
} else if file_name == "main.lua" {
550+
} else if file_name == "conf.lua" {
512551
has_main_lua = true;
513552
}
514553
}

ui/main.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export component MainWindow inherits Window {
246246
font-size: 1.25rem;
247247
}
248248
Text {
249-
text: "The game source code folder containing main.lua.";
249+
text: "The game source code folder containing conf.lua.";
250250
font-size: 0.96rem;
251251
}
252252
}

0 commit comments

Comments
 (0)