Skip to content

Commit 09e361c

Browse files
task: Configured Windows subsystem, adjust binary settings, and add asset embedding & installation scripts
1 parent 4b8886a commit 09e361c

File tree

10 files changed

+315
-19
lines changed

10 files changed

+315
-19
lines changed

Cargo.lock

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,22 @@ dirs = "5.0.1"
1212
serde = { version = "1.0", features = ["derive"] }
1313
serde_json = "1.0"
1414
chrono = "0.4.38"
15-
winapi = { version = "0.3", features = ["winuser"] }
15+
winapi = { version = "0.3", features = ["winuser","consoleapi"] }
1616
notify-rust = "4"
17+
rust-embed = "8.4.0"
18+
tempfile = "3.10.1"
19+
20+
# Adjust compiler behavior for Windows.
21+
[package.metadata.cargo-make]
22+
windows = [
23+
"set RUSTFLAGS=-C link-args=/SUBSYSTEM:WINDOWS", # Use Windows GUI subsystem.
24+
]
25+
26+
[[bin]]
27+
name = "rustcraft"
28+
path = "src/main.rs"
29+
test = false # No test harness.
30+
doc = false # No documentation.
31+
32+
[build-dependencies]
33+
winresource = "0.1.17"

assets/normal.jpeg

-172 KB
Binary file not shown.

assets/normal.png

1.98 MB
Loading

build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ use std::env;
22
use std::fs::File;
33
use std::io::Write;
44
use std::path::Path;
5+
use winresource::WindowsResource;
56

67
fn main() {
8+
if env::var_os("CARGO_CFG_WINDOWS").is_some() {
9+
WindowsResource::new()
10+
.set_icon("assets/icon.ico")
11+
.compile()
12+
.unwrap();
13+
};
14+
715
// Retrieve the output directory from the environment variables set by Cargo.
816
let out_dir = env::var("OUT_DIR").expect("Could not get OUT_DIR");
917

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
; *******************************************************
2+
; * *
3+
; * RustCraft Setup Script x64 *
4+
; * *
5+
; * NOTES FOR USERS: *
6+
; * 1. License File: *
7+
; * Replace `C:\path\to\LICENSE.txt` with the *
8+
; * actual path to your license file. *
9+
; * *
10+
; * 2. Setup Icon File: *
11+
; * Replace `C:\path\to\icon.ico` with the actual *
12+
; * path to your icon file. *
13+
; * *
14+
; * 3. Source Files: *
15+
; * Replace `C:\path\to\release\rustcraft.exe` *
16+
; * and `C:\path\to\assets\*` with the actual *
17+
; * paths to the executable and assets. *
18+
; * *
19+
; * 4. Output Base Filename: *
20+
; * This sets the name of the output installer *
21+
; * file to `RustCraft_Installation_Script_x64.exe` *
22+
; * Adjust as necessary. *
23+
; * *
24+
; *******************************************************
25+
26+
; Script generated by the Inno Setup Script Wizard.
27+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
28+
29+
#define MyAppName "Rustcraft"
30+
#define MyAppVersion "0.8.0-alpha"
31+
#define MyAppPublisher "franwbu"
32+
#define MyAppURL "https://www.franwbu.com/"
33+
#define MyAppExeName "Rustcraft.exe"
34+
35+
[Setup]
36+
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
37+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
38+
AppId={{5879C06F-7B45-4878-BE15-9C7FE0CBD477}}
39+
AppName={#MyAppName}
40+
AppVersion={#MyAppVersion}
41+
;AppVerName={#MyAppName} {#MyAppVersion}
42+
AppPublisher={#MyAppPublisher}
43+
AppPublisherURL={#MyAppURL}
44+
AppSupportURL={#MyAppURL}
45+
AppUpdatesURL={#MyAppURL}
46+
DefaultDirName={autopf}\{#MyAppName}
47+
; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run
48+
; on anything but x64 and Windows 11 on Arm.
49+
ArchitecturesAllowed=x64compatible
50+
; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the
51+
; install be done in "64-bit mode" on x64 or Windows 11 on Arm,
52+
; meaning it should use the native 64-bit Program Files directory and
53+
; the 64-bit view of the registry.
54+
ArchitecturesInstallIn64BitMode=x64compatible
55+
DisableProgramGroupPage=yes
56+
LicenseFile=C:\path\to\LICENSE.txt
57+
; Remove the following line to run in administrative install mode (install for all users.)
58+
PrivilegesRequired=lowest
59+
OutputBaseFilename=RustCraft_Installation_Script_x64
60+
SetupIconFile=C:\path\to\icon.ico
61+
Compression=lzma
62+
SolidCompression=yes
63+
WizardStyle=modern
64+
65+
[Languages]
66+
Name: "english"; MessagesFile: "compiler:Default.isl"
67+
68+
[Tasks]
69+
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
70+
71+
[Files]
72+
Source: "C:\path\to\release\rustcraft.exe"; DestDir: "{app}"; Flags: ignoreversion
73+
Source: "C:\path\to\assets\*"; DestDir: "{app}\assets"; Flags: recursesubdirs createallsubdirs
74+
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
75+
76+
[Icons]
77+
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
78+
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
79+
80+
[Run]
81+
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
; *******************************************************
2+
; * *
3+
; * RustCraft Setup Script x86 *
4+
; * *
5+
; * NOTES FOR USERS: *
6+
; * 1. License File: *
7+
; * Replace `C:\path\to\LICENSE.txt` with the *
8+
; * actual path to your license file. *
9+
; * *
10+
; * 2. Setup Icon File: *
11+
; * Replace `C:\path\to\icon.ico` with the actual *
12+
; * path to your icon file. *
13+
; * *
14+
; * 3. Source Files: *
15+
; * Replace `C:\path\to\release\rustcraft.exe` *
16+
; * and `C:\path\to\assets\*` with the actual *
17+
; * paths to the executable and assets. *
18+
; * *
19+
; * 4. Output Base Filename: *
20+
; * This sets the name of the output installer *
21+
; * file to `RustCraft_Installation_Script_x64.exe` *
22+
; * Adjust as necessary. *
23+
; * *
24+
; *******************************************************
25+
26+
; Script generated by the Inno Setup Script Wizard.
27+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
28+
29+
#define MyAppName "Rustcraft"
30+
#define MyAppVersion "0.8.0-alpha"
31+
#define MyAppPublisher "franwbu"
32+
#define MyAppURL "https://www.franwbu.com/"
33+
#define MyAppExeName "Rustcraft.exe"
34+
35+
[Setup]
36+
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
37+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
38+
AppId={{5879C06F-7B45-4878-BE15-9C7FE0CBD477}}
39+
AppName={#MyAppName}
40+
AppVersion={#MyAppVersion}
41+
;AppVerName={#MyAppName} {#MyAppVersion}
42+
AppPublisher={#MyAppPublisher}
43+
AppPublisherURL={#MyAppURL}
44+
AppSupportURL={#MyAppURL}
45+
AppUpdatesURL={#MyAppURL}
46+
DefaultDirName={autopf}\{#MyAppName}
47+
; "ArchitecturesAllowed=x86" specifies that Setup cannot run on anything but x86.
48+
ArchitecturesAllowed=x86
49+
; "ArchitecturesInstallIn64BitMode=x86" requests that the install be done in "32-bit mode" on x86.
50+
ArchitecturesInstallIn64BitMode=x86
51+
DisableProgramGroupPage=yes
52+
LicenseFile=C:\path\to\LICENSE.txt
53+
; Remove the following line to run in administrative install mode (install for all users.)
54+
PrivilegesRequired=lowest
55+
OutputBaseFilename=RustCraft_Installation_Script_x86
56+
SetupIconFile=C:\path\to\icon.ico
57+
Compression=lzma
58+
SolidCompression=yes
59+
WizardStyle=modern
60+
61+
[Languages]
62+
Name: "english"; MessagesFile: "compiler:Default.isl"
63+
64+
[Tasks]
65+
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
66+
67+
[Files]
68+
Source: "C:\path\to\release\rustcraft.exe"; DestDir: "{app}"; Flags: ignoreversion
69+
Source: "C:\path\to\assets\*"; DestDir: "{app}\assets"; Flags: recursesubdirs createallsubdirs
70+
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
71+
72+
[Icons]
73+
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
74+
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
75+
76+
[Run]
77+
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

src/assets.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use rust_embed::RustEmbed;
2+
3+
#[derive(RustEmbed)]
4+
#[folder = "assets/"]
5+
struct Assets;
6+
7+
pub fn get_asset(name: &str) -> Option<Vec<u8>> {
8+
Assets::get(name).map(|file| file.data.into_owned())
9+
}

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn save_configuration(
2020

2121
pub fn load_configuration() -> (Option<String>, Option<String>, i32) {
2222
let path = Path::new(CONFIG_FILE);
23-
let mut backup_frequency = 24; // Default backup frequency in hours
23+
let mut backup_frequency = 0; // Default backup frequency in hours
2424
let (minecraft_dir, backup_dir) = if path.exists() {
2525
let data = fs::read_to_string(path).unwrap();
2626
let json: Value = serde_json::from_str(&data).unwrap();

0 commit comments

Comments
 (0)