12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 26 ■ <strong>Creating</strong> Unit Frames with Group Templates 521Figure 26-6 shows the unit frames with a dead unit, which is much easier tosee when it’s shaded.Figure 26-6: SquareUnitFrames showing a dead unit shaded outDisplaying Unit NamesCurrently, whenever SquareUnitFrames displays a name that is longer thanfour characters (<strong>and</strong> some names that are shorter), it is truncated with anellipsis (‘‘ ... ’’) at the end. This isn’t very desirable—an ellipsis takes upmuch <strong>of</strong> the unit button’s width, space that could be better used to displaymore characters <strong>of</strong> the name—but <strong>WoW</strong> doesn’t really provide an easy wayto fit as much <strong>of</strong> a name as possible in a font string <strong>of</strong> limited width.What you can do instead is try different substrings <strong>of</strong> the name in order t<strong>of</strong>it as many characters as you can in a 30-pixel-wide font string. This algorithmmight look like this:local substring(name, length)<strong>for</strong> length=#name, 1, -1 dosubstring = string.sub(name, 1, length)button.name:SetText(substring)if button.name:GetStringWidth() print(string.len(“Grüber“))7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!