查看: 4079|回复: 6

[已经解决] (已解决)这个主菜单载入的速度有点慢,为什么?

[复制链接]
梦石
20
星屑
13972
在线时间
1744 小时
注册时间
2017-1-12
回帖
1666

MZ评测员开拓者

发表于 2020-10-20 20:10:02 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 火锅深处 于 2020-10-24 17:27 编辑

一开始只显示选项图标,大约需要2秒左右才能把才能完全显示出来。是开了新工程实验的,应该不存在脚本冲突的问题。
脚本正文
  1. #===============================================================================
  2. # Name: Dark's Super Simple Menu
  3. # Author: Nhat Nguyen (Dark Sky)
  4. # Released on: May 28th 2016
  5. #-------------------------------------------------------------------------------
  6. # Version 1.0: Released!
  7. #-------------------------------------------------------------------------------
  8. # Plug and play!
  9. #===============================================================================
  10. module DarkCreation
  11.   module SuperSimpleMenu
  12.     WINDOW_X = 140
  13.     WINDOW_y = 155
  14.     BACKGROUND_OPACITY = 130
  15.     HELP_FONT = ["04b_19"]
  16.     NON_COMBAT_STYLE = true
  17.     COMMANDS = {
  18.     :item => [261,"Items","Just for accessing Item Sceneeeeeeeeeeee"],
  19.     :skill => [98,"Skills","DO SOME MAGIC!"],
  20.     :equip => [170,"Equipment","Change clothes"],
  21.     :status => [122,"Status","Check for current status"],
  22.     :save => [236,"Save","Save current process"],
  23.     :game_end => [121,"End","End this bullsh*t!"],
  24.     }
  25.     NON_COMBAT_STYLE_LIST = [:skill,:status]
  26.   end
  27. end
  28. #==============================================================================
  29. # ** Window_MenuCommand
  30. #------------------------------------------------------------------------------
  31. #  This command window appears on the menu screen.
  32. #==============================================================================
  33. include DarkCreation::SuperSimpleMenu
  34. class Window_MenuCommand < Window_Command
  35.   attr_accessor :list
  36.   attr_accessor :dhelp_window
  37.   #--------------------------------------------------------------------------
  38.   # * Object Initialization
  39.   #--------------------------------------------------------------------------
  40.   def initialize
  41.     super(WINDOW_X, WINDOW_y)
  42.     @dcontents.x = self.x
  43.     @dcontents.y = self.y
  44.     @dcontents2.x = 150 + (self.x - 100)
  45.     @dcontents2.y = 105 + (self.y - 100)
  46.     @dcontents.opacity = 0
  47.     @dcontents2.opacity = 0
  48.     self.opacity = 0
  49.     self.back_opacity = 0
  50.     select_last
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Get Window Width
  54.   #--------------------------------------------------------------------------
  55.   def window_width
  56.     return 48
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # * Get Window Width
  60.   #--------------------------------------------------------------------------
  61.   alias :dark_dispose_window_menu_qwe  :dispose
  62.   def dispose
  63.     dark_dispose_window_menu_qwe
  64.     @dcontents.bitmap.dispose
  65.     @dcontents.dispose
  66.     @dcontents2.bitmap.dispose
  67.     @dcontents2.dispose
  68.   end
  69.   
  70.   #--------------------------------------------------------------------------
  71.   # * Draw Character Graphic
  72.   #--------------------------------------------------------------------------
  73.   def draw_character2(character_name, character_index, x, y)
  74.     return unless character_name
  75.     bitmap = Cache.character(character_name)
  76.     sign = character_name[/^[\!\$]./]
  77.     if sign && sign.include?('$')
  78.       cw = bitmap.width / 3
  79.       ch = bitmap.height / 4
  80.     else
  81.       cw = bitmap.width / 12
  82.       ch = bitmap.height / 8
  83.     end
  84.     n = character_index
  85.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  86.     @cw = cw
  87.     @dcontents2.bitmap.blt(x - cw / 2, y - ch, bitmap, src_rect)
  88.   end
  89.   
  90.   def draw_actor_graphic2(actor, x, y)
  91.     draw_character2(actor.character_name, actor.character_index, x, y)
  92.   end
  93.   
  94.   #--------------------------------------------------------------------------
  95.   # * Draw Face Graphic
  96.   #     enabled : Enabled flag. When false, draw semi-transparently.
  97.   #--------------------------------------------------------------------------
  98.   def draw_face2(face_name, face_index, x, y, enabled = true)
  99.     bitmap = Cache.face(face_name)
  100.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  101.     @dcontents2.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  102.     bitmap.dispose
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # * Draw Actor Face Graphic
  106.   #--------------------------------------------------------------------------
  107.   def draw_actor_face2(actor, x, y, enabled = true)
  108.     draw_face2(actor.face_name, actor.face_index, x, y, enabled)
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Refresh
  112.   #--------------------------------------------------------------------------
  113.   def refresh
  114.    
  115.     contents.clear
  116.     @dcontents ||= Sprite.new
  117.     @dcontents.bitmap ||= Bitmap.new(self.width - 5,self.height - 5)
  118.     @dcontents.bitmap.clear
  119.     @dcontents.bitmap.fill_rect(5,5,self.width,self.height,Color.new(0,0,0,BACKGROUND_OPACITY)) #contents.fill_rect(0,0,contents.width,contents.height,Color.new(0,0,0,170))
  120.    
  121.     @dcontents2 ||= Sprite.new
  122.     @dcontents2.bitmap ||= Bitmap.new(233,108)#self.width - 5,self.height - 5)
  123.     @dcontents2.bitmap.clear
  124.     @dcontents2.bitmap.font.name = HELP_FONT
  125.     @dcontents2.bitmap.fill_rect(0,0,233,108,Color.new(0,0,0,BACKGROUND_OPACITY))
  126.     draw_actor_graphic2($game_party.members[0],20,43)
  127.     x = @dcontents2.width - 96
  128.     draw_actor_face2($game_party.members[0],x,7)
  129.     @actor_info = "#{$game_party.members[0].name}"# | #{$game_party.members[0].class.name}"
  130.     @dcontents2.bitmap.font.size -= 6
  131.     @dcontents2.bitmap.draw_text(@cw + 10,5,233,24,@actor_info)
  132.     @dcontents2.bitmap.font.color = Color.new(253,155,51)
  133.     @dcontents2.bitmap.draw_text(@cw + 10,5+24,233,24,"#{$game_party.members[0].class.name}")
  134.     @dcontents2.bitmap.font.color = Color.new(255,255,255)
  135.     @dcontents2.bitmap.draw_text(5,5+24+24,233,24,"Gold: #{$game_party.gold}G")
  136.     @dcontents2.bitmap.draw_text(5,5+24*3,233,24,"Place: #{$game_map.display_name}")
  137.     draw_all_items
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # * Create Command List
  141.   #--------------------------------------------------------------------------
  142.   def make_command_list
  143.     add_main_commands
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # * Add Main Commands to List
  147.   #--------------------------------------------------------------------------
  148.   def add_main_commands
  149.     COMMANDS.each_key do |key|
  150.       next if NON_COMBAT_STYLE_LIST.include?(key) && NON_COMBAT_STYLE
  151.       add_command(COMMANDS[key][1],   key,   main_commands_enabled)
  152.     end
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # * Draw Item
  156.   #--------------------------------------------------------------------------
  157.   def draw_item(index)
  158.     change_color(normal_color, command_enabled?(index))
  159.     rect = item_rect_for_text(index)
  160.     rect.x = 0
  161.     draw_icon(COMMANDS[@list[index][:symbol]][0],rect.x,rect.y)
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Process cursor move
  165.   #--------------------------------------------------------------------------
  166.   alias dark_menucommand_process_cursor_move_213 process_cursor_move
  167.   def process_cursor_move
  168.     dark_menucommand_process_cursor_move_213
  169.     @dhelp_window.refresh(true)
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # * Update
  173.   #--------------------------------------------------------------------------
  174.   alias dark_menucommand_update_213 update
  175.   def update
  176.     dark_menucommand_update_213
  177.     if @dcontents.opacity < 255
  178.       @dcontents.opacity += 10
  179.       @dcontents2.opacity += 10
  180.     end
  181.       if @dhelp_window
  182.         @dhelp_window.refresh
  183.       end
  184.   end
  185. end

  186. include DarkCreation::SuperSimpleMenu
  187. class Window_HelpScroll < Window_Base
  188.   attr_accessor :target
  189.   attr_accessor :index
  190.   def initialize(x,y,width,height)
  191.     super(x,y,width,height)
  192.     self.opacity = 0
  193.     self.back_opacity = 0
  194.     @scroll_pos = 0
  195.     @opacity = 0
  196.   end
  197.   def target=(tar)
  198.     if tar.is_a?(Window)
  199.       @target = tar
  200.       create_assets
  201.       refresh
  202.     end
  203.   end
  204.   def dispose
  205.     super
  206.     @dcontents.bitmap.dispose
  207.     @dcontents.dispose
  208.     @d_scroll.bitmap.dispose
  209.     @d_scroll.dispose
  210.   end
  211.   def cal_text_width(text)
  212.     size = 0
  213.     for i in 0...text.size
  214.       size += text_size(text[i]).width
  215.     end
  216.     return size
  217.   end
  218.   def create_assets
  219.     @dcontents = Sprite.new
  220.     @dcontents.bitmap = Bitmap.new(self.width - 5,self.height - 5)
  221.     @dcontents.bitmap.clear
  222.     @dcontents.bitmap.fill_rect(5,5,self.width,self.height,Color.new(0,0,0,BACKGROUND_OPACITY - 20))
  223.     @d_scroll = Sprite.new
  224.     @d_scroll.bitmap ||= Bitmap.new(544,416)
  225.     @dcontents.bitmap.fill_rect(8,@dcontents.bitmap.height - 30,self.width - 16,26,Color.new(0,0,0,BACKGROUND_OPACITY + 30))
  226.     @w_width = self.width - 16
  227.     @w_height = 26
  228.     @w_x = 8
  229.     @w_y = @dcontents.bitmap.height - 30
  230.     @viewport = Viewport.new(5,5,544,416)
  231.     @viewport.z = 990
  232.     @dcontents.viewport = @viewport
  233.     @d_scroll.bitmap.clear
  234.     @dcontents.x = self.x
  235.     @dcontents.y = self.y
  236.     @viewport1 = Viewport.new(self.x + 14,self.y+32,@w_width-1,@w_height)
  237.     @viewport1.z = 999
  238.     @dcontents.bitmap.font.name = HELP_FONT
  239.     @d_scroll.bitmap.font.name = HELP_FONT
  240.     @d_scroll.bitmap.font.size = 15
  241.     @d_scroll.viewport = @viewport1
  242.     @dcontents.opacity = @d_scroll.opacity = 0
  243.     @index = -1
  244.   end
  245.   def refresh(reset=false)
  246.     @d_scroll.bitmap.clear
  247.     @dcontents.bitmap.clear
  248.     @text = COMMANDS[@target.list[@target.index][:symbol]][2]
  249.     if @dcontents.opacity < 255
  250.       @dcontents.opacity += 5
  251.       @d_scroll.opacity += 5
  252.     end
  253.     if @index != @target.index
  254.       @scroll_pos = -@w_width+1
  255.       @d_scroll.ox = @scroll_pos
  256.       @index = @target.index
  257.     else
  258.       @dcontents.bitmap.fill_rect(5,5,self.width,self.height,Color.new(0,0,0,BACKGROUND_OPACITY - 20))
  259.           @dcontents.bitmap.fill_rect(8,@dcontents.bitmap.height - 30,self.width - 16,26,Color.new(0,0,0,BACKGROUND_OPACITY + 30))
  260.       @dcontents.bitmap.draw_text(8,-1,@dcontents.bitmap.width,24,COMMANDS[@target.list[@target.index][:symbol]][1])
  261.     end
  262.     @d_scroll.bitmap.draw_text(2,4,cal_text_width(@text),24,@text)
  263.     @d_scroll.ox = @scroll_pos
  264.     @scroll_pos += 1
  265.     if @scroll_pos > cal_text_width(@text) - 10
  266.       @scroll_pos = -@w_width+1
  267.     end
  268.   end
  269. end

  270. #==============================================================================
  271. # ** Scene_Menu
  272. #------------------------------------------------------------------------------
  273. #  This class performs the menu screen processing.
  274. #==============================================================================

  275. class Scene_Menu < Scene_MenuBase
  276.   #--------------------------------------------------------------------------
  277.   # * Start Processing
  278.   #--------------------------------------------------------------------------
  279.   def start
  280.     super
  281.     create_command_window
  282.     #create_gold_window
  283.     #create_status_window
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # * Create Command Window
  287.   #--------------------------------------------------------------------------
  288.   def create_command_window
  289.     @command_window = Window_MenuCommand.new
  290.     @scroll_help = Window_HelpScroll.new(@command_window.x - 4,@command_window.y,9*32,32*2)
  291.     @scroll_help.y = @command_window.y - @scroll_help.height
  292.     @scroll_help.target = @command_window
  293.     @command_window.dhelp_window = @scroll_help
  294.     @command_window.set_handler(:item,      method(:command_item))
  295.     @command_window.set_handler(:skill,     method(:on_personal_ok))
  296.     @command_window.set_handler(:equip,     method(:on_personal_ok))
  297.     @command_window.set_handler(:status,    method(:on_personal_ok))
  298.     #@command_window.set_handler(:formation, method(:command_formation))
  299.     @command_window.set_handler(:save,      method(:command_save))
  300.     @command_window.set_handler(:game_end,  method(:command_game_end))
  301.     @command_window.set_handler(:cancel,    method(:return_scene))
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # * Create Gold Window
  305.   #--------------------------------------------------------------------------
  306.   def create_gold_window
  307.     @gold_window = Window_Gold.new
  308.     @gold_window.x = 0
  309.     @gold_window.y = Graphics.height - @gold_window.height
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # * Create Status Window
  313.   #--------------------------------------------------------------------------
  314.   def create_status_window
  315.     @status_window = Window_MenuStatus.new(@command_window.width, 0)
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # * [Item] Command
  319.   #--------------------------------------------------------------------------
  320.   def command_item
  321.     SceneManager.call(Scene_Item)
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # * [Skill], [Equipment] and [Status] Commands
  325.   #--------------------------------------------------------------------------
  326.   def command_personal
  327.     @status_window.select_last
  328.     @status_window.activate
  329.     @status_window.set_handler(:ok,     method(:on_personal_ok))
  330.     @status_window.set_handler(:cancel, method(:on_personal_cancel))
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # * [Formation] Command
  334.   #--------------------------------------------------------------------------
  335.   def command_formation
  336.     @status_window.select_last
  337.     @status_window.activate
  338.     @status_window.set_handler(:ok,     method(:on_formation_ok))
  339.     @status_window.set_handler(:cancel, method(:on_formation_cancel))
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # * [Save] Command
  343.   #--------------------------------------------------------------------------
  344.   def command_save
  345.     SceneManager.call(Scene_Save)
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # * [Exit Game] Command
  349.   #--------------------------------------------------------------------------
  350.   def command_game_end
  351.     SceneManager.call(Scene_End)
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # * [OK] Personal Command
  355.   #--------------------------------------------------------------------------
  356.   def on_personal_ok
  357.     case @command_window.current_symbol
  358.     when :skill
  359.       SceneManager.call(Scene_Skill)
  360.     when :equip
  361.       SceneManager.call(Scene_Equip)
  362.     when :status
  363.       SceneManager.call(Scene_Status)
  364.     end
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # * [Cancel] Personal Command
  368.   #--------------------------------------------------------------------------
  369.   def on_personal_cancel
  370.     @status_window.unselect
  371.     @command_window.activate
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # * Formation [OK]
  375.   #--------------------------------------------------------------------------
  376.   def on_formation_ok
  377.     if @status_window.pending_index >= 0
  378.       $game_party.swap_order(@status_window.index,
  379.                              @status_window.pending_index)
  380.       @status_window.pending_index = -1
  381.       @status_window.redraw_item(@status_window.index)
  382.     else
  383.       @status_window.pending_index = @status_window.index
  384.     end
  385.     @status_window.activate
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * Formation [Cancel]
  389.   #--------------------------------------------------------------------------
  390.   def on_formation_cancel
  391.     if @status_window.pending_index >= 0
  392.       @status_window.pending_index = -1
  393.       @status_window.activate
  394.     else
  395.       @status_window.unselect
  396.       @command_window.activate
  397.     end
  398.   end
  399. end
复制代码

梦石
1
星屑
22113
在线时间
4886 小时
注册时间
2014-12-22
回帖
1509

开拓者

发表于 2020-10-21 09:52:53 | 显示全部楼层
本帖最后由 shencao 于 2020-10-21 09:55 编辑

看了一下,它本身就是设计成渐隐的效果吧?
我改了46,47,243行的 0 改到 255,下面的窗口可以直接显示了,但是上面滚动文字那个始终是要迟一拍,以我的脚本能力是解决不了了,你要不等等大佬,或者看看能不能就接受了这个设定(´・ω・`)

点评

确实,上面那个窗口感觉除了文字应该和下面的一样,到底该改哪儿呢_(:з)∠)_ 从油管的演示看这个渐入似乎丝滑柔顺https://www.youtube.com/watch?v=iz3sbAHXDGQ  发表于 2020-10-22 19:45
回复

使用道具 举报

梦石
0
星屑
6375
在线时间
1473 小时
注册时间
2015-7-25
回帖
609

极短25参与开拓者

发表于 2020-10-21 20:07:56 | 显示全部楼层
你update里一直在@dhelp_window.refresh肯定卡呀,我觉得注释掉会好很多

点评

谢谢建议,不过完全不懂脚本不造注释会不会出问题,我再试试_(:з)∠)_  发表于 2020-10-22 19:46
哎我插个话,它这@dhelp_window是一个文字走马灯的效果,所以一直在刷新吧(我猜的。所以我也不会改,超出我能力范围了_(:з」∠)_  发表于 2020-10-22 14:49
笨肉包的游戏讨论群932812135 (实时更新) 喜欢的话欢迎加入~
目前的坑
??? #像素风OC游戏 准备中 短篇-约5小时
花城梦之心 #像素风OC游戏 系统开发+素材绘制中
【不可思议的迷宫】幽灵契约外传:歌莉娅 v0.4 游戏文件已更新
同时更新中~ (沉迷摸鱼中~更新速度较慢请见谅w)
这是属于笨肉包一个人的旅行~(这只肉包又在摸鱼!
旅途的最终目标~ ???(保密~
回复

使用道具 举报

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

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

发表于 2020-10-24 17:20:02 | 显示全部楼层
照2L的方式都改成255之后,
因为help窗的内容是在设置绑定的目标窗之后才刷新内容的,所以会慢一拍,

我尝试在执行绑定之后(代码296行左右的地方)强制执行一次画面更新,问题似乎解决了,如下:
  1. @scroll_help.target = @command_window
  2. @command_window.dhelp_window = @scroll_help
  3. update_basic
复制代码

评分

参与人数 1赞 +1 收起 理由
火锅深处 + 1 可以来了,谢谢大佬

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部