[XP] Multiple Message Windows Ex

Started by LiTTleDRAgo, February 12, 2012, 12:16:11 am

Previous topic - Next topic

LiTTleDRAgo

*fixed*
probably I didn't fix it in elegant way since I didn't have much free time right now

Heretic86

Just out of curiousity, what did you do?

When I get some free time, I might come back to this script again...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

LiTTleDRAgo

Spoiler: ShowHide
Quote#--------------------------------------------------------------------------
  # * Terminate Message
  #--------------------------------------------------------------------------
  def terminate_message
    return if $game_temp.input_in_window
    self.active = false
    self.pause = false
    self.index = -1
    self.contents.clear
    @fwindowskin.bitmap.clear if !@fwindowskin.nil? && !@fwindowskin.disposed?
    # Clear showing flag
    @contents_showing = false
    # Clear variables related to text, choices, and number input
    @tail.visible = false
    # note that these variables are now indexed arrays
    $game_temp.message_text = [] if !$game_temp.message_text.is_a?(Array)
    $game_temp.message_proc = [] if !$game_temp.message_proc.is_a?(Array)
    $game_temp.message_text[@msgindex] = nil
    # Call message callback
    if $game_temp.message_proc[@msgindex] != nil
      # make sure no message boxes are displaying
      if $game_temp.message_text.compact.empty?
        $game_temp.message_proc[@msgindex].call
        message_interpreter.class.send(:attr_accessor,:message_waiting)
        $game_temp.message_window_showing = false
        message_interpreter.message_waiting = false
      end
      $game_temp.message_proc[@msgindex] = nil
    end
    @update_text = true
    $game_temp.choice_start = 99
    $game_temp.choice_max = 0
    $game_temp.choice_cancel_type = 0
    $game_temp.choice_proc = nil
    $game_temp.num_input_start = 99
    $game_temp.num_input_variable_id = 0
    $game_temp.num_input_digits_max = 0
    # Open gold window
    if @gold_window != nil
      @gold_window.dispose
      @gold_window = nil
    end
  end


Quote
  #--------------------------------------------------------------------------
  # * Message_Eval
  #--------------------------------------------------------------------------
  def message_eval(v)
    message_interpreter.message_eval(v)
  end
  #--------------------------------------------------------------------------
  # * Message_Interpreter
  #--------------------------------------------------------------------------
  def message_interpreter
    if $scene.is_a?(Scene_Map)
      $game_system.map_interpreter
    elsif $scene.is_a?(Scene_Battle)
      $game_system.battle_interpreter
    else
      Interpreter.new
    end
  end


Quote#--------------------------------------------------------------------------
  # * Reposition Window
  #--------------------------------------------------------------------------
  def reposition
    if @float_id.is_a?(Array)
      char_height = 1
      char_width = 1
      char_x = @float_id[0]
      char_y = @float_id[1]
    elsif $game_temp.in_battle
      if 'abcd'.include?(@float_id) # must be between a and d
        @float_id = @float_id[0] - 97 # a = 0, b = 1, c = 2, d = 3
        return if $scene.spriteset.actor_sprites[@float_id] == nil
        sprite = $scene.spriteset.actor_sprites[@float_id]
      else
        @float_id -= 1 # account for, e.g., player entering 1 for index 0
        return if $scene.spriteset.enemy_sprites[@float_id] == nil
        sprite = $scene.spriteset.enemy_sprites[@float_id]
      end
      char_height = sprite.height
      char_width = sprite.width
      char_x = sprite.x
      char_y = sprite.y - char_height/2
    else # not in battle...
      char = (@float_id == 0 ? $game_player : $game_map.events[@float_id])
      if char == nil
        # no such character
        @float_id = nil
        return
      end
      # close message (and stop event processing) if speaker is off-screen
      if speaker_offscreen(char) || 
        ($game_system.message.allow_offscreen && !$game_temp.in_battle &&
        (self.height - self.y > 480 || self.height + self.y < 0 ||
          self.width - self.x > 640 || self.width + self.x < 0)) ||
         ($game_system.message.move_during &&  @dist_exit &&
           @float_id > 0 && !char.within_range?(@dist_max, @float_id) &&
           @float_id == @event_id )
        terminate_message
        if !@fwindowskin.nil? && !@fwindowskin.disposed?
          @fwindowskin.visible = false
          @fwindowskin.bitmap.dispose if !@fwindowskin.bitmap.disposed?
          @fwindowskin.dispose
          @fwindowskin = nil
        end
        char.foot_forward_off  if @auto_ff_reset && !char.no_ff
        @auto_ff_reset = false
        return
      end
      if char.character_name =~ /[8]/i
        char_height = RPG::Cache.character(char.character_name,0).height / 8
      else
        char_height = RPG::Cache.character(char.character_name,0).height / 4
      end
      if char.character_name =~ /[s]/i
        char_width = RPG::Cache.character(char.character_name,0).width / 8
      else
        char_width = RPG::Cache.character(char.character_name,0).width / 4
      end
      # record coords of character's center
      char_x = record_screen_xy(char)[0]
      char_y = record_screen_xy(char)[1] - char_height/2
    end
    params = [char_height, char_width, char_x, char_y]
    # position window and message tail
    vars = new_position(params)
    x,y = vars[0], vars[1]
    # check if any window locations need to be "flipped"
    offsc = (!$game_system.message.allow_offscreen || $game_temp.in_battle)
    flip = need_flip?(@float_id, @location, x, y, params)
    loc4 = ((x < 0 && !@face) || (x < 90 && @face)) && offsc
    if @location == 4 && (loc4 || flip)
      if @auto_orient == 1 and need_flip?(@float_id, @location, x, y)
        @location = put_behind(@float_id, 6)
      else  # switch to right
        @location = 6
      end
      vars = new_position(params)
      x = vars[0]
      if (x + self.width) > 640 && offsc
        # right is no good either...
        if y >= 0
          # switch to top
          @location = 8
          vars = new_position(params)
        else
          # switch to bottom
          @location = 2
          vars = new_position(params)
        end
      end
    elsif @location == 6 && (((x + self.width) > 640 && offsc) || flip)
      if @auto_orient == 1 and need_flip?(@float_id, @location, x, y)
        @location = put_behind(@float_id, 4)
      else     # switch to left
        @location = 4
      end
      vars = new_position(params)
      x = vars[0]
      if x < 0 && offsc
        # left is no good either...
        if y >= 0
          # switch to top
          @location = 8
          vars = new_position(params)
        else
          # switch to bottom
          @location = 2
          vars = new_position(params)
        end
      end
    elsif @location == 8 && ((y < 0 && offsc) || flip)
      if @auto_orient == 1 and need_flip?(@float_id, @location, x, y)
        @location = put_behind(@float_id, 2)
      else     # switch to bottom
        @location = 2
      end
      vars = new_position(params)
      y = vars[1]
      if (y + self.height) > 480 && offsc
        # bottom is no good either...
        # note: this will probably never occur given only 3 lines of text
        x = vars[0]
        if x >= 0
          # switch to left
          @location = 4
          vars = new_position(params)
        else
          # switch to right
          @location = 6
          vars = new_position(params)
        end
      end
    elsif @location == 2 && (((y + self.height) > 480 && offsc) || flip)
      if @auto_orient == 1 and need_flip?(@float_id, @location, x, y)
        @location = put_behind(@float_id, 8)
      else   # switch to top
        @location = 8
      end
      vars = new_position(params)
      y = vars[1]
      if y < 0 && offsc
        # top is no good either...
        # note: this will probably never occur given only 3 lines of text
        x = vars[0]
        if x >= 0
          # switch to left
          @location = 4
          vars = new_position(params)
        else
          # switch to right
          @location = 6
          vars = new_position(params)
        end
      end
    end
    x = vars[0]
    y = vars[1]
    tail_x = vars[2]
    tail_y = vars[3]   
    # adjust windows if near edge of screen
    if offsc
      if x < 0 && !@face
        x = 0
      elsif x < 90 && @face
        x = 90
      elsif (x + self.width) > 640
        x = 640 - self.width
      end
      if y < 0
        y = [y, 0].max
      elsif (y + self.height) > 480
        y = 480 - self.height
      elsif $game_temp.in_battle && @location == 2 && (y > (320 - self.height))
        # when in battle, prevent enemy messages from overlapping battle status
        # (note that it could still happen from actor messages, though)
        y = 320 - self.height
        tail_y = y
      end
    end
    # finalize positions
    self.x = x
    self.y = y
    @tail.x = tail_x
    @tail.y = tail_y
    v = case @location
    when 2, 6 then -15
    when 4, 8 then -17
    end
    if self.visible #!$game_temp.message_text.compact.empty?
      draw_window
      @fwindowskin.dispose if !@fwindowskin.nil? && !@fwindowskin.disposed?
      @fwindowskin = Sprite.new
      @fwindowskin.z = self.z - 10
      @fwindowskin.bitmap = Bitmap.new(640,480)
      @fwindowskin.bitmap.blt(x,y,@frame.bitmap,@frame.bitmap.rect)
      @fwindowskin.bitmap.blt(tail_x+v,tail_y+v,@tail.bitmap,
                 @tail.bitmap.rect) if show_message_tail?
      @fwindowskin.opacity = $game_system.message.opacity
      if @face && self.height > 64
        a = 80
        while a >= -10
          @fwindowskin.bitmap.blt(@face.x+a,y,@frame.bitmap,
            Rect.new(0,0,@face.bitmap.width-45,@frame.bitmap.height))
          a = (a == 5) ? 15 : a - 25
        end
      end
      self.opacity = @tail.opacity = 0
      @frame.dispose
    end
    bit = @tail.bitmap
  end


Quote
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias drg128_setup setup unless method_defined?(:drg128_setup)
  alias drg128_upd update unless method_defined?(:drg128_upd)
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(*args)
    drg128_setup(*args)
    # index of window for the message
    @msgindex = 0
    $game_temp.message_text, $game_temp.message_proc = [],[]
    # whether multiple messages are displaying
    @multi_message = false
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update(*args)
    @message_waiting = $game_temp.message_window_showing
    drg128_upd(*args)
  end
  ...
end

Heretic86

December 17, 2012, 08:39:15 pm #43 Last Edit: December 19, 2012, 02:12:21 am by Heretic86
Im bad.  I never update.  I R teh Lay-zee.

Then I updated RMXP to 1.04 last night.  I just sat on 1.02 for years before even starting to use it.  Now it seems as if I have created a new issue for myself in regards to MMW features I added.  When I am using the "Foot Forward" options, XP1.04 now shows Box Characters any place that \F+ and \F- exist in the text.  I am sure this will affect other people.  But a quick edit of the ini and reverting to RGSS102E.dll over 104 makes those boxes go away, but the version is also old.  

Any fast solutions to resolve this minor bug?

Edit:  NVM, got it.  Add c = '' for each foot forward call in def update_text
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ThallionDarkshine

Alright, I ported the animation feature from my Window Message Mod script to MMW, and here is the script. I also fixed a few inefficient pieces of code that was using for loops instead of each loops.

http://pastebin.com/raw.php?i=cuGgw297

LiTTleDRAgo

*update the script and demo*

- fixed "foot forward" glitch
- fixed "exit by player distance" glitch
- added ThallionDarkshine's Animated Letters
- added an option for switching windowskins

MarkHest

December 25, 2013, 01:39:30 am #46 Last Edit: December 25, 2013, 01:40:58 am by MarkHest
I can't live without this script. It's too awesome.

I have found a little weird glitch though. Whenever I finish talking to a character their event replays over and over unless I either hold the move button to instantly move away after the event after they finish talking, or add a wait command after the event. 1 frame is enough to stop the loop. Any fast fixes to this?




Damn, i'm posting a lot today!
   

KinTery

Just tried testing but not sure if i'll put this in my game, and seems like im having the same problem with MarkHest.
I can't move because the message is repeating until i hold a move button.
Is it a bug??

LiTTleDRAgo

For now, I don't have enough free time to fix the script, sorry
You can use wait 1 frame in the end of event to avoid this problem

MarkHest

Another thing I want to mention is that the @sound_frequency option doesn't work no matter what you put it to. The sound is always the same speed.
   

dullman

I have a question is method and properties named cinemamask, create_cinema, update_cinema important or i can comment it without worrying that it will destroy some function of MMW Ex. My problem was that it create a black bar on non standard resolution

LiTTleDRAgo

you can just change all 640 & 480 into your resolution


      @cinemasks = [ create_cinema(640,48,0,-48), create_cinema(640,72,0,480),
                     create_cinema(640,480,0,0,199,0)]



        @cinemasks[1].y = 480 -  9 * (24 - @cinema_fadecount) / 3[/codde]

MarkHest

Found a new bug with the script. Parallel Events refuses to run while a text box is active. This is a problem for me :p

Things that I want to request fixes on:
- The 'wait 1 frame' problem I mentioned before.
- The 'sound frequency' problem I mentioned before.
- The 'Parallel Event' problem explained here.

Think you can do it when you have time?
   

Heretic86

If its a bug in this version of the script, there are "workarounds".  Before your message displays where a parallel event is expected to run, try running a couple Script calls:

$game_map.event[41].refresh
$game_map.events[41].start

Calling "start" can force an event to start executing, even if the event is set to "Action Button".

Still worth while to find out why a Parallel wont run for you.  Is the parallel event on the screen viewable by the player?  Not just on the same map, but visible to the player (if it had a graphic)?  Bug may also be coming from some form of Framerate Optimizer...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

MarkHest

The Parallel process just won't run at all while a text box is active. I tried it on both my project with lots of other scripts and a new project with only this script in it. Same problem.
It's like the text boxes pauses the game completely from running anything else.

e.g:
-Let's say I talk to a guy and activate a switch for a parallel process next to him.
-This parallel process should now start to jump infinitely because of the event command telling him to jump.
-A text box is active from talking to the first event and the event next to him won't jump at all.
-the text box ends and the parallel event starts jumping but stops once another text box is active. Then starts again once the text box ends.

I even tried common events.
   

LiTTleDRAgo

August 10, 2014, 06:59:58 pm #55 Last Edit: August 21, 2016, 11:48:10 am by LiTTleDRAgo
when I testing this script, I'm surprised there are glitch that hard to fix.
maybe I'll overhaul this script when I have time.
but I'm sorry, for now, I lack the time & motivation to do that.

---
update to 1.6b

* fixed the repeating bug

LiTTleDRAgo

updated the script and demo again to 1.6c 

* fix the bug when animated letters didn't displayed properly into message log

koktengri

Thanks for keep updating the script.
Will there be a fix in the future for the letter by letter mode not working with the auto shrink feature?

Thanks in advance.

LiTTleDRAgo

maybe not.... as I said earlier, I lack time.
unless there are fatal bug, I probably wont update it.

sorry about that.