aboutsummaryrefslogtreecommitdiff
path: root/font_metro/textures/font_metro_043d.png
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-12-03 23:17:35 +0100
committerorwell96 <orwell@bleipb.de>2018-12-03 23:17:35 +0100
commit8928f78ee6305e29ed8d3b9395fcb6564c984fdf (patch)
treecd250c2b98d7131158e3744efe238780cec73fec /font_metro/textures/font_metro_043d.png
parenteccdad46ef2b38cd061aab7ae6bcb252a67c2218 (diff)
parenta3e0d36a68247cac40349d9089fe3c71546d75e8 (diff)
downloaddisplay_modpack-8928f78ee6305e29ed8d3b9395fcb6564c984fdf.tar.gz
display_modpack-8928f78ee6305e29ed8d3b9395fcb6564c984fdf.tar.bz2
display_modpack-8928f78ee6305e29ed8d3b9395fcb6564c984fdf.zip
Merge remote-tracking branch 'upstream/master'HEADmaster
Resolved conflicts by reordering of files
Diffstat (limited to 'font_metro/textures/font_metro_043d.png')
-rw-r--r--font_metro/textures/font_metro_043d.pngbin0 -> 305 bytes
1 files changed, 0 insertions, 0 deletions
diff --git a/font_metro/textures/font_metro_043d.png b/font_metro/textures/font_metro_043d.png
new file mode 100644
index 0000000..1d27972
--- /dev/null
+++ b/font_metro/textures/font_metro_043d.png
Binary files differ
id='n148' href='#n148'>148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
--- Signal aspect handling.
-- @module advtrains.interlocking.aspect

local registered_groups = {}

local named_aspect_aspfields = {main = true, shunt = true, proceed_as_main = true}

local signal_aspect = {}

local signal_aspect_metatable = {
	__eq = function(asp1, asp2)
		for _, k in pairs {"main", "dst", "shunt", "proceed_as_main"} do
			local v1, v2 = (asp1[k] or false), (asp2[k] or false)
			if v1 ~= v2 then
				return false
			end
		end
		if asp1.group and asp1.group == asp2.group then
			return asp1.name == asp2.name
		end
		return true
	end,
	__index = function(asp, field)
		local method = signal_aspect[field]
		if method then
			return method
		end
		if not named_aspect_aspfields[field] then
			return nil
		end
		local group = registered_groups[rawget(asp, "group")]
		if not group then
			return false
		end
		local aspdef = group.aspects[rawget(asp, "name")]
		if not aspdef then
			return false
		end
		return aspdef[field] or false
	end,
	__tostring = function(asp)
		local st = {}
		if asp.group and asp.name then
			table.insert(st, ("%q in %q"):format(asp.name, asp.group))
		end
		if asp.main then
			table.insert(st, ("current %d"):format(asp.main))
		end
		if asp.main ~= 0 then
			if asp.dst then
				table.insert(st, string.format("next %d", asp.dst))
			end
		end
		if asp.main ~= 0 and asp.proceed_as_main then
			table.insert(st, "proceed as main")
		end
		return ("[%s]"):format(table.concat(st, ", "))
	end,
}

local function quicknew(t)
	return setmetatable(t, signal_aspect_metatable)
end

--- Signal aspect class.
-- @type signal_aspect

--- Return a plain version of the signal aspect.
-- @param[opt=false] raw Bypass metamethods when fetching signal aspects
-- @return A plain copy of the signal aspect object.
function signal_aspect:plain(raw)
	local t = {}
	for _, k in pairs {"main", "dst", "shunt", "proceed_as_main", "group", "name"} do
		local v
		if raw then
			v = rawget(self, k)
		else
			v = self[k]
		end
		t[k] = v
	end
	return t
end

--- Create (or copy) a signal aspect object.
-- Note that signal aspect objects can also be created by calling the `advtrains.interlocking.aspect` table.
-- @return The newly created signal aspect object.
function signal_aspect:new()
	if type(self) ~= "table" then
		return quicknew{}
	end
	local newasp = {}
	for _, k in pairs {"main", "dst"} do
		if type(self[k]) == "table" then
			if self[k].free then
				newasp[k] = self[k].speed
			else
				newasp[k] = 0
			end
		else
			newasp[k] = self[k]
		end
	end
	if type(self.shunt) == "table" then
		newasp.shunt = self.shunt.free
		newasp.proceed_as_main = self.shunt.proceed_as_main
	else
		newasp.shunt = self.shunt
	end
	for _, k in pairs {"group", "name"} do
		newasp[k] = self[k]
	end
	return quicknew(newasp)
end

--- Modify the signal aspect in-place to fit in the specific signal group.
-- @param group The signal group. The `nil` indicates a generic group.
-- @return The (now modified) signal aspect itself.
function signal_aspect:to_group(group)
	local cg = self.group
	local gdef = registered_groups[group]
	if type(self.name) ~= "string" then
		self.name = nil
	end
	if not gdef then