PDA

View Full Version : newbie & confused... text problem


amaranth
September 6th, 2005, 11:38 PM
Hi there, I was wondering if anyone could help me out with something...

I created a window and populated it with text. The text is longer than the window and I was able to get the window to scroll down, but the text that wasn't drawn initially in the window doesn't show up. When I scroll, it's blank after the first page.

Anyone know what I'm doing wrong?

Here's my code:


class Window_Journal < Window_Selectable

# ------------------------
def initialize
super(0, 32, 640, 416)
@column_max = 1
refresh
self.index = 0
end


#----------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end

self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize

# n represents the y coordinate where the entry will be displayed
@n = 0
@item_max = 0

# enter the switch begin and end number for the journal
# these are global variables store in the game_temp class
$game_temp.journal_start = 676
$game_temp.journal_end = 693

# create your empty journal
@data = []

# populate your journal with entries. Each entry must match its switch number!
@data[676] = "A"
@data[677] = "B"
@data[678] = "C"
@data[679] = "D"
@data[680] = "E"
@data[681] = "F"
@data[682] = "G"
@data[683] = "H"
@data[684] = "I"
@data[685] = "J"
@data[686] = "K"
@data[687] = "L"
@data[688] = "M"
@data[689] = "N"
@data[690] = "O"
@data[691] = "P"
@data[692] = "Q"
@data[693] = "R"


for i in $game_temp.journal_start...$game_temp.journal_end

# check to see which quest switches are on
if $game_switches[i] == false
@data[i] = nil
else
@item_max += 1
end

# check to see which messages should display
if @data[i] != nil
draw_item(i)
end

end

end


#-----------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = Rect.new(10, @n, 640, 32)
self.contents.fill_rect(rect, Color.new(0,0,0,0))
self.contents.draw_text(10, @n, 640, 32, "●", 0)
self.contents.draw_text(25, @n, 640, 32, item, 0)
@n += 32

end

end

bluetechnx
September 7th, 2005, 12:55 AM
I don't know what GUI toolkit you are trying to use. Knowing that might help abit.

The code appears ok to me. You have an refresh function that does a fair chunk of work, and I assume that the gui toolkit works properly by calling 'refresh' until the window is closed.

So somewhere you should have something like....

#This is fictious code
jw = JournalWindow.new
jw.setExit(:on_exit)

# or even maybe...
jw = JournalWindow.new
jw.setExit(:on_exit)
jw.refresh


and assuming refresh prepares the data to be shown, it should refresh as you scroll.
Did you tie the scrollbar to the parent window properly?


These are just some thoughts...maybe you could tell use what gui kit and put up the scrollbar code to...

SlipKnot
December 8th, 2005, 01:16 PM
Because he is using the RGSS.
But I really don't see the problem.