It is currently 27 Apr 2024, 10:41
   
Text Size

Why Forge Swing GUI is currently hold with duct tape

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Why Forge Swing GUI is currently hold with duct tape

Postby Snacko » 12 Jul 2011, 08:45

Swing is single threaded, this means every creation / manipulation of Swing objects has to be done on the even dispatch thread.
This has a heavy implication that you dont bog down the even dispatch thread with heavy computation or the GUI wont update. The exact example of this done wrong is the progress bar which doesn't update if you move it around, but just smears.

Currently as a duct tape fix the whole Forge code runs on the even dispatch queue!
To disable the tape fix you have to comment the code in Gui_NewGame.java
Code: Select all
SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    AllZone.setComputer(new ComputerAI_Input(new ComputerAI_General()));
                    new Gui_NewGame();
                }
            });
And only leave the two lines inside or run. For a better effect you can enable one of Substance skins which will enable the checking of proper Swing usage. If you're brave enough, you now should see couple hundred exceptions and Forge GUI might not work at all at some points ;)

The good course of action would be to fix this at some point. I'm just leaving it here for anyone wanting to do any GUI work on Forge.

You can read more here :
basically you need to use invokeLater or SwingWorker
http://www.javaworld.com/javaworld/jw-0 ... tml?page=1
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Re: Why Forge Swing GUI is currently hold with duct tape

Postby friarsol » 12 Jul 2011, 12:02

Snacko wrote:The good course of action would be to fix this at some point. I'm just leaving it here for anyone wanting to do any GUI work on Forge.
Thanks for the Notes Snacko, but I slightly disagree. The good course of action is to nuke it all and start from scratch. Our UI needs a major makeover.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Why Forge Swing GUI is currently hold with duct tape

Postby Braids » 15 Jul 2011, 18:07

if we could implement more of the UI in terms of (a list of?) decisions you or the AI can make at this moment and the effects of each of these decisions, this would greatly help minimax.

do we need a separate View layer? (as in Model View Controller)
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Why Forge Swing GUI is currently hold with duct tape

Postby Braids » 17 Aug 2011, 19:03

i'm rewriting some of the UI startup code. thanks for the pointer, Snacko. i should be able to avoid the pitfall you describe during the execution of my new code. well, it's a start. better than nothing.

@Snacko, could you review my code once i've committed it? if i don't hear from you, i'll try to PM you after the commit.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Why Forge Swing GUI is currently hold with duct tape

Postby Snacko » 17 Aug 2011, 21:52

Pm me after commit as I don't follow commits very closely.
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Re: Why Forge Swing GUI is currently hold with duct tape

Postby cuhnkedrik » 10 Oct 2023, 01:43

Minimax could be considerably improved if the user interface provided more information about the choices you or the AI had right now and the outcomes of those choices.

Is a View layer really necessary?
cuhnkedrik
 
Posts: 2
Joined: 04 Oct 2023, 09:41
Has thanked: 0 time
Been thanked: 0 time


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 100 guests


Who is online

In total there are 100 users online :: 0 registered, 0 hidden and 100 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 100 guests

Login Form