MCPcopy Create free account
hub / github.com/KilledByAPixel/LittleJS / constructor

Method constructor

plugins/uiSystem.js:51–304  ·  view source on GitHub ↗

Create the global UI system object * @param {CanvasRenderingContext2D} [context] * @example * // create the ui plugin object * new UISystemPlugin;

(context=mainContext)

Source from the content-addressed store, hash-verified

49 * new UISystemPlugin;
50 */
51 constructor(context=mainContext)
52 {
53 ASSERT(!uiSystem, 'UI system already initialized');
54 uiSystem = this;
55
56 // default settings
57 /** @property {boolean} - Activate when mouse is pressed down instead of clicked */
58 this.activateOnPress = false;
59 /** @property {Color} - Default fill color for UI elements */
60 this.defaultColor = WHITE;
61 /** @property {Color} - Default outline color for UI elements */
62 this.defaultLineColor = BLACK;
63 /** @property {Color} - Default text color for UI elements */
64 this.defaultTextColor = BLACK;
65 /** @property {Color} - Default button color for UI elements */
66 this.defaultButtonColor = hsl(0,0,.7);
67 /** @property {Color} - Default hover color for UI elements */
68 this.defaultHoverColor = hsl(0,0,.9);
69 /** @property {Color} - Default color for disabled UI elements */
70 this.defaultDisabledColor = hsl(0,0,.3);
71 /** @property {Color} - Uses a gradient fill combined with color */
72 this.defaultGradientColor = undefined;
73 /** @property {number} - Default line width for UI elements */
74 this.defaultLineWidth = 4;
75 /** @property {number} - Default rounded rect corner radius for UI elements */
76 this.defaultCornerRadius = 0;
77 /** @property {number} - Default scale to use for fitting text to object */
78 this.defaultTextFitScale = .8;
79 /** @property {string} - Default font for UI elements */
80 this.defaultFont = fontDefault;
81 /** @property {Sound} - Default sound when interactive UI element is pressed */
82 this.defaultSoundPress = undefined;
83 /** @property {Sound} - Default sound when interactive UI element is released */
84 this.defaultSoundRelease = undefined;
85 /** @property {Sound} - Default sound when interactive UI element is clicked */
86 this.defaultSoundClick = undefined;
87 /** @property {Color} - Color for shadow */
88 this.defaultShadowColor = CLEAR_BLACK;
89 /** @property {number} - Size of shadow blur */
90 this.defaultShadowBlur = 5;
91 /** @property {Vector2} - Offset of shadow blur */
92 this.defaultShadowOffset = vec2(5);
93 /** @property {number} - If set ui coords will be renormalized to this canvas height */
94 this.nativeHeight = 0;
95
96 // navigation properties
97 /** @property {UIObject} - Object currently selected by navigation (gamepad or keyboard) */
98 this.navigationObject = undefined;
99 /** @property {Timer} - Cool down timer for navigation inputs */
100 this.navigationTimer = new Timer(undefined, true);
101 /** @property {number} - Time between navigation inputs in seconds */
102 this.navigationDelay = .2;
103 /** @property {boolean} - should the navigation be horizontal, vertical, or both? */
104 this.navigationDirection = 1;
105 /** @property {boolean} - True if user last used navigation instead of mouse */
106 this.navigationMode = false;
107
108 // system state

Callers

nothing calls this directly

Calls 5

hslFunction · 0.85
vec2Function · 0.85
engineAddPluginFunction · 0.85
onKeyDownMethod · 0.80
ASSERTFunction · 0.50

Tested by

no test coverage detected