2020-09-18 14:28:07 +00:00
|
|
|
#pragma once
|
|
|
|
#include "core/memory_card_image.h"
|
|
|
|
#include "ui_memorycardeditordialog.h"
|
|
|
|
#include <QtWidgets/QComboBox>
|
|
|
|
#include <QtWidgets/QDialog>
|
|
|
|
#include <QtWidgets/QLabel>
|
|
|
|
#include <QtWidgets/QPushButton>
|
|
|
|
#include <QtWidgets/QTableWidget>
|
|
|
|
|
|
|
|
class MemoryCardEditorDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
MemoryCardEditorDialog(QWidget* parent);
|
|
|
|
~MemoryCardEditorDialog();
|
|
|
|
|
2020-11-10 13:24:07 +00:00
|
|
|
bool setCardA(const QString& path);
|
|
|
|
bool setCardB(const QString& path);
|
|
|
|
|
2020-09-18 14:28:07 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent* ev);
|
|
|
|
void closeEvent(QCloseEvent* ev);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onCardASelectionChanged();
|
|
|
|
void onCardBSelectionChanged();
|
|
|
|
void doCopyFile();
|
|
|
|
void doDeleteFile();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Card
|
|
|
|
{
|
|
|
|
std::string filename;
|
|
|
|
MemoryCardImage::DataArray data;
|
|
|
|
std::vector<MemoryCardImage::FileInfo> files;
|
|
|
|
u32 blocks_free = 0;
|
|
|
|
bool dirty = false;
|
|
|
|
|
|
|
|
QComboBox* path_cb = nullptr;
|
|
|
|
QTableWidget* table = nullptr;
|
|
|
|
QLabel* blocks_free_label = nullptr;
|
|
|
|
QPushButton* save_button = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
void connectUi();
|
|
|
|
void populateComboBox(QComboBox* cb);
|
|
|
|
void clearSelection();
|
|
|
|
void loadCardFromComboBox(Card* card, int index);
|
|
|
|
bool loadCard(const QString& filename, Card* card);
|
|
|
|
void updateCardTable(Card* card);
|
|
|
|
void updateCardBlocksFree(Card* card);
|
|
|
|
void setCardDirty(Card* card);
|
|
|
|
void newCard(Card* card);
|
2020-12-19 07:01:20 +00:00
|
|
|
void openCard(Card* card);
|
2020-09-18 14:28:07 +00:00
|
|
|
void saveCard(Card* card);
|
|
|
|
void promptForSave(Card* card);
|
|
|
|
void importCard(Card* card);
|
2021-06-21 07:25:08 +00:00
|
|
|
void formatCard(Card* card);
|
2020-09-18 14:28:07 +00:00
|
|
|
|
2021-03-05 04:50:20 +00:00
|
|
|
void doExportSaveFile();
|
|
|
|
void importSaveFile(Card* card);
|
|
|
|
|
2020-09-18 14:28:07 +00:00
|
|
|
std::tuple<Card*, const MemoryCardImage::FileInfo*> getSelectedFile();
|
|
|
|
void updateButtonState();
|
|
|
|
|
|
|
|
Ui::MemoryCardEditorDialog m_ui;
|
|
|
|
|
|
|
|
Card m_card_a;
|
|
|
|
Card m_card_b;
|
|
|
|
};
|