Skip to content

Commit

Permalink
Merge pull request #142 from lioncash/hdd
Browse files Browse the repository at this point in the history
Misc HDD stuff
  • Loading branch information
AlexAltea committed Mar 30, 2014
2 parents ae5d06d + b9de74f commit e6aa1a9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions rpcs3/Emu/HDD/HDD.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,11 @@ class vfsDeviceHDD : public vfsDevice
class vfsHDD : public vfsFileBase
{
vfsHDD_Hdr m_hdd_info;
vfsLocalFile m_hdd_file;
const wxString& m_hdd_path;
vfsHDD_Entry m_cur_dir;
u64 m_cur_dir_block;
vfsHDDFile m_file;
vfsLocalFile m_hdd_file;
const wxString& m_hdd_path;

public:
vfsHDD(vfsDevice* device, const wxString& hdd_path)
Expand Down
46 changes: 22 additions & 24 deletions rpcs3/Gui/VHDDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void VHDDExplorer::UpdateList()
{
m_list->Freeze();
m_list->DeleteAllItems();
m_entries.Clear();
m_entries.clear();
m_names.Clear();

u64 block;
Expand All @@ -101,7 +101,7 @@ void VHDDExplorer::UpdateList()
m_list->SetItem(item, 1, entry.type == vfsHDD_Entry_Dir ? "Dir" : "File");
m_list->SetItem(item, 2, wxString::Format("%lld", entry.size));
m_list->SetItem(item, 3, wxDateTime().Set(time_t(entry.ctime)).Format());
m_entries.AddCpy(entry);
m_entries.push_back(entry);
m_names.Add(name);
}

Expand Down Expand Up @@ -397,7 +397,7 @@ VHDDManagerDialog::VHDDManagerDialog(wxWindow* parent)
Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnRemove));
Connect(id_create_hdd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnCreateHDD));
Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VHDDManagerDialog::OnClose));
LoadPathes();
LoadPaths();
UpdateList();
}

Expand All @@ -406,9 +406,9 @@ void VHDDManagerDialog::UpdateList()
m_list->Freeze();
m_list->DeleteAllItems();

for(size_t i=0; i<m_pathes.GetCount(); ++i)
for(size_t i=0; i<m_paths.size(); ++i)
{
m_list->InsertItem(i, m_pathes[i]);
m_list->InsertItem(i, m_paths[i]);
}

m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
Expand All @@ -420,7 +420,7 @@ void VHDDManagerDialog::UpdateList()

void VHDDManagerDialog::Open(int sel)
{
VHDDExplorer dial(this, m_pathes[sel]);
VHDDExplorer dial(this, m_paths[sel]);
dial.ShowModal();
}

Expand All @@ -439,14 +439,14 @@ void VHDDManagerDialog::AddHDD(wxCommandEvent& event)
return;
}

wxArrayString pathes;
ctrl.GetPaths(pathes);
for(size_t i=0; i<pathes.GetCount(); ++i)
wxArrayString paths;
ctrl.GetPaths(paths);
for(size_t i=0; i<paths.GetCount(); ++i)
{
bool skip = false;
for(size_t j=0; j<m_pathes.GetCount(); ++j)
for(size_t j=0; j<m_paths.size(); ++j)
{
if(m_pathes[j].CmpNoCase(pathes[i]) == 0)
if(m_paths[j].CmpNoCase(paths[i]) == 0)
{
skip = true;
break;
Expand All @@ -455,7 +455,7 @@ void VHDDManagerDialog::AddHDD(wxCommandEvent& event)

if(!skip)
{
m_pathes.Move(new wxString(pathes[i].c_str()));
m_paths.emplace_back(paths[i]);
}
}
UpdateList();
Expand Down Expand Up @@ -483,7 +483,7 @@ void VHDDManagerDialog::OnRemove(wxCommandEvent& event)
{
for(int sel = m_list->GetNextSelected(-1), offs = 0; sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel), --offs)
{
m_pathes.RemoveAt(sel + offs);
m_paths.erase(m_paths.begin() + (sel + offs));
}

UpdateList();
Expand All @@ -506,44 +506,42 @@ void VHDDManagerDialog::OnCreateHDD(wxCommandEvent& event)
u64 size, bsize;
dial.GetResult(size, bsize);
vfsHDDManager::CreateHDD(ctrl.GetPath(), size, bsize);
m_pathes.AddCpy(ctrl.GetPath());
m_paths.push_back(ctrl.GetPath());
UpdateList();
}
}

void VHDDManagerDialog::OnClose(wxCloseEvent& event)
{
SavePathes();
SavePaths();
event.Skip();
}

void VHDDManagerDialog::LoadPathes()
void VHDDManagerDialog::LoadPaths()
{
IniEntry<int> path_count;
path_count.Init("path_count", "HDDManager");
int count = 0;
count = path_count.LoadValue(count);

m_pathes.SetCount(count);

for(size_t i=0; i<m_pathes.GetCount(); ++i)
for(size_t i=0; i<count; ++i)
{
IniEntry<wxString> path_entry;
path_entry.Init(wxString::Format("path[%d]", i), "HDDManager");
new (m_pathes + i) wxString(path_entry.LoadValue(wxEmptyString));
m_paths.emplace_back(path_entry.LoadValue(wxEmptyString));
}
}

void VHDDManagerDialog::SavePathes()
void VHDDManagerDialog::SavePaths()
{
IniEntry<int> path_count;
path_count.Init("path_count", "HDDManager");
path_count.SaveValue(m_pathes.GetCount());
path_count.SaveValue(m_paths.size());

for(size_t i=0; i<m_pathes.GetCount(); ++i)
for(size_t i=0; i<m_paths.size(); ++i)
{
IniEntry<wxString> path_entry;
path_entry.Init(wxString::Format("path[%d]", i), "HDDManager");
path_entry.SaveValue(m_pathes[i]);
path_entry.SaveValue(m_paths[i]);
}
}
9 changes: 5 additions & 4 deletions rpcs3/Gui/VHDDManager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <vector>
#include <wx/dnd.h>
#include "Emu/HDD/HDD.h"

Expand All @@ -20,7 +21,7 @@ class VHDDListDropTarget : public wxDropTarget

class VHDDExplorer : public wxDialog
{
Array<vfsHDD_Entry> m_entries;
std::vector<vfsHDD_Entry> m_entries;
wxArrayString m_names;
wxListView* m_list;
vfsHDD* m_hdd;
Expand Down Expand Up @@ -65,7 +66,7 @@ class VHDDSetInfoDialog : public wxDialog

class VHDDManagerDialog : public wxDialog
{
Array<wxString> m_pathes;
std::vector<wxString> m_paths;
wxListView* m_list;

public:
Expand All @@ -82,6 +83,6 @@ class VHDDManagerDialog : public wxDialog
void OnCreateHDD(wxCommandEvent& event);

void OnClose(wxCloseEvent& event);
void LoadPathes();
void SavePathes();
void LoadPaths();
void SavePaths();
};

0 comments on commit e6aa1a9

Please sign in to comment.