-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
136 lines (124 loc) · 4.89 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import scala.sys.process._
import scala.language.postfixOps
import indigoplugin.IndigoGenerators
import indigoplugin.IndigoOptions
import sbtwelcome._
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0"
val scala3Version = "3.3.1"
lazy val pirateOptions: IndigoOptions =
IndigoOptions.defaults
.withTitle("The Cursed Pirate")
.withWindowWidth(1280)
.withWindowHeight(720)
.withBackgroundColor("black")
.excludeAssetPaths {
case p if p.contains("unused") => true
case p if p.contains("Captain Clown Nose Data.json") => true
}
lazy val pirate =
(project in file("."))
.enablePlugins(
ScalaJSPlugin,
SbtIndigo
)
.settings(
name := "pirate",
version := "0.0.1",
scalaVersion := scala3Version,
organization := "pirate",
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % "0.7.29" % Test,
"org.scalacheck" %%% "scalacheck" % "1.15.3" % "test"
),
Test / scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }
)
.settings(
indigoOptions := pirateOptions,
libraryDependencies ++= Seq(
"io.indigoengine" %%% "indigo-json-circe" % "0.16.0",
"io.indigoengine" %%% "indigo" % "0.16.0",
"io.indigoengine" %%% "indigo-extras" % "0.16.0"
),
Compile / sourceGenerators += Def.task {
val cachedFun = FileFunction.cached(
streams.value.cacheDirectory / "pirate-gen"
) { _ =>
IndigoGenerators("pirate.generated")
.listAssets("Assets", pirateOptions.assets)
.generateConfig("Config", pirateOptions)
.embedAseprite("CaptainAnim", baseDirectory.value / "assets" / "captain" / "Captain Clown Nose Data.json")
.toSourceFiles((Compile / sourceManaged).value)
.toSet
}
cachedFun(IO.listFiles(baseDirectory.value / "assets").toSet).toSeq
}
)
.enablePlugins(GhpagesPlugin)
.settings(
siteSourceDirectory := target.value / "indigoBuildFull",
makeSite / includeFilter := "*",
makeSite / excludeFilter := ".DS_Store",
git.remoteRepo := "[email protected]:PurpleKingdomGames/pirate-demo.git",
ghpagesNoJekyll := true,
ghpagesBranch := "gh-pages"
)
.settings(
code := {
val command = Seq("code", ".")
val run = sys.props("os.name").toLowerCase match {
case x if x contains "windows" => Seq("cmd", "/C") ++ command
case _ => command
}
run.!
}
)
.settings(
logo := rawLogo + "(v" + version.value.toString + ")",
usefulTasks := Seq(
UsefulTask("runGame", "Run the game").noAlias,
UsefulTask("buildGame", "Build web version").noAlias,
UsefulTask("runGameFull", "Run the fully optimised game").noAlias,
UsefulTask(
"buildGameFull",
"Build the fully optimised web version"
).noAlias,
UsefulTask("publishGame", "Publish the game to ghpages").noAlias,
UsefulTask("code", "Launch VSCode").noAlias
),
logoColor := scala.Console.MAGENTA,
aliasColor := scala.Console.YELLOW,
commandColor := scala.Console.CYAN,
descriptionColor := scala.Console.WHITE
)
addCommandAlias("buildGame", ";compile;fastLinkJS;indigoBuild")
addCommandAlias("buildGameFull", ";compile;fullOptJS;indigoBuildFull")
addCommandAlias("runGame", ";compile;fastLinkJS;indigoRun")
addCommandAlias("runGameFull", ";compile;fullOptJS;indigoRunFull")
addCommandAlias(
"publishGame",
List(
"buildGameFull",
"makeSite",
"ghpagesPushSite"
).mkString(";", ";", "")
)
lazy val code =
taskKey[Unit]("Launch VSCode in the current directory")
lazy val rawLogo =
"""
_______ .-. .-.,---. ,--, .-. .-.,---. .---. ,---. ,'|"\
|__ __|| | | || .-' .' .') | | | || .-.\ ( .-._)| .-' | |\ \
)| | | `-' || `-. | |(_) | | | || `-'/ (_) \ | `-. | | \ \
(_) | | .-. || .-' \ \ | | | || ( _ \ \ | .-' | | \ \
| | | | |)|| `--. \ `-. | `-')|| |\ \( `-' ) | `--. /(|`-' /
`-' /( (_)/( __.' \____\`---(_)|_| \)\`----' /( __.'(__)`--'
(__) (__) (__) (__)
,---. ,-.,---. .--. _______ ,---.
| .-.\ |(|| .-.\ / /\ \|__ __|| .-'
| |-' )(_)| `-'/ / /__\ \ )| | | `-.
| |--' | || ( | __ |(_) | | .-'
| | | || |\ \ | | |)| | | | `--.
/( `-'|_| \)\|_| (_) `-' /( __.'
(__) (__) (__)
"""