This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch feature/settings into main (#85)
* Implement settings - Implement SettingsManager - Implement Settings classes - Let SettingsManager be available through Services * Bugfixes Fixed usage of isIComplexEntity in renderers. Adapt level1 and level2 to new syntax.
- Loading branch information
Showing
18 changed files
with
110 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Setting<T> { | ||
private _get: (() => T) | undefined; | ||
private _set: ((value: T) => void) | undefined; | ||
|
||
public get(): T { | ||
if (!this._get) { | ||
throw new Error("Get-Method not implemented for this setting."); | ||
} | ||
return this._get(); | ||
} | ||
|
||
public set(value: T): void { | ||
if (!this._set) { | ||
throw new Error("Set-Method not implemented for this setting."); | ||
} | ||
this._set(value); | ||
} | ||
|
||
public constructor( | ||
get: (() => T) | undefined, | ||
set: ((value: T) => void) | undefined | ||
) { | ||
this._get = get; | ||
this._set = set; | ||
} | ||
} | ||
|
||
export default Setting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Setting from "./setting.js"; | ||
|
||
class SettingsManager { | ||
private _settings: Map<string, Setting<any>>; | ||
|
||
constructor() { | ||
this._settings = new Map(); | ||
} | ||
|
||
public has(key: string): boolean { | ||
return this._settings.has(key); | ||
} | ||
|
||
public get<T>(key: string): Setting<T> { | ||
return this._settings.get(key) as Setting<T>; | ||
} | ||
|
||
public set<T>(key: string, value: Setting<T>): void { | ||
this._settings.set(key, value); | ||
} | ||
} | ||
|
||
export default SettingsManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Setting from "./setting"; | ||
|
||
class SimpleSetting<T> extends Setting<T> { | ||
private _value: T; | ||
|
||
private getValue(): T { | ||
return this._value; | ||
} | ||
|
||
private setValue(value: T) { | ||
this._value = value; | ||
} | ||
|
||
constructor(value: T) { | ||
super( | ||
undefined, //Can't use "this" keyword here, so we'll define the methods below | ||
undefined | ||
); | ||
|
||
this._value = value; | ||
|
||
this.getValue = this.getValue.bind(this); | ||
this.setValue = this.setValue.bind(this); | ||
} | ||
} | ||
|
||
export default SimpleSetting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters