Nifty labels inside a scrollPanel control

My game implements a head-up display using Nifty. When I upgraded from RC2 to 3.0Stable, the HUD’s appearance changed for the worse, with all the labels in the scrollPanel becoming invisible illegible. I’ve written a small test app which demonstrates the issue:

[java]
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.niftygui.NiftyJmeDisplay;
import de.lessvoid.nifty.Nifty;

/**

  • A simple JME3 app to demonstrate the Nifty scrollPanel control.
    */
    public class Main extends SimpleApplication {

    public static void main(String[] args) {
    Main app = new Main();
    app.setShowSettings(false);
    app.start();
    }

    @Override
    public void simpleInitApp() {
    NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
    inputManager, audioRenderer, guiViewPort);
    Nifty nifty = niftyDisplay.getNifty();
    String interfaceAssetPath = “Interface/hud.xml”;
    nifty.addXml(interfaceAssetPath);
    viewPort.addProcessor(niftyDisplay);
    nifty.gotoScreen(“hud”);
    }
    }
    [/java]

Here’s the hud.xml file:
[java]
<?xml version=“1.0” encoding=“UTF-8”?>
<nifty xmlns=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd”>
<useStyles filename=“nifty-default-styles.xml”/>
<useControls filename=“nifty-default-controls.xml”/>

&lt;screen id="hud"&gt;
    &lt;layer childLayout="horizontal"&gt;
        &lt;panel/&gt;
        &lt;panel childLayout="vertical"
               width="190"&gt;
            &lt;control name="scrollPanel"
                     horizontal="false"&gt;
                &lt;panel childLayout="vertical"
                       backgroundColor="#f0ff"
                       padding="10"&gt;
                    &lt;control name="button"
                             label="a button label"/&gt;
                    &lt;control name="label"
                             color="#0f0f"
                             text="some green text"/&gt;
                &lt;/panel&gt;
            &lt;/control&gt;
        &lt;/panel&gt;
    &lt;/layer&gt;
&lt;/screen&gt;

</nifty>
[/java]

Can anybody explain why the labels are invisible / illegible?

Do the labels look fine when not inside the scroll panel?

1 Like

@zarch: yes, they look fine that way.

Odd. I don’t use the nifty scrollpanel myself so you may need to see if someone who does (or @void256) comes along.

1 Like

Just for the record it looks like this:

(I’ve added the button and label outside the scrollpanel where it renders ok)

The problem seems to be the blendMode=“multiply” which is applied in the standard-style for the scrollpanel. This somehow makes anything inside the scrollpanel to render without texturing enabled and/or missing texture coordinates when used in jme3.

I don’t know why (yet). I’m pretty sure we had that problem before but I can’t remember what we did the last time it occured :wink:

There is a workaround however. Just add that snippet to your xml somewhere before the screen tag:

[java]

[/java]

And then apply that style to your scrollpanel control:

[java][/java]

3 Likes

Thanks, @void256! The workaround you suggested resolves this issue in my game … though I did have to change “onactive” to “onActive”.

1 Like

Begging your pardon, @void256, but I guess I’m unclear: where would I report this issue? To https://github.com/void256/nifty-gui/issues or to https://code.google.com/p/jmonkeyengine/issues ?

This specific issue is best reported as a jME specific issue: https://code.google.com/p/jmonkeyengine/issues since the problem is in the jME-Nifty integration code. Not sure if this can actually be fixed properly (besides the workaround posted above).

2 Likes

Thanks, @void256. I’ve filed this as a new issue (#609).

Hello,
i ran into the same issue.
The posted solution above works, however the scrollbar changes its color from red to grey as soon as i start to drag an image.

Coudl you @void256 provide me a hint? I would really appreciate :slight_smile:

1 Like