2018-05-20 04:53:34 +00:00
|
|
|
// Pi1541 - A Commodore 1541 disk drive emulator
|
|
|
|
// Copyright(C) 2018 Stephen White
|
|
|
|
//
|
|
|
|
// This file is part of Pi1541.
|
|
|
|
//
|
|
|
|
// Pi1541 is free software : you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Pi1541 is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef FileBrowser_H
|
|
|
|
#define FileBrowser_H
|
|
|
|
#include <assert.h>
|
|
|
|
#include "ff.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "types.h"
|
|
|
|
#include "DiskImage.h"
|
|
|
|
#include "DiskCaddy.h"
|
|
|
|
#include "ROMs.h"
|
2018-06-03 08:11:58 +00:00
|
|
|
#include "ScreenBase.h"
|
2018-05-20 04:53:34 +00:00
|
|
|
|
|
|
|
#define VIC2_COLOUR_INDEX_BLACK 0
|
|
|
|
#define VIC2_COLOUR_INDEX_WHITE 1
|
|
|
|
#define VIC2_COLOUR_INDEX_RED 2
|
|
|
|
#define VIC2_COLOUR_INDEX_CYAN 3
|
|
|
|
#define VIC2_COLOUR_INDEX_MAGENTA 4
|
|
|
|
#define VIC2_COLOUR_INDEX_GREEN 5
|
|
|
|
#define VIC2_COLOUR_INDEX_BLUE 6
|
|
|
|
#define VIC2_COLOUR_INDEX_YELLOW 7
|
|
|
|
#define VIC2_COLOUR_INDEX_ORANGE 8
|
|
|
|
#define VIC2_COLOUR_INDEX_BROWN 9
|
|
|
|
#define VIC2_COLOUR_INDEX_PINK 10
|
|
|
|
#define VIC2_COLOUR_INDEX_DGREY 11
|
|
|
|
#define VIC2_COLOUR_INDEX_GREY 12
|
|
|
|
#define VIC2_COLOUR_INDEX_LGREEN 13
|
|
|
|
#define VIC2_COLOUR_INDEX_LBLUE 14
|
|
|
|
#define VIC2_COLOUR_INDEX_LGREY 15
|
|
|
|
|
|
|
|
#define FILEBROWSER_MAX_PNG_SIZE 0x10000
|
|
|
|
|
|
|
|
#define STATUS_BAR_POSITION_Y (40 * 16 + 10)
|
|
|
|
|
|
|
|
class FileBrowser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
class BrowsableList;
|
|
|
|
|
|
|
|
class BrowsableListView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BrowsableListView(BrowsableList* list, ScreenBase* screen, u32 columns, u32 rows, u32 positionX, u32 positionY, bool lcdPgUpDown)
|
|
|
|
: list(list)
|
|
|
|
, screen(screen)
|
|
|
|
, columns(columns)
|
|
|
|
, rows(rows)
|
|
|
|
, positionX(positionX)
|
|
|
|
, positionY(positionY)
|
|
|
|
, lcdPgUpDown(lcdPgUpDown)
|
2018-07-15 08:46:49 +00:00
|
|
|
, highlightScrollOffset(0)
|
|
|
|
, highlightScrollStartCount(0)
|
|
|
|
, highlightScrollEndCount(0)
|
|
|
|
, scrollHighlightRate()
|
2018-06-03 08:11:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Refresh();
|
2018-07-15 08:46:49 +00:00
|
|
|
void RefreshLine(u32 entryIndex, u32 x, u32 y, bool selected);
|
|
|
|
void RefreshHighlightScroll();
|
2018-06-03 08:11:58 +00:00
|
|
|
bool CheckBrowseNavigation(bool pageOnly);
|
|
|
|
|
|
|
|
BrowsableList* list;
|
|
|
|
u32 offset;
|
|
|
|
|
|
|
|
ScreenBase* screen;
|
|
|
|
u32 columns;
|
|
|
|
u32 rows;
|
|
|
|
u32 positionX;
|
|
|
|
u32 positionY;
|
|
|
|
bool lcdPgUpDown;
|
2018-07-15 08:46:49 +00:00
|
|
|
u32 highlightScrollOffset;
|
|
|
|
u32 highlightScrollStartCount;
|
|
|
|
u32 highlightScrollEndCount;
|
|
|
|
float scrollHighlightRate;
|
2018-06-03 08:11:58 +00:00
|
|
|
};
|
|
|
|
|
2018-05-20 04:53:34 +00:00
|
|
|
class BrowsableList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BrowsableList()
|
|
|
|
: current(0)
|
|
|
|
, currentIndex(0)
|
2018-07-15 08:46:49 +00:00
|
|
|
, currentHighlightTime(0)
|
|
|
|
, scrollHighlightRate(0)
|
2018-05-20 04:53:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
2018-06-03 08:11:58 +00:00
|
|
|
u32 index;
|
2018-05-20 04:53:34 +00:00
|
|
|
entries.clear();
|
|
|
|
current = 0;
|
|
|
|
currentIndex = 0;
|
2018-06-03 08:11:58 +00:00
|
|
|
for (index = 0; index < views.size(); ++index)
|
|
|
|
{
|
|
|
|
views[index].offset = 0;
|
|
|
|
}
|
2018-05-20 04:53:34 +00:00
|
|
|
}
|
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
void AddView(ScreenBase* screen, u32 columns, u32 rows, u32 positionX, u32 positionY, bool lcdPgUpDown)
|
|
|
|
{
|
|
|
|
BrowsableListView view(this, screen, columns, rows, positionX, positionY, lcdPgUpDown);
|
|
|
|
views.push_back(view);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearSelections();
|
|
|
|
|
2018-07-15 08:46:49 +00:00
|
|
|
void SetCurrent()
|
|
|
|
{
|
|
|
|
if (entries.size() > 0)
|
|
|
|
{
|
|
|
|
Entry* currentEntry = &entries[currentIndex];
|
|
|
|
if (currentEntry != current)
|
|
|
|
{
|
|
|
|
current = currentEntry;
|
|
|
|
currentHighlightTime = scrollHighlightRate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-20 04:53:34 +00:00
|
|
|
struct Entry
|
|
|
|
{
|
2018-06-03 08:11:58 +00:00
|
|
|
Entry() : caddyIndex(-1)
|
|
|
|
{
|
|
|
|
}
|
2018-05-20 04:53:34 +00:00
|
|
|
FILINFO filImage;
|
|
|
|
FILINFO filIcon;
|
2018-06-03 08:11:58 +00:00
|
|
|
int caddyIndex;
|
2018-05-20 04:53:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Entry* FindEntry(const char* name);
|
2018-07-20 02:30:20 +00:00
|
|
|
int FindNextAutoName(char* basename);
|
2018-05-20 04:53:34 +00:00
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
void RefreshViews();
|
2018-07-15 08:46:49 +00:00
|
|
|
void RefreshViewsHighlightScroll();
|
2018-06-03 08:11:58 +00:00
|
|
|
bool CheckBrowseNavigation();
|
|
|
|
|
2018-05-20 04:53:34 +00:00
|
|
|
std::vector<Entry> entries;
|
|
|
|
Entry* current;
|
|
|
|
u32 currentIndex;
|
2018-07-15 08:46:49 +00:00
|
|
|
float currentHighlightTime;
|
|
|
|
float scrollHighlightRate;
|
2018-05-20 04:53:34 +00:00
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
std::vector<BrowsableListView> views;
|
2018-05-20 04:53:34 +00:00
|
|
|
};
|
|
|
|
|
2018-07-21 03:07:14 +00:00
|
|
|
FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate);
|
2018-05-20 04:53:34 +00:00
|
|
|
|
2018-07-27 13:56:42 +00:00
|
|
|
void SelectAutoMountImage(const char* image);
|
2018-05-20 04:53:34 +00:00
|
|
|
void DisplayRoot();
|
2018-07-15 08:46:49 +00:00
|
|
|
void Update();
|
2018-05-20 04:53:34 +00:00
|
|
|
|
|
|
|
void RefeshDisplay();
|
|
|
|
void DisplayDiskInfo(DiskImage* diskImage, const char* filenameForIcon);
|
|
|
|
|
|
|
|
void DisplayStatusBar();
|
|
|
|
|
|
|
|
void FolderChanged();
|
|
|
|
void PopFolder();
|
|
|
|
|
|
|
|
bool SelectionsMade() { return selectionsMade; }
|
|
|
|
const char* LastSelectionName() { return lastSelectionName; }
|
2018-06-03 08:11:58 +00:00
|
|
|
void ClearSelections();
|
2018-05-20 04:53:34 +00:00
|
|
|
|
|
|
|
void ShowDeviceAndROM();
|
|
|
|
|
|
|
|
void ClearScreen();
|
|
|
|
|
|
|
|
static const long int LSTBuffer_size = 1024 * 8;
|
|
|
|
static unsigned char LSTBuffer[];
|
|
|
|
|
|
|
|
static u32 Colour(int index);
|
|
|
|
|
2018-08-07 14:38:08 +00:00
|
|
|
bool MakeLST(const char* filenameLST);
|
2018-05-20 04:53:34 +00:00
|
|
|
bool SelectLST(const char* filenameLST);
|
|
|
|
|
2018-07-15 08:46:49 +00:00
|
|
|
void SetScrollHighlightRate(float value) { scrollHighlightRate = value; }
|
|
|
|
|
2018-05-20 04:53:34 +00:00
|
|
|
private:
|
|
|
|
void DisplayPNG(FILINFO& filIcon, int x, int y);
|
|
|
|
void RefreshFolderEntries();
|
|
|
|
|
|
|
|
void UpdateInputFolders();
|
|
|
|
void UpdateInputDiskCaddy();
|
|
|
|
|
2018-07-15 08:46:49 +00:00
|
|
|
void UpdateCurrentHighlight();
|
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
//void RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* browsableList, int xOffset, bool showSelected = true);
|
2018-05-20 04:53:34 +00:00
|
|
|
|
|
|
|
bool FillCaddyWithSelections();
|
|
|
|
|
|
|
|
bool AddToCaddy(FileBrowser::BrowsableList::Entry* current);
|
2018-08-07 08:57:21 +00:00
|
|
|
bool AddImageToCaddy(FileBrowser::BrowsableList::Entry* current);
|
2018-05-20 04:53:34 +00:00
|
|
|
|
|
|
|
bool CheckForPNG(const char* filename, FILINFO& filIcon);
|
|
|
|
void DisplayPNG();
|
|
|
|
|
2018-07-30 23:41:50 +00:00
|
|
|
bool SelectROMOrDevice(u32 index);
|
2018-07-29 04:22:14 +00:00
|
|
|
|
2018-05-20 04:53:34 +00:00
|
|
|
enum State
|
|
|
|
{
|
|
|
|
State_Folders,
|
|
|
|
State_DiskCaddy
|
|
|
|
} state;
|
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
BrowsableList folder;
|
2018-05-20 04:53:34 +00:00
|
|
|
DiskCaddy* diskCaddy;
|
|
|
|
bool selectionsMade;
|
|
|
|
const char* lastSelectionName;
|
|
|
|
ROMs* roms;
|
2018-07-21 03:07:14 +00:00
|
|
|
u8* deviceID;
|
2018-05-20 04:53:34 +00:00
|
|
|
bool displayPNGIcons;
|
2018-07-30 23:41:50 +00:00
|
|
|
bool buttonChangedROMDevice;
|
2018-05-20 04:53:34 +00:00
|
|
|
|
|
|
|
BrowsableList caddySelections;
|
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
ScreenBase* screenMain;
|
|
|
|
ScreenBase* screenLCD;
|
|
|
|
|
2018-07-15 08:46:49 +00:00
|
|
|
float scrollHighlightRate;
|
|
|
|
|
2018-05-20 04:53:34 +00:00
|
|
|
char PNG[FILEBROWSER_MAX_PNG_SIZE];
|
|
|
|
};
|
|
|
|
#endif
|