赞 | 1 |
VIP | 255 |
好人卡 | 52 |
积分 | 1 |
经验 | 77416 |
最后登录 | 2016-1-18 |
在线时间 | 1269 小时 |
Lv1.梦旅人 薄凉看客
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 1269 小时
- 注册时间
- 2010-6-20
- 帖子
- 1316
|
本帖最后由 恋′挂机 于 2013-9-21 21:10 编辑
- #==============================================================================
- # ■ Window_ShopBuy
- #------------------------------------------------------------------------------
- # 商店画面、浏览显示可以购买的商品的窗口。
- #==============================================================================
- class Window_ShopBuy < Window_Selectable
- #请看65行脚本
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # shop_goods : 商品
- #--------------------------------------------------------------------------
- def initialize(shop_goods)
- #都五列了当然要把宽调大点,你说的翻页其实只要调小高度就可以了
- super(0, 128, 368, 32 * 4 + 32)#X坐标、Y坐标、宽度、高度
- self.z = 123
- @column_max = 1#列数,直接改这里,1也不能省略
- @shop_goods = shop_goods
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for goods_item in @shop_goods
- case goods_item[0]
- when 0
- item = $data_items[goods_item[1]]
- when 1
- item = $data_weapons[goods_item[1]]
- when 2
- item = $data_armors[goods_item[1]]
- end
- if item != nil
- @data.push(item)
- end
- end
- # 如果项目数不是 0 就生成位图、描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- ###################################################
- icon_x = 0#图标的X坐标附加值,向右为正,向左为负
- icon_y = 0#图标的Y坐标附加值,向下为正,向上为负
- #name_x = 0#物品名的X坐标附加值,向右为正,向左为负
- #name_y = 0#物品名的Y坐标附加值,向下为正,向上为负
- price_x = 0#物品价格的X坐标附加值,向右为正,向左为负
- price_y = 0#物品价格的Y坐标附加值,向下为正,向上为负
- ##################################################
- item = @data[index]
- # 获取物品所持数
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
- # 除此之外的情况设置为无效文字色
- if item.price <= $game_party.gold and number < 99
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- #################################
- x = 4 + index % @column_max * (95 + 32)
- y = index / @column_max * 32
- self.contents.font.size = 15#字体大小
- #################################
- rect = Rect.new(x, y, self.width - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x + icon_x, y + 4 + icon_y, bitmap, Rect.new(0, 0, 24, 24), opacity)
- #self.contents.draw_text(x + 28 + name_x, y + name_y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240 + price_x, y + price_y, 88, 32, item.price.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
复制代码 |
|