Skip to content

Commit

Permalink
J2D: Support multiple root-level panes for J2DScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
themikelester committed Dec 28, 2024
1 parent 6ef04e6 commit 8c85c4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 10 additions & 7 deletions src/Common/JSYSTEM/J2Dv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ function readPAN1Chunk(buffer: ArrayBufferSlice, parent: PAN1 | null): PAN1 {
//#endregion Loading/J2Pane

//#region Loading/J2Screen
export interface SCRN {
inf1: INF1;
panes: PAN1[];
export interface SCRN extends PAN1 {
color: Color
}

export class BLO {
Expand All @@ -194,7 +193,11 @@ export class BLO {
const inf1 = readINF1Chunk(j2d.nextChunk('INF1'))
const panes: PAN1[] = [];

let parentStack: (PAN1 | null)[] = [null];
const screen: SCRN = { parent: null, type: 'SCRN', children: [], visible: true,
x: 0, y: 0, w: inf1.width, h: inf1.height, color: inf1.color, rot: 0, tag: '', basePos: 0,
alpha: inf1.color.a, inheritAlpha: false, offset: 0 };

let parentStack: (PAN1 | null)[] = [screen];
let shouldContinue = true;
while (shouldContinue) {
const magic = readString(buffer, j2d.offs, 4);
Expand Down Expand Up @@ -226,7 +229,7 @@ export class BLO {
}
}

return { inf1, panes };
return screen;
}
}

Expand Down Expand Up @@ -453,8 +456,8 @@ export class J2DScreen extends J2DPane {
public color: Color

constructor(data: SCRN, cache: GfxRenderCache) {
super(data.panes[0], cache, null);
this.color = data.inf1.color;
super(data, cache, null);
this.color = data.color;
}

public override draw(renderInstManager: GfxRenderInstManager, viewerRenderInput: ViewerRenderInput, ctx2D: J2DGrafContext, offsetX?: number, offsetY?: number): void {
Expand Down
6 changes: 3 additions & 3 deletions src/ZeldaWindWaker/d_place_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export class d_place_name extends msg_class {
}

this.screen = new J2DScreen(screen, globals.renderer.renderCache);
this.screen.children[0].data.visible = false;
this.screen.children[1].data.visible = false;
const pic = this.screen.children[2] as J2DPicture;
this.screen.children[0].children[0].data.visible = false;
this.screen.children[0].children[1].data.visible = false;
const pic = this.screen.children[0].children[2] as J2DPicture;
pic.setTexture(img);

return cPhs__Status.Complete;
Expand Down

0 comments on commit 8c85c4b

Please sign in to comment.