Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- settingsmodel.lua
- -- Enthält alle definierten Konfigurationswerte inkl. Typ, Bereich, Quelle usw.
- -- Helper-Funktion zur Laufzeit-Sprachauswahl
- local function getLabel(key)
- local language = require("language")
- local state = require("state")
- local langCode = language.data[state.settings.language] and state.settings.language or "de"
- local labels = language.data[langCode].settingsLabels or {}
- return labels[key] or key
- end
- local function generateColorOptions()
- local t = {}
- for k, v in pairs(colors) do
- if type(v) == "number" and type(k) == "string" and not k:find("%.") then
- -- nur echte Farben wie "red", "blue", aber keine Funktionen oder verschachtelte Keys
- local key = "colors." .. k
- t[key] = k
- end
- end
- return t
- end
- return {
- order = {
- "startpage",
- "language",
- "updateInterval",
- "timeFormat",
- "dateFormat",
- "forceStart",
- "forceStop",
- "mBPerBlade",
- "energyStopThreshold",
- "errorResetTime",
- "flowEfficiencyLimit",
- "rotorMaxSpeed",
- "referenceMass",
- "referenceRPMThreshold1",
- "referenceRPMThreshold2",
- "referenceRPMThreshold3",
- "headerBackground",
- "headerText",
- "buttonWindowColor",
- "buttonBackgroundColor",
- "buttonTextColor",
- "infoBackgroundColorA",
- "infoBackgroundColorB",
- "infoTextColor"
- },
- startpage = {
- label = function() return getLabel("startpage") end,
- type = "text",
- default = 1,
- scope = "system",
- options = function()
- local language = require("language")
- local state = require("state")
- local langCode = language.data[state.settings.language] and state.settings.language or "de"
- return language.data[langCode].gui.pageNames or {}
- end,
- optionKeys = { 1, 2, 3 }
- },
- language = {
- label = function() return getLabel("language") end,
- type = "text",
- default = "de",
- scope = "system",
- options = function()
- local lang = require("language")
- local state = require("state")
- local langKey = state.langKey or "de"
- return lang.data[langKey].gui.languageoptions or {}
- end,
- optionKeys = { "de", "en" }
- },
- updateInterval = {
- label = function() return getLabel("updateInterval") end,
- type = "number",
- min = 1,
- max = 5,
- step = 1,
- default = 2,
- unit = "s",
- scope = "system"
- },
- timeFormat = {
- label = function() return getLabel("timeFormat") end,
- type = "text",
- default = 1,
- scope = "system",
- options = function()
- local lang = require("language")
- local state = require("state")
- local langCode = state.langKey or "de"
- return lang.data[langCode].gui.timeFormatOptions or {}
- end,
- optionKeys = { 1, 2, 3, 4 }
- },
- dateFormat = {
- label = function() return getLabel("dateFormat") end,
- type = "text",
- default = 1,
- scope = "system",
- options = function()
- local lang = require("language")
- local state = require("state")
- local langCode = state.langKey or "de"
- return lang.data[langCode].gui.dateFormatOptions or {}
- end,
- optionKeys = { 1, 2, 3, 4, 5}
- },
- forceStart = {
- label = function() return getLabel("forceStart") end,
- type = "toggle",
- default = true,
- scope = "user"
- },
- forceStop = {
- label = function() return getLabel("forceStop") end,
- type = "toggle",
- default = true,
- scope = "user"
- },
- mBPerBlade = {
- label = function() return getLabel("mBPerBlade") end,
- type = "number",
- unit = "mB",
- min = 1,
- max = 100,
- step = 1,
- default = 25,
- scope = "user"
- },
- energyStopThreshold = {
- label = function() return getLabel("energyStopThreshold") end,
- type = "number",
- min = 0.0,
- max = 1.0,
- step = 0.01,
- default = 0.95,
- scope = "system"
- },
- errorResetTime = {
- label = function() return getLabel("errorResetTime") end,
- type = "number",
- min = 10,
- max = 600,
- step = 10,
- default = 60,
- scope = "system"
- },
- flowEfficiencyLimit = {
- label = function() return getLabel("flowEfficiencyLimit") end,
- type = "toggle",
- default = true,
- scope = "user"
- },
- rotorMaxSpeed = {
- label = function() return getLabel("rotorMaxSpeed") end,
- type = "number",
- unit = "RPM",
- min = 1000,
- max = 2000,
- step = 50,
- default = 1800,
- scope = "user"
- },
- referenceMass = {
- label = function() return getLabel("referenceMass") end,
- type = "number",
- min = 100,
- max = 2000,
- step = 50,
- default = 300,
- scope = "system"
- },
- referenceRPMThreshold1 = {
- label = function() return getLabel("referenceRPMThreshold1") end,
- type = "number",
- min = 50,
- max = 500,
- step = 10,
- default = 240,
- scope = "system"
- },
- referenceRPMThreshold2 = {
- label = function() return getLabel("referenceRPMThreshold2") end,
- type = "number",
- min = 50,
- max = 500,
- step = 10,
- default = 160,
- scope = "system"
- },
- referenceRPMThreshold3 = {
- label = function() return getLabel("referenceRPMThreshold3") end,
- type = "number",
- min = 50,
- max = 500,
- step = 10,
- default = 80,
- scope = "system"
- },
- headerBackground = {
- label = function() return getLabel("headerBackground") end,
- type = "color",
- scope = "system",
- default = "colors.brown",
- options = generateColorOptions()
- },
- headerText = {
- label = function() return getLabel("headerText") end,
- type = "color",
- scope = "system",
- default = "colors.black",
- options = generateColorOptions()
- },
- buttonWindowColor = {
- label = function() return getLabel("buttonWindowColor") end,
- type = "color",
- scope = "system",
- default = "colors.orange",
- options = generateColorOptions()
- },
- buttonBackgroundColor = {
- label = function() return getLabel("buttonBackgroundColor") end,
- type = "color",
- scope = "system",
- default = "colors.black",
- options = generateColorOptions()
- },
- buttonTextColor = {
- label = function() return getLabel("buttonTextColor") end,
- type = "color",
- scope = "system",
- default = "colors.white",
- options = generateColorOptions()
- },
- infoBackgroundColorA = {
- label = function() return getLabel("infoBackgroundColorA") end,
- type = "color",
- scope = "system",
- default = "colors.gray",
- options = generateColorOptions()
- },
- infoBackgroundColorB = {
- label = function() return getLabel("infoBackgroundColorB") end,
- type = "color",
- scope = "system",
- default = "colors.lightGray",
- options = generateColorOptions()
- },
- infoTextColor = {
- label = function() return getLabel("infoTextColor") end,
- type = "color",
- scope = "system",
- default = "colors.white",
- options = generateColorOptions()
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement