Fix Rust formatting
Server integrations / Paper and protocol tests (push) Failing after 20s
Server integrations / fabric / 1.20.1 (push) Failing after 11s
Server integrations / fabric / 1.21.1 (push) Failing after 14s
Server integrations / fabric / 26.1.2 (push) Failing after 17s
Server integrations / fabric / 26.2 (push) Failing after 12s
Server integrations / fabric / 26.3 (push) Failing after 6s
Server integrations / forge / 1.20.1 (push) Failing after 6s
Server integrations / forge / 1.21.1 (push) Failing after 8s
Server integrations / forge / 26.1.2 (push) Failing after 8s
Server integrations / forge / 26.2 (push) Failing after 8s
Server integrations / forge / 26.3 (push) Failing after 7s
CI / Web UIs (type-check + build) (panel/web) (push) Canceled after 0s
CI / Launcher (Windows build check) (push) Canceled after 2m53s
CI / Real installs (Mojang, Fabric, Quilt, Forge, NeoForge) (push) Canceled after 0s
CI / Docker image builds (push) Canceled after 0s
CI / Rust (fmt, clippy, tests) (push) Canceled after 1m22s
CI / Web UIs (type-check + build) (launcher) (push) Canceled after 1m27s
Server integrations / Paper and protocol tests (push) Failing after 20s
Server integrations / fabric / 1.20.1 (push) Failing after 11s
Server integrations / fabric / 1.21.1 (push) Failing after 14s
Server integrations / fabric / 26.1.2 (push) Failing after 17s
Server integrations / fabric / 26.2 (push) Failing after 12s
Server integrations / fabric / 26.3 (push) Failing after 6s
Server integrations / forge / 1.20.1 (push) Failing after 6s
Server integrations / forge / 1.21.1 (push) Failing after 8s
Server integrations / forge / 26.1.2 (push) Failing after 8s
Server integrations / forge / 26.2 (push) Failing after 8s
Server integrations / forge / 26.3 (push) Failing after 7s
CI / Web UIs (type-check + build) (panel/web) (push) Canceled after 0s
CI / Launcher (Windows build check) (push) Canceled after 2m53s
CI / Real installs (Mojang, Fabric, Quilt, Forge, NeoForge) (push) Canceled after 0s
CI / Docker image builds (push) Canceled after 0s
CI / Rust (fmt, clippy, tests) (push) Canceled after 1m22s
CI / Web UIs (type-check + build) (launcher) (push) Canceled after 1m27s
This commit is contained in:
1 parent
ce49447b6e
commit
60edc99780
58 files changed
+3533
-1375
No files matched your search
+73
-17
@@ -7,18 +7,67 @@ use std::path::Path;
|
||||
/// Player-owned vanilla preferences. Pack-managed options.txt may be replaced
|
||||
/// during sync, so these are captured separately and merged back afterward.
|
||||
const VANILLA_KEYS: &[&str] = &[
|
||||
"fov", "gamma", "graphicsMode", "fancyGraphics", "renderDistance", "simulationDistance",
|
||||
"maxFps", "enableVsync", "fullscreen", "fullscreenResolution", "guiScale", "particles",
|
||||
"clouds", "renderClouds", "entityShadows", "entityDistanceScaling", "biomeBlendRadius",
|
||||
"mipmapLevels", "ao", "ambientOcclusion", "bobView", "attackIndicator", "autoJump",
|
||||
"mouseSensitivity", "invertYMouse", "discrete_mouse_scroll", "mouseWheelSensitivity",
|
||||
"rawMouseInput", "toggleCrouch", "toggleSprint", "sneakToggled", "sprintToggled",
|
||||
"screenEffectScale", "fovEffectScale", "darknessEffectScale", "narrator", "subtitles",
|
||||
"chatVisibility", "chatColors", "chatLinks", "chatLinksPrompt", "chatOpacity", "textBackgroundOpacity",
|
||||
"backgroundForChatOnly", "chatScale", "chatWidth", "chatHeightFocused", "chatHeightUnfocused",
|
||||
"mainHand", "lang", "forceUnicodeFont", "tutorialStep", "hideBundleTutorial",
|
||||
"soundDevice", "directionalAudio", "musicFrequency", "notificationDisplayTime",
|
||||
"joinedFirstServer", "pauseOnLostFocus", "reducedDebugInfo", "showSubtitles",
|
||||
"fov",
|
||||
"gamma",
|
||||
"graphicsMode",
|
||||
"fancyGraphics",
|
||||
"renderDistance",
|
||||
"simulationDistance",
|
||||
"maxFps",
|
||||
"enableVsync",
|
||||
"fullscreen",
|
||||
"fullscreenResolution",
|
||||
"guiScale",
|
||||
"particles",
|
||||
"clouds",
|
||||
"renderClouds",
|
||||
"entityShadows",
|
||||
"entityDistanceScaling",
|
||||
"biomeBlendRadius",
|
||||
"mipmapLevels",
|
||||
"ao",
|
||||
"ambientOcclusion",
|
||||
"bobView",
|
||||
"attackIndicator",
|
||||
"autoJump",
|
||||
"mouseSensitivity",
|
||||
"invertYMouse",
|
||||
"discrete_mouse_scroll",
|
||||
"mouseWheelSensitivity",
|
||||
"rawMouseInput",
|
||||
"toggleCrouch",
|
||||
"toggleSprint",
|
||||
"sneakToggled",
|
||||
"sprintToggled",
|
||||
"screenEffectScale",
|
||||
"fovEffectScale",
|
||||
"darknessEffectScale",
|
||||
"narrator",
|
||||
"subtitles",
|
||||
"chatVisibility",
|
||||
"chatColors",
|
||||
"chatLinks",
|
||||
"chatLinksPrompt",
|
||||
"chatOpacity",
|
||||
"textBackgroundOpacity",
|
||||
"backgroundForChatOnly",
|
||||
"chatScale",
|
||||
"chatWidth",
|
||||
"chatHeightFocused",
|
||||
"chatHeightUnfocused",
|
||||
"mainHand",
|
||||
"lang",
|
||||
"forceUnicodeFont",
|
||||
"tutorialStep",
|
||||
"hideBundleTutorial",
|
||||
"soundDevice",
|
||||
"directionalAudio",
|
||||
"musicFrequency",
|
||||
"notificationDisplayTime",
|
||||
"joinedFirstServer",
|
||||
"pauseOnLostFocus",
|
||||
"reducedDebugInfo",
|
||||
"showSubtitles",
|
||||
];
|
||||
|
||||
pub fn read_vanilla_preferences(game_dir: &Path) -> Result<BTreeMap<String, String>> {
|
||||
@@ -28,10 +77,13 @@ pub fn read_vanilla_preferences(game_dir: &Path) -> Result<BTreeMap<String, Stri
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(BTreeMap::new()),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
Ok(contents.lines().filter_map(|line| {
|
||||
let (key, value) = line.split_once(':')?;
|
||||
(VANILLA_KEYS.contains(&key) || key.starts_with("soundCategory_")).then(|| (key.to_owned(), value.to_owned()))
|
||||
}).collect())
|
||||
Ok(contents
|
||||
.lines()
|
||||
.filter_map(|line| {
|
||||
let (key, value) = line.split_once(':')?;
|
||||
(VANILLA_KEYS.contains(&key) || key.starts_with("soundCategory_")).then(|| (key.to_owned(), value.to_owned()))
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// Merge `key_<binding>:<key>` lines into options.txt, keeping everything
|
||||
@@ -85,7 +137,11 @@ mod tests {
|
||||
#[test]
|
||||
fn captures_only_vanilla_preferences() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
std::fs::write(dir.path().join("options.txt"), "fov:0.8\ngamma:1.0\nautoJump:false\nsoundCategory_music:0.25\nkey_key.forward:key.keyboard.w\nmodded:yes\n").unwrap();
|
||||
std::fs::write(
|
||||
dir.path().join("options.txt"),
|
||||
"fov:0.8\ngamma:1.0\nautoJump:false\nsoundCategory_music:0.25\nkey_key.forward:key.keyboard.w\nmodded:yes\n",
|
||||
)
|
||||
.unwrap();
|
||||
let prefs = read_vanilla_preferences(dir.path()).unwrap();
|
||||
assert_eq!(prefs.get("fov").map(String::as_str), Some("0.8"));
|
||||
assert_eq!(prefs.get("autoJump").map(String::as_str), Some("false"));
|
||||
|
||||
Reference in new issue
Block a user