Port from Ace: Lemony's Default Map Tone

Status
Not open for further replies.

Oriceles

Veteran
Veteran
Joined
Apr 4, 2012
Messages
384
Reaction score
71
First Language
English
Primarily Uses
N/A
Hello forum!, this time I'm requesting yet another good old script from the Ace era that I think would be super useful on MV. This script was originally distributed by the Resource Staff back in 2013, I hoping there is someone kind enough to make a MV Plugin version of this.
I noticed that there is not a built in way of setting default screen tones for each map, and making auto start events to set the tone for the map makes weird effects. The fact that you can not change the screen tone while playtesting makes even more difficult the selection of the right tone for your maps.

This tool allows the developer to modify the map screen tone while playtesting and to set a default tone for the map. The tone is saved to a file in the Data folder in the game directory, and the tone is loaded from it each time the map loads. It works in fullscreen mode too.
— Lemony
The original script and terms are inside the spoiler.

Code:
#==============================================================================
# ** Lemony's Default Map Tone, (LDMT), (ReStaff Febraury 2013), v.1.0
#==============================================================================
#  I noticed that there is not a built in way of setting default screen tones
# for each map, and making auto start events to set the tone for the map makes
# weird effects. The fact that you can not change the screen tone while
# playtesting makes even more difficult the selection of the right tone for your
# maps.
#  This tool allows the developer to modify the map screen tone while
# playtesting and to set a default tone for the map. The tone is saved to a file
# in the Data folder in the game directory, and the tone is loaded from it each
# time the map loads. It works in fullscreen mode too.
#==============================================================================
# (*) How to use.-
#==============================================================================
# * To enter or exit the map tone menu, press F5. (Only for Scene_Map)
#
# * When you are ready to distribute your game, set the variable Enabled,
# found in LDMT module, to false.
#
# * For compatibility purposes, the keys used to toggle the tone menu, create
# the tone file and to reset the tone, can be modified in LDMT module.
#
# * RMVXAce default tone handling mode makes the map tone persist until changed
# by event commands. That makes the tone that has been set in one map, persist
# to the other maps until a new tone is set. If you, for some reason, want to
# avoid that, set to true the variable Reset_T found in LDMT module.
#==============================================================================
# (***) Terms of use.-
#==============================================================================
# This script is free to use in any commercial or non commercial game or
# project created with any RPG Maker with a valid license as long as explicit
# credits are given to the author (Lemony).
#==============================================================================
module LDMT
  #--------------------------------------------------------------------------
  # * Set to false to disable the map tone menu.
  #--------------------------------------------------------------------------
  Enabled    = true
  #--------------------------------------------------------------------------
  # * Set to true for reseting the map tone when set up. (if no map tone file)
  #--------------------------------------------------------------------------
  Reset_T    = false
  #--------------------------------------------------------------------------
  # * Key for entering & exiting the map tone menu.
  #--------------------------------------------------------------------------
  Toggle_Key = :F5
  #--------------------------------------------------------------------------
  # * Key for creating the map tone file.
  #--------------------------------------------------------------------------
  Create_Key = :F6
  #--------------------------------------------------------------------------
  # * Key for reseting the map tone.
  #--------------------------------------------------------------------------
  Reset_Key  = :CTRL
end
if LDMT::Enabled
 
class LDMT_Set
  #--------------------------------------------------------------------------
  # * Public Instance for disposed.
  #--------------------------------------------------------------------------
  attr_reader :disposed
  #--------------------------------------------------------------------------
  # * LDMT Initialize.
  #--------------------------------------------------------------------------
  def initialize
    @otn = $game_map.screen.tone
    @disposed = false
    @sprite = Sprite.new
    @sprite.z = 99999999
    @sprite.x, @sprite.y = (Graphics.width / 2) - 130, (Graphics.height / 3)
    @sprite.bitmap = Bitmap.new(260, 180)
    font = Font.new('Verdana', 16)
    font.color = Color.new(208, 202, 136)
    font.outline = false
    font.bold = true
    @sprite.bitmap.font = font
    @sprite.bitmap.fill_rect(0, 0, 260, 180, Color.new(58, 58, 58))
    @sprite.bitmap.fill_rect(2, 2, 256, 176, Color.new(208, 202, 136))
    @sprite.bitmap.fill_rect(4, 4, 252, 172, Color.new(58, 58, 58))
    ['Red.', 'Green.', 'Blue.', 'Gray.'].each_with_index {|text, index|
    @sprite.bitmap.draw_text(8 + (61 * index), 36, 61, 16, text, 1)}
    @sprite.bitmap.font.size = 18
    @sprite.bitmap.draw_text(8, 8, 244, 18, "Lemony's Default Map Tone", 1)
    @sprite.bitmap.font.size = 14
    @sprite.bitmap.font.color = Color.new(200, 200, 200)
    resets = "#{LDMT::Reset_Key.to_s} to reset tone values."
    helps0 = "#{LDMT::Create_Key.to_s} to make default map tone."
    helps1 = 'LEFT & RIGHT to select propertie.'
    helps2 = 'UP & DOWN to change values.'
    helps3 = 'Hold SHIFT to speed up.'
    @sprite.bitmap.draw_text(8, 102, 250, 14, resets, 1)
    @sprite.bitmap.draw_text(8, 116, 250, 14, helps0, 1)
    @sprite.bitmap.draw_text(8, 130, 250, 14, helps1, 1)
    @sprite.bitmap.draw_text(8, 144, 250, 14, helps2, 1)
    @sprite.bitmap.draw_text(8, 158, 250, 14, helps3, 1)
    @cursor = Sprite.new
    @cursor.z = @sprite.z + 1
    @cursor.x, @cursor.y = @sprite.x + 8, @sprite.y + 52
    @cursor.bitmap = Bitmap.new(61, 39)
    @cursor.bitmap.fill_rect(0, 0, 61, 39, Color.new(208, 202, 136))
    @cursor.bitmap.clear_rect(2, 2, 57, 35)
    @mindex, t, @font = 0, $game_map.screen.tone, font
    @tindex = [t.red.to_i, t.green.to_i, t.blue.to_i, t.gray.to_i]
    @tindex.each_with_index {|t, i|
    @sprite.bitmap.draw_text(8 + (61 * i), 52, 61, 39, t.to_s, 1)}
  end
  #--------------------------------------------------------------------------
  # * LDMT Dispose.
  #--------------------------------------------------------------------------
  def dispose
    @sprite.bitmap.dispose
    @sprite.dispose
    @cursor.bitmap.dispose
    @sprite.dispose
    @tindex.clear
    @mindex = @tindex = nil
    @disposed = true
  end
  #--------------------------------------------------------------------------
  # * LDMT Draw Tone Value.
  #--------------------------------------------------------------------------
  def draw_tone_value(batch = false)
    x, y = @cursor.x - @sprite.x, @cursor.y - @sprite.y
    if batch
      @tindex.each_with_index {|t, i|
      @sprite.bitmap.fill_rect(8 + (61 * i), 52, 61, 39, Color.new(58, 58, 58))
      @sprite.bitmap.draw_text(8 + (61 * i), 52, 61, 39, t.to_s, 1)}
    else
      @sprite.bitmap.fill_rect(x, y, 61, 39, Color.new(58, 58, 58))
      @sprite.bitmap.draw_text(x, y, 61, 39, @tindex[@mindex], 1)
    end
    $game_map.screen.start_tone_change(Tone.new(*@tindex), 0)
  end
  #--------------------------------------------------------------------------
  # * LDMT Update.
  #--------------------------------------------------------------------------
  def update
    @sprite.update
    @cursor.x, @cursor.y = @sprite.x + 8 + (@mindex * 61), @sprite.y + 52
    @mindex = [@mindex - 1, 0].max if Input.trigger?(:LEFT)
    @mindex = [@mindex + 1, 3].min if Input.trigger?(:RIGHT)
    speed_up_down = Input.press?(:SHIFT) && Input.press?(:DOWN)
    speed_up_up   = Input.press?(:SHIFT) && Input.press?(:UP)
    if Input.trigger?(LDMT::Create_Key)
      t = $game_map.screen.tone
      str = "#{t.red.to_i} #{t.green.to_i} #{t.blue.to_i} #{t.gray.to_i}"
      string = Zlib::Deflate.deflate(str)
      filenm = "Data/LDMT_MapTones#{$game_map.map_id}.rvdata2"
      File.open(filenm, File::WRONLY|File::TRUNC|File::CREAT|File::BINARY) {|f|
      Marshal.dump(string, f)}
      spr = Sprite.new
      spr.y = 64
      spr.bitmap = Bitmap.new(Graphics.width, 32)
      spr.bitmap.fill_rect(0, 0, Graphics.width, 32, Color.new(0, 0, 0, 199))
      spr.bitmap.font = @font
      spr.opacity = 0
      txt = "Default Map Tone file created successfully."
      spr.bitmap.draw_text(0, 0, Graphics.width, 32, txt, 1)
      39.times {Graphics.update ; spr.opacity += (255 / 39).to_i}
      39.times {Graphics.update ; spr.opacity -= (255 / 39).to_i}
      spr.bitmap.dispose
      spr.dispose
    end
    if Input.trigger?(LDMT::Reset_Key)
      @tindex = [@otn.red.to_i, @otn.green.to_i, @otn.blue.to_i, @otn.gray.to_i]
      draw_tone_value(true)
    end
    if Input.trigger?(:DOWN) || Input.repeat?(:DOWN) || speed_up_down
      @tindex[@mindex] = [@tindex[@mindex] - 1, (@mindex == 3 ? 0 : -255)].max
      draw_tone_value
    elsif Input.trigger?(:UP) || Input.repeat?(:UP)  || speed_up_up
      @tindex[@mindex] = [@tindex[@mindex] + 1, 255].min
      draw_tone_value
    end
  end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  Alias to Move by Input, which prevents the player movement when editing tone.
#==============================================================================
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Move by Input.                                               [MOD]
  #--------------------------------------------------------------------------
  alias ldmt_mbi move_by_input
  def move_by_input
    return if SceneManager.scene.ldmt_set
    ldmt_mbi
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Aliases update & terminate to handle the tone editor.
#==============================================================================
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Public Instance for LDMT.                                          [NEW]
  #--------------------------------------------------------------------------
  attr_accessor :ldmt_set
  #--------------------------------------------------------------------------
  # * Alias Update.                                                      [MOD]
  #--------------------------------------------------------------------------
  alias ldmt_update update
  def update
    if Input.trigger?(LDMT::Toggle_Key)
      @ldmt_set.dispose        if @ldmt_set
      @ldmt_set = LDMT_Set.new if @ldmt_set.nil?
      @ldmt_set = nil if @ldmt_set.disposed
    end
    @ldmt_set.update if @ldmt_set
    ldmt_update
  end
  #--------------------------------------------------------------------------
  # * Alias Terminate.                                                   [MOD]
  #--------------------------------------------------------------------------
  alias ldmt_terminate terminate
  def terminate
    @ldmt_set.dispose if @ldmt_set
    @ldmt_set = nil   if @ldmt_set
    ldmt_terminate
  end
end

end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  Alias to setup, which allows for automatically using a screen tone.
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Alias Setup.                                                       [MOD]
  #--------------------------------------------------------------------------
  alias ldmt_ini setup
  def setup(*args)
    ldmt_ini(*args)
    tone = load_data("Data/LDMT_MapTones#{@map_id}.rvdata2") rescue nil
    if tone
      data = Zlib::Inflate.inflate(tone).split(' ')
      r, g, b, gr = data[0].to_i, data[1].to_i, data[2].to_i, data[3].to_i
      @screen.start_tone_change(Tone.new(r, g, b, gr), 0)
    end
  end
end
if LDMT::Reset_T
#==============================================================================
# ** Lemony's Reset Map Tone (LRMT)
#------------------------------------------------------------------------------
#  Alias to setup, which allows for reseting the map tone when map changes.
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Alias Setup.                                                       [MOD]
  #--------------------------------------------------------------------------
  alias lrmt_setup setup
  def setup(*args)
    @screen.start_tone_change(Tone.new(0, 0, 0, 0), 0)
    lrmt_setup(*args)
  end
end

end
 

Nich21

Warper
Member
Joined
Mar 8, 2017
Messages
4
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
Maybe with an event, no necessary a plugin for this. Only you have to start event in every map you´re doing :D
 

Oriceles

Veteran
Veteran
Joined
Apr 4, 2012
Messages
384
Reaction score
71
First Language
English
Primarily Uses
N/A
Maybe with an event, no necessary a plugin for this. Only you have to start event in every map you´re doing :D
Wrong :headshake:. You can't play test tint screens without closing the game over and over again, the closest thing would be playing with the hue on Photoshop with a screenshot of the map, but that will limit you to the area of the screenshot. Also making an event that changes the tint upon the map load makes a small transition effect from the default map tone to the desired tint :headshake:, that is something I want to avoid by giving a default tone. :kaoswt:
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Good old CSS3 standards are a lightweight way to do it. https://www.w3schools.com/cssref/css3_pr_filter.asp
PHP:
var hue = "hue-rotate(90deg)";
document.body.style.WebkitFilter = hue;
document.body.style.MozFilter = hue;
document.body.style.MsFilter = hue;
document.body.style.OFilter = hue;
document.body.style.filter = hue;


(is he kidding? LOL... *waits to get challenged*)
 
Last edited:

Oriceles

Veteran
Veteran
Joined
Apr 4, 2012
Messages
384
Reaction score
71
First Language
English
Primarily Uses
N/A
Well I'm not really good at code, and much less on implementing stuff via console... now if you can further enlighten me about how to do it and stuff that would be great.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Anything that can be run in the web console can also be run in event script call.
Screen Shot 2017-04-25 at 11.24.48 PM.png
 

Oriceles

Veteran
Veteran
Joined
Apr 4, 2012
Messages
384
Reaction score
71
First Language
English
Primarily Uses
N/A
I feel stupid because I can't understand it, but I'm trying!. So... I have to call a script call that defines the hue on parallel right?, I don't understand that hue rotate thing, where do i input the RGB and Gray values?
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Only once, so kill the switch soon after if parallel.
 

Oriceles

Veteran
Veteran
Joined
Apr 4, 2012
Messages
384
Reaction score
71
First Language
English
Primarily Uses
N/A
Ok I tried the code you posted, and works by doing the change before map load, but this tints everything!, including the menu.
Also I went to the link on the first post, but I still don't get how I can apply a specific RGB.

 

Oriceles

Veteran
Veteran
Joined
Apr 4, 2012
Messages
384
Reaction score
71
First Language
English
Primarily Uses
N/A
HAHAHAHAHAHA I managed to find a workaround, I'm a total idiot.
◆Tint Screen:(-68,-68,0,68), 1 frame
◆Erase Event

sadly this requires to apply a similar event to every map, and I can't check each tint while play testing as I could with the plugin I'm requesting.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Ok I tried the code you posted, and works by doing the change before map load, but this tints everything!, including the menu.
Also I went to the link on the first post, but I still don't get how I can apply a specific RGB.

Yeah, that's the downside with having the whole game in one element. (I think it looks cool)

You can change that 90° to any number that looks good and there are many more filter options on that link I posted.

For the record, I'm making a plugin that makes the game Windows separate elements from the game canvas, but it's a work in progress.

HAHAHAHAHAHA I managed to find a workaround, I'm a total idiot.
◆Tint Screen:(-68,-68,0,68), 1 frame
◆Erase Event

sadly this requires to apply a similar event to every map, and I can't check each tint while play testing as I could with the plugin I'm requesting.
That's probably the best way. I didn't know about it either. (I knew think I about it, but I didn't think of it.)

For the record, I think your "hue-rotate(90deg)" makes for a cool blacklight effect.
Maybe when I finish my DOM plugin, good old CSS3 will replace those bloatware lighting plugins.
 

Oriceles

Veteran
Veteran
Joined
Apr 4, 2012
Messages
384
Reaction score
71
First Language
English
Primarily Uses
N/A
Totally looking after that plugin then!. Thanks for the help.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Thanks.

I was actually waiting to get attacked about using CSS3 filters, and I still may... which I why I typed LOL...

The joke is that CSS3 filters are notorious no-no's in web design, but it's really only because these today's web pages are like the Tumblr and Facebook and Pinterest, and they are DOM heavy 20-1000 images loaded with asynchronous XmlHttpRequests per single page, and with decorative masonry positioned by javascript and a filter in that environment is laggy as all get out.

But I've discovered a single gameCanvas filters as fast as a single image, so it's totally lightweight.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
[closed]IgnoreMe[/closed]
by OP request
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top