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

Project1

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

[已经解决] 道具选择窗口追加缩略图

[复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
568 小时
注册时间
2012-9-7
帖子
611
跳转到指定楼层
1
发表于 2013-4-22 21:08:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 wingzeroplus 于 2013-4-24 21:23 编辑
  1. #==============================================================================
  2. # □ アイテム選択の処理実装 (for XP)
  3. #------------------------------------------------------------------------------
  4. # Version : 1_20120701
  5. # by サリサ・タイクーン
  6. # http://www.tycoon812.com/rgss/
  7. #==============================================================================

  8. #==============================================================================
  9. # □ 素材スイッチ
  10. #==============================================================================
  11. $rgsslab = {} if $rgsslab == nil
  12. $rgsslab["アイテム選択の処理実装"] = true

  13. if $rgsslab["アイテム選択の処理実装"]

  14. # カスタマイズポイントは、ありません。
  15. module RGSSLAB end

  16. #==============================================================================
  17. # □ RGSSLAB::Item_Select_Process [module]
  18. #==============================================================================
  19. module RGSSLAB::Item_Select_Process
  20.   #--------------------------------------------------------------------------
  21.   # ○ 素材設定用の定数定義
  22.   #--------------------------------------------------------------------------
  23.   MATERIAL_NAME = "アイテム選択の処理実装"
  24.   VERSION       = 1
  25.   RELEASE       = 20120701
  26. end

  27. #==============================================================================
  28. # ■ Game_Temp [class]
  29. #==============================================================================
  30. class Game_Temp
  31.   #--------------------------------------------------------------------------
  32.   # ● 公開インスタンス変数
  33.   #--------------------------------------------------------------------------
  34.   attr_accessor :selected_item
  35.   #--------------------------------------------------------------------------
  36.   # ● オブジェクト初期化 [エイリアス]
  37.   #--------------------------------------------------------------------------
  38.   alias item_select_process_initialize initialize
  39.   def initialize
  40.     item_select_process_initialize
  41.     @selected_item = 0
  42.   end
  43. end

  44. #==============================================================================
  45. # ■ Game_Party [class]
  46. #==============================================================================
  47. class Game_Party
  48.   #--------------------------------------------------------------------------
  49.   # ○ アイテムオブジェクトの配列取得 (武器と防具を含む)
  50.   #--------------------------------------------------------------------------
  51.   def items
  52.     result = []
  53.     for i in @items.keys.sort do result.push($data_items[i]) if $data_items[i].id >100 and @items[i] > 0 end
  54.   #  for i in @items.keys.sort do result.push($data_items[i]) if @items[i] > 0 end
  55.   #  for i in @weapons.keys.sort do result.push($data_weapons[i]) if @weapons[i] > 0 end
  56.   #  for i in @armors.keys.sort do result.push($data_armors[i]) if @armors[i] > 0 end
  57.     return result
  58.   end
  59. end

  60. #==============================================================================
  61. # ■ Interpreter [class]
  62. #==============================================================================
  63. class Interpreter
  64.   #--------------------------------------------------------------------------
  65.   # ○ アイテム選択の処理の呼び出し
  66.   #     message : 表示メッセージ
  67.   #--------------------------------------------------------------------------
  68.   def call_item_select_process(message = "")
  69.     @flag = true if $rgsslab["スクリプト・改"]
  70.     $scene = Scene_ItemSelectProcess.new(message)
  71.     @index += 1
  72.     return false
  73.   end
  74. end

  75. #==============================================================================
  76. # ■ Window_Base [class]
  77. #==============================================================================
  78. class Window_Base < Window
  79.   #--------------------------------------------------------------------------
  80.   # ○ 項目を描画する矩形の取得
  81.   #     index : 項目番号
  82.   #--------------------------------------------------------------------------
  83.   def item_rect(index)
  84.     rect        = Rect.new(0, 0, 0, 0)
  85.     rect.width  = contents.width / @column_max
  86.     rect.height = 32
  87.     rect.x      = index % @column_max * rect.width + (index % @column_max * 20)
  88.     rect.y      = index / @column_max * 32
  89.     return rect
  90.   end
  91. end

  92. #==============================================================================
  93. # □ Window_ItemSelectProcess [class]
  94. #==============================================================================
  95. class Window_ItemSelectProcess < Window_Selectable
  96.   #--------------------------------------------------------------------------
  97.   # ○ オブジェクト初期化 [オーバーライド]
  98.   #--------------------------------------------------------------------------
  99.   def initialize
  100.     super(320, 0, 320, 480)
  101.     self.back_opacity = 128
  102.     @column_max = 1
  103.     self.index = 0
  104.     refresh
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ○ アイテムの取得
  108.   #--------------------------------------------------------------------------
  109.   def item
  110.     return @data[self.index]
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ○ リフレッシュ
  114.   #--------------------------------------------------------------------------
  115.   def refresh
  116.     @data = []
  117.     for item in $game_party.items
  118.       @data.push(item)
  119.     end
  120.     @item_max = @data.size
  121.     h = row_max * 32
  122.     if h == 0
  123.       h = 1
  124.     end
  125.     self.contents = Bitmap.new(width - 32, h)
  126.     for i in 0...@item_max do draw_item(i) end
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ○ 項目の描画
  130.   #     index : 項目数
  131.   #--------------------------------------------------------------------------
  132.   def draw_item(index)
  133.     rect = item_rect(index)
  134.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  135.     item = @data[index]
  136.     if item != nil
  137.       case item
  138.       when RPG::Item   ; number = $game_party.item_number(item.id)
  139.       when RPG::Weapon ; number = $game_party.weapon_number(item.id)
  140.       when RPG::Armor  ; number = $game_party.armor_number(item.id)
  141.       end
  142.       rect.width -= 4
  143.       draw_item_name(item, rect.x, rect.y)
  144.       self.contents.draw_text(rect.x + 240, rect.y, 16, 32, ":", 1)
  145.       self.contents.draw_text(rect.x + 256, rect.y, 24, 32, number.to_s, 2)
  146.     end
  147.   end
  148.   #
  149. end

  150. #==============================================================================
  151. # □ Window_ItemSelectProcess_Message [class]
  152. #==============================================================================
  153. class Window_ItemSelectProcess_Message < Window_Base
  154.   #--------------------------------------------------------------------------
  155.   # ○ オブジェクト初期化 [オーバーライド]
  156.   #     message : メッセージ
  157.   #--------------------------------------------------------------------------
  158.   def initialize(message)
  159.     super(0, 320, 320, 160)
  160.     self.contents = Bitmap.new(width - 32, height - 32)
  161.     self.back_opacity = 128
  162.     refresh(message)
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ○ リフレッシュ
  166.   #     message : メッセージ
  167.   #--------------------------------------------------------------------------
  168.   def refresh(message = nil)
  169.     self.contents.clear
  170.     rect = self.contents.text_size(message)
  171.     self.contents.draw_text(rect, message)
  172.   end
  173. end

  174. #==============================================================================
  175. # □ Scene_ItemSelectProcess [class]
  176. #==============================================================================
  177. class Scene_ItemSelectProcess
  178.   #--------------------------------------------------------------------------
  179.   # ○ オブジェクト初期化
  180.   #     message : メッセージ
  181.   #--------------------------------------------------------------------------
  182.   def initialize(message)
  183.     @message = message
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ○ メイン処理
  187.   #--------------------------------------------------------------------------
  188.   def main
  189.     start
  190.     Graphics.transition
  191.     Input.update
  192.     loop do
  193.       Graphics.update
  194.       Input.update
  195.       update
  196.       break if $scene != self
  197.     end
  198.     Graphics.update
  199.     Graphics.freeze
  200.     terminate
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ○ 開始処理
  204.   #--------------------------------------------------------------------------
  205.   def start
  206.     @spriteset      = Spriteset_Map.new
  207.     @select_window  = Window_ItemSelectProcess.new
  208.     @message_window = Window_ItemSelectProcess_Message.new(@message)
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ○ 終了処理
  212.   #--------------------------------------------------------------------------
  213.   def terminate
  214.     @spriteset.dispose
  215.     @select_window.dispose
  216.     @message_window.dispose
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ○ フレーム更新
  220.   #--------------------------------------------------------------------------
  221.   def update
  222.     @select_window.update
  223.     if Input.trigger?(Input::B)
  224.       $game_system.se_play($data_system.cancel_se)
  225.   #    $game_temp.selected_item = 0
  226.   #    $scene = Scene_Map.new
  227.     end
  228.     if Input.trigger?(Input::C)
  229.       $game_system.se_play($data_system.decision_se)
  230.       case @select_window.item
  231.       when RPG::Item   ; $game_temp.selected_item = @select_window.item.id
  232.       when RPG::Weapon ; $game_temp.selected_item = @select_window.item.id + 1000
  233.       when RPG::Armor  ; $game_temp.selected_item = @select_window.item.id + 2000
  234.       end
  235.       $scene = Scene_Map.new
  236.     end
  237.   end
  238. end

  239. end
复制代码
原版脚本被我稍微改变了下,左上方是空白的
现在想在这个里面追加一个道具缩略图窗口   super的位置和大小是(0, 0, 320, 320)
根据选择窗口里光标指向的道具ID, 在这个新窗口中央刷新并显示PICTURE文件夹下 同ID名在道具图片,自己弄了半天都不行
求高人帮忙
FTM正式版已经发布,点击图片开启传送门

Lv5.捕梦者

梦石
0
星屑
31939
在线时间
5081 小时
注册时间
2012-11-19
帖子
4877

开拓者

2
发表于 2013-4-23 20:38:30 | 只看该作者
呃~~,可不可以把脚本弄好一点,那个,,,,复制到新工程都报错,那样还怎么改啊。
特别是那个定义的 @message  是什么?

点评

我直接上个程吧  发表于 2013-4-23 21:30
忘了说 这个脚本是这么调用的 call_item_select_process("显示的文字")  发表于 2013-4-23 21:29
xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
568 小时
注册时间
2012-9-7
帖子
611
3
 楼主| 发表于 2013-4-23 21:30:03 | 只看该作者
我直接上工程

Project10086.zip

208.42 KB, 下载次数: 65

点评

试试,貌似有点麻烦  发表于 2013-4-23 21:47
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
31939
在线时间
5081 小时
注册时间
2012-11-19
帖子
4877

开拓者

4
发表于 2013-4-24 19:14:24 | 只看该作者
本帖最后由 芯☆淡茹水 于 2013-4-24 19:17 编辑

      唔~,弄好了。
原脚本里新加了个窗口。新加的地方有标识。物品大图命名为 --> 物品名 ,保存在 pictures 文件夹
范例的两张图片是随意找的,320X320的大图(满窗口)。要显示小图可改新建窗口里的坐标。
Project10086.rar (375.27 KB, 下载次数: 60)

评分

参与人数 1星屑 +12 收起 理由
wingzeroplus + 12 认可答案

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
568 小时
注册时间
2012-9-7
帖子
611
5
 楼主| 发表于 2013-4-24 21:22:41 | 只看该作者
非常感谢,原来关键的是那个@select_window.item
FTM正式版已经发布,点击图片开启传送门
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 13:12

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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