SaveFileList Isn't Correctly Listing my Items
by Orion the Hunter · in Torque Game Builder · 09/09/2013 (6:26 am) · 2 replies
Yet again, I need your help. :P
Here's the problem. I have a list of all the save files that shows up when you go to my load gui. You can select one of the items and then press "Load game" and it will load that level. The problem, surprisingly, is not with that, but with the GuiTextListCtrl. It loads the first file onto the list alright, but all of the other files' names are instantly changed (on the list, at least) to whatever the first file's name is. For example, if there are two items, one name "MyFirstFile" and "MySecondFile" it changes "MyFirstFile" to "MySecondFile" so it appears that there are two "MySecondFile" entries. Here is my code. Could you please help? Any advice is greatly appreciated.
Here's the problem. I have a list of all the save files that shows up when you go to my load gui. You can select one of the items and then press "Load game" and it will load that level. The problem, surprisingly, is not with that, but with the GuiTextListCtrl. It loads the first file onto the list alright, but all of the other files' names are instantly changed (on the list, at least) to whatever the first file's name is. For example, if there are two items, one name "MyFirstFile" and "MySecondFile" it changes "MyFirstFile" to "MySecondFile" so it appears that there are two "MySecondFile" entries. Here is my code. Could you please help? Any advice is greatly appreciated.
//-----------------------------------------------------------------------------
// SaveManager - SaveFileList
//-----------------------------------------------------------------------------
function LoadGui::onWake(%this)
{
%pattern = "~/data/saves/*.hdsdat";
SaveFileList.entryCount = 0;
SaveFileList.clear();
for(%file = findFirstFile(%pattern); %file !$= ""; %file = findNextFile(%pattern))
{
SaveFileList.fileName[SaveFileList.entryCount] = %file;
%stuff = fileBase(%file);
SaveFileList.addRow(SaveFileList.entryCount, %stuff);
SaveFileList.entryCount++;
echo("ForLoop 1 --" SPC %stuff);
}
SaveFileList.sortNumerical(1);
for(%i = 0; %i < SaveFileList.entryCount; %i++)
{
%rowId = SaveFileList.getRowId(%i);
%text = SaveFileList.getRowTextById(%rowId);
%text = restWords(%text);
%text = %i + 1 @". "@ %stuff;
SaveFileList.setRowById(%rowId, %text);
warn("ForLoop 2!");
}
SaveFileList.setSelectedRow(0);
}
function SaveFileList::onSelect(%this, %row)
{
echo("Row... " @ %row);
echo("Row text thing... " @ %this.getRowText(%row));
echo("OnSelect = " @ %this.fileName[%row]);
$SaveFolder = fileBase(%this.fileName[%row]);
error("OnSelect stuff..." SPC $saveFolder);
}
#2
09/10/2013 (6:06 am)
Ah, thanks, but it turned out to be a problem with the second ForLoop. I really appreciate that solution, though, and I'm sure it will prove helpful for others. :)
Torque Owner Richard Ranft
Roostertail Games
SaveFileList.entryCount = 0; SaveFileList.clear(); %file = findFirstFile(%pattern); while(%file !$= "") { SaveFileList.fileName[SaveFileList.entryCount] = %file; %stuff = fileBase(%file); SaveFileList.addRow(SaveFileList.entryCount, %stuff); SaveFileList.entryCount++; echo("ForLoop 1 --" SPC %stuff); %file = findNextFile(%pattern); }