Skip to content

Commit

Permalink
Release 3.0.0-b6
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tommyettinger committed May 30, 2016
1 parent fc50462 commit fb1f686
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 9 deletions.
2 changes: 2 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.squidpony</groupId>
<artifactId>squidlib-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-b6</version>
<packaging>pom</packaging>

<name>squidlib-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion squidlib-util/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

(Also see "math LICENSE.txt" and "NOTICE.txt")
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
2 changes: 1 addition & 1 deletion squidlib-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.squidpony</groupId>
<artifactId>squidlib-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-b6</version>
<relativePath>../</relativePath>
</parent>
<artifactId>squidlib-util</artifactId>
Expand Down
22 changes: 22 additions & 0 deletions squidlib-util/src/main/java/squidpony/Maker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -77,6 +78,12 @@ public static <K, V> LinkedHashMap<K, V> 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 <T> just about any non-primitive type
* @return a newly-allocated ArrayList containing all of elements, in order
*/
@SafeVarargs
public static <T> ArrayList<T> makeList(T... elements) {
if(elements == null) return null;
Expand All @@ -85,4 +92,19 @@ public static <T> ArrayList<T> 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 <T> 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 <T> LinkedHashSet<T> makeLHS(T... elements) {
if(elements == null) return null;
LinkedHashSet<T> set = new LinkedHashSet<>(elements.length);
Collections.addAll(set, elements);
return set;
}

}
3 changes: 3 additions & 0 deletions squidlib/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions squidlib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.squidpony</groupId>
<artifactId>squidlib-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-b6</version>
<relativePath>../</relativePath>
</parent>
<artifactId>squidlib</artifactId>
Expand All @@ -26,7 +26,7 @@
<dependency>
<groupId>com.squidpony</groupId>
<artifactId>squidlib-util</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-b6</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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.
* <br>
* 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.
Expand Down Expand Up @@ -580,6 +609,10 @@ public void pause() {
tentacle.dispose();
tentacle = null;
}
if(iconAtlas != null) {
iconAtlas.dispose();
iconAtlas = null;
}
}

/**
Expand Down
11 changes: 7 additions & 4 deletions squidlib/src/test/resources/icons-license.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.

0 comments on commit fb1f686

Please sign in to comment.