Page 1 of 1

Simple Phase Step Viewer

PostPosted: 26 Oct 2013, 17:34
by Lodici
Being new to MTG I wrote this small feature to help me remember how the various phases and steps that make up a turn are organized. It uses tooltips to display the full phase/step name, for example if I hover the mouse cursor over "DA" it will display "Combat Phase: Declare Attackers Step".

PhaseStepViewer.png

-Lodici

Re: Simple Phase Step Viewer

PostPosted: 27 Oct 2013, 01:40
by melvin
This is very helpful! A good step in the direction to addressing https://code.google.com/p/magarena/issues/detail?id=1

Merging this right now, just in time for this month's release.

Re: Simple Phase Step Viewer

PostPosted: 27 Oct 2013, 11:15
by Lodici
Not sure why you changed the layout - I used BoxLayout instead of FlowLayout (which is very limited) specifically so that it would use the whole width of the GameDualViewer which I think looks better and less cramped. If I had wanted to make the code simpler (ie use ordinal) without changing the display I would have preferred to use MigLayout but that would have meant introducing a new external library.

- Lodici

Re: Simple Phase Step Viewer

PostPosted: 27 Oct 2013, 11:59
by melvin
The BoxLayout was overflowing for me on a 1920 x 1080 display, the last two phases were not visible. I tried tweaking the amount of gap and initial padding but I wasn't sure if it would work properly on different resolutions. The FlowLayout seems to do it properly without any additional tweaks, hence I chose it in the end.

Is it possible to have it use the full width in a programmatic way without fixing the amount gap in advance? I think SpringLayout might do the trick but didn't have enough time to work it out.

Re: Simple Phase Step Viewer

PostPosted: 27 Oct 2013, 13:42
by Lodici
Ok, thanks for the clarification. The LHS of the game screen appears to be fixed at 300px so I assumed that absolute dimensions would work regardless of resolution.

I am not sure whether the SpringLayout would work either. TBH, most of my experience is with MigLayout which is a powerful replacement for all the myriad native layout managers producing much more concise and cleaner code.

I have attached an update you might want to try which I think will fix the problem. Note, the minimal update required to the existing code.

It uses the MigLayout library which I have added via the Build.xml file - not sure if this is correct way to do it. After downloading, you will need to add a reference to "miglayout-core-4.2.jar" and "miglayout-swing-4.2.jar" in order to build.

- Lodici

Re: Simple Phase Step Viewer

PostPosted: 27 Oct 2013, 14:21
by melvin
I just checkout out your patch, it looks good and the needed lib are self contained and quite small.

I'm curious as to why the asymmetry in the insets for the left and right side (4 on the left and 6 on the right)?

Re: Simple Phase Step Viewer

PostPosted: 27 Oct 2013, 14:45
by Lodici
melvin wrote:I'm curious as to why the asymmetry in the insets for the left and right side (4 on the left and 6 on the right)?
Ah, you discovered my deliberate error. :wink: You are right, they should both be the same value.

- Lodici

Re: Simple Phase Step Viewer

PostPosted: 27 Oct 2013, 20:40
by Lodici
Please find attached the PhaseStepViewer inset fix and a fix for the border painting on the GameDuelViewer titlebar.

- Lodici

Re: Simple Phase Step Viewer

PostPosted: 28 Oct 2013, 03:39
by melvin
Lodici wrote:Please find attached the PhaseStepViewer inset fix and a fix for the border painting on the GameDuelViewer titlebar.
Wonderful, I've merged this change in as https://code.google.com/p/magarena/sour ... 5dd622fa7f

For the longest time, this project had no external dependency. The first to be added was Groovy, as it allowed us to write card scripts in groovy that can be loaded dynamically at runtime.

In this case, I think the ability of MigLayout to simplify and make it easier for us to modify the UI going forward is sufficient reason to include it as a dependency.

Re: Simple Phase Step Viewer

PostPosted: 28 Oct 2013, 11:32
by Lodici
Here is a small update that makes the TabSelector buttons appear kind of translucent on the GameDuelViewer component. Note this is an optional property via an additional constructor method and does not affect any of the other instances where the TabSelector is used.
screenshot.png
screenshot.png (7.57 KiB) Viewed 6849 times


- Lodici

Re: Simple Phase Step Viewer

PostPosted: 28 Oct 2013, 12:20
by Lodici
Here is an update that replaces the up/down arrow with the actual avatar of the player whose turn it is which I think is a bit clearer.

screenshot.png

Note, this does require MigLayout.

- Lodici

Re: Simple Phase Step Viewer

PostPosted: 28 Oct 2013, 13:09
by melvin
Thanks for the two updates. The translucent tab looks nicer and less jaring. Replacing the arrow to an avatar is a great idea! Unfortunately, after I apply your patch the title bar and phase step viewer overflow and is clipped of. See attached screenshot.

Re: Simple Phase Step Viewer

PostPosted: 28 Oct 2013, 14:34
by Lodici
It looks like your "dialog" font is wider than mine. I have attached what I hope is a fix for your problem. I have reduced the font size of the phase bar and amended a couple of resizing parameters which previously were preventing components shrinking to a more optimum minimum size.

- Lodici

Re: Simple Phase Step Viewer

PostPosted: 29 Oct 2013, 01:42
by melvin
Thanks, that did the trick. It all fits now. I've merged your changes to the main repo.