mirror of
https://github.com/dborth/fceugx.git
synced 2024-11-01 06:55:05 +01:00
browser fix
This commit is contained in:
parent
32086172cc
commit
1e98f458ad
@ -543,16 +543,21 @@ bool ParseDirEntries()
|
|||||||
|
|
||||||
// Sort the file list
|
// Sort the file list
|
||||||
if(i >= 0)
|
if(i >= 0)
|
||||||
{
|
|
||||||
qsort(browserList, browser.numEntries+i, sizeof(BROWSERENTRY), FileSortCallback);
|
qsort(browserList, browser.numEntries+i, sizeof(BROWSERENTRY), FileSortCallback);
|
||||||
}
|
|
||||||
|
browser.numEntries += i;
|
||||||
|
|
||||||
|
if(res != 0 || parseHalt)
|
||||||
|
{
|
||||||
|
dirclose(dirIter); // close directory
|
||||||
|
dirIter = NULL;
|
||||||
|
|
||||||
// try to find and select the last loaded file
|
// try to find and select the last loaded file
|
||||||
if(selectLoadedFile == 1 && res != 0 && loadedFile[0] != 0 && browser.dir[0] != 0)
|
if(selectLoadedFile == 1 && parseHalt == 0 && loadedFile[0] != 0 && browser.dir[0] != 0)
|
||||||
{
|
{
|
||||||
int indexFound = -1;
|
int indexFound = -1;
|
||||||
|
|
||||||
for(int j=1; j < browser.numEntries + i; j++)
|
for(int j=1; j < browser.numEntries; j++)
|
||||||
{
|
{
|
||||||
if(strcmp(browserList[j].filename, loadedFile) == 0)
|
if(strcmp(browserList[j].filename, loadedFile) == 0)
|
||||||
{
|
{
|
||||||
@ -564,26 +569,23 @@ bool ParseDirEntries()
|
|||||||
// move to this file
|
// move to this file
|
||||||
if(indexFound > 0)
|
if(indexFound > 0)
|
||||||
{
|
{
|
||||||
if(indexFound > FILE_PAGESIZE)
|
if(indexFound >= FILE_PAGESIZE)
|
||||||
{
|
{
|
||||||
browser.pageIndex = (ceil(indexFound/FILE_PAGESIZE*1.0)) * FILE_PAGESIZE;
|
int newIndex = (floor(indexFound/(float)FILE_PAGESIZE)) * FILE_PAGESIZE;
|
||||||
|
|
||||||
if(browser.pageIndex + FILE_PAGESIZE > browser.numEntries + i)
|
if(newIndex + FILE_PAGESIZE > browser.numEntries)
|
||||||
{
|
newIndex = browser.numEntries - FILE_PAGESIZE;
|
||||||
browser.pageIndex = browser.numEntries + i - FILE_PAGESIZE;
|
|
||||||
}
|
if(newIndex < 0)
|
||||||
|
newIndex = 0;
|
||||||
|
|
||||||
|
browser.pageIndex = newIndex;
|
||||||
}
|
}
|
||||||
browser.selIndex = indexFound;
|
browser.selIndex = indexFound;
|
||||||
}
|
}
|
||||||
selectLoadedFile = 2; // selecting done
|
selectLoadedFile = 2; // selecting done
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.numEntries += i;
|
|
||||||
|
|
||||||
if(res != 0 || parseHalt)
|
|
||||||
{
|
|
||||||
dirclose(dirIter); // close directory
|
|
||||||
dirIter = NULL;
|
|
||||||
return false; // no more entries
|
return false; // no more entries
|
||||||
}
|
}
|
||||||
return true; // more entries
|
return true; // more entries
|
||||||
|
@ -199,6 +199,14 @@ void GuiFileBrowser::ResetState()
|
|||||||
|
|
||||||
void GuiFileBrowser::TriggerUpdate()
|
void GuiFileBrowser::TriggerUpdate()
|
||||||
{
|
{
|
||||||
|
int newIndex = browser.selIndex-browser.pageIndex;
|
||||||
|
|
||||||
|
if(newIndex >= FILE_PAGESIZE)
|
||||||
|
newIndex = FILE_PAGESIZE-1;
|
||||||
|
else if(newIndex < 0)
|
||||||
|
newIndex = 0;
|
||||||
|
|
||||||
|
selectedItem = newIndex;
|
||||||
listChanged = true;
|
listChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user