Hello everyone! I'm learning how to write my own custom HUD in js.
I wrote three classes, in which Window_MainCityMapContainerView is loaded on the map scene.
By switching the buttons of the command window, you can obtain different indexes and then draw different pictures.
Then my question is, I use a proxy object in Window_CustomMenuView, will this cause a circular reference?
Sorry to bother you all during the working day, hope you all have a nice day.
I wrote three classes, in which Window_MainCityMapContainerView is loaded on the map scene.
JavaScript:
class Window_CustomMenuView extends Window_Command {
proxy
constructor() {
const rect = {
x: 176,
y: 314,
width: 200,
height: 208
}
super(rect);
this.setHandler("ok", this.clickOk.bind(this))
this.setHandler("cancel", this.clickCancel.bind(this))
}
itemHeight() {
return 30;
}
makeCommandList() {
this.addCommand("Tavern", "Tavern", true);
this.addCommand("Guild", "Guild", false);
this.addCommand("Church", "Church", true);
this.addCommand("Castle", "Castle", true);
this.addCommand("HitchHouse", "HitchHouse", true);
this.addCommand("OutsideTown", "OutsideTown", true);
}
clickOk() {
console.log("ok: ", this.currentSymbol())
}
clickCancel() {
console.log("cancel: ", this.currentSymbol())
}
select(index) {
super.select(index)
//console.log(this.proxy)
if(this.proxy && this.proxy.__proto__.hasOwnProperty("selectIndex")) {
this.proxy.selectIndex(index)
}
}
drawText(text, x, y, maxWidth, align) {
this.contents.fontSize = 20
this.contents.drawText(text, 20, y, maxWidth, this.lineHeight(), 'left');
}
}
class Window_CustomPictureView extends Window_Base {
constructor() {
const rect = {
x: 502,
y: 262,
width: 552,
height: 312
}
super(rect)
}
drawPicture(filename, x, y) {
const bitmap = ImageManager.loadParallax(filename)
bitmap.addLoadListener(() => {
this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y, this.contents.width, this.contents.height)
})
};
}
class Window_MainCityMapContainerView extends Window_Base {
customMenuView
customPictureView
constructor() {
const rect = {
x: 0,
y: 0,
width: 1104,
height: 624
}
super(rect)
this.customMenuView = new Window_CustomMenuView()
this.customMenuView.proxy = this
this.customPictureView = new Window_CustomPictureView()
//this.customPictureView.drawPicture("bg004a", 0, 0)
this.addChildToBack(this.customMenuView)
this.addChildToBack(this.customPictureView)
}
selectIndex(index) {
console.log("select: ", index)
this.customPictureView.drawPicture(`${index}`, 0, 0)
}
}
By switching the buttons of the command window, you can obtain different indexes and then draw different pictures.
Then my question is, I use a proxy object in Window_CustomMenuView, will this cause a circular reference?
Sorry to bother you all during the working day, hope you all have a nice day.