Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 10:00 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Aug 08, 2008 6:27 am 
Offline

Joined: Tue Jul 24, 2007 8:43 am
Posts: 22
Ummm... don't really know how to easily describe this problem.

The GUI gets scaled strangely, I am trying to put a 1680x1050 game into an 840x525 window, which is working but the GUI seems to be clipped to an 840x525 section of the original game size which means it gets scaled and clipped to a 420x260ish region of the window. The mouse input etc is working at this scaled size.

The other strange thing is that there seems to be an invisilbe rectangle in the upper left corner of where the GUI is being drawn which clips some controls within a dialog but not others. Using the search dialog from the demo as a test and dragging it around everything except the dialog box, label for the combo box, and text area for the combo box gets clipped by the invisible rectangle.

Cheers,
Brett


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 6:35 am 
Offline
User avatar

Joined: Fri Aug 01, 2008 8:00 am
Posts: 16
Location: Rome, Italy
Always give the code to reproduce the error!

regards,
andrea


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 7:58 am 
Offline

Joined: Tue Jul 24, 2007 8:43 am
Posts: 22
Main.java
Code:
public class Main
{

    public Main()
    {
        try
        {
            Game game = new Game();
            AppGameContainer container = new AppGameContainer( new ScalableGame( game, 1680, 1050, true ) );
           
            container.setVSync(true);

            container.setDisplayMode( 840, 525, false );
            container.start();
        }
        catch( SlickException ex )
        {
            ex.printStackTrace();
        }
    }
   
    public static void main( String[] args )
    {
        new Main();
    }
}


Game.java
Code:
public class Game
        extends StateBasedGame
{

    public Game()
    {
        super( "Game" );
    }

    @Override
    public void initStatesList( GameContainer arg0 ) throws SlickException
    {
        addState( new State() );
    }
}


State.java
Code:
public class State
        extends BasicGameState
{
    private Page page;
    private Thinlet thinlet;

    public void init( Thinlet thinlet )
    {
        this.thinlet = thinlet;
    }
   
    @Override
    public int getID()
    {
        return 1;
    }

    public void init( GameContainer container, StateBasedGame arg1 ) throws SlickException
    {
        Thingle.init( new SlickThinletFactory( container ) );
        Thingle.setMethodInvoker( new LegacyMethodInvoker() );
        try
        {
            page = new Page( "res/guitest.xml", this );
        }
        catch( ThingleException e )
        {
            e.printStackTrace();
        }
        page.setDrawDesktop( false );
        page.enable();
    }

    public void render( GameContainer arg0, StateBasedGame arg1, Graphics arg2 ) throws SlickException
    {
        page.render();
    }

    public void update( GameContainer arg0, StateBasedGame arg1, int arg2 ) throws SlickException
    {
    }
}


guitest.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<desktop init="init(thinlet)">
<dialog text="Find" icon="res/icon/search.gif" modal="true"
      columns="4" top="4" left="4" bottom="4" right="4" gap="4"
      closable="true">
   <label text="Find what:" mnemonic="0" for="ch_what" />
   <combobox name="ch_what" colspan="2" valign="center" />
   <label text="Direction:" alignment="right" />
   <checkbox name="rb_up" text="Up" mnemonic="0" group="direction" />
   <checkbox name="cb_match" text="Match case" mnemonic="0" selected="true" />
   <button name="b_cancel" text="Cancel" type="cancel" />
   <label />
   <checkbox name="rb_down" text="Down" mnemonic="0"
      group="direction" selected="true" />
</dialog>
</desktop>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 11, 2008 7:00 am 
Offline

Joined: Tue Jul 24, 2007 8:43 am
Posts: 22
Ok, I did a bit of hacking around in the source and came up with a fix for most of the problems.

I started treating ScalableGame as a first class citizen and inserted detection for running a ScalableGame into the getWidth() and getHeight() methods of GameContainer. I also added a boolean parameter to those methods to allow you to either get the window's width and height or the scaled game's width and height.

The Thingle GUI is now using the entire game area, although the invisible clip rectangle is still there. I haven't been able to figure out where that might be coming from.

Doing this I was also able to fix (mostly) a problem that I had with transitions not being ScalableGame aware either (for my game I had created ScalabelFadeIn/OutTransitions). Some of the transitions don't work quite right, my fault for not calling getWidth/Height() with the right parameter I expect, or perhaps a clip setting issue.

There are a lot of little edits throughout the code so I won't post them here.

So, is anybody else actually interested in this? Or am I the only one using ScalableGame?

Cheers,
Brett


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 11, 2008 7:31 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Sorry, I've been meaning to post a "I'm not sure, but I'm looking at it". Don't have a solution yet so not much to post.

I guess rendering the page in the overlay section of the scalable game isn't any use to you?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 11, 2008 8:04 am 
Offline

Joined: Tue Jul 24, 2007 8:43 am
Posts: 22
What I am doing is trying to put together an in-game level editor as a game state. The state wraps my platform game state, passing through render, update, input, etc calls, then rendering the page on top.

I had a look at how the renderOverlay() method is used in ScalableTest and I suppose if I can get access to the current state and defer rendering of the GUI then it could work. I'll have a go when I get home tonight.

Thanks for the tip Kev, I hope I can get it to work. Although I think the only way to solve all of my ScalableGame problems is to have ScalableGame as the main game type, and have all of the internals of Slick treat a game as though it is scalable, where a game that is the same size as its container is just a special case but not treated any differently.

Cheers,
Brett


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 15, 2008 7:43 am 
Offline

Joined: Tue Jul 24, 2007 8:43 am
Posts: 22
I had a go at rendering the gui in the overlay. It seemed to render at the proper scaling, but I couldn't figure out how to get it to recognise mouse input.

Also, implementing this in my game, keeping a reference to the state with the gui, then having to override the ScalableGame to get the reference back out of the StateBasedGame that the ScalableGame was wrapping seemed really messy. If there is a better way of using overlays with a StateBasedGame please tell me.

One other thing i thought of while I was typing this, to do with input, is that won't all the input be scaled (since I'm running a 1680x1050 game in a 840x525 container) and not work properly in an unscaled overlay?
Cheers,
Brett


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 21, 2008 6:47 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Can't get this to work in any usable way yet. Still looking, it might be an easy way to scale UI's to different resolutions.

Kev


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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