Skip to content

Commit

Permalink
Fixes, added more alias usage info
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastDarkthorne committed Mar 14, 2023
1 parent e197988 commit f3a2e6f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 76 deletions.
2 changes: 1 addition & 1 deletion mfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"package": "AchaeaChatTabs",
"version": "1.2.2",
"version": "1.3",
"author": "Erikka, Demonnic",
"title": "Chat tabs for Achaea",
"outputFile": true
Expand Down
2 changes: 1 addition & 1 deletion src/aliases/AchaeaChatTabs/act.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local lecho = AchaeaChatTabs.echo
local valid_options = {"font", "fontSize", "blink", "blankLine", "timestamp", "save", "load", "show", "hide", "commandLine"}
local valid_options_string = table.concat(valid_options)
local option = matches[2]
Expand All @@ -7,7 +8,6 @@ if not table.contains(valid_options, option) then
return
end
local chatEMCO = AchaeaChatTabs.chatEMCO
local lecho = AchaeaChatTabs.echo
local EMCO = require("AchaeaChatTabs.emco")
local gaggedMobFile = getMudletHomeDir() .. "AchaeaChatGaggedMobs.lua"
if option == "save" then
Expand Down
8 changes: 8 additions & 0 deletions src/aliases/AchaeaChatTabs/act_reset.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local echo = AchaeaChatTabs.helpers.echo
if matches[2] then
AchaeaChatTabs.resetChat(true)
echo("Chat colors reset!")
else
AchaeaChatTabs.resetChat()
echo("Chat reset!")
end
3 changes: 2 additions & 1 deletion src/aliases/AchaeaChatTabs/act_usage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ local aliases = {
["act notify <tabName>"] = "turn on OS notifications for tabName. Returns list of tabs when no arguments are provided.",
["act unnotify <tabName>"] = "turn off OS notifications for tabName",
["act color <option> <value>"] = "used to change the colors for the active/inactive tab, and the background color for the consoles. 'act color' with no options will print out available options",
["act update"] = "Updates the package to latest version",
["act update"] = "updates the package to latest version",
["act reset|act reset color"] = "resets the chat to defaults/resets chat colors only"
}

echo("\nAvailable aliases for AchaeaChatTabs")
Expand Down
4 changes: 4 additions & 0 deletions src/aliases/AchaeaChatTabs/aliases.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@
{
"name": "act update",
"regex": "^act update$"
},
{
"name": "act reset",
"regex": "^act reset(?: (color))?$"
}
]
142 changes: 69 additions & 73 deletions src/scripts/AchaeaChatTabs/ChatTabs.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local EMCO = require("AchaeaChatTabs.emco")
AchaeaChatTabs = AchaeaChatTabs or {}
AchaeaChatTabs.helpers = AchaeaChatTabs.helpers or {}
AchaeaChatTabs.config = AchaeaChatTabs.config or {}
local defaultConfig = {activeColor = "black", inactiveColor = "black", activeBorder = "green", activeText = "green", inactiveText = "grey", background = "black", windowBorder = "green"}
local defaultConfig = {activeColor = "green", inactiveColor = "rgb(60,60,60)", activeBorder = "rgb(0,180,0)", activeText = "yellow", inactiveText = "white", background = "black", windowBorder = "green"}
AchaeaChatTabs.config = AchaeaChatTabs.config or defaultConfig
local default_constraints = {name = "AchaeaChatTabsContainer", x = "-25%", y = "-60%", width = "25%", height = "60%", attached = "right"}
local baseStyle = Geyser.StyleSheet:new(f [[
border-width: 2px;
Expand All @@ -22,52 +22,16 @@ local adjLabelStyle = Geyser.StyleSheet:new(f[[
border-color: {AchaeaChatTabs.config.windowBorder};
border-radius: 4px;]])


AchaeaChatTabs.emcoContainer = AchaeaChatTabs.emcoContainer or Adjustable.Container:new(default_constraints)
AchaeaChatTabs.chatEMCO = AchaeaChatTabs.chatEMCO or EMCO:new({
name = "AchaeaChat",
title = "AchaeaChat",
x = 0,
y = 0,
height = "100%",
width = "100%",
consoles = {"All", "Local", "City", "House", "Tells", "Group", "Order", "Clans", "Misc"},
allTab = true,
allTabName = "All",
blankLine = true,
blink = true,
bufferSize = 10000,
deleteLines = 500,
timestamp = true,
fontSize = 12,
font = "Ubuntu Mono",
commandLine = true,
}, AchaeaChatTabs.emcoContainer)

local chatEMCO = AchaeaChatTabs.chatEMCO
local filename = getMudletHomeDir() .. "/EMCO/AchaeaChat.lua"
local confFile = getMudletHomeDir() .. "/EMCO/AchaeaChatOptions.lua"

if io.exists(filename) then
chatEMCO:load()
end
chatEMCO:replayAll(10)
function AchaeaChatTabs.echo(msg)
msg = msg or ""
cecho(f"<green>AchaeaChatTabs: <reset>{msg}\n")
end

function AchaeaChatTabs.helpers.resetToDefaults()
default_constraints.adjLabelstyle = adjLabelStyle:getCSS()
AchaeaChatTabs.container = AchaeaChatTabs.container or Adjustable.Container:new(default_constraints)
AchaeaChatTabs.config = defaultConfig
AchaeaChatTabs.chat = EMCO:new({
name = "EMCOPrebuiltChat",
function AchaeaChatTabs.createChat()
AchaeaChatTabs.emcoContainer = AchaeaChatTabs.emcoContainer or Adjustable.Container:new(default_constraints)
AchaeaChatTabs.chatEMCO = AchaeaChatTabs.chatEMCO or EMCO:new({
name = "AchaeaChat",
title = "AchaeaChat",
x = 0,
y = 0,
height = "100%",
width = "100%",
consoles = {"All", "Local", "City", "OOC", "Tells", "Group"},
consoles = {"All", "Local", "City", "House", "Tells", "Group", "Order", "Clans", "Misc"},
allTab = true,
allTabName = "All",
blankLine = true,
Expand All @@ -81,12 +45,42 @@ function AchaeaChatTabs.helpers.resetToDefaults()
activeTabCSS = activeStyle:getCSS(),
inactiveTabCSS = inactiveStyle:getCSS(),
activeTabFGColor = AchaeaChatTabs.config.activeText,
activeTabBGColor = AchaeaChatTabs.config.activeColor,
inactiveTabFGColor = AchaeaChatTabs.config.inactiveText,
gap = 3,
commandLine = true,
}, AchaeaChatTabs.container)
chatEMCO = AchaeaChatTabs.chat
AchaeaChatTabs.helpers.retheme()
commandLine = false,
}, AchaeaChatTabs.emcoContainer)
end
AchaeaChatTabs.createChat()

function AchaeaChatTabs.resetChat(onlycolors)
if onlycolors == true then
AchaeaChatTabs.config = defaultConfig
AchaeaChatTabs.helpers.retheme()
else
AchaeaChatTabs.chatEMCO = nil
AchaeaChatTabs.emcoContainer = Adjustable.Container:new(default_constraints)
AchaeaChatTabs.config = defaultConfig
AchaeaChatTabs.createChat()
AchaeaChatTabs.helpers.retheme()

end
end

local chatEMCO = AchaeaChatTabs.chatEMCO
local filename = getMudletHomeDir() .. "/EMCO/AchaeaChat.lua"
local confFile = getMudletHomeDir() .. "/EMCO/AchaeaChatOptions.lua"

if io.exists(filename) then
chatEMCO:load()
end
if io.exists(confFile) then
AchaeaChatTabs.emcoContainer:load()
end

chatEMCO:replayAll(10)
function AchaeaChatTabs.echo(msg)
msg = msg or ""
cecho(f"<green>AchaeaChatTabs: <reset>{msg}\n")
end

function AchaeaChatTabs.helpers.retheme()
Expand All @@ -96,14 +90,17 @@ function AchaeaChatTabs.helpers.retheme()
inactiveStyle:set("border-color", AchaeaChatTabs.config.inactiveColor)
adjLabelStyle:set("border-color", AchaeaChatTabs.config.windowBorder)
local als = adjLabelStyle:getCSS()
AchaeaChatTabs.container.adjLabelstyle = als
AchaeaChatTabs.container.adjLabel:setStyleSheet(als)
AchaeaChatTabs.emcoContainer.adjLabelstyle = als
AchaeaChatTabs.emcoContainer.adjLabel:setStyleSheet(als)
chatEMCO.activeTabCSS = activeStyle:getCSS()
chatEMCO.inactiveTabCSS = inactiveStyle:getCSS()
chatEMCO:setActiveTabFGColor(AchaeaChatTabs.config.activeText)
chatEMCO:setInactiveTabFGColor(AchaeaChatTabs.config.inactiveText)
chatEMCO:setConsoleColor(AchaeaChatTabs.config.background)
chatEMCO:adjustTabBackgrounds()
chatEMCO:switchTab(chatEMCO.currentTab)
--AchaeaChatTabs.chatEMCO = nil
--AchaeaChatTabs.createChat()
end

function AchaeaChatTabs.helpers.setConfig(cfg, val)
Expand All @@ -118,28 +115,7 @@ end

function AchaeaChatTabs.helpers.echo(msg)
msg = msg or ""
cecho(f "<green>EMCO Chat: <reset>{msg}\n")
end

function AchaeaChatTabs.helpers.save()
chatEMCO:save()
table.save(confFile, AchaeaChatTabs.config)
AchaeaChatTabs.container:save()
end

function AchaeaChatTabs.helpers.load()
if io.exists(confFile) then
local conf = {}
table.load(confFile, conf)
AchaeaChatTabs.config = table.update(AchaeaChatTabs.config, conf)
end
if io.exists(filename) then
chatEMCO:hide()
chatEMCO:load()
chatEMCO:show()
end
AchaeaChatTabs.container:load()
AchaeaChatTabs.helpers.retheme()
cecho(f "<green>AchaeaChatTabs: <reset>{msg}\n")
end

AchaeaChatTabs.gaggedMobs = {}
Expand All @@ -163,11 +139,27 @@ function AchaeaChatTabs.load()
if io.exists(filename) then
chatEMCO:load()
end
if io.exists(confFile) then
local conf = {}
table.load(confFile, conf)
AchaeaChatTabs.config = table.update(AchaeaChatTabs.config, conf)
end
--[[
if io.exists(filename) then
chatEMCO:hide()
chatEMCO:load()
chatEMCO:show()
end
]]
AchaeaChatTabs.emcoContainer:load()
--AchaeaChatTabs.helpers.retheme()
end

function AchaeaChatTabs.save()
chatEMCO:save()
AchaeaChatTabs.saveGaggedMobs()
table.save(confFile, AchaeaChatTabs.config)
AchaeaChatTabs.emcoContainer:save()
end

local channelToTab = {
Expand Down Expand Up @@ -255,3 +247,7 @@ end
if not AchaeaChatTabs.loginHandler then
AchaeaChatTabs.loginHandler = registerAnonymousEventHandler("gmcp.Char.Name", startGMCPChat)
end

if not AchaeaChatTabs.loadHandler then
AchaeaChatTabs.loadHandler = registerAnonymousEventHandler("sysLoadEvent", AchaeaChatTabs.load)
end

0 comments on commit f3a2e6f

Please sign in to comment.