Skip to content

Commit

Permalink
Convert blurry scaling checkbox to multichoice
Browse files Browse the repository at this point in the history
This was considered easier to understand.

Thanks to @lydell.
  • Loading branch information
SimonAlling committed Mar 28, 2017
1 parent 9aaa531 commit 9898e6d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
30 changes: 21 additions & 9 deletions js/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ const Zatacka = (() => {
default: true,
},
{
type: BooleanPreference,
key: STRINGS.pref_key_allow_blurry_scaling,
label: TEXT.pref_label_allow_blurry_scaling,
description: TEXT.pref_label_description_allow_blurry_scaling,
default: false,
type: MultichoicePreference,
key: STRINGS.pref_key_scaling,
label: TEXT.pref_label_scaling,
description: TEXT.pref_label_description_scaling,
values: [
STRINGS.pref_value_scaling_prefer_quality,
STRINGS.pref_value_scaling_prefer_size,
],
labels: [
TEXT.pref_label_scaling_prefer_quality,
TEXT.pref_label_scaling_prefer_size,
],
default: STRINGS.pref_value_scaling_prefer_quality,
},
{
type: MultichoicePreference,
Expand Down Expand Up @@ -196,6 +204,10 @@ const Zatacka = (() => {
}
}

function setScalingMode(mode) {
guiController.setBlurryScaling(mode === STRINGS.pref_value_scaling_prefer_size);
}

function setPreventSpawnkill(mode) {
if (game.isStarted()) {
throw new Error("Cannot change edge padding when the game is running.");
Expand Down Expand Up @@ -480,18 +492,18 @@ const Zatacka = (() => {
let preference_value_edge_fix;
let preference_value_hints;
let preference_value_prevent_spawnkill;
let preference_value_allow_blurry_scaling;
let preference_value_scaling;
try {
preference_value_edge_fix = preferenceManager.getSaved(STRINGS.pref_key_edge_fix);
preference_value_hints = preferenceManager.getSaved(STRINGS.pref_key_hints);
preference_value_prevent_spawnkill = preferenceManager.getSaved(STRINGS.pref_key_prevent_spawnkill);
preference_value_allow_blurry_scaling = preferenceManager.getSaved(STRINGS.pref_key_allow_blurry_scaling);
preference_value_scaling = preferenceManager.getSaved(STRINGS.pref_key_scaling);
} catch(e) {
logWarning("Could not load settings from localStorage. Using cached settings instead.");
preference_value_edge_fix = preferenceManager.getCached(STRINGS.pref_key_edge_fix);
preference_value_hints = preferenceManager.getCached(STRINGS.pref_key_hints);
preference_value_prevent_spawnkill = preferenceManager.getCached(STRINGS.pref_key_prevent_spawnkill);
preference_value_allow_blurry_scaling = preferenceManager.getCached(STRINGS.pref_key_allow_blurry_scaling);
preference_value_scaling = preferenceManager.getCached(STRINGS.pref_key_scaling);
handleSettingsAccessError(e);
}

Expand All @@ -502,7 +514,7 @@ const Zatacka = (() => {
// Prevent spawnkill:
game.setPreventSpawnkill(preference_value_prevent_spawnkill);
// Blurry scaling:
guiController.setBlurryScaling(preference_value_allow_blurry_scaling);
setScalingMode(preference_value_scaling);
}

function handleSettingsAccessError(error) {
Expand Down
6 changes: 4 additions & 2 deletions js/locales/Zatacka.en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export default (() => {
pref_label_confirm_reload: `Confirm reload`,
pref_label_description_confirm_reload: `Ask for confirmation before reloading the application (F5).`,

pref_label_allow_blurry_scaling: `Allow blurry scaling`,
pref_label_description_allow_blurry_scaling: `Let the game use the available screen area more efficiently at the expense of visual quality. Can be useful if the game is very small on your screen.`,
pref_label_scaling: `Scaling`,
pref_label_description_scaling: `Visual quality ensures a crisp, pixelmapped image. On-screen size may result in blurry graphics and other visual errors, but can be useful if the game is very small on your screen.`,
pref_label_scaling_prefer_quality: `Prefer visual quality`,
pref_label_scaling_prefer_size: `Prefer on-screen size`,
});
})();
5 changes: 4 additions & 1 deletion js/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ export default Object.freeze({
pref_key_confirm_quit: "confirm_quit",
pref_key_confirm_reload: "confirm_reload",
pref_key_prevent_spawnkill: "prevent_spawnkill",
pref_key_allow_blurry_scaling: "allow_blurry_scaling",

pref_key_scaling: "scaling",
pref_value_scaling_prefer_quality: "prefer_quality",
pref_value_scaling_prefer_size: "prefer_size",
});

0 comments on commit 9898e6d

Please sign in to comment.