use of com.lilithsthrone.game.character.gender.GenderPronoun in project liliths-throne-public by Innoxia.
the class MainController method setUpButtons.
private void setUpButtons() {
// HOTKEYS:
actionKeyPressed = new EventHandler<KeyEvent>() {
private Map.Entry<KeyboardAction, KeyCodeWithModifiers> findExistingBinding(Map<KeyboardAction, KeyCodeWithModifiers> bindings, KeyEvent lookingFor) {
return bindings.entrySet().stream().filter(entry -> entry.getValue() != null).filter(entry -> entry.getValue().matches(lookingFor)).findFirst().orElse(null);
}
private void printAlreadyExistingBinding(String primarySecondary, String actionName, String eventCodeName) {
Main.game.getTextStartStringBuilder().append("<p style='text-align:center;'>" + "<b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>The key '" + eventCodeName + "' is already the " + primarySecondary + " bind for the action '" + actionName + "'!</b>" + "</p>");
Main.game.setContent(new Response("", "", Main.game.getCurrentDialogueNode()));
}
private boolean handleExistingBindings(Map<KeyboardAction, KeyCodeWithModifiers> bindings, KeyEvent lookingFor, String primarySecondary) {
Map.Entry<KeyboardAction, KeyCodeWithModifiers> existingBinding = findExistingBinding(bindings, lookingFor);
boolean hasExistingBinding = existingBinding != null;
if (hasExistingBinding) {
actionToBind = null;
printAlreadyExistingBinding(primarySecondary, existingBinding.getKey().getName(), existingBinding.getValue().getFullName());
}
return hasExistingBinding;
}
public void handle(KeyEvent event) {
if (allowInput) {
// Hotkey bindings:
if (Main.game.getCurrentDialogueNode() == OptionsDialogue.KEYBINDS) {
if (actionToBind != null) {
KeyCode eventCode = event.getCode();
if (eventCode == KeyCode.SHIFT || eventCode == KeyCode.CONTROL) {
// these are explicitly blocked to allow SHIFT + key and CTRL + key
return;
}
if (handleExistingBindings(Main.getProperties().hotkeyMapPrimary, event, "primary") || handleExistingBindings(Main.getProperties().hotkeyMapSecondary, event, "secondary")) {
// such a binding already exists
return;
}
KeyCodeWithModifiers newBinding = new KeyCodeWithModifiers(eventCode, event.isControlDown(), event.isShiftDown());
if (primaryBinding)
Main.getProperties().hotkeyMapPrimary.put(actionToBind, newBinding);
else
Main.getProperties().hotkeyMapSecondary.put(actionToBind, newBinding);
actionToBind = null;
Main.saveProperties();
Main.game.setContent(new Response("", "", Main.game.getCurrentDialogueNode()));
return;
}
} else {
actionToBind = null;
}
if (!buttonsPressed.contains(event.getCode())) {
buttonsPressed.add(event.getCode());
System.arraycopy(lastKeys, 0, lastKeys, 1, 4);
lastKeys[0] = event.getCode();
checkLastKeys();
if (event.getCode() == KeyCode.END) {
Main.game.getPlayer().setMana(1);
// Cell[][] grid = new Cell[5][5];
// for(int i=0; i<grid.length;i++) {
// for(int j=0; j<grid[0].length;j++) {
// grid[i][j] = new Cell(WorldType.SEWERS, new Vector2i(i, j));
// grid[i][j].setPlace(new GenericPlace(PlaceType.SUBMISSION_IMP_PALACE));
// }
// }
//
// Generation.printMaze(WorldType.SEWERS, Generation.generateTestMap(WorldType.SEWERS, 0, 0, grid, 2));
// Main.game.getPlayer().incrementCummedInArea(OrificeType.VAGINA, 10000);
// Main.game.getPlayer().addPsychoactiveFluidIngested(FluidType.CUM_HUMAN);
// Main.game.getPlayer().addPsychoactiveFluidIngested(FluidType.MILK_HUMAN);
// Main.game.getPlayer().addPsychoactiveFluidIngested(FluidType.GIRL_CUM_HUMAN);
// Main.game.getPlayer().addStatusEffect(StatusEffect.PSYCHOACTIVE, 60*6);
// Main.game.getPlayer().addAddiction(new Addiction(FluidType.MILK_HUMAN, Main.game.getMinutesPassed()));
// Main.game.getPlayer().incrementAlcoholLevel(0.2f);
// for(Fetish f : Fetish.values()) {
// Main.game.getPlayer().incrementFetishExperience(f, (int) (Math.random()*20));
// }
// Main.game.getPlayer().incrementCummedInArea(OrificeType.MOUTH, 2500);
// for(NPC npc : Main.game.getNPCMap().values()) {
// System.out.println(npc.getId());
// }
// for(int i=0; i<=1000; i++) {
// System.out.println(Util.intToString(i));
// }
// Main.game.getPlayer().addDirtySlot(InventorySlot.GROIN);
// Main.game.getPlayer().addDirtySlot(InventorySlot.MOUTH);
// Main.game.getPlayer().addDirtySlot(InventorySlot.LEG);
// System.out.println(Main.isVersionOlderThan("0.1.84", Main.VERSION_NUMBER));
// for(int i=0;i<10;i++) {
// System.out.println(Name.getRandomTriplet(Race.DEMON));
// }
// Game.exportGame();
// System.out.println(Main.game.getNumberOfWitches());
// SlaveryUtil.calculateEvent(Main.game.getMinutesPassed(), Main.game.getPlayer().getSlavesOwned().get(0));
// for(String npc : Main.game.getNPCMap().keySet()) {
// System.out.println(npc);
// }
//
// System.out.println(ItemType.BOOK_CAT_MORPH.getId());
// System.out.println(Main.game.getPlayer().getNextClothingToRemoveForCoverableAreaAccess(CoverableArea.VAGINA).getKey().getName());
// webViewMain = new WebView();
// webViewAttributes = new WebView();
// webViewInventory = new WebView();
// webViewMap = new WebView();
// webViewMapTitle = new WebView();
// webViewButtons = new WebView();
// webViewResponse = new WebView();
//
// setUpWebViews();
// File dir = new File("data/clothing");
// dir.mkdir();
// for (ClothingType ct : ClothingType.values()) {
//
// dir = new File("data/clothing/"+ct);
// dir.mkdir();
//
// for(Colour c : ct.getAvailableColours()) {
// try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("data/clothing/"+ct+"/"+ct.getName().replaceAll(" ", "_")+"_"+c+".svg"), "utf-8"))) {
// writer.write(ct.getSVGImage(c));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// dir = new File("data/items");
// dir.mkdir();
// for (ItemType ct : ItemType.values()) {
//
//
// try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("data/items/"+ct.getName(false).replaceAll(" ", "_")+".svg"), "utf-8"))) {
// writer.write(ct.getSVGString());
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// dir = new File("data/weapons");
// dir.mkdir();
// for (WeaponType ct : WeaponType.values()) {
//
// for(DamageType dt : ct.getAvailableDamageTypes())
// try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("data/weapons/"+ct.getName().replaceAll(" ", "_")+"("+dt+").svg"), "utf-8"))) {
// writer.write(ct.getSVGStringMap().get(dt));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// dir = new File("data/statusEffects");
// dir.mkdir();
// for (StatusEffect se : StatusEffect.values()) {
// if(!se.isSexEffect()) {
// try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("data/statusEffects/"+se+"("+se.getName(Main.game.getPlayer()).replaceAll(" ", "_")+").svg"), "utf-8"))) {
// writer.write(se.getSVGString(Main.game.getPlayer()));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// dir = new File("data/fetishes");
// dir.mkdir();
// for (Fetish se : Fetish.values()) {
//
// try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("data/fetishes/"+se+"("+se.getName(Main.game.getPlayer()).replaceAll(" ", "_")+").svg"), "utf-8"))) {
// writer.write(se.getSVGString());
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// Main.getProperties().savePropertiesAsXML();
// System.out.println("Free memory (bytes) -gc: " + Runtime.getRuntime().freeMemory());
// System.gc();
// System.out.println("Free memory (bytes) +gc: " + Runtime.getRuntime().freeMemory());
// System.out.println("Body sizes:");
// for(BodySize bs : BodySize.values()) {
// System.out.println(bs.getName(false));
// }
// System.out.println("");
// System.out.println("Muscle:");
// for(Muscle m : Muscle.values()) {
// System.out.println(m.getName(false));
// }
// System.out.println("");
// System.out.println("");
// System.out.println("Body shapes:");
// for(BodyShape bs : BodyShape.values()) {
// System.out.println(bs.getRelatedBodySize().getName(false)+" + "+bs.getRelatedMuscle().getName(false)+" = "+bs.getName());
// }
}
// Escape Menu:
if (keyEventMatchesBindings(KeyboardAction.MENU, event))
openOptions();
// Movement:
if (keyEventMatchesBindings(KeyboardAction.MOVE_NORTH, event)) {
if (!Main.game.getCurrentDialogueNode().isTravelDisabled()) {
moveNorth();
} else {
Main.game.responseNavigationUp();
}
}
if (keyEventMatchesBindings(KeyboardAction.MOVE_WEST, event)) {
if (!Main.game.getCurrentDialogueNode().isTravelDisabled()) {
moveWest();
} else {
Main.game.responseNavigationLeft();
}
}
if (keyEventMatchesBindings(KeyboardAction.MOVE_SOUTH, event)) {
if (!Main.game.getCurrentDialogueNode().isTravelDisabled()) {
moveSouth();
} else {
Main.game.responseNavigationDown();
}
}
if (keyEventMatchesBindings(KeyboardAction.MOVE_EAST, event)) {
if (!Main.game.getCurrentDialogueNode().isTravelDisabled()) {
moveEast();
} else {
Main.game.responseNavigationRight();
}
}
if (keyEventMatchesBindings(KeyboardAction.MOVE_RESPONSE_CURSOR_NORTH, event)) {
Main.game.responseNavigationUp();
}
if (keyEventMatchesBindings(KeyboardAction.MOVE_RESPONSE_CURSOR_WEST, event)) {
Main.game.responseNavigationLeft();
}
if (keyEventMatchesBindings(KeyboardAction.MOVE_RESPONSE_CURSOR_SOUTH, event)) {
Main.game.responseNavigationDown();
}
if (keyEventMatchesBindings(KeyboardAction.MOVE_RESPONSE_CURSOR_EAST, event)) {
Main.game.responseNavigationRight();
}
// Game stuff:
if (keyEventMatchesBindings(KeyboardAction.QUICKSAVE, event)) {
Main.quickSaveGame();
}
if (keyEventMatchesBindings(KeyboardAction.QUICKLOAD, event)) {
Main.quickLoadGame();
}
boolean allowInput = true;
boolean enterConsumed = false;
// Name selections:
if (Main.game.getCurrentDialogueNode() == CharacterCreation.CHOOSE_NAME || Main.game.getCurrentDialogueNode() == CityHall.CITY_HALL_NAME_CHANGE_FORM) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('nameInput') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
Main.game.setContent(1);
}
}
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('surnameInput') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
Main.game.setContent(1);
}
}
}
if (Main.game.getCurrentDialogueNode() == SlaveryManagementDialogue.ROOM_UPGRADES) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('nameInput') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
boolean unsuitableName = false;
if (Main.mainController.getWebEngine().executeScript("document.getElementById('nameInput')") != null) {
Main.mainController.getWebEngine().executeScript("document.getElementById('hiddenFieldName').innerHTML=document.getElementById('nameInput').value;");
if (Main.mainController.getWebEngine().getDocument() != null) {
unsuitableName = Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent().length() < 1 || Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent().length() > 32;
}
if (!unsuitableName) {
Main.game.setContent(new Response("Rename Room", "Rename this room to whatever you've entered in the text box.", Main.game.getCurrentDialogueNode()) {
@Override
public void effects() {
Main.game.getPlayerCell().getPlace().setName(Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent());
}
});
} else {
Main.game.setContent(new Response("Rename Room", "", Main.game.getCurrentDialogueNode()));
}
}
}
}
}
if (Main.game.getCurrentDialogueNode() == CityHall.CITY_HALL_NAME_CHANGE_FORM) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('nameInput') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
Main.game.setContent(1);
}
}
}
if (Main.game.getCurrentDialogueNode() == OptionsDialogue.SAVE_LOAD) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('new_save_name') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
Main.mainController.getWebEngine().executeScript("document.getElementById('hiddenPField').innerHTML=document.getElementById('new_save_name').value;");
if (Main.isSaveGameAvailable()) {
Main.saveGame(Main.mainController.getWebEngine().getDocument().getElementById("hiddenPField").getTextContent(), false);
}
Main.game.setContent(new Response("Save", "", Main.game.getCurrentDialogueNode()));
}
}
}
if (Main.game.getCurrentDialogueNode() == SlaveryManagementDialogue.SLAVE_MANAGEMENT_INSPECT || Main.game.getCurrentDialogueNode() == SlaveryManagementDialogue.SLAVE_MANAGEMENT_JOBS || Main.game.getCurrentDialogueNode() == SlaveryManagementDialogue.SLAVE_MANAGEMENT_PERMISSIONS) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('slaveToPlayerNameInput') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
boolean unsuitableName = false;
if (Main.mainController.getWebEngine().executeScript("document.getElementById('slaveToPlayerNameInput')") != null) {
Main.mainController.getWebEngine().executeScript("document.getElementById('hiddenFieldName').innerHTML=document.getElementById('slaveToPlayerNameInput').value;");
if (Main.mainController.getWebEngine().getDocument() != null) {
unsuitableName = Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent().length() < 1 || Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent().length() > 32;
}
if (!unsuitableName) {
Main.game.setContent(new Response("Rename", "", Main.game.getCurrentDialogueNode()) {
@Override
public void effects() {
Main.game.getDialogueFlags().getSlaveryManagerSlaveSelected().setPlayerPetName(Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent());
}
});
} else {
Main.game.setContent(new Response("Rename", "", Main.game.getCurrentDialogueNode()));
}
}
}
}
if (((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('slaveNameInput') === document.activeElement"))) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
boolean unsuitableName = false;
if (Main.mainController.getWebEngine().executeScript("document.getElementById('slaveNameInput')") != null) {
Main.mainController.getWebEngine().executeScript("document.getElementById('hiddenFieldName').innerHTML=document.getElementById('slaveNameInput').value;");
if (Main.mainController.getWebEngine().getDocument() != null) {
unsuitableName = Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent().length() < 1 || Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent().length() > 32;
}
if (!unsuitableName) {
Main.game.setContent(new Response("Rename", "", Main.game.getCurrentDialogueNode()) {
@Override
public void effects() {
Main.game.getDialogueFlags().getSlaveryManagerSlaveSelected().setName(new NameTriplet(Main.mainController.getWebEngine().getDocument().getElementById("hiddenFieldName").getTextContent()));
}
});
} else {
Main.game.setContent(new Response("Rename", "", Main.game.getCurrentDialogueNode()));
}
}
}
}
}
if (((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('offspringPetNameInput') === document.activeElement"))) {
allowInput = false;
}
if (Main.game.getCurrentDialogueNode() == OptionsDialogue.OPTIONS_PRONOUNS) {
for (GenderPronoun gp : GenderPronoun.values()) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('feminine_" + gp + "') === document.activeElement") || (boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('masculine_" + gp + "') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
Main.game.setContent(1);
}
}
}
for (GenderNames genderName : GenderNames.values()) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('GENDER_NAME_MASCULINE_" + genderName + "') === document.activeElement") || (boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('GENDER_NAME_ANDROGYNOUS_" + genderName + "') === document.activeElement") || (boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('GENDER_NAME_FEMININE_" + genderName + "') === document.activeElement")) {
allowInput = false;
if (event.getCode() == KeyCode.ENTER) {
enterConsumed = true;
Main.game.setContent(1);
}
}
}
}
if (Main.game.getCurrentDialogueNode() == DebugDialogue.PARSER) {
if ((boolean) Main.mainController.getWebEngine().executeScript("document.getElementById('parseInput') === document.activeElement"))
allowInput = false;
}
if (allowInput) {
if (keyEventMatchesBindings(KeyboardAction.INVENTORY, event))
openInventory();
if (keyEventMatchesBindings(KeyboardAction.JOURNAL, event))
openPhone();
if (keyEventMatchesBindings(KeyboardAction.CHARACTERS, event))
openCharactersPresent(null);
if (keyEventMatchesBindings(KeyboardAction.ZOOM, event))
zoomMap();
if (keyEventMatchesBindings(KeyboardAction.SCROLL_UP, event))
Main.mainController.getWebEngine().executeScript("document.getElementById('main-content').scrollTop -= 50");
if (keyEventMatchesBindings(KeyboardAction.SCROLL_DOWN, event))
Main.mainController.getWebEngine().executeScript("document.getElementById('main-content').scrollTop += 50");
// Responses:
KeyboardAction[] keyboardActionsForResponses = { KeyboardAction.RESPOND_0, KeyboardAction.RESPOND_1, KeyboardAction.RESPOND_2, KeyboardAction.RESPOND_3, KeyboardAction.RESPOND_4, KeyboardAction.RESPOND_5, KeyboardAction.RESPOND_6, KeyboardAction.RESPOND_7, KeyboardAction.RESPOND_8, KeyboardAction.RESPOND_9, KeyboardAction.RESPOND_10, KeyboardAction.RESPOND_11, KeyboardAction.RESPOND_12, KeyboardAction.RESPOND_13, KeyboardAction.RESPOND_14 };
for (int i = 0; i < keyboardActionsForResponses.length; i++) {
if (keyEventMatchesBindings(keyboardActionsForResponses[i], event)) {
processResponse(i);
}
}
if (keyEventMatchesBindings(KeyboardAction.MENU_SELECT, event)) {
if (event.getCode() == KeyCode.ENTER) {
if (!enterConsumed) {
Main.game.setContent(Main.game.getResponsePointer());
}
} else {
Main.game.setContent(Main.game.getResponsePointer());
}
}
}
// Next/Previous response tab:
if (keyEventMatchesBindings(KeyboardAction.RESPOND_NEXT_TAB, event)) {
if (Main.game.incrementResponseTab()) {
Main.game.updateResponses();
}
}
if (keyEventMatchesBindings(KeyboardAction.RESPOND_PREVIOUS_TAB, event)) {
if (Main.game.decrementResponseTab()) {
Main.game.updateResponses();
}
}
// Next/Previous response page:
if (keyEventMatchesBindings(KeyboardAction.RESPOND_NEXT_PAGE, event)) {
if (Main.game.isHasNextResponsePage()) {
Main.game.setResponsePage(Main.game.getResponsePage() + 1);
Main.game.updateResponses();
}
}
if (keyEventMatchesBindings(KeyboardAction.RESPOND_PREVIOUS_PAGE, event)) {
if (Main.game.getResponsePage() != 0) {
Main.game.setResponsePage(Main.game.getResponsePage() - 1);
Main.game.updateResponses();
}
}
}
}
}
};
actionKeyReleased = new EventHandler<KeyEvent>() {
public void handle(KeyEvent event) {
if (buttonsPressed.contains(event.getCode())) {
buttonsPressed.remove(event.getCode());
}
}
};
Main.primaryStage.addEventFilter(KeyEvent.KEY_PRESSED, actionKeyPressed);
Main.primaryStage.addEventFilter(KeyEvent.KEY_RELEASED, actionKeyReleased);
}
use of com.lilithsthrone.game.character.gender.GenderPronoun in project liliths-throne-public by Innoxia.
the class Properties method savePropertiesAsXML.
public void savePropertiesAsXML() {
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element properties = doc.createElement("properties");
doc.appendChild(properties);
// Previous save information:
Element previousSave = doc.createElement("previousSave");
properties.appendChild(previousSave);
createXMLElementWithValue(doc, previousSave, "location", lastSaveLocation);
createXMLElementWithValue(doc, previousSave, "nameColour", nameColour);
createXMLElementWithValue(doc, previousSave, "name", name);
createXMLElementWithValue(doc, previousSave, "race", race);
createXMLElementWithValue(doc, previousSave, "quest", quest);
createXMLElementWithValue(doc, previousSave, "level", String.valueOf(level));
createXMLElementWithValue(doc, previousSave, "money", String.valueOf(money));
createXMLElementWithValue(doc, previousSave, "arcaneEssences", String.valueOf(arcaneEssences));
createXMLElementWithValue(doc, previousSave, "versionNumber", Main.VERSION_NUMBER);
createXMLElementWithValue(doc, previousSave, "lastQuickSaveName", lastQuickSaveName);
// Game settings:
Element settings = doc.createElement("settings");
properties.appendChild(settings);
createXMLElementWithValue(doc, settings, "fontSize", String.valueOf(fontSize));
createXMLElementWithValue(doc, settings, "lightTheme", String.valueOf(lightTheme));
createXMLElementWithValue(doc, settings, "furryTailPenetrationContent", String.valueOf(furryTailPenetrationContent));
createXMLElementWithValue(doc, settings, "nonConContent", String.valueOf(nonConContent));
createXMLElementWithValue(doc, settings, "incestContent", String.valueOf(incestContent));
createXMLElementWithValue(doc, settings, "inflationContent", String.valueOf(inflationContent));
createXMLElementWithValue(doc, settings, "facialHairContent", String.valueOf(facialHairContent));
createXMLElementWithValue(doc, settings, "pubicHairContent", String.valueOf(pubicHairContent));
createXMLElementWithValue(doc, settings, "bodyHairContent", String.valueOf(bodyHairContent));
createXMLElementWithValue(doc, settings, "feminineBeardsContent", String.valueOf(feminineBeardsContent));
createXMLElementWithValue(doc, settings, "overwriteWarning", String.valueOf(overwriteWarning));
createXMLElementWithValue(doc, settings, "fadeInText", String.valueOf(fadeInText));
createXMLElementWithValue(doc, settings, "calendarDisplay", String.valueOf(calendarDisplay));
createXMLElementWithValue(doc, settings, "twentyFourHourTime", String.valueOf(twentyFourHourTime));
createXMLElementWithValue(doc, settings, "androgynousIdentification", String.valueOf(androgynousIdentification));
createXMLElementWithValue(doc, settings, "humanEncountersLevel", String.valueOf(humanEncountersLevel));
createXMLElementWithValue(doc, settings, "multiBreasts", String.valueOf(multiBreasts));
createXMLElementWithValue(doc, settings, "forcedTFPercentage", String.valueOf(forcedTFPercentage));
createXMLElementWithValue(doc, settings, "pregnancyBreastGrowthVariance", String.valueOf(pregnancyBreastGrowthVariance));
createXMLElementWithValue(doc, settings, "pregnancyBreastGrowth", String.valueOf(pregnancyBreastGrowth));
createXMLElementWithValue(doc, settings, "pregnancyBreastGrowthLimit", String.valueOf(pregnancyBreastGrowthLimit));
createXMLElementWithValue(doc, settings, "pregnancyLactationIncreaseVariance", String.valueOf(pregnancyLactationIncreaseVariance));
createXMLElementWithValue(doc, settings, "pregnancyLactationIncrease", String.valueOf(pregnancyLactationIncrease));
createXMLElementWithValue(doc, settings, "pregnancyLactationLimit", String.valueOf(pregnancyLactationLimit));
createXMLElementWithValue(doc, settings, "forcedFetishPercentage", String.valueOf(forcedFetishPercentage));
createXMLElementWithValue(doc, settings, "newWeaponDiscovered", String.valueOf(newWeaponDiscovered));
createXMLElementWithValue(doc, settings, "newClothingDiscovered", String.valueOf(newClothingDiscovered));
createXMLElementWithValue(doc, settings, "newItemDiscovered", String.valueOf(newItemDiscovered));
createXMLElementWithValue(doc, settings, "newRaceDiscovered", String.valueOf(newRaceDiscovered));
createXMLElementWithValue(doc, settings, "difficultyLevel", difficultyLevel.toString());
// Game key binds:
Element keyBinds = doc.createElement("keyBinds");
properties.appendChild(keyBinds);
for (KeyboardAction ka : KeyboardAction.values()) {
Element element = doc.createElement("binding");
keyBinds.appendChild(element);
Attr bindName = doc.createAttribute("bindName");
bindName.setValue(ka.toString());
element.setAttributeNode(bindName);
Attr primaryBind = doc.createAttribute("primaryBind");
if (hotkeyMapPrimary.get(ka) != null)
primaryBind.setValue(hotkeyMapPrimary.get(ka).toString());
else
primaryBind.setValue("");
element.setAttributeNode(primaryBind);
Attr secondaryBind = doc.createAttribute("secondaryBind");
if (hotkeyMapSecondary.get(ka) != null)
secondaryBind.setValue(hotkeyMapSecondary.get(ka).toString());
else
secondaryBind.setValue("");
element.setAttributeNode(secondaryBind);
}
// Gender names:
Element genderNames = doc.createElement("genderNames");
properties.appendChild(genderNames);
for (GenderNames gp : GenderNames.values()) {
Element element = doc.createElement("genderName");
genderNames.appendChild(element);
Attr pronounName = doc.createAttribute("name");
pronounName.setValue(gp.toString());
element.setAttributeNode(pronounName);
Attr feminineValue = doc.createAttribute("feminineValue");
if (genderNameFemale.get(gp) != null) {
feminineValue.setValue(genderNameFemale.get(gp));
} else {
feminineValue.setValue(gp.getFeminine());
}
element.setAttributeNode(feminineValue);
Attr masculineValue = doc.createAttribute("masculineValue");
if (genderNameMale.get(gp) != null) {
masculineValue.setValue(genderNameMale.get(gp));
} else {
masculineValue.setValue(gp.getMasculine());
}
element.setAttributeNode(masculineValue);
Attr neutralValue = doc.createAttribute("neutralValue");
if (genderNameNeutral.get(gp) != null) {
neutralValue.setValue(genderNameNeutral.get(gp));
} else {
neutralValue.setValue(gp.getNeutral());
}
element.setAttributeNode(neutralValue);
}
// Gender pronouns:
Element pronouns = doc.createElement("genderPronouns");
properties.appendChild(pronouns);
for (GenderPronoun gp : GenderPronoun.values()) {
Element element = doc.createElement("pronoun");
pronouns.appendChild(element);
Attr pronounName = doc.createAttribute("pronounName");
pronounName.setValue(gp.toString());
element.setAttributeNode(pronounName);
Attr feminineValue = doc.createAttribute("feminineValue");
if (genderPronounFemale.get(gp) != null)
feminineValue.setValue(genderPronounFemale.get(gp));
else
feminineValue.setValue(gp.getFeminine());
element.setAttributeNode(feminineValue);
Attr masculineValue = doc.createAttribute("masculineValue");
if (genderPronounMale.get(gp) != null)
masculineValue.setValue(genderPronounMale.get(gp));
else
masculineValue.setValue(gp.getMasculine());
element.setAttributeNode(masculineValue);
}
// Gender preferences:
Element genderPreferences = doc.createElement("genderPreferences");
properties.appendChild(genderPreferences);
for (Gender g : Gender.values()) {
Element element = doc.createElement("preference");
genderPreferences.appendChild(element);
Attr gender = doc.createAttribute("gender");
gender.setValue(g.toString());
element.setAttributeNode(gender);
Attr value = doc.createAttribute("value");
value.setValue(String.valueOf(genderPreferencesMap.get(g).intValue()));
element.setAttributeNode(value);
}
// Forced TF settings:
createXMLElementWithValue(doc, settings, "forcedTFPreference", String.valueOf(forcedTFPreference));
createXMLElementWithValue(doc, settings, "forcedTFTendency", String.valueOf(forcedTFTendency));
createXMLElementWithValue(doc, settings, "forcedFetishTendency", String.valueOf(forcedFetishTendency));
// Race preferences:
Element racePreferences = doc.createElement("subspeciesPreferences");
properties.appendChild(racePreferences);
for (Subspecies s : Subspecies.values()) {
Element element = doc.createElement("preferenceFeminine");
racePreferences.appendChild(element);
Attr race = doc.createAttribute("subspecies");
race.setValue(s.toString());
element.setAttributeNode(race);
Attr preference = doc.createAttribute("preference");
preference.setValue(subspeciesFemininePreferencesMap.get(s).toString());
element.setAttributeNode(preference);
preference = doc.createAttribute("furryPreference");
preference.setValue(subspeciesFeminineFurryPreferencesMap.get(s).toString());
element.setAttributeNode(preference);
element = doc.createElement("preferenceMasculine");
racePreferences.appendChild(element);
race = doc.createAttribute("subspecies");
race.setValue(s.toString());
element.setAttributeNode(race);
preference = doc.createAttribute("preference");
preference.setValue(subspeciesMasculinePreferencesMap.get(s).toString());
element.setAttributeNode(preference);
preference = doc.createAttribute("furryPreference");
preference.setValue(subspeciesMasculineFurryPreferencesMap.get(s).toString());
element.setAttributeNode(preference);
}
// Discoveries:
Element itemsDiscovered = doc.createElement("itemsDiscovered");
properties.appendChild(itemsDiscovered);
for (AbstractItemType itemType : this.itemsDiscovered) {
Element element = doc.createElement("itemType");
itemsDiscovered.appendChild(element);
Attr hash = doc.createAttribute("id");
hash.setValue(itemType.getId());
element.setAttributeNode(hash);
}
Element weaponsDiscovered = doc.createElement("weaponsDiscovered");
properties.appendChild(weaponsDiscovered);
for (AbstractWeaponType weaponType : this.weaponsDiscovered) {
Element element = doc.createElement("weaponType");
weaponsDiscovered.appendChild(element);
Attr hash = doc.createAttribute("id");
hash.setValue(weaponType.getId());
element.setAttributeNode(hash);
}
Element clothingDiscovered = doc.createElement("clothingDiscovered");
properties.appendChild(clothingDiscovered);
for (AbstractClothingType clothingType : this.clothingDiscovered) {
Element element = doc.createElement("clothingType");
clothingDiscovered.appendChild(element);
Attr hash = doc.createAttribute("id");
if (clothingType != null)
hash.setValue(clothingType.getId());
element.setAttributeNode(hash);
}
Element racesDiscovered = doc.createElement("racesDiscovered");
properties.appendChild(racesDiscovered);
for (Race race : Race.values()) {
Element element = doc.createElement("raceDiscovery");
racesDiscovered.appendChild(element);
Attr discovered = doc.createAttribute("race");
discovered.setValue(race.toString());
element.setAttributeNode(discovered);
discovered = doc.createAttribute("discovered");
discovered.setValue(String.valueOf(this.racesDiscovered.contains(race)));
element.setAttributeNode(discovered);
discovered = doc.createAttribute("advancedKnowledge");
discovered.setValue(String.valueOf(this.racesAdvancedKnowledge.contains(race)));
element.setAttributeNode(discovered);
}
// Write out to properties.xml:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File("data/properties.xml"));
transformer.transform(source, result);
} catch (ParserConfigurationException | TransformerException e) {
e.printStackTrace();
}
}
Aggregations