Yes, this is my third post today, but it's Saturday and I'm cranking through code now that I've gotten over the mouse-picking hurdle!
I have created a new component "Label" that is moderately self-explanatory, but represents a single-line of text. With this Resource comes to fruition as a simple lookup call "Resource(resourceName)" that will find a resource in the defined resource paths (defaults to look in "resource" path). Additionally I have created a FontManager that simplifies the management of fonts in the system. I have plans in the long-run to create a bitmap-font generator from AWT fonts, but for now getting a font is as easy as "FontManager("Arial")" presuming there's an AngelCode font definition in the Resource lookup path by the name of "Arial.fnt".
See the following test of Label:
package org.sgine.ui
import scala.io.Source
import org.sgine.input.event.MousePressEvent
import org.sgine.render.Renderer
import org.sgine.render.font.FontManager
import org.sgine.render.scene.RenderableScene
import org.sgine.scene.GeneralNodeContainer
object TestLabel {
def main(args: Array[String]): Unit = {
val r = Renderer.createFrame(1024, 768, "Test RenderScene")
val scene = new GeneralNodeContainer()
val component = new Label()
component.location.z := -500.0
component.font := FontManager("Franklin")
component.text := "Hello World!"
scene += component
r.renderable := RenderableScene(scene)
}
}
Even more exciting is Scale-9 (a.k.a nine-slice) support that opens up more advanced skinning functionality and in the short-run allows creation of pretty buttons; bet you can guess what's up next. ;)
Anyway, here's a quick test using the new Scale9 component:
package org.sgine.ui
import org.sgine.core.Resource
import org.sgine.render.Renderer
import org.sgine.render.scene.RenderableScene
import org.sgine.scene.GeneralNodeContainer
object TestScale9 {
def main(args: Array[String]): Unit = {
val r = Renderer.createFrame(1024, 768, "Test Scale-9")
val scene = new GeneralNodeContainer()
val component = new Scale9()
component(Resource("scale9/windows/button/hover.png"), 3.0, 3.0, 4.0, 5.0)
component.width := 200.0
component.height := 50.0
component.location.z := -500.0
scene += component
r.renderable := RenderableScene(scene)
}
}
Here's a screenshot of the application:
That's using a pretty Windows 7 skinned button in a hover state.