Skip to content

Commit

Permalink
Added Resolution and ScaledResolution getter methods to Screen class
Browse files Browse the repository at this point in the history
  • Loading branch information
mythicalbro committed Oct 14, 2020
1 parent 08a2a94 commit 01c088f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/ui/Screen.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
import { Audio } from '../Audio';
import { HudColor, NotificationType } from '../enums';
import { Color, PointF, stringToArray, Vector3 } from '../utils';
import { Color, PointF, Size, stringToArray, Vector3 } from '../utils';
import { Notification } from './';

export abstract class Screen {
public static get Width(): number {
return GetScreenActiveResolution()[0];
public static get Resolution(): Size {
const [width, height] = GetScreenActiveResolution();
return new Size(width, height);
}

public static get Height(): number {
return GetScreenActiveResolution()[1];
public static get ScaledResolution(): Size {
const height = this.Height;
return new Size(height * this.AspectRatio, height);
}

public static get AspectRatio(): number {
return GetAspectRatio(false);
public static get Width(): number {
return this.Resolution.width;
}

public static get ScaledWidth(): number {
return this.Height * this.AspectRatio;
}

public static get Height(): number {
return this.Resolution.height;
}

public static get AspectRatio(): number {
return GetAspectRatio(false);
}

public static showSubtitle(message: string, duration = 2500): void {
const strings: string[] = stringToArray(message);

Expand Down

0 comments on commit 01c088f

Please sign in to comment.