xref: /freebsd/stand/lua/drawer.lua (revision b57465454b35f6e24a6df02a93a27d0136c016d9)
1088b4f5fSWarner Losh--
2088b4f5fSWarner Losh-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
3df74a61fSKyle Evans-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
4088b4f5fSWarner Losh-- All rights reserved.
5088b4f5fSWarner Losh--
6088b4f5fSWarner Losh-- Redistribution and use in source and binary forms, with or without
7088b4f5fSWarner Losh-- modification, are permitted provided that the following conditions
8088b4f5fSWarner Losh-- are met:
9088b4f5fSWarner Losh-- 1. Redistributions of source code must retain the above copyright
10088b4f5fSWarner Losh--    notice, this list of conditions and the following disclaimer.
11088b4f5fSWarner Losh-- 2. Redistributions in binary form must reproduce the above copyright
12088b4f5fSWarner Losh--    notice, this list of conditions and the following disclaimer in the
13088b4f5fSWarner Losh--    documentation and/or other materials provided with the distribution.
14088b4f5fSWarner Losh--
15088b4f5fSWarner Losh-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16088b4f5fSWarner Losh-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17088b4f5fSWarner Losh-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18088b4f5fSWarner Losh-- ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19088b4f5fSWarner Losh-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20088b4f5fSWarner Losh-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21088b4f5fSWarner Losh-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22088b4f5fSWarner Losh-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23088b4f5fSWarner Losh-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24088b4f5fSWarner Losh-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25088b4f5fSWarner Losh-- SUCH DAMAGE.
26088b4f5fSWarner Losh--
27088b4f5fSWarner Losh-- $FreeBSD$
28088b4f5fSWarner Losh--
29088b4f5fSWarner Losh
30088b4f5fSWarner Loshlocal color = require("color");
31a7cf0562SKyle Evanslocal core = require("core");
32088b4f5fSWarner Loshlocal screen = require("screen");
33088b4f5fSWarner Losh
34c8518398SKyle Evanslocal drawer = {};
35c8518398SKyle Evans
3602122e53SKyle Evanslocal fbsd_logo;
3702122e53SKyle Evanslocal beastie_color;
3802122e53SKyle Evanslocal beastie;
3902122e53SKyle Evanslocal fbsd_logo_v;
4002122e53SKyle Evanslocal orb;
4102122e53SKyle Evanslocal none;
42bb26c57dSKyle Evanslocal none_shifted = false;
4302122e53SKyle Evans
44e15abd1fSKyle Evanslocal menu_entry_name = function(drawing_menu, entry)
45e15abd1fSKyle Evans	local name_handler = drawer.menu_name_handlers[entry.entry_type];
46e15abd1fSKyle Evans
47e15abd1fSKyle Evans	if (name_handler ~= nil) then
48e15abd1fSKyle Evans		return name_handler(drawing_menu, entry);
49e15abd1fSKyle Evans	end
50e15abd1fSKyle Evans	return entry.name();
51e15abd1fSKyle Evansend
52e15abd1fSKyle Evans
53e15abd1fSKyle Evanslocal shift_brand_text = function(shift)
54e15abd1fSKyle Evans	drawer.brand_position.x = drawer.brand_position.x + shift.x;
55e15abd1fSKyle Evans	drawer.brand_position.y = drawer.brand_position.y + shift.y;
56e15abd1fSKyle Evans	drawer.menu_position.x = drawer.menu_position.x + shift.x;
57e15abd1fSKyle Evans	drawer.menu_position.y = drawer.menu_position.y + shift.y;
58e15abd1fSKyle Evans	drawer.box_pos_dim.x = drawer.box_pos_dim.x + shift.x;
59e15abd1fSKyle Evans	drawer.box_pos_dim.y = drawer.box_pos_dim.y + shift.y;
60e15abd1fSKyle Evansend
61e15abd1fSKyle Evans
6202122e53SKyle Evansfbsd_logo = {
63088b4f5fSWarner Losh	"  ______               ____   _____ _____  ",
64088b4f5fSWarner Losh	" |  ____|             |  _ \\ / ____|  __ \\ ",
65088b4f5fSWarner Losh	" | |___ _ __ ___  ___ | |_) | (___ | |  | |",
66088b4f5fSWarner Losh	" |  ___| '__/ _ \\/ _ \\|  _ < \\___ \\| |  | |",
67088b4f5fSWarner Losh	" | |   | | |  __/  __/| |_) |____) | |__| |",
68088b4f5fSWarner Losh	" | |   | | |    |    ||     |      |      |",
69088b4f5fSWarner Losh	" |_|   |_|  \\___|\\___||____/|_____/|_____/ "
70088b4f5fSWarner Losh};
71088b4f5fSWarner Losh
7202122e53SKyle Evansbeastie_color = {
73088b4f5fSWarner Losh	"               \027[31m,        ,",
74088b4f5fSWarner Losh	"              /(        )`",
75088b4f5fSWarner Losh	"              \\ \\___   / |",
76088b4f5fSWarner Losh	"              /- \027[37m_\027[31m  `-/  '",
77088b4f5fSWarner Losh	"             (\027[37m/\\/ \\\027[31m \\   /\\",
78088b4f5fSWarner Losh	"             \027[37m/ /   |\027[31m `    \\",
79088b4f5fSWarner Losh	"             \027[34mO O   \027[37m) \027[31m/    |",
80088b4f5fSWarner Losh	"             \027[37m`-^--'\027[31m`<     '",
81088b4f5fSWarner Losh	"            (_.)  _  )   /",
82088b4f5fSWarner Losh	"             `.___/`    /",
83088b4f5fSWarner Losh	"               `-----' /",
84088b4f5fSWarner Losh	"  \027[33m<----.\027[31m     __ / __   \\",
85088b4f5fSWarner Losh	"  \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|",
86088b4f5fSWarner Losh	"  \027[33m<----'\027[31m    `--' `.__,' \\",
87088b4f5fSWarner Losh	"               |        |",
88088b4f5fSWarner Losh	"                \\       /       /\\",
89088b4f5fSWarner Losh	"           \027[36m______\027[31m( (_  / \\______/",
90088b4f5fSWarner Losh	"         \027[36m,'  ,-----'   |",
91088b4f5fSWarner Losh	"         `--{__________)\027[37m"
92088b4f5fSWarner Losh};
93088b4f5fSWarner Losh
9402122e53SKyle Evansbeastie = {
95088b4f5fSWarner Losh	"               ,        ,",
96088b4f5fSWarner Losh	"              /(        )`",
97088b4f5fSWarner Losh	"              \\ \\___   / |",
98088b4f5fSWarner Losh	"              /- _  `-/  '",
99088b4f5fSWarner Losh	"             (/\\/ \\ \\   /\\",
100088b4f5fSWarner Losh	"             / /   | `    \\",
101088b4f5fSWarner Losh	"             O O   ) /    |",
102088b4f5fSWarner Losh	"             `-^--'`<     '",
103088b4f5fSWarner Losh	"            (_.)  _  )   /",
104088b4f5fSWarner Losh	"             `.___/`    /",
105088b4f5fSWarner Losh	"               `-----' /",
106088b4f5fSWarner Losh	"  <----.     __ / __   \\",
107088b4f5fSWarner Losh	"  <----|====O)))==) \\) /====|",
108088b4f5fSWarner Losh	"  <----'    `--' `.__,' \\",
109088b4f5fSWarner Losh	"               |        |",
110088b4f5fSWarner Losh	"                \\       /       /\\",
111088b4f5fSWarner Losh	"           ______( (_  / \\______/",
112088b4f5fSWarner Losh	"         ,'  ,-----'   |",
113088b4f5fSWarner Losh	"         `--{__________)"
114088b4f5fSWarner Losh};
115088b4f5fSWarner Losh
11602122e53SKyle Evansfbsd_logo_v = {
117088b4f5fSWarner Losh	"  ______",
118088b4f5fSWarner Losh	" |  ____| __ ___  ___ ",
119088b4f5fSWarner Losh	" | |__ | '__/ _ \\/ _ \\",
120088b4f5fSWarner Losh	" |  __|| | |  __/  __/",
121088b4f5fSWarner Losh	" | |   | | |    |    |",
122088b4f5fSWarner Losh	" |_|   |_|  \\___|\\___|",
123088b4f5fSWarner Losh	"  ____   _____ _____",
124088b4f5fSWarner Losh	" |  _ \\ / ____|  __ \\",
125088b4f5fSWarner Losh	" | |_) | (___ | |  | |",
126088b4f5fSWarner Losh	" |  _ < \\___ \\| |  | |",
127088b4f5fSWarner Losh	" | |_) |____) | |__| |",
128088b4f5fSWarner Losh	" |     |      |      |",
129088b4f5fSWarner Losh	" |____/|_____/|_____/"
130088b4f5fSWarner Losh};
131088b4f5fSWarner Losh
13202122e53SKyle Evansorb_color = {
133088b4f5fSWarner Losh	"  \027[31m```                        \027[31;1m`\027[31m",
134088b4f5fSWarner Losh	" s` `.....---...\027[31;1m....--.```   -/\027[31m",
135088b4f5fSWarner Losh	" +o   .--`         \027[31;1m/y:`      +.\027[31m",
136088b4f5fSWarner Losh	"  yo`:.            \027[31;1m:o      `+-\027[31m",
137088b4f5fSWarner Losh	"   y/               \027[31;1m-/`   -o/\027[31m",
138088b4f5fSWarner Losh	"  .-                  \027[31;1m::/sy+:.\027[31m",
139088b4f5fSWarner Losh	"  /                     \027[31;1m`--  /\027[31m",
140088b4f5fSWarner Losh	" `:                          \027[31;1m:`\027[31m",
141088b4f5fSWarner Losh	" `:                          \027[31;1m:`\027[31m",
142088b4f5fSWarner Losh	"  /                          \027[31;1m/\027[31m",
143088b4f5fSWarner Losh	"  .-                        \027[31;1m-.\027[31m",
144088b4f5fSWarner Losh	"   --                      \027[31;1m-.\027[31m",
145088b4f5fSWarner Losh	"    `:`                  \027[31;1m`:`",
146088b4f5fSWarner Losh	"      \027[31;1m.--             `--.",
147088b4f5fSWarner Losh	"         .---.....----.\027[37m"
148088b4f5fSWarner Losh};
149088b4f5fSWarner Losh
15002122e53SKyle Evansorb = {
151088b4f5fSWarner Losh	"  ```                        `",
152088b4f5fSWarner Losh	" s` `.....---.......--.```   -/",
153088b4f5fSWarner Losh	" +o   .--`         /y:`      +.",
154088b4f5fSWarner Losh	"  yo`:.            :o      `+-",
155088b4f5fSWarner Losh	"   y/               -/`   -o/",
156088b4f5fSWarner Losh	"  .-                  ::/sy+:.",
157088b4f5fSWarner Losh	"  /                     `--  /",
158088b4f5fSWarner Losh	" `:                          :`",
159088b4f5fSWarner Losh	" `:                          :`",
160088b4f5fSWarner Losh	"  /                          /",
161088b4f5fSWarner Losh	"  .-                        -.",
162088b4f5fSWarner Losh	"   --                      -.",
163088b4f5fSWarner Losh	"    `:`                  `:`",
164088b4f5fSWarner Losh	"      .--             `--.",
165088b4f5fSWarner Losh	"         .---.....----."
166088b4f5fSWarner Losh};
167088b4f5fSWarner Losh
16802122e53SKyle Evansnone = {""};
169088b4f5fSWarner Losh
170*b5746545SKyle Evans-- Module exports
171*b5746545SKyle Evansdrawer.menu_name_handlers = {
172*b5746545SKyle Evans	-- Menu name handlers should take the menu being drawn and entry being
173*b5746545SKyle Evans	-- drawn as parameters, and return the name of the item.
174*b5746545SKyle Evans	-- This is designed so that everything, including menu separators, may
175*b5746545SKyle Evans	-- have their names derived differently. The default action for entry
176*b5746545SKyle Evans	-- types not specified here is to call and use entry.name().
177*b5746545SKyle Evans	[core.MENU_CAROUSEL_ENTRY] = function(drawing_menu, entry)
178*b5746545SKyle Evans		local carid = entry.carousel_id;
179*b5746545SKyle Evans		local caridx = menu.getCarouselIndex(carid);
180*b5746545SKyle Evans		local choices = entry.items();
181*b5746545SKyle Evans
182*b5746545SKyle Evans		if (#choices < caridx) then
183*b5746545SKyle Evans			caridx = 1;
184*b5746545SKyle Evans		end
185*b5746545SKyle Evans		return entry.name(caridx, choices[caridx], choices);
186*b5746545SKyle Evans	end,
187*b5746545SKyle Evans};
188*b5746545SKyle Evans
189*b5746545SKyle Evansdrawer.brand_position = {x = 2, y = 1};
190*b5746545SKyle Evansdrawer.logo_position = {x = 46, y = 1};
191*b5746545SKyle Evansdrawer.menu_position = {x = 6, y = 11};
192*b5746545SKyle Evansdrawer.box_pos_dim = {x = 3, y = 10, w = 41, h = 11};
193*b5746545SKyle Evans
19429aa5794SKyle Evansdrawer.branddefs = {
195699578a6SKyle Evans	-- Indexed by valid values for loader_brand in loader.conf(5). Valid
196699578a6SKyle Evans	-- keys are: graphic (table depicting graphic)
19729aa5794SKyle Evans	["fbsd"] = {
19829aa5794SKyle Evans		graphic = fbsd_logo,
19929aa5794SKyle Evans	},
20029aa5794SKyle Evans	["none"] = {
20129aa5794SKyle Evans		graphic = none,
20229aa5794SKyle Evans	},
20329aa5794SKyle Evans};
20429aa5794SKyle Evans
205bb26c57dSKyle Evansdrawer.logodefs = {
206bb26c57dSKyle Evans	-- Indexed by valid values for loader_logo in loader.conf(5). Valid keys
207752b2d40SKyle Evans	-- are: requires_color (boolean), graphic (table depicting graphic), and
208bb26c57dSKyle Evans	-- shift (table containing x and y).
209bb26c57dSKyle Evans	["beastie"] = {
210bb26c57dSKyle Evans		requires_color = true,
211752b2d40SKyle Evans		graphic = beastie_color,
212bb26c57dSKyle Evans	},
213bb26c57dSKyle Evans	["beastiebw"] = {
214752b2d40SKyle Evans		graphic = beastie,
215bb26c57dSKyle Evans	},
216bb26c57dSKyle Evans	["fbsdbw"] = {
217752b2d40SKyle Evans		graphic = fbsd_logo_v,
218bb26c57dSKyle Evans		shift = {x = 5, y = 4},
219bb26c57dSKyle Evans	},
220bb26c57dSKyle Evans	["orb"] = {
221bb26c57dSKyle Evans		requires_color = true,
222752b2d40SKyle Evans		graphic = orb_color,
223bb26c57dSKyle Evans		shift = {x = 2, y = 4},
224bb26c57dSKyle Evans	},
225bb26c57dSKyle Evans	["orbbw"] = {
226752b2d40SKyle Evans		graphic = orb,
227bb26c57dSKyle Evans		shift = {x = 2, y = 4},
228bb26c57dSKyle Evans	},
229bb26c57dSKyle Evans	["tribute"] = {
230752b2d40SKyle Evans		graphic = fbsd_logo,
231bb26c57dSKyle Evans	},
232bb26c57dSKyle Evans	["tributebw"] = {
233752b2d40SKyle Evans		graphic = fbsd_logo,
234bb26c57dSKyle Evans	},
235bb26c57dSKyle Evans	["none"] = {
236752b2d40SKyle Evans		graphic = none,
237bb26c57dSKyle Evans		shift = {x = 17, y = 0},
238bb26c57dSKyle Evans	},
239bb26c57dSKyle Evans};
240bb26c57dSKyle Evans
241088b4f5fSWarner Loshfunction drawer.drawscreen(menu_opts)
242088b4f5fSWarner Losh	-- drawlogo() must go first.
243088b4f5fSWarner Losh	-- it determines the positions of other elements
244088b4f5fSWarner Losh	drawer.drawlogo();
245088b4f5fSWarner Losh        drawer.drawbrand();
246088b4f5fSWarner Losh        drawer.drawbox();
247088b4f5fSWarner Losh	return drawer.drawmenu(menu_opts);
248088b4f5fSWarner Loshend
249088b4f5fSWarner Losh
250088b4f5fSWarner Loshfunction drawer.drawmenu(m)
251088b4f5fSWarner Losh	x = drawer.menu_position.x;
252088b4f5fSWarner Losh	y = drawer.menu_position.y;
253088b4f5fSWarner Losh
254088b4f5fSWarner Losh	-- print the menu and build the alias table
255088b4f5fSWarner Losh	local alias_table = {};
256088b4f5fSWarner Losh	local entry_num = 0;
257d8757746SKyle Evans	local menu_entries = m.entries;
2582e716cecSKyle Evans	if (type(menu_entries) == "function") then
2592e716cecSKyle Evans		menu_entries = menu_entries();
2602e716cecSKyle Evans	end
261d8757746SKyle Evans	for line_num, e in ipairs(menu_entries) do
2624a4fb4f8SKyle Evans		-- Allow menu items to be conditionally visible by specifying
2634a4fb4f8SKyle Evans		-- a visible function.
2644a4fb4f8SKyle Evans		if (e.visible ~= nil) and (not e.visible()) then
265ddb76e07SKyle Evans			goto continue;
2664a4fb4f8SKyle Evans		end
267a7cf0562SKyle Evans		if (e.entry_type ~= core.MENU_SEPARATOR) then
268088b4f5fSWarner Losh			entry_num = entry_num + 1;
269088b4f5fSWarner Losh			screen.setcursor(x, y + line_num);
270ada26c4aSKyle Evans
2712413c411SKyle Evans			print(entry_num .. ". " .. menu_entry_name(m, e));
272088b4f5fSWarner Losh
273088b4f5fSWarner Losh			-- fill the alias table
274088b4f5fSWarner Losh			alias_table[tostring(entry_num)] = e;
275196ba166SKyle Evans			if (e.alias ~= nil) then
276088b4f5fSWarner Losh				for n, a in ipairs(e.alias) do
277088b4f5fSWarner Losh					alias_table[a] = e;
278088b4f5fSWarner Losh				end
279196ba166SKyle Evans			end
280088b4f5fSWarner Losh		else
281088b4f5fSWarner Losh			screen.setcursor(x, y + line_num);
2822413c411SKyle Evans			print(menu_entry_name(m, e));
283088b4f5fSWarner Losh		end
2844a4fb4f8SKyle Evans		::continue::
285088b4f5fSWarner Losh	end
286088b4f5fSWarner Losh	return alias_table;
287088b4f5fSWarner Loshend
288088b4f5fSWarner Losh
289088b4f5fSWarner Losh
290088b4f5fSWarner Loshfunction drawer.drawbox()
291088b4f5fSWarner Losh	x = drawer.box_pos_dim.x;
292088b4f5fSWarner Losh	y = drawer.box_pos_dim.y;
293088b4f5fSWarner Losh	w = drawer.box_pos_dim.w;
294088b4f5fSWarner Losh	h = drawer.box_pos_dim.h;
295088b4f5fSWarner Losh
296088b4f5fSWarner Losh	local hl = string.char(0xCD);
297088b4f5fSWarner Losh	local vl = string.char(0xBA);
298088b4f5fSWarner Losh
299088b4f5fSWarner Losh	local tl = string.char(0xC9);
300088b4f5fSWarner Losh	local bl = string.char(0xC8);
301088b4f5fSWarner Losh	local tr = string.char(0xBB);
302088b4f5fSWarner Losh	local br = string.char(0xBC);
303088b4f5fSWarner Losh
304088b4f5fSWarner Losh	screen.setcursor(x, y); print(tl);
305088b4f5fSWarner Losh	screen.setcursor(x, y+h); print(bl);
306088b4f5fSWarner Losh	screen.setcursor(x+w, y); print(tr);
307088b4f5fSWarner Losh	screen.setcursor(x+w, y+h); print(br);
308088b4f5fSWarner Losh
309088b4f5fSWarner Losh	for i = 1, w-1 do
310088b4f5fSWarner Losh		screen.setcursor(x+i, y);
311088b4f5fSWarner Losh		print(hl);
312088b4f5fSWarner Losh		screen.setcursor(x+i, y+h);
313088b4f5fSWarner Losh		print(hl);
314088b4f5fSWarner Losh	end
315088b4f5fSWarner Losh
316088b4f5fSWarner Losh	for i = 1, h-1 do
317088b4f5fSWarner Losh		screen.setcursor(x, y+i);
318088b4f5fSWarner Losh		print(vl);
319088b4f5fSWarner Losh		screen.setcursor(x+w, y+i);
320088b4f5fSWarner Losh		print(vl);
321088b4f5fSWarner Losh	end
322088b4f5fSWarner Losh
323088b4f5fSWarner Losh	screen.setcursor(x+(w/2)-9, y);
324088b4f5fSWarner Losh	print("Welcome to FreeBSD");
325088b4f5fSWarner Loshend
326088b4f5fSWarner Losh
327088b4f5fSWarner Loshfunction drawer.draw(x, y, logo)
328088b4f5fSWarner Losh	for i = 1, #logo do
329088b4f5fSWarner Losh		screen.setcursor(x, y + i);
330088b4f5fSWarner Losh		print(logo[i]);
331088b4f5fSWarner Losh	end
332088b4f5fSWarner Loshend
333088b4f5fSWarner Losh
334088b4f5fSWarner Loshfunction drawer.drawbrand()
33524a1bd54SKyle Evans	local x = tonumber(loader.getenv("loader_brand_x")) or
33624a1bd54SKyle Evans	    drawer.brand_position.x;
33724a1bd54SKyle Evans	local y = tonumber(loader.getenv("loader_brand_y")) or
33824a1bd54SKyle Evans	    drawer.brand_position.y;
339088b4f5fSWarner Losh
34029aa5794SKyle Evans	local graphic = drawer.branddefs[loader.getenv("loader_brand")];
34129aa5794SKyle Evans	if (graphic == nil) then
34229aa5794SKyle Evans		graphic = fbsd_logo;
34329aa5794SKyle Evans	end
34429aa5794SKyle Evans	drawer.draw(x, y, graphic);
345088b4f5fSWarner Loshend
346088b4f5fSWarner Losh
347088b4f5fSWarner Loshfunction drawer.drawlogo()
34824a1bd54SKyle Evans	local x = tonumber(loader.getenv("loader_logo_x")) or
34924a1bd54SKyle Evans	    drawer.logo_position.x;
35024a1bd54SKyle Evans	local y = tonumber(loader.getenv("loader_logo_y")) or
35124a1bd54SKyle Evans	    drawer.logo_position.y;
352088b4f5fSWarner Losh
353088b4f5fSWarner Losh	local logo = loader.getenv("loader_logo");
354088b4f5fSWarner Losh	local colored = color.isEnabled();
355088b4f5fSWarner Losh
356bb26c57dSKyle Evans	-- Lookup
357bb26c57dSKyle Evans	local logodef = drawer.logodefs[logo];
358bb26c57dSKyle Evans
359752b2d40SKyle Evans	if (logodef ~= nil) and (logodef.graphic == none) then
360088b4f5fSWarner Losh		-- centre brand and text if no logo
361bb26c57dSKyle Evans		if (not none_shifted) then
362bb26c57dSKyle Evans			shift_brand_text(logodef.shift);
363bb26c57dSKyle Evans			none_shifted = true;
364088b4f5fSWarner Losh		end
365752b2d40SKyle Evans	elseif (logodef == nil) or (logodef.graphic == nil) or
366bb26c57dSKyle Evans	    ((not colored) and logodef.requires_color) then
367bb26c57dSKyle Evans		-- Choose a sensible default
36824a1bd54SKyle Evans		if (colored) then
369bb26c57dSKyle Evans			logodef = drawer.logodefs["orb"];
370088b4f5fSWarner Losh		else
371bb26c57dSKyle Evans			logodef = drawer.logodefs["orbbw"];
372088b4f5fSWarner Losh		end
373088b4f5fSWarner Losh	end
374bb26c57dSKyle Evans	if (logodef.shift ~= nil) then
375bb26c57dSKyle Evans		x = x + logodef.shift.x;
376bb26c57dSKyle Evans		y = y + logodef.shift.y;
377bb26c57dSKyle Evans	end
378752b2d40SKyle Evans	drawer.draw(x, y, logodef.graphic);
379088b4f5fSWarner Loshend
380088b4f5fSWarner Losh
38124a1bd54SKyle Evansreturn drawer;
382