Skip to content

Commit 1a7e096

Browse files
Adjust typings and formatting on rpg_core
1 parent 1caf8eb commit 1a7e096

23 files changed

+253
-366
lines changed

lib/rpg_core/Bitmap.d.ts

Lines changed: 27 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,69 @@
11
import * as PIXI from "pixi.js";
2+
23
import { Rectangle } from "./Rectangle";
34
import { Stage } from "./Stage";
45

5-
6-
// TODO : document the class?
7-
8-
/**
9-
* The basic object that rpresents an image.
10-
*
11-
* @class Bitmap
12-
*/
136
declare class Bitmap {
147

15-
/**
16-
* The base texture that holds the image.
17-
*
18-
* @type {PIXI.BaseTexture}
19-
* @memberof Bitmap
20-
*/
21-
8+
constructor(width: number, height: number);
229

10+
public readonly url: string;
2311
public readonly baseTexture : PIXI.BaseTexture;
24-
25-
/**
26-
* The bitmap canvas.
27-
*
28-
* @type {HTMLCanvasElement}
29-
* @memberof Bitmap
30-
*/
12+
public readonly image: HTMLImageElement;
3113
public readonly canvas: HTMLCanvasElement;
32-
33-
/**
34-
* The 2d context of the bitmap canvas.
35-
*
36-
* @type {CanvasRenderingContext2D}
37-
* @memberof Bitmap
38-
*/
3914
public readonly context: CanvasRenderingContext2D;
4015

41-
public fontBold: boolean;
16+
public readonly width: number;
17+
public readonly height: number;
18+
public readonly rect: Rectangle
4219

43-
public fontFace: string;
20+
public smooth: boolean;
4421

45-
public fontItalic: boolean;
22+
public paintOpacity: number;
4623

24+
public fontFace: string;
4725
public fontSize: number;
26+
public fontBold: boolean;
27+
public fontItalic: boolean;
4828

49-
public readonly image: HTMLImageElement;
29+
public textColor: string;
5030

5131
public outlineColor: string;
52-
5332
public outlineWidth: number;
5433

55-
public paintOpacity: number;
56-
57-
public readonly rect: Rectangle
58-
59-
public smooth: boolean;
60-
61-
public textColor: string;
62-
63-
public readonly url: string;
64-
65-
public readonly width: number;
66-
67-
public readonly height: number;
68-
69-
/**
70-
* Creates an instance of Bitmap.
71-
* @param {number} width The width of the bitmap.
72-
* @param {number} height The height of the bitmap.
73-
* @memberof Bitmap
74-
*/
75-
constructor(width: number, height: number);
76-
7734
public static load(url: string): Bitmap;
78-
7935
public static snap(stage: Stage): Bitmap;
8036

81-
// eslint-disable-next-line @typescript-eslint/ban-types
82-
public addLoadListener(listner: Function): void;
37+
public isError(): boolean;
38+
public isReady(): boolean;
8339

84-
public blt(source: Bitmap,sx: number,sy: number,sw: number,sh: number, dx: number,dy: number, dw: number, dh: number): void;
40+
public retry(): void;
8541

86-
public clear(): void;
42+
public addLoadListener(listener: (self: Bitmap) => void): void;
8743

44+
public blt(source: Bitmap, sx: number, sy: number, sw: number, sh: number, dx: number,dy: number, dw: number, dh: number): void;
45+
46+
public clear(): void;
8847
public clearRect(x: number, y: number, width: number, height: number): void;
8948

9049
public destroy(): void;
9150

9251
public drawCircle(x: number, y: number, radius: number, color: number): void;
93-
94-
public drawText(text: string | number,x: number,y: number, maxWidth: number, lineHeight:number, align: string): void;
52+
public drawText(text: string | number, x: number, y: number, maxWidth: number, lineHeight:number, align: string): void;
9553

9654
public fillAll(color: string): void;
55+
public fillRect(x: number, y:number, width: number, height: number, color: string): void;
56+
public gradientFillRect(x: number, y: number, width: number, height: number, color1: string, color2: string, vertical: boolean): void;
9757

98-
public fillRect(x: number,y:number,width: number, height: number, color: string): void;
99-
10058
public getAlphaPixel(x:number, y: number): string;
101-
10259
public getPixel(x: number, y: number): string;
10360

104-
public gradientFillRect(x: number, y: number, width: number, height: number, color1: string, color2: string, vertical: boolean): void;
105-
106-
public isError(): boolean;
107-
108-
public isReady(): boolean;
109-
110-
public measureTextwidth(text: string): number;
111-
112-
public retry(): void;
61+
public measureTextWidth(text: string): number;
11362

11463
public strokeRect(x: number, y: number, width: number, height: number, color: string): void;
11564

116-
public resize(width: number, height: number)
65+
public resize(width: number, height: number): void;
66+
11767
}
11868

119-
export {Bitmap}
69+
export { Bitmap };

lib/rpg_core/ColorFilter.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as PIXI from "pixi.js";
22

3-
type ColorTone = [number,number,number,number];
3+
type ColorTone = [number, number, number, number];
44

55
declare class ColorFilter extends PIXI.Filter {
66

@@ -12,12 +12,11 @@ declare class ColorFilter extends PIXI.Filter {
1212

1313
public setColorTone(tone: ColorTone): void;
1414

15-
public setHue(hue: number);
15+
public setHue(hue: number): void;
1616

1717
}
1818

1919
export {
2020
ColorFilter,
2121
ColorTone
22-
23-
}
22+
};

lib/rpg_core/Graphics.d.ts

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
11
import * as PIXI from "pixi.js";
2+
23
import { EffekseerContext } from "effekseer";
34
import { Stage } from "./Stage";
45

5-
declare class Graphics {
6-
7-
public static app: PIXI.Application;
8-
public static boxHeight: number;
9-
public static boxWidth: number;
10-
public static defaultScale: number;
11-
public static effekseer: EffekseerContext;
12-
public static frameCount: number;
13-
public static height: number;
14-
public static width: number;
15-
16-
public static endLoading(): boolean;
17-
public static eraseError(): void;
18-
public static hideScreen(): void;
19-
public static initialize(): boolean;
20-
public static isInsideCanvas(x: number, y: number): boolean;
21-
public static pageToCanvasX(x: number): number;
22-
public static pageToCanvasY(y: number): number;
23-
public static printError(name: string, message: string, error: Error): void;
24-
public static resize(width: number, height: number): void;
25-
public static setStage(stage: Stage): void;
26-
public static setTickHandler(handler: Function): void;
27-
public static showRetryButton(retry: Function): void;
28-
public static showScreen(): void;
29-
public static startGameLoop(): void;
30-
public static startLoading(): void;
31-
public static stopGameLoop(): void;
6+
declare namespace Graphics {
7+
8+
export const app: PIXI.Application;
9+
10+
export let boxHeight: number;
11+
export let boxWidth: number;
12+
export let defaultScale: number;
13+
14+
export const effekseer: EffekseerContext;
15+
16+
export let frameCount: number;
17+
export let height: number;
18+
export let width: number;
19+
20+
export function initialize(): boolean;
21+
22+
export function endLoading(): boolean;
23+
24+
export function eraseError(): void;
25+
export function hideScreen(): void;
26+
27+
export function isInsideCanvas(x: number, y: number): boolean;
28+
29+
export function pageToCanvasX(x: number): number;
30+
export function pageToCanvasY(y: number): number;
31+
32+
export function printError(name: string, message: string, error: Error): void;
33+
34+
export function resize(width: number, height: number): void;
35+
36+
export function setStage(stage: Stage): void;
37+
38+
export function setTickHandler(handler: (delta: number) => void): void;
39+
40+
export function showRetryButton(retry: () => void): void;
41+
export function showScreen(): void;
42+
43+
export function startGameLoop(): void;
44+
export function startLoading(): void;
45+
export function stopGameLoop(): void;
46+
3247
}
33-
export {
34-
Graphics
35-
}
48+
49+
export { Graphics };

lib/rpg_core/Input.d.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import {RPG} from "./RPG";
2-
declare class Input {
1+
import { RPG } from "./RPG";
32

4-
public static readonly date: number;
5-
public static readonly dir4: number;
6-
public static readonly dir8: number;
7-
public static gamepadMapper: RPG.InputGamepad;
8-
public static keyMapper: RPG.InputKey;
9-
public static keyRepeatInterval: number;
10-
public static keyRepeatWait: number;
3+
declare namespace Input {
114

12-
public static clear(): void;
13-
public static initialize(): void;
14-
public static isLongPressed(keyname: string): boolean;
15-
public static isPressed(keyName: string): boolean;
16-
public static isRepeated(keyName: string): boolean;
17-
public static isTriggered(keyName: string): boolean;
18-
public static update(): void;
5+
export const date: number;
6+
export const dir4: number;
7+
export const dir8: number;
8+
9+
export let gamepadMapper: RPG.InputGamepad;
10+
export let keyMapper: RPG.InputKey;
11+
export let keyRepeatInterval: number;
12+
export let keyRepeatWait: number;
1913

20-
}
14+
export function clear(): void;
15+
export function initialize(): void;
16+
export function isLongPressed(keyname: string): boolean;
17+
export function isPressed(keyName: string): boolean;
18+
export function isRepeated(keyName: string): boolean;
19+
export function isTriggered(keyName: string): boolean;
20+
export function update(): void;
2121

22-
export {
23-
Input
2422
}
23+
24+
export { Input };

lib/rpg_core/JsonEx.d.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
2-
declare class JsonEx {
3-
4-
public static maxDepth: number;
1+
declare namespace JsonEx {
2+
export let maxDepth: number;
53

6-
public static makeDeepCopy<T>(object : Object): T;
7-
8-
public static parse<T>(json: string): T;
9-
10-
public static stringify(object: Object): string;
4+
export function makeDeepCopy<T>(object: T): T;
115

6+
export function parse<T>(json: string): T;
7+
export function stringify(object: unknown): string;
128
}
139

14-
export {
15-
JsonEx
16-
}
10+
export { JsonEx };

lib/rpg_core/Point.d.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import * as PIXI from "pixi.js";
22

3-
43
declare class Point extends PIXI.Point {
5-
64
constructor(x: number, y: number);
75
}
86

9-
export {
10-
Point
11-
}
7+
export { Point };

lib/rpg_core/RPG.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export namespace RPG {
1414
14: "left"; // D-pad left
1515
15: "right"; // D-pad right
1616
}
17+
1718
export interface InputKey {
1819
9: "tab"; // tab
1920
13: "ok"; // enter

lib/rpg_core/Rectangle.d.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
11
import * as PIXI from "pixi.js";
22

3-
/**
4-
*The rectangle class
5-
*
6-
* @class Rectangle
7-
* @extends {PIXI.Rectangle}
8-
*/
9-
class Rectangle extends PIXI.Rectangle {
10-
11-
/**
12-
* Creates an instance of Rectangle.
13-
* @param {number} x The x coordinate for the upper-left corner.
14-
* @param {number} y The y coordinate for the upper-left corner.
15-
* @param {number} width The width of the rectangle.
16-
* @param {number} height The height of the rectangle.
17-
* @memberof Rectangle
18-
*/
3+
declare class Rectangle extends PIXI.Rectangle {
194
constructor(x: number, y: number, width: number, height: number);
205
}
216

22-
export {Rectangle}
7+
export { Rectangle };

lib/rpg_core/ScreenSprite.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ declare class ScreenSprite extends PIXI.Container {
88

99
public destroy(): void;
1010

11-
public setBlack(): void;
12-
1311
public setColor(r: number,g: number,b: number): void;
14-
12+
public setBlack(): void;
1513
public setWhite(): void;
14+
1615
}
1716

18-
export {ScreenSprite}
17+
export { ScreenSprite };

0 commit comments

Comments
 (0)