设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 58|回复: 0

[转载发布] Highly customizable sorting plugin

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    8067

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    30141
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    39102

    灌水之王

    发表于 5 天前 | 显示全部楼层 |阅读模式
    Introduction:
    Searching the forum and also google for sorting plugins surely brings up a bunch of results and those I had a look at definitely fulfilled the needs of multiple users, just not mine.

    So what are my needs, and why have I written another sorting plugin?

    I haven't played many RPGs, but most of them I have played offered at least two different pre-defined sort orders for the items.

    So I had 2 different goals while developing this plugin:
         - Offer multiple sort options to the player
         - Offer customizability to the programmer(s) who will use this plugin
            They should be able to decide which sort options are available in there game.

    Credits and Use:
    It's completely open to non-commercial and commercial projects and does not require any credits.

    Features:
    The plugin itself is very complex, because it has high customizability. So let's go over the plugin parameters:
    [/url]

    As you can see, it defines 5 structs for 5 different things that can be sorted by the plugin and a bunch of texts which are for a
    new option in the "Options" menu which I explain later.
    The plugin defines sorting options for Items, Weapons, Armor, Skills and Goods seperately.
    The Goods option let's you define sort orders for the shop buy window, in case you wonder.

    Now let's have a look at one of the structs:
    It has a bunch of sub structs for pre-defined sorting options, each of them consisting of a "Name" you can customize and
    a flag where you can set whether you want to use them in your game.
    [url=https://forums.rpgmakerweb.com/attachments/particular-sort-option-png.114062/]

    Changes to the parameters which I have marked yellow won't affect your game once you have already started it with plugin installed before. Why this is the case I'll also explain later.

    Now let's have a look at the custom option:
    It is a list of sub structures, each consisting of the same two parameters 'Name' and 'Use' and a third one where you can define your custom javascript sort value calculation function:
    [/url]

    All these parameters will be converted into arrays by the plugin. The parameter 'Default Sort Method' is the index in this array.
    So for Items this particularly means:
        0: Unsorted (Database Order)
        1: Lexicographically
        2: By Price
        3: By amount in possession
        4: Custom option 1
        5: Custom option 2
        ...
    The option which is marked as 'Default' must always have the 'Use' flag set to 'true', otherwise the plugin will throw an error.

    The parameter 'Descending' should be self explanatory.

    The plugin parameters for the equipment have another sub option called parameters.
    Here you can define the stats for which sorting options should be defined.
    In the given example, they will be defined for:
         1 - MaxMP
         2 - Attack
         4 - Magic Attack
         6 - Agility and
         7 - Luck
    [url=https://forums.rpgmakerweb.com/attachments/equipmentoptions-png.114066/]

    Please define only valid numbers here, the plugin doesn't handle invalid numbers not very well
    and please plan those beforehand. Adding or removing parameters after you have started you game once with the
    plugin installed might mess with already defined sorting orders saved with the game.

    What does this plugin lack:
    - Ability to let the player swap items in the sort order (something many RPGs actually offer).
       I found a plugin in the request section of this forum that actually implements such a functionality, but unfortunately
       it won't be compatible with my plugin unless the player always uses the default sorting order. My sorting options will
       definitely overwrite any sorting done by the player manually, so I won't implement such a feature into this plugin.

    How does the plugin affect the game:
    The first thing the plugin does is loading the values of the plugin parameters 'Default Sort Order' and 'Descending' of each individual struct into the ConfigManager, which means they will be saved globally with your game in the config.rpgsave file.
    Unless you delete that file, the defaults from the plugin parameters will be overwritten with the saved configuration the next
    time you start your game, thus any changes to those two plugin parameters won't have any effect.

    The plugin adds a new option 'Sorting Rules' to your games option menu.
    [/url]

    If you are using YEP_OptionsCore this option won't appear. You have to add it seperately to the plugin parameters of Yanfly's plugin. The important parameter values are as follows:

    Help Description:
    Change default sorting rules for items, weapons,
    armor, skills and shop goods.

    Show/Hide:
    show = Imported.BO_SortingOptions;

    Symbol:
    SortingRules

    Draw Option Code:
                    Code:       
    1. var rect = this.itemRectForText(index);
    2. var text = this.commandName(index);
    3. this.resetTextColor();
    4. this.changePaintOpacity(this.isCommandEnabled(index));
    5. this.drawText(text, rect.x, rect.y, rect.width, 'left');
    复制代码


    Process OK Code:
                    Code:       
    1. Yanfly.Options.Window_Options_processOk.call(this);
    复制代码


    Set every parameter below the Process OK Code parameter to blank strings.
    You also have to install YEP_OptionsCore below my plugin to make it work.

    The new option will pop up a new scene, where you can change the sorting options and orders of the different types
    by pressing the left and right keys:
    [url=https://forums.rpgmakerweb.com/attachments/sorting-options-scene-png.114070/]


    If the menu is opened from the title screen any changes will be saved into the Config Manager and will automatically
    taken over to the save files created by the 'New Game' option.

    If the menu is opened from within the game any changes will be saved into a new object which is saved with your save file.
    So there is a global option and individual options per save file.

    Example:
    Let's sort Armor descending by 'Magic Attack':
    [/url]
    You can see, that equipment is sorted differently depending on whether you are in the item scene or in the equip scene.
    In the item scene the equipment items are sorted by their raw stats (Power Ring offering 25, Ring 10 and Lost Ring only 5 Magic Attack)
    In the equip scene they are sorted by the actual effect on the actor (Lost Ring has set a 400% Magic Attack trait, so it comes first).

    Each time one of the windows that can be sorted with this plugin is opened it is sorted by the rules defined in the options,
    e.g.

    [url=https://forums.rpgmakerweb.com/attachments/sort-options-items-png.114406/]


    my Item Window is always sorted ascending by name when it is opened.
    I can change the sort order by pression 'O' and the sort method by pressing 'S'.
    These changes are not saved, when the window is closed or switched to 'Weapon'/'Armor'/'Key Item' mode.
    The next time it is opened it is again sorted by the default sorting rule applied in the options.

    The little info window which displayes the keys used for sorting will only show up as long as it's parent window
    is active. Depending on the size of it's parent window it will either by vertical or horizontal:



    Compatibility:
    - Should be compatible with any plugin, that does not sorting on it's own.
    - Should be compatible with any plugin, that does not overwrite the function makeItemList of the following windows
       Window_ItemList, Window_SkillList, Window_ShopBuy without calling an alias.
    - Is in it's current development state at least compatible with the following Yanfly Plugins, as you might have already spotted
       in last screenshot:
       YEP_ItemCore: But won't use it with independend items, as sorting in general seems to mess up with this functionality.
       YEP_X_ItemCategories: Any weapon, armor added to a new category defined by this plugin, will be sorted by the rules
                                            for normal items.
       YEP_EquipCore
       YEP_SkillCore
       YEP_ShopMenuCore
       YEP_BattleEngineCore

    This plugin has to be placed under those plugins, but above YEP_OptionsCore to function properly.

    Is not compatible with key board customization or gamepads yet. I would really appreciate suggestions on how I can get compatible with those!!!

    Thanks
    Thanks go to Yanfly. I learned a lot from reading through the code of Yanflys plugins. Without these plugins it might have taken
    a lot longer to develop this plugin.

    The actual plugin:
    As I currently do not have any acount on a content sharing platform, I cannot provide a test project even I really want to.
    Therefore I will upload the plugin directly here. Please grab it if you are interested.
    Any feedback would be appreciated.

    Thanks you,
    BurningOrca


    本贴来自国际rpgmaker官方论坛作者:BurningOrca处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/highly-customizable-sorting-plugin.108247/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 11:45 , Processed in 0.117175 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表