feat: add NpcDialogueForm

This commit is contained in:
KobeBryant114514
2024-10-10 11:59:48 +08:00
Unverified
parent efacbeb89b
commit 5cc610a830
2 changed files with 130 additions and 7 deletions
+55 -2
View File
@@ -1,6 +1,10 @@
const getNextCallbackId = ll.import("GMLIB_FormAPI", "getNextFormCallbackId");
class ServerSettingForm {
constructor() {
throw new Error("Static class cannot be instantiated");
}
static getDefaultPriority() {
return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
}
@@ -123,7 +127,56 @@ class ServerSettingForm {
static removeElement(id) {
return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
}
}
module.exports = { ServerSettingForm };
class NpcDialogueForm {
constructor(npcName, sceneName, dialogue) {
this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
}
addButton(button) {
return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
}
sendTo(pl, callback = (pl, index, type) => { }, free = true) {
let callbackId = getNextCallbackId();
ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
if (free) {
this.destroy();
}
}
destroy() {
ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
}
}
class ChestForm {
constructor(npcName, sceneName, dialogue) {
this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
}
addButton(button) {
return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
}
sendTo(pl, free = true) {
//let callbackId = getNextCallbackId();
//ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
//ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
//if (free) {
// this.destroy();
//}
}
destroy() {
//ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
}
}
module.exports = {
ServerSettingForm,
NpcDialogueForm,
ChestForm
};