From 37d06e98d37ffeb2b6537854c8eaa45ad13f9df1 Mon Sep 17 00:00:00 2001 From: totemo Date: Tue, 11 Aug 2015 18:32:02 +0930 Subject: [PATCH] Add a vector_length configuration setting that specifies the default minimum length of a vector for it to be visible. Configuring that value is a persistent way of doing "/w vector length " - it also sets the current vector length. Fixed /w config's handling of some settings so that when a new value is not specified, the setting is either toggled (if boolean) or the current value shown. Fixed saving of time_ordered_deposits in the configuration file (typo in the previous commit). --- Changes.md | 6 ++- README.md | 11 +++- build/buildnumber.txt | 4 +- res/litemod.json | 4 +- src/watson/Configuration.java | 37 ++++++++++++- src/watson/DisplaySettings.java | 43 +++++++-------- src/watson/cli/WatsonCommand.java | 87 +++++++++++++++++++++++++------ 7 files changed, 146 insertions(+), 46 deletions(-) diff --git a/Changes.md b/Changes.md index 3ef3537..f828b80 100644 --- a/Changes.md +++ b/Changes.md @@ -1,9 +1,13 @@ Change History ============== -0.10.1.117-mc1.8.0 +0.10.1.118-mc1.8.0 ----------------- * For LogBlock, the following date formats are now supported: yyyy-MM-dd (ISO 8601), yy-MM-dd, MM-dd (the LogBlock default). * If reformatting of parsed results is enabled, kills are formatted as "killer weapon > victim". +* Added a time_ordered_deposits (on/off) configuration setting to number deposits strictly by timestamp, rather than considering rarity of the ore. +* Added a vector_length configuration setting that is the default minimum length for a vector to be visible. +* Fix ore deposit label billboards having a solid background colour; they can now be transparent again. +* /w config now shows colours in hexadecimal #AARRGGBB format. 0.10.0.115-mc1.8.0 ----------------- diff --git a/README.md b/README.md index 746fba8..4f6f367 100644 --- a/README.md +++ b/README.md @@ -139,9 +139,13 @@ Given the above commands for working with ore deposits, a basic x-ray checking p ### Manipulating the Vector and Outline Displays -Watson draws vectors (arrows) from each edit to the next edit which is more recent, provided that the distance in space between the edits is greater than the minimum vector length. The default minimum length is 4. To draw vectors between all edits: +Watson draws vectors (arrows) from each edit to the next edit which is more recent, provided that the distance in space between the edits is greater than the minimum vector length. The default minimum length is a configuration setting that defaults to 4.0. To draw vectors between all edits: - /w vector length 1 + /w vector length 0 + +The above command sets the minimum vector length for the current session. The minimum vector length can be permanently changed to that value using: + + /w config vector_length 0 To hide, show or toggle the vector display: @@ -467,6 +471,9 @@ Running "/w config help" will show help for all of the configuration settings. time_ordered_deposits on / off off When off (the default) ore deposits are numbered in order of their significance to investigating xray (diamonds before iron, before coal). When on, ore deposits are numbered in the order they were mined. /w config time_ordered_deposits on + + vector_length decimal 4.0 Specifies the minimum length (in blocks) of a vector for it to be visible. /w config vector_length 0 + diff --git a/build/buildnumber.txt b/build/buildnumber.txt index 9ec4061..34861f2 100644 --- a/build/buildnumber.txt +++ b/build/buildnumber.txt @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sat Jun 20 10:23:32 ACST 2015 -build.number=116 +#Tue Aug 11 17:57:57 ACST 2015 +build.number=119 diff --git a/res/litemod.json b/res/litemod.json index 18e35bd..a29ace2 100644 --- a/res/litemod.json +++ b/res/litemod.json @@ -4,8 +4,8 @@ "name": "watson", "mcversion": "1.8.0", - "version": "0.10.0.115-mc1.8.0", - "revision": "115", + "version": "0.10.0.118-mc1.8.0", + "revision": "118", "author": "totemo", "description": "A 3-D log visualisation tool." } diff --git a/src/watson/Configuration.java b/src/watson/Configuration.java index 2331fff..8ac78c8 100644 --- a/src/watson/Configuration.java +++ b/src/watson/Configuration.java @@ -83,6 +83,7 @@ public void message(String text) _reformatQueryResults = (Boolean) dom.get("reformat_query_results"); _recolourQueryResults = (Boolean) dom.get("recolour_query_results"); _timeOrderedDeposits = (Boolean) dom.get("time_ordered_deposits"); + _vectorLength = ((Double) dom.get("vector_length")).floatValue(); } catch (Exception ex) { @@ -124,7 +125,8 @@ public void save() dom.put("ss_date_directory", _ssDateDirectory.toPattern()); dom.put("reformat_query_results", _reformatQueryResults); dom.put("recolour_query_results", _recolourQueryResults); - dom.put("time_ordered_desposits", _timeOrderedDeposits); + dom.put("time_ordered_deposits", _timeOrderedDeposits); + dom.put("vector_length", (double) _vectorLength); DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); @@ -745,6 +747,34 @@ public boolean timeOrderedDeposits() return _timeOrderedDeposits; } + // -------------------------------------------------------------------------- + /** + * Set the default minimum length of vectors for them to be visible. + * + * The current displayed minimum vector length is also set. + * + * @param length the minimum length of a vector for it to be visible. + */ + public void setVectorLength(float length) + { + _vectorLength = length; + Controller.instance.getDisplaySettings().setMinVectorLength(length); + save(); + } + + // -------------------------------------------------------------------------- + /** + * Set the default minimum length of vectors for them to be visible. + * + * The current displayed minimum vector length is also set. + * + * @param length the minimum length of a vector for it to be visible. + */ + public float getVectorLength() + { + return _vectorLength; + } + // -------------------------------------------------------------------------- /** * Perform lazy initialisation of the SnakeValidator used to validate in @@ -780,6 +810,7 @@ protected void configureValidator() root.addChild("reformat_query_results", new TypeValidatorNode(Boolean.class, true, true)); root.addChild("recolour_query_results", new TypeValidatorNode(Boolean.class, true, true)); root.addChild("time_ordered_deposits", new TypeValidatorNode(Boolean.class, true, false)); + root.addChild("vector_length", new TypeValidatorNode(Double.class, true, 4.0)); _validator.setRoot(root); } @@ -914,5 +945,9 @@ protected void configureValidator() */ protected boolean _timeOrderedDeposits = false; + /** + * The default minimum length of vectors for them to be visible. + */ + protected float _vectorLength = 4.0f; } // class Configuration diff --git a/src/watson/DisplaySettings.java b/src/watson/DisplaySettings.java index 2f4fa81..1e43767 100644 --- a/src/watson/DisplaySettings.java +++ b/src/watson/DisplaySettings.java @@ -3,7 +3,7 @@ import net.minecraft.world.WorldSettings; import watson.chat.Chat; -// -------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- /** * Records the current settings that affect the Watson displays. */ @@ -20,12 +20,13 @@ public void configure(String serverIP, WorldSettings.GameType gameType) // presence of ModMode and its associated notifications to turn on or off // the display. _displayed = gameType.isCreative(); + _minVectorLength = Configuration.instance.getVectorLength(); } // -------------------------------------------------------------------------- /** * Turn on or off all Watson displays. - * + * * @param displayed true if Watson draws stuff; false otherwise. */ public void setDisplayed(boolean displayed) @@ -38,7 +39,7 @@ public void setDisplayed(boolean displayed) // -------------------------------------------------------------------------- /** * Return true if Watson draws stuff; false otherwise. - * + * * @return true if Watson draws stuff; false otherwise. */ public boolean isDisplayed() @@ -50,10 +51,10 @@ public boolean isDisplayed() /** * Return true if the Watson display's visibility setting has changed since * the last time this method was called. - * + * * This is used by the Watson Macro/Keybind Support mod to determine when to * dispatch the corresponding event. - * + * * @return true if isDisplayed() has changed. */ public boolean isDisplayVisibilityChanged() @@ -66,7 +67,7 @@ public boolean isDisplayVisibilityChanged() // -------------------------------------------------------------------------- /** * Turn on or off the wireframe block outline display. - * + * * @param outlineShown if true, block outlines are drawn. */ public void setOutlineShown(boolean outlineShown) @@ -78,11 +79,11 @@ public void setOutlineShown(boolean outlineShown) // -------------------------------------------------------------------------- /** * Return true if block outines should be drawn. - * + * * This method takes into account the last calls to both setOutlineShown() and * setDisplayed(). It will return false if outlines are disabled or if the * overall Watson display is turned off. - * + * * @return true if block outines should be drawn. */ public boolean isOutlineShown() @@ -93,7 +94,7 @@ public boolean isOutlineShown() // -------------------------------------------------------------------------- /** * Turn on or off the annotation display. - * + * * @param annotationsShown if true, annotations are drawn. */ public void setAnnotationsShown(boolean annotationsShown) @@ -106,7 +107,7 @@ public void setAnnotationsShown(boolean annotationsShown) // -------------------------------------------------------------------------- /** * Return true if block annotations should be drawn. - * + * * @return true if block annotations should be drawn. */ public boolean areAnnotationsShown() @@ -117,7 +118,7 @@ public boolean areAnnotationsShown() // -------------------------------------------------------------------------- /** * Turn on or off the ore deposit number labels. - * + * * @param labelsShown if true, labels are shown. */ public void setLabelsShown(boolean labelsShown) @@ -129,7 +130,7 @@ public void setLabelsShown(boolean labelsShown) // -------------------------------------------------------------------------- /** * Return true if ore deposit labels should be drawn. - * + * * @return true if ore deposit labels should be drawn. */ public boolean areLabelsShown() @@ -140,7 +141,7 @@ public boolean areLabelsShown() // -------------------------------------------------------------------------- /** * Turn on or off the wireframe vector display. - * + * * @param outlineShown if true, vectors between sufficiently spaced blocks are * drawn. */ @@ -153,11 +154,11 @@ public void setVectorsShown(boolean vectorsShown) // -------------------------------------------------------------------------- /** * Return true if block outines should be drawn. - * + * * This method takes into account the last calls to both setOutlineShown() and * setDisplayed(). It will return false if outlines are disabled or if the * overall Watson display is turned off. - * + * * @return true if block outines should be drawn. */ public boolean areVectorsShown() @@ -169,7 +170,7 @@ public boolean areVectorsShown() /** * Control whether block creations are linked by vectors (when they are * shown). - * + * * @param linkedCreations if true, links are drawn. */ public void setLinkedCreations(boolean linkedCreations) @@ -182,7 +183,7 @@ public void setLinkedCreations(boolean linkedCreations) // -------------------------------------------------------------------------- /** * Return true if vectors are drawn between block creations. - * + * * @return true if vectors are drawn between block creations. */ public boolean isLinkedCreations() @@ -194,7 +195,7 @@ public boolean isLinkedCreations() /** * Control whether block destructions are linked by vectors (when they are * shown). - * + * * @param linkedDestructions if true, links are drawn. */ public void setLinkedDestructions(boolean linkedDestructions) @@ -207,7 +208,7 @@ public void setLinkedDestructions(boolean linkedDestructions) // -------------------------------------------------------------------------- /** * Return true if vectors are drawn between block destructions. - * + * * @return true if vectors are drawn between block destructions. */ public boolean isLinkedDestructions() @@ -218,7 +219,7 @@ public boolean isLinkedDestructions() // -------------------------------------------------------------------------- /** * Set the minimum length of a vector between edits for it to be drawn. - * + * * @param minVectorLength */ public void setMinVectorLength(float minVectorLength) @@ -231,7 +232,7 @@ public void setMinVectorLength(float minVectorLength) // -------------------------------------------------------------------------- /** * Return the minimum length of a vector between edits for it to be drawn. - * + * * @return the minimum length of a vector between edits for it to be drawn. */ public float getMinVectorLength() diff --git a/src/watson/cli/WatsonCommand.java b/src/watson/cli/WatsonCommand.java index 2e0c842..07568dc 100644 --- a/src/watson/cli/WatsonCommand.java +++ b/src/watson/cli/WatsonCommand.java @@ -959,48 +959,96 @@ else if (args.length >= 3) // Enable or disable the reformatting of query results. if (args[1].equals("reformat_query_results")) { - if (args[2].equals("on")) + if (args.length == 2) { - Configuration.instance.setReformatQueryResults(true); + Configuration.instance.setReformatQueryResults(!Configuration.instance.getReformatQueryResults()); return true; } - else if (args[2].equals("off")) + else if (args.length == 3) { - Configuration.instance.setReformatQueryResults(false); - return true; + if (args[2].equals("on")) + { + Configuration.instance.setReformatQueryResults(true); + return true; + } + else if (args[2].equals("off")) + { + Configuration.instance.setReformatQueryResults(false); + return true; + } } } // /w config reformat_query_results // Enable or disable the recolouring of query results. if (args[1].equals("recolour_query_results")) { - if (args[2].equals("on")) + if (args.length == 2) { - Configuration.instance.setRecolourQueryResults(true); + Configuration.instance.setRecolourQueryResults(!Configuration.instance.getRecolourQueryResults()); return true; } - else if (args[2].equals("off")) + else if (args.length == 3) { - Configuration.instance.setRecolourQueryResults(false); - return true; + if (args[2].equals("on")) + { + Configuration.instance.setRecolourQueryResults(true); + return true; + } + else if (args[2].equals("off")) + { + Configuration.instance.setRecolourQueryResults(false); + return true; + } } } // /w config recolour_query_results // Enable timestamp-only ordering of ore deposits. if (args[1].equals("time_ordered_deposits")) { - if (args[2].equals("on")) + if (args.length == 2) { - Configuration.instance.setTimeOrderedDeposits(true); + Configuration.instance.setTimeOrderedDeposits(!Configuration.instance.timeOrderedDeposits()); return true; } - else if (args[2].equals("off")) + else if (args.length == 3) { - Configuration.instance.setTimeOrderedDeposits(false); - return true; + if (args[2].equals("on")) + { + Configuration.instance.setTimeOrderedDeposits(true); + return true; + } + else if (args[2].equals("off")) + { + Configuration.instance.setTimeOrderedDeposits(false); + return true; + } } } // /w config time_ordered_deposits + // Minimum vector length (initial value for /w vector length ). + if (args[1].equals("vector_length")) + { + if (args.length == 2) + { + float length = Configuration.instance.getVectorLength(); + localOutput(sender, "The default minimum length of a vector for it to be visible is " + length + " blocks."); + return true; + } + else if (args.length == 3) + { + try + { + float length = Math.max(0.0f, Float.parseFloat(args[2])); + Configuration.instance.setVectorLength(length); + } + catch (NumberFormatException ex) + { + localError(sender, "The minimum vector length should be a number."); + } + return true; + } + } // /w config vector_length + // Help with /w config if (args[1].equals("help")) { @@ -1049,12 +1097,17 @@ else if (args[2].equals("off")) sender, " /" + w - + " config time_ordered_deposits [on/off] : number deposits in according to their timestamp (on), or their scarcity (off)"); + + " config time_ordered_deposits [on/off] : number deposits according to their timestamp (on), or their scarcity (off)"); + localOutput( + sender, + " /" + + w + + " config vector_length [decimal]: set the default minimum length of a vector for it to be visible"); return true; } // /w config help return false; - } // handleConfigCommand + }// handleConfigCommand // -------------------------------------------------------------------------- /**