Skip to content

Commit

Permalink
Updated default editor
Browse files Browse the repository at this point in the history
Can now actually edit the entire entry instead of the value (oops)
Testing required entries for newly created items, should require less reference to game files after completion.
  • Loading branch information
rexc159 committed Mar 10, 2018
1 parent 78129f4 commit c2a06e3
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 12 deletions.
34 changes: 34 additions & 0 deletions src/StellarisDK/FileClasses/Agenda.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package StellarisDK.FileClasses;

import StellarisDK.GUI.AgendaUI;
import javafx.scene.control.TreeItem;

public class Agenda extends GenericData {

private String[] requiredSet = {"weight_modifier", "modifier"};

public Agenda() {
super();
this.type = "agenda";
ui = new AgendaUI(this);
}

public Agenda(String input, String type) {
super(input, type);
ui = new AgendaUI(this);
}

@Override
public TreeItem getRequiredTreeSet(){
TreeItem root = new TreeItem<>("agenda");
for(String set : requiredSet){
root.getChildren().addAll(new TreeItem<>(set));
}
return root;
}

@Override
public GenericData createNew() {
return new Agenda();
}
}
6 changes: 6 additions & 0 deletions src/StellarisDK/FileClasses/AmbientObject.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package StellarisDK.FileClasses;

import StellarisDK.GUI.AmbientObjectUI;
import javafx.scene.control.TreeItem;

public class AmbientObject extends GenericData {

Expand All @@ -20,4 +21,9 @@ public AmbientObject(String input) {
public GenericData createNew() {
return new AmbientObject();
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}
}
6 changes: 6 additions & 0 deletions src/StellarisDK/FileClasses/Anomaly/Anomaly.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import StellarisDK.FileClasses.GenericData;
import StellarisDK.GUI.AnomalyUI;
import javafx.scene.control.TreeItem;

public class Anomaly extends GenericData {

Expand All @@ -21,4 +22,9 @@ public Anomaly(String input) {
public GenericData createNew() {
return new Anomaly();
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}
}
6 changes: 6 additions & 0 deletions src/StellarisDK/FileClasses/Anomaly/AnomalyCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import StellarisDK.FileClasses.GenericData;
import StellarisDK.GUI.AnomalyCategoryUI;
import javafx.scene.control.TreeItem;

public class AnomalyCategory extends GenericData {
public AnomalyCategory() {
Expand All @@ -20,4 +21,9 @@ public AnomalyCategory(String input) {
public GenericData createNew() {
return new AnomalyCategory();
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}
}
6 changes: 6 additions & 0 deletions src/StellarisDK/FileClasses/Component/CompSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import StellarisDK.FileClasses.GenericData;
import StellarisDK.GUI.CompSetUI;
import javafx.scene.control.TreeItem;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -83,6 +84,11 @@ public String export() {
"}\n";
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}

@Override
public String toString() {
return key != null ? key : name;
Expand Down
6 changes: 6 additions & 0 deletions src/StellarisDK/FileClasses/Component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import StellarisDK.FileClasses.GenericData;
import StellarisDK.GUI.CompUI;
import javafx.scene.control.TreeItem;

public class Component extends GenericData {

Expand Down Expand Up @@ -50,4 +51,9 @@ public Component createNew() {
public String getGroup() {
return data.get("component_set").toString();
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}
}
3 changes: 3 additions & 0 deletions src/StellarisDK/FileClasses/DataParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public static ArrayList<TreeItem> parseAll(File file) throws IOException {
String tabby = obj.group(2).replaceAll(" {4}", "\t");
GenericData gData;
switch (obj.group(1)) {
case "agenda":
gData = new Agenda(tabby, obj.group(1));
break;
case "country_event":
gData = new Event(tabby);
break;
Expand Down
6 changes: 6 additions & 0 deletions src/StellarisDK/FileClasses/Event.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package StellarisDK.FileClasses;

import StellarisDK.GUI.EventUI;
import javafx.scene.control.TreeItem;

public class Event extends GenericData {

Expand All @@ -22,4 +23,9 @@ public Event(String input) {
public GenericData createNew() {
return new Event();
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}
}
6 changes: 6 additions & 0 deletions src/StellarisDK/FileClasses/GenericData.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public void setType(String type){
this.type = type;
}

public int getSize(){
return data.getFullSize();
}

public abstract TreeItem getRequiredTreeSet();

public static int getTab() {
return tab;
}
Expand Down
13 changes: 2 additions & 11 deletions src/StellarisDK/FileClasses/Helper/DataCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ public DataCell() {
public void startEdit() {
super.startEdit();
if (textField == null) {
if (getItem() instanceof String) {
textField = new TextField(getItem().toString());
} else {
textField = new TextField(((VPair) ((ValueTriplet) getItem()).getValue()).getValue().toString());
}
textField = new TextField(getItem().toString().replaceAll("#tabs",""));
textField.setOnKeyReleased(event -> {
if (event.getCode() == KeyCode.ENTER) {
commitEdit((T) textField.getText());
Expand All @@ -113,12 +109,7 @@ public void startEdit() {

@Override
public void commitEdit(T newValue) {
if (getItem() instanceof String) {
super.commitEdit(newValue);
} else {
((VPair) ((ValueTriplet) getItem()).getValue()).setValue(newValue);
}
super.commitEdit(getItem());
super.commitEdit(newValue);
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions src/StellarisDK/FileClasses/ModDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import StellarisDK.FileClasses.Helper.DataMap;
import StellarisDK.GUI.ModDescUI;
import javafx.scene.control.TreeItem;

import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -100,4 +101,8 @@ public String export() {
return out.replaceAll("\\\\", "\\\\\\\\");
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}
}
24 changes: 24 additions & 0 deletions src/StellarisDK/GUI/AgendaUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package StellarisDK.GUI;

import StellarisDK.FileClasses.Agenda;
import StellarisDK.FileClasses.Helper.DataCell;

public class AgendaUI extends AbstractUI {

public AgendaUI(Agenda obj) {
init("FXML/agendaFX.fxml");
window.setText("Agenda Editor");
this.obj = obj;
}

@Override
public void load() {
treeView.setEditable(true);
treeView.setCellFactory(param -> new DataCell());
if(obj.getSize() != 0){
treeView.setRoot(obj.toTreeItem());
}else{
treeView.setRoot(obj.getRequiredTreeSet());
}
}
}
2 changes: 1 addition & 1 deletion src/StellarisDK/GUI/guiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void setCM(TreeCell cell) {
private TreeItem createNew(String type) {
switch (type) {
case "agendas":
break;
return new TreeItem<>(new Agenda());
case "ambient_objects":
return new TreeItem<>(new AmbientObject());
case "anomalies":
Expand Down

0 comments on commit c2a06e3

Please sign in to comment.