It is currently 31 Oct 2025, 05:29
   
Text Size

Some UI fixes

Post MTG Forge Related Programming Questions Here

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

Some UI fixes

Postby Fnoed » 08 Jan 2011, 07:57

I have made some minor UI improvements to cardforge:

The card table sorter treats colored mana as more significant than colorless mana when sorting by casting cost
Code: Select all
diff --git a/src/forge/CardUtil.java b/src/forge/CardUtil.java
index 53ab4ea..0dc5abc 100644
--- a/src/forge/CardUtil.java
+++ b/src/forge/CardUtil.java
@@ -309,4 +309,12 @@ public class CardUtil {
 
        return "none";
     }
+
+       public static double getWeightedManaCost(String manaCost)
+       {
+               if(manaCost.equals("")) return 0;
+
+               ManaCost cost = new ManaCost(manaCost);
+               return cost.getWeightedManaCost();
+       }
 }
diff --git a/src/forge/ManaCost.java b/src/forge/ManaCost.java
index fa19ebf..dfcb1ab 100644
--- a/src/forge/ManaCost.java
+++ b/src/forge/ManaCost.java
@@ -187,6 +187,22 @@ public class ManaCost {
                return cmc;
        }
 
+       /**
+        * Returns Mana cost, adjusted slightly to make colored mana parts more significant.
+        * Should only be used for comparison purposes.
+        * @return The converted cost + 0.0001* the number of colored mana in the cost
+        */
+       public double getWeightedManaCost(){
+               double cmc = 0;
+               for(Object s : manaPart){
+                       cmc += ((Mana_Part)s).getConvertedManaCost();
+                       if (s instanceof Mana_PartColor){
+                               cmc+= 0.0001;
+                       }
+               }
+               return cmc;
+       }
+
     private ArrayList<Object> split(String cost) {
         ArrayList<Object> list = new ArrayList<Object>();
         
diff --git a/src/forge/TableSorter.java b/src/forge/TableSorter.java
index 3637020..235fd03 100644
--- a/src/forge/TableSorter.java
+++ b/src/forge/TableSorter.java
@@ -48,13 +48,13 @@ public class TableSorter implements Comparator<Card>, NewConstants
     }
     else if (column == 2)//Cost
     {
-      aCom = Integer.valueOf(CardUtil.getConvertedManaCost(a.getManaCost()));
-      bCom = Integer.valueOf(CardUtil.getConvertedManaCost(b.getManaCost()));
+      aCom = Double.valueOf(CardUtil.getWeightedManaCost(a.getManaCost()));
+      bCom = Double.valueOf(CardUtil.getWeightedManaCost(b.getManaCost()));
 
       if(a.isLand())
-        aCom = Integer.valueOf(-1);
+        aCom = Double.valueOf(-1);
       if(b.isLand())
-        bCom = Integer.valueOf(-1);
+        bCom = Double.valueOf(-1);
     }
     else if (column == 3)//Color
     {
--
The Quest window can be closed using the window decoration
Code: Select all
diff --git a/src/forge/Gui_Quest_Assignments.java b/src/forge/Gui_Quest_Assignments.java
index b6904c0..17cd677 100644
--- a/src/forge/Gui_Quest_Assignments.java
+++ b/src/forge/Gui_Quest_Assignments.java
@@ -4,6 +4,7 @@ import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.io.File;
 import java.util.ArrayList;
@@ -54,7 +55,15 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
         
         setup();
 
-        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+               this.addWindowListener(new WindowAdapter()
+               {
+                       @Override
+                       public void windowClosed(WindowEvent e)
+                       {
+                               Gui_Quest_Assignments.this.this_windowClosing(e);
+                       }
+               });
         
         setSize(1024, 768);
         this.setResizable(false);
@@ -293,11 +302,10 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
        questGui.setVisible(true);
     
         dispose();
-       
     }
     
     void this_windowClosing(WindowEvent e) {
-        quitButton_actionPerformed(null);
+               questGui.setVisible(true);
     }
     
 }
--
Typo fix in AI deck descriptions
Code: Select all
diff --git a/src/forge/Gui_Quest.java b/src/forge/Gui_Quest.java
index b783804..8506744 100644
--- a/src/forge/Gui_Quest.java
+++ b/src/forge/Gui_Quest.java
@@ -394,11 +394,11 @@ public class Gui_Quest extends JFrame implements NewConstants{
         sb.append("\r\n");
         sb.append("Comic Book Guy 3    hard    Roc and Rukh Eggs, Flamebrake, Earthquake, Auriok Champion, Kor Firewalker");
         sb.append("\r\n");
-        sb.append("Crocodile Dundee 1  easy    Mone red deck with Mudbrawler Cohort and Bloodmark Mentor");
+        sb.append("Crocodile Dundee 1  easy    Mono red deck with Mudbrawler Cohort and Bloodmark Mentor");
         sb.append("\r\n");
-        sb.append("Crocodile Dundee 2  medium  Mone red deck with Mudbrawler Cohort and Bloodmark Mentor");
+        sb.append("Crocodile Dundee 2  medium  Mono red deck with Mudbrawler Cohort and Bloodmark Mentor");
         sb.append("\r\n");
-        sb.append("Crocodile Dundee 3  hard    Mone red deck with Mudbrawler Cohort and Bloodmark Mentor");
+        sb.append("Crocodile Dundee 3  hard    Mono red deck with Mudbrawler Cohort and Bloodmark Mentor");
         sb.append("\r\n");
         sb.append("Cyclops 3           hard    Slivers mainly, some spells");
         sb.append("\r\n");
Card shop window's tables have the cell text as tooltips. This provides a way of seeing the price of expensive cards that don't fit in the Value column, this change will also be needed if that window is made resizable in the future.
Code: Select all
diff --git a/src/forge/Gui_CardShop.java b/src/forge/Gui_CardShop.java
index f0c2fe2..dffbe46 100644
--- a/src/forge/Gui_CardShop.java
+++ b/src/forge/Gui_CardShop.java
@@ -34,6 +34,9 @@ import javax.swing.border.Border;
 import javax.swing.border.EtchedBorder;
 import javax.swing.border.TitledBorder;
 import javax.swing.event.MouseInputListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+
 import forge.error.ErrorViewer;
 import forge.gui.game.CardDetailPanel;
 import forge.gui.game.CardPicturePanel;
@@ -62,8 +65,8 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
     private TitledBorder      titledBorder2;
     private JButton           buyButton            = new JButton();
 
-    private JTable            topTable             = new JTable();
-    private JTable            bottomTable          = new JTable();
+    private JTable            topTable;
+    private JTable            bottomTable;
     private JScrollPane       jScrollPane3         = new JScrollPane();
     private JPanel            jPanel3              = new JPanel();
     private GridLayout        gridLayout1          = new GridLayout();
@@ -450,6 +453,31 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
     }
     
     private void jbInit() throws Exception {
+
+               //Replace cell renderer with one that displays the cell text as tooltip.
+               topTable = new JTable(){
+                       public TableCellRenderer getCellRenderer(int row, int column){
+                               TableCellRenderer renderer = new DefaultTableCellRenderer(){
+                                       public String getToolTipText(){
+                                               return this.getText();
+                                       }
+                               };
+                               return renderer;
+                       }
+               };
+
+               bottomTable = new JTable(){
+                       public TableCellRenderer getCellRenderer(int row, int column){
+                               TableCellRenderer renderer = new DefaultTableCellRenderer(){
+                                       public String getToolTipText(){
+                                               return this.getText();
+                                       }
+                               };
+                               return renderer;
+                       }
+               };
+
+
         border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(148, 145, 140));
         titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)),
                 "All Cards");
In general, how are submissions handled? Is submitting individual patches (like above) the right way to get these changes into the repo? Or do developers commit to the repo directly?
Fnoed
 
Posts: 84
Joined: 20 Dec 2010, 01:03
Has thanked: 0 time
Been thanked: 3 times

Re: Some UI fixes

Postby Chris H. » 08 Jan 2011, 15:05

Fnoed wrote:I have made some minor UI improvements to cardforge:
`
In general, how are submissions handled? Is submitting individual patches (like above) the right way to get these changes into the repo? Or do developers commit to the repo directly?
`
Send your google email address to DennisBergkamp via private message and he will give you commit status. This will allow you to merge your work into the SVN for all to enjoy. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Some UI fixes

Postby Chris H. » 10 Jan 2011, 02:26

Fnoed wrote:I have made some minor UI improvements to cardforge:
`
Thank you for your recent commits. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Some UI fixes

Postby Fnoed » 10 Jan 2011, 02:38

I've committed the above changes; thanks to Dennis for adding me to the committers list. All of them are either enhancements or drop-in replacements of the existing UI layout.

I also want to make larger changes to improve the gameplay; but I did not want to start on this before consulting active developers.

The biggest annoyance that I have is that everything in quest mode is done through dialogs instead being in a single frame. Some of the dialogs seem to be unnecessary, too. For example, there is only one purchase per bazaar item; it would make sense to show a single, larger, dialog that contains all of the possible purchases in the bazaar.

What you you guys say if I created a single-frame UI that handles the quest mode? Is it too early to make this change? Would the Shandalar/Adventure mode make this change obsolete?
Fnoed
 
Posts: 84
Joined: 20 Dec 2010, 01:03
Has thanked: 0 time
Been thanked: 3 times

Re: Some UI fixes

Postby Chris H. » 10 Jan 2011, 03:38

Dennis has not added anything to the original or fantasy quest modes since the first half of last year. If he can find any free time he spends it developing a new Shandalar/Adventure quest mode. Sol, Sloth and I added some additional material to the existing quest modes. But we are fairly busy with other parts of the project at this time.

If you come up with any additional improvements for the original or fantasy quest modes it would be appreciated by the user base. There are still a number of people playing these quest modes.

It may be possible to combine some of the dialogs like you suggest into a single window. Forge is designed to use a display which is at least 1024 x 768. What ever you come up with should fit into that area. Resizable windows can be a nice feature in some areas of the game.

I just spent some time with the deck editor code trying to get everything to show up when displayed at the smallest size. It can be tricky. At some point we would like to place all of the different deck editors into a single class. An improvement made to one of them would automatically show up in all of them. :)
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Some UI fixes

Postby Fnoed » 10 Jan 2011, 05:10

Good, in that case I'll start moving some of the quest UI code from dialogs to panels, that way the code can be reused in the adventure mode. I'll do my work in a new package (forge.quest), this way we can have both UI's around for now. (And it'll improve the code layout a bit once the old copy is removed.) I'll add checkbox somewhere to make the new UI visible once it reaches a usable state.
Fnoed
 
Posts: 84
Joined: 20 Dec 2010, 01:03
Has thanked: 0 time
Been thanked: 3 times

Re: Some UI fixes

Postby Fnoed » 10 Jan 2011, 05:20

Hmm... I noticed that you added some serialVersionUID's to the JTables I created. As far as I can see those are throw-away tables that would never be serialized, is there some framework we are using that needs the UIDs?
Fnoed
 
Posts: 84
Joined: 20 Dec 2010, 01:03
Has thanked: 0 time
Been thanked: 3 times

Re: Some UI fixes

Postby Chris H. » 10 Jan 2011, 14:04

Most of the devs are using Eclipse and Eclipse can provide warnings in reference to a number of things. When Rares first released the code as open source Rob and Dennis noticed hundreds of warnings and at that level it can be distracting. :)

Dennis spent some time reducing the number of warnings. By the time he set up the SVN these warnings were removed for the most part. It became a habit to address these from time to time. It is not so much a requirement as it helps to make the code less distracting.

In a similar vein having so many classes in the forge package can also be distracting. Your offer to place your new quest UI work into a forge.quest package is a good solution. Thank you. :)
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Some UI fixes

Postby friarsol » 10 Jan 2011, 14:26

Fnoed,

As Chris says. Do it. For the most part, the active development has been only touching the UI when necessary, as most of use don't have as much experience in the area. So feel free to rewrite, upgrade, create packages, simplify, etc. anything in the UI you can get your hands on.

If you need any specific hooks into the game layer, and can't find them, feel free to ask.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 30 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 30 users online :: 0 registered, 0 hidden and 30 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 30 guests

Login Form