diff --git a/candybot.otui b/candybot.otui index e576cee..c35f1b8 100644 --- a/candybot.otui +++ b/candybot.otui @@ -202,12 +202,37 @@ MainWindow margin-bottom: -5 @onClick: CandyBot.hide() + ComboBox + id: loggerType + !tooltip: tr('Log level determining what log messages will be shown. This will show messages') + anchors.left: parent.left + anchors.bottom: parent.bottom + margin-bottom: -10 + margin-left: -7 + options: + -Info + -Warning + -Error + -Debug + @onOptionChange: | + local option = self:getCurrentOption() + if option.text == "Info" then + BotLogger.logType = BotLogTypes.info + elseif option.text == "Warning" then + BotLogger.logType = BotLogTypes.warning + elseif option.text == "Error" then + BotLogger.logType = BotLogTypes.error + elseif option.text == Debug then + BotLogger.logType = BotLogTypes.debug + end + Label id: versionInfo !text: tr('') - anchors.left: parent.left + anchors.left: loggerType.right anchors.bottom: parent.bottom margin-bottom: -5 + margin-left: 5 color: #ffffff44 text-auto-resize: true diff --git a/logger.lua b/logger.lua index 87ea4c5..e071ac3 100644 --- a/logger.lua +++ b/logger.lua @@ -7,10 +7,12 @@ BotLogger = {} BotLogTypes = { - warning = 1, - error = 2, - debug = 3 + info = 1, + warning = 2, + error = 3, + debug = 4 } +BotLogger.logType = BotLogTypes.info local MAX_LINES = 35 @@ -22,6 +24,10 @@ function BotLogger.init() logBuffer = logWindow:getChildById('logBuffer') end +function BotLogger.info(msg) + BotLogger.print(BotLogTypes.info, msg) +end + function BotLogger.warning(msg) BotLogger.print(BotLogTypes.warning, msg) end @@ -38,15 +44,29 @@ function BotLogger.print(type, msg) local trace = debug.getinfo(debug.getinfo(3, "f").func) local path = BotLogger.trimPath(trace.short_src:explode("/")) - if type == BotLogTypes.warning then - --g_logger.warning(msg) - BotLogger.createLabel(msg, "yellow") - elseif type == BotLogTypes.error then - --g_logger.error(msg) - BotLogger.createLabel(msg, "red") - elseif type == BotLogTypes.debug then - --g_logger.debug(msg) - BotLogger.createLabel(msg, "white") + if BotLogger.logType then + + if type == BotLogTypes.info then + if BotLogger.logType >= BotLogTypes.info then + --g_logger.info(msg) + BotLogger.createLabel(msg, "white") + end + elseif type == BotLogTypes.warning then + if BotLogger.logType >= BotLogTypes.warning then + --g_logger.warning(msg) + BotLogger.createLabel(msg, "yellow") + end + elseif type == BotLogTypes.error then + if BotLogger.logType >= BotLogTypes.error then + --g_logger.error(msg) + BotLogger.createLabel(msg, "red") + end + elseif type == BotLogTypes.debug then + if BotLogger.logType >= BotLogTypes.debug then + --g_logger.debug(msg) + BotLogger.createLabel(msg, "green") + end + end end end diff --git a/modules/00-bot/events/disablebot.lua b/modules/00-bot/events/disablebot.lua index 983d857..80ff9f6 100644 --- a/modules/00-bot/events/disablebot.lua +++ b/modules/00-bot/events/disablebot.lua @@ -13,5 +13,5 @@ function Disable.Event(event) botIcon:setTooltip("Disabled") CandyBot.enable(false) - BotLogger.warning("Bot disabled.") + BotLogger.info("Bot disabled.") end \ No newline at end of file diff --git a/modules/00-bot/events/enablebot.lua b/modules/00-bot/events/enablebot.lua index 16fa73c..7d37c63 100644 --- a/modules/00-bot/events/enablebot.lua +++ b/modules/00-bot/events/enablebot.lua @@ -16,9 +16,9 @@ function Enable.Event(event) EventHandler.signal() -- signal events to start ListenerHandler.signal() -- signal listeners to start - BotLogger.warning("Bot enabled.") + BotLogger.info("Bot enabled.") if g_game.isOfficialTibia() then - BotLogger.warning("Note: Bags must be open for certain bot features.") + BotLogger.info("Note: Bags must be open for certain bot features.") end end \ No newline at end of file diff --git a/modules/01-afk/afk.otui b/modules/01-afk/afk.otui index 2cfe615..4519259 100644 --- a/modules/01-afk/afk.otui +++ b/modules/01-afk/afk.otui @@ -120,7 +120,7 @@ Panel BotOptionCheckBox id: AutoReplaceWeapon !text: tr('Auto Replace Weapons') - !tooltip: tr('Automatically "refill" used throwing weapons (container of replacing items must be open).') + !tooltip: tr('Automatically "refill" used throwing weapons\n(container of replacing items must be open).') anchors.left: parent.left anchors.top: prev.top margin-top: 10 diff --git a/modules/04-targets/targets.lua b/modules/04-targets/targets.lua index e615fb3..971f83e 100644 --- a/modules/04-targets/targets.lua +++ b/modules/04-targets/targets.lua @@ -161,7 +161,7 @@ function TargetsModule.bindHandlers() TargetsModule.setCurrentSetting(selectedTarget:getSetting(1)) end else - currentSetting = false + currentSetting = nil TargetsModule.syncSetting() end end