Controlling Galv's Layer Graphics script with Yanfly System Options?

Hey all! So I'm trying to make Yanfly Ace System Options control Galv's Layer Graphics. Galv's script has a script call that can turn layers on and off. Essentially, I want to give the players the ability to turn layers on and off in the options menu.



How could I make it so that turning a switch on or off in the system options toggles Galv's layers on or off? I tried setting up a common event with a parallel process that called the script calls `layer_status(false)` or `layer_status(true)` depending on a switch. Of course, that wasn't going cause it's a parallel process, it just glitched out the layers.

1714218190257.png


Are there any ways to accomplish this? So I do know one way to go about this - using the Hime's scene interperter script. The graphics layers option would show a choice window and the player could pick an option. Right now, I like keeping with the format of On and Off though. Any alternatives would be appreciated. Thank you!
As this is using script calls to change the layers it would probably be best to use a common event to process the commands.
I will provide the adjusted script and break down the changes I did to make it work.

Added the option to the menu, you can change the command name if you like
Ruby:
    COMMANDS =[
      :window_red,   # Changes the red tone for all windows.
      :window_grn,   # Changes the green tone for all windows.
      :window_blu,   # Changes the blue tone for all windows.
      :volume_bgm,   # Changes the BGM volume used.
      :volume_bgs,   # Changes the BGS volume used.
      :volume_sfx,   # Changes the SFX volume used.
      :blank,
      :autodash,     # Sets the player to automatically dash.
      :instantmsg,   # Sets message text to appear instantly.
      :animations,   # Enables battle animations or disables them.
    # :switch_1,     # Custom Switch 1. Adjust settings below.
    # :switch_2,     # Custom Switch 2. Adjust settings below.
    # :variable_1,   # Custom Variable 1. Adjust settings below.
    # :variable_2,   # Custom Variable 2. Adjust settings below.
      :ce_1,
      :blank,
      :to_title,     # Returns to the title screen.
      :shutdown,     # Shuts down the game.
    ] # Do not remove this.

Added the custom CE by Switch section below CUSTOM_SWITCHES
Ruby:
    # -------------------------------------------------------------------------
    } # Do not remove this.
    
    #--------------------------------------------------------------------------
    # - Custom Common Event Switches -
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # If you want your game to have system options other than just the ones
    # listed above, you can insert custom switches here to produce such an
    # effect. Adjust the settings here as you see fit.
    #--------------------------------------------------------------------------
    CUSTOM_CE_SWITCHES ={
    # -------------------------------------------------------------------------
    # :switch    => [Switch, Name, Off Text, On Text,
    #                Help Window Description,
    #                Switch off CE called, Switch on CE called
    #               ], # Do not remove this.
    # -------------------------------------------------------------------------
      :ce_1  => [ 1, "Custom CE 1", "OFF", "ON",
                     "Help description used for custom switch 1.",
                     1, 2 # CE called (off / on)
                    ],
    # -------------------------------------------------------------------------
      :ce_2  => [ 2, "Custom CE 2", "OFF", "ON",
                     "Help description used for custom switch 2.",
                     3, 4 # CE called  (off / on)
                    ],
    # -------------------------------------------------------------------------
    } # Do not remove this.

Added a line in make_command_list
Ruby:
      else
        process_custom_switch(command)
        process_custom_ce_switch(command)
        process_custom_variable(command)
      end
    end
  end

Added custom method below process_custom_switch
Ruby:
  #--------------------------------------------------------------------------
  # process_custom_switch
  #--------------------------------------------------------------------------
  def process_custom_ce_switch(command)
    return unless YEA::SYSTEM::CUSTOM_CE_SWITCHES.include?(command)
    name = YEA::SYSTEM::CUSTOM_CE_SWITCHES[command][1]
    add_command(name, :custom_ce, true, command)
    @help_descriptions[command] = YEA::SYSTEM::CUSTOM_CE_SWITCHES[command][4]
  end

Added option in draw_item(index)
Ruby:
  #--------------------------------------------------------------------------
  # draw_item
  #--------------------------------------------------------------------------
  def draw_item(index)
    reset_font_settings
    rect = item_rect(index)
    contents.clear_rect(rect)
    case @list[index][:symbol]
    when :window_red, :window_grn, :window_blu
      draw_window_tone(rect, index, @list[index][:symbol])
    when :volume_bgm, :volume_bgs, :volume_sfx
      draw_volume(rect, index, @list[index][:symbol])
    when :autodash, :instantmsg, :animations
      draw_toggle(rect, index, @list[index][:symbol])
    when :to_title, :shutdown
      draw_text(item_rect_for_text(index), command_name(index), 1)
    when :custom_switch
      draw_custom_switch(rect, index, @list[index][:ext])
    when :custom_ce
      draw_custom_ce_switch(rect, index, @list[index][:ext])
    when :custom_variable
      draw_custom_variable(rect, index, @list[index][:ext])
    end
  end

Added custom method below draw_custom_switch(rect, index, ext)
Ruby:
  #--------------------------------------------------------------------------
  # cursor_right
  #--------------------------------------------------------------------------
  def draw_custom_ce_switch(rect, index, ext)
    name = @list[index][:name]
    draw_text(0, rect.y, contents.width/2, line_height, name, 1)
    #---
    dx = contents.width / 2
    enabled = $game_switches[YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][0]]
    dx = contents.width/2
    change_color(normal_color, !enabled)
    option1 = YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][2]
    draw_text(dx, rect.y, contents.width/4, line_height, option1, 1)
    dx += contents.width/4
    change_color(normal_color, enabled)
    option2 = YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][3]
    draw_text(dx, rect.y, contents.width/4, line_height, option2, 1)
  end

Added process in cursor_change(direction)
Ruby:
  #--------------------------------------------------------------------------
  # cursor_change
  #--------------------------------------------------------------------------
  def cursor_change(direction)
    case current_symbol
    when :window_red, :window_blu, :window_grn
      change_window_tone(direction)
    when :volume_bgm, :volume_bgs, :volume_sfx
      change_volume(direction)
    when :autodash, :instantmsg, :animations
      change_toggle(direction)
    when :custom_switch
      change_custom_switch(direction)
    when :custom_ce
      change_custom_ce_switch(direction)
    when :custom_variable
      change_custom_variables(direction)
    end
  end

Added custom method below change_custom_switch(direction)
Ruby:
  #--------------------------------------------------------------------------
  # change_custom_switch
  #--------------------------------------------------------------------------
  def change_custom_ce_switch(direction)
    value = direction == :left ? false : true
    ext = current_ext
    current_case = $game_switches[YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][0]]
    $game_switches[YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][0]] = value
    # start ce
    if value != current_case
      value == true ?
      $game_temp.reserve_common_event(YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][6]) :
      $game_temp.reserve_common_event(YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][5])
    end
    # end of ce
    Sound.play_cursor if value != current_case
    draw_item(index)
  end

Then setup your common events
Wow!! Thank you very much for writing that out! That was a bit more complicated than I expected. I'll incorporate this into the system options script you upgraded with full screen a while back :hhappy:

Original thread: https://forums.rpgmakerweb.com/threads/controlling-galvs-layer-graphics-script-with-yanfly-system-options.168113/