From fb1f686d82bf011834dba7bdcf2105c6ed9c112b Mon Sep 17 00:00:00 2001 From: Tommy Ettinger Date: Sun, 29 May 2016 19:11:23 -0700 Subject: [PATCH] Release 3.0.0-b6 It seems like enough moderately-important fixes and additions are present here to warrant another release, and while I'm working on a "showcase" demo for gdx-setup, I might as well fix as many relevant bugs as possible. This commit adds a useful method in Maker to make LinkedHashSets, and also makes an icon atlas available via DefaultResources if the relevant files are present. This release adds a lot more in total! See release notes. --- LICENSE.txt | 2 ++ pom.xml | 2 +- squidlib-util/LICENSE.txt | 2 +- squidlib-util/pom.xml | 2 +- .../src/main/java/squidpony/Maker.java | 22 +++++++++++++ squidlib/LICENSE.txt | 3 ++ squidlib/pom.xml | 4 +-- .../squidgrid/gui/gdx/DefaultResources.java | 33 +++++++++++++++++++ squidlib/src/test/resources/icons-license.txt | 11 ++++--- 9 files changed, 72 insertions(+), 9 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 4b8c631ea5..1ec9cb0b3d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,3 +1,5 @@ +(Also see "math LICENSE.txt", "NOTICE.txt", and if you have the test +sources, "squidlib/src/test/resources/icons-license.txt") Apache License Version 2.0, January 2004 diff --git a/pom.xml b/pom.xml index bc5ffe847d..fb2dfb0622 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.squidpony squidlib-parent - 3.0.0-SNAPSHOT + 3.0.0-b6 pom squidlib-parent diff --git a/squidlib-util/LICENSE.txt b/squidlib-util/LICENSE.txt index 4b8c631ea5..5ad9f2203f 100644 --- a/squidlib-util/LICENSE.txt +++ b/squidlib-util/LICENSE.txt @@ -1,4 +1,4 @@ - +(Also see "math LICENSE.txt" and "NOTICE.txt") Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ diff --git a/squidlib-util/pom.xml b/squidlib-util/pom.xml index 7a85d50b2c..613d6f2ba2 100644 --- a/squidlib-util/pom.xml +++ b/squidlib-util/pom.xml @@ -6,7 +6,7 @@ com.squidpony squidlib-parent - 3.0.0-SNAPSHOT + 3.0.0-b6 ../ squidlib-util diff --git a/squidlib-util/src/main/java/squidpony/Maker.java b/squidlib-util/src/main/java/squidpony/Maker.java index 391be0c8c9..c58d402634 100644 --- a/squidlib-util/src/main/java/squidpony/Maker.java +++ b/squidlib-util/src/main/java/squidpony/Maker.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; /** * Utility methods for more easily constructing data structures, particularly those in Java's standard library. @@ -77,6 +78,12 @@ public static LinkedHashMap makeLHM() return new LinkedHashMap<>(); } + /** + * Makes an ArrayList of T given an array or vararg of T elements. + * @param elements an array or vararg of T + * @param just about any non-primitive type + * @return a newly-allocated ArrayList containing all of elements, in order + */ @SafeVarargs public static ArrayList makeList(T... elements) { if(elements == null) return null; @@ -85,4 +92,19 @@ public static ArrayList makeList(T... elements) { return list; } + /** + * Makes a LinkedHashSet (LHS) of T given an array or vararg of T elements. Duplicate items in elements will have + * all but one item discarded, using the later item in elements. + * @param elements an array or vararg of T + * @param just about any non-primitive type + * @return a newly-allocated LinkedHashSet containing all of the non-duplicate items in elements, in order + */ + @SafeVarargs + public static LinkedHashSet makeLHS(T... elements) { + if(elements == null) return null; + LinkedHashSet set = new LinkedHashSet<>(elements.length); + Collections.addAll(set, elements); + return set; + } + } diff --git a/squidlib/LICENSE.txt b/squidlib/LICENSE.txt index 4b8c631ea5..dc2efd0380 100644 --- a/squidlib/LICENSE.txt +++ b/squidlib/LICENSE.txt @@ -1,3 +1,6 @@ +(Also see "math LICENSE.txt", "NOTICE.txt", and if you have the test +sources, "src/test/resources/icons-license.txt") + Apache License Version 2.0, January 2004 diff --git a/squidlib/pom.xml b/squidlib/pom.xml index 19e0787434..da2651d1c1 100644 --- a/squidlib/pom.xml +++ b/squidlib/pom.xml @@ -6,7 +6,7 @@ com.squidpony squidlib-parent - 3.0.0-SNAPSHOT + 3.0.0-b6 ../ squidlib @@ -26,7 +26,7 @@ com.squidpony squidlib-util - 3.0.0-SNAPSHOT + 3.0.0-b6 diff --git a/squidlib/src/main/java/squidpony/squidgrid/gui/gdx/DefaultResources.java b/squidlib/src/main/java/squidpony/squidgrid/gui/gdx/DefaultResources.java index 617c0c2279..9db1b56fd7 100644 --- a/squidlib/src/main/java/squidpony/squidgrid/gui/gdx/DefaultResources.java +++ b/squidlib/src/main/java/squidpony/squidgrid/gui/gdx/DefaultResources.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.LifecycleListener; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.glutils.ShaderProgram; import squidpony.squidmath.StatefulRNG; @@ -35,6 +36,7 @@ public class DefaultResources implements LifecycleListener { unicode1 = null, unicode2 = null; private TextCellFactory distanceNarrow = null, distanceSquare = null, typewriterDistanceNarrow = null, distancePrint = null, distanceClean = null; + private TextureAtlas iconAtlas = null; public static final String squareName = "Zodiac-Square-12x12.fnt", narrowName = "Rogue-Zodiac-6x12.fnt", unicodeName = "Mandrill-6x16.fnt", @@ -452,6 +454,33 @@ public static TextureRegion getTentacle() return instance.tentacleRegion; } + + /** + * Gets a TextureAtlas containing many icons with a distance field effect applied, allowing them to be used with + * "stretchable" fonts and be resized in the same way. These will not look as-expected if stretchable fonts are not + * in use, and will seem hazy and indistinct if the shader hasn't been set up for a distance field effect by + * TextCellFactory (which stretchable fonts will do automatically). The one page of the TextureAtlas is 2048x2048, + * which may be too large for some old, low-end Android phones, and possibly integrated graphics with fairly old + * processors on desktop. It has over 2000 icons. + *
+ * The icons are CC-BY and the license is distributed with them, though the icons are not necessarily included with + * SquidLib. If you use the icon atlas, be sure to include icons-license.txt with it and reference it with your + * game's license and/or credits information. + * @return a TextureAtlas containing over 2000 icons with a distance field effect + */ + public static TextureAtlas getIconAtlas() + { + initialize(); + if(instance.iconAtlas == null) + { + try { + instance.iconAtlas = new TextureAtlas(Gdx.files.internal("icons.atlas")); + } catch (Exception ignored) { + } + } + return instance.iconAtlas; + } + /** * This is a static global StatefulRNG that's meant for usage in cases where the seed does not matter and any * changes to this RNG's state will not change behavior elsewhere in the program; this means the GUI mainly. @@ -580,6 +609,10 @@ public void pause() { tentacle.dispose(); tentacle = null; } + if(iconAtlas != null) { + iconAtlas.dispose(); + iconAtlas = null; + } } /** diff --git a/squidlib/src/test/resources/icons-license.txt b/squidlib/src/test/resources/icons-license.txt index eb84c29187..0c7c392b83 100644 --- a/squidlib/src/test/resources/icons-license.txt +++ b/squidlib/src/test/resources/icons-license.txt @@ -1,6 +1,7 @@ Icons provided under the Creative Commons 3.0 BY license. -Each subfolders in this archive correspond to a different contributor : +The icons in icons.png are the work of several different contributors, and if you distribute icons.png you must give +attribution for all of them (they're all in the same image). The contributors are: - Lorc, http://lorcblog.blogspot.com - Delapouite, http://delapouite.com @@ -21,8 +22,10 @@ Each subfolders in this archive correspond to a different contributor : Please, include a mention "Icons made by {author}" in your derivative work. -If you use them in one of your project, don't hesitate to drop a message to delapouite@gmail.com so we can add your creation to the showcase page. +If you use them in one of your project, don't hesitate to drop a message to delapouite@gmail.com so we can add your +creation to the showcase page. -More info and icons available at game-icons.net +More info and icons available at http://game-icons.net -These icons (the May 23, 2016 batch) have all been merged into one texture atlas, and modifications made to imitate the vector resizability with a distance field effect. +These icons (the May 23, 2016 batch) have all been merged into one texture atlas, and modifications made to imitate the +resizability of the vector version with a distance field effect.