WoWInterface SVN gError

[/] [gError.lua] - Rev 2

Compare with Previous | Blame | View Log

--[[
        gError
        Author: Lars Norberg
        
        License:
                This program is free software; you can redistribute it and/or
                modify it under the terms of the GNU General Public License
                as published by the Free Software Foundation; either version 2
                of the License, or (at your option) any later version.

                This program is distributed in the hope that it will be useful,
                but WITHOUT ANY WARRANTY; without even the implied warranty of
                MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                GNU General Public License for more details.

                You should have received a copy of the GNU General Public License
                along with this program(see GPL.txt); if not, write to the Free Software
                Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

        Note:
                This AddOn's source code is specifically designed to work with
                World of Warcraft's interpreted AddOn system.
                You have an implicit licence to use this AddOn with these facilities
                since that is its designated purpose as per:
                http://www.fsf.org/licensing/licenses/gpl-faq.html#InterpreterIncompat
]]--

gError = CreateFrame( "Frame", nil, UIParent );

gError:SetScript( "OnEvent", function( self, event, ... ) self[event]( self, ... ); end);

gError:RegisterEvent( "ADDON_LOADED" );
gError:RegisterEvent( "UI_ERROR_MESSAGE" );

UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE");

local UIERRORSFRAME_WHITELIST

function gError:ADDON_LOADED()
        if not( arg1 == "gError" ) then return end
        self:UnregisterEvent("ADDON_LOADED");
        
        -- set a whitelist 
        -- using constants to avoid localization issues
        -- http://www.wowwiki.com/WoW_Constants/Errors
        UIERRORSFRAME_WHITELIST = {
                [ ERR_BAG_FULL ] = true,                                                        -- That bag is full.
                [ ERR_BAG_IN_BAG ] = true,                                                      -- Can't put non-empty bags in other bags. 
                [ ERR_BANK_FULL ] = true,                                                       -- Your bank is full 
                [ ERR_FISH_ESCAPED ] = true,                                            -- Your fish got away! 
                [ ERR_INV_FULL ] = true,                                                        -- Inventory is full. 
                [ ERR_ITEM_CANT_BE_DESTROYED ] = true,                          -- That item cannot be destroyed. 
                [ ERR_ITEM_MAX_COUNT ] = true,                                          -- You can't carry any more of those items.
                [ ERR_LOGOUT_FAILED ] = true,                                           -- You can't logout now. 
                [ ERR_LOOT_WHILE_INVULNERABLE ] = true,                         -- Cannot loot while invulnerable. 
                [ ERR_MOUNT_LOOTING ] = true,                                           -- You can't mount while looting! 
                [ ERR_MOUNT_SHAPESHIFTED ] = true,                                      -- You can't mount while shapeshifted! 
                [ ERR_MOUNT_TOOFARAWAY ] = true,                                        -- That mount is too far away!  
                [ ERR_MUST_EQUIP_ITEM ] = true,                                         -- You must equip that item to use it.  
                [ ERR_MUST_REPAIR_DURABILITY ] = true,                          -- You must repair that item's durability to use it. 
                [ ERR_NO_SLOT_AVAILABLE ] = true,                                       -- No equipment slot is available for that item. 
                [ ERR_NOT_ENOUGH_MONEY ] = true,                                        -- You don't have enough money. 
                [ ERR_NOT_EQUIPPABLE ] = true,                                          -- This item cannot be equipped. 
                [ ERR_NOT_IN_COMBAT ] = true,                                           -- You can't do that while in combat 
                [ ERR_NOT_WHILE_SHAPESHIFTED ] = true,                          -- You can't do that while shapeshifted.  
                [ ERR_PASSIVE_ABILITY ] = true,                                         -- You can't put a passive ability in the action bar. 
                [ ERR_PET_SPELL_DEAD ] = true,                                          -- Your pet is dead. 
                [ ERR_QUEST_LOG_FULL ] = true,                                          -- Your quest log is full.  
                [ ERR_TAXINOPATHS ] = true,                                             -- You don't know any flight locations connected to this one. 
                [ ERR_TAXINOSUCHPATH ] = true,                                          -- There is no direct path to that destination! 
                [ ERR_TAXINOTENOUGHMONEY ] = true,                                      -- You don't have enough money! 
                [ ERR_TAXIPLAYERALREADYMOUNTED ] = true,                        -- You are already mounted! Dismount first. 
                [ ERR_TAXIPLAYERBUSY ] = true,                                          -- You are busy and can't use the taxi service now. 
                [ ERR_TAXIPLAYERMOVING ] = true,                                        -- You are moving. 
                [ ERR_TAXIPLAYERSHAPESHIFTED ] = true,                          -- You can't take a taxi while disguised! 
                [ ERR_TAXISAMENODE ] = true,                                            -- You are already there! 
                [ ERR_TOOBUSYTOFOLLOW ] = true,                                         -- You're too busy to follow anything! 
                [ ERR_TRADE_BAG_FULL ] = true,                                          -- Trade failed, you don't have enough space. 
                [ ERR_TRADE_MAX_COUNT_EXCEEDED ] = true,                        -- You have too many of a unique item. 
                [ ERR_TRADE_TARGET_MAX_COUNT_EXCEEDED ] = true,         -- Your trade partner has too many of a unique item. 
                [ ERR_TRADE_QUEST_ITEM ] = true,                                        -- You can't trade a quest item.  
                [ SPELL_FAILED_NO_MOUNTS_ALLOWED ] = true,                      -- You can't mount here.
                [ SPELL_FAILED_ONLY_BATTLEGROUNDS ] = true,             -- Can only use in battlegrounds
        }
end

function gError:UI_ERROR_MESSAGE( self, ... )
        if not arg1 then return end
        if UIERRORSFRAME_WHITELIST[arg1] then
                UIErrorsFrame:AddMessage( arg1, 1.0, 0.1, 0.1, 1.0 );
        end
end

Compare with Previous | Blame