WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   Dungeon Difficulty / Minimap (https://www.wowinterface.com/forums/showthread.php?t=46622)

Tonyleila 06-05-13 02:43 PM

Dungeon Difficulty / Minimap
 
I can't find an addon or data broker to display the Dungeon Difficulty. I use chinchilla minimap for years now and this is one of the things I don't like about it is the ugly blizzard display for it. I used V Difficulty (LDB) for some time now but its not up to date any more and I don't realy like that its always on. I only want to see it if I'm in a dungeon or raid and then I only want to see the Difficulty for this Dungeon/raid. So just show one of this: 10N, 10H, 25N, 25H, 5N, 5H, 5C

Anyone knows an alternative addon?

Phanx 06-05-13 03:52 PM

Here's the code I use for a simplified text-only difficulty display in my private minimap addon:
Code:

MiniMapInstanceDifficulty:SetParent(Minimap)
MiniMapInstanceDifficulty:ClearAllPoints()
MiniMapInstanceDifficulty:SetPoint("TOPRIGHT", -2, 20)

MiniMapInstanceDifficultyText:ClearAllPoints()
MiniMapInstanceDifficultyText:SetPoint("RIGHT", 0, -9)
MiniMapInstanceDifficultyText:SetFontObject(TextStatusBarText)

MiniMapInstanceDifficultyTexture:Hide()

GuildInstanceDifficulty:Hide()

MiniMapInstanceDifficulty:HookScript("OnEvent", function(self, event, isGuildGroup)
        if event == "GUILD_PARTY_STATE_UPDATED" then
                self.__isGuildGroup = isGuildGroup
        end
end)

function MiniMapInstanceDifficulty_Update()
        local instanceName, instanceType, difficulty, _, maxPlayers, playerDifficulty, isDynamicInstance = GetInstanceInfo()
        local _, _, isHeroic, isChallengeMode = GetDifficultyInfo(difficulty)

        if MiniMapInstanceDifficulty.__isGuildGroup then
                instanceType = "GUILD"
        end

        local color = ChatTypeInfo[strupper(instanceType)]

        if color and maxPlayers > 0 then
                MiniMapInstanceDifficultyText:SetFormattedText("%d%s", maxPlayers, isChallengeMode and "++" or isHeroic and "+" or "")
                MiniMapInstanceDifficultyText:SetTextColor(color.r, color.g, color.b)
                MiniMapInstanceDifficulty:Show()
        else
                MiniMapInstanceDifficulty:Hide()
        end
end

local difficultyText = {
        DUNGEON_DIFFICULTY1,
        DUNGEON_DIFFICULTY2,
        RAID_DIFFICULTY1,
        RAID_DIFFICULTY2,
        RAID_DIFFICULTY3,
        RAID_DIFFICULTY4,
        UNKNOWN,
        CHALLENGE_MODE,
}

MiniMapInstanceDifficulty:EnableMouse(true)
MiniMapInstanceDifficulty:SetScript("OnEnter", function(self)
        local instanceName, instanceType, difficulty, difficultyText, maxPlayers, playerDifficulty, isDynamicInstance = GetInstanceInfo()

        GameTooltip:SetOwner(self, "ANCHOR_NONE")
        GameTooltip:SetPoint("TOPRIGHT", self, "LEFT")

        GameTooltip:AddLine(instanceName, 1, 0.82, 0)
        GameTooltip:AddLine(difficultyText, 1, 1, 1)
        GameTooltip:AddLine(difficultyText[difficulty] or UNKNOWN, 1, 1, 1)

        if self.__isGuildGroup then
                GameTooltip:AddLine(GUILD, 1, 1, 1)
        end

        GameTooltip:Show()
end)
MiniMapInstanceDifficulty:SetScript("OnLeave", GameTooltip_Hide)

Drycoded Broker conversion:
Code:

local DEFAULT_TEXT = ""

local isGuildGroup

local b = LibStub("LibDataBroker-1.1"):NewDataObject("InstanceDifficulty", {
        type = "data source",
        text = DEFAULT_TEXT,
        OnTooltipShow = function(GameTooltip)
                local instanceName, instanceType, difficultyID, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance = GetInstanceInfo()
                local difficultyText = GetDifficultyInfo(difficultyID)

                GameTooltip:AddLine(instanceName, 1, 0.82, 0)
                GameTooltip:AddLine(difficultyText, 1, 1, 1)

                if isGuildGroup then
                        GameTooltip:AddLine(GUILD, 1, 1, 1)
                end

                GameTooltip:Show()
        end,
})

local f = CreateFrame("Frame")
f:RegisterEvent("GROUP_ROSTER_UPDATE")
f:RegisterEvent("GUILD_PARTY_STATE_UPDATED")
f:RegisterEvent("PARTY_MEMBER_DISABLE")
f:RegisterEvent("PARTY_MEMBER_ENABLE")
f:RegisterEvent("PLAYER_DIFFICULTY_CHANGED")
f:RegisterEvent("PLAYER_GUILD_UPDATE")
f:RegisterEvent("UPDATE_INSTANCE_INFO")
f:SetScript("OnEvent", function(self, event, ...)
        if event == "GUILD_PARTY_STATE_UPDATED" then
                isGuildGroup = ...
        elseif event ~= "UPDATE_INSTANCE_INFO" then
                RequestGuildPartyState()
        end

        local instanceName, instanceType, difficulty, _, maxPlayers, playerDifficulty, isDynamicInstance = GetInstanceInfo()
        local _, _, isHeroic, isChallengeMode = GetDifficultyInfo(difficulty)

        if isGuildGroup then
                instanceType = "GUILD"
        end

        local color = ChatTypeInfo[strupper(instanceType)]

        if color and maxPlayers > 0 then
                b.text = format("|cff%02x%02x%02x%s%d", color.r * 255, color.g * 255, color.b * 255, isChallengeMode and "++" or isHeroic and "+" or "", maxPlayers)
        else
                b.text = DEFAULT_TEXT
        end
end)


Tonyleila 06-05-13 04:43 PM

Thank you Phanx! I use the broker one right now but for some reason the text is showing up in black.

Phanx 06-05-13 05:07 PM

Fixed. Forgot to multiply the RGB values by 255 before formatting as hex values.

Tonyleila 06-05-13 06:13 PM

Quote:

Originally Posted by Phanx (Post 279249)
Fixed. Forgot to multiply the RGB values by 255 before formatting as hex values.

Yep that fixed it. Only the name "InstanceDifficulty" is still black (but thats not a big deal since I only use that to move it in the broker display around.


Don't you want to upload that market gap fixing addon? Its simply perfect :banana:

Folder:
Broker_InstanceDifficulty

Code from above:
Broker_InstanceDifficulty.lua

Broker_InstanceDifficulty.toc
Code:

## Interface: 50300
## Title: Broker InstanceDifficulty
## Version: 1.0
## Author: Phanx
## Notes: Displays Instance Difficulty when in an Instance

Broker_InstanceDifficulty.lua


Phanx 06-05-13 07:18 PM

Quote:

Originally Posted by Tonyleila (Post 279256)
Only the name "InstanceDifficulty" is still black ...

Where are you seeing that? There's nothing in the code I posted that should show that phrase as text anywhere. The only instance of that phrase in my code was the internal identifier of the plugin as registered with LibDataBroker. If your display addon is showing internal plugin identifiers, there's nothing I can do in the plugin code to control that.

The only text that should be displayed on the plugin is something like "52" for a normal 25-man, "10+" for a heroic 10-man, or "5++" for a challenge mode dungeon.

(The numbers and plusses were reversed for my right-aligned minimap; I've edited my previous code to show them in standard order on the Broker plugin.)

Tonyleila 06-05-13 09:44 PM

As far as I know broker addons always have a label and a text to display.
I think Bazooka is best addon for Broker plugins. It has an option to display the titel of the broker - for plugins like this one where you normaly woud need to go into an instace to move it around. Also its possible to stripe colors to make all text white (but not your black one only the other one).However as I said I only use this name to move it around so don't care if its black.
For myself I changed the + and ++ to C H and N


Edit: and I'm not able to test it now but will it hide in raidfinder?

p3lim 06-05-13 10:03 PM

Turn off the title.

Tonyleila 06-05-13 10:21 PM

Quote:

Originally Posted by p3lim (Post 279267)
Turn off the title.

Mahh I know I just turned the titel on to move it around outside the instance and then I turned it off again. And for the screenshot I just turned it on to show Phanx that its black :D

Seerah 06-06-13 12:23 PM

It might be up to Bazooka to configure the color of the title.

Phanx 06-06-13 04:25 PM

I also use Bazooka. Check the general options and change the Label Color to something other than black.

Also, you don't need to turn on the label to move the plugin. You can click and drag anywhere on the plugin, including on the text. If you want to see text when you're not in a group, change the DEFAULT_TEXT value at the top of the file to "Solo" or something.


All times are GMT -6. The time now is 09:32 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI