aboutsummaryrefslogtreecommitdiff
path: root/advtrains/spec/texture_spec.lua
diff options
context:
space:
mode:
authorY. Wang <yw05@forksworld.de>2023-06-02 13:30:54 +0200
committergpcf <gpcf@gpcf.eu>2024-08-08 22:48:23 +0200
commit0bfc7bbe099c7bba20cf1194b3ffad9471d0c7a4 (patch)
treeef8d8f3914b32fc29d9b46652861b854b4cb6844 /advtrains/spec/texture_spec.lua
parent4cfd07e992ae44ac9d06c4936df9dc8d71ac905b (diff)
downloadadvtrains-0bfc7bbe099c7bba20cf1194b3ffad9471d0c7a4.tar.gz
advtrains-0bfc7bbe099c7bba20cf1194b3ffad9471d0c7a4.tar.bz2
advtrains-0bfc7bbe099c7bba20cf1194b3ffad9471d0c7a4.zip
Rework graphical train HUD code
- A basic texture manipulation API is added; currently this is only a (selected) subset of texture modifiers provided by MT; the goal is to avoid writing (potentially incorrect) texture strings by hand; - The graphical HUD code is cleaned up; in particular, most code used for generating texture patterns are moved to texture.lua so that the code can be used outside of the HUD; - Inactive elements are given the darkslategray background. A basic unittest is added; however, it needs to be expanded for better coverage. Reported-by: Lars Müller <appgurulars@gmx.de>
Diffstat (limited to 'advtrains/spec/texture_spec.lua')
-rw-r--r--advtrains/spec/texture_spec.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/advtrains/spec/texture_spec.lua b/advtrains/spec/texture_spec.lua
new file mode 100644
index 0000000..2e3bd5d
--- /dev/null
+++ b/advtrains/spec/texture_spec.lua
@@ -0,0 +1,19 @@
+package.path = "../?.lua;" .. package.path
+local T = require "texture"
+
+describe("Texture creation", function()
+ it("works", function()
+ assert.same("^.png", tostring(T.raw"^.png"))
+ assert.same("foo\\:bar.png", tostring(T"foo:bar.png"))
+ end)
+end)
+
+describe("Texture modifiers", function()
+ it("work", function()
+ assert.same("x^[colorize:c", tostring(T"x":colorize"c"))
+ assert.same("x^[colorize:c:alpha", tostring(T"x":colorize("c", "alpha")))
+ assert.same("x^[multiply:c", tostring(T"x":multiply"c"))
+ assert.same("x^[resize:2x3", tostring(T"x":resize(2, 3)))
+ assert.same("x^[transformI", tostring(T"x":transform"I"))
+ end)
+end)