From 1091c8fe47a24dc6e010b57b0a2226797b753aa8 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sun, 1 Apr 2018 01:07:15 +0000 Subject: [PATCH] lualoader: Split logodefs out into logo-* files This commit splits all of the logodefs/graphics out into their own own files and provides a method for these files to register their logodefs with the drawer. Graphics are now loaded on demand if they don't exist in the current set of logodefs. The drawer module becomes a little easier to navigate through without all of the graphics mixed in. It's also easy to do one-off graphics like the 9.2 Die Hard tribute by dteske@ without adding even more to our memory requirements. --- stand/lua/Makefile | 5 ++ stand/lua/drawer.lua | 166 +++++++---------------------------- stand/lua/logo-beastie.lua | 60 +++++++++++++ stand/lua/logo-beastiebw.lua | 59 +++++++++++++ stand/lua/logo-fbsdbw.lua | 54 ++++++++++++ stand/lua/logo-orb.lua | 57 ++++++++++++ stand/lua/logo-orbbw.lua | 56 ++++++++++++ 7 files changed, 322 insertions(+), 135 deletions(-) create mode 100644 stand/lua/logo-beastie.lua create mode 100644 stand/lua/logo-beastiebw.lua create mode 100644 stand/lua/logo-fbsdbw.lua create mode 100644 stand/lua/logo-orb.lua create mode 100644 stand/lua/logo-orbbw.lua diff --git a/stand/lua/Makefile b/stand/lua/Makefile index 3ff75ca7e26..d48cccca897 100644 --- a/stand/lua/Makefile +++ b/stand/lua/Makefile @@ -10,6 +10,11 @@ FILES= cli.lua \ drawer.lua \ hook.lua \ loader.lua \ + logo-beastie.lua \ + logo-beastiebw.lua \ + logo-fbsdbw.lua \ + logo-orb.lua \ + logo-orbbw.lua \ menu.lua \ password.lua \ screen.lua diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index e8140dd6a25..518c4f24cd2 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -36,12 +36,7 @@ local screen = require("screen") local drawer = {} -local fbsd_logo -local beastie_color -local beastie -local fbsd_logo_v -local orb_color -local orb +local fbsd_brand local none local function menuEntryName(drawing_menu, entry) @@ -56,7 +51,20 @@ local function menuEntryName(drawing_menu, entry) return entry.name end -fbsd_logo = { +local function getLogodef(logo) + -- Look it up + local logodef = drawer.logodefs[logo] + + -- Try to pull it in + if logodef == nil then + try_include('logo-' .. logo) + logodef = drawer.logodefs[logo] + end + + return logodef +end + +fbsd_brand = { " ______ ____ _____ _____ ", " | ____| | _ \\ / ____| __ \\ ", " | |___ _ __ ___ ___ | |_) | (___ | | | |", @@ -65,103 +73,6 @@ fbsd_logo = { " | | | | | | || | | |", " |_| |_| \\___|\\___||____/|_____/|_____/ " } - -beastie_color = { -" \027[31m, ,", -" /( )`", -" \\ \\___ / |", -" /- \027[37m_\027[31m `-/ '", -" (\027[37m/\\/ \\\027[31m \\ /\\", -" \027[37m/ / |\027[31m ` \\", -" \027[34mO O \027[37m) \027[31m/ |", -" \027[37m`-^--'\027[31m`< '", -" (_.) _ ) /", -" `.___/` /", -" `-----' /", -" \027[33m<----.\027[31m __ / __ \\", -" \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|", -" \027[33m<----'\027[31m `--' `.__,' \\", -" | |", -" \\ / /\\", -" \027[36m______\027[31m( (_ / \\______/", -" \027[36m,' ,-----' |", -" `--{__________)\027[37m" -} - -beastie = { -" , ,", -" /( )`", -" \\ \\___ / |", -" /- _ `-/ '", -" (/\\/ \\ \\ /\\", -" / / | ` \\", -" O O ) / |", -" `-^--'`< '", -" (_.) _ ) /", -" `.___/` /", -" `-----' /", -" <----. __ / __ \\", -" <----|====O)))==) \\) /====|", -" <----' `--' `.__,' \\", -" | |", -" \\ / /\\", -" ______( (_ / \\______/", -" ,' ,-----' |", -" `--{__________)" -} - -fbsd_logo_v = { -" ______", -" | ____| __ ___ ___ ", -" | |__ | '__/ _ \\/ _ \\", -" | __|| | | __/ __/", -" | | | | | | |", -" |_| |_| \\___|\\___|", -" ____ _____ _____", -" | _ \\ / ____| __ \\", -" | |_) | (___ | | | |", -" | _ < \\___ \\| | | |", -" | |_) |____) | |__| |", -" | | | |", -" |____/|_____/|_____/" -} - -orb_color = { -" \027[31m``` \027[31;1m`\027[31m", -" s` `.....---...\027[31;1m....--.``` -/\027[31m", -" +o .--` \027[31;1m/y:` +.\027[31m", -" yo`:. \027[31;1m:o `+-\027[31m", -" y/ \027[31;1m-/` -o/\027[31m", -" .- \027[31;1m::/sy+:.\027[31m", -" / \027[31;1m`-- /\027[31m", -" `: \027[31;1m:`\027[31m", -" `: \027[31;1m:`\027[31m", -" / \027[31;1m/\027[31m", -" .- \027[31;1m-.\027[31m", -" -- \027[31;1m-.\027[31m", -" `:` \027[31;1m`:`", -" \027[31;1m.-- `--.", -" .---.....----.\027[37m" -} - -orb = { -" ``` `", -" s` `.....---.......--.``` -/", -" +o .--` /y:` +.", -" yo`:. :o `+-", -" y/ -/` -o/", -" .- ::/sy+:.", -" / `-- /", -" `: :`", -" `: :`", -" / /", -" .- -.", -" -- -.", -" `:` `:`", -" .-- `--.", -" .---.....----." -} - none = {""} -- Module exports @@ -205,42 +116,30 @@ drawer.branddefs = { -- Indexed by valid values for loader_brand in loader.conf(5). Valid -- keys are: graphic (table depicting graphic) ["fbsd"] = { - graphic = fbsd_logo, + graphic = fbsd_brand, }, ["none"] = { graphic = none, }, } +function drawer.addBrand(name, def) + drawer.branddefs[name] = def +end + +function drawer.addLogo(name, def) + drawer.logodefs[name] = def +end + drawer.logodefs = { -- Indexed by valid values for loader_logo in loader.conf(5). Valid keys -- are: requires_color (boolean), graphic (table depicting graphic), and -- shift (table containing x and y). - ["beastie"] = { - requires_color = true, - graphic = beastie_color, - }, - ["beastiebw"] = { - graphic = beastie, - }, - ["fbsdbw"] = { - graphic = fbsd_logo_v, - shift = {x = 5, y = 4}, - }, - ["orb"] = { - requires_color = true, - graphic = orb_color, - shift = {x = 2, y = 4}, - }, - ["orbbw"] = { - graphic = orb, - shift = {x = 2, y = 4}, - }, ["tribute"] = { - graphic = fbsd_logo, + graphic = fbsd_brand, }, ["tributebw"] = { - graphic = fbsd_logo, + graphic = fbsd_brand, }, ["none"] = { graphic = none, @@ -413,10 +312,8 @@ function drawer.drawbrand() local y = tonumber(loader.getenv("loader_brand_y")) or drawer.brand_position.y - local graphic = drawer.branddefs[loader.getenv("loader_brand")] - if graphic == nil then - graphic = fbsd_logo - end + local graphic = drawer.branddefs[loader.getenv("loader_brand")] or + fbsd_brand x = x + drawer.shift.x y = y + drawer.shift.y @@ -432,16 +329,15 @@ function drawer.drawlogo() local logo = loader.getenv("loader_logo") local colored = color.isEnabled() - -- Lookup - local logodef = drawer.logodefs[logo] + local logodef = getLogodef(logo) if logodef == nil or logodef.graphic == nil or (not colored and logodef.requires_color) then -- Choose a sensible default if colored then - logodef = drawer.logodefs["orb"] + logodef = getLogodef("orb") else - logodef = drawer.logodefs["orbbw"] + logodef = getLogodef("orbbw") end end diff --git a/stand/lua/logo-beastie.lua b/stand/lua/logo-beastie.lua new file mode 100644 index 00000000000..63b9576ed8e --- /dev/null +++ b/stand/lua/logo-beastie.lua @@ -0,0 +1,60 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions +-- are met: +-- 1. Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +-- SUCH DAMAGE. +-- +-- $FreeBSD$ +-- + +local drawer = require("drawer") + +local beastie_color = { +" \027[31m, ,", +" /( )`", +" \\ \\___ / |", +" /- \027[37m_\027[31m `-/ '", +" (\027[37m/\\/ \\\027[31m \\ /\\", +" \027[37m/ / |\027[31m ` \\", +" \027[34mO O \027[37m) \027[31m/ |", +" \027[37m`-^--'\027[31m`< '", +" (_.) _ ) /", +" `.___/` /", +" `-----' /", +" \027[33m<----.\027[31m __ / __ \\", +" \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|", +" \027[33m<----'\027[31m `--' `.__,' \\", +" | |", +" \\ / /\\", +" \027[36m______\027[31m( (_ / \\______/", +" \027[36m,' ,-----' |", +" `--{__________)\027[37m" +} + +drawer.addLogo("beastie", { + requires_color = true, + graphic = beastie_color, +}) + +return true diff --git a/stand/lua/logo-beastiebw.lua b/stand/lua/logo-beastiebw.lua new file mode 100644 index 00000000000..96b15604452 --- /dev/null +++ b/stand/lua/logo-beastiebw.lua @@ -0,0 +1,59 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions +-- are met: +-- 1. Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +-- SUCH DAMAGE. +-- +-- $FreeBSD$ +-- + +local drawer = require("drawer") + +local beastiebw = { +" , ,", +" /( )`", +" \\ \\___ / |", +" /- _ `-/ '", +" (/\\/ \\ \\ /\\", +" / / | ` \\", +" O O ) / |", +" `-^--'`< '", +" (_.) _ ) /", +" `.___/` /", +" `-----' /", +" <----. __ / __ \\", +" <----|====O)))==) \\) /====|", +" <----' `--' `.__,' \\", +" | |", +" \\ / /\\", +" ______( (_ / \\______/", +" ,' ,-----' |", +" `--{__________)" +} + +drawer.addLogo("beastiebw", { + graphic = beastiebw, +}) + +return true diff --git a/stand/lua/logo-fbsdbw.lua b/stand/lua/logo-fbsdbw.lua new file mode 100644 index 00000000000..c9d2dcd15ac --- /dev/null +++ b/stand/lua/logo-fbsdbw.lua @@ -0,0 +1,54 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions +-- are met: +-- 1. Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +-- SUCH DAMAGE. +-- +-- $FreeBSD$ +-- + +local drawer = require("drawer") + +local fbsd_logo = { +" ______", +" | ____| __ ___ ___ ", +" | |__ | '__/ _ \\/ _ \\", +" | __|| | | __/ __/", +" | | | | | | |", +" |_| |_| \\___|\\___|", +" ____ _____ _____", +" | _ \\ / ____| __ \\", +" | |_) | (___ | | | |", +" | _ < \\___ \\| | | |", +" | |_) |____) | |__| |", +" | | | |", +" |____/|_____/|_____/" +} + +drawer.addLogo("fbsdbw", { + graphic = fbsd_logo, + shift = {x = 5, y = 4}, +}) + +return true diff --git a/stand/lua/logo-orb.lua b/stand/lua/logo-orb.lua new file mode 100644 index 00000000000..905ae1ccb4b --- /dev/null +++ b/stand/lua/logo-orb.lua @@ -0,0 +1,57 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions +-- are met: +-- 1. Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +-- SUCH DAMAGE. +-- +-- $FreeBSD$ +-- + +local drawer = require("drawer") + +local orb_color = { +" \027[31m``` \027[31;1m`\027[31m", +" s` `.....---...\027[31;1m....--.``` -/\027[31m", +" +o .--` \027[31;1m/y:` +.\027[31m", +" yo`:. \027[31;1m:o `+-\027[31m", +" y/ \027[31;1m-/` -o/\027[31m", +" .- \027[31;1m::/sy+:.\027[31m", +" / \027[31;1m`-- /\027[31m", +" `: \027[31;1m:`\027[31m", +" `: \027[31;1m:`\027[31m", +" / \027[31;1m/\027[31m", +" .- \027[31;1m-.\027[31m", +" -- \027[31;1m-.\027[31m", +" `:` \027[31;1m`:`", +" \027[31;1m.-- `--.", +" .---.....----.\027[37m" +} + +drawer.addLogo("orb", { + requires_color = true, + graphic = orb_color, + shift = {x = 2, y = 4}, +}) + +return true diff --git a/stand/lua/logo-orbbw.lua b/stand/lua/logo-orbbw.lua new file mode 100644 index 00000000000..3635e1e1be3 --- /dev/null +++ b/stand/lua/logo-orbbw.lua @@ -0,0 +1,56 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions +-- are met: +-- 1. Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +-- SUCH DAMAGE. +-- +-- $FreeBSD$ +-- + +local drawer = require("drawer") + +local orbbw = { +" ``` `", +" s` `.....---.......--.``` -/", +" +o .--` /y:` +.", +" yo`:. :o `+-", +" y/ -/` -o/", +" .- ::/sy+:.", +" / `-- /", +" `: :`", +" `: :`", +" / /", +" .- -.", +" -- -.", +" `:` `:`", +" .-- `--.", +" .---.....----." +} + +drawer.addLogo("orbbw", { + graphic = orbbw, + shift = {x = 2, y = 4}, +}) + +return true