Monday, August 4, 2008

Java: Character Simulator Update #6

Apparently I got a bit carried away with the next round of updates to this application. I decided that the skill calculator should have the option of being a standalone application that doesn't require the user to enter in what equipment they are using. As a result I needed to add another JPanel to the southern portion of the BorderLayout manager. This new JPanel, aptly named plusSkillPanel, is populated with JLabels and JComboBoxes depending on which character was selected.

Since the user will be able to select manually which types of +skill mods are available I needed to be able to keep track of what has been selected. This was done through a new int array variable and a listener that altered the array depending on which JComboBox was changed.

Of course if the skill calculator could be changed to be a standalone program then the equipment and final stats tabbedpanes would need to become hidden at that time. Otherwise the array variable holding the +skill mod values could be altered in both ways and that would lead to incorrect information being displayed. This was done by adding a new menu item, specifically a JCheckBoxMenuItem. When selected the tabbedpanes for final stats and equipment are removed from the program and the plusSkillPanel JPanel is added to the bottom of the application. When it is unchecked all of these changes are reversed.

if(event.getActionCommand().compareTo(STAND) == 0){ //standalone menuitem pressed
if (standaloneMenuItem.getState() == false){
tabbedPane.insertTab("Final Stats", null, new Stats(), null, 0);
Stats.SetCharType();

tabbedPane.insertTab("Equipment", null, new Equipment(), null, 1);

Skills.plusSkillPanel.removeAll();

Once that was completed it was time to work on the calculations and displays of the skills. There are seven characters with thirty skills apiece, that's 210 skills overall and each has it's own method calculating the value dependent on what level is selected for the skill. When calculating these skill values the synergies had to be taken into account as well, so the calculates are a bit lengthy, but not too complex.

First the String variable that holds the description of the skill's value is set to a null string just in case any previous data had been present. After that the method checks if the skill itself has either any hard points assigned or is gaining any points from equipment (which of course doesn't work in standalone mode). If points are in the skill then the String variable is altered to continue all of the values of the skill in question, calculated with synergies being taken into account as well as +skill mods. Then the String variable is set as the ToolTip for the JComboBox of the skill.

Along with this ToolTip a second tip was created that resides on the JLabel of each skill. Specifically this ToolTip is assigned in the constructor and is a text description of what the skill does exactly.

Each of these changes had to be made for all 210 skills, and after a while became very tedious. However it is all done and the skill calculator does work as intended, with a few updates necessary. Specifically:

1. Update the skill text files to hold data for skill values up to 55
2. Fix bug where JComboBox ToolTip is not updated when a synergies skill is changed
3. Fix bug where when switch between characters the SkillPanel panel is repopulated even when the application is set to standalone mode, where only the skill calculator Tabbedpane is visible

No comments: