Hi. Here I am trying to create the basic structure of my "Select Language" Scene.
In this code there are several issues, but I'm trying to focus on some of them.
First of all. The scene should be composed by two windows. The first one (not reported here) only draw a text with the title "Choose your language".
The second window is a Window_Selectable where you should pick one of the items, select it and choose your language. On this second window, you should see a list of flag images (in this example the UK flag and IT flag) wich are enclosed in a unique png image (like it happen on faceset) placed in Pictures.
While you change your cursor, you should see what flag you are "pointing to" becouse it should be the only flag full opaque (255) [in the code this feature is still not present, since I cannot find any function into Bitmap that allows me to SET a new trans value.
However this is the code I wrote until now (the questions will follow after code)
How can I solve those issues / what I am doing wrong?
1) When I choose "Language" from the main menu (my Scene), I am not able to quit in any way. The "Esc" key does not work. No item is displayed at all. I cannot select anything. If I try to press return (to select an item, even in the window appears empty), again the scene stands still and nothing happens (and you didn't came back to main menu).
2) Under "initialize" function in Window_UTRLanguages I wrote this:
But "this.languages" is evalued as undefined in Window_UTRLanguages.prototype.maxItems [the reason why I wrote the if === undefined was to confirm it on debugging]. Why?
3) I cannot find any way to blit, in a content, a part of a source image setting a different transparency. On RpgMaker VX Ace (ruby) you could use
but the blt function under Bitmap does not have any option to set another opacity, nor there isn't any method on Bitmap to do this task. What I could use to change transparency?
Those are the most important questions I have to ask at the moment. Thank in advance for any help.
In this code there are several issues, but I'm trying to focus on some of them.
First of all. The scene should be composed by two windows. The first one (not reported here) only draw a text with the title "Choose your language".
The second window is a Window_Selectable where you should pick one of the items, select it and choose your language. On this second window, you should see a list of flag images (in this example the UK flag and IT flag) wich are enclosed in a unique png image (like it happen on faceset) placed in Pictures.
While you change your cursor, you should see what flag you are "pointing to" becouse it should be the only flag full opaque (255) [in the code this feature is still not present, since I cannot find any function into Bitmap that allows me to SET a new trans value.
However this is the code I wrote until now (the questions will follow after code)
PHP:
function Window_UTRLanguages() {
this.initialize.apply(this, arguments);
}
Window_UTRLanguages.prototype = Object.create(Window_Selectable.prototype);
Window_UTRLanguages.prototype.constructor = Window_UTRLanguages;
Window_UTRLanguages.prototype.initialize = function(x, y) {
var width = this.windowWidth();
var height = this.windowHeight();
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.languages = ["en.po", "it.po" ];
// this.loadImages();
this.updateFlag(0);
this._index = 0;
};
Window_UTRLanguages.prototype.windowWidth = function() {
//return Graphics.boxWidth - 40;
return Graphics.width - 40;
};
Window_UTRLanguages.prototype.windowHeight = function() {
//return Graphics.boxHeight;
return Graphics.height - (125+20) - 120;
};
Window_UTRLanguages.prototype.maxItems = function() {
if (this.languages === undefined) {
console.log("undefined met");
return 1;
}
else if(this.languages.length >= 2) {
return this.languages;
}
else {
return 1;
}
};
Window_UTRLanguages.prototype.itemHeight = function() {
//var clientHeight = this.height - this.padding * 2;
//return Math.floor(clientHeight / this.numVisibleRows());
return 80;
};
Window_UTRLanguages.prototype.itemWidth = function() {
//var clientHeight = this.height - this.padding * 2;
//return Math.floor(clientHeight / this.numVisibleRows());
return (136 - this.spacing);
};
Window_UTRLanguages.prototype.maxCols = function() {
return 3;
};
Window_UTRLanguages.prototype.spacing = function() {
return 12;
};
Window_UTRLanguages.prototype.drawItem = function(index, opacity) {
var bitmap = ImageManager.loadPicture("countries");
//we have to find a method to change paintOpacity
// bitmap.paintOpacity(opacity); //HOW TO CHANGE OPACITY????
var rect = new Rectangle(index % 4 * 68, index / 4 * 40, 68, 40);
var place_item = new Rectangle((index % 3 * 68), (index / 3 * 40), 68, 40);
this.contents.blt(bitmap, rect.x, rect.y, rect.width, rect.height,
place_item.x, place_item.y,
place_item.width, place_item.height);
};
Window_UTRLanguages.prototype.select = function(index) {
Window_Selectable.prototype.select.call(this, index);
console.log(index);
this.updateFlag(index);
};
Window_UTRLanguages.prototype.updateFlag = function(index) {
this.refresh();
this.drawItem(index, 255);
};
Window_UTRLanguages.prototype.drawAllItems = function() {
for(var i = 0; i < this.maxItems(); i++) {
this.drawItem(i, 120);
}
};
Window_UTRLanguages.prototype.refresh = function() {
Window_Selectable.prototype.refresh.call(this);
this.drawAllItems();
};
Window_UTRLanguages.prototype.languageSelected = function() {
UtrTranslator.change_language(this.languages[this._index]); //this contains only a console.log message, at the moment
};
//-----
//Part3: Scene_UTRChooseLang
//-----
function Scene_UTRChooseLang() {
this.initialize.apply(this, arguments);
}
Scene_UTRChooseLang.prototype = Object.create(Scene_MenuBase.prototype);
Scene_UTRChooseLang.prototype.constructor = Scene_UTRChooseLang;
Scene_UTRChooseLang.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_UTRChooseLang.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createTitleWindow();
this.createSelectionWindow();
};
Scene_UTRChooseLang.prototype.terminate = function() {
Scene_MenuBase.prototype.terminate.call(this);
//SceneManager.goto(Scene_Title);
};
Scene_UTRChooseLang.prototype.createTitleWindow = function() {
this._tWin = new Window_UTRTitle(20,125);
this.addWindow(this._tWin);
};
Scene_UTRChooseLang.prototype.createSelectionWindow = function() {
this._selWin = new Window_UTRLanguages(20,(125+20));
this._selWin.setHandler('cancel', this.popScene.bind(this));
this._selWin.setHandler('ok', this.commandLanguageSelected.bind(this));
this.addWindow(this._selWin);
};
Scene_UTRChooseLang.prototype.commandLanguageSelected = function() {
this._selWin.languageSelected();
SceneManager.goto(Scene_Title);
};
How can I solve those issues / what I am doing wrong?
1) When I choose "Language" from the main menu (my Scene), I am not able to quit in any way. The "Esc" key does not work. No item is displayed at all. I cannot select anything. If I try to press return (to select an item, even in the window appears empty), again the scene stands still and nothing happens (and you didn't came back to main menu).
2) Under "initialize" function in Window_UTRLanguages I wrote this:
PHP:
this.languages = ["en.po", "it.po" ];
3) I cannot find any way to blit, in a content, a part of a source image setting a different transparency. On RpgMaker VX Ace (ruby) you could use
Code:
contents.stretch_blt(item_rect(index), bitmap, rect, opacity)
Those are the most important questions I have to ask at the moment. Thank in advance for any help.