Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 9:11 pm

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Widgets not visible
PostPosted: Fri May 04, 2012 4:15 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
I apologize, I'm probably blind and forgetting something extremely easy.

I've included TWL with my Slick project, but I can't get my button to show up, no matter what I try.

Taken from your wiki:
Code:
@Override
   protected void createRootPane() {
      super.createRootPane();

      button = new Button("New Game");
      button.addCallback(new Runnable() {
         @Override
         public void run() {
            System.out.println("it works");
         }
      });

      rootPane.add(button);
   }

   @Override
   public void layoutRootPane() {
      button.adjustSize();
      button.setPosition(100, 100);
   }


I get no errors (except state0/state1 themes not found) but nothing is visible.
My theme for testing purposes is from this thread: viewtopic.php?f=18&t=4859

Code:
@Override
   protected URL getThemeURL() {
      return Game.class.getResource("/me/game/theme/chutzpah.xml");
   }


Any help appreciated.
Biki


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Fri May 04, 2012 7:05 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1190
Do you get any messages on System.err ?

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Fri May 04, 2012 8:30 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
Quote:
Could not find theme: state0
Could not find theme: state1


This is all I get.

In the meanwhile I've included the newer version of the TWLSlick.zip in my projects. I'm now doing the following:

Code:
@Override
   public void layoutRootPane() {
      button.adjustSize();
      button.setPosition(100, 100);
   }

   @Override
   public void init(final GameContainer container, final StateBasedGame game) throws SlickException {
      super.init(container, game);

      button = new Button("New Game");
      getRootPane().add(button);

        ....
}


But it's still as before - nothing is shown.


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Fri May 04, 2012 9:33 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
there is some theme missing for the button. Has the xmxl file a button theme?

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Fri May 04, 2012 9:44 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
Yes. I've tried using setTheme() on the rootPane and/or button to no avail.


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Fri May 04, 2012 10:08 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1190
You should upgrade the theme with the fallback theme.
Add this to "-defaults":
<theme name="" ref="*"/>

And add this as top level theme after the "-defaults":
<theme name="*" ref="-defaults"/>

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Sat May 05, 2012 2:10 am 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
I've added the fallback to the theme and uploaded a new version.

The slick examples set the root pane's theme to "state0", "state1", etc. So it's looking for the theme called "state0.button" which doesn't exist. The fallback should now fix that, but you'll still get a warning message.

Ideally you should just clear the root pane themes unless you need them. In each state's init(), use the following:
Code:
getRootPane().setTheme("");


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Sat May 05, 2012 8:22 am 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
Thank you guys, I've upgraded the XML file.

Button is still not visible, though.

Code:
@Override
   public void layoutRootPane() {
      button.adjustSize();
      button.setPosition(100, 100);
   }

   @Override
   public void init(final GameContainer container, final StateBasedGame game) throws SlickException {
      super.init(container, game);
      getRootPane().setTheme("");

      button = new Button("New Game");
      button.setTheme("button");
      getRootPane().add(button);
        ...
}


System.err: Selected fallback theme for missing theme "state0"

I really don't know what's wrong here. Couldn't be an OpenGL problem or something like that, could it?


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Sat May 05, 2012 4:49 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
It seems more likely a problem elsewhere in your code. Try running this test, main class is TWLGame:
http://www.mediafire.com/?s7mnyd881c16749


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Sat May 05, 2012 6:09 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
Your test code works perfectly with the same libs/jars I'm using in my main project, so it's indeed an error in my code.

I needed to change serveral methods from protected to public since I put the TWLSlick files in several packages. But I guess this won't do anything.
I'm also using MarteEngine, so my BasicTWLGameState is extending World, which is extending BasicGameState. But I already checked Override problems :?


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Mon May 07, 2012 12:53 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
I really don't get it. Makes absolutely no sense.
The above test works perfect, I copy the same stuff into my game structure and I see NOTHING. I even disabled all the states but my main menu state. Nothing...

I've added MarteEngine to the Test and it still works, so no problems there. I'm confused :?


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Mon May 07, 2012 5:56 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1190
Maybe paste your code?

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Wed May 09, 2012 3:27 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
Still trying to fix this error.

When I do it the following way:

Code:
public void init(GameContainer container, StateBasedGame game) throws SlickException {
      super.init(container, game);

      getRootPane().setTheme("");

      btn = new Button("Hello, world!");
      getRootPane().add(btn);
   }

   @Override
   public void layoutRootPane() {
      super.layoutRootPane();

      btn.adjustSize();
   }


(Leaving out the position and adjustSize)

I get this result:

Image

Does this mean something to anyone? Is this intended to look like this?


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Wed May 09, 2012 7:02 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1190
You could verify the size of the root pane?

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Widgets not visible
PostPosted: Thu May 10, 2012 12:19 pm 
Offline
Regular

Joined: Sun Oct 25, 2009 5:24 pm
Posts: 118
getRootPane().getWidth/Height returns 0 for either. So I guess that's the problem? :)

LWJGLRenderer().getWidth/Height returns 32/32 after initialization. Also strange, isn't it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group