CurseForge and Overwolf are joining forces!
Awesome More Information
  • 0

    posted a message on [Text] Creating And Using Color Constants

    Objective: Define a new color constant and use it in your text entries.


    What is a color constant?


    A color constant is a constant identifier for a specific color. It is used to take one unique color and use it consistently across many different locations. If you've worked with data, you've probably seen them at least once. For example, the value ColorAttackInfo is defined as ffff8a, or the rgb value of (Red: 255, Green 255, Blue 138). This color is used across many unit descriptions to display the plane they can attack.


    How do I use a color constant?


    It's pretty easy to use a constant. Usually in your text, you might use the tags <c val="#ffff8a">Can attack ground units.</c> to use this same color. But with a constant, you can replace the hexadecimal value with the color constant name: <c val="#ColorAttackInfo">Can attack ground units.</c>. It won't usually save you a byte of map size, but it's a value that can offer some clarity toward the purpose of a piece of text being colored and if you ever decide to change the color, it'll affect every text that's using that constant.


    Get on with it, already


    Adding constants isn't extremely obvious, but this method doesn't require using a component map. To begin, open the Text Module (Default: F8). Toward the top of the screen you'll see a couple tabs, one named Text and one Font Style. Click on the Font Styles Tab and you'll be given access to a list of all the styles that can be applied to text. You can use this to make a psuedo-constant in the form of a style, but that's not why we're here. Right-click on the left pane and click Add Style. You can just click OK from there, we won't be using it. Save your map and you may close the Text module.


    Now open the Import module (Default: F9). Toward the top of that window, click the Show Reserved check box. You'll see a bunch of files that you should be careful not to mess with too much. in the Base.SC2Data folder there's the UI sub-folder. From there, click a file called FontStyles.SC2Style. You'll now see the contents of this file that, if you haven't touched it otherwise, should only contain your style. Enter a new Constant entry under your Style so the file looks like:


    <?xml version="1.0" encoding="utf-8" standalone="yes"?>


      <Style name="UnnamedFontStyle"/>

      <Constant name="ColorTest" val="0000ff"/>



    The Constant field will allow you to use the color value <c val="#ColorTest">Example Text</c> to create some example text with a  pure blue color. You may delete the line that contains your old style, unless you really want that style to be in there for some reason.


    What else?


    Since StarCraft 2 uses hexadecimal colors, it might be nice to learn a bit about them. Google them or check out their Wikipedia entry.


    Find all of the current color constants. I learned to do this by finding the original FontStyles.SC2Style file. Fortunately there's a wiki page that has a list if you don't want to look for it yourself.

    Posted in: Tutorials
  • To post a comment, please or register a new account.