Tuesday, March 11, 2008

Chewy Gui

In case you don’t know how to pronounce Gui (goo-ey) it rhymes with chewy. (Gui stands for graphic user interface. Windows and all Windows programs are Gui. DOS and command prompts are not Gui.)

Gui’s are hard to write for many reasons. One, despite the power of modern computers, displaying a simple image on the screen and allowing the user to interact with it is very difficult. How many free video games do you play for more than 5 minutes? (Well not counting MTG Forge of course, ha.) Two, writing a gui that people can understand and use is magnitudes harder than point number one. I can pick up and play Mario 3 which is about 15 years old because the gui is so easy to understand. Writing an intuitive interface like Mario can make you famously wealthy for life, but I doubt Mario 3 was written by less than 50 dedicated people. For a really bad gui just look at Word 2007, they played hide-and-seek with the toolbar and I find it unusable.

So what does all this gui talk have to do with MTG Forge, well MTG Forge has a gui doesn’t it? Admittedly it is a basic gui that was built with regular components like buttons, panels, and text areas. I have been experimenting with a more sophisticated gui for MTG Forge 2.0 but I am getting frustrated. I have a working knowledge of Python, although there are many deeper topics that I don’t quite understand yet. For all you programmers, my fingers have finally gotten used to _not_ adding a semicolon at the end of every line. You don’t really know a programming language until you can program blindfolded, it has to be in your fingers.

But the frustrating part is also learning about the graphical library that will let me draw pictures on the screen. Learning Python was manageable since I previously mastered Java and I am familiar with the basic fundamentals of programming: variables, loops, if statements. Learning a graphical library is like trying to learn another language, but I’m not familiar with the basic language.

I am getting sidetracked by trying to write a better gui but I really want to focus on adding Lorwyn and Morningtide cards, so I am thinking about using my previous Java gui for MTG Forge 2.0. But you may ask, “I thought you were using Python and not Java?” Well thanks to Jython, I can compile Python into Java. Unlike the current version of MTG Forge, I plan to program the gui completely separate from the rest of the code in case some enterprising programmer wants to write a better one. (In the current version of MTG Forge, I accidentally let some non-gui code slip into the gui which would make writing a different gui much harder.) In version 2.0, I want to be able to change the gui with just one line of code.

By the way, I try to re-read my posts to catch any grammatical mistakes, but I’m sure I miss a few. Every time I start a sentence with “but”, I always think back to my high school English class (no “buts” allowed). --Forge

4 comments:

Nanocore said...

I for one would certainly welcome the separation between gui and code as ever since you talked of going to python, which my n800 tablet runs, I have really become excited to be able to take magic on the road and in my pocket. Unfortunately, Java hasn't been ported to run on it (more political and timing rather then technical), and it doesn't have support for accelerated graphics (ie Opengl). Hence if I want it on my tablet I would have to write the interface my self (or at least modify a pygame version to run with a smaller display if someone else writes that first). So I too have delved into the python GUI coding in hopes that I could assist with an alternative GUI.

Having the display code separate from the rest of the code, however, is a new discipline to learn, if you haven't done it before. Its not hard, but tedious and sometimes not elegant.

Anonymous said...

GUI in MTG Forge was not very good, and leave it in second version will be a big mistake.

I understand your intentions, I too tried придумать GUI after has got the исходники on Python and beside me little that was got, but even so I think that it is necessary to do something another, rather then use GUI from the first version.

Clamatius said...

For what it's worth, I left you a resizable Java gui in your sourceforge patches section.

I resisted the urge to change too much and just tweaked the layout setup so it will resize in a semi-reasonable manner.

Forge said...

Thanks for the feedback. I know the GUI is the most interesting part from the user's perspective. Even Wizards has a hard time making the perfect Magic gui.

I can't make up my mind. Right now I'm having good success with PyGame which is SDL. It isn't perfect but the GUI is far better than Java. I'm not sure how I'll do the deck editor, it may look alot like Shandalar's editor.