use of gmgen.plugin.InitHolder in project pcgen by PCGen.
the class InitiativePlugin method fileSave.
/**
* <p>
* Saves the combatants to a file
* </p>
*/
private void fileSave() {
for (int i = 0; i < theView.initList.size(); i++) {
InitHolder iH = theView.initList.get(i);
if (iH instanceof PcgCombatant) {
PcgCombatant pcgcbt = (PcgCombatant) iH;
messageHandler.handleMessage(new RequestToSavePlayerCharacterMessage(this, pcgcbt.getPC()));
}
}
theView.saveToFile();
}
use of gmgen.plugin.InitHolder in project pcgen by PCGen.
the class Initiative method hyperLinkSelected.
/**
* <p>Called when a hyperlink is selected in one of the text panes in {@code tpaneInfo}.
* Used to generate attack/skill, etc. dialogs.</p>
*
* @param e {@code HyperLinkEvent} that called this method.
* @param cbt {@code PcgCombatant} to perform action for.
*/
private void hyperLinkSelected(HyperlinkEvent e, InitHolder cbt) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
PObjectModel model = PObjectModel.Factory(e.getDescription());
if (model != null) {
if ((model instanceof AttackModel) && (cbt instanceof PcgCombatant)) {
InitHolder pcgcbt = cbt;
performAttack((AttackModel) model, pcgcbt);
} else if (model instanceof CheckModel) {
performCheck((CheckModel) model);
} else if (model instanceof SpellModel) {
castSpell((SpellModel) model, cbt);
} else if (model instanceof SaveModel) {
performSave((SaveModel) model, cbt);
} else if ((model instanceof DiceRollModel) && (cbt instanceof PcgCombatant)) {
performDiceRoll((DiceRollModel) model);
}
}
}
}
use of gmgen.plugin.InitHolder in project pcgen by PCGen.
the class Initiative method deleteCombatant.
/** Deletes the selected combatants from the Init List */
private void deleteCombatant() {
final List<InitHolder> selectedList = getSelected();
while (!selectedList.isEmpty()) {
try {
InitHolder iH = selectedList.remove(0);
initList.remove(iH);
removeTab(iH);
} catch (Exception e) {
// TODO: Exception Needs to be handled
}
}
initList.sort();
refreshTable();
}
use of gmgen.plugin.InitHolder in project pcgen by PCGen.
the class Initiative method startEvent.
/** Calls up the CastSpell dialog, passing in the data for the first selected combatant, if there is one*/
private void startEvent() {
final List<InitHolder> selectedList = getSelected();
while (!selectedList.isEmpty()) {
InitHolder iH = selectedList.remove(0);
StartEvent dialog = new StartEvent(JOptionPane.getFrameForComponent(this), true, this, iH.getPlayer(), iH.getInitiative().getCurrentInitiative());
dialog.setVisible(true);
refreshTable();
return;
}
initList.sort();
refreshTable();
StartEvent dialog = new StartEvent(JOptionPane.getFrameForComponent(this), true, this);
dialog.setVisible(true);
refreshTable();
}
use of gmgen.plugin.InitHolder in project pcgen by PCGen.
the class Initiative method editTable.
// TODO Change the Status to be a drop down list rather than a text field.
private void editTable(int row, int column) {
// Figure out which row is the active row
// Karianna - Commented out this section to fix bug
/*
int activeRow = 0;
for (int i = 0; i < initList.size(); i++)
{
InitHolder c = initList.get(i);
// IF the InitHolder status is not Dead or showDead is selected (e.g. InitHolder is alive or we're showeing the dead)
// AND InitHolder is not an Event or we're shoeing events
// THEN update the active row
if ((c.getStatus() != Status.Dead || showDead.isSelected())
&& (!(c instanceof Event) || showEvents.isSelected()))
{
activeRow++;
}
}
*/
// Look up the active row (-1 as arrays are indexed starting at 0)
//InitHolder iH = initList.get(activeRow - 1);
InitHolder iH = initList.get(row);
String oldName = iH.getName();
Object data = combatantTable.getValueAt(row, column);
boolean atTop = (currentInit == initList.getMaxInit());
iH.editRow(columnList, column, data);
if (!iH.getName().equals(oldName) && (iH instanceof Combatant)) {
removeTab(oldName);
addTab((Combatant) iH);
}
initHolderUpdated(iH);
initList.sort();
if (atTop) {
setCurrentInit(initList.getMaxInit());
}
refreshTable();
}
Aggregations