Thread Tools Display Modes
Unread 07-08-09, 12:57 AM   #1
Xrystal
nUI User and Supporter
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,028
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

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

Last edited by Xrystal : 07-08-09 at 08:48 AM.
Xrystal is offline  
Unread 07-08-09, 04:44 AM   #2
spiel2001
nUI's Author
 
spiel2001's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 7,724
~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.
__________________

What people don't get is that I am, ultimately, an artist at heart.
My brush has two colors, 1 and 0, and my canvas is made of silicon.



Official nUI Web Site: http://www.nUIaddon.com
Official nUI Support Forum: http://forums.nUIaddon.com
My day job: http://www.presidio.com/
spiel2001 is offline  
Unread 07-08-09, 11:20 AM   #3
Xrystal
nUI User and Supporter
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,028
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

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.
__________________

Last edited by Xrystal : 07-08-09 at 11:43 AM.
Xrystal is offline  
Unread 07-08-09, 11:40 AM   #4
spiel2001
nUI's Author
 
spiel2001's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 7,724
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.
__________________

What people don't get is that I am, ultimately, an artist at heart.
My brush has two colors, 1 and 0, and my canvas is made of silicon.



Official nUI Web Site: http://www.nUIaddon.com
Official nUI Support Forum: http://forums.nUIaddon.com
My day job: http://www.presidio.com/
spiel2001 is offline  
Unread 07-08-09, 11:55 AM   #5
Xrystal
nUI User and Supporter
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,028
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:
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_070809_185656.jpg
Views:	693
Size:	423.9 KB
ID:	3025  
__________________

Last edited by Xrystal : 07-08-09 at 12:17 PM.
Xrystal is offline  
 

Go BackWoWInterface » Featured Projects » nUI, MozzFullWorldMap and PartySpotter » Customization » nUI: Developer Chat » Slash Commands and localisations

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off