Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setting to lock mobile joystick positions #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,12 @@ <h3 translation="settings"></h3>
<input type="checkbox" id="toggle-auto-pickup">
</label>
</div>
<div class="modal-item checkbox-setting">
<label>
<span class="setting-title">Lock joystick position</span>
<input type="checkbox" id="toggle-mobile-joystick-lock">
</label>
</div>
<div class="modal-item checkbox-setting">
<label>
<span class="setting-title"><span translation="settings_hires_textures"></span><i>*</i></span>
Expand Down
16 changes: 14 additions & 2 deletions client/src/scripts/managers/inputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,25 @@ export class InputManager {
const leftJoyStick = nipplejs.create({
zone: $("#left-joystick-container")[0],
size,
color: `rgba(255, 255, 255, ${transparency})`
color: `rgba(255, 255, 255, ${transparency})`,
...(game.console.getBuiltInCVar("mb_joystick_lock")
? {
position: { top: "50%", left: "25%" },
mode: "static"
}
: {})
});

const rightJoyStick = nipplejs.create({
zone: $("#right-joystick-container")[0],
size,
color: `rgba(255, 255, 255, ${transparency})`
color: `rgba(255, 255, 255, ${transparency})`,
...(game.console.getBuiltInCVar("mb_joystick_lock")
? {
position: { top: "50%", right: "-25%" },
mode: "static"
}
: {})
});

let rightJoyStickUsed = false;
Expand Down
1 change: 1 addition & 0 deletions client/src/scripts/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,7 @@ export async function setUpUI(game: Game): Promise<void> {
addCheckboxListener("#toggle-mobile-controls", "mb_controls_enabled");
addSliderListener("#slider-joystick-size", "mb_joystick_size");
addSliderListener("#slider-joystick-transparency", "mb_joystick_transparency");
addCheckboxListener("#toggle-mobile-joystick-lock", "mb_joystick_lock");
addCheckboxListener("#toggle-high-res-mobile", "mb_high_res_textures");

function updateUiScale(): void {
Expand Down
2 changes: 2 additions & 0 deletions client/src/scripts/utils/console/defaultClientCVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const CVarCasters = Object.freeze({
mb_controls_enabled: Casters.toBoolean,
mb_joystick_size: Casters.toNumber,
mb_joystick_transparency: Casters.toNumber,
mb_joystick_lock: Casters.toBoolean,
mb_high_res_textures: Casters.toBoolean,

dv_password: Casters.toString,
Expand Down Expand Up @@ -217,6 +218,7 @@ export const defaultClientCVars: SimpleCVarMapping = Object.freeze({
mb_controls_enabled: true,
mb_joystick_size: 150,
mb_joystick_transparency: 0.8,
mb_joystick_lock: false,
mb_high_res_textures: false,

dv_password: "",
Expand Down