Scene Item

jackken123

Veteran
Veteran
Joined
Aug 24, 2017
Messages
81
Reaction score
8
First Language
Chinese
Primarily Uses
RMMV
Can I have a scene item that both category and item list are activate?

Now I make a try and it works, but when I use an item, for example potion.
And for the first time it works.
But when I cancel and back to scene item, then use the item again it turns out pretty strange.(There will be item mismatch)

So I try to delete some code and use try and error to test.
Then I found, when I activate both
_itemWindow
_categoryWindow
these kind of item mismatch happen.

And if I just activate one window then I got only one window to work , of course.

So anyone see the question?

Code:
function Scene_Ken_Item() {
    this.initialize.apply(this, arguments);
}
Scene_Ken_Item.prototype = Object.create(Scene_ItemBase.prototype);
Scene_Ken_Item.prototype.constructor = Scene_Ken_Item;

Scene_Ken_Item.prototype.initialize = function() {
    Scene_ItemBase.prototype.initialize.call(this);
};

Scene_Ken_Item.prototype.create = function() {
    Scene_ItemBase.prototype.create.call(this);
    this.createHelpWindow();
    this.createCategoryWindow();
    this.createItemWindow();
    this.createActorWindow();
    this._helpWindow.opacity = 0;
    this._categoryWindow.x = 0;
    this._categoryWindow.y = 17;
    this._itemWindow.x = 0;
    this._itemWindow.y = this._categoryWindow.height;
    this._helpWindow.x = 0;
    this._helpWindow.y = this._categoryWindow.height;
    this._helpWindow.width = Graphics.width / 24 * 10;
    this._itemWindow.activate();
    this._itemWindow.selectLast();
};

Scene_Ken_Item.prototype.createCategoryWindow = function() {
    this._categoryWindow = new Window_ItemCategory();
    this._categoryWindow.setHandler('ok',     this.onCategoryOk.bind(this));
    this._categoryWindow.setHandler('cancel', this.popScene.bind(this));
    this.addWindow(this._categoryWindow);
};

Scene_Ken_Item.prototype.createItemWindow = function() {
    var wy = this._categoryWindow.y + this._categoryWindow.height;
    var wh = Graphics.boxHeight - wy;
    this._itemWindow = new Window_ItemList(0, wy, Graphics.boxWidth, wh);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
    this.addWindow(this._itemWindow);
    this._categoryWindow.setItemWindow(this._itemWindow);
    this.showSubWindow(this._categoryWindow);
};

Scene_Ken_Item.prototype.user = function() {
    var members = $gameParty.movableMembers();
    var bestActor = members[0];
    var bestPha = 0;
    for (var i = 0; i < members.length; i++) {
        if (members[i].pha > bestPha) {
            bestPha = members[i].pha;
            bestActor = members[i];
        }
    }
    return bestActor;
};

Scene_Ken_Item.prototype.onCategoryOk = function() {
    this.hideSubWindow(this._categoryWindow);
    this._itemWindow.selectLast();
    $gameParty.setLastItem(this.item());
    this.determineItem();
};

Scene_Ken_Item.prototype.onItemOk = function() {
    this.hideSubWindow(this._categoryWindow);
    $gameParty.setLastItem(this.item());
    this.determineItem();
};

Scene_Ken_Item.prototype.onItemCancel = function() {
    this._itemWindow.deselect();
    SceneManager.pop();
};

Scene_Ken_Item.prototype.playSeForItem = function() {
    SoundManager.playUseItem();
};

Scene_Ken_Item.prototype.useItem = function() {
    Scene_ItemBase.prototype.useItem.call(this);
    this._itemWindow.redrawCurrentItem();
};

Scene_Ken_Item.prototype.determineItem = function() {
    var action = new Game_Action(this.user());
    var item = this.item();
    action.setItemObject(item);
    if (action.isForFriend()) {
        this.showSubWindow(this._actorWindow);
        this._actorWindow.selectForItem(this.item());
    } else {
        this.useItem();
        this.activateItemWindow();
    }
};

Scene_Ken_Item.prototype.createActorWindow = function() {
    this._actorWindow = new Window_MenuActor();
    this._actorWindow.setHandler('ok',     this.onActorOk.bind(this));
    this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this));
    this.addWindow(this._actorWindow);
};

Scene_Ken_Item.prototype.onActorOk = function() {
    if (this.canUse()) {
        this.useItem();
    } else {
        SoundManager.playBuzzer();
    }
    this._categoryWindow.deactivate();
};

Scene_Ken_Item.prototype.onActorCancel = function() {
    this.hideSubWindow(this._actorWindow);
    this.showSubWindow(this._itemWindow);
    this.showSubWindow(this._categoryWindow);
   
   
   
};

Scene_Ken_Item.prototype.hideSubWindow = function(window) {
    window.hide();
    window.deactivate();
};

Scene_Ken_Item.prototype.showSubWindow = function(window) {      
    window.show();
    window.activate();
};

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

ImageManager.loadKen = function (filename, hue) {
    return this.loadBitmap('img/ChunKen/', filename, hue, true);  
};
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top