-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
248 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package StellarisDK.FileClasses; | ||
|
||
import StellarisDK.FileClasses.Helper.DataEntry; | ||
import StellarisDK.FileClasses.Helper.DataMap; | ||
import StellarisDK.FileClasses.Helper.EntryArrayList; | ||
import StellarisDK.GUI.AttitudeUI; | ||
|
||
import java.util.Arrays; | ||
|
||
public class Attitude extends GenericData { | ||
|
||
public Attitude() { | ||
super(); | ||
this.type = new DataEntry("new_attitude"); | ||
data.put("behaviour", new EntryArrayList<>(Arrays.asList(new DataMap()))); | ||
ui = new AttitudeUI(this); | ||
} | ||
|
||
public Attitude(String input, String type) { | ||
super(input, type); | ||
ui = new AttitudeUI(this); | ||
} | ||
|
||
@Override | ||
public GenericData createNew() { | ||
return new Attitude(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package StellarisDK.GUI; | ||
|
||
import StellarisDK.FileClasses.Attitude; | ||
import StellarisDK.FileClasses.Helper.DataEntry; | ||
import StellarisDK.FileClasses.Helper.DataMap; | ||
import StellarisDK.FileClasses.Helper.EntryArrayList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.CheckBox; | ||
import javafx.scene.control.TextField; | ||
|
||
public class AttitudeUI extends AbstractUI { | ||
|
||
@FXML | ||
private TextField type; | ||
|
||
@FXML | ||
private CheckBox attack; | ||
|
||
@FXML | ||
private CheckBox weaken; | ||
|
||
@FXML | ||
private CheckBox alliance; | ||
|
||
@FXML | ||
private CheckBox vassalize; | ||
|
||
@FXML | ||
private CheckBox trade; | ||
|
||
@FXML | ||
private CheckBox coexist; | ||
|
||
public AttitudeUI(Attitude obj) { | ||
init("FXML/attitudeFX.fxml"); | ||
window.setText("Attitude Editor"); | ||
this.obj = obj; | ||
} | ||
|
||
@Override | ||
public void load() { | ||
type.setText(obj.getFirstString(type.getId())); | ||
DataMap temp = (DataMap)((DataEntry)obj.getFirstValue("behaviour")).getValue(); | ||
if (temp.get(attack.getId()) != null && ((DataEntry)temp.getFirstValue(attack.getId())).getValue().toString().toLowerCase().equals("yes")) { | ||
attack.setSelected(true); | ||
} else { | ||
attack.setSelected(false); | ||
} | ||
if (temp.get(weaken.getId()) != null && ((DataEntry)temp.getFirstValue(weaken.getId())).getValue().toString().toLowerCase().equals("yes")) { | ||
weaken.setSelected(true); | ||
} else { | ||
weaken.setSelected(false); | ||
} | ||
if (temp.get(alliance.getId()) != null && ((DataEntry)temp.getFirstValue(alliance.getId())).getValue().toString().toLowerCase().equals("yes")) { | ||
alliance.setSelected(true); | ||
} else { | ||
alliance.setSelected(false); | ||
} | ||
if (temp.get(vassalize.getId()) != null && ((DataEntry)temp.getFirstValue(vassalize.getId())).getValue().toString().toLowerCase().equals("yes")) { | ||
vassalize.setSelected(true); | ||
} else { | ||
vassalize.setSelected(false); | ||
} | ||
if (temp.get(trade.getId()) != null && ((DataEntry)temp.getFirstValue(trade.getId())).getValue().toString().toLowerCase().equals("yes")) { | ||
trade.setSelected(true); | ||
} else { | ||
trade.setSelected(false); | ||
} | ||
if (temp.get(coexist.getId()) != null && ((DataEntry)temp.getFirstValue(coexist.getId())).getValue().toString().toLowerCase().equals("yes")) { | ||
coexist.setSelected(true); | ||
} else { | ||
coexist.setSelected(false); | ||
} | ||
} | ||
|
||
@Override | ||
public Object save() { | ||
DataMap temp = (DataMap)((DataEntry)obj.getFirstValue("behaviour")).getValue(); | ||
if(type.getText() == null || type.getText().equals("")){ | ||
obj.setValue(type.getId(), "Unnamed Object", true, 0); | ||
} else { | ||
obj.setValue(type.getId(), type.getText(), true, 0); | ||
} | ||
int size = 0; | ||
if (attack.isSelected()) { | ||
temp.put(attack.getId(), new EntryArrayList<>(new DataEntry<>(attack.getId(), "yes", size++, 1110))); | ||
}else{ | ||
temp.remove(attack.getId()); | ||
} | ||
if (weaken.isSelected()) { | ||
temp.put(weaken.getId(), new EntryArrayList<>(new DataEntry<>(weaken.getId(), "yes", size++, 1110))); | ||
}else{ | ||
temp.remove(weaken.getId()); | ||
} | ||
if (alliance.isSelected()) { | ||
temp.put(alliance.getId(), new EntryArrayList<>(new DataEntry<>(alliance.getId(), "yes", size++, 1110))); | ||
}else{ | ||
temp.remove(alliance.getId()); | ||
} | ||
if (vassalize.isSelected()) { | ||
temp.put(vassalize.getId(), new EntryArrayList<>(new DataEntry<>(vassalize.getId(), "yes", size++, 1110))); | ||
}else{ | ||
temp.remove(vassalize.getId()); | ||
} | ||
if (trade.isSelected()) { | ||
temp.put(trade.getId(), new EntryArrayList<>(new DataEntry<>(trade.getId(), "yes", size++, 1110))); | ||
}else{ | ||
temp.remove(trade.getId()); | ||
} | ||
if (coexist.isSelected()) { | ||
temp.put(coexist.getId(), new EntryArrayList<>(new DataEntry<>(coexist.getId(), "yes", size++, 1110))); | ||
}else{ | ||
temp.remove(coexist.getId()); | ||
} | ||
|
||
System.out.println(obj.export()); | ||
itemView.refresh(); | ||
return obj; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.*?> | ||
<?import javafx.scene.layout.*?> | ||
<AnchorPane fx:id="main" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<children> | ||
<GridPane layoutX="10.0" layoutY="10.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0"> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="SOMETIMES" minWidth="110.0" /> | ||
<ColumnConstraints hgrow="SOMETIMES" /> | ||
<ColumnConstraints hgrow="SOMETIMES" /> | ||
</columnConstraints> | ||
<rowConstraints> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||
</rowConstraints> | ||
<children> | ||
<Label text="Attitude Name" /> | ||
<TextField id="type" fx:id="type" GridPane.columnIndex="2" /> | ||
<CheckBox id="attack" fx:id="attack" mnemonicParsing="false" text="Attack" GridPane.rowIndex="1" /> | ||
<Button id="btn_save" fx:id="btn_save" mnemonicParsing="false" text="Save" GridPane.columnIndex="2" GridPane.halignment="RIGHT" GridPane.rowIndex="5" /> | ||
<CheckBox id="weaken" fx:id="weaken" mnemonicParsing="false" text="Weaken" GridPane.columnIndex="2" GridPane.rowIndex="1" /> | ||
<CheckBox id="alliance" fx:id="alliance" mnemonicParsing="false" text="Alliance" GridPane.rowIndex="2" /> | ||
<CheckBox id="vassalize" fx:id="vassalize" mnemonicParsing="false" text="Vassalize" GridPane.columnIndex="2" GridPane.rowIndex="2" /> | ||
<CheckBox id="trade" fx:id="trade" mnemonicParsing="false" text="Trade" GridPane.rowIndex="4" /> | ||
<CheckBox id="coexist" fx:id="coexist" mnemonicParsing="false" text="Coexist" GridPane.columnIndex="2" GridPane.rowIndex="4" /> | ||
</children> | ||
</GridPane> | ||
</children> | ||
<padding> | ||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> | ||
</padding> | ||
</AnchorPane> |
Oops, something went wrong.