diff --git a/demos/pirate/assets/shaders/frag.frag b/demos/pirate/assets/shaders/frag.frag
deleted file mode 100644
index e1ec14e47..000000000
--- a/demos/pirate/assets/shaders/frag.frag
+++ /dev/null
@@ -1,48 +0,0 @@
-#version 300 es
-
-precision mediump float;
-
-uniform sampler2D SRC_CHANNEL;
-
-vec4 CHANNEL_0;
-vec4 COLOR;
-vec2 UV;
-vec2 TEXTURE_SIZE;
-vec2 SIZE;
-vec2 CHANNEL_0_POSITION;
-vec2 CHANNEL_0_SIZE;
-
-//
-layout (std140) uniform IndigoBitmapData {
- highp float FILLTYPE;
-};
-
-void fragment(){
-
- // 0 = normal; 1 = stretch; 2 = tile
- int fillType = int(round(FILLTYPE));
- vec4 textureColor;
-
- switch(fillType) {
- case 0:
- textureColor = CHANNEL_0;
- break;
-
- case 1:
- vec2 stretchedUVs = CHANNEL_0_POSITION + UV * CHANNEL_0_SIZE;
- textureColor = texture(SRC_CHANNEL, stretchedUVs);
- break;
-
- case 2:
- vec2 tiledUVs = CHANNEL_0_POSITION + (fract(UV * (SIZE / TEXTURE_SIZE)) * CHANNEL_0_SIZE);
- textureColor = texture(SRC_CHANNEL, tiledUVs);
- break;
-
- default:
- textureColor = CHANNEL_0;
- break;
- }
-
- COLOR = textureColor;
-}
-//
diff --git a/demos/pirate/assets/shaders/vert.vert b/demos/pirate/assets/shaders/vert.vert
deleted file mode 100644
index f89903dbe..000000000
--- a/demos/pirate/assets/shaders/vert.vert
+++ /dev/null
@@ -1,3 +0,0 @@
-//
-void vertex(){}
-//
diff --git a/demos/pirate/build.sbt b/demos/pirate/build.sbt
index 15e7b329f..e1f4456b9 100644
--- a/demos/pirate/build.sbt
+++ b/demos/pirate/build.sbt
@@ -9,6 +9,13 @@ Global / onChangedBuildSource := ReloadOnSourceChanges
val scala3Version = "3.3.0"
+lazy val pirateOptions: IndigoOptions =
+ IndigoOptions.defaults
+ .withTitle("The Cursed Pirate")
+ .withWindowWidth(1280)
+ .withWindowHeight(720)
+ .withBackgroundColor("black")
+
lazy val pirate =
(project in file("."))
.enablePlugins(
@@ -27,22 +34,11 @@ lazy val pirate =
Test / scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }
)
.settings( // Indigo specific settings
- indigoOptions :=
- IndigoOptions.defaults
- .withTitle("The Cursed Pirate")
- .withWindowWidth(1280)
- .withWindowHeight(720)
- .withBackgroundColor("black")
- .excludeAssetPaths { case p: String if p.startsWith("shaders") => true },
+ indigoOptions := pirateOptions,
indigoGenerators :=
IndigoGenerators
- .sbt((Compile / sourceManaged).value, "some.pkg")
- .embedGLSLShaders(
- "MyShader",
- "assets/shaders/vert.vert",
- "assets/shaders/frag.frag",
- false
- ),
+ .sbt((Compile / sourceManaged).value, "pirate.generated")
+ .listAssets("GeneratedAssets", pirateOptions.assets),
libraryDependencies ++= Seq(
"io.indigoengine" %%% "indigo-json-circe" % IndigoVersion.getVersion, // Needed for Aseprite & Tiled support
"io.indigoengine" %%% "indigo" % IndigoVersion.getVersion, // Important! :-)
diff --git a/indigo-plugin/indigo-plugin/src/indigoplugin/generators/AssetListing.scala b/indigo-plugin/indigo-plugin/src/indigoplugin/generators/AssetListing.scala
index 4dc6bf8bb..21ebda00d 100644
--- a/indigo-plugin/indigo-plugin/src/indigoplugin/generators/AssetListing.scala
+++ b/indigo-plugin/indigo-plugin/src/indigoplugin/generators/AssetListing.scala
@@ -1,6 +1,7 @@
package indigoplugin.generators
import indigoplugin.IndigoAssets
+import scala.annotation.tailrec
object AssetListing {
@@ -67,6 +68,38 @@ object AssetListing {
renderFolderContents("", children, indent, toSafeName)
}
+ def errorOnDuplicates(files: List[PathTree.File], toSafeName: (String, String) => String): Unit = {
+ @tailrec
+ def rec(remaining: List[PathTree.File], acc: List[(String, PathTree.File, PathTree.File)]): List[String] =
+ remaining match {
+ case Nil =>
+ acc.map { case (n, a, b) =>
+ s"""'$n' is the safe name of both '${a.fullName}' and '${b.fullName}'."""
+ }
+
+ case e :: es =>
+ val errors = es
+ .filter(n => toSafeName(n.name, n.extension) == toSafeName(e.name, e.extension))
+ .map(n => (toSafeName(e.name, e.extension), e, n))
+ rec(es, acc ++ errors)
+ }
+
+ val errors = rec(files, Nil)
+
+ if (errors.nonEmpty) {
+ val msg =
+ s"""
+ |**Generated asset names collision!**
+ |You have one or more conflicting asset names. Please change these names, or move them to separate sub-folders within your assets directory."
+ |The following assets would have the same names in your generated asset listings code:
+ |
+ |${errors.mkString("\n")}
+ |""".stripMargin
+
+ println(msg)
+ } else ()
+ }
+
def renderFolderContents(
folderName: String,
children: List[PathTree],
@@ -79,6 +112,8 @@ object AssetListing {
val safeFolderName = toSafeName(folderName, "")
val files: List[PathTree.File] = children.collect { case f: PathTree.File => f }
+ errorOnDuplicates(files, toSafeName)
+
val renderedFiles: List[(String, String)] =
files
.map {