I'm going to assume that the data fields you sscanf into are strings, or that you can get that data into string form. What follows is a basic example of how you might add the content to a MCL.
First of all I'm going to use a custom ListboxTextItem, this makes everything much easier since we do not then have to manually set up every item, this is basically taken from the CEGUI samples. Note that the default text colour is
white, this means that if your list has a white or light coloured background, you will have to set the text colour also in the constructor here.
Code: Select all
class MyListItem : public CEGUI::ListboxTextItem
{
public:
MyListItem(const CEGUI::String& text) : ListboxTextItem(text)
{
setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
}
};
Next we have a little helper function, it takes a pointer to the MCL widget and a couple of C strings, it does the work to add the row to the list using the MyListItem class defined above.
Code: Select all
void addMCLEntry(CEGUI::MultiColumnList* list, const char* func_text, const char* key_text)
{
uint row_idx = list->addRow();
list->setItem(new MyListItem(func_text), 0, row_idx);
list->setItem(new MyListItem(key_text), 1, row_idx);
}
Don't forget to add the columns to the list, if you have not done this in XML or code anywhere, you might do it like this (here the MCL window is named KEY_MAP:
Code: Select all
MultiColumnList* key_map =
static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("KEY_MAP"));
// add columns if we did not do that already!
if (key_map->getColumnCount() == 0)
{
key_map->addColumn("Function", 0, UDim(0.75f, 0));
key_map->addColumn("Key", 1, UDim(0.25f, 0));
}
Then you call the function addMCLEntry each time you parse a line out of the file:
Code: Select all
// func_str and key_str are c-style strings
addMCLEntry(key_map, func_str, key_str);
HTH
CE.