Search in sources :

Example 1 with InitHolder

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();
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) RequestToSavePlayerCharacterMessage(pcgen.pluginmgr.messages.RequestToSavePlayerCharacterMessage) InitHolder(gmgen.plugin.InitHolder)

Example 2 with InitHolder

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);
            }
        }
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) SpellModel(plugin.initiative.SpellModel) DiceRollModel(plugin.initiative.DiceRollModel) PObjectModel(plugin.initiative.PObjectModel) SaveModel(plugin.initiative.SaveModel) AttackModel(plugin.initiative.AttackModel) CheckModel(plugin.initiative.CheckModel) InitHolder(gmgen.plugin.InitHolder)

Example 3 with InitHolder

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();
}
Also used : InitHolder(gmgen.plugin.InitHolder) IOException(java.io.IOException)

Example 4 with InitHolder

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();
}
Also used : InitHolder(gmgen.plugin.InitHolder)

Example 5 with InitHolder

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();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Aggregations

InitHolder (gmgen.plugin.InitHolder)31 PcgCombatant (gmgen.plugin.PcgCombatant)18 XMLCombatant (plugin.initiative.XMLCombatant)13 Combatant (gmgen.plugin.Combatant)11 InitHolderList (gmgen.plugin.InitHolderList)7 ArrayList (java.util.ArrayList)7 Event (gmgen.plugin.Event)6 ActionEvent (java.awt.event.ActionEvent)6 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 ListSelectionEvent (javax.swing.event.ListSelectionEvent)6 List (java.util.List)5 Vector (java.util.Vector)2 Element (org.jdom2.Element)2 SaveModel (plugin.initiative.SaveModel)2 Spell (gmgen.plugin.Spell)1 SystemHP (gmgen.plugin.SystemHP)1 SystemInitiative (gmgen.plugin.SystemInitiative)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1