mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-09-28 20:54:46 +00:00
Merge branch 'master' of https://github.com/badvision/lawless-legends
This commit is contained in:
commit
c1102dbf1f
@ -25,7 +25,6 @@ import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.MapEditor;
|
||||
import org.badvision.outlaweditor.TransferHelper;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
|
@ -19,7 +19,10 @@ import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
@ -28,17 +31,23 @@ import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableRow;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.converter.DefaultStringConverter;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import org.badvision.outlaweditor.SheetEditor;
|
||||
import org.badvision.outlaweditor.TransferHelper;
|
||||
import org.badvision.outlaweditor.data.DataUtilities;
|
||||
import static org.badvision.outlaweditor.data.DataUtilities.getValue;
|
||||
import static org.badvision.outlaweditor.data.DataUtilities.setValue;
|
||||
import org.badvision.outlaweditor.data.xml.Columns;
|
||||
import org.badvision.outlaweditor.data.xml.Rows;
|
||||
import org.badvision.outlaweditor.data.xml.Rows.Row;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.UserType;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
import org.badvision.outlaweditor.ui.SheetEditorController;
|
||||
@ -59,6 +68,21 @@ public class SheetEditorControllerImpl extends SheetEditorController {
|
||||
tableData = FXCollections.observableArrayList();
|
||||
table.setItems(tableData);
|
||||
table.setEditable(true);
|
||||
table.setRowFactory(tableView -> {
|
||||
final TableRow<Row> row = new TableRow<>();
|
||||
|
||||
final ContextMenu contextMenu = new ContextMenu(
|
||||
createMenuItem("Insert Row", () -> tableData.add(row.getIndex(), new Row())),
|
||||
createMenuItem("Clone Row", () -> cloneRow(row.getItem())),
|
||||
createMenuItem("Delete Row", () -> deleteRowWithConfirmation(row.getItem()))
|
||||
);
|
||||
row.contextMenuProperty().bind(
|
||||
Bindings.when(row.emptyProperty())
|
||||
.then((ContextMenu) null)
|
||||
.otherwise(contextMenu)
|
||||
);
|
||||
return row;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -231,6 +255,19 @@ public class SheetEditorControllerImpl extends SheetEditorController {
|
||||
return colNumber;
|
||||
}
|
||||
|
||||
private void deleteRowWithConfirmation(Row row) {
|
||||
UIAction.confirm("Delete row, are you sure?", ()->tableData.remove(row), ()->{});
|
||||
}
|
||||
|
||||
private void cloneRow(Row row) {
|
||||
try {
|
||||
Row newRow = TransferHelper.cloneObject(row, Row.class, "row");
|
||||
tableData.add(tableData.lastIndexOf(row), newRow);
|
||||
} catch (JAXBException ex) {
|
||||
Logger.getLogger(SheetEditorControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncData() {
|
||||
if (editor.getSheet().getRows() == null) {
|
||||
editor.getSheet().setRows(new Rows());
|
||||
|
@ -204,51 +204,55 @@
|
||||
<block type="text_getstring"></block>
|
||||
</value>
|
||||
<next>
|
||||
<block inline="false" type="controls_if">
|
||||
<mutation else="1"></mutation>
|
||||
<value name="IF0">
|
||||
<block inline="true" type="logic_compare">
|
||||
<field name="OP">EQ</field>
|
||||
<value name="A">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">response</field>
|
||||
<block type="text_clear_window">
|
||||
<next>
|
||||
<block inline="false" type="controls_if">
|
||||
<mutation else="1"></mutation>
|
||||
<value name="IF0">
|
||||
<block inline="true" type="logic_compare">
|
||||
<field name="OP">EQ</field>
|
||||
<value name="A">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">response</field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="B">
|
||||
<block type="text">
|
||||
<field name="TEXT">correct response</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
</value>
|
||||
<value name="B">
|
||||
<block type="text">
|
||||
<field name="TEXT">correct response</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
</value>
|
||||
<statement name="DO0">
|
||||
<block inline="false" type="text_print">
|
||||
<value name="VALUE">
|
||||
<block type="text">
|
||||
<field name="TEXT">Affirmative Response</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="text_getanykey"></block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
<statement name="ELSE">
|
||||
<block inline="false" type="text_print">
|
||||
<value name="VALUE">
|
||||
<block type="text">
|
||||
<field name="TEXT">Negative Response</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="text_getanykey">
|
||||
<statement name="DO0">
|
||||
<block inline="false" type="text_print">
|
||||
<value name="VALUE">
|
||||
<block type="text">
|
||||
<field name="TEXT">Affirmative Response</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="events_move_backward"></block>
|
||||
<block type="text_getanykey"></block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</statement>
|
||||
<statement name="ELSE">
|
||||
<block inline="false" type="text_print">
|
||||
<value name="VALUE">
|
||||
<block type="text">
|
||||
<field name="TEXT">Negative Response</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="text_getanykey">
|
||||
<next>
|
||||
<block type="events_move_backward"></block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
</statement>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
@ -424,13 +428,18 @@
|
||||
<next>
|
||||
<block inline="false" type="controls_if">
|
||||
<value name="IF0">
|
||||
<block type="interaction_has_item">
|
||||
<field name="NAME"></field>
|
||||
</block>
|
||||
<block type="text_getboolean"></block>
|
||||
</value>
|
||||
<statement name="DO0">
|
||||
<block inline="false" type="controls_if">
|
||||
<mutation else="1"></mutation>
|
||||
<value name="IF0">
|
||||
<block type="interaction_has_item">
|
||||
<field name="NAME"></field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="IF0">
|
||||
</value>
|
||||
<statement name="DO0">
|
||||
<block type="text_clear_window">
|
||||
<next>
|
||||
|
Loading…
Reference in New Issue
Block a user