Skip to content

Commit

Permalink
refactor: Component, AnimBase and AnimFrame class names
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet-jordan committed May 30, 2024
1 parent 477d8fd commit 4a903d4
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 252 deletions.
82 changes: 41 additions & 41 deletions src/js/client.ts

Large diffs are not rendered by default.

172 changes: 86 additions & 86 deletions src/js/game.ts

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions src/js/interface-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import NpcType from './jagex2/config/NpcType';
import IdkType from './jagex2/config/IdkType';
import SpotAnimType from './jagex2/config/SpotAnimType';
import VarpType from './jagex2/config/VarpType';
import ComType from './jagex2/config/ComType';
import Component from './jagex2/config/Component';

import Draw3D from './jagex2/graphics/Draw3D';
import PixFont from './jagex2/graphics/PixFont';
import Model from './jagex2/graphics/Model';
import SeqBase from './jagex2/graphics/SeqBase';
import SeqFrame from './jagex2/graphics/SeqFrame';
import AnimBase from './jagex2/graphics/AnimBase';
import AnimFrame from './jagex2/graphics/AnimFrame';

import Jagfile from './jagex2/io/Jagfile';

Expand All @@ -36,8 +36,8 @@ class InterfaceEditor extends Client {
super(false);
}

activeInterface: ComType | null = null;
activeComponent: ComType | null = null;
activeInterface: Component | null = null;
activeComponent: Component | null = null;
stickyComponent: boolean = false;
movingComponent: boolean = false;
movingRelativeX: number = 0;
Expand Down Expand Up @@ -83,8 +83,8 @@ class InterfaceEditor extends Client {

await this.showProgress(83, 'Unpacking models');
Model.unpack(models);
SeqBase.unpack(models);
SeqFrame.unpack(models);
AnimBase.unpack(models);
AnimFrame.unpack(models);

await this.showProgress(86, 'Unpacking config');
SeqType.unpack(config);
Expand All @@ -100,7 +100,7 @@ class InterfaceEditor extends Client {
Wave.unpack(sounds);

await this.showProgress(92, 'Unpacking interfaces');
ComType.unpack(interfaces, media, [this.fontPlain11, this.fontPlain12, this.fontBold12, this.fontQuill8]);
Component.unpack(interfaces, media, [this.fontPlain11, this.fontPlain12, this.fontBold12, this.fontQuill8]);

await this.showProgress(97, 'Preparing game engine');
WordFilter.unpack(wordenc);
Expand All @@ -111,7 +111,7 @@ class InterfaceEditor extends Client {
this.drawArea?.bind();
Draw3D.init2D();

this.activeInterface = ComType.instances[0];
this.activeInterface = Component.instances[0];
} catch (err) {
this.errorLoading = true;
console.error(err);
Expand Down Expand Up @@ -251,7 +251,7 @@ class InterfaceEditor extends Client {
}
};

simulateClientInput = (com: ComType, mouseX: number, mouseY: number, x: number, y: number, scrollPosition: number): void => {
simulateClientInput = (com: Component, mouseX: number, mouseY: number, x: number, y: number, scrollPosition: number): void => {
if (com.type !== 0 || !com.childId || !com.childX || !com.childY || mouseX < x || mouseY < y || mouseX > x + com.width || mouseY > y + com.height) {
return;
}
Expand All @@ -260,7 +260,7 @@ class InterfaceEditor extends Client {
for (let i: number = 0; i < children; i++) {
let childX: number = com.childX[i] + x;
let childY: number = com.childY[i] + y - scrollPosition;
const child: ComType = ComType.instances[com.childId[i]];
const child: Component = Component.instances[com.childId[i]];

childX += child.x;
childY += child.y;
Expand All @@ -278,31 +278,31 @@ class InterfaceEditor extends Client {
} else if (mouseX >= childX && mouseY >= childY && mouseX < childX + child.width && mouseY < childY + child.height) {
if (child.buttonType !== 0 && child.option && child.option.length) {
this.tooltip = child.option;
} else if (child.buttonType === ComType.BUTTON_CLOSE) {
} else if (child.buttonType === Component.BUTTON_CLOSE) {
this.tooltip = 'Close';
}
}
}
};

getActiveComponent = (com: ComType, mouseX: number, mouseY: number, x: number, y: number, scrollPosition: number): ComType | null => {
getActiveComponent = (com: Component, mouseX: number, mouseY: number, x: number, y: number, scrollPosition: number): Component | null => {
if (com.type !== 0 || !com.childId || !com.childX || !com.childY || mouseX < x || mouseY < y || mouseX > x + com.width || mouseY > y + com.height) {
return null;
}

let active: ComType | null = null;
let active: Component | null = null;

const children: number = com.childId.length;
for (let i: number = 0; i < children; i++) {
let childX: number = com.childX[i] + x;
let childY: number = com.childY[i] + y - scrollPosition;
const child: ComType = ComType.instances[com.childId[i]];
const child: Component = Component.instances[com.childId[i]];

childX += child.x;
childY += child.y;

if (child.type === 0) {
const childActive: ComType | null = this.getActiveComponent(child, mouseX, mouseY, childX, childY, child.scrollPosition);
const childActive: Component | null = this.getActiveComponent(child, mouseX, mouseY, childX, childY, child.scrollPosition);

if (childActive) {
active = childActive;
Expand Down
8 changes: 4 additions & 4 deletions src/js/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import ObjType from './jagex2/config/ObjType';
import Draw3D from './jagex2/graphics/Draw3D';
import PixFont from './jagex2/graphics/PixFont';
import Model from './jagex2/graphics/Model';
import SeqBase from './jagex2/graphics/SeqBase';
import SeqFrame from './jagex2/graphics/SeqFrame';
import AnimBase from './jagex2/graphics/AnimBase';
import AnimFrame from './jagex2/graphics/AnimFrame';

import Jagfile from './jagex2/io/Jagfile';

Expand Down Expand Up @@ -84,8 +84,8 @@ class Items extends Client {

await this.showProgress(83, 'Unpacking models');
Model.unpack(models);
SeqBase.unpack(models);
SeqFrame.unpack(models);
AnimBase.unpack(models);
AnimFrame.unpack(models);

await this.showProgress(86, 'Unpacking config');
SeqType.unpack(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import JString from '../datastruct/JString';
import {TypedArray1d} from '../util/Arrays';
import Draw2D from '../graphics/Draw2D';

export default class ComType {
static instances: ComType[] = [];
export default class Component {
static instances: Component[] = [];
static imageCache: LruCache | null = null;
static modelCache: LruCache | null = null;

Expand Down Expand Up @@ -116,7 +116,7 @@ export default class ComType {
id = dat.g2;
}

const com: ComType = (this.instances[id] = new ComType());
const com: Component = (this.instances[id] = new Component());
com.id = id;
com.layer = layer;
com.type = dat.g1;
Expand Down Expand Up @@ -158,7 +158,7 @@ export default class ComType {
}
}

if (com.type === ComType.TYPE_LAYER) {
if (com.type === Component.TYPE_LAYER) {
com.scroll = dat.g2;
com.hide = dat.g1 === 1;

Expand All @@ -174,11 +174,11 @@ export default class ComType {
}
}

if (com.type === ComType.TYPE_UNUSED) {
if (com.type === Component.TYPE_UNUSED) {
dat.pos += 3;
}

if (com.type === ComType.TYPE_INV) {
if (com.type === Component.TYPE_INV) {
com.invSlotObjId = new Int32Array(com.width * com.height);
com.invSlotObjCount = new Int32Array(com.width * com.height);

Expand Down Expand Up @@ -216,11 +216,11 @@ export default class ComType {
}
}

if (com.type === ComType.TYPE_RECT) {
if (com.type === Component.TYPE_RECT) {
com.fill = dat.g1 === 1;
}

if (com.type === ComType.TYPE_TEXT || com.type === ComType.TYPE_UNUSED) {
if (com.type === Component.TYPE_TEXT || com.type === Component.TYPE_UNUSED) {
com.center = dat.g1 === 1;
const fontId: number = dat.g1;
if (fonts) {
Expand All @@ -229,21 +229,21 @@ export default class ComType {
com.shadowed = dat.g1 === 1;
}

if (com.type === ComType.TYPE_TEXT) {
if (com.type === Component.TYPE_TEXT) {
com.text = dat.gjstr;
com.activeText = dat.gjstr;
}

if (com.type === ComType.TYPE_UNUSED || com.type === ComType.TYPE_RECT || com.type === ComType.TYPE_TEXT) {
if (com.type === Component.TYPE_UNUSED || com.type === Component.TYPE_RECT || com.type === Component.TYPE_TEXT) {
com.colour = dat.g4;
}

if (com.type === ComType.TYPE_RECT || com.type === ComType.TYPE_TEXT) {
if (com.type === Component.TYPE_RECT || com.type === Component.TYPE_TEXT) {
com.activeColour = dat.g4;
com.overColour = dat.g4;
}

if (com.type === ComType.TYPE_GRAPHIC) {
if (com.type === Component.TYPE_GRAPHIC) {
const graphic: string = dat.gjstr;
if (graphic.length > 0) {
const index: number = graphic.lastIndexOf(',');
Expand All @@ -258,7 +258,7 @@ export default class ComType {
}
}

if (com.type === ComType.TYPE_MODEL) {
if (com.type === Component.TYPE_MODEL) {
const model: number = dat.g1;
if (model !== 0) {
com.model = this.getModel(((model - 1) << 8) + dat.g1);
Expand Down Expand Up @@ -288,7 +288,7 @@ export default class ComType {
com.yan = dat.g2;
}

if (com.type === ComType.TYPE_INV_TEXT) {
if (com.type === Component.TYPE_INV_TEXT) {
com.invSlotObjId = new Int32Array(com.width * com.height);
com.invSlotObjCount = new Int32Array(com.width * com.height);

Expand All @@ -315,23 +315,23 @@ export default class ComType {
}
}

if (com.buttonType === ComType.BUTTON_TARGET || com.type === ComType.TYPE_INV) {
if (com.buttonType === Component.BUTTON_TARGET || com.type === Component.TYPE_INV) {
com.actionVerb = dat.gjstr;
com.action = dat.gjstr;
com.actionTarget = dat.g2;
}

if (com.buttonType === ComType.BUTTON_OK || com.buttonType === ComType.BUTTON_TOGGLE || com.buttonType === ComType.BUTTON_SELECT || com.buttonType === ComType.BUTTON_CONTINUE) {
if (com.buttonType === Component.BUTTON_OK || com.buttonType === Component.BUTTON_TOGGLE || com.buttonType === Component.BUTTON_SELECT || com.buttonType === Component.BUTTON_CONTINUE) {
com.option = dat.gjstr;

if (com.option.length === 0) {
if (com.buttonType === ComType.BUTTON_OK) {
if (com.buttonType === Component.BUTTON_OK) {
com.option = 'Ok';
} else if (com.buttonType === ComType.BUTTON_TOGGLE) {
} else if (com.buttonType === Component.BUTTON_TOGGLE) {
com.option = 'Select';
} else if (com.buttonType === ComType.BUTTON_SELECT) {
} else if (com.buttonType === Component.BUTTON_SELECT) {
com.option = 'Select';
} else if (com.buttonType === ComType.BUTTON_CONTINUE) {
} else if (com.buttonType === Component.BUTTON_CONTINUE) {
com.option = 'Continue';
}
}
Expand Down Expand Up @@ -530,7 +530,7 @@ export default class ComType {
return this.x;
}

let parent: ComType = ComType.instances[this.layer];
let parent: Component = Component.instances[this.layer];
if (!parent.childId || !parent.childX || !parent.childY) {
return this.x;
}
Expand All @@ -542,7 +542,7 @@ export default class ComType {

let x: number = parent.childX[childIndex];
while (parent.layer !== parent.id) {
const grandParent: ComType = ComType.instances[parent.layer];
const grandParent: Component = Component.instances[parent.layer];
if (grandParent.childId && grandParent.childX && grandParent.childY) {
childIndex = grandParent.childId.indexOf(parent.id);
if (childIndex !== -1) {
Expand All @@ -560,7 +560,7 @@ export default class ComType {
return this.y;
}

let parent: ComType = ComType.instances[this.layer];
let parent: Component = Component.instances[this.layer];
if (!parent.childId || !parent.childX || !parent.childY) {
return this.y;
}
Expand All @@ -572,7 +572,7 @@ export default class ComType {

let y: number = parent.childY[childIndex];
while (parent.layer !== parent.id) {
const grandParent: ComType = ComType.instances[parent.layer];
const grandParent: Component = Component.instances[parent.layer];
if (grandParent.childId && grandParent.childX && grandParent.childY) {
childIndex = grandParent.childId.indexOf(parent.id);
if (childIndex !== -1) {
Expand All @@ -599,7 +599,7 @@ export default class ComType {
this.x = 0;
this.y = 0;

const parent: ComType = ComType.instances[this.layer];
const parent: Component = Component.instances[this.layer];

if (parent.childId && parent.childX && parent.childY) {
const childIndex: number = parent.childId.indexOf(this.id);
Expand All @@ -616,7 +616,7 @@ export default class ComType {
return;
}

const parent: ComType = ComType.instances[this.layer];
const parent: Component = Component.instances[this.layer];

if (parent.childId && parent.childX && parent.childY) {
const childIndex: number = parent.childId.indexOf(this.id);
Expand Down
4 changes: 2 additions & 2 deletions src/js/jagex2/config/SeqType.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Jagfile from '../io/Jagfile';
import {ConfigType} from './ConfigType';
import Packet from '../io/Packet';
import SeqFrame from '../graphics/SeqFrame';
import AnimFrame from '../graphics/AnimFrame';

export default class SeqType extends ConfigType {
static count: number = 0;
Expand Down Expand Up @@ -60,7 +60,7 @@ export default class SeqType extends ConfigType {

this.delay[i] = dat.g2;
if (this.delay[i] === 0) {
this.delay[i] = SeqFrame.instances[this.frames[i]].delay;
this.delay[i] = AnimFrame.instances[this.frames[i]].delay;
}

if (this.delay[i] === 0) {
Expand Down
14 changes: 7 additions & 7 deletions src/js/jagex2/dash3d/entity/NpcEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import SpotAnimType from '../../config/SpotAnimType';
import SeqType from '../../config/SeqType';

export default class NpcEntity extends PathingEntity {
static ANIM: number = 0x2;
static FACE_ENTITY: number = 0x4;
static SAY: number = 0x8;
static DAMAGE: number = 0x10;
static CHANGE_TYPE: number = 0x20;
static SPOTANIM: number = 0x40;
static FACE_COORD: number = 0x80;
static readonly ANIM: number = 0x2;
static readonly FACE_ENTITY: number = 0x4;
static readonly SAY: number = 0x8;
static readonly DAMAGE: number = 0x10;
static readonly CHANGE_TYPE: number = 0x20;
static readonly SPOTANIM: number = 0x40;
static readonly FACE_COORD: number = 0x80;

type: NpcType | null = null;

Expand Down
20 changes: 10 additions & 10 deletions src/js/jagex2/dash3d/entity/PlayerEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import {TypedArray1d} from '../../util/Arrays';
import Colors from '../../graphics/Colors';

export default class PlayerEntity extends PathingEntity {
static APPEARANCE: number = 0x1;
static ANIM: number = 0x2;
static FACE_ENTITY: number = 0x4;
static SAY: number = 0x8;
static DAMAGE: number = 0x10;
static FACE_COORD: number = 0x20;
static CHAT: number = 0x40;
static BIG_UPDATE: number = 0x80;
static SPOTANIM: number = 0x100;
static EXACT_MOVE: number = 0x200;
static readonly APPEARANCE: number = 0x1;
static readonly ANIM: number = 0x2;
static readonly FACE_ENTITY: number = 0x4;
static readonly SAY: number = 0x8;
static readonly DAMAGE: number = 0x10;
static readonly FACE_COORD: number = 0x20;
static readonly CHAT: number = 0x40;
static readonly BIG_UPDATE: number = 0x80;
static readonly SPOTANIM: number = 0x100;
static readonly EXACT_MOVE: number = 0x200;

// prettier-ignore
static readonly TORSO_RECOLORS: number[] = [
Expand Down
Loading

0 comments on commit 4a903d4

Please sign in to comment.