Search in sources :

Example 26 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method refreshTable.

//** Table CoreUtility Functions **
/**  Refreshes the main table to reflect the current data in memory */
public void refreshTable() {
    combatantTable.clearSelection();
    DefaultTableModel model = (DefaultTableModel) combatantTable.getModel();
    model.setNumRows(0);
    int startSelect = -1;
    int rowNum = 0;
    for (int i = 0; i < initList.size(); i++) {
        InitHolder c = initList.get(i);
        if (((c.getStatus() != State.Dead) || showDead.isSelected()) && (!(c instanceof Event) || showEvents.isSelected())) {
            Vector rowVector = initList.getRowVector(i, columnList);
            model.addRow(rowVector);
            int cInit = c.getInitiative().getCurrentInitiative();
            if (cInit == currentInit) {
                if (startSelect == -1) {
                    startSelect = rowNum;
                }
                combatantTable.setRowSelectionInterval(startSelect, rowNum);
            }
            rowNum++;
        }
    }
    refreshEventTab();
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ActionEvent(java.awt.event.ActionEvent) Event(gmgen.plugin.Event) Vector(java.util.Vector) InitHolder(gmgen.plugin.InitHolder)

Example 27 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method saveToDocument.

/**
	 *  Saves the current combatants out to an XML file
	 *
	 *@param  xml            The File to save to
	 *@exception  Exception  XML and file IO exceptions
	 */
private void saveToDocument(File xml) throws IOException {
    Element party = new Element("Party");
    party.setAttribute("filever", "1.0");
    party.setAttribute("filetype", "initsave");
    /*if(currentInit > -1) {
		 party.setAttribute("current_init", Integer.toString(currentInit));
		 }*/
    initList.forEach((InitHolder anInitList) -> party.addContent(anInitList.getSaveElement()));
    XMLOutputter xmlOut = new XMLOutputter();
    xmlOut.setFormat(Format.getRawFormat().setEncoding("US-ASCII"));
    try (Writer fr = new FileWriter(xml)) {
        Document saveDocument = new Document(party);
        xmlOut.output(saveDocument, fr);
        fr.flush();
        fr.close();
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Element(org.jdom2.Element) FileWriter(java.io.FileWriter) Document(org.jdom2.Document) InitHolder(gmgen.plugin.InitHolder) Writer(java.io.Writer) FileWriter(java.io.FileWriter)

Example 28 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class InitiativePlugin method handleInitHolderListSendMessage.

/**
	 * <p>
	 * Handles an {@code InitHolderListSendMessage} by addomg all new
	 * combatants to the views list.
	 * </p>
	 *
	 * @param message
	 */
private void handleInitHolderListSendMessage(TransmitInitiativeValuesBetweenComponentsMessage message) {
    if (message.getSource() != this) {
        InitHolderList cl = message.getInitHolderList();
        for (InitHolder iH : cl) {
            theView.addInitHolder(iH);
        }
        theView.refreshTable();
    }
}
Also used : InitHolderList(gmgen.plugin.InitHolderList) InitHolder(gmgen.plugin.InitHolder)

Example 29 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method stabilizeCombatant.

/**  Stabilizes the selected combatants */
private void stabilizeCombatant() {
    final List<InitHolder> selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            writeToCombatTabWithRound(iH.getName() + " (" + cbt.getPlayer() + ") Stabilized");
            cbt.stabilize();
            combatantUpdated(cbt);
        }
    }
    initList.sort();
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 30 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class GMGenMessageHandler method handleInitHolderListSendMessage.

private void handleInitHolderListSendMessage(TransmitInitiativeValuesBetweenComponentsMessage message) {
    InitHolderList list = message.getInitHolderList();
    for (int i = 0; i < list.size(); i++) {
        InitHolder iH = list.get(i);
        if (iH instanceof PcgCombatant) {
            //TODO: Resolve against the current PC list and add any new characters.
            PcgCombatant pcg = (PcgCombatant) iH;
            PlayerCharacter aPC = pcg.getPC();
            Globals.getPCList().add(aPC);
            aPC.setDirty(true);
        //				addPCTab(aPC);
        }
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) PlayerCharacter(pcgen.core.PlayerCharacter) InitHolderList(gmgen.plugin.InitHolderList) 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