Skip to content

Commit

Permalink
Added Steam Workshop Support
Browse files Browse the repository at this point in the history
Minor Bugfixes
  • Loading branch information
rexc159 committed Apr 7, 2018
1 parent b39c922 commit ec6c3f5
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 168 deletions.
231 changes: 116 additions & 115 deletions src/StellarisDK/FileClasses/DataParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class DataParser {
private final static Pattern pattern = Pattern.compile("(?s)(?m)(^\\w+)\\s=\\s\\{(.+?)[\\r\\n]\\}[\\r\\n]?");
private final static Pattern constants = Pattern.compile("(\\@\\w+) = (.+)");

public static void parseToConsole(File file) throws IOException{
public static void parseToConsole(File file) throws IOException {
Scanner scan = new Scanner(file);
Component data;
String temp;
Expand All @@ -34,7 +34,7 @@ public static void parseToConsole(File file) throws IOException{
Matcher obj = pattern.matcher(objectDat);
obj.find();
data = new Component();
data.setData((DataMap)data.load(obj.group(2)));
data.setData((DataMap) data.load(obj.group(2)));
System.out.println(data.export());
} else {
break;
Expand Down Expand Up @@ -75,8 +75,8 @@ public static ArrayList<TreeItem> parseAll(File file) throws IOException {
temp = scan.findWithinHorizon(name, 0);
if (temp != null)
namespace.getChildren().add(new TreeItem<>(temp));
}while (temp != null);
if(!namespace.getChildren().isEmpty())
} while (temp != null);
if (!namespace.getChildren().isEmpty())
out.add(namespace);
do {
temp = scan.findWithinHorizon(constants, 0);
Expand All @@ -92,118 +92,119 @@ public static ArrayList<TreeItem> parseAll(File file) throws IOException {
obj.find();
String tabby = obj.group(2).replaceAll(" {4}", "\t");
GenericData gData;
String search = file.getParent().split("\\\\")[file.getParent().split("\\\\").length-1];
System.out.println(bracketCheck(tabby));
switch (search) {
case "agendas":
gData = new Agenda(tabby, obj.group(1));
break;
case "ambient_objects":
gData = new AmbientObject(tabby);
break;
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 "ascension_perks":
gData = new Tradition(tabby, obj.group(1), false);
break;
case "attitudes":
gData = new Attitude(tabby, obj.group(1));
break;
case "bombardment_stances":
case "buildable_pops":
case "building tags":
case "buildings":
case "colors":
gData = new Component(tabby, obj.group(1));
break;
case "component_sets":
gData = new CompSet(tabby);
break;
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 "traditions":
gData = new Tradition(tabby, obj.group(1), true);
break;
case "traits":
case "events":
gData = new Event(tabby, obj.group(1));
break;
case "localisation":
default:
gData = new Component(tabby, obj.group(1));
String search = file.getParent().split("\\\\")[file.getParent().split("\\\\").length - 1];
if (bracketCheck(tabby)) {
switch (search) {
case "agendas":
gData = new Agenda(tabby, obj.group(1));
break;
case "ambient_objects":
gData = new AmbientObject(tabby);
break;
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 "ascension_perks":
gData = new Tradition(tabby, obj.group(1), false);
break;
case "attitudes":
gData = new Attitude(tabby, obj.group(1));
break;
case "bombardment_stances":
case "buildable_pops":
case "building tags":
case "buildings":
case "colors":
gData = new Component(tabby, obj.group(1));
break;
case "component_sets":
gData = new CompSet(tabby);
break;
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 "traditions":
gData = new Tradition(tabby, obj.group(1), true);
break;
case "traits":
case "events":
gData = new Event(tabby, obj.group(1));
break;
case "localisation":
default:
gData = new Component(tabby, obj.group(1));
}
out.add(new TreeItem<>(gData));
}
out.add(new TreeItem<>(gData));
} else {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/StellarisDK/FileClasses/DataPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DataPattern {

// Pattern matches for single value variable
// i.e. key, size, power
public static final Pattern kv = Pattern.compile("(?m)^\\t?(\\w+)(\\s?[=<>]+\\s?)([^\\s\\{#\\n]+)(#.+)*");
public static final Pattern kv = Pattern.compile("(?m)^\\t?(\\w+)(\\s?[=<>]+\\s?)([^\\{#\\n]+)(#.+)*$");

// Pattern matches for single lines objects
// Group 1-3: Special match for color
Expand Down
10 changes: 7 additions & 3 deletions src/StellarisDK/FileClasses/Helper/DataCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,14 @@ private void setCM() {
ContextMenu contextMenu = new ContextMenu();
MenuItem createNew = new MenuItem("New..");
createNew.setOnAction(event -> {
if (!((DataEntry) getItem()).isSingleEntry()) {
if (getItem() instanceof DataEntry) {
if (!((DataEntry) getItem()).isSingleEntry()) {
getTreeItem().getChildren().add(new TreeItem("Click_to_Edit"));
} else {
getTreeItem().getParent().getChildren().add(new TreeItem("Click_to_Edit"));
}
} else {
getTreeItem().getChildren().add(new TreeItem("Click_to_Edit"));
}else{
getTreeItem().getParent().getChildren().add(new TreeItem("Click_to_Edit"));
}
});
MenuItem edit = new MenuItem("Rename");
Expand Down
12 changes: 8 additions & 4 deletions src/StellarisDK/GUI/AbstractUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ public void load() {
}
} else if (new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN).match(event)) {
System.out.println("CTRL+N");
if (!((DataEntry) selected.getValue()).isSingleEntry()) {
selected.getChildren().add(new TreeItem<>("Click_to_Edit"));
}else {
selected.getParent().getChildren().add(new TreeItem<>("Click_to_Edit"));
if (selected.getValue() instanceof DataEntry) {
if (!((DataEntry) selected.getValue()).isSingleEntry()) {
selected.getChildren().add(new TreeItem<>("Click_to_Edit"));
} else {
selected.getParent().getChildren().add(new TreeItem<>("Click_to_Edit"));
}
} else {
selected.getChildren().add(new TreeItem("Click_to_Edit"));
}
} else if (event.getCode() == KeyCode.DELETE) {
if (selected.getParent() != null || !((DataEntry) selected.getValue()).isRequired())
Expand Down
3 changes: 2 additions & 1 deletion src/StellarisDK/GUI/AgendaUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public AgendaUI(Agenda obj) {
window.setText("Agenda Editor");
this.obj = obj;
}
}

}
41 changes: 27 additions & 14 deletions src/StellarisDK/GUI/ModLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,41 @@ public ModLoader(ArrayList<TreeItem> modList) {

@Override
public void load() {
for (TreeItem modList : modList) {
CheckBox temp = new CheckBox(modList.getValue().toString());
temp.setId(temp.getText());
list.getChildren().add(temp);
if (list.getChildren().size() == 0) {
for (TreeItem modList : modList) {
CheckBox temp = new CheckBox(modList.getValue().toString());
temp.setId(temp.getText());
list.getChildren().add(temp);
}
Button load = new Button("Load Selected");
load.setOnAction(event -> removeUnchecked());
list.getChildren().add(load);
}
}

public void load(ArrayList<TreeItem> modList) {
this.modList = modList;
if (list.getChildren().size() > 0) {
list.getChildren().remove(0, list.getChildren().size());
}
Button load = new Button("Load Selected");
load.setOnAction(event -> removeUnchecked());
list.getChildren().add(load);
load();
}

private void removeUnchecked() {
for (TreeItem item : modList) {
item.getChildren().clear();
itemView.getRoot().getChildren().remove(item);
if (((CheckBox) list.getChildren().get(modList.indexOf(item))).isSelected()) {
itemView.getRoot().getChildren().add(item);
String mainLoadPath = FileSystemView.getFileSystemView().getDefaultDirectory().getPath() +
"\\Paradox Interactive\\Stellaris\\" +
(((ModDescriptor) item.getValue()).getValue("path").toString().replaceAll("/", "\\\\"));
guiController.loadMod(mainLoadPath, item, true);
item.getChildren().add(new TreeItem<>(item.getValue()));
}else{
modList.set(modList.indexOf(item), null);
if ((((ModDescriptor) item.getValue()).getValue("path") != null)) {
String mainLoadPath = FileSystemView.getFileSystemView().getDefaultDirectory().getPath() +
"\\Paradox Interactive\\Stellaris\\" +
(((ModDescriptor) item.getValue()).getValue("path").toString().replaceAll("/", "\\\\"));
guiController.loadMod(mainLoadPath, item, true);
item.getChildren().add(new TreeItem<>(item.getValue()));
} else {
guiController.extractZip(item);
}
}
}
root.getChildren().remove(this);
Expand Down
Loading

0 comments on commit ec6c3f5

Please sign in to comment.