Skip to content

Commit

Permalink
Added DataEntry class for locking entries
Browse files Browse the repository at this point in the history
With the introduction of said class, the DataMap nesting is now as follows:
ArrayList -> DataEntry -> ValueTriplet -> (String, VPair, Integer)
Which should actually be simplified to ArrayList -> DataEntry but this is just for testing how well the TreeView work for editors.
  • Loading branch information
rexc159 committed Mar 11, 2018
1 parent 5e7f520 commit 2688b74
Show file tree
Hide file tree
Showing 21 changed files with 459 additions and 85 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stellaris Modding Kit (WIP)
General Purpose Mod Development Tool Kit for Stellaris

#### Latest Version: v0.1.14-alpha
#### Latest Version: v0.2.0-alpha

## Description
This modding kit, or "Stellaris Development Kit (SDK)" is designed to:
Expand Down
22 changes: 15 additions & 7 deletions src/StellarisDK/FileClasses/Agenda.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package StellarisDK.FileClasses;

import StellarisDK.FileClasses.Helper.DataEntry;
import StellarisDK.GUI.AgendaUI;
import javafx.scene.control.TreeItem;

public class Agenda extends GenericData {

private String[] requiredSet = {"weight_modifier", "modifier"};
private DataEntry[] requiredSet = {
new DataEntry("weight_modifier", false, false),
new DataEntry("modifier", false, false)
};

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

Expand All @@ -19,10 +23,14 @@ public Agenda(String input, String type) {
}

@Override
public TreeItem getRequiredTreeSet(){
TreeItem root = new TreeItem<>("agenda");
for(String set : requiredSet){
root.getChildren().addAll(new TreeItem<>(set));
public TreeItem getRequiredTreeSet() {
TreeItem root = new TreeItem<>(new DataEntry(type, true, false));
for (DataEntry entry : requiredSet) {
TreeItem temp = new TreeItem<>(entry);
if(!entry.isSingleEntry()){
temp.getChildren().add(new TreeItem<>("click_to_edit"));
}
root.getChildren().add(temp);
}
return root;
}
Expand All @@ -31,4 +39,4 @@ public TreeItem getRequiredTreeSet(){
public GenericData createNew() {
return new Agenda();
}
}
}
2 changes: 1 addition & 1 deletion src/StellarisDK/FileClasses/AmbientObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public GenericData createNew() {

@Override
public TreeItem getRequiredTreeSet() {
return null;
return new TreeItem<>(type);
}
}
15 changes: 14 additions & 1 deletion src/StellarisDK/FileClasses/Anomaly/Anomaly.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package StellarisDK.FileClasses.Anomaly;

import StellarisDK.FileClasses.GenericData;
import StellarisDK.FileClasses.Helper.DataEntry;
import StellarisDK.FileClasses.Helper.VPair;
import StellarisDK.FileClasses.Helper.ValueTriplet;
import StellarisDK.GUI.AnomalyUI;
import javafx.scene.control.TreeItem;

public class Anomaly extends GenericData {

private DataEntry[] requiredSet = {
new DataEntry(new ValueTriplet<>("event", new VPair<>("=", "..."), 0), true, true),
new DataEntry(new ValueTriplet<>("category", new VPair<>("=", "..."), 0), true, true),
new DataEntry("potential", false, false)
};

public Anomaly() {
super();
this.type = "anomaly";
Expand All @@ -25,6 +34,10 @@ public GenericData createNew() {

@Override
public TreeItem getRequiredTreeSet() {
return null;
TreeItem root = new TreeItem<>(new DataEntry(type, false, false));
for (DataEntry entry : requiredSet) {
root.getChildren().add(entry.toNestedTree());
}
return root;
}
}
1 change: 1 addition & 0 deletions src/StellarisDK/FileClasses/Anomaly/AnomalyCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javafx.scene.control.TreeItem;

public class AnomalyCategory extends GenericData {

public AnomalyCategory() {
super();
this.type = "anomaly_category";
Expand Down
28 changes: 28 additions & 0 deletions src/StellarisDK/FileClasses/Army.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package StellarisDK.FileClasses;

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

public class Army extends GenericData {

public Army() {
super();
this.type = "army";
ui = new ArmyUI(this);
}

public Army(String input, String type) {
super(input, type);
ui = new ArmyUI(this);
}

@Override
public GenericData createNew() {
return new Army();
}

@Override
public TreeItem getRequiredTreeSet() {
return null;
}
}
111 changes: 94 additions & 17 deletions src/StellarisDK/FileClasses/DataParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,111 @@ public static ArrayList<TreeItem> parseAll(File file) throws IOException {
obj.find();
String tabby = obj.group(2).replaceAll(" {4}", "\t");
GenericData gData;
switch (obj.group(1)) {
case "agenda":
String search = file.getParent().split("\\\\")[file.getParent().split("\\\\").length-1];
switch (search) {
case "agendas":
gData = new Agenda(tabby, obj.group(1));
break;
case "country_event":
gData = new Event(tabby);
break;
case "ambient_object":
case "ambient_objects":
gData = new AmbientObject(tabby);
break;
case "anomaly":
gData = new Anomaly(tabby);
case "anomalies":
if(obj.group(1).equals("anomaly")){
gData = new Anomaly(tabby);
}else{
gData = new AnomalyCategory(tabby);
}
break;
case "armies":
gData = new Army(tabby, obj.group(1));
break;
case "anomaly_category":
gData = new AnomalyCategory(tabby);
case "ascension_perks":
gData = new Tradition(tabby, obj.group(1), false);
break;
case "attitudes":
case "bombardment_stances":
case "buildable_pops":
case "building tags":
case "buildings":
case "colors":
gData = new Component(tabby, obj.group(1));
break;
case "component_set":
case "component_sets":
gData = new CompSet(tabby);
break;
case "utility_component_template":
gData = new Component(tabby, 0);
case "component_templates":
gData = new Component(tabby, obj.group(1));
break;
case "country_types":
case "defines":
case "deposits":
case "diplo_phrases":
case "edicts":
case "event_chains":
case "fallen_empires":
case "game_rules":
case "global_ship_designs":
case "governments":
case "authorities":
case "civics":
case "graphical_culture":
case "mandates":
case "map_modes":
case "megastructures":
case "name_lists":
case "notification_modifiers":
case "observation_station_missions":
case "on_actions":
case "opinion_modifiers":
case "personalities":
case "planet_classes":
case "planet_modifiers":
case "policies":
case "pop_faction_types":
case "precursor_civilizations":
case "random_names":
case "base":
case "scripted_effects":
case "scripted_loc":
case "scripted_triggers":
case "scripted_variables":
case "section_templates":
case "sector_settings":
case "sector_types":
case "ship_behaviors":
case "ship_sizes":
case "solar_system_initializers":
case "special_projects":
case "species_archetypes":
case "species_classes":
case "species_names":
case "species_rights":
case "star_classes":
case "starbase_buildings":
case "starbase_levels":
case "starbase_modules":
case "starbase_types":
case "start_screen_messages":
case "static_modifiers":
case "strategic_resources":
case "subjects":
case "system_types":
case "technology":
case "category":
case "tier":
case "terraform":
case "tile_blockers":
case "tradition_categories":
gData = new Component(tabby, obj.group(1));
break;
case "weapon_component_template":
gData = new Component(tabby, 1);
case "traditions":
gData = new Tradition(tabby, obj.group(1), true);
break;
case "strike_craft_component_template":
gData = new Component(tabby, 2);
case "traits":
case "events":
gData = new Event(tabby, obj.group(1));
break;
case "localisation":
default:
gData = new Component(tabby, obj.group(1));
}
Expand Down
5 changes: 5 additions & 0 deletions src/StellarisDK/FileClasses/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public Event(String input) {
ui = new EventUI(this);
}

public Event(String input, String type) {
super(input, type);
ui = new EventUI(this);
}

@Override
public GenericData createNew() {
return new Event();
Expand Down
28 changes: 16 additions & 12 deletions src/StellarisDK/FileClasses/GenericData.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ public void setData(DataMap data) {
this.data = data;
}

public void setType(String type){
public void setType(String type) {
this.type = type;
}

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

Expand Down Expand Up @@ -191,40 +191,44 @@ public TreeItem toTreeItem() {

public Object load(String input) {
int size = 0;
DataMap<String, ArrayList<Object>> data = new DataMap<>();
DataMap<String, PairArrayList<DataEntry>> data = new DataMap<>();
Matcher matcher;

matcher = DataPattern.newCombine.matcher(input);

while (matcher.find()) {
ArrayList temp;
PairArrayList<DataEntry> temp;
if (matcher.group(5) != null) {
if (matcher.group(7).contains("{")) {
ValueTriplet dat;
DataEntry entry;
Matcher color = DataPattern.color.matcher(matcher.group(7));
if (color.find()) {
try {
dat = new ValueTriplet<>(matcher.group(6).trim(), new StellarisColor(color.group(1).trim(), color.group(2).trim(), color.group(3).trim(), color.group(4).trim(), color.group(5).trim()), size++);
entry = new DataEntry(dat, true, false);
} catch (NullPointerException e) {
dat = new ValueTriplet<>(matcher.group(6).trim(), new StellarisColor(color.group(1).trim(), color.group(2).trim(), color.group(3).trim(), color.group(4).trim()), size++);
entry = new DataEntry(dat, true, true);
}
} else {
dat = new ValueTriplet<>(matcher.group(6).trim(), sLrecursion(matcher.group(7).trim()), size++);
entry = new DataEntry(dat, true, true);
}
if (data.containsKey(matcher.group(5))) {
data.get(matcher.group(5).trim()).add(dat);
data.get(matcher.group(5).trim()).add(entry);
} else {
temp = new PairArrayList();
temp.add(dat);
temp = new PairArrayList<>();
temp.add(entry);
data.put(matcher.group(5).trim(), temp);
}
} else {
ValueTriplet dat = new ValueTriplet<>(matcher.group(6).trim(), matcher.group(7).trim(), size++);
if (data.containsKey(matcher.group(5).trim())) {
data.get(matcher.group(5).trim()).add(dat);
data.get(matcher.group(5).trim()).add(new DataEntry(dat, true, true));
} else {
temp = new PairArrayList();
temp.add(dat);
temp = new PairArrayList<>();
temp.add(new DataEntry(dat, true, true));
data.put(matcher.group(5).trim(), temp);
}
}
Expand All @@ -239,9 +243,9 @@ public Object load(String input) {
secMap = (DataMap) load(matcher.group(4).replaceAll("(?m)^\t", ""));
dat = new ValueTriplet<>(matcher.group(2).trim(), secMap, order);
}
temp.add(dat);
temp.add(new DataEntry(dat, true, false));
if (data.containsKey(matcher.group(1).trim())) {
data.get(matcher.group(1).trim()).add(dat);
data.get(matcher.group(1).trim()).add(new DataEntry(dat, true, false));
} else {
data.put(matcher.group(1).trim(), temp);
}
Expand Down
Loading

0 comments on commit 2688b74

Please sign in to comment.