Skip to content

Commit 93a0ba9

Browse files
Trico-EverfireWano-k
authored andcommitted
Add additional functionality for inject plugin function to allow 'this' context and function parameters.
1 parent 32f9f89 commit 93a0ba9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/Manager/Plugins.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
import { IO, Paths, Constants, Utils } from "../Common";
1111
import { System } from "../index";
1212

13+
type ClassMethod<T extends NewableFunction,M extends keyof T["prototype"]> = (this:T["prototype"], ...args:Parameters<T["prototype"][M]>) => ReturnType<T["prototype"][M]>
14+
1315
/** @class
1416
* The class who handles plugins of RPG Paper Maker.
1517
* @static
16-
* @author Nio Kasgami, Wano
18+
* @author Nio Kasgami, Wano, Trico Everfire
1719
*/
1820
class Plugins {
1921

@@ -182,8 +184,6 @@ class Plugins {
182184
*/
183185
}
184186

185-
186-
187187
/**
188188
* @static
189189
* @usage This function is used to inject/overwrite original class methods and variables.
@@ -195,8 +195,8 @@ class Plugins {
195195
* @param overwrite (METHODS ONLY) Should call original method's code or overwrite original method. (DEFAULT: false)
196196
* @param loadBefore (METHODS ONLY) Should original method's code be executed before or after your code (NOTE: This is obviously disabled if param overwrite is set to true.) (DEFAULT: true)
197197
*/
198-
static inject<T extends NewableFunction, M extends keyof T, LT extends keyof T["prototype"], TR = string, LM = NewableFunction>(
199-
classObject: T, prototypeName: LT | TR | M, prototype:T["prototype"][LT]
198+
static inject<T extends NewableFunction, M extends keyof T, LT extends keyof T["prototype"], CXT = ClassMethod<T,LT>, TR = string, LM = NewableFunction>(
199+
classObject: T, prototypeName: LT | TR | M, prototype:CXT
200200
| T[M] | LM, staticType :boolean = false, overwrite: boolean = false,
201201
loadOriginalBefore: boolean = true) {
202202
let TheAnyPrototype:any = prototype; //force any type, system will not accept otherwise!

0 commit comments

Comments
 (0)