Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------
- -- GUI.lua (Собранная библиотека)
- -- Содержит: table.reduce, объекты GUI, GUI.Scene,
- -- все components (Button, Switch, Label и т.д.),
- -- утилиты (gpuMethods, StyleValidator, Symbols),
- -- базовую тему (default).
- ------------------------------------------------------------
- local component = require("component")
- local computer = require("computer")
- local unicode = require("unicode")
- local gpu = component.gpu -- При необходимости можете перенести в другое место
- local os = require("os")
- ------------------------------------------------------------
- -- table.reduce (из GUI_01.lua)
- ------------------------------------------------------------
- table.reduce = function(tbl, init, func)
- local accumulator = init
- for _, value in ipairs(tbl) do
- accumulator = func(accumulator, value)
- end
- return accumulator
- end
- ------------------------------------------------------------
- -- Объявляем GUI как глобальную таблицу
- ------------------------------------------------------------
- GUI = {}
- GUI.__index = GUI
- GUI.last_event = nil
- GUI.themes = {} -- Список всех тем
- GUI.components = {} -- Список всех компонентов
- ------------------------------------------------------------
- -- Обёртка для задержки (для sleep(0)) и т.д.
- -- Если нужно, чтобы код "отпускал" CPU при долгих циклах
- ------------------------------------------------------------
- local function safeSleep(t)
- os.sleep(t or 0)
- end
- ------------------------------------------------------------
- -- Определим Scene (основной класс сцены)
- ------------------------------------------------------------
- GUI.Scene = {}
- GUI.Scene.__index = GUI.Scene
- function GUI.Scene:newScene(themeName)
- local scene = {
- themeName = themeName or "default",
- isActive = false,
- last_event = {},
- windows = {},
- theme = {},
- signalHandlerSleepTLWD = 0
- }
- setmetatable(scene, GUI.Scene)
- scene:setTheme(themeName or "default")
- return scene
- end
- --- Обрабатывает сигналы (pullSignal(0)).
- function GUI.Scene:signalHandler(callback)
- self.signalHandlerSleepTLWD = self.signalHandlerSleepTLWD + 1
- if self.signalHandlerSleepTLWD == 2048 then
- safeSleep(0)
- self.signalHandlerSleepTLWD = 0
- end
- local signal = { computer.pullSignal(0) }
- if signal then return signal end
- return { [1]="none",[2]="",[3]=0,[4]=0,[5]=0,[6]=0 }
- end
- function GUI.Scene:run(callback)
- self.isActive = true
- while self.isActive do
- self.last_event = self:signalHandler(callback)
- for _, window in ipairs(self.windows) do
- window:handleEvent(self.last_event)
- end
- end
- end
- function GUI.Scene:stop()
- self.isActive = false
- end
- function GUI.Scene:setTheme(themeName)
- assert(GUI.themes[themeName],("Theme (%s) not found in GUI.themes"):format(themeName))
- -- Рекурсивная таблица
- local function createSearchableTable(data)
- local mt = {
- __index = function(tbl, key)
- if rawget(tbl,key) then return rawget(tbl,key) end
- for k,v in pairs(tbl) do
- if type(v)=="table" then
- local result = v[key]
- if result then return result end
- error(("Ключ (%s) не найден в подтаблице: %s"):format(key,tostring(k)))
- end
- end
- error(("Ключ (%s) не найден в таблице."):format(key))
- end
- }
- return setmetatable(data,mt)
- end
- self.theme = createSearchableTable(GUI.themes[themeName])
- end
- function GUI.Scene:validateColorTheme(objType, objName, colorName)
- assert(self.theme[objType],("objType: %s not found in theme"):format(objType))
- assert(self.theme[objType][objName],
- ("objName: %s not found in %s"):format(objName,objType))
- assert(self.theme[objType][objName][colorName],
- ("colorName: %s not found in %s"):format(colorName,objName))
- return self.theme[objType][objName][colorName]
- end
- function GUI.Scene:addWindow(x,y,width,height,colorName)
- self:validateColorTheme("components","Window",colorName)
- local window = self.Window:new(x,y,width,height,colorName)
- window.Scene = self
- table.insert(self.windows, window)
- return self.windows[#self.windows]
- end
- function GUI.Scene:destroyWindow(window_name)
- if not self.windows[window_name] then
- error("Can\'t find a window in the scene")
- end
- self.windows[window_name] = nil
- end
- ------------------------------------------------------------
- -- Класс окна (Window)
- ------------------------------------------------------------
- GUI.Scene.Window = {}
- GUI.Scene.Window.__index = GUI.Scene.Window
- function GUI.Scene.Window:new(x,y,width,height,colorName)
- local window = {
- type = "Window",
- x=x,y=y,width=width,height=height,
- colorName=colorName, background=0,
- elements={}
- }
- setmetatable(window, GUI.Scene.Window)
- return window
- end
- function GUI.Scene.Window:draw()
- gpu.setForeground(self.Scene.theme.Scene.Window[self.colorName])
- gpu.setBackground(self.Scene.theme.Scene.Window[self.colorName])
- self.background = self.Scene.theme.Scene.Window[self.colorName]
- gpu.fill(self.x,self.y,self.width,self.height," ")
- end
- function GUI.Scene.Window:handleEvent(event)
- for _,el in ipairs(self.elements) do
- if el.handleEvent then el:handleEvent(event) end
- end
- end
- function GUI.Scene.Window:addElement(elementType,elementName,...)
- assert(GUI[elementType],("elementType (%s) not found"):format(elementType))
- assert(GUI[elementType][elementName],
- ("elementName (%s) not found in GUI[%s]"):format(elementName,elementType))
- local element = GUI[elementType][elementName]:new(...)
- element.ParentOBJ = self
- table.insert(self.elements, element)
- return self.elements[#self.elements]
- end
- ------------------------------------------------------------
- -- Некоторые вспомогательные методы GUI
- ------------------------------------------------------------
- function GUI:new() return self end
- function GUI:getThemesName()
- local t={}
- for k,_ in pairs(self.themes) do table.insert(t,k) end
- return t
- end
- function GUI:getCurrentThemeName()
- return self.themeName
- end
- ------------------------------------------------------------
- -- gpuMethods (.\src\Depency\gpuMethods.lua)
- ------------------------------------------------------------
- GUI.gpuMethods = {}
- GUI.gpuMethods.__index = GUI.gpuMethods
- function GUI.gpuMethods:set(text,x,y,foreground,background)
- if foreground then gpu.setForeground(foreground) end
- if background then gpu.setBackground(background) end
- gpu.set(x,y,text)
- end
- function GUI.gpuMethods:fill(symbol,x,y,width,height,foreground,background)
- if foreground then gpu.setForeground(foreground) end
- if background then gpu.setBackground(background) end
- gpu.fill(x,y,width,height,symbol)
- end
- ------------------------------------------------------------
- -- StyleValidator (.\src\Utils\StyleValidator.lua)
- ------------------------------------------------------------
- GUI.StyleValidator = {}
- GUI.StyleValidator.__index = GUI.StyleValidator
- function GUI.StyleValidator:_checkForDuplicateStyles(stylesString)
- local seen={}
- for style in stylesString:gmatch("%S+") do
- if seen[style] then
- error(("Дублирующийся стиль: \'%s\'"):format(style))
- end
- seen[style]=true
- end
- end
- function GUI.StyleValidator:isStyleCompatible(compatibilityTable,style1,style2)
- if compatibilityTable[style1] then
- for _,compatible in ipairs(compatibilityTable[style1]) do
- if compatible==style2 then return true end
- end
- end
- return false
- end
- function GUI.StyleValidator:validateStyles(stylesString,compatibilityTable,validatedStyles)
- local valid_styles={}
- self:_checkForDuplicateStyles(stylesString)
- for style in stylesString:gmatch("%S+") do
- local isValid=false
- for _,v in ipairs(validatedStyles) do
- if style==v then isValid=true;break end
- end
- assert(isValid,
- ("Стиль \'%s\' недопустим. Допустимые стили: %s"):format(
- style,table.concat(validatedStyles,"; ")))
- if compatibilityTable[style] then
- for otherStyle in stylesString:gmatch("%S+") do
- if style~=otherStyle and not self:isStyleCompatible(compatibilityTable,style,otherStyle) then
- error(("Стили \'%s\' и \'%s\' несовместимы."):format(style,otherStyle))
- end
- end
- end
- valid_styles[style]=true
- end
- return valid_styles
- end
- ------------------------------------------------------------
- -- Components
- ------------------------------------------------------------
- -- Button (.\src\Components\Button.lua)
- GUI.components.Button={}
- GUI.components.Button.__index=GUI.components.Button
- function GUI.components.Button:new(x,y,styles,callback)
- local button={
- type="Button", styles=styles,
- x=x,y=y, width=0, height=0,
- callback=callback,
- background=0, foreground=0xFFFFFF, disabled=false,
- button_colors_names={
- "btn-primary","btn-secondary","btn-success","btn-danger","btn-warning",
- "btn-info","btn-light","btn-dark","btn-link"
- },
- styles_validated={
- "btn-primary","btn-secondary","btn-success","btn-danger","btn-warning",
- "btn-info","btn-light","btn-dark","btn-link",
- "sm","rounded","brackets","strokes","doted","disabled"
- },
- compatibility_styles={
- ["btn-primary"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-secondary"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-success"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-danger"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-warning"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-info"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-light"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-dark"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["btn-link"]={"sm","rounded","brackets","strokes","doted","disabled"},
- ["sm"]={"rounded","brackets","disabled"}
- },
- inserted_obj={},
- valid_styles={},
- button_colors={}
- }
- button.button_colors = table.reduce(
- button.button_colors_names,{},function(acc,colorClassName)
- local themeColor = GUI.Scene.theme.components.Button[colorClassName]
- acc[colorClassName] = themeColor or 0xFFFFFF
- return acc
- end
- )
- button.valid_styles = GUI.StyleValidator:validateStyles(
- styles, button.compatibility_styles, button.styles_validated
- )
- button.height = (button.valid_styles["sm"] and 1) or 3
- assert(type(x)=="number","x must be number")
- assert(type(y)=="number","y must be number")
- setmetatable(button,GUI.components.Button)
- return button
- end
- function GUI.components.Button:addElement(elementName,...)
- local supportElements={Label=true,Checked=true,Badge=true,Switch=true}
- assert(supportElements[elementName],("ElementName (%s) not supported in Button"):format(elementName))
- assert(GUI.components[elementName],("No GUI.components.%s"):format(elementName))
- local element=GUI.components[elementName]:new(...)
- element.ParentOBJ=self
- table.insert(self.inserted_obj,element)
- return element
- end
- function GUI.components.Button:draw()
- local fg=self.foreground or 0xFFFFFF
- local bg=self.background or 0x000000
- GUI.gpuMethods:fill(" ",self.x,self.y,self.width,self.height,fg,bg)
- for _,obj in ipairs(self.inserted_obj) do
- if obj.draw then obj:draw() end
- end
- end
- function GUI.components.Button:erase()
- local bg=(self.ParentOBJ and self.ParentOBJ.background) or 0x000000
- GUI.gpuMethods:fill(" ",self.x,self.y,self.width,self.height,bg,bg)
- end
- function GUI.components.Button:disable(state)
- self.disabled=(state==true)
- self:draw()
- end
- function GUI.components.Button:handleEvent(event)
- if not self.disabled and event[1]=="touch" then
- local _,_,tx,ty=table.unpack(event)
- if tx>=self.x and tx<=(self.x+self.width-1)
- and ty>=self.y and ty<=(self.y+self.height-1)
- then
- if type(self.callback)=="function" then self.callback(self) end
- end
- end
- end
- -- Switch (.\src\Components\Switch.lua)
- GUI.components.Switch={}
- GUI.components.Switch.__index=GUI.components.Switch
- function GUI.components.Switch:new(x,y,isOn,callback)
- local sw={
- type="Switch", x=x,y=y,
- isOn=(isOn==true),
- width=5,height=1,
- backgroundOn=0x00FF00, backgroundOff=0xFF0000,
- foreground=0x000000,
- callback=callback
- }
- setmetatable(sw,GUI.components.Switch)
- return sw
- end
- function GUI.components.Switch:draw()
- local bg=self.isOn and self.backgroundOn or self.backgroundOff
- local text=self.isOn and "[On] " or "[Off]"
- GUI.gpuMethods:fill(" ",self.x,self.y,self.width,self.height,self.foreground,bg)
- gpu.setForeground(self.foreground)
- gpu.setBackground(bg)
- gpu.set(self.x,self.y,text)
- end
- function GUI.components.Switch:handleEvent(event)
- if event[1]=="touch" then
- local _,_,tx,ty=table.unpack(event)
- if tx>=self.x and tx<(self.x+self.width) and ty==self.y then
- self.isOn=not self.isOn
- if type(self.callback)=="function" then
- self.callback(self,self.isOn)
- end
- self:draw()
- end
- end
- end
- -- Checked (.\src\Components\Checked.lua) (Чекбокс/флажок)
- GUI.Checked={}
- GUI.Checked.__index=GUI.Checked
- function GUI.Checked:new(x,y,checked)
- local c={x=x,y=y,checked=checked or false}
- setmetatable(c,GUI.Checked)
- return c
- end
- function GUI.Checked:handleEvent(event)
- if event[1]=="touch" then
- local _,_,tx,ty=table.unpack(event)
- if tx==self.x and ty==self.y then
- self.checked=not self.checked
- end
- end
- end
- -- Label (.\src\Components\Label.lua)
- GUI.components.Label={}
- GUI.components.Label.__index=GUI.Label
- function GUI.components.Label:new(text_table,x,y,align,callback)
- self:validateTextTable(text_table)
- local label={
- type="Label",
- x=0,y=y, full_len_text=0,
- text_table=self:prepareTextTable(text_table),
- background=0,
- callback=callback
- }
- label.x, label.full_len_text = self:calculatePositionAndLength(text_table,x,align)
- setmetatable(label,GUI.components.Label)
- return label
- end
- function GUI.components.Label:validateTextTable(tt)
- assert(type(tt)=="table" and next(tt),("Label text_table is empty or not table"))
- for _,v in ipairs(tt) do
- assert(type(v.colorName)=="string","Label colorName must be string")
- -- Здесь проверка GUI:validateColorTheme("components","Label",v.colorName)
- -- но такой функции нет напрямую в GUI, поэтому опустим или реализуем при желании.
- end
- end
- function GUI.components.Label:prepareTextTable(tt)
- local t={}
- for _,v in ipairs(tt) do
- table.insert(t,{str=v.str,colorName=v.colorName,str_len=unicode.len(v.str)})
- end
- return t
- end
- function GUI.components.Label:calculatePositionAndLength(tt,x,align)
- local s=""
- for _,v in ipairs(tt) do
- s=s..v.str
- end
- local length=unicode.len(s)
- if align then return x,length end
- return math.abs(math.floor(x-(length/2))),length
- end
- function GUI.components.Label:draw()
- local x=self.x
- for _,v in ipairs(self.text_table) do
- gpu.setBackground(self.ParentOBJ.background)
- -- Если хотите цвета из темы, надо делать что-то вроде:
- -- local fgColor = self.ParentOBJ.Scene.theme.components.Label[v.colorName]
- -- но здесь используем "gpu.setForeground(...)"
- gpu.setForeground(0xFFFFFF)
- gpu.set(x,self.y,v.str)
- x=x+v.str_len
- end
- end
- function GUI.components.Label:handleEvent(event)
- if event[1]=="touch" then
- local _,_,tx,ty=table.unpack(event)
- if tx>=self.x and tx<=(self.x+self.full_len_text) and ty==self.y then
- return self.callback and self.callback(self) or false
- end
- end
- end
- ------------------------------------------------------------
- -- AllColors (.\src\Depency\AllColors.lua) -- не обязательно используется
- ------------------------------------------------------------
- GUI.AllColors={
- [1] = {
- [1] = 0x000000, [11] = 0x660000, [21] = 0xcc0000,
- [2] = 0x000040, [12] = 0x660040, [22] = 0xcc0040,
- [3] = 0x000080, [13] = 0x660080, [23] = 0xcc0080,
- [4] = 0x0000c0, [14] = 0x6600c0, [24] = 0xcc00c0,
- [5] = 0x0000ff, [15] = 0x6600ff, [25] = 0xcc00ff,
- [6] = 0x330000, [16] = 0x990000, [26] = 0xff0000,
- [7] = 0x330040, [17] = 0x990040, [27] = 0xff0040,
- [8] = 0x330080, [18] = 0x990080, [28] = 0xff0080,
- [9] = 0x3300c0, [19] = 0x9900c0, [29] = 0xff00c0,
- [10]= 0x3300ff, [20] = 0x9900ff, [30] = 0xff00ff
- },
- [2] = {
- [1] = 0x002400, [11] = 0x662400, [21] = 0xcc2400,
- [2] = 0x002440, [12] = 0x662440, [22] = 0xcc2440,
- [3] = 0x002480, [13] = 0x662480, [23] = 0xcc2480,
- [4] = 0x0024c0, [14] = 0x6624c0, [24] = 0xcc24c0,
- [5] = 0x0024ff, [15] = 0x6624ff, [25] = 0xcc24ff,
- [6] = 0x332400, [16] = 0x992400, [26] = 0xff2400,
- [7] = 0x332440, [17] = 0x992440, [27] = 0xff2440,
- [8] = 0x332480, [18] = 0x992480, [28] = 0xff2480,
- [9] = 0x3324c0, [19] = 0x9924c0, [29] = 0xff24c0,
- [10]= 0x3324ff, [20] = 0x9924ff, [30] = 0xff24ff
- },
- [3] = {
- [1] = 0x004900, [11] = 0x664900, [21] = 0xcc4900,
- [2] = 0x004940, [12] = 0x664940, [22] = 0xcc4940,
- [3] = 0x004980, [13] = 0x664980, [23] = 0xcc4980,
- [4] = 0x0049c0, [14] = 0x6649c0, [24] = 0xcc49c0,
- [5] = 0x0049ff, [15] = 0x6649ff, [25] = 0xcc49ff,
- [6] = 0x334900, [16] = 0x994900, [26] = 0xff4900,
- [7] = 0x334940, [17] = 0x994940, [27] = 0xff4940,
- [8] = 0x334980, [18] = 0x994980, [28] = 0xff4980,
- [9] = 0x3349c0, [19] = 0x9949c0, [29] = 0xff49c0,
- [10]= 0x3349ff, [20] = 0x9949ff, [30] = 0xff49ff
- },
- [4] = {
- [1] = 0x006d00, [11] = 0x666d00, [21] = 0xcc6d00,
- [2] = 0x006d40, [12] = 0x666d40, [22] = 0xcc6d40,
- [3] = 0x006d80, [13] = 0x666d80, [23] = 0xcc6d80,
- [4] = 0x006dc0, [14] = 0x666dc0, [24] = 0xcc6dc0,
- [5] = 0x006dff, [15] = 0x666dff, [25] = 0xcc6dff,
- [6] = 0x336d00, [16] = 0x996d00, [26] = 0xff6d00,
- [7] = 0x336d40, [17] = 0x996d40, [27] = 0xff6d40,
- [8] = 0x336d80, [18] = 0x996d80, [28] = 0xff6d80,
- [9] = 0x336dc0, [19] = 0x996dc0, [29] = 0xff6dc0,
- [10]= 0x336dff, [20] = 0x996dff, [30] = 0xff6dff
- },
- [5] = {
- [1] = 0x009200, [11] = 0x669200, [21] = 0xcc9200,
- [2] = 0x009240, [12] = 0x669240, [22] = 0xcc9240,
- [3] = 0x009280, [13] = 0x669280, [23] = 0xcc9280,
- [4] = 0x0092c0, [14] = 0x6692c0, [24] = 0xcc92c0,
- [5] = 0x0092ff, [15] = 0x6692ff, [25] = 0xcc92ff,
- [6] = 0x339200, [16] = 0x999200, [26] = 0xff9200,
- [7] = 0x339240, [17] = 0x999240, [27] = 0xff9240,
- [8] = 0x339280, [18] = 0x999280, [28] = 0xff9280,
- [9] = 0x3392c0, [19] = 0x9992c0, [29] = 0xff92c0,
- [10]= 0x3392ff, [20] = 0x9992ff, [30] = 0xff92ff
- },
- [6] = {
- [1] = 0x00b600, [11] = 0x66b600, [21] = 0xccb600,
- [2] = 0x00b640, [12] = 0x66b640, [22] = 0xccb640,
- [3] = 0x00b680, [13] = 0x66b680, [23] = 0xccb680,
- [4] = 0x00b6c0, [14] = 0x66b6c0, [24] = 0xccb6c0,
- [5] = 0x00b6ff, [15] = 0x66b6ff, [25] = 0xccb6ff,
- [6] = 0x33b600, [16] = 0x99b600, [26] = 0xffb600,
- [7] = 0x33b640, [17] = 0x99b640, [27] = 0xffb640,
- [8] = 0x33b680, [18] = 0x99b680, [28] = 0xffb680,
- [9] = 0x33b6c0, [19] = 0x99b6c0, [29] = 0xffb6c0,
- [10]= 0x33b6ff, [20] = 0x99b6ff, [30] = 0xffb6ff
- },
- [7] = {
- [1] = 0x00db00, [11] = 0x66db00, [21] = 0xccdb00,
- [2] = 0x00db40, [12] = 0x66db40, [22] = 0xccdb40,
- [3] = 0x00db80, [13] = 0x66db80, [23] = 0xccdb80,
- [4] = 0x00dbc0, [14] = 0x66dbc0, [24] = 0xccdbc0,
- [5] = 0x00dbff, [15] = 0x66dbff, [25] = 0xccdbff,
- [6] = 0x33db00, [16] = 0x99db00, [26] = 0xffdb00,
- [7] = 0x33db40, [17] = 0x99db40, [27] = 0xffdb40,
- [8] = 0x33db80, [18] = 0x99db80, [28] = 0xffdb80,
- [9] = 0x33dbc0, [19] = 0x99dbc0, [29] = 0xffdbc0,
- [10]= 0x33dbff, [20] = 0x99dbff, [30] = 0xffdbff
- },
- [8] = {
- [1] = 0x00ff00, [11] = 0x66ff00, [21] = 0xccff00,
- [2] = 0x00ff40, [12] = 0x66ff40, [22] = 0xccff40,
- [3] = 0x00ff80, [13] = 0x66ff80, [23] = 0xccff80,
- [4] = 0x00ffc0, [14] = 0x66ffc0, [24] = 0xccffc0,
- [5] = 0x00ffff, [15] = 0x66ffff, [25] = 0xccffff,
- [6] = 0x33ff00, [16] = 0x99ff00, [26] = 0xffff00,
- [7] = 0x33ff40, [17] = 0x99ff40, [27] = 0xffff40,
- [8] = 0x33ff80, [18] = 0x99ff80, [28] = 0xffff80,
- [9] = 0x33ffc0, [19] = 0x99ffc0, [29] = 0xffffc0,
- [10]= 0x33ffff, [20] = 0x99ffff, [30] = 0xffffff
- },
- [0] = { -- grey colors
- [1] = 0x0f0f0f, [9] = 0x878787,
- [2] = 0x1e1e1e, [10] = 0x969696,
- [3] = 0x2d2d2d, [11] = 0xa5a5a5,
- [4] = 0x3c3c3c, [12] = 0xb4b4b4,
- [5] = 0x4b4b4b, [13] = 0xc3c3c3,
- [6] = 0x5a5a5a, [14] = 0xd2d2d2,
- [7] = 0x696969, [15] = 0xe1e1e1,
- [8] = 0x787878, [16] = 0xf0f0f0,
- }
- }
- -- (Укорочено)
- ------------------------------------------------------------
- -- Symbols (.\src\Utils\Symbols.lua)
- ------------------------------------------------------------
- GUI.Symbols={}
- GUI.Symbols.__index=GUI.Symbols
- GUI.Symbols.fullwidth_symbols={
- -- Полношрифтные латинские буквы
- ["A"] = "A", -- U+FF21
- ["B"] = "B", -- U+FF22
- ["C"] = "C", -- U+FF23
- ["D"] = "D", -- U+FF24
- ["E"] = "E", -- U+FF25
- ["F"] = "F", -- U+FF26
- ["G"] = "G", -- U+FF27
- ["H"] = "H", -- U+FF28
- ["I"] = "I", -- U+FF29
- ["J"] = "J", -- U+FF2A
- ["K"] = "K", -- U+FF2B
- ["L"] = "L", -- U+FF2C
- ["M"] = "M", -- U+FF2D
- ["N"] = "N", -- U+FF2E
- ["O"] = "O", -- U+FF2F
- ["P"] = "P", -- U+FF30
- ["Q"] = "Q", -- U+FF31
- ["R"] = "R", -- U+FF32
- ["S"] = "S", -- U+FF33
- ["T"] = "T", -- U+FF34
- ["U"] = "U", -- U+FF35
- ["V"] = "V", -- U+FF36
- ["W"] = "W", -- U+FF37
- ["X"] = "X", -- U+FF38
- ["Y"] = "Y", -- U+FF39
- ["Z"] = "Z", -- U+FF3A
- -- Полношрифтные цифры
- ["0"] = "0", -- U+FF10
- ["1"] = "1", -- U+FF11
- ["2"] = "2", -- U+FF12
- ["3"] = "3", -- U+FF13
- ["4"] = "4", -- U+FF14
- ["5"] = "5", -- U+FF15
- ["6"] = "6", -- U+FF16
- ["7"] = "7", -- U+FF17
- ["8"] = "8", -- U+FF18
- ["9"] = "9", -- U+FF19
- -- Полношрифтные русские буквы
- ["А"] = "A", -- U+FF21 (А)
- ["Б"] = "Б", -- U+FF22 (Б)
- ["В"] = "В", -- U+FF23 (В)
- ["Г"] = "Г", -- U+FF24 (Г)
- ["Д"] = "Д", -- U+FF25 (Д)
- ["Е"] = "Е", -- U+FF26 (Е)
- ["Ё"] = "Ё", -- U+FF27 (Ё)
- ["Ж"] = "Ж", -- U+FF28 (Ж)
- ["З"] = "З", -- U+FF29 (З)
- ["И"] = "И", -- U+FF2A (И)
- ["Й"] = "Й", -- U+FF2B (Й)
- ["К"] = "К", -- U+FF2C (К)
- ["Л"] = "Л", -- U+FF2D (Л)
- ["М"] = "М", -- U+FF2E (М)
- ["Н"] = "Н", -- U+FF2F (Н)
- ["О"] = "О", -- U+FF30 (О)
- ["П"] = "П", -- U+FF31 (П)
- ["Р"] = "Р", -- U+FF32 (Р)
- ["С"] = "С", -- U+FF33 (С)
- ["Т"] = "Т", -- U+FF34 (Т)
- ["У"] = "У", -- U+FF35 (У)
- ["Ф"] = "Ф", -- U+FF36 (Ф)
- ["Х"] = "Х", -- U+FF37 (Х)
- ["Ц"] = "Ц", -- U+FF38 (Ц)
- ["Ч"] = "Ч", -- U+FF39 (Ч)
- ["Ш"] = "Ш", -- U+FF3A (Ш)
- ["Щ"] = "Щ", -- U+FF3B (Щ)
- ["Ъ"] = "Ъ", -- U+FF3C (Ъ)
- ["Ы"] = "Ы", -- U+FF3D (Ы)
- ["Ь"] = "Ь", -- U+FF3E (Ь)
- ["Э"] = "Э", -- U+FF3F (Э)
- ["Ю"] = "Ю", -- U+FF40 (Ю)
- ["Я"] = "Я", -- U+FF41 (Я)
- -- Полношрифтные специальные символы
- ["!"] = "!", -- U+FF01
- ["\""] = """, -- U+FF02
- ["#"] = "#", -- U+FF03
- ["$"] = "$", -- U+FF04
- ["%"] = "%", -- U+FF05
- ["&"] = "&", -- U+FF06
- ["'"] = "'", -- U+FF07
- ["("] = "(", -- U+FF08
- [")"] = ")", -- U+FF09
- ["*"] = "*", -- U+FF0A
- ["+"] = "+", -- U+FF0B
- [","] = ",", -- U+FF0C
- ["-"] = "-", -- U+FF0D
- ["."] = ".", -- U+FF0E
- ["/"] = "/", -- U+FF0F
- [":"] = ":", -- U+FF1A
- [";"] = ";", -- U+FF1B
- ["<"] = "<", -- U+FF1C
- ["="] = "=", -- U+FF1D
- [">"] = ">", -- U+FF1E
- ["?"] = "?", -- U+FF1F
- ["@"] = "@", -- U+FF20
- ["["] = "[", -- U+FF3B
- ["\\"] = "\", -- U+FF3C
- ["]"] = "]", -- U+FF3D
- ["^"] = "^", -- U+FF3E
- ["_"] = "_", -- U+FF3F
- ["`"] = "`", -- U+FF40
- ["{"] = "{", -- U+FF5B
- ["|"] = "|", -- U+FF5C
- ["}"] = "}", -- U+FF5D
- ["~"] = "~", -- U+FF5E
- -- Математические символы
- ["±"] = "±", -- U+00B1
- ["×"] = "×", -- U+00D7
- ["÷"] = "÷", -- U+00F7
- ["≠"] = "≠", -- U+2260
- ["≤"] = "≤", -- U+2264
- ["≥"] = "≥", -- U+2265
- ["∞"] = "∞", -- U+221E
- ["∑"] = "∑", -- U+2211
- ["√"] = "√", -- U+221A
- ["∏"] = "∏", -- U+220F
- -- Другие специальные символы
- ["§"] = "§", -- U+00A7
- ["©"] = "©", -- U+00A9
- ["®"] = "®", -- U+00AE
- ["™"] = "™", -- U+2122
- }
- GUI.Symbols.additionalSymbols={
- cross="❌"
- }
- function GUI.Symbols:replaceSpecialSymbols(input)
- local value=unicode.upper(input)
- local res=""
- local length=unicode.len(value)
- for i=1,length do
- local ch=unicode.sub(value,i,i)
- if self.fullwidth_symbols[ch] then
- res=res..self.fullwidth_symbols[ch]
- else
- res=res..ch
- end
- end
- return res
- end
- function GUI.Symbols:getSymbol(key)
- if self.fullwidth_symbols[key] then return self.fullwidth_symbols[key] end
- if self.additionalSymbols[key] then return self.additionalSymbols[key] end
- return false
- end
- ------------------------------------------------------------
- -- Подключаем (или просто объявляем) тему (.\src\Themes\default_02.lua)
- ------------------------------------------------------------
- GUI.themes.default={
- components={
- Label={white=0xFFFFFF,background=0},
- Button={foreground=0xFFFFFF,background=0,["btn-primary"]=0x00AAFF,["btn-success"]=0x00FF00,["btn-danger"]=0xFF0000},
- Badge={foreground=0xFFFFFF,background=0},
- Input={foreground=0,background=0},
- Window={grey=0xCFCFCF,background=0,foreground=0}
- },
- Scene={
- Window={
- grey=0xCFCFCF
- }
- }
- }
- ------------------------------------------------------------
- -- Возвращаем GUI (на случай require(...) )
- ------------------------------------------------------------
- return GUI
Advertisement
Add Comment
Please, Sign In to add comment