Reddo пре 5 година
родитељ
комит
9e7fdf2504

+ 26 - 16
app/Controls/Classes/ContentType.ts

@@ -3,6 +3,7 @@
 /// <reference path="../Modules/ContentHandler.ts" />
 interface ContentTypeOptions {
     id : string;
+    name : string;
     defaultValue : boolean;
     description : Say | string;
     currentValueDescription? : (c : ContentType) => Say | string;
@@ -16,6 +17,7 @@ interface ContentTypeOptions {
 }
 
 class ContentType extends StoredMemory<boolean> {
+    public name : string;
     private description : Say;
     private valueDescription : (c : ContentType) => Say | string = () => { return new Say (JSON.stringify(this.getValue())); };
     private changeable : boolean = true;
@@ -34,6 +36,8 @@ class ContentType extends StoredMemory<boolean> {
             this.changeable = false;
         }
 
+        this.name = options.name;
+
         ContentHandler.registerContentType(this);
     }
 
@@ -41,6 +45,10 @@ class ContentType extends StoredMemory<boolean> {
         return this.description;
     }
 
+    public getName () {
+        return this.name;
+    }
+
     public getValueDescription () {
         let desc = this.valueDescription(this);
         if (desc instanceof Say) {
@@ -60,9 +68,14 @@ class ContentType extends StoredMemory<boolean> {
         return this.getValue();
     }
 
+    public isChangeable () {
+        return this.changeable;
+    }
+
     public static MM = new ContentType({
         changeable : false, // There will be too little content at first for us to block part of it for no good reason, maybe at some point
-        description : "Homosexual (M/M) sexual events",
+        name: "Male-Male",
+        description : "Homosexual (M/M) sexual encounters.",
         id : "MM",
         defaultValue : true
     });
@@ -70,7 +83,8 @@ class ContentType extends StoredMemory<boolean> {
 
     public static FF = new ContentType({
         changeable : false, // There will be too little content at first for us to block part of it for no good reason, maybe at some point
-        description : "Homosexual (F/F) sexual events",
+        description : "Homosexual (F/F) sexual events.",
+        name : "Female-Female",
         id : "FF",
         defaultValue : true
     });
@@ -78,7 +92,8 @@ class ContentType extends StoredMemory<boolean> {
 
     public static MF = new ContentType({
         changeable : false, // There will be too little content at first for us to block part of it for no good reason, maybe at some point
-        description : "Heterosexual (M/F) sexual events",
+        name : "Male-Female",
+        description : "Heterosexual (M/F) sexual events.",
         id : "MF",
         defaultValue : true
     });
@@ -86,23 +101,18 @@ class ContentType extends StoredMemory<boolean> {
 
     public static Beast = new ContentType({
         changeable : true,
-        description : "Sexual events with either monsters or magical beasts. MM/MF/FF take precedence over this one if blocked. Sufficiently human creatures do not get counted into this.",
+        description : "Sexual events with either monsters or magical beasts. MM/MF/FF take precedence over this one if blocked. Sufficiently human creatures (like Orcs and even Ogres) do not get counted into this, furry ones (Minotaurs) do..",
         id : "Beast",
+        name : "Beast mode",
         defaultValue : true
     });
 
 
-    public static Scat = new ContentType({
-        changeable : false,
-        description : "Scatologic sexual events",
-        id : "Scat",
-        defaultValue : false // There is no intention of ever adding these
-    });
-
-    public static Pee = new ContentType({
-        changeable : false,
-        description : "Sexual events with urine",
-        id : "Urophilia",
-        defaultValue : false // There is no intention of ever adding these
+    public static Ravishment = new ContentType({
+        changeable : true,
+        description : "Allows sexual events to be initiated and continued by NPCs regardless of what the player says or does. Without this, sexual events can only be initiated by the player.",
+        id : "Ravish",
+        name : "Ravishment",
+        defaultValue : true
     });
 }

+ 55 - 3
app/Controls/Modules/KeyHandler.ts

@@ -151,14 +151,14 @@ module Controls.KeyHandler {
         "keyCodesRoom",
         createKeyCodes( ["Digit1", "Digit2", "Digit3", "Digit4", "Digit5"],
                          ["1", "2", "3", "4", "5"],
-                        [true, true, true, true])
+                        [true, true, true, false])
     );
 
     export var keyCodes2 = new StoredMemory(
         "keyCodesActions",
         createKeyCodes( ["KeyQ", "KeyW", "KeyE", "KeyR", "KeyT"],
             ["Q", "W", "E", "R", "T"],
-            [true, true, true, true])
+            [true, true, true, false])
     );
 
 
@@ -167,7 +167,7 @@ module Controls.KeyHandler {
         "keyCodesGlobal",
         createKeyCodes( ["KeyF", "KeyV", "KeyG", "KeyB"],
             ["F", "V", "G", "B"],
-            [true, true, true, true])
+            [true, true, true, false])
     );
 
     export var keyCodeNorth = new StoredMemory(
@@ -230,6 +230,7 @@ module Controls.KeyHandler {
         return directionCodeByIndex[index].getValue();
     }
 
+    export var keyRows = 3;
     export var available1 : Array<KeyCode> = [];
     export var available2 : Array<KeyCode> = [];
     export var available3 : Array<KeyCode> = [];
@@ -314,4 +315,55 @@ module Controls.KeyHandler {
             rejectPromise(promiseStack[index]);
         }
     }
+
+    export function addKey (row : number, ev : KeyboardEvent) {
+        let keyName = ev.key.toUpperCase();
+        if (["ALT", "CONTROL", "SHIFT", " ", "TAB"].includes(keyName)) {
+            return;
+        }
+        if (keyName == "BACKSPACE") {
+            clearKeys(row);
+            return;
+        }
+        if (row >= 1 && row <= Controls.KeyHandler.keyRows) {
+            let rowArray : StoredMemory<Array<KeyCode>> = Controls.KeyHandler["keyCodes" + row];
+            let keyArray = rowArray.getValue().splice(0);
+            keyArray.push(...
+                createKeyCodes( [ev.code],
+                    [keyName],
+                    [true, true, true, false])
+            );
+
+            let modNumber = (name : string) => {
+                if (name.indexOf("Shift") != -1) {
+                    return 1;
+                } else if (name.indexOf("Control") != -1) {
+                    return 2;
+                } else if (name.indexOf("Alt") != -1) {
+                    return 3;
+                }
+                return 0;
+            };
+
+            keyArray.sort((a, b) => {
+                let ma = modNumber(a.name);
+                let mb = modNumber(b.name);
+                if (ma != mb) {
+                    return ma - mb;
+                }
+                if (a.representation < b.representation) return -1;
+                else if (a.representation > b.representation) return 1;
+                return 0;
+            });
+
+            rowArray.storeValue(keyArray);
+        }
+    }
+
+    export function clearKeys (row : number) {
+        if (row >= 1 && row <= Controls.KeyHandler.keyRows) {
+            let rowArray: StoredMemory<Array<KeyCode>> = Controls.KeyHandler["keyCodes" + row];
+            rowArray.storeValue([]);
+        }
+    }
 }

+ 88 - 0
app/Controls/Modules/KeyHandler/KeySetter.ts

@@ -0,0 +1,88 @@
+module Controls.KeyHandler.KeySetter {
+    let resolver;
+    let div = document.createElement("div");
+
+    function printTable() {
+        let p = document.createElement("p");
+        p.classList.add("content");
+        p.appendChild(document.createTextNode("Each row usually has a purpose, though an row will do if there are not enough keys in the ideal row."));
+        Elements.CurrentTurnHandler.print(p);
+
+        p = document.createElement("p");
+        p.classList.add("content");
+        p.appendChild(document.createTextNode("Row 1 is preferred for Choices and Room Objects. Row 2 is used for commands relating to the selected thing (Take, Wear). Row 3 is used for commands that you do without targets (Get Up, Wait, Save game)."));
+        Elements.CurrentTurnHandler.print(p);
+
+        p = document.createElement("p");
+        p.classList.add("content");
+        p.appendChild(document.createTextNode("Select the row you wish to edit and press keys to add them to the list. You can press Backspace to clear it."));
+        Elements.CurrentTurnHandler.print(p);
+
+
+
+        for (let i = 1; i <= Controls.KeyHandler.keyRows; i++) {
+            let p = document.createElement("p");
+            p.classList.add("content");
+            p.appendChild(document.createTextNode("Row " + i + ": "));
+
+            let input = document.createElement("input");
+            input.classList.add("keySelectorInput");
+            p.appendChild(input);
+
+            let updateInput = () => {
+                let keys = <Array<KeyCode>> Controls.KeyHandler["keyCodes" + i].getValue();
+                let values = [];
+                keys.forEach(key => {
+                    values.push(key.representation)
+                });
+                input.value = values.join("; ");
+            };
+
+            updateInput();
+
+            let inputF = (ev : KeyboardEvent) => {
+                Controls.KeyHandler.addKey(i, ev);
+                updateInput();
+                ev.stopPropagation();
+                ev.preventDefault();
+            };
+
+            input.addEventListener("keydown", inputF);
+            input.addEventListener("keyup", (ev) => {ev.stopPropagation();});
+            Elements.CurrentTurnHandler.print(p);
+        }
+    }
+
+    function printConfirm () {
+        (new Say("Confirm")).getHTML("p", ["choice"]).then(elementArray => {
+            elementArray[0].addEventListener("click", () => {
+                resolver();
+            });
+            Controls.KeyHandler.applyCode(elementArray[0], Controls.KeyHandler.getSecondKeyCode());
+            Elements.CurrentTurnHandler.print(elementArray[0]);
+        });
+    }
+
+    function reset () {
+        Elements.CurrentTurnHandler.clear();
+        Elements.CurrentTurnHandler.print(div);
+        printTable();
+        Elements.CurrentTurnHandler.print(document.createElement("br"));
+        Elements.CurrentTurnHandler.print(document.createElement("br"));
+        printConfirm();
+    }
+
+    export async function setKeys () {
+        Elements.startMenu();
+
+        let promise = new Promise(resolve => {
+            resolver = resolve;
+        });
+
+        reset();
+
+        await promise;
+
+        Elements.endMenu();
+    }
+}

+ 2 - 2
app/Elements/Modules/FontSize.ts

@@ -5,9 +5,9 @@
  */
 function updateFontSize () {
     var minWidth = Elements.isMobile? 800 : 1280;
-    var proportion = Elements.isMobile ? 17 : 14.5;
+    var proportion = new StoredMemory("FontProportion", Elements.isMobile ? 17 : 14.5);
     var width = document.body.clientWidth < minWidth ? minWidth : document.body.clientWidth;
-    document.documentElement.style[ "font-size" ] = (width * proportion / 1280) + "px";
+    document.documentElement.style[ "font-size" ] = (width * proportion.getValue() / 1280) + "px";
 }
 
 updateFontSize();