Using custom choice list with common events?

Discussion in 'Learning Javascript' started by Occupant, Jan 21, 2018.

  1. Occupant

    Occupant Hypothetical Member

    Messages:
    15
    Likes Received:
    8
    First Language:
    English
    Primarily Uses:
    RMMV
    Hello everyone,

    I am wondering if there is a way to use my own custom Window_ChoiceList with the common event "Show Choices".

    My goal is to change the default position and sizes of the Window_ChoiceList when it is used for the "Show Choices" common event, as well as enable some extended "help window" features.

    However, I'd still like to benefit from other plugins that add features to the "Show Choices" common event, such as HIME's "disable choices".

    For example, if I have a custom Window_ChoiceList like so:

    Code:
    function My_Window_ChoiceList() {
      this.initialize(this, arguments);
    }
    
    My_Window_ChoiceList.prototype = Object.Create(Window_ChoiceList.prototype);
    My_Window_ChoiceList.prototype.constructor = Window_ChoiceList;
    
    // then various overrides to Window_ChoiceList functions
    Are there ways I can use that class when Show Choices events are run, instead of the default?

    So far, the only way I have thought it might work would be to override actual Window_ChoiceList prototype itself, perhaps by taking over one of the positions as an opportunity to specify my logic, like so:

    Code:
    var Default_Window_ChoiceList_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
    Window_ChoiceList.prototype.updatePlacement = function() {
      var positionType = $gameMessage.choicePositionType();
      if (Math.floor(positionType) === 0) { // take over the left position for custom code
        // do my custom updatePlacement stuff here
      }
      else Default_Window_ChoiceList_updatePlacement.call(this); // do default stuff for other positions
    }
    I think this would work, but it limits my options on how my custom code can be used (i.e. can't be used in other positions).

    Thanks for any help!
     
    #1

Share This Page