查看: 4010|回复: 6

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

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

MZ评测员开拓者

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

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

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

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

一开始只显示选项图标,大约需要2秒左右才能把才能完全显示出来。是开了新工程实验的,应该不存在脚本冲突的问题。
脚本正文
[pre lang="ruby"]#===============================================================================
# Name: Dark's Super Simple Menu
# Author: Nhat Nguyen (Dark Sky)
# Released on: May 28th 2016
#-------------------------------------------------------------------------------
# Version 1.0: Released!
#-------------------------------------------------------------------------------
# Plug and play!
#===============================================================================
module DarkCreation
  module SuperSimpleMenu
    WINDOW_X = 140
    WINDOW_y = 155
    BACKGROUND_OPACITY = 130
    HELP_FONT = ["04b_19"]
    NON_COMBAT_STYLE = true
    COMMANDS = {
    :item => [261,"Items","Just for accessing Item Sceneeeeeeeeeeee"],
    :skill => [98,"Skills","DO SOME MAGIC!"],
    :equip => [170,"Equipment","Change clothes"],
    :status => [122,"Status","Check for current status"],
    :save => [236,"Save","Save current process"],
    :game_end => [121,"End","End this bullsh*t!"],
    }
    NON_COMBAT_STYLE_LIST = [:skill,:status]
  end
end
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
#  This command window appears on the menu screen.
#==============================================================================
include DarkCreation::SuperSimpleMenu
class Window_MenuCommand < Window_Command
  attr_accessor :list
  attr_accessor :dhelp_window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(WINDOW_X, WINDOW_y)
    @dcontents.x = self.x
    @dcontents.y = self.y
    @dcontents2.x = 150 + (self.x - 100)
    @dcontents2.y = 105 + (self.y - 100)
    @dcontents.opacity = 0
    @dcontents2.opacity = 0
    self.opacity = 0
    self.back_opacity = 0
    select_last
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 48
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  alias :dark_dispose_window_menu_qwe  :dispose
  def dispose
    dark_dispose_window_menu_qwe
    @dcontents.bitmap.dispose
    @dcontents.dispose
    @dcontents2.bitmap.dispose
    @dcontents2.dispose
  end
  
  #--------------------------------------------------------------------------
  # * Draw Character Graphic
  #--------------------------------------------------------------------------
  def draw_character2(character_name, character_index, x, y)
    return unless character_name
    bitmap = Cache.character(character_name)
    sign = character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    n = character_index
    src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
    @cw = cw
    @dcontents2.bitmap.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
  
  def draw_actor_graphic2(actor, x, y)
    draw_character2(actor.character_name, actor.character_index, x, y)
  end
  
  #--------------------------------------------------------------------------
  # * Draw Face Graphic
  #     enabled : Enabled flag. When false, draw semi-transparently.
  #--------------------------------------------------------------------------
  def draw_face2(face_name, face_index, x, y, enabled = true)
    bitmap = Cache.face(face_name)
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
    @dcontents2.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
    bitmap.dispose
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Face Graphic
  #--------------------------------------------------------------------------
  def draw_actor_face2(actor, x, y, enabled = true)
    draw_face2(actor.face_name, actor.face_index, x, y, enabled)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
   
    contents.clear
    @dcontents ||= Sprite.new
    @dcontents.bitmap ||= Bitmap.new(self.width - 5,self.height - 5)
    @dcontents.bitmap.clear
    @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))
   
    @dcontents2 ||= Sprite.new
    @dcontents2.bitmap ||= Bitmap.new(233,108)#self.width - 5,self.height - 5)
    @dcontents2.bitmap.clear
    @dcontents2.bitmap.font.name = HELP_FONT
    @dcontents2.bitmap.fill_rect(0,0,233,108,Color.new(0,0,0,BACKGROUND_OPACITY))
    draw_actor_graphic2($game_party.members[0],20,43)
    x = @dcontents2.width - 96
    draw_actor_face2($game_party.members[0],x,7)
    @actor_info = "#{$game_party.members[0].name}"# | #{$game_party.members[0].class.name}"
    @dcontents2.bitmap.font.size -= 6
    @dcontents2.bitmap.draw_text(@cw + 10,5,233,24,@actor_info)
    @dcontents2.bitmap.font.color = Color.new(253,155,51)
    @dcontents2.bitmap.draw_text(@cw + 10,5+24,233,24,"#{$game_party.members[0].class.name}")
    @dcontents2.bitmap.font.color = Color.new(255,255,255)
    @dcontents2.bitmap.draw_text(5,5+24+24,233,24,"Gold: #{$game_party.gold}G")
    @dcontents2.bitmap.draw_text(5,5+24*3,233,24,"Place: #{$game_map.display_name}")
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_main_commands
  end
  #--------------------------------------------------------------------------
  # * Add Main Commands to List
  #--------------------------------------------------------------------------
  def add_main_commands
    COMMANDS.each_key do |key|
      next if NON_COMBAT_STYLE_LIST.include?(key) && NON_COMBAT_STYLE
      add_command(COMMANDS[key][1],   key,   main_commands_enabled)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    rect.x = 0
    draw_icon(COMMANDS[@list[index][:symbol]][0],rect.x,rect.y)
  end
  #--------------------------------------------------------------------------
  # * Process cursor move
  #--------------------------------------------------------------------------
  alias dark_menucommand_process_cursor_move_213 process_cursor_move
  def process_cursor_move
    dark_menucommand_process_cursor_move_213
    @dhelp_window.refresh(true)
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias dark_menucommand_update_213 update
  def update
    dark_menucommand_update_213
    if @dcontents.opacity < 255
      @dcontents.opacity += 10
      @dcontents2.opacity += 10
    end
      if @dhelp_window
        @dhelp_window.refresh
      end
  end
end

include DarkCreation::SuperSimpleMenu
class Window_HelpScroll < Window_Base
  attr_accessor :target
  attr_accessor :index
  def initialize(x,y,width,height)
    super(x,y,width,height)
    self.opacity = 0
    self.back_opacity = 0
    @scroll_pos = 0
    @opacity = 0
  end
  def target=(tar)
    if tar.is_a?(Window)
      @target = tar
      create_assets
      refresh
    end
  end
  def dispose
    super
    @dcontents.bitmap.dispose
    @dcontents.dispose
    @d_scroll.bitmap.dispose
    @d_scroll.dispose
  end
  def cal_text_width(text)
    size = 0
    for i in 0...text.size
      size += text_size(text).width
    end
    return size
  end
  def create_assets
    @dcontents = Sprite.new
    @dcontents.bitmap = Bitmap.new(self.width - 5,self.height - 5)
    @dcontents.bitmap.clear
    @dcontents.bitmap.fill_rect(5,5,self.width,self.height,Color.new(0,0,0,BACKGROUND_OPACITY - 20))
    @d_scroll = Sprite.new
    @d_scroll.bitmap ||= Bitmap.new(544,416)
    @dcontents.bitmap.fill_rect(8,@dcontents.bitmap.height - 30,self.width - 16,26,Color.new(0,0,0,BACKGROUND_OPACITY + 30))
    @w_width = self.width - 16
    @w_height = 26
    @w_x = 8
    @w_y = @dcontents.bitmap.height - 30
    @viewport = Viewport.new(5,5,544,416)
    @viewport.z = 990
    @dcontents.viewport = @viewport
    @d_scroll.bitmap.clear
    @dcontents.x = self.x
    @dcontents.y = self.y
    @viewport1 = Viewport.new(self.x + 14,self.y+32,@w_width-1,@w_height)
    @viewport1.z = 999
    @dcontents.bitmap.font.name = HELP_FONT
    @d_scroll.bitmap.font.name = HELP_FONT
    @d_scroll.bitmap.font.size = 15
    @d_scroll.viewport = @viewport1
    @dcontents.opacity = @d_scroll.opacity = 0
    @index = -1
  end
  def refresh(reset=false)
    @d_scroll.bitmap.clear
    @dcontents.bitmap.clear
    @text = COMMANDS[@target.list[@target.index][:symbol]][2]
    if @dcontents.opacity < 255
      @dcontents.opacity += 5
      @d_scroll.opacity += 5
    end
    if @index != @target.index
      @scroll_pos = -@w_width+1
      @d_scroll.ox = @scroll_pos
      @index = @target.index
    else
      @dcontents.bitmap.fill_rect(5,5,self.width,self.height,Color.new(0,0,0,BACKGROUND_OPACITY - 20))
          @dcontents.bitmap.fill_rect(8,@dcontents.bitmap.height - 30,self.width - 16,26,Color.new(0,0,0,BACKGROUND_OPACITY + 30))
      @dcontents.bitmap.draw_text(8,-1,@dcontents.bitmap.width,24,COMMANDS[@target.list[@target.index][:symbol]][1])
    end
    @d_scroll.bitmap.draw_text(2,4,cal_text_width(@text),24,@text)
    @d_scroll.ox = @scroll_pos
    @scroll_pos += 1
    if @scroll_pos > cal_text_width(@text) - 10
      @scroll_pos = -@w_width+1
    end
  end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_command_window
    #create_gold_window
    #create_status_window
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_MenuCommand.new
    @scroll_help = Window_HelpScroll.new(@command_window.x - 4,@command_window.y,9*32,32*2)
    @scroll_help.y = @command_window.y - @scroll_help.height
    @scroll_help.target = @command_window
    @command_window.dhelp_window = @scroll_help
    @command_window.set_handler(:item,      method(:command_item))
    @command_window.set_handler(:skill,     method(:on_personal_ok))
    @command_window.set_handler(:equip,     method(:on_personal_ok))
    @command_window.set_handler(:status,    method(:on_personal_ok))
    #@command_window.set_handler(:formation, method(:command_formation))
    @command_window.set_handler(:save,      method(:command_save))
    @command_window.set_handler(:game_end,  method(:command_game_end))
    @command_window.set_handler(:cancel,    method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Create Gold Window
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = Graphics.height - @gold_window.height
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_status_window
    @status_window = Window_MenuStatus.new(@command_window.width, 0)
  end
  #--------------------------------------------------------------------------
  # * [Item] Command
  #--------------------------------------------------------------------------
  def command_item
    SceneManager.call(Scene_Item)
  end
  #--------------------------------------------------------------------------
  # * [Skill], [Equipment] and [Status] Commands
  #--------------------------------------------------------------------------
  def command_personal
    @status_window.select_last
    @status_window.activate
    @status_window.set_handler(:ok,     method(:on_personal_ok))
    @status_window.set_handler(:cancel, method(:on_personal_cancel))
  end
  #--------------------------------------------------------------------------
  # * [Formation] Command
  #--------------------------------------------------------------------------
  def command_formation
    @status_window.select_last
    @status_window.activate
    @status_window.set_handler(:ok,     method(:on_formation_ok))
    @status_window.set_handler(:cancel, method(:on_formation_cancel))
  end
  #--------------------------------------------------------------------------
  # * [Save] Command
  #--------------------------------------------------------------------------
  def command_save
    SceneManager.call(Scene_Save)
  end
  #--------------------------------------------------------------------------
  # * [Exit Game] Command
  #--------------------------------------------------------------------------
  def command_game_end
    SceneManager.call(Scene_End)
  end
  #--------------------------------------------------------------------------
  # * [OK] Personal Command
  #--------------------------------------------------------------------------
  def on_personal_ok
    case @command_window.current_symbol
    when :skill
      SceneManager.call(Scene_Skill)
    when :equip
      SceneManager.call(Scene_Equip)
    when :status
      SceneManager.call(Scene_Status)
    end
  end
  #--------------------------------------------------------------------------
  # * [Cancel] Personal Command
  #--------------------------------------------------------------------------
  def on_personal_cancel
    @status_window.unselect
    @command_window.activate
  end
  #--------------------------------------------------------------------------
  # * Formation [OK]
  #--------------------------------------------------------------------------
  def on_formation_ok
    if @status_window.pending_index >= 0
      $game_party.swap_order(@status_window.index,
                             @status_window.pending_index)
      @status_window.pending_index = -1
      @status_window.redraw_item(@status_window.index)
    else
      @status_window.pending_index = @status_window.index
    end
    @status_window.activate
  end
  #--------------------------------------------------------------------------
  # * Formation [Cancel]
  #--------------------------------------------------------------------------
  def on_formation_cancel
    if @status_window.pending_index >= 0
      @status_window.pending_index = -1
      @status_window.activate
    else
      @status_window.unselect
      @command_window.activate
    end
  end
end[/pre]
梦石
1
星屑
22083
在线时间
4885 小时
注册时间
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
星屑
9716
在线时间
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.

在本版发帖返回顶部