Auto-Sizing Text Windows
#7
Okay... this is the rewrite of the initialize method I mentioned:
Code:
def initialize(x,y,lines)
    @lines = []
    @lines = lines
    @line_width = []
    if @lines.size == 0
      print("Error: Auto-sizing windows must have at least one line")
      exit
    end
    @tester = Window_Base.new(0, 0, 640, 480)
    @tester.contents = Bitmap.new(@tester.width - 32, @tester.height - 32)
    @tester.contents.font.name = "Arial"
    @tester.contents.font.size = 18
    max = 0
    for i in 0..@lines.size - 1
      t = @lines[i]
      @line_width[i] = @tester.contents.text_size(t).width
      if @line_width[i] > max
        max = @line_width[i]
      end
    end
    w = max + 40
    h = @lines.size + 1
    h *= 32
    @tester.dispose
    super(x, y, w, h)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Arial"
    self.contents.font.size = 18
    refresh
  end

And this is a map event 'Script Call' I wrote.
Code:
Window_Autosize.new(20,20,
["Here","There"])

Rather than the window showing up at 0,0, it shows up at 20,20 (in pixels). The window resizes to fit the text... two small one-word lines.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }


Messages In This Thread
Auto-Sizing Text Windows - by RPG Advocate - 03-02-2008, 08:27 AM
RE: Auto-Sizing Text Windows - by xnadvance - 06-02-2011, 01:40 AM
RE: Auto-Sizing Text Windows - by Charlie Fleed - 06-02-2011, 06:37 AM
RE: Auto-Sizing Text Windows - by sagam12 - 06-09-2011, 09:11 PM
RE: Auto-Sizing Text Windows - by NightOwl - 06-09-2011, 11:21 PM
RE: Auto-Sizing Text Windows - by sagam12 - 06-10-2011, 01:09 AM
RE: Auto-Sizing Text Windows - by DerVVulfman - 06-10-2011, 05:01 AM
RE: Auto-Sizing Text Windows - by sagam12 - 06-10-2011, 02:03 PM
RE: Auto-Sizing Text Windows - by DerVVulfman - 06-11-2011, 04:00 AM
RE: Auto-Sizing Text Windows - by sagam12 - 06-11-2011, 06:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Text Scroll Script - Enhanced DerVVulfman 23 34,306 02-18-2021, 04:16 AM
Last Post: DerVVulfman
   Message Text from Files DerVVulfman 0 5,286 04-13-2016, 03:25 AM
Last Post: DerVVulfman
   Text Extraction Generator DerVVulfman 5 12,954 10-13-2014, 09:32 PM
Last Post: Narzew
   Text to RGSS DerVVulfman 10 25,615 05-04-2013, 04:34 AM
Last Post: DerVVulfman
   Auto Equip Optimizer for Guillaume777's MultiSlots DerVVulfman 1 6,972 06-20-2012, 03:26 PM
Last Post: buddysievers
   Damage Text Revamp 2.1 PK8 3 12,832 04-08-2012, 06:47 PM
Last Post: PK8
   Auto Populate Maps, Version 0.5 Charlie Fleed 14 27,052 03-17-2012, 03:04 PM
Last Post: LilyKnight
   Popup Windows deValdr 5 10,774 06-02-2011, 09:38 AM
Last Post: deValdr
   Another Scrolling Text Script kyonides 1 6,477 04-12-2010, 01:36 AM
Last Post: Shiroiyuki
   [Unsupported] Auto Tone PK8 0 5,333 12-07-2008, 03:06 PM
Last Post: PK8



Users browsing this thread: 1 Guest(s)