Skip to content

Commit

Permalink
task: Configured Windows subsystem, adjust binary settings, and add a…
Browse files Browse the repository at this point in the history
…sset embedding & installation scripts
  • Loading branch information
FrancescoCoding committed Jun 19, 2024
1 parent 4b8886a commit 09e361c
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 19 deletions.
103 changes: 103 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,22 @@ dirs = "5.0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = "0.4.38"
winapi = { version = "0.3", features = ["winuser"] }
winapi = { version = "0.3", features = ["winuser","consoleapi"] }
notify-rust = "4"
rust-embed = "8.4.0"
tempfile = "3.10.1"

# Adjust compiler behavior for Windows.
[package.metadata.cargo-make]
windows = [
"set RUSTFLAGS=-C link-args=/SUBSYSTEM:WINDOWS", # Use Windows GUI subsystem.
]

[[bin]]
name = "rustcraft"
path = "src/main.rs"
test = false # No test harness.
doc = false # No documentation.

[build-dependencies]
winresource = "0.1.17"
Binary file removed assets/normal.jpeg
Binary file not shown.
Binary file added assets/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use winresource::WindowsResource;

fn main() {
if env::var_os("CARGO_CFG_WINDOWS").is_some() {
WindowsResource::new()
.set_icon("assets/icon.ico")
.compile()
.unwrap();
};

// Retrieve the output directory from the environment variables set by Cargo.
let out_dir = env::var("OUT_DIR").expect("Could not get OUT_DIR");

Expand Down
81 changes: 81 additions & 0 deletions scripts/RustCraft Installation Script x64.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
; *******************************************************
; * *
; * RustCraft Setup Script x64 *
; * *
; * NOTES FOR USERS: *
; * 1. License File: *
; * Replace `C:\path\to\LICENSE.txt` with the *
; * actual path to your license file. *
; * *
; * 2. Setup Icon File: *
; * Replace `C:\path\to\icon.ico` with the actual *
; * path to your icon file. *
; * *
; * 3. Source Files: *
; * Replace `C:\path\to\release\rustcraft.exe` *
; * and `C:\path\to\assets\*` with the actual *
; * paths to the executable and assets. *
; * *
; * 4. Output Base Filename: *
; * This sets the name of the output installer *
; * file to `RustCraft_Installation_Script_x64.exe` *
; * Adjust as necessary. *
; * *
; *******************************************************

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Rustcraft"
#define MyAppVersion "0.8.0-alpha"
#define MyAppPublisher "franwbu"
#define MyAppURL "https://www.franwbu.com/"
#define MyAppExeName "Rustcraft.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{5879C06F-7B45-4878-BE15-9C7FE0CBD477}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run
; on anything but x64 and Windows 11 on Arm.
ArchitecturesAllowed=x64compatible
; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the
; install be done in "64-bit mode" on x64 or Windows 11 on Arm,
; meaning it should use the native 64-bit Program Files directory and
; the 64-bit view of the registry.
ArchitecturesInstallIn64BitMode=x64compatible
DisableProgramGroupPage=yes
LicenseFile=C:\path\to\LICENSE.txt
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputBaseFilename=RustCraft_Installation_Script_x64
SetupIconFile=C:\path\to\icon.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\path\to\release\rustcraft.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\path\to\assets\*"; DestDir: "{app}\assets"; Flags: recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
77 changes: 77 additions & 0 deletions scripts/RustCraft Installation Script x86.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
; *******************************************************
; * *
; * RustCraft Setup Script x86 *
; * *
; * NOTES FOR USERS: *
; * 1. License File: *
; * Replace `C:\path\to\LICENSE.txt` with the *
; * actual path to your license file. *
; * *
; * 2. Setup Icon File: *
; * Replace `C:\path\to\icon.ico` with the actual *
; * path to your icon file. *
; * *
; * 3. Source Files: *
; * Replace `C:\path\to\release\rustcraft.exe` *
; * and `C:\path\to\assets\*` with the actual *
; * paths to the executable and assets. *
; * *
; * 4. Output Base Filename: *
; * This sets the name of the output installer *
; * file to `RustCraft_Installation_Script_x64.exe` *
; * Adjust as necessary. *
; * *
; *******************************************************

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Rustcraft"
#define MyAppVersion "0.8.0-alpha"
#define MyAppPublisher "franwbu"
#define MyAppURL "https://www.franwbu.com/"
#define MyAppExeName "Rustcraft.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{5879C06F-7B45-4878-BE15-9C7FE0CBD477}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
; "ArchitecturesAllowed=x86" specifies that Setup cannot run on anything but x86.
ArchitecturesAllowed=x86
; "ArchitecturesInstallIn64BitMode=x86" requests that the install be done in "32-bit mode" on x86.
ArchitecturesInstallIn64BitMode=x86
DisableProgramGroupPage=yes
LicenseFile=C:\path\to\LICENSE.txt
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputBaseFilename=RustCraft_Installation_Script_x86
SetupIconFile=C:\path\to\icon.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\path\to\release\rustcraft.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\path\to\assets\*"; DestDir: "{app}\assets"; Flags: recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
9 changes: 9 additions & 0 deletions src/assets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use rust_embed::RustEmbed;

#[derive(RustEmbed)]
#[folder = "assets/"]
struct Assets;

pub fn get_asset(name: &str) -> Option<Vec<u8>> {
Assets::get(name).map(|file| file.data.into_owned())
}
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn save_configuration(

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

0 comments on commit 09e361c

Please sign in to comment.