WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   nUI: Developer Chat (https://www.wowinterface.com/forums/forumdisplay.php?f=96)
-   -   Slash Commands and localisations (https://www.wowinterface.com/forums/showthread.php?t=25277)

Xrystal 07-08-09 12:57 AM

Slash Commands and localisations
 
Scott, just a quick question when you get a moment.

Whilst working on updating my LDB addon for nUIs new Release update I noticed that the settings seem to be localised in files but actually in English. Is that supposed to be the case ?

An example from the zhTW localisation file.

Code:

        nUI_L[nUI_SLASHCMD_OPTIONS( nUI_SLASHCMD_FEEDBACK, "curse" )]    = "curse";
        nUI_L[nUI_SLASHCMD_OPTIONS( nUI_SLASHCMD_FEEDBACK, "disease" )]  = "disease";
        nUI_L[nUI_SLASHCMD_OPTIONS( nUI_SLASHCMD_FEEDBACK, "magic" )]    = "magic";
        nUI_L[nUI_SLASHCMD_OPTIONS( nUI_SLASHCMD_FEEDBACK, "poison" )]  = "poison";

I take it instead of using "curse" I should use nUI_L[nUI_SLASHCMD_OPTIONS( nUI_SLASHCMD_FEEDBACK, "curse" )] so that if at a later date it becomes localised the addon will reflect that.

Thought I had better ask that question before I start localising all the text if most of that stuff is in nUI by default.

Edit: Rofl, no matter, just noticed whilst looking at the old code I had already used your localised versions already :D

Edit2: Edited due to me being too tired and wrote answer instead of ask .. rofl.

spiel2001 07-08-09 04:44 AM

~lol~

But you are correct. The "right" value to use is "
nUI_L[nUI_SLASHCMD_OPTIONS( nUI_SLASHCMD_FEEDBACK, "curse" )]" and not just "curse" so that if someone decides to localize the slash commands for their language, they will still work correctly.

Xrystal 07-08-09 11:20 AM

To save starting a new thread regarding something else to do with the slash commands I thought I would post it here.

I noticed that when you toggle the display of the cooldowns on the buttons if the timing is more than a minute it doesn't update the display straight away when you turn it on. If its less than a minute it works fine. And when you turn it off it is immediate.

Example:
Button Cooldowns = true
Arcane Torrent 2 min Countdown clicked
Button shows Cooldown
Turn off cooldowns and cooldown disappears
Cooldown now at over 1 min but less than 2 min
Turn on cooldowns and cooldown doesn't appear
40 seconds later .... still no cooldown
Cooldown now at 60s
Cooldown appears.

Also, is the Toggle Durations supposed to toggle the Cooldowns too ? As it seems to be doing that too until the next update pass which from the note above is as much as 2 mins :D

Oh and finally ( I hope ). I noticed the dimming alpha isn't quite right.


if not alpha or alpha <= 0 or alpha > 1 then

It looks like it is failing the first test as if I remember right it treats nil and 0 as false. Only a problem for those that want to fully transparent the button.

spiel2001 07-08-09 11:40 AM

That's probably a bug in the logic.

Most of nUI's modules try to avoid unnecessary screen updates (which are relatively expensive) by caching their states and performing a relatively inexpensive test to see if the state changed before doing anything that would cause a screen update.

In the case of cooldowns, when the text that is to be displayed on the button changes, I call "SetText()" to update the button face, then set button.text = newValue; -- as long as the text remains the same as what "button.text" says it is displaying, I don't update the button face.

My guess (I'm at work, so I can't look at the code, but you can confirm this pretty quickly) is that when the display feature is turned off via the slash command, I am setting the text to "" by calling SetText( "" ) but I am not updating the cached value. So, when you turn the cooldown back on, it doesn't realize the button text is empty and so it doesn't set the cooldown text again until it changes from the last stored value.

Follow that? Take a look at [ nUI > Bars > nUI_Button.lua ] and look for either layer.cooldown:SetText() or cdc:SetText() and you should see where I am testing if the text changed and probably also testing to see if the feature is turned off via slash command.

Xrystal 07-08-09 11:55 AM

1 Attachment(s)
It calls this function in ButtonBar.lua whenever the slash command is executed:

Code:

function nUI_ButtonBars:setUserBarOptions( bar )

        for i=1,#bar.Buttons do
                for j=1,#bar.Buttons[i] do
               
                        local overlay = nUI_ButtonMap[bar.Buttons[i][j]];
       
                        overlay.layers.count:SetAlpha( nUI_Options.barStackCounts and 1 or 0 );
                        overlay.layers.name:SetAlpha( nUI_Options.barMacroNames and 1 or 0 );
                        overlay.layers.hotkey:SetAlpha( nUI_Options.barKeyBindings and 1 or 0 );

                        if not nUI_Options.barCooldowns or not nUI_Options.barDurations then
                                overlay.layers.cdc.value = nil;
                                overlay.layers.cdc:SetText( "" );
                        end                                                               
                end
        end
end

So it looks like it only turns it off automatically. As to the settings in Button.lua it looks like it validates value with text and updates if it is different and flagged for display.

Changing the relative section in the function above to the following solves the problem but I am not sure how it will affect the rest of the overlay system.

Code:

                        if not nUI_Options.barCooldowns or not nUI_Options.barDurations then
                                overlay.layers.cdc:Hide();
                        else
                                overlay.layers.cdc:Show();
                        end

In fact it could be changed to set the alpha value like the other options are dealth with. That seems to work fine too.

But, it doesn't seem to solve the following problem :

Arcane Torrent has a brief duration timer which is stuck at 0.0 until the cooldown timer updates again. Here's a picture to show you:


All times are GMT -6. The time now is 05:33 PM.

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