Help Creating a scene with selectable items

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)

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" ];
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
Code:
contents.stretch_blt(item_rect(index), bitmap, rect, opacity)
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.
It would be easier if you would provide the whole plugin, so we could actually run it in game.

To change the opacity you have to do
PHP:
this.contents.paintOpacity = value

For example this would change the opacity of icons to 128.
PHP:
Window_Base.prototype.drawIcon = function(iconIndex, x, y) {
    var bitmap = ImageManager.loadSystem('IconSet');
    var pw = Window_Base._iconWidth;
    var ph = Window_Base._iconHeight;
    var sx = iconIndex % 16 * pw;
    var sy = Math.floor(iconIndex / 16) * ph;
    this.contents.paintOpacity = 128;
    this.contents.blt(bitmap, sx, sy, pw, ph, x, y);
    // Reset opacity changes, otherwise it would keep the change for all
    this.contents.paintOpacity = 255;
};
hmm... watching your sample code, I have a doubt. If you have to use the variable paintOpacity (wich is not an actual function), and if changing paintOpacity on content will affect ALL item in contents, I am afraid I will have a very big problem.
In my idea I will have to display all item semi-trasparent EXCEPT ONE (fully opaque) wich is the item currently pointed at the cursor. I could develop this effect on RpgMaker VX Ace and I hoped I could develop it also on MV.

I will try to make a test and see what it happens if I change the opacity value on source bitmap before blitting it in content, but I am afraid I will not obtain the desired effect... I will see...

It would be easier if you would provide the whole plugin, so we could actually run it in game.
Here a shorten version of the plugin wich you can place as-is in a test game to reproduce all the issues I am asking about:

PHP:
(function () {
   
    function UtrTranslator() {
        throw new Error("This is a static class");
    }
   
    UtrTranslator.langCmd = function() {
        return "Language";
    };
   
    UtrTranslator.langTitle = function() {
        return "Choose your language";
    };
   
   
   
    /********************************************
     *   Language Selection Menu
     ********************************************/
   
    //-----
    //Part1: Window_UTRTitle
    //-----
   
    function Window_UTRTitle() {
        this.initialize.apply(this, arguments);
    }
   
    Window_UTRTitle.prototype = Object.create(Window_Base.prototype);
    Window_UTRTitle.prototype.constructor = Window_UTRTitle;
   
    Window_UTRTitle.prototype.initialize = function(x, y) {
        var width = this.windowWidth();
        var height = this.windowHeight();
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };

    Window_UTRTitle.prototype.windowWidth = function() {
        return Graphics.width - 40;
    };
   
    Window_UTRTitle.prototype.windowHeight = function() {
        //todel
        //console.log(this.fittingHeight(1)); //72
        return this.fittingHeight(1);
    };
   
    Window_UTRTitle.prototype.numVisibleRows = function() {
        return 1;
    };
   
    Window_UTRTitle.prototype.refresh = function() {
        this.contents.clear();
        this.drawText(UtrTranslator.langTitle(), 4, 0, this.windowWidth());
    };
   
    //------
    //Part2: Window_UTRLanguages
    //------
   
    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;
        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() {
        console.log("a new language was selected");
    };
   
    //-----
    //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);
    };
   
   
    /*****************************
     *  Menu item override
     *****************************/
   
    Window_TitleCommand.prototype.makeCommandList = function() {
       this.addCommand(TextManager.newGame,   'newGame');
       this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
       this.addCommand(UtrTranslator.langCmd(), 'utr_change_language');
       this.addCommand(TextManager.options,   'options');
    };
   
   
    Scene_Title.prototype.createCommandWindow = function() {   
       this._commandWindow = new Window_TitleCommand();
       this._commandWindow.setHandler('newGame',  this.commandNewGame.bind(this));
       this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
       this._commandWindow.setHandler('utr_change_language', this.cmdUtrChangeLang.bind(this));
       this._commandWindow.setHandler('options',  this.commandOptions.bind(this));
       this.addWindow(this._commandWindow);
    };
   
    Scene_Title.prototype.cmdUtrChangeLang = function() {
       this._commandWindow.close();
       SceneManager.push(Scene_UTRChooseLang);
    };
})();
In order to make it work, you have to place a "countries.png" image on your img/pictures folder. This is the image you can use for testing:
https://ibb.co/cKLa7F

------------

Let me know if you have an answer of question 2) and 3)
NOTE: I am aware that currently the windows are bad placed. The final aspect of the scene (this is the case where you added no more than 3 languages) should be a centered two-little-windows: the upper one for the title, the second one to show the flag list (only a row with two or three flags available)
Moved to: JavaScript/Plugin Support
@Unqou
I changed the code a bit and fixed some issues.

PHP:
(function() {
//=============================================================================
// UtrTranslator
//=============================================================================
function UtrTranslator() {
    throw new Error("This is a static class");
}

UtrTranslator.langCmd = function () {
    return "Language";
};

UtrTranslator.langTitle = function () {
    return "Choose your language";
};

//=============================================================================
// Window_UTRTitle
//=============================================================================
function Window_UTRTitle() {
    this.initialize.apply(this, arguments);
}

Window_UTRTitle.prototype = Object.create(Window_Base.prototype);
Window_UTRTitle.prototype.constructor = Window_UTRTitle;

Window_UTRTitle.prototype.initialize = function (x, y) {
    var ww = this.windowWidth();
    var wh = this.windowHeight();
    Window_Base.prototype.initialize.call(this, x, y, ww, wh);
    this._title = UtrTranslator.langTitle();
    this.refresh();
};

Window_UTRTitle.prototype.windowWidth = function () {
    return Graphics.width - 40;
};

Window_UTRTitle.prototype.windowHeight = function () {
    return this.fittingHeight(1);
};

Window_UTRTitle.prototype.refresh = function () {
    this.contents.clear();
    this.drawText(this._title, this.textPadding(), 0, 'left');
};

//=============================================================================
// Window_UTRLanguages
//=============================================================================
function Window_UTRLanguages() {
    this.initialize.apply(this, arguments);
}

Window_UTRLanguages.prototype = Object.create(Window_ItemList.prototype);
Window_UTRLanguages.prototype.constructor = Window_UTRLanguages;

Window_UTRLanguages.prototype.initialize = function (x, y) {
    var ww = this.windowWidth();
    var wh = this.windowHeight();
    Window_ItemList.prototype.initialize.call(this, x, y, ww, wh);
    this._bitmap = null;
    // Activate the window, so the user can navigate it
    this.activate();
    // Set the cursor position to the first item
    this.select(0);
};

Window_UTRLanguages.prototype.setBitmap = function (bitmap) {
    this._bitmap = bitmap;
};

Window_UTRLanguages.prototype.windowWidth = function () {
    return Graphics.width - 40;
};

Window_UTRLanguages.prototype.windowHeight = function () {
    return 120;
};

Window_UTRLanguages.prototype.itemHeight = function () {
    return 80;
};

Window_UTRLanguages.prototype.maxCols = function() {
    return 1;
};

Window_UTRLanguages.prototype.maxCols = function () {
    return 3;
};

Window_UTRLanguages.prototype.makeItemList = function () {
    this._data = ["en.po", "it.po"];
};

Window_UTRLanguages.prototype.isEnabled = function (item) {
    return true;
};

Window_UTRLanguages.prototype.drawItem = function (index) {
    if (this._bitmap) {
        var rect = this.itemRect(index);
        this.setOpacity(index);
        this.drawFlag(index, rect.x + 34, rect.y);
        this.resetOpacity();
        this._lastIndex = this._index;
    }
};

Window_UTRLanguages.prototype.drawFlag = function (index, x, y) {
    var width = 272; // Width of the countries file
    var height = 80; // Height of the countries file
    var pw = 68; // Width of a single flag
    var ph = 40; // Height of a single flag
    var sw = Math.min(width, pw);
    var sh = Math.min(height, ph);
    var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
    var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
    var sx = index % 4 * pw + (pw - sw) / 2;
    var sy = Math.floor(index / 4) * ph + (ph - sh) / 2;
    this.contents.blt(this._bitmap, sx, sy, sw, sh, dx, dy);
};

Window_UTRLanguages.prototype.setOpacity = function (index) {
    this.contents.paintOpacity = this.index() == index ? 255 : 128;
};

Window_UTRLanguages.prototype.resetOpacity = function () {
    this.contents.paintOpacity = 255;
};

Window_UTRLanguages.prototype.update = function () {
    Window_ItemList.prototype.update.call(this);
    // In order to change the opacity of every item, we need to add the refresh
    // to the update function. Update get's called every frame
    if (this._lastIndex !== this._index) {
        this.refresh();
    }
};

Window_UTRLanguages.prototype.languageSelected = function () {
    var selectedLanguage = this._data[this._index];
    console.log("Selected language: " + selectedLanguage);
};

//=============================================================================
// Window_UTRLanguages
//=============================================================================
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.createTitleWindow = function () {
    this._tWin = new Window_UTRTitle(0, 0);
    this.addWindow(this._tWin);
};

Scene_UTRChooseLang.prototype.createSelectionWindow = function () {
    var bitmap = ImageManager.loadPicture('countries');
    this._selWin = new Window_UTRLanguages(0, 72);
    this._selWin.setHandler('ok', this.commandLanguageSelected.bind(this));
    this._selWin.setHandler('cancel', this.popScene.bind(this));
    // Use a LoadListener. Custom files can take a bit longer to load.
    // Only when the bitmap is loaded, add the window.
    var setupWindow = function () {
        this._selWin.setBitmap(bitmap);
        this.addWindow(this._selWin);
        this._selWin.refresh();
    };
    bitmap.addLoadListener(setupWindow.bind(this));
};

Scene_UTRChooseLang.prototype.commandLanguageSelected = function () {
    this._selWin.languageSelected();
    SceneManager.goto(Scene_Title);
};

//=============================================================================
// Window_TitleCommand
//=============================================================================
Window_TitleCommand.prototype.makeCommandList = function () {
    this.addCommand(TextManager.newGame, 'newGame');
    this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
    this.addCommand(UtrTranslator.langCmd(), 'utr_change_language');
    this.addCommand(TextManager.options, 'options');
};

//=============================================================================
// Scene_Title
//=============================================================================
Scene_Title.prototype.createCommandWindow = function () {
    this._commandWindow = new Window_TitleCommand();
    this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));
    this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
    this._commandWindow.setHandler('utr_change_language', this.cmdUtrChangeLang.bind(this));
    this._commandWindow.setHandler('options', this.commandOptions.bind(this));
    this.addWindow(this._commandWindow);
};

Scene_Title.prototype.cmdUtrChangeLang = function () {
    this._commandWindow.close();
    SceneManager.push(Scene_UTRChooseLang);
};
})();
//-------------------------------------------------------------------------------
Thank a lot for your help. I hope I will not bother you too much, but I have some questions to ask in order to understand better your changes

1)
PHP:
Window_UTRLanguages.prototype.drawFlag = function (index, x, y) {
    var width = 272; // Width of the countries file
    var height = 80; // Height of the countries file
    var pw = 68; // Width of a single flag
    var ph = 40; // Height of a single flag
    var sw = Math.min(width, pw);
    var sh = Math.min(height, ph);to
    var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
    var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
    var sx = index % 4 * pw + (pw - sw) / 2;
    var sy = Math.floor(index / 4) * ph + (ph - sh) / 2;
    this.contents.blt(this._bitmap, sx, sy, sw, sh, dx, dy);
};
looking at your code, sw and sh should be equal to width / heigh of a single flag. Did you use Math.min() for code safety if the countries.png (or remaining pixel starting from x,y on source image) was smaller than the flag size to avoid possible issues?

2)
PHP:
Window_UTRLanguages.prototype.makeItemList = function () {
    this._data = ["en.po", "it.po"];
};
Why do you move this.languages from intialize and move it to makeItemList? Why did you rename this.languages to this._data ?
Sorry if the question is a bit stupid, but MV documentations lacks of informations and sometime the source comments are not enough to understand if there are special "requirements" like this one.

-------------------

3) How the code can know that there are 2 items (no function itemMax() was defined) and how it is possible that it draws the two items. It has something to do to the this._data you defined in Window_UTRLanguages.prototype.makeItemList ? I need a more detailed explaination about this point

-----------------------
4)
PHP:
// Use a LoadListener. Custom files can take a bit longer to load.
    // Only when the bitmap is loaded, add the window.
    var setupWindow = function () {
        this._selWin.setBitmap(bitmap);
        this.addWindow(this._selWin);
        this._selWin.refresh();
    };
    bitmap.addLoadListener(setupWindow.bind(this));
Probably I got it, but I am not sure about it. Can you explain me better what is a LoadListenere and, more important, how it works? (you wrote the code in that way for a reason, and I am trying to understand it better).


[more question may follows. At the moment I will stop my questions here]
No problem. 🙂

1)
That code is based on other functions that draw stuffs like the drawFace or drawIcon. I just copy-pasted it and changed it to fit what I need. If you want you could remove the Math.min function. It was there becaue the drawFace or drawIcon function has the width and height as parameters. I just forgot it.

2)
In your code the Window_UTRLanguages was based on Window_Selectable. I changed that to Window_ItemList.
Window_ItemList is used for displaying the player's item in the Scene_Item. I like to use that Window_ItemList as a base for windows that I create that will display a list of data. I changed it from this.languages to this._data because the Window_ItemList uses this._data for the actual data that will be drawn in the window.
So makeItemList will be called for getting the data that will be displayed. Then I just need to modify the drawItem function. That function will be used to draw one item of the this._data array. This way I don't have to rewrite a whole lot from scratch, I can just modify two functions and the rest of the functionalities are just there. If you just use Window_Selectable you would have to add a lot more.

3)
Because I based it on the Window_ItemList and used makeItemList for setting up the data.

4)
After I restructured your code, I noticed that when you entered the Language Selection Scene for the first time, the flags would not appear. When I left that scene and entered it again, the flags would appear. That's because loading a ressource takes some time. In your code the bitmap was loaded right before drawing it. That was way to late. So I moved the loading part. This way it has more time before the bitmap is needed, because now the bitmap will be already loaded when the window wants to draw the this._data.
I also added a LoadListener. You can add a LoadListener to a bitmap with bitmap.addLoadListener(). You give it a callback function as an argument. That callback function will be called, when the bitmap is fully loaded.
Inside that callback function we give the loaded bitmap to the window, add the window to the scene and refresh it. I did that because if we would add that window right away and somehow the bitmap was not loaded in time it would not draw the flags.
Thank you very much for all your explainations. I will wait a couple of days before marking this post as "solved" becouse I could have other questions about your code (I'm doing some changes and experiments starting from your code, but I will continue analyzing it).
Yeah, just ask if there are more questions. 🙂
I think I got it. But probably I will ask more help in the future.
For the moment I will ask a final question before marking this topic as "solved".

PHP:
//=============================================================================
// Window_TitleCommand
//=============================================================================
Window_TitleCommand.prototype.makeCommandList = function () {
    this.addCommand(TextManager.newGame, 'newGame');
    this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
    this.addCommand(UtrTranslator.langCmd(), 'utr_change_language');
    this.addCommand(TextManager.options, 'options');
};

//=============================================================================
// Scene_Title
//=============================================================================
Scene_Title.prototype.createCommandWindow = function () {
    this._commandWindow = new Window_TitleCommand();
    this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));
    this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
    this._commandWindow.setHandler('utr_change_language', this.cmdUtrChangeLang.bind(this));
    this._commandWindow.setHandler('options', this.commandOptions.bind(this));
    this.addWindow(this._commandWindow);
};

Scene_Title.prototype.cmdUtrChangeLang = function () {
    this._commandWindow.close();
    SceneManager.push(Scene_UTRChooseLang);
};
})();
Is it possible, some way, to write this final part code with "alias" instead of override?
I mean... this is a problem I encountered both here and in VX Ace (that case "Languages" must be placed before "quit" wich is not included in MV). Here again I can't see a way to abandone the overload, wich may leads to incompatibilities to other possible plugins.

Original thread: https://forums.rpgmakerweb.com/threads/help-creating-a-scene-with-selectable-items.82813/