AT2ZVX7CCT3LEZQQHZEXFGJVZL7RMVGJD26LETXGGJB33VUPNBSQC
VJMS4HGLML2M42HV34Y7UCQQSKNUCKWMXV5OKF2BCUGFGGDVH6SAC
LAYV3N3DGBTXLJG6RCFGHXVTCYD27RMI45MBJOVWMMVNPXMUGREQC
D5HZ4T56PKU6JLAVUXCZI23GSPLFHCF4NCUP63DBVUWQD4B2B7BQC
SGMPSXY74KFNCDFEHW76MML6LULMONLRJLXH4P5TESBOGS3VJVOQC
3UFL673QX2JG7KHTAM7DFH4BBYVHDNMXBS2RW45G3JBNFZFLSRRQC
3AHM23N6D5QHSAUIF6XU6BMWT22KHBOAILIMRH2L6AWVCZ4GXN6QC
MLD2UMGNFL5Q446O6EI5L5JS3RTEZ4IR4VENYHE7RIKBKVYKVUEAC
GZRMSSTEWT3T2JERC7WCVT727X237UA6MXWVT6OSV5D5BRD4UOGQC
L4VMIGM6D5WUEBYOCXBIF6V66NRJAKOJO4FHALHIUIAGAUQUKDPAC
VLNQ64Y6W3IQSKEQNCOT6W3SMITHEVPGT4MI43NONFGOKID66R5QC
IKCJ6T4DD7PYT24W2CHOPJ7KQ7CVPSA3WFQQRUJ4S3BY2RNN7R5QC
DHO4JCJIELKX4R42XXAMAHVQTTE6OWULLP2QF4BXO3UWC5UTMSMAC
PYGXEPNZSHLTHHKG2A7TCN5KF6I4KO5SJAMOTJNMWXY6LRP5CEAQC
3ZRM324R2G5FCZJUPXQLD3JRQ6E5XGF6G6BDY3UZ2TRFMM4NYTKQC
FYPDXXXIPT67FWCHK4EPOTVHREE57MSHPKK332BHXO2ZYGDUCIKAC
6BAFIOUBCBGNG6MMNGULNGACWYFSGRF5XEH5TE4TMAJ3XF57ZUAAC
const tooltippableAreaPropsFactory = (p: Props, s: State) => {
let nodeDescription: string = "Nothing (empty node)";
if (p.pointNodeGen.resourceType !== ResourceType.Nothing) {
nodeDescription = `${p.pointNodeGen.resourceAmount} ${p.pointNodeGen.resourceModifier} ${p.pointNodeGen.resourceType}`;
}
return {
args: {
markForceUpdate: this.markForceUpdate,
},
text: nodeDescription,
hitArea: this.hitArea, // TODO(bowei): move into state???
}
}
this.tooltippableArea = new TooltippableAreaComponent(tooltippableAreaPropsFactory(props, this.state));
// const tooltippableAreaPropsFactory = (p: Props, s: State) => {
// let nodeDescription: string = "Nothing (empty node)";
// if (p.pointNodeGen.resourceType !== ResourceType.Nothing) {
// nodeDescription = `${p.pointNodeGen.resourceAmount} ${p.pointNodeGen.resourceModifier} ${p.pointNodeGen.resourceType}`;
// }
// return {
// args: {
// markForceUpdate: this.markForceUpdate,
// },
// text: nodeDescription,
// hitArea: this.hitArea, // TODO(bowei): move into state???
// }
// }
// this.tooltippableArea = new TooltippableAreaComponent(tooltippableAreaPropsFactory(props, this.state));
this.addChild({
childClass: TooltippableAreaComponent,
instance: this.tooltippableArea,
propsFactory: tooltippableAreaPropsFactory,
});
// this.addChild({
// childClass: TooltippableAreaComponent,
// instance: this.tooltippableArea,
// propsFactory: tooltippableAreaPropsFactory,
// });
}
protected updateSelf(props: Props) {
let nodeDescription: string = "Nothing (empty node)";
if (props.pointNodeGen.resourceType !== ResourceType.Nothing) {
nodeDescription = `${props.pointNodeGen.resourceAmount} ${props.pointNodeGen.resourceModifier} ${props.pointNodeGen.resourceType}`;
}
this.state.descriptionText = nodeDescription;
this.container.addListener('pointerover', (event: Pixi.InteractionEvent) => {
this._staleProps.args.markForceUpdate(this);
this._staleProps.tooltipUpdaters.enqueueUpdate((prev) => {
const next = { ...prev, visible: true, text: this.state.descriptionText };
next.position = new Vector2(this.container.worldTransform.tx, this.container.worldTransform.ty);
// TODO(bowei): what about position??
// console.log({ next });
return next;
})
});
this.container.addListener('pointerout', (event: Pixi.InteractionEvent) => {
this._staleProps.args.markForceUpdate(this);
this._staleProps.tooltipUpdaters.enqueueUpdate((prev) => {
const next = { ...prev, visible: false, text: '' };
return next;
})
});
public zLevel: ZLevelComponent | undefined;
public zLevelPropsFactory: (p: Props, s: State) => ZLevelComponentProps;
public backdrop: Pixi.Graphics;
private zLevel: ZLevelComponent | undefined;
private zLevelPropsFactory: (p: Props, s: State) => ZLevelComponentProps;
private backdrop: Pixi.Graphics;
const box = new Pixi.Graphics();
// this.box = new Pixi.Graphics();
// this.box.lineStyle(1, 0x222222, 1);
// this.box.beginFill(0xEEEEEE);
// this.box.drawRoundedRect(0, 0, this.text.width + 18, this.text.height + 18, 4);
// this.box.zIndex = 0;
// this.container.addChild(this.box);
}
box.lineStyle(1, 0x222222, 1);
box.beginFill(0xEEEEEE);
box.drawRoundedRect(0, 0, this.text.width + 18, this.text.height + 18, 4);
box.zIndex = 0;
this.container.addChild(box);
protected shouldUpdate(prevProps: Props, prevState: State, props: Props, state: State): boolean {
for (let key of (Object.keys(prevProps) as (keyof Props)[])) {
if (prevProps[key] !== props[key]) {
return true;
}
}
return false;
this.text.text = props.text;
if (this.box) {
this.container.removeChild(this.box);
}
this.box = new Pixi.Graphics();
this.box.lineStyle(1, 0x222222, 1);
this.box.beginFill(0xEEEEEE);
this.box.drawRoundedRect(0, 0, this.text.width + 18, this.text.height + 18, 4);
this.box.zIndex = 0;
this.container.addChild(this.box);