Friday, September 5, 2008

Java: Character Simulator Update #7

Three pieces were planned on being completed for the next update. 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

The first piece required the most amount of time and was mind-numbingly boring. It basically consisted of me updating text files with the information of each skill level. Some of the skills were fairly easy to do as the skill values progressed at a steady pace. In this regards the Barbarian class is my favorite. However other skills, such as Plague Javelin for the Amazon, increased exponentially and therefore required far more time to update. Thankfully that is done and hopefully all of the data was entered correctly, as finding a mistake will be rather difficult. I will spot check a few skills and compare my results to that of another skill calculator, but I will not be checking every single skill and synergy.

Fixing the ToolTip on the JComboBox to update when synergies are updated was fairly simple. I had Listeners set to update the calculations and tooltips for each category, such as Necromancer Curses. However some synergies are outside of the skill's category, so I expanded the update to include all tooltips rather than just the category's ten. To accomplish this I created a new method, RecalculateSkills, that was called at the end of each JPanel listener.

Lastly I wanted to fix the bug where when the Skill Calculator is not set to act in standalone mode the SkillPanel containing the JComboBoxes for selecting plus skill values is not removed correctly. When the standalone mode is turned off the initial SkillPanel is removed, but when a different character class is chosen then their corresponding SkillPanel appears. To bypass this a single line of code was required.

if (CharSi.standaloneMenuItem.getState() == true)

This is called just before the SkillPanel method is called, so that if the Skill Calculator is to act in standalone mode then the method is utilized, otherwise it is not.

Originally I had thought that after making these changes I would be done with the Skill Calculator and could move on to the next piece of the application. However upon further consideration I've decided to add two additional pieces.

1. Create Clear All skill selections button
2. Synergy information in skill description tooltips

Creating the Clear All button was the easy part. Simply add the JButton component at the end of the selectionPanel. A few JLabels full of spaces were added to ensure the original components stayed where they were and the JButton was placed in the upper right corner of the application window. Getting the listener to act properly was a bit tougher.

A difference instance for each character type was created inside of the listener. Within each instance a few things had to be altered. First the arrays that help plus skill values were zeroed out using For loops. Then the JComboBoxes had to be reset to index zero. It was this step that caused quite a few problems. When a JComboBox that has a requirement is set to zero this caused the JOptionPane error message to appear, regardless of which order the JComboBoxes were reset. In the end I had to create a new variable that would be a specific value inside of the Skills class Button listener. Then the character JPanel listeners were ignored if the new variable was this specific value.

if (Skills.clearing == 1)
return;

'Clearing' being the variable in question and the above code is executed first in each listener. This ensured the requirement error doesn't appear multiple times when the Clear All button was pressed.

As for including the Synergy information into the tiptool of the JLabel, no problem. All of the information was already in the description of the corresponding calculator method. It simply had to be copied over.

This leaves the Skill Calculator portion of the application basically complete. Some minor word changes or correction of typos may occur but it is fully functional and ready to use. Now I just need to create an icon for it and generate the necessary executable file.

No comments: