mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2026-02-14 12:22:42 +00:00
adding basic modal system
This commit is contained in:
21
assets/Scripts/Services/ModalWindowSystem/ModalWindow.ts
Normal file
21
assets/Scripts/Services/ModalWindowSystem/ModalWindow.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Component } from "cc";
|
||||
import { delay } from "../Utils/AsyncUtils";
|
||||
|
||||
export abstract class ModalWindow<TParam, TResult> extends Component {
|
||||
private result: TResult;
|
||||
private isDismissed = false;
|
||||
|
||||
public async runAsync(params?: TParam): Promise<TResult> {
|
||||
this.setup(params);
|
||||
while (!this.isDismissed) await delay(100);
|
||||
|
||||
return this.result;
|
||||
}
|
||||
|
||||
protected abstract setup(params?: TParam): void;
|
||||
|
||||
protected dismiss(result?: TResult): void {
|
||||
this.result = result;
|
||||
this.isDismissed = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user