Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 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 30,479 02-18-2021, 04:16 AM
Last Post: DerVVulfman
   Message Text from Files DerVVulfman 0 4,734 04-13-2016, 03:25 AM
Last Post: DerVVulfman
   Customize/Disable Text Outline + Shadow (v1.1) Zerbu 3 7,136 11-01-2015, 03:56 PM
Last Post: DerVVulfman
   Text Sound Effect (SE) v1.1 Zerbu 3 7,392 11-01-2015, 03:53 PM
Last Post: DerVVulfman
   Text Extraction Generator DerVVulfman 5 11,603 10-13-2014, 09:32 PM
Last Post: Narzew
   Text to RGSS DerVVulfman 10 23,625 05-04-2013, 04:34 AM
Last Post: DerVVulfman
   Victor Engine - State Auto Apply Victor Sant 0 3,799 06-25-2012, 12:17 AM
Last Post: Victor Sant
   Auto Equip Optimizer for Guillaume777's MultiSlots DerVVulfman 1 6,385 06-20-2012, 03:26 PM
Last Post: buddysievers
   Damage Text Revamp 2.1 PK8 3 11,775 04-08-2012, 06:47 PM
Last Post: PK8
   Victor Engine - Sprites in Windows Victor Sant 2 6,442 03-24-2012, 12:19 AM
Last Post: MetalRenard



Users browsing this thread: