Yanfly's Item Synth.- Ingredients Window Display

Discussion in 'Javascript/Plugin Support' started by Djajapena, Oct 28, 2017.

  1. Djajapena

    Djajapena Villager Member

    Messages:
    10
    Likes Received:
    0
    Location:
    Indonesia
    First Language:
    Indonesia
    Primarily Uses:
    RMMV
    I need help about Yanfly's Item Synthesis plugin.

    In this plugin's window, the ingredients window only show up to the 5th ingredient. The 6th ingredient onwards didn't show correctly.
    [​IMG]
    My game is in default 816*624 Px resolution. It's intended to be played on windowed mode side-by-side with study material.

    In the game, each synthesized item need 4 to the maximum of 9 ingredient materials. I want the Ingredients Window to show the ingredients in 3*3 grids, displaying only the ingredient items icon and amount like this:
    [​IMG]
    It's obviously photoshoped

    I'm not well versed with JS and only use the plugins in plug-and-play way with minimum edits.
    Thank you in advance for the help.
     
    #1
  2. Johnboy

    Johnboy Veteran Veteran

    Messages:
    275
    Likes Received:
    65
    Location:
    Canadia
    First Language:
    English
    You could give SRD's super tools plugin a shot. It allows you to modify window sizes and lines.
     
    #2
  3. Djajapena

    Djajapena Villager Member

    Messages:
    10
    Likes Received:
    0
    Location:
    Indonesia
    First Language:
    Indonesia
    Primarily Uses:
    RMMV
    Johnboy Unfortunately SRD's Super Tools Plugin can only modify the Opacity, Widht, and Height of the Ingredients Window.
     
    #3
  4. SeaPhoenix

    SeaPhoenix Veteran Veteran

    Messages:
    116
    Likes Received:
    59
    First Language:
    English
    Primarily Uses:
    RMMV
    @Djajapena Do you still need help with this or did you solve it? I can take a look if you still need help.
     
    #4
  5. Djajapena

    Djajapena Villager Member

    Messages:
    10
    Likes Received:
    0
    Location:
    Indonesia
    First Language:
    Indonesia
    Primarily Uses:
    RMMV
    #5
  6. SeaPhoenix

    SeaPhoenix Veteran Veteran

    Messages:
    116
    Likes Received:
    59
    First Language:
    English
    Primarily Uses:
    RMMV
    Here's the plugin and some screenshots. Just copy-and-paste the plugin code into a new file, save it (I use the name SPX_ItemSynthesisMod.js but anything is fine) and place the plugin somewhere below YEP_ItemSynthesis.js.

    synthesis1.png
    synthesis2.png

    Code:
    // Modifications to YEP_ItemSynthesis.js by SeaPhoenix
    // Place in plug-in list anywhere BELOW YEP_ItemSynthesis.js
    
    // Can change the number 20 in the two functions below to a bigger number (e.g., 24) for more white space between ingredient columns,
    // or to a smaller number (e.g., 16) for less white space between ingredient columns
    // (may be needed if you have a synthesis cost of more than 9,999 money units so that the text doesn't get shrunk)
    
    Window_SynthesisIngredients.prototype.ingredientSpacing = function() {
      return this.textPadding() * 20; 
    };
    
    Window_SynthesisNumber.prototype.ingredientSpacing = function() {
      return this.textPadding() * 20; 
    };
    
    ////////////////////////////////////////////////////////////////////////
    
    // Window_SynthesisIngredients
    
    Window_SynthesisIngredients.prototype.drawItemIngredients = function(item, wy) {
        var ww = this.contents.width;
        this.changeTextColor(this.systemColor());
        this.drawText(Yanfly.Param.ISIngredientsList, 0, 0, ww, 'center');
        this.changeTextColor(this.normalColor());
        var cell = 0;
        for (var i = 0; i < item.synthIngredients.length; ++i) {
          cell = this.drawItemDetails(i, cell, wy);
          if (cell > 0 && cell % 3 === 0) wy += this.lineHeight()
          if (wy + this.lineheight > this.contents.height) break;
        }
        this.drawItemSynthCost(item, cell, wy);
    };
    
    Window_SynthesisIngredients.prototype.drawItemDetails = function(index, cell, wy) {
        var ingredient = DataManager.getSynthesisIngredient(this._item, index);
        var quantity = DataManager.getSynthesisQuantity(this._item, index);
        var ww = (this.contents.width - this.ingredientSpacing()) / 3;
        var wx = (ww + (this.ingredientSpacing() / 2)) * (cell % 3);
        if (!ingredient) return cell;
        this.resetFontSettings();
        this.drawIcon(ingredient.iconIndex, wx + 2, wy + 2);
        if (Yanfly.Param.ISAmountFmt) {
          this.drawItemQuantity(index, wx, wy, ww);
        } else {
          this.drawItemQuantity2(index, wx, wy, ww);
        }
        return cell + 1;
    };
    
    Window_SynthesisIngredients.prototype.drawItemQuantity = function(index, wx, wy, ww) {
        var ingredient = DataManager.getSynthesisIngredient(this._item, index);
        var quantity = DataManager.getSynthesisQuantity(this._item, index);
        this.contents.fontSize = Yanfly.Param.ISQuantitySize;
        this.changeTextColor(this.normalColor());
        var num = '/' + Yanfly.Util.toGroup($gameParty.numItems(ingredient));
        this.drawText(num, wx, wy, ww, 'right');
        ww -= this.textWidth(num);
        if ($gameParty.numItems(ingredient) >= quantity) {
          this.changeTextColor(this.powerUpColor());
        } else {
          this.changeTextColor(this.powerDownColor());
        }
        var text = String(Yanfly.Util.toGroup(quantity));
        this.drawText(text, wx, wy, ww, 'right');
    }
    
    Window_SynthesisIngredients.prototype.drawItemQuantity2 = function(index, wx, wy, ww) {
        var ingredient = DataManager.getSynthesisIngredient(this._item, index);
        var quantity = DataManager.getSynthesisQuantity(this._item, index);
        var owned = $gameParty.numItems(ingredient);
        this.contents.fontSize = Yanfly.Param.ISQuantitySize;
        this.changeTextColor(this.normalColor());
        var num = '/' + Yanfly.Util.toGroup(quantity);
        this.drawText(num, wx, wy, ww, 'right');
        ww -= this.textWidth(num);
        if ($gameParty.numItems(ingredient) >= quantity) {
          this.changeTextColor(this.powerUpColor());
        } else {
          this.changeTextColor(this.powerDownColor());
        }
        var text = String(Yanfly.Util.toGroup(owned));
        this.drawText(text, wx, wy, ww, 'right');
    }
    
    Window_SynthesisIngredients.prototype.drawItemSynthCost = function(item, cell, wy) {
        if (item.synthCost <= 0) return;
        this.resetFontSettings();
        var value = item.synthCost;
        var ww = (this.contents.width - this.ingredientSpacing()) / 3;
        var wx = (ww + (this.ingredientSpacing() / 2)) * (cell % 3);
        this.drawCurrencyValue(value, TextManager.currencyUnit, wx, wy, ww)
    };
    
    // Window_SynthesisNumber
    
    Window_SynthesisNumber.prototype.drawIngredients = function() {
        var wy = this.lineHeight();
        var cell = 0;
        for (var i = 0; i < this._item.synthIngredients.length; ++i) {
          cell = this.drawItemDetails(i, cell, wy);
          if (cell > 0 && cell % 3 === 0) wy += this.lineHeight()
          if (wy + this.lineHeight() > this.contents.height) break;
        }
        this.drawItemSynthCost(this._item, cell, wy);
    };
    
    Window_SynthesisNumber.prototype.drawItemDetails = function(index, cell, wy) {
        var ingredient = DataManager.getSynthesisIngredient(this._item, index);
        var quantity = DataManager.getSynthesisQuantity(this._item, index);
        var ww = (this.contents.width - this.ingredientSpacing()) / 3;
        var wx = (ww + (this.ingredientSpacing() / 2)) * (cell % 3);
        if (!ingredient) return wy;
        this.resetFontSettings();
        this.drawIcon(ingredient.iconIndex, wx + 2, wy + 2);
        this.drawItemQuantity(index, wx, wy, ww);
        return cell + 1;
    };
    
    Window_SynthesisNumber.prototype.drawItemQuantity = function(index, wx, wy, ww) {
        var ingredient = DataManager.getSynthesisIngredient(this._item, index);
        var quantity = DataManager.getSynthesisQuantity(this._item, index);
        quantity *= this.number();
        this.contents.fontSize = Yanfly.Param.ISQuantitySize;
        this.changeTextColor(this.normalColor());
        var num = '/' + Yanfly.Util.toGroup($gameParty.numItems(ingredient));
        this.drawText(num, wx, wy, ww, 'right');
        ww -= this.textWidth(num);
        if ($gameParty.numItems(ingredient) >= quantity) {
          this.changeTextColor(this.powerUpColor());
        } else {
          this.changeTextColor(this.powerDownColor());
        }
        var text = String(Yanfly.Util.toGroup(quantity));
        this.drawText(text, wx, wy, ww, 'right');
    }
    
    Window_SynthesisNumber.prototype.drawItemSynthCost = function(item, cell, wy) {
        if (item.synthCost <= 0) return;
        this.resetFontSettings();
        var value = item.synthCost * this.number();
        var ww = (this.contents.width - this.ingredientSpacing()) / 3;
        var wx = (ww + (this.ingredientSpacing() / 2)) * (cell % 3);
        this.drawCurrencyValue(value, TextManager.currencyUnit, wx, wy, ww)
    };
    
    Window_SynthesisNumber.prototype.buttonY = function() {
        return Math.round(this.priceY() + this.lineHeight() * 2);
    };
     
    #6
    LynXXX and Djajapena like this.
  7. Djajapena

    Djajapena Villager Member

    Messages:
    10
    Likes Received:
    0
    Location:
    Indonesia
    First Language:
    Indonesia
    Primarily Uses:
    RMMV
    @SeaPhoenix This work perfectly! Thank you. What are the terms of use and credit?
     
    #7
  8. SeaPhoenix

    SeaPhoenix Veteran Veteran

    Messages:
    116
    Likes Received:
    59
    First Language:
    English
    Primarily Uses:
    RMMV
    Feel free to use for commercial or non-commercial, no credit necessary (except to Yanfly, but I assume that's already going to happen :smile:) since it's a minor change.
     
    #8
    Djajapena likes this.

Share This Page