|
From: <boo...@us...> - 2006-11-22 03:56:38
|
Revision: 1685
http://svn.sourceforge.net/pcgen/?rev=1685&view=rev
Author: boomer70
Date: 2006-11-21 19:56:37 -0800 (Tue, 21 Nov 2006)
Log Message:
-----------
Added support for:
* random description tab stuff
* random name selection
Modified Paths:
--------------
Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java
Trunk/pcgen/code/src/java/pcgen/gui/NPCGeneratorDlg.java
Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.java
Modified: Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java 2006-11-22 02:34:59 UTC (rev 1684)
+++ Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java 2006-11-22 03:56:37 UTC (rev 1685)
@@ -36,6 +36,7 @@
import pcgen.core.Domain;
import pcgen.core.GameMode;
import pcgen.core.Globals;
+import pcgen.core.Names;
import pcgen.core.PCAlignment;
import pcgen.core.PCClass;
import pcgen.core.PCStat;
@@ -44,11 +45,14 @@
import pcgen.core.RuleConstants;
import pcgen.core.SettingsHandler;
import pcgen.core.Skill;
+import pcgen.core.SystemCollections;
import pcgen.core.character.CharacterSpell;
import pcgen.core.pclevelinfo.PCLevelInfo;
import pcgen.core.prereq.PrereqHandler;
import pcgen.core.spell.Spell;
import pcgen.core.system.GameModeRollMethod;
+import pcgen.gui.NameElement;
+import pcgen.util.Delta;
import pcgen.util.Logging;
import pcgen.util.WeightedList;
import pcgen.util.chooser.ChooserFactory;
@@ -469,7 +473,7 @@
}
final Domain domain = domains.getRandomValue();
final WeightedList<Spell> domainSpells = new WeightedList<Spell>(Globals.getSpellsIn(aLevel, Constants.EMPTY_STRING, domain.getKeyName()));
- selectSpell( aPC, aClass, domain, "Prepared Spells", domainSpells, aLevel );
+ selectSpell( aPC, aClass, domain, "Prepared Spells", domainSpells, aLevel ); //$NON-NLS-1$
}
private void selectSpell( final PlayerCharacter aPC, final PCClass aClass, final Domain aDomain, final String aBookName, final WeightedList<Spell> aSpellList, final int aLevel )
@@ -526,7 +530,8 @@
final GenderGeneratorOption aGender,
final List<ClassGeneratorOption> classList,
final List<LevelGeneratorOption> levels,
- final GameModeRollMethod aRollMethod)
+ final GameModeRollMethod aRollMethod,
+ final NameElement nameChoice)
{
// Force a more quiet process
final String oldChooser = ChooserFactory.getInterfaceClassname();
@@ -705,7 +710,38 @@
}
}
}
+ final String randBioString = "EYES.HAIR.SKIN.HT.WT.AGE."; //$NON-NLS-1$
+ Globals.getBioSet().randomize(randBioString, aPC);
+
+ final List<String> globalHairStyleList = SystemCollections.getUnmodifiableHairStyleList();
+ aPC.setHairStyle(globalHairStyleList.get(Globals.getRandomInt(globalHairStyleList.size())));
+ final List<String> speechList = SystemCollections.getUnmodifiableSpeechList();
+ aPC.setSpeechTendency(speechList.get(Globals.getRandomInt(speechList.size())));
+ final List<String> globalPhobiaList = SystemCollections.getUnmodifiablePhobiaList();
+ aPC.setPhobias(globalPhobiaList.get(Globals.getRandomInt(globalPhobiaList.size())));
+ final List<String> globalInterestsList = SystemCollections.getUnmodifiableInterestsList();
+ aPC.setInterests(globalInterestsList.get(Globals.getRandomInt(globalInterestsList.size())));
+ final List<String> globalPhraseList = SystemCollections.getUnmodifiablePhraseList();
+ aPC.setCatchPhrase(globalPhraseList.get(Globals.getRandomInt(globalPhraseList.size())));
+ final List<String> globalTraitList = SystemCollections.getUnmodifiableTraitList();
+ aPC.setTrait1(globalTraitList.get(Globals.getRandomInt(globalTraitList.size())));
+ aPC.setTrait2(globalTraitList.get(Globals.getRandomInt(globalTraitList.size())));
+
+ final List<String> globalCityList = SystemCollections.getUnmodifiableCityList();
+ aPC.setResidence(globalCityList.get(Globals.getRandomInt(globalCityList.size())));
+ final List<String> globalLocationList = SystemCollections.getUnmodifiableLocationList();
+ aPC.setLocation(globalLocationList.get(Globals.getRandomInt(globalLocationList.size())));
+ final List<String> globalBirthplaceList = SystemCollections.getUnmodifiableBirthplaceList();
+ aPC.setBirthplace(globalBirthplaceList.get(Globals.getRandomInt(globalBirthplaceList.size())));
+
+ final Names nameGen = Names.getInstance();
+ nameGen.init(nameChoice, aPC);
+ aPC.setName(nameGen.getRandomName());
}
+ catch (Exception e)
+ {
+ Logging.errorPrint("Problem generation NPC", e);
+ }
finally
{
SettingsHandler.setShowHPDialogAtLevelUp(tempShowHP);
Modified: Trunk/pcgen/code/src/java/pcgen/gui/NPCGeneratorDlg.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui/NPCGeneratorDlg.java 2006-11-22 02:34:59 UTC (rev 1684)
+++ Trunk/pcgen/code/src/java/pcgen/gui/NPCGeneratorDlg.java 2006-11-22 03:56:37 UTC (rev 1685)
@@ -32,6 +32,7 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.swing.Box;
@@ -45,6 +46,7 @@
import pcgen.core.Constants;
import pcgen.core.GameMode;
+import pcgen.core.Names;
import pcgen.core.SettingsHandler;
import pcgen.core.npcgen.AlignGeneratorOption;
import pcgen.core.npcgen.ClassGeneratorOption;
@@ -77,17 +79,17 @@
@SuppressWarnings("serial")
public class NPCGeneratorDlg extends JDialog
{
- JButton okButton = new JButton();
- JButton cancelButton = new JButton();
- JComboBox alignCombo = new JComboBox();
- JComboBox raceCombo = new JComboBox();
- JButton editRace = new JButton();
- JButton editAlign = new JButton();
- JButton editGender = new JButton();
- JComboBox genderCombo = new JComboBox();
+ private JButton okButton = new JButton();
+ private JButton cancelButton = new JButton();
+ private JComboBox alignCombo = new JComboBox();
+ private JComboBox raceCombo = new JComboBox();
+ private JButton editRace = new JButton();
+ private JButton editAlign = new JButton();
+ private JButton editGender = new JButton();
+ private JComboBox genderCombo = new JComboBox();
- JButton editStats = new JButton();
- JComboBox statsCombo = new JComboBox();
+ private JButton editStats = new JButton();
+ private JComboBox statsCombo = new JComboBox();
public static final int OK_BUTTON = 1;
public static final int CANCEL_BUTTON = 0;
@@ -102,9 +104,11 @@
private static final int MAX_CLASSES = 3;
- JComboBox[] classCombos = new JComboBox[MAX_CLASSES];
- JComboBox[] lvlCombos = new JComboBox[MAX_CLASSES];
+ private JComboBox[] classCombos = new JComboBox[MAX_CLASSES];
+ private JComboBox[] lvlCombos = new JComboBox[MAX_CLASSES];
+ private JComboBox nameCombo = new JComboBox();
+
public NPCGeneratorDlg(final Frame owner, final String title, final boolean modal)
{
super(owner, title, modal);
@@ -168,6 +172,11 @@
return theRollMethod;
}
+ public NameElement getNameChoice()
+ {
+ return (NameElement)nameCombo.getSelectedItem();
+ }
+
private void okActionPerformed()
{
if (okButton.isEnabled())
@@ -318,6 +327,16 @@
workPanel.add(statsPanel);
+ final JPanel namePanel = new JPanel();
+ final JLabel nameLabel = new JLabel("Name Set:");
+
+ nameCombo.setMinimumSize(new Dimension(210, 19));
+ nameCombo.setPreferredSize(new Dimension(210, 19));
+ namePanel.add(nameLabel);
+ namePanel.add(nameCombo);
+
+ workPanel.add(namePanel);
+
mainPanel.add(workPanel, java.awt.BorderLayout.CENTER);
// Create the Button panel
@@ -422,5 +441,13 @@
statsCombo.addItem(rm);
rm = gameMode.getRollingMethod(++gmi);
}
+
+ List<NameElement> allNamesFiles = Names.findAllNamesFiles();
+ Collections.sort(allNamesFiles);
+
+ for (int i = 0; i < allNamesFiles.size(); i++)
+ {
+ nameCombo.addItem(allNamesFiles.get(i));
+ }
}
}
Modified: Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.java 2006-11-22 02:34:59 UTC (rev 1684)
+++ Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.java 2006-11-22 03:56:37 UTC (rev 1685)
@@ -1279,7 +1279,8 @@
npcgen.generate(pc, genDlg.getAlignment(),
genDlg.getRace(), genDlg.getGender(),
genDlg.getClassList(), genDlg.getLevels(),
- genDlg.getRollMethod());
+ genDlg.getRollMethod(),
+ genDlg.getNameChoice());
Globals.getPCList().add(pc);
Globals.setCurrentPC(pc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|