Alt-Tab Toggle

Creating a new alert module

Here's a basic framework that's needed to make a new alert module.

local folder, core = ...
local Summon = core:NewModule("Summon", "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale(folder, true)

local LSM = LibStub("LibSharedMedia-3.0", true)
if not LSM then	return end

Summon.name = L["Summon"] --Name that shows up in the submenu list.
Summon.desc = L["Summon requests"] --Description that shows up on the options page.

function Summon:OnInitialize()
	self.db = core.db:RegisterNamespace("Summon", {
		profile = {
			enabled = true, --module is enabled by default.
			sound = "ATT alert", --default sound to use.
		},
	})
	

	if not self.db.profile.enabled then
		--Disable the module if the option is disabled.
		self:SetEnabledState(false)
	end
end


function Summon:OnEnable()
	--Register the trigger event that you're watcing for.
	self:RegisterEvent("CONFIRM_SUMMON")
end

function Summon:CONFIRM_SUMMON(event, ...)
	--Our trigger event has fired, now call ATT's ToggleGame function in the core.lua file.
	core:ToggleGame(self.name, LSM:Fetch('sound', self.db.profile.sound) )
end

function Summon:GetOptions()
	--The options table that's displayed in the sub menu. 
	--This simply shows the enable option and the sound drop down menu.
	return {
		name = self.name,
		type = "group",
		get = function(info)
			local key = info[#info]
			return self.db.profile[key]
		end,
		set = function(info, v)
			local key = info[#info]
			self.db.profile[key] = v
		end,
		args = {
			Desc = {
				type = "description",
				name = self.desc,
				order = 1,
			},
			enabled = {
				type = "toggle",	order	= 10,
				name	= ENABLE,
				desc	= L["Enables / Disables the module."],
				set = function(info, v)
					self.db.profile.enabled = v 
					if v == true then
						self:Enable()
					else
						self:Disable()
					end
				end,
				
			},
			sound = {
				type = 'select',	 order	= 11,
				dialogControl = 'LSM30_Sound', --Select your widget here
				values = LSM:HashTable('sound'), -- pull in your font list from LSM
				name = L["Sound"],
				desc = L["Sound to play"],
			},
		}
	}
end

Let me know if you have a module to add. I'll add you as a maintainer so you can commit to the repository.

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Nov 15, 2010

Author