GFXLoader

class GFXLoader @JvmOverloads constructor(root: Path, useVram: Boolean = false) : LocalVariables, DefinitionsLoader

GFXLoader can load map textures (Texture) from local scripts, and five instructions are provided in the loading scripts: gfx/shear/loop/font/shear_font. Also, some instructions are provided in VM.

The instructions for using the script

The script header is gfx_items and follows the following format:

gfx_items = {
...
}

All instructions follow the format `` name = {parameters} ``, where parameters are key-value pairs, which values can be variables, strings, and numbers, and variables can be referenced within strings.

Ways to reference variables

Variable names should be preceded by symbols, and if the variable is surrounded by characters, parentheses '(', ')' should be added around its name

xxx$variable_name
xxx$(variable_name)xxx

The variable format: $variable_name

Format of instructions

Instruction NameParametersParameters InstructionsFunctions
gfxname, pathname = "xxx", fill in the name of the texture.
path = "xxx", fill in the path to the image file corresponding to the texture.
Loads a texture map based on the given file path
shearname, key, x, y, w, hname is same as ``gfx``.
key = "xxx", the key of the source texture to fill in the clipping texture.
x = number, fill in the x coordinate where cropping starts.
y = number, fill in the y coordinate to start clipping.
w = number, fill in the width of the crop area.
h = number, fill in the height of the cropping area.
Cut one texture from another.
loopvar_name, begin, end, loadvar_name = "xxx", fill in the variable declared while loop, its value will be set from "begin" to "end" during invoking the loop.
begin = number, optional parameter, the number at which the loop starts. The loop will continue until the previous variable is set to end. The default is 0.
end = number, optional parameter, the number to terminate the loop, the default is 0.
load = {} Composite parameters, inside the brackets are a series of instructions that need to be executed during the loop.
Execute loop.

e.g.

    gfx = {
name = "planes_koishi"
path = "./icons/planes_koishi.png"
}
loop = {
var_name = "state"
end = 2
load = {
loop = {
var_name = "i"
end = 7
load = {
set_var = { name = "x" value = $i }
set_var = { name = "y" value = $state }
mul_var = { name = "x" value = 32 }
mul_var = { name = "y" value = 48 }
shear = {
name = "plane_koishi_$(state)_$i"
key = "planes_koishi"
x = $x
y = $y
w = 32
h = 48
}
}
}
}
}

It needs to provide the root of the directory to be loaded, and all image paths are given as paths relative to the root.

@author KKoishi_

Constructors

Link copied to clipboard
constructor(root: String, useVRAM: Boolean = false)
constructor(root: Path, useVram: Boolean = false)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
operator fun get(name: String): LocalVariables.Var?
Link copied to clipboard
Link copied to clipboard
open override fun loadDefinitions()
Link copied to clipboard
fun <T : Any> setVar(name: String, value: T, klz: KClass<out T> = value::class)
Link copied to clipboard
open override fun toString(): String