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();
}
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();
}
}
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();
}
}
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();
}
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);
}
}
}
Aggregations