Advertisement
PlatinKinggg

settingsmodel.lua

Jun 21st, 2025 (edited)
1,246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.35 KB | Gaming | 0 0
  1. -- settingsmodel.lua
  2. -- Enthält alle definierten Konfigurationswerte inkl. Typ, Bereich, Quelle usw.
  3.  
  4.  
  5.  
  6. -- Helper-Funktion zur Laufzeit-Sprachauswahl
  7. local function getLabel(key)
  8.     local language = require("language")
  9.     local state = require("state")
  10.     local langCode = language.data[state.settings.language] and state.settings.language or "de"
  11.     local labels = language.data[langCode].settingsLabels or {}
  12.     return labels[key] or key
  13. end
  14.  
  15. local function generateColorOptions()
  16.     local t = {}
  17.     for k, v in pairs(colors) do
  18.         if type(v) == "number" and type(k) == "string" and not k:find("%.") then
  19.             -- nur echte Farben wie "red", "blue", aber keine Funktionen oder verschachtelte Keys
  20.             local key = "colors." .. k
  21.             t[key] = k
  22.         end
  23.     end
  24.     return t
  25. end
  26.  
  27. return {
  28.     order = {
  29.         "startpage",
  30.         "language",
  31.         "updateInterval",
  32.         "timeFormat",
  33.         "dateFormat",
  34.         "forceStart",
  35.         "forceStop",
  36.         "mBPerBlade",
  37.         "energyStopThreshold",
  38.         "errorResetTime",
  39.         "flowEfficiencyLimit",
  40.         "rotorMaxSpeed",
  41.         "referenceMass",
  42.         "referenceRPMThreshold1",
  43.         "referenceRPMThreshold2",
  44.         "referenceRPMThreshold3",
  45.         "headerBackground",
  46.         "headerText",
  47.         "buttonWindowColor",
  48.         "buttonBackgroundColor",
  49.         "buttonTextColor",
  50.         "infoBackgroundColorA",
  51.         "infoBackgroundColorB",
  52.         "infoTextColor"
  53.     },
  54.  
  55.     startpage = {
  56.         label = function() return getLabel("startpage") end,
  57.         type = "text",
  58.         default = 1,
  59.         scope = "system",
  60.         options = function()
  61.             local language = require("language")
  62.             local state = require("state")
  63.             local langCode = language.data[state.settings.language] and state.settings.language or "de"
  64.             return language.data[langCode].gui.pageNames or {}
  65.         end,
  66.         optionKeys = { 1, 2, 3 }
  67.     },
  68.  
  69.     language = {
  70.         label = function() return getLabel("language") end,
  71.         type = "text",
  72.         default = "de",
  73.         scope = "system",
  74.         options = function()
  75.             local lang = require("language")
  76.             local state = require("state")
  77.             local langKey = state.langKey or "de"
  78.             return lang.data[langKey].gui.languageoptions or {}
  79.         end,
  80.         optionKeys = { "de", "en" }
  81.     },
  82.  
  83.     updateInterval = {
  84.         label = function() return getLabel("updateInterval") end,
  85.         type = "number",
  86.         min = 1,
  87.         max = 5,
  88.         step = 1,
  89.         default = 2,
  90.         unit = "s",
  91.         scope = "system"
  92.     },
  93.  
  94.     timeFormat = {
  95.         label = function() return getLabel("timeFormat") end,
  96.         type = "text",
  97.         default = 1,
  98.         scope = "system",
  99.         options = function()
  100.             local lang = require("language")
  101.             local state = require("state")
  102.             local langCode = state.langKey or "de"
  103.             return lang.data[langCode].gui.timeFormatOptions or {}
  104.         end,
  105.         optionKeys = { 1, 2, 3, 4 }
  106.     },
  107.  
  108.     dateFormat = {
  109.         label = function() return getLabel("dateFormat") end,
  110.         type = "text",
  111.         default = 1,
  112.         scope = "system",
  113.         options = function()
  114.             local lang = require("language")
  115.             local state = require("state")
  116.             local langCode = state.langKey or "de"
  117.             return lang.data[langCode].gui.dateFormatOptions or {}
  118.         end,
  119.         optionKeys = { 1, 2, 3, 4, 5}
  120.     },
  121.  
  122.     forceStart = {
  123.         label = function() return getLabel("forceStart") end,
  124.         type = "toggle",
  125.         default = true,
  126.         scope = "user"
  127.     },
  128.  
  129.     forceStop = {
  130.         label = function() return getLabel("forceStop") end,
  131.         type = "toggle",
  132.         default = true,
  133.         scope = "user"
  134.     },
  135.  
  136.     mBPerBlade = {
  137.         label = function() return getLabel("mBPerBlade") end,
  138.         type = "number",
  139.         unit = "mB",
  140.         min = 1,
  141.         max = 100,
  142.         step = 1,
  143.         default = 25,
  144.         scope = "user"
  145.     },
  146.  
  147.     energyStopThreshold = {
  148.         label = function() return getLabel("energyStopThreshold") end,
  149.         type = "number",
  150.         min = 0.0,
  151.         max = 1.0,
  152.         step = 0.01,
  153.         default = 0.95,
  154.         scope = "system"
  155.     },
  156.  
  157.     errorResetTime = {
  158.         label = function() return getLabel("errorResetTime") end,
  159.         type = "number",
  160.         min = 10,
  161.         max = 600,
  162.         step = 10,
  163.         default = 60,
  164.         scope = "system"
  165.     },
  166.  
  167.     flowEfficiencyLimit = {
  168.         label = function() return getLabel("flowEfficiencyLimit") end,
  169.         type = "toggle",
  170.         default = true,
  171.         scope = "user"
  172.     },
  173.  
  174.     rotorMaxSpeed = {
  175.         label = function() return getLabel("rotorMaxSpeed") end,
  176.         type = "number",
  177.         unit = "RPM",
  178.         min = 1000,
  179.         max = 2000,
  180.         step = 50,
  181.         default = 1800,
  182.         scope = "user"
  183.     },
  184.  
  185.     referenceMass = {
  186.         label = function() return getLabel("referenceMass") end,
  187.         type = "number",
  188.         min = 100,
  189.         max = 2000,
  190.         step = 50,
  191.         default = 300,
  192.         scope = "system"
  193.     },
  194.  
  195.     referenceRPMThreshold1 = {
  196.         label = function() return getLabel("referenceRPMThreshold1") end,
  197.         type = "number",
  198.         min = 50,
  199.         max = 500,
  200.         step = 10,
  201.         default = 240,
  202.         scope = "system"
  203.     },
  204.  
  205.     referenceRPMThreshold2 = {
  206.         label = function() return getLabel("referenceRPMThreshold2") end,
  207.         type = "number",
  208.         min = 50,
  209.         max = 500,
  210.         step = 10,
  211.         default = 160,
  212.         scope = "system"
  213.     },
  214.  
  215.     referenceRPMThreshold3 = {
  216.         label = function() return getLabel("referenceRPMThreshold3") end,
  217.         type = "number",
  218.         min = 50,
  219.         max = 500,
  220.         step = 10,
  221.         default = 80,
  222.         scope = "system"
  223.     },
  224.  
  225.     headerBackground = {
  226.         label = function() return getLabel("headerBackground") end,
  227.         type = "color",
  228.         scope = "system",
  229.         default = "colors.brown",
  230.         options = generateColorOptions()
  231.     },
  232.    
  233.     headerText = {
  234.         label = function() return getLabel("headerText") end,
  235.         type = "color",
  236.         scope = "system",
  237.         default = "colors.black",
  238.         options = generateColorOptions()
  239.     },
  240.    
  241.     buttonWindowColor = {
  242.         label = function() return getLabel("buttonWindowColor") end,
  243.         type = "color",
  244.         scope = "system",
  245.         default = "colors.orange",
  246.         options = generateColorOptions()
  247.     },
  248.    
  249.     buttonBackgroundColor = {
  250.         label = function() return getLabel("buttonBackgroundColor") end,
  251.         type = "color",
  252.         scope = "system",
  253.         default = "colors.black",
  254.         options = generateColorOptions()
  255.     },
  256.    
  257.     buttonTextColor = {
  258.         label = function() return getLabel("buttonTextColor") end,
  259.         type = "color",
  260.         scope = "system",
  261.         default = "colors.white",
  262.         options = generateColorOptions()
  263.     },
  264.    
  265.     infoBackgroundColorA = {
  266.         label = function() return getLabel("infoBackgroundColorA") end,
  267.         type = "color",
  268.         scope = "system",
  269.         default  = "colors.gray",
  270.         options = generateColorOptions()
  271.     },
  272.    
  273.     infoBackgroundColorB = {
  274.         label = function() return getLabel("infoBackgroundColorB") end,
  275.         type = "color",
  276.         scope = "system",
  277.         default  = "colors.lightGray",
  278.         options = generateColorOptions()
  279.     },
  280.    
  281.     infoTextColor = {
  282.         label = function() return getLabel("infoTextColor") end,
  283.         type = "color",
  284.         scope = "system",
  285.         default = "colors.white",
  286.         options = generateColorOptions()
  287.     },
  288. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement