RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Warning message(scripters tool)

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 68
RMRK Junior
I created this script long ago for one of my menus and any other project. Its very flexible and can be used for a lot of things. It uses a modified window+sprite combination because i think that it looks better, anyway you can modify it or do what you want.

Features:

-The window size and position is based on the text size.
-All other sizes or positions are set automatically.
-It have methods for automatically visible/invisible, dipose,etc, all sprites
and windows.
-You can add a question to it. With this a modified version of a window command
is actived.
-You can changue the text, ask option, x and y in every call.

I use it with a variable in the Scene called "Warning_message_type" that defines the behavior of it.

Note that you need scripting knoledge for using this. Basically im sharing the code for anyone that may need it and don't want to make his own.

If you add something realy cool to it, tell me, the idea is to improve it. Anyway, suggerences,bugs,etc, i will listen for any feedback.

Code: text [Select]
#==============================================================================
# Warning message
# By gerkrt/gerrtunk
# Version: 1
# License: GPL, credits
#==============================================================================
=begin
 
Features:
 
I created this script long ago for one of my menus and any other project. Its very flexible
and can be used for a lot of things. It uses a modified window+sprite combination
because i think that it looks better, anyway you can modify it or do what you want.
 
-The window size and position is based on the text size.
-All other sizes or positions are set automatically.
-It have methods for automatically visible/invisible, dipose,etc, all sprites
and windows.
-You can add a question to it. With this a modified version of a window command
is actived.
-You can changue the text, ask option, x and y in every call.
 
I use it with a variable in the Scene called "Warning_message_type" that defines
the behavior of it.
 
=end
 
class Warning_Message
  def initialize
    # Default values when refreshing it
    @default_x = 200
    @default_y = 200
    # Back text window
    @text_window = Window_Base.new(120, 136, 400, 64)
    @text_window.z = 252
    @text_window.visible = false
    # Text sprite
    @text_sprite = Sprite.new
    @text_sprite.z = 254
    @text_sprite.x = 120
    @text_sprite.y = 136
    @text_sprite.bitmap = Bitmap.new(400,64)
    # Testing bitmap for size test
    @testing_bitmap =  Bitmap.new(1,1)
    # Question window
    @question_window = Window_Selection.new(80, ["Yes", "No"])
    @question_window.x = 280
    @question_window.y = 200
    @question_window.z = 253
    @question_window.back_opacity = 0
    @question_window.opacity = 0
    @question_window.active = false
    @question_window.visible = false
    # Back question window
    @back_question_window = Window_Base.new(120, 136, 64, 64)
    @back_question_window.x = 280
    @back_question_window.y = 200
    @back_question_window.z = 254
    @back_question_window.visible = false
 
  end
 
  # Make all the sprites/windows visibles
  def visible
    @text_window.visible = true
    @text_sprite.visible = true
    # Question ones only if active
    if @back_question_window.active
      @question_window.visible = true
      @back_question_window.visible = true
    end
  end
 
  # Make all the sprites/windows invisibles
  def no_visible
    @text_window.visible = false
    @text_sprite.visible = false
    @question_window.visible = false
    @back_question_window.visible = false
  end
 
  # Is question window active?
  def active
    return @question_window.active
  end
 
  # Set question window active
  def active=(value)
    @question_window.active = value
  end
 
  # Update all the sprites/windows visibles
  def update
    @text_window.update
    @text_sprite.update
    @back_question_window.update
    @question_window.update
  end
 
  # Draw the warning message
  # question: called to add a yes/no window.
  def refresh(message, question=true, x=@default_x, y=@default_y)
    # Basic position settings
    @text_window.y = y
    @text_window.x = x
    @text_sprite.x = x
    @text_sprite.y = y
    rect = @testing_bitmap.text_size(message)
    # With question window or not. All the positions auto-setting are done here.
    if question
      @text_window.width = rect.width+26+40
      @question_window.visible = true
      @question_window.active = true
      @back_question_window.visible = true
      @question_window.x = @text_window.x+rect.width+4+6
      @question_window.y = @text_window.y - 16
      @back_question_window.x = @text_window.x+rect.width+4+16
      @back_question_window.y = @text_window.y
    else
      @text_window.width = rect.width+26
    end
    # First update the back window
    @text_window.update
    @text_sprite.bitmap.clear
    # Draw text
    @text_sprite.bitmap.draw_text(0+10,0,400,64,message, 0)
    @text_sprite.update
  end
 
  # Dispose all the sprites/windows visibles
  def dispose
    @text_window.dispose
    @text_sprite.dispose
    @question_window.dispose
    @back_question_window.dispose
  end
end
 
 
class Window_Selection < Window_Command
   #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get current row
    row = @index / @column_max
    # If current row is before top row
    if row < self.top_row
      # Scroll so that current row becomes top row
      self.top_row = row
    end
    # If current row is more to back than back row
    if row > self.top_row + (self.page_row_max - 1)
      # Scroll so that current row becomes back row
      self.top_row = row - (self.page_row_max - 1)
    end
    # Calculate cursor width
    cursor_width = (self.width / @column_max - 32)+11
    # Calculate cursor coordinates
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    # Update cursor rectangle
    self.cursor_rect.set(x-4, y, cursor_width, 32)
  end
 
end