| 赞 | 46 |
| VIP | |
| 好人卡 | |
| 积分 | 97 |
| 经验 | |
| 最后登录 | 2026-6-17 |
| 在线时间 | 2775 小时 |
梦石0
星屑9716
在线时间2775 小时
注册时间2008-9-5
回帖3458
   
|
发表于 2020-9-11 13:06:18
|
显示全部楼层
本帖最后由 cinderelmini 于 2020-9-11 14:33 编辑
啊……这还是有点年头的产物了……我看看先……
检查了一遍,大概找到问题是什么原因导致的了,
因为这个图标物品列表脚本里,给每一行都加上了原本作为横向排列的间距参数spacing,
但是这个方法过于暴力,改变了很多作为计算用的数值,而且原本很多是动态计算出来的数值都被设置为固定数字了,于是导致了滚动条的计算出现问题。
我不是很建议让这两个脚本放在一起使用,可以换用另一个来自外网“atelier-rgss”的滚动条脚本:
MOG - Scroll Bar (V1.2)- #==============================================================================
- # +++ MOG - Scroll Bar (V1.2) +++
- #==============================================================================
- # By Moghunter
- # http://www.atelier-rgss.com
- #==============================================================================
- # Adiciona uma barra de rolamento nas janelas quando a lista de itens é maior
- # que a altura da janela.
- #==============================================================================
- # Histórico.
- #==============================================================================
- # 1.2 - Melhoria de compatibilidade.
- #==============================================================================
- module MOG_SCROLL_BAR
- #Definição da posição da barra de deslize.
- SCROLL_BAR_POSITION = [-6,8]
- #Definição da posição Z.
- SCROLL_BAR_Z = 100
- #Definição da cor na imagem baseado no Windowskin.
- SCROLL_BAR_COLOR = [72,96]
- SCROLL_BACKGROUND_COLOR = [64,96]
- end
- $imported = {} if $imported.nil?
- $imported[:mog_scroll_bar] = true
- #==============================================================================
- # ■ Window Selectable
- #==============================================================================
- class Window_Selectable < Window_Base
-
- include MOG_SCROLL_BAR
-
- #--------------------------------------------------------------------------
- # * Create Scroll Bar
- #--------------------------------------------------------------------------
- def create_scroll_bar
- @scroll_bitmap = true
- return if row_max < 1
- @sc_active = self.active ; @sb_sprite = []; @sb_sprite_px = 0
- 2.times do |i| @sb_sprite[i] = Sprite.new; @sb_sprite[i].opacity = 0
- @sb_sprite[i].bitmap = Bitmap.new(4,self.height - 16) end
- refresh_scroll_bar ; update_scroll_bar
- end
-
- #--------------------------------------------------------------------------
- # * Refresh Scroll Bar
- #--------------------------------------------------------------------------
- def refresh_scroll_bar
- return if @sb_sprite == nil
- @sc_active = self.active
- refresh_scroll_point ; refresh_scroll_background
- end
-
- #--------------------------------------------------------------------------
- # * Refresh Scroll Point
- #--------------------------------------------------------------------------
- def refresh_scroll_point
- @sb_sprite[1].bitmap.clear
- row_max_sc = row_max > 20 ? 20 : row_max
- @sb_row_zize = @sb_sprite[1].bitmap.height / row_max_sc + 1
- @row_range_y = @sb_sprite[1].bitmap.height.to_f / row_max
- @sb_row_max = self.y + self.height + 8 - (@sb_row_zize + 16)
- sc_rect = Rect.new(SCROLL_BAR_COLOR[0],SCROLL_BAR_COLOR[1],4,8)
- sc_rect2 = Rect.new(0,0,6,@sb_row_zize)
- @sb_sprite[1].bitmap.stretch_blt(sc_rect2, self.windowskin, sc_rect)
- @sb_sprite[1].z = self.z + SCROLL_BAR_Z + 1; @sb_sprite[1].opacity = 0
- @sb_sprite[1].visible = can_scroll_bar_visible?
- end
-
- #--------------------------------------------------------------------------
- # * Refresh Scroll Background
- #--------------------------------------------------------------------------
- def refresh_scroll_background
- @sb_sprite[0].bitmap.clear
- @sb_sprite_px = self.width - (-SCROLL_BAR_POSITION[0] + @sb_sprite[0].bitmap.width)
- sc_rect = Rect.new(SCROLL_BACKGROUND_COLOR[0],SCROLL_BACKGROUND_COLOR[1],6,8)
- sc_rect2 = Rect.new(0,0,6,@sb_sprite[0].bitmap.height)
- @sb_sprite[0].bitmap.stretch_blt(sc_rect2, self.windowskin, sc_rect)
- @sb_sprite[0].z = self.z + SCROLL_BAR_Z; @sb_sprite[0].opacity = 0
- @sb_sprite[0].visible = can_scroll_bar_visible?
- end
-
- #--------------------------------------------------------------------------
- # * Can Scroll Bar Visible
- #--------------------------------------------------------------------------
- def can_scroll_bar_visible?
- return false if row_max <= page_row_max
- return true
- end
-
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- alias mog_sc_dispose dispose
- def dispose
- mog_sc_dispose
- dispose_scroll_bar
- end
-
- #--------------------------------------------------------------------------
- # * Dispose Scroll Bar
- #--------------------------------------------------------------------------
- def dispose_scroll_bar
- return if @sb_sprite == nil
- @sb_sprite.each {|sprite| sprite.bitmap.dispose ; sprite.dispose }
- end
-
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- alias mog_sc_update update
- def update
- mog_sc_update
- update_scroll_bar
- end
-
- #--------------------------------------------------------------------------
- # * Update Scroll Bar
- #--------------------------------------------------------------------------
- def update_scroll_bar
- create_scroll_bar if @scroll_bitmap == nil
- return if @sb_sprite == nil
- refresh_scroll_bar if @sc_active != self.active
- @sb_sprite[0].y = self.y + 8; @sb_sprite[1].y = scroll_bar_y
- @sb_sprite[1].y = @sb_row_max if @sb_sprite[1].y > @sb_row_max
- @sb_sprite.each {|sprite| sprite.x = self.x + @sb_sprite_px; update_sc_visible(sprite)}
- end
- #--------------------------------------------------------------------------
- # * Update SC Visible
- #--------------------------------------------------------------------------
- def update_sc_visible(sprite)
- if self.active
- sprite.opacity += 15 ; sprite.opacity = 0 if !self.visible
- else
- sprite.opacity -= 30
- end
- end
-
- #--------------------------------------------------------------------------
- # * Scroll Bar Y
- #--------------------------------------------------------------------------
- def scroll_bar_y
- self.y + SCROLL_BAR_POSITION[1] + (@row_range_y * row)
- end
-
- end
复制代码
他这个计算机制和动态方式都不一样,但是兼容性非常好。
另外,我这提供一个与自己那个脚本兼容的解决方法思路:
如果要在行之间增加间距,不建议直接暴力在各项参数里加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两处)
附上粗略修改的版本- #简单图标物品栏 v1.0
- #----------#
- #特点: 看, 是图标! 而不是列表!
- #
- #使用方法: 即插即用.
- #
- #----------#
- #-- Script by: V.M of D.T
- #
- #- Questions or comments can be:
- # given by email: sumptuaryspade@live.ca
- # provided on facebook: [url]http://www.facebook.com/DaimoniousTailsGames[/url]
- # All my other scripts and projects can be found here: [url]http://daimonioustails.weebly.com/[/url]
- #
- #--- Free to use in any project, commercial or non-commercial, with credit given
- # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
-
- class Window_ItemList < Window_Selectable
- def col_max
- #~ (self.width - standard_padding) / 42
- (self.width - standard_padding) / line_height
- end
- #~ def page_row_max
- #~ 7
- #~ end
- def line_height
- return 36 + spacing
- end
- #~ def item_height
- #~ 36
- #~ end
- def item_width
- 36
- end
- #~ def contents_height
- #~ [super - super % item_height, row_max * (item_height + spacing)].max
- #~ end
- def spacing
- 6
- end
- #~ def top_row
- #~ oy / (item_height + spacing)
- #~ end
- #~ def top_row=(row)
- #~ row = 0 if row < 0
- #~ row = row_max - 1 if row > row_max - 1
- #~ self.oy = row * (item_height + spacing)
- #~ end
- #~ def item_rect(index)
- #~ rect = Rect.new
- #~ rect.width = item_width
- #~ rect.height = item_height
- #~ rect.x = index % col_max * (item_width + spacing) + spacing
- #~ rect.y = index / col_max * (item_height + spacing) + spacing
- #~ rect
- #~ end
- def item_rect_for_grid(index)
- rect = item_rect(index)
- rect.height -= spacing
- return rect
- end
- def draw_item(index)
- item = @data[index]
- if item
- #~ rect = item_rect(index)
- rect = item_rect_for_grid(index)
- rect.width -= 4
- rect.x += 2
- big_rect = Rect.new(rect.x-1,rect.y-1,rect.width+2,rect.height+2)
- contents.fill_rect(big_rect, Color.new(0,0,0,255))
- contents.fill_rect(rect, Color.new(0,0,0,100))
- draw_icon(item.icon_index, rect.x+6, rect.y+6)
- contents.font.size = 12
- number = $game_party.item_number(item)
- if number > 1
- draw_text(rect.x + 20, rect.y + 28, 24, contents.font.size, "x" + number.to_s)
- end
- end
- end
-
- def update_cursor
- if @cursor_all
- cursor_rect.set(0, 0, contents.width, row_max * item_height)
- self.top_row = 0
- elsif @index < 0
- cursor_rect.empty
- else
- ensure_cursor_visible
- #~ cursor_rect.set(item_rect(@index))
- cursor_rect.set(item_rect_for_grid(@index))
- end
- end
- end
复制代码
PS:这样粗略修改之后其实还有一点点高度上的误差,可能我还有什么地方没计算好吧(X
|
评分
-
查看全部评分
|