Help with Standardness and GBUI

Perhaps someone could help with problem, I have a feeling there is something wrong with StandardApplet.  I'll show you what I mean.  Here's some code that works with JME and GBUI projects added Versus.java:



import java.util.concurrent.Callable;

import com.jme.input.InputHandler;
import com.jme.input.MouseInput;
import com.jme.system.DisplaySystem;
import com.jme.util.GameTaskQueueManager;
import com.jme.util.Timer;
import com.jmex.awt.applet.StandardApplet;
import com.jmex.bui.BButton;
import com.jmex.bui.BWindow;
import com.jmex.bui.BuiSystem;
import com.jmex.bui.PolledRootNode;
import com.jmex.bui.event.ActionEvent;
import com.jmex.bui.event.ActionListener;
import com.jmex.bui.layout.AbsoluteLayout;
import com.jmex.bui.util.Point;
import com.jmex.game.StandardGame;
import com.jmex.game.state.BasicGameState;
import com.jmex.game.state.DebugGameState;
import com.jmex.game.state.GameState;
import com.jmex.game.state.GameStateManager;

public class Versus {//extends StandardApplet {

   private static final long serialVersionUID = 1L;

   public static void main (String[] args) {
      StandardGame game = new StandardGame("Woot!");
      game.start();
      // See the cursor?
        MouseInput.get().setCursorVisible(true);
      
      GameState state = new GbuiGameState();
      state.setActive(true);
      GameStateManager.getInstance().attachChild(state);   
      
          DebugGameState base = new DebugGameState();
           base.setActive(true);
           GameStateManager.getInstance().attachChild(base);
   }
   
   /*public void start() {
      setSize(640, 480);
      super.start();
      // See the cursor?
        MouseInput.get().setCursorVisible(true);
      
      GameState state = new GbuiGameState();
      state.setActive(true);
      GameStateManager.getInstance().attachChild(state);      
   }*/
   
}

class GbuiGameState extends BasicGameState {

   private InputHandler input = new InputHandler();
   
   public GbuiGameState() {
      super("Menu");
      BuiSystem.init(new PolledRootNode(Timer.getTimer(), input), "/test.bss");
       rootNode.attachChild(BuiSystem.getRootNode());
      final BWindow bWindow = new BWindow(BuiSystem.getStyle(), new AbsoluteLayout());
      final BButton bButton = new BButton("Click Me!");
      bButton.setPreferredSize(640, 480);
        bButton.addListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent event) {
                System.out.println("Button Pressed!");
            }
        });
       

       
        try {
           GameTaskQueueManager.getManager().update(new Callable<Object>() {
              public Object call() throws Exception {
                   bWindow.setSize(640, 480);
                 bWindow.add(bButton, new Point(0, 0));
                 BuiSystem.addWindow(bWindow);
                 bWindow.center();
                 return null;             
              }
           });
        } catch (Exception e) {
           e.printStackTrace();
        }
      
   }
   
   public void update(float tpf) {
      super.update(tpf);
      input.update(tpf);
   
   }
      
}


Make sure to add this bss file test.bss:

root {
  color: #FFFFFF;
  font: "Dialog" plain 16;
}

root:disabled {
  color: #BBBBBB;
}

window {
  border: 1 solid #FFFFFF;
}

decoratedwindow {
  border: 1 solid #FFFFFF;
}

button:hover {
  text-effect: outline;
  effect-color: #000000;
}

button {
  padding: 3 5;
  font: "Dialog" bold 24;
  color: #FFFF88;
  text-align: center;
}

to make this work along with changing this line

BuiSystem.init(new PolledRootNode(Timer.getTimer(), input), "/test.bss");

to point to the file.

Run it and see that Standard Game works! :D  The Button shows up and when you click it, it states it was clicked!  :D

Now try uncommenting

extends StandardApplet

and

public void start() { ..... }



Also comment out the

public static void main(String[] args) { ... }

method so you're using StandardApplet instead.  Note: You might have to remove the final modifier on start() in the StandardApplet.java

When you run it now, the Button doesn't show up   :(,  but when you click the screen the button says it was clicked!  :?  So apparently the Button is being set up, but not drawn?  The code is the same for both, so by logic  I deduce that the problem is run with StandardApplet.  Is it not loading the bss or is it just not rendering the button?  Please help!

I believe I may have found a more simpler example of what I mean.  This involves jmetest.game.state.TestLoadingGameState.java.  This works with StandardGame, obviously, but when I try similar StandardApplet code, nothing shows up, why is this?  After toying with this for quite a while, I believe there is either some setting not being set correctly, or something isn't being rendered correctly.  Any help will be greatly appreciated.  :D  Here's the Applet version of the code:

package com.scarsofbravery;



import java.util.concurrent.Callable;

import com.jme.util.GameTaskQueueManager;

import com.jmex.game.state.DebugGameState;

import com.jmex.game.state.GameStateManager;

import com.jmex.game.state.load.LoadingGameState;

import com.jmex.awt.applet.StandardApplet;



public class TestLoadingGameStateApplet extends StandardApplet {



   private static final long serialVersionUID = -4323241276581716165L;



   public void start() {

      setSize(640, 480);

      super.start();

      GameTaskQueueManager.getManager().update(new Callable<Void>(){



         public Void call() throws Exception {

            // Create LoadingGameState and enable

            final LoadingGameState loading = new LoadingGameState();

            GameStateManager.getInstance().attachChild(loading);

            loading.setActive(true);



            // Enable DebugGameState

            DebugGameState debug = new DebugGameState();

            GameStateManager.getInstance().attachChild(debug);

            debug.setActive(true);



            GameTaskQueueManager.getManager().update(new LoadingTask(loading, 0));

            

            return null;

         }

      });

   }

}

class LoadingTask implements Callable<Void> {

   private final LoadingGameState loading;

   private final int progress;

   

   public LoadingTask(LoadingGameState loading, int progress) {

      super();

      this.loading = loading;

      this.progress = progress;

   }



   public Void call() throws Exception {

      String status;         

      if (progress == 100) {

         status = "I'm Finished!";

      } else if (progress > 80) {

         status = "Almost There!";

      } else if (progress > 70) {

         status = "Loading Something Extremely Useful";

      } else if (progress > 50) {

         status = "More Than Half-Way There!";

      } else if (progress > 20) {

         status = "Loading Something That You Probably Won't Care About";

      } else {

         status = "Started Loading";

      }

                        

      Thread.sleep(100);

      loading.setProgress(progress / 100.0f, status);



      if (progress < 100) {            

         GameTaskQueueManager.getManager().update(new LoadingTask(loading, progress + 1));

      }

      return null;

   }

}





Edit: I tried using SceneMonitor, and it shows up when turning highlighting on.  :?  This is extremely puzzling to me what could be the cause?

when looking into the StandardApplet problem here, i noticed display.getWidth() returns 0 in StandardApplet, thats causing a endless loop then pressing F4 in DebugGameState for example.

So your issue might be related somehow.

In your TestLoadingGameStateApplet  example you overwrite StandardApplets start() method ??

Thats not possible, start is final in StandardApplet.



You should use init();

Core-Dump said:

In your TestLoadingGameStateApplet  example you overwrite StandardApplets start() method ??
Thats not possible, start is final in StandardApplet.

You should use init();



I removed the final modifier for my StandardApplet  }:-@  Just so I could say that the StandardGame and StandardApplet would behave the same.  I'm not sure if overriding init() is best, but I'll take your word for it.  I think the modifications that you made are what was messing me up before.  I've have to get back to you on that.  Thanks for all your help with the fixes on StandardApplet, I didn't really understand everything about it, when I created it.

Yeah, so the problem was fixed by that fix that Core-Dump made.  I still like overriding the start method though because that's sorta of how StandardGame works, you run it by calling standardgame.start() on an instance.  Also that way you don't have to do run everything in the OpenGL thread like TestStandardApplet does because by the start() initializes more (Like DisplaySystem) than init().  Hopes this makes sense…  :wink:

heh sure, it wasn't my idea to make start final, i removed the modifier from StandardApplets#start()