add silent option

Leandro Silva [07-06-21 - 10:14]
add silent option
Filename
LeoTrainer.lua
LeoTrainer.txt
LeoTrainerConst.lua
Settings.lua
diff --git a/LeoTrainer.lua b/LeoTrainer.lua
index 2a6f35f..04065c1 100644
--- a/LeoTrainer.lua
+++ b/LeoTrainer.lua
@@ -290,6 +290,8 @@ function LeoTrainer.Initialize()
     LeoTrainer.data = LibSavedVars:NewAccountWide( "LeoTrainer_Data", LeoTrainer.dataDefaults )
     LeoTrainer.data.loaded = true

+    if LeoTrainer.data.silent == nil then LeoTrainer.data.silent = false end
+
     if LeoTrainer.settings.deconstruct.maxQuality[CRAFTING_TYPE_ENCHANTING] == nil then LeoTrainer.settings.deconstruct.maxQuality[CRAFTING_TYPE_ENCHANTING] = ITEM_FUNCTIONAL_QUALITY_ARCANE end

     LeoTrainer.stage = LEOTRAINER_STAGE_START
@@ -328,13 +330,16 @@ function LeoTrainer.Initialize()
     end
 end

-function LeoTrainer.log(message)
+function LeoTrainer.log(message, force)
+    if force == nil then force = false end
+    if LeoTrainer.data.silent == true and not force then return end
+
     d(LeoTrainer.chatPrefix .. message)
 end

 function LeoTrainer.debug(message)
     if not LeoTrainer.isDebug then return end
-    LeoTrainer.log('[D] ' .. message)
+    LeoTrainer.log('[D] ' .. message, true)
 end

 local function onNewMovementInUIMode(eventCode)
@@ -367,7 +372,7 @@ local function onLeoAltholicInitialized()

     LeoTrainer.LLC = LibLazyCrafting:AddRequestingAddon(LeoTrainer.name, true, LeoTrainer.LLC_Completed)

-    LeoTrainer.log("started.")
+    LeoTrainer.log("started.", true)
 end

 function LeoTrainer.OnAddOnLoaded(event, addonName)
diff --git a/LeoTrainer.txt b/LeoTrainer.txt
index 3b1756f..02e9316 100644
--- a/LeoTrainer.txt
+++ b/LeoTrainer.txt
@@ -1,7 +1,7 @@
 ## Title: Leo's Trainer
 ## APIVersion: 100035
-## Version: 2.2.2
-## AddOnVersion: 222
+## Version: 2.2.3
+## AddOnVersion: 223
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoTrainer_Settings LeoTrainer_Data
 ## OptionalDependsOn: FCOItemSaver PersonalAssistant DolgubonsLazyWritCreator
diff --git a/LeoTrainerConst.lua b/LeoTrainerConst.lua
index 22b4f59..f7a67eb 100644
--- a/LeoTrainerConst.lua
+++ b/LeoTrainerConst.lua
@@ -7,7 +7,7 @@ LeoTrainer = {
 }
 LeoTrainer.name = "LeoTrainer"
 LeoTrainer.displayName = "Leo's Trainer"
-LeoTrainer.version = "2.2.2"
+LeoTrainer.version = "2.2.3"
 LeoTrainer.chatPrefix = "|c39B027" .. LeoTrainer.name .. "|r: "
 LeoTrainer.setting = nil
 LeoTrainer.hidden = true
diff --git a/Settings.lua b/Settings.lua
index 59f8fa7..c210e22 100644
--- a/Settings.lua
+++ b/Settings.lua
@@ -125,6 +125,13 @@ function LeoTrainer_SettingsMenu:CreatePanel()
             getFunc = function() return LeoTrainer.data.trainNirnhoned end,
             setFunc = function(value) LeoTrainer.data.trainNirnhoned = value end,
         },
+        {
+            type = "checkbox",
+            name = "Silent mode. No message displayed on chat.",
+            default = false,
+            getFunc = function() return LeoTrainer.data.silent end,
+            setFunc = function(value) LeoTrainer.data.silent = value end,
+        },
         LeoTrainer.settings:GetLibAddonMenuAccountCheckbox(),
         {
             type = "submenu",