设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3251|回复: 5
打印 上一主题 下一主题

Vlue的「简单图标物品栏」兼容「右侧滚动条」

[复制链接]

Lv5.捕梦者

梦石
0
星屑
24287
在线时间
5046 小时
注册时间
2016-3-8
帖子
1618
跳转到指定楼层
1
发表于 2020-9-10 21:04:25 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 alexncf125 于 2024-1-25 13:05 编辑

@cinderelmini
大大的右侧滚动条与下方的脚本合用会有瑕疵喔
问题好像与page_row_max有关?


RUBY 代码复制
  1. #简单图标物品栏 v1.0
  2. #----------#
  3. #特点: 看, 是图标! 而不是列表!
  4. #
  5. #使用方法:    即插即用.
  6. #
  7. #----------#
  8. #-- Script by: V.M of D.T
  9. #
  10. #- Questions or comments can be:
  11. #    given by email: [email protected]
  12. #    provided on facebook: [url]http://www.facebook.com/DaimoniousTailsGames[/url]
  13. #   All my other scripts and projects can be found here: [url]http://daimonioustails.weebly.com/[/url]
  14. #
  15. #--- Free to use in any project, commercial or non-commercial, with credit given
  16. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  17.  
  18. class Window_ItemList < Window_Selectable
  19.   def col_max
  20.     (self.width - standard_padding) / 42
  21.   end
  22.   def page_row_max
  23.     7
  24.   end
  25.   def item_height
  26.     36
  27.   end
  28.   def item_width
  29.     36
  30.   end
  31.   def contents_height
  32.     [super - super % item_height, row_max * (item_height + spacing)].max
  33.   end
  34.   def spacing
  35.     6
  36.   end
  37.   def top_row
  38.     oy / (item_height + spacing)
  39.   end
  40.   def top_row=(row)
  41.     row = 0 if row < 0
  42.     row = row_max - 1 if row > row_max - 1
  43.     self.oy = row * (item_height + spacing)
  44.   end
  45.   def item_rect(index)
  46.     rect = Rect.new
  47.     rect.width = item_width
  48.     rect.height = item_height
  49.     rect.x = index % col_max * (item_width + spacing) + spacing
  50.     rect.y = index / col_max * (item_height + spacing) + spacing
  51.     rect
  52.   end
  53.   def draw_item(index)
  54.     item = @data[index]
  55.     if item
  56.       rect = item_rect(index)
  57.       rect.width -= 4
  58.       rect.x += 2
  59.       big_rect = Rect.new(rect.x-1,rect.y-1,rect.width+2,rect.height+2)
  60.       contents.fill_rect(big_rect, Color.new(0,0,0,255))
  61.       contents.fill_rect(rect, Color.new(0,0,0,100))
  62.       draw_icon(item.icon_index, rect.x+6, rect.y+6)
  63.       contents.font.size = 12
  64.       number = $game_party.item_number(item)
  65.       if number > 1
  66.         draw_text(rect.x + 20, rect.y + 28, 24, contents.font.size, "x" + number.to_s)
  67.       end
  68.     end
  69.   end
  70. end

Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9335
在线时间
2745 小时
注册时间
2008-9-5
帖子
3540

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

2
发表于 2020-9-11 13:06:18 | 只看该作者
本帖最后由 cinderelmini 于 2020-9-11 14:33 编辑

啊……这还是有点年头的产物了……我看看先……


检查了一遍,大概找到问题是什么原因导致的了,
因为这个图标物品列表脚本里,给每一行都加上了原本作为横向排列的间距参数spacing,
但是这个方法过于暴力,改变了很多作为计算用的数值,而且原本很多是动态计算出来的数值都被设置为固定数字了,于是导致了滚动条的计算出现问题。

我不是很建议让这两个脚本放在一起使用,可以换用另一个来自外网“atelier-rgss”的滚动条脚本:
MOG - Scroll Bar (V1.2)

他这个计算机制和动态方式都不一样,但是兼容性非常好。


另外,我这提供一个与自己那个脚本兼容的解决方法思路:
如果要在行之间增加间距,不建议直接暴力在各项参数里加spacing,那样会改动非常多地方。
item_height方法本来就是使用line_height,那么不要动它,直接改line_height,
把spacing加到line_height上,但是这样一来可能draw_item和update_cursor等地方里使用到的item_rect的高度会比预期的高出一段spacing,
那么只需要仿照item_rect_for_text另外设置一个rect方法,读取item_rect并将高度减去spacing用到对应的地方去就可以了
(注:不是替换所有的item_rect,仅作为增加行距的话,仅需要替换draw_item和update_cursor两处)
附上粗略修改的版本

PS:这样粗略修改之后其实还有一点点高度上的误差,可能我还有什么地方没计算好吧(X

点评

已更新~请查收~  发表于 2020-9-11 13:49
忘了说,那个物品列表当时有999(测试效果)种不同的物品  发表于 2020-9-11 13:20

评分

参与人数 1+1 收起 理由
alexncf125 + 1 麻烦您了

查看全部评分

回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24287
在线时间
5046 小时
注册时间
2016-3-8
帖子
1618
3
 楼主| 发表于 2020-9-11 15:03:42 | 只看该作者
cinderelmini 发表于 2020-9-11 13:06
啊……这还是有点年头的产物了……我看看先……


检查了一遍,大概找到问题是什么原 ...

按大大的脚本改了后, 很多東西的位置和宽高都不同了
我想我转用MOG好了, 不过还是大大的滚动条最美观

点评

呃,可能你是把line_height和item_leight分开使用了吧,单纯这个脚本的话我这边这样改之后没什么排版问题。如果改动太多的话用mog确实会比较方便233  发表于 2020-9-11 16:32
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-26 10:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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