Multiline TextBox - Ignition + FontMachine

Monkey Forums/Monkey Programming/Multiline TextBox - Ignition + FontMachine

Tibit(Posted 2013) [#1]
I'm using FontMachine and Ignition.

I haven't found a way to make the text multiline. I know someone made a hack to fontMachine to support this, but I can't find it now and it doesn't seem to be implemented into FontMachine yet.

I can't find the ignition docs related to gui, however I tested with iGuiScrollBox, iGuiTextField,iGuiText but the text does not wrap for me.

I'd prefer a Ignition GUI way, since then I can position the text box resolution independant.

Is there a way?

If not, any suggestions?


Paul - Taiphoz(Posted 2013) [#2]
it was me, should be in the code section I just did a quick override and hacked in some code to split the lines, but it's not overly efficient, I am sure that Zig has actually coded his own way more efficiant multi line method now, so it might be worth looking through the module again.

think this is what your looking for. unless your talking about text input.
http://www.monkeycoder.co.nz/Community/posts.php?topic=3207


Tibit(Posted 2013) [#3]
Thanks! I'll use that if it turns out I can't use Ignition GUI to do it :)


ziggy(Posted 2013) [#4]
Latest FontMachine has a class that handles rendering of multiline text with wordwrap without having to recalculate everything per frame, and without creating substrings.

You can see it here: https://code.google.com/p/fontmachine/

This is a sample using wordwrapp text:
Import fontmachine
Import mojo
Function Main()
	Local g:= New Game
End

Class Game Extends App
	Field font:BitmapFont
	
	Field wrapedtext:WordWrapedText
	Method OnCreate()
		SetUpdateRate(60)
		font = New BitmapFont("smallfont.txt")
		wrapedtext = New WordWrapedText
		wrapedtext.Font = font
		Local text:= LoadString("sampletext.txt")
		If text = "" Then Error("Could not load text!")
		wrapedtext.Text = text
		
		wrapedtext.Width = 50
	End
	
	Method OnUpdate()
		If KeyDown(KEY_A) Then wrapedtext.Width += 1
		If KeyDown(KEY_S) Then wrapedtext.Width -= 1
	End
	
	Method OnRender()
		Cls(255,255,255)
		font.DrawText("Press A or S to modify the wordwrapp area width", 0, 0)
		SetColor(200, 200, 200)
		DrawRect(100, 100, wrapedtext.Width, 5000)
		SetColor(255, 255, 255)
		wrapedtext.Draw(100, 100)
	End
End



Paul - Taiphoz(Posted 2013) [#5]
I'v still not actually ported my own code over to use your new module yet ziggy this is a nice reminder that I really need to do it at some point.


Playniax(Posted 2013) [#6]
Maybe I can help? :)

Do you need static text or input?


Raph(Posted 2013) [#7]
Ziggy, two minor things.

1. It's "Wrapped" not "Wraped." :) To a native English speaker, the second one reads like "raped."

2. I use Jungle IDE's module updater, and you don't seem to have this wordwrap code in the version that grabs (13.03.11-000A). In fact, I had to dig a bit in your repo, because it's not in the module itself but in a subfolder... I expected it to be in the module itself. So in case others miss it like I did, maybe it should be with the main module, or there should be a txt file pointing to it or something?


ziggy(Posted 2013) [#8]
this has not been promoted to official yet. will do very soon.


Tibit(Posted 2013) [#9]
@Playniax - great, I need simple static text. Just like Ziggy posted, but with your awesome GUI controls :)


Paul - Taiphoz(Posted 2013) [#10]
Ziggy any reason your holding back on pushing out the release?


ziggy(Posted 2013) [#11]
@Taiphoz: Just willing to have tested a bit more. But I'll be releasing as an official "update" very soon


ziggy(Posted 2013) [#12]
It's been promoted to "stable" and an update is available.


dave.h(Posted 2013) [#13]
Thanks this is a very useful update and it works great.I was just wondering if there was any way to align the text to the center or to the right.Or is it just always aligned to the left.


ziggy(Posted 2013) [#14]
I was just wondering if there was any way to align the text to the center or to the right.Or is it just always aligned to the left.
Not yet!


Playniax(Posted 2013) [#15]
Hey Tibit, did you get my mail?


pit(Posted 2014) [#16]
hi all,

I bought Ignition X.
in the package, I found the font framework from ignition AND the fontmachine from ziggy.
Question: are they complementary ? Or is there an advantage to use one or the other ?
Fontmachine work with the same font than the font converted by the tool from playnax ?

Sorry for the questions, but as I'm just beginning to find a text-font framework to convert my old blitzmax games, I don't have a clear view now :-)

Pit


Playniax(Posted 2014) [#17]
The Ignition X font tool only converts ttf fonts to a format that Igition X can use.

Fontmachine can do more like edit the font, adding colors etc.

Ignition X can handle both font formats.


pit(Posted 2014) [#18]
Hi playniax

I decided to use the ignition framework as it offer what I want : the same functionalities than the font type of blitmax.
And... it works ! My Class is now migrated and works as in Blitz !
:-)

So... thanks !

Pit