Skip to content

Commit

Permalink
refactor: store rootdir for CD devices in Amiberry
Browse files Browse the repository at this point in the history
Since we're not on Windows, we need the path to the device, not a one-letter drive.
  • Loading branch information
midwan committed Nov 13, 2024
1 parent 72507c2 commit 1aa52e6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 33 deletions.
3 changes: 3 additions & 0 deletions src/osdep/amiberry_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,9 @@ void new_cddrive(int entry)
ci.device_emu_unit = 0;
ci.controller_type = current_cddlg.ci.controller_type;
ci.controller_unit = current_cddlg.ci.controller_unit;
#ifdef AMIBERRY
_tcscpy(ci.rootdir, current_cddlg.ci.rootdir);
#endif
ci.type = UAEDEV_CD;
ci.readonly = true;
ci.blocksize = 2048;
Expand Down
10 changes: 10 additions & 0 deletions src/osdep/gui/EditCDDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CDDriveActionListener : public gcn::ActionListener
wndEditCDDrive->setCaption("Path is empty!");
return;
}

dialogResult = true;
dialogFinished = true;
}
Expand Down Expand Up @@ -506,6 +507,15 @@ bool EditCDDrive(const int unit_no)

if (dialogResult)
{
strncpy(current_cddlg.ci.rootdir, txtCDDrivePath->getText().c_str(), sizeof(current_cddlg.ci.rootdir) - 1);

auto posn = controller[cboCDDriveController->getSelected()].type;
current_cddlg.ci.controller_type = posn % HD_CONTROLLER_NEXT_UNIT;
current_cddlg.ci.controller_type_unit = posn / HD_CONTROLLER_NEXT_UNIT;
inithdcontroller(current_cddlg.ci.controller_type, current_cddlg.ci.controller_type_unit, UAEDEV_CD, current_cddlg.ci.rootdir[0] != 0);

current_cddlg.ci.controller_unit = cboCDDriveUnit->getSelected();

new_cddrive(unit_no);
}

Expand Down
61 changes: 28 additions & 33 deletions src/osdep/gui/PanelHD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,6 @@ static void harddisktype(TCHAR* s, struct uaedev_config_info* ci)
}
}

static int GetHDType(const int index)
{
mountedinfo mi{};

auto type = get_filesys_unitconfig(&changed_prefs, index, &mi);
if (type < 0)
{
auto* uci = &changed_prefs.mountconfig[index];
struct uaedev_config_info* ci = &uci->ci;
type = ci->type == UAEDEV_HDF ? FILESYS_HARDFILE : FILESYS_VIRTUAL;
}
return type;
}

static gcn::StringListModel cdfileList;

static void RefreshCDListModel()
Expand Down Expand Up @@ -135,36 +121,49 @@ class HDEditActionListener : public gcn::ActionListener
public:
void action(const gcn::ActionEvent& actionEvent) override
{
for (auto i = 0; i < MAX_HD_DEVICES; ++i)
for (auto entry = 0; entry < MAX_HD_DEVICES; ++entry)
{
if (actionEvent.getSource() == listCmdProps[i])
if (actionEvent.getSource() == listCmdProps[entry])
{
if (GetHDType(i) == FILESYS_VIRTUAL)
int type;
struct uaedev_config_data* uci;
struct mountedinfo mi;

uci = &changed_prefs.mountconfig[entry];

type = get_filesys_unitconfig(&changed_prefs, entry, &mi);
if (type < 0)
{
if (EditFilesysVirtual(i))
type = uci->ci.type == UAEDEV_HDF ? FILESYS_HARDFILE : FILESYS_VIRTUAL;
}

if (uci->ci.type == UAEDEV_CD)
{
if (EditCDDrive(entry))
gui_force_rtarea_hdchange();
}
else if (GetHDType(i) == FILESYS_HARDFILE || GetHDType(i) == FILESYS_HARDFILE_RDB)
else if (uci->ci.type == UAEDEV_TAPE)
{
if (EditFilesysHardfile(i))
if (EditTapeDrive(entry))
gui_force_rtarea_hdchange();
}
else if (GetHDType(i) == FILESYS_HARDDRIVE)
else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB)
{
if (EditFilesysHardDrive(i))
if (EditFilesysHardfile(entry))
gui_force_rtarea_hdchange();
}
else if (GetHDType(i) == UAEDEV_CD)
else if (type == FILESYS_HARDDRIVE) /* harddisk */
{
if (EditCDDrive(i))
if (EditFilesysHardDrive(entry))
gui_force_rtarea_hdchange();
}
else if (GetHDType(i) == UAEDEV_TAPE)
else /* Filesystem */
{
if (EditTapeDrive(i))
if (EditFilesysVirtual(entry))
gui_force_rtarea_hdchange();
}
listCmdProps[i]->requestFocus();

listCmdProps[entry]->requestFocus();
break;
}
}
Expand All @@ -184,43 +183,39 @@ class HDAddActionListener : public gcn::ActionListener
if (EditFilesysVirtual(-1))
gui_force_rtarea_hdchange();
cmdAddDirectory->requestFocus();
RefreshPanelHD();
}
else if (actionEvent.getSource() == cmdAddHardfile)
{
if (EditFilesysHardfile(-1))
gui_force_rtarea_hdchange();
cmdAddHardfile->requestFocus();
RefreshPanelHD();
}
else if (actionEvent.getSource() == cmdAddHardDrive)
{
if (EditFilesysHardDrive(-1))
gui_force_rtarea_hdchange();
cmdAddHardDrive->requestFocus();
RefreshPanelHD();
}
else if (actionEvent.getSource() == cmdAddCDDrive)
{
if (EditCDDrive(-1))
gui_force_rtarea_hdchange();
cmdAddCDDrive->requestFocus();
RefreshPanelHD();
}
else if (actionEvent.getSource() == cmdAddTapeDrive)
{
if (EditTapeDrive(-1))
gui_force_rtarea_hdchange();
cmdAddTapeDrive->requestFocus();
RefreshPanelHD();
}
else if (actionEvent.getSource() == cmdCreateHardfile)
{
if (CreateFilesysHardfile())
gui_force_rtarea_hdchange();
cmdCreateHardfile->requestFocus();
RefreshPanelHD();

}
RefreshPanelHD();
}
};

Expand Down

0 comments on commit 1aa52e6

Please sign in to comment.