About Store Forum Documentation Contact



Post Reply 
List.setElmTextColor weirdness
Author Message
phleshdef Offline
Member

Post: #1
List.setElmTextColor weirdness
I'm experiencing a really strange phenomena. I'm attempting to stylize my list/grid for an inventory GUI I'm building. Styling the columns and everything else in this window is working out just fine. But something very strange is happening with my attempt to set the text color of the text in the List's rows. It seems, for one, to ignore my color specification altogether. But it also seems to render the text a different color everytime I hide/show my Inventory window. I have it rigged up, naturally, to hide and show when hitting the "I" key. I'll show it, the text will be pink, I'll hide it, then show it, and the text is purple, I'll hide it, then show it, and the text is black. And it only seems to affect the text in the rows. The column text styles properly, and the background color behind the rows and all the other styles I'm setting within this window seem to be doing what they are suppose to.

My code goes something like this:

Code:
struct GUIStyles
{
    GUIStyles();

    GuiStyle MenuWindowStyle;
    Color MenuWindowColor;

    Color MenuTextColor;
    Color MenuBackColor;

    void InitStyles();

} extern GlobalGUIStyles;


void GUIStyles::InitStyles()
{
    MenuWindowColor = Color(31, 31, 31, 100);
    MenuWindowStyle.back_color = MenuWindowColor;

    MenuTextColor = WHITE;
    MenuBackColor = BLACK;
}


void InventoryWindow::Show()
{    
    if (!IsShowing)
    {
        ListColumn list_column[] =
        {
           ListColumn(MEMBER(LysianItem, name), 0.3f, L"Name"),
           ListColumn(MEMBER(LysianItem, damage), 0.3f, L"Damage"),
           ListColumn(MEMBER(LysianItem, value), 0.3f, L"Value")
        };

        region += invItems.create(list_column, Elms(list_column)).setData(Players[0].inventory.items);    
        
        GlobalGUIStyles.InitStyles();
        
        invItems.setElmTextColor(MEMBER(GUIStyles, MenuTextColor));
        invItems.back_color = GlobalGUIStyles.MenuBackColor;

        for(int colIndex = 0; colIndex < invItems.columns(); colIndex++)
        {
            invItems.column(colIndex).button.color = GlobalGUIStyles.MenuBackColor;
            invItems.column(colIndex).button.tds->color = GlobalGUIStyles.MenuTextColor;
        }

        Ms.visible(true);
        window.show();
        IsShowing = true;
    }
}

Do I need to maybe make MenuTextColor a static member of GUIStyles?

As always, any guidance on this is greatly appreciated.
09-23-2012 09:09 PM
Find all posts by this user Quote this message in a reply
phleshdef Offline
Member

Post: #2
RE: List.setElmTextColor weirdness
I recently tried a variation on the above code by using a TextDS object and setting the Lists tds property. It made the text color correct, but the letters were all screwed up, as if they were all on top of one another, forming one, single illegible letter. Is there no one else thats gotten this to work?
09-26-2012 01:48 AM
Find all posts by this user Quote this message in a reply
phleshdef Offline
Member

Post: #3
RE: List.setElmTextColor weirdness
To clarify on my last post, I've changed the code to do this:

Code:
void GUIStyles::InitStyles()
{
    MenuWindowColor = Color(31, 31, 31, 100);
    MenuWindowStyle.back_color = MenuWindowColor;

    MenuTextColor = WHITE;
    MenuBackColor = BLACK;

    GridTextDS.color = WHITE;
}

void InventoryWindow::Show()
{    
    if (!IsShowing)
    {
        ListColumn list_column[] =
        {
           ListColumn(MEMBER(LysianItem, name), 0.3f, L"Name"),
           ListColumn(MEMBER(LysianItem, damage), 0.3f, L"Damage"),
           ListColumn(MEMBER(LysianItem, value), 0.3f, L"Value")
        };

        region += invItems.create(list_column, Elms(list_column)).setData(Players[0].inventory.items);    
        
        GlobalGUIStyles.InitStyles();
        
        invItems.back_color = GlobalGUIStyles.MenuBackColor;

        for(int colIndex = 0; colIndex < invItems.columns(); colIndex++)
        {
            invItems.column(colIndex).button.color = GlobalGUIStyles.MenuBackColor;
            invItems.column(colIndex).button.tds->color = GlobalGUIStyles.MenuTextColor;
        }
        
        invItems.tds = &GlobalGUIStyles.GridTextDS;
        Ms.visible(true);
        window.show();
        IsShowing = true;
    }
}

So thats using the tds property of List and the end result I'm getting is shown in the attached screenshot (it should say something like name - club, damage - 20, value - 5). Using the approach in my first post in this thread, it displays the values correctly, but with a different color everytime I show the window. Using this approach I just pasted in this post, its showing the right color, but the text is all screwy.


Attached File(s) Image(s)
   
09-26-2012 03:38 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: List.setElmTextColor weirdness
setElmTextColor needs to be set with MEMBER with class and member of the class that you're using with List

class Data
{
Str name;
Color color;
}
List<Data> list;
list.setelm..(MEMBER(Data,color));
is this not in any tutorial?
09-26-2012 01:01 PM
Find all posts by this user Quote this message in a reply
phleshdef Offline
Member

Post: #5
RE: List.setElmTextColor weirdness
Thanks. I'll give that a spin.

The only tutorial I could find dealing with list is the List.cpp tutorial in the Gui folder and it does not cover anything related to styling it.
09-26-2012 03:13 PM
Find all posts by this user Quote this message in a reply
phleshdef Offline
Member

Post: #6
RE: List.setElmTextColor weirdness
Oh I see what you are talking about now. You must be referring to Properties - Class Member Editing.cpp. I didn't make the connection with that tutorial and what I was attempting to do here.

I think it would be nice to, at some point, have some solid documentation on each function/property for each object type in the API that has a clear description of what each member does and an example of each member being used. The tutorials provide a good general overview of the concepts behind the way things work in your API but sometimes its like going on a treasure hunt to find exactly what I'm looking for and its not always clear where I need to look.
09-26-2012 05:41 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #7
RE: List.setElmTextColor weirdness
Every function and members have description in headers. Check Header Browser Tool. It's very useful.
09-26-2012 06:02 PM
Visit this user's website Find all posts by this user Quote this message in a reply
phleshdef Offline
Member

Post: #8
RE: List.setElmTextColor weirdness
Yea, I read the header files. I read everything. I just didn't make the connection that members had to be members of the same class or struct they are being used for. I thought it could be a member of any class or struct.
09-26-2012 06:39 PM
Find all posts by this user Quote this message in a reply
Post Reply