-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bc73e2e
Showing
8 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build] | ||
target = "i686-pc-windows-msvc" | ||
rustflags = ["-C", "link-args=/debug:none"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/* |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "mod" | ||
version = "0.1.0" | ||
authors = ["lcdr"] | ||
edition = "2018" | ||
description = "A mod to change LU's UI scale." | ||
readme = "README.md" | ||
license = "AGPL-3.0-or-later" | ||
repository = "https://github.com/lcdr/ui_scaler/" | ||
|
||
[dependencies] | ||
winapi = { version = "0.3.9", features = ["libloaderapi", "memoryapi"] } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[profile.release] | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
A mod to change LU's UI scale. | ||
|
||
# Installation: | ||
|
||
If you haven't installed my modloader yet, install it from https://github.com/lcdr/mod_loader/releases/, following the instructions there. | ||
|
||
Download this mod from https://github.com/lcdr/ui_scaler/releases/, following the instructions there. | ||
|
||
# Usage: | ||
|
||
Open your client's boot.cfg file and add a new config entry named `UI_SCALE` with type 3 (float) and the scaling factor as the value, e.g. append `,UI_SCALE=3:2.0` to the file for x2 scaling. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
mod patch; | ||
mod scale_ui; | ||
use scale_ui::patch_ui_scale; | ||
|
||
use winapi::{ | ||
shared::minwindef::{BOOL, DWORD, HINSTANCE, LPVOID, TRUE}, | ||
um::libloaderapi::GetModuleHandleA, | ||
}; | ||
|
||
static mut BASE: usize = 0; | ||
|
||
#[no_mangle] | ||
pub extern "system" fn DllMain( | ||
_dll_module: HINSTANCE, | ||
call_reason: DWORD, | ||
_reserved: LPVOID) | ||
-> BOOL { | ||
const DLL_PROCESS_ATTACH: DWORD = 1; | ||
|
||
match call_reason { | ||
DLL_PROCESS_ATTACH => init(), | ||
_ => TRUE | ||
} | ||
} | ||
|
||
fn init() -> BOOL { | ||
unsafe { BASE = GetModuleHandleA(std::ptr::null()) as usize; } | ||
patch_ui_scale(); | ||
TRUE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use winapi::shared::minwindef::{DWORD, LPVOID}; | ||
use winapi::um::memoryapi::VirtualProtect; | ||
use winapi::um::winnt::PAGE_EXECUTE_READWRITE; | ||
|
||
use crate::BASE; | ||
|
||
pub fn patch<T>(dst: usize, new: T) { | ||
unsafe { | ||
let dst = (dst + BASE) as LPVOID; | ||
let mut old_protect: DWORD = PAGE_EXECUTE_READWRITE; | ||
VirtualProtect(dst, std::mem::size_of::<T>(), PAGE_EXECUTE_READWRITE, &mut old_protect); | ||
*(dst as *mut T) = new; | ||
VirtualProtect(dst, std::mem::size_of::<T>(), old_protect, &mut old_protect); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::fs::read_to_string; | ||
|
||
use crate::patch::patch; | ||
|
||
const VIEWPORT_HEIGHT_OFFSET: usize = 0x7939ce; | ||
const VIEWPORT_HEIGHT_VALUE: usize = 0x7939d2; | ||
|
||
pub fn patch_ui_scale() { | ||
let lnv = read_to_string("boot.cfg").expect("could not open boot.cfg"); | ||
|
||
for name_value in lnv.split(",") { | ||
let name_value = name_value.trim(); | ||
let (name, value) = name_value.split_at(name_value.find(":").expect(&format!("malformed boot.cfg entry, colon missing: {}", name_value))+1); | ||
|
||
if name == "UI_SCALE=3:" { | ||
let scale: f32 = value.parse().expect(&format!("could not parse boot.cfg UI_SCALE value as float: {}", value)); | ||
let scale = 1.0 / scale; | ||
patch(VIEWPORT_HEIGHT_OFFSET, 0x00_00_01_50_u32); | ||
patch(VIEWPORT_HEIGHT_VALUE, scale); | ||
} | ||
} | ||
} |