forked from MapComplete/MapComplete
Css tweaks
This commit is contained in:
parent
489c6fc3c0
commit
701ce3e89a
23 changed files with 1220 additions and 114 deletions
34
UI/Base/Ornament.ts
Normal file
34
UI/Base/Ornament.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import {UIElement} from "../UIElement";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import Svg from "../../Svg";
|
||||
|
||||
export default class Ornament extends UIElement {
|
||||
private static readonly ornamentsCount = Ornament.countOrnaments();
|
||||
private readonly _index = new UIEventSource<number>(0)
|
||||
|
||||
constructor(index = new UIEventSource<number>(0)) {
|
||||
super(index);
|
||||
this._index = index;
|
||||
this.SetClass("ornament")
|
||||
const self = this;
|
||||
this.onClick(() => {
|
||||
self._index.setData((self._index.data + 1) % Ornament.ornamentsCount);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
private static countOrnaments() {
|
||||
let ornamentCount = 0;
|
||||
for (const key in Svg.All) {
|
||||
if (key.startsWith("Ornament-Horiz-")) {
|
||||
ornamentCount++;
|
||||
}
|
||||
}
|
||||
return ornamentCount;
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
return Svg.All[`Ornament-Horiz-${this._index.data}.svg`]
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue