Skip to content

Commit

Permalink
Merge pull request #289 from mcottontensor/backport/UE5.2/pr-288
Browse files Browse the repository at this point in the history
[UE5.2] Merge pull request #288 from mcottontensor/longer_afk
  • Loading branch information
mcottontensor authored Oct 1, 2024
2 parents c9cb6f9 + a83bfa2 commit e68045c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Frontend/library/src/Config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export class Config {
'AFK timeout',
'The time (in seconds) it takes for the application to time out if AFK timeout is enabled.',
0 /*min*/,
600 /*max*/,
null /*max*/,
120 /*value*/,
useUrlParams
)
Expand Down
18 changes: 13 additions & 5 deletions Frontend/library/src/Config/SettingNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { SettingBase } from './SettingBase';
export class SettingNumber<
CustomIds extends string = NumericParametersIds
> extends SettingBase {
_min: number;
_max: number;
_min: number | null;
_max: number | null;

id: NumericParametersIds | CustomIds;
onChangeEmit: (changedValue: number) => void;
Expand All @@ -20,8 +20,8 @@ export class SettingNumber<
id: NumericParametersIds | CustomIds,
label: string,
description: string,
min: number,
max: number,
min: number | null,
max: number | null,
defaultNumber: number,
useUrlParams: boolean,
// eslint-disable-next-line @typescript-eslint/no-empty-function
Expand Down Expand Up @@ -83,7 +83,15 @@ export class SettingNumber<
* @returns The clamped number.
*/
public clamp(inNumber: number): number {
return Math.max(Math.min(this._max, inNumber), this._min);
if (this._min == null && this._max == null) {
return inNumber;
} else if (this._min == null) {
return Math.min(this._max, inNumber);
} else if (this._max == null) {
return Math.max(this._min, inNumber);
} else {
return Math.max(Math.min(this._max, inNumber), this._min);
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions Frontend/ui-library/src/Config/SettingUINumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ export class SettingUINumber<
if (!this._spinner) {
this._spinner = document.createElement('input');
this._spinner.type = 'number';
this._spinner.min = this.setting.min.toString();
this._spinner.max = this.setting.max.toString();
if (this.setting.min != null) {
this._spinner.min = this.setting.min.toString();
}
if (this.setting.max != null) {
this._spinner.max = this.setting.max.toString();
}
this._spinner.value = this.setting.number.toString();
this._spinner.title = this.setting.description;
this._spinner.classList.add('form-control');
Expand Down

0 comments on commit e68045c

Please sign in to comment.