added banner image showing/saving to filesystemviewer. Cleaned up daco's cache code a bit (only coding style stuff), added default banner image. Commented out progress bar for plugin loading.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1055 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2008-11-03 04:17:57 +00:00
parent 22153edc59
commit c9b1cced9c
7 changed files with 370 additions and 72 deletions

View File

@ -24,7 +24,6 @@
BEGIN_EVENT_TABLE(CFilesystemViewer, wxDialog)
EVT_CLOSE(CFilesystemViewer::OnClose)
EVT_RIGHT_DOWN(CFilesystemViewer::OnRightClick)
EVT_TREE_ITEM_RIGHT_CLICK(ID_TREECTRL,CFilesystemViewer::OnRightClickOnTree)
EVT_BUTTON(ID_CLOSE,CFilesystemViewer::OnCloseClick)
EVT_MENU(IDM_BNRSAVEAS, CFilesystemViewer::OnBannerImageSave)
@ -83,10 +82,17 @@ CFilesystemViewer::CFilesystemViewer(const std::string fileName, wxWindow* paren
// Banner
// ...all the BannerLoader functions are bool...gross
//m_Version;
//if (OpenISO_.GetBNRVersion() == "BNR1")
m_Lang->Enable(false);
m_ShortName->SetValue(wxString(OpenISO_.GetName().c_str(), wxConvUTF8));
//m_LongName->SetValue(wxString(OpenISO_.GetLongName().c_str(), wxConvUTF8));
m_Maker->SetValue(wxString(OpenISO_.GetCompany().c_str(), wxConvUTF8));//dev too
m_Comment->SetValue(wxString(OpenISO_.GetDescription().c_str(), wxConvUTF8));
m_Banner->SetBitmap(OpenISO_.GetImage());
m_Banner->Connect(wxID_ANY, wxEVT_RIGHT_DOWN,
wxMouseEventHandler(CFilesystemViewer::RightClickOnBanner), (wxObject*)NULL, this);
Fit();
}
CFilesystemViewer::~CFilesystemViewer()
@ -150,7 +156,7 @@ void CFilesystemViewer::CreateGUIControls()
m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// ISO Details
sbISODetails = new wxStaticBoxSizer(wxVERTICAL, this, wxT("ISO Details:"));
sbISODetails = new wxStaticBoxSizer(wxVERTICAL, this, wxT("ISO Details"));
sISODetails = new wxGridBagSizer(0, 0);
sISODetails->AddGrowableCol(1);
m_NameText = new wxStaticText(this, ID_NAME_TEXT, wxT("Name:"), wxDefaultPosition, wxDefaultSize);
@ -182,13 +188,19 @@ void CFilesystemViewer::CreateGUIControls()
sbISODetails->Add(sISODetails, 0, wxEXPAND, 5);
// Banner Details
wxArrayString arrayStringFor_Lang;
sbBannerDetails = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Banner Details:"));
sbBannerDetails = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Banner Details"));
sBannerDetails = new wxGridBagSizer(0, 0);
m_VersionText = new wxStaticText(this, ID_VERSION_TEXT, wxT("Version:"), wxDefaultPosition, wxDefaultSize);
m_Version = new wxTextCtrl(this, ID_VERSION, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_LangText = new wxStaticText(this, ID_LANG_TEXT, wxT("Show Language:"), wxDefaultPosition, wxDefaultSize);
arrayStringFor_Lang.Add(wxT("English"));
arrayStringFor_Lang.Add(wxT("German"));
arrayStringFor_Lang.Add(wxT("French"));
arrayStringFor_Lang.Add(wxT("Spanish"));
arrayStringFor_Lang.Add(wxT("Italian"));
arrayStringFor_Lang.Add(wxT("Dutch"));
m_Lang = new wxChoice(this, ID_LANG, wxDefaultPosition, wxDefaultSize, arrayStringFor_Lang, 0, wxDefaultValidator);
m_Lang->SetSelection(0);
m_ShortText = new wxStaticText(this, ID_SHORTNAME_TEXT, wxT("Short Name:"), wxDefaultPosition, wxDefaultSize);
m_ShortName = new wxTextCtrl(this, ID_SHORTNAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_LongText = new wxStaticText(this, ID_LONGNAME_TEXT, wxT("Long Name:"), wxDefaultPosition, wxDefaultSize);
@ -198,8 +210,7 @@ void CFilesystemViewer::CreateGUIControls()
m_CommentText = new wxStaticText(this, ID_COMMENT_TEXT, wxT("Comment:"), wxDefaultPosition, wxDefaultSize);
m_Comment = new wxTextCtrl(this, ID_COMMENT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY);
m_BannerText = new wxStaticText(this, ID_BANNER_TEXT, wxT("Banner:"), wxDefaultPosition, wxDefaultSize);
// Needs to be image:
m_Banner = new wxTextCtrl(this, ID_BANNER, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
m_Banner = new wxStaticBitmap(this, ID_BANNER, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0);
sBannerDetails->Add(m_VersionText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
sBannerDetails->Add(m_Version, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
@ -219,7 +230,7 @@ void CFilesystemViewer::CreateGUIControls()
sbBannerDetails->Add(sBannerDetails, 0, wxEXPAND, 0);
// Filesystem tree
sbTreectrl = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Filesytem:"));
sbTreectrl = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Filesytem"));
m_Treectrl = new wxTreeCtrl(this, ID_TREECTRL, wxDefaultPosition, wxSize(350, -1), wxTR_DEFAULT_STYLE, wxDefaultValidator);
sbTreectrl->Add(m_Treectrl, 1, wxEXPAND);
@ -234,7 +245,6 @@ void CFilesystemViewer::CreateGUIControls()
this->SetSizer(sMain);
this->Layout();
Fit();
}
void CFilesystemViewer::OnClose(wxCloseEvent& WXUNUSED (event))
@ -247,17 +257,25 @@ void CFilesystemViewer::OnCloseClick(wxCommandEvent& WXUNUSED (event))
Close();
}
void CFilesystemViewer::OnRightClick(wxMouseEvent& WXUNUSED (event))
void CFilesystemViewer::RightClickOnBanner(wxMouseEvent& event)
{
//check for right click on banner image
//if(event.GetId() == ID_BANNER)
//{
// //on banner then save as.
// wxMenu popupMenu;
// popupMenu.Append(IDM_BNRSAVEAS, wxString::FromAscii("Save as..."));
// PopupMenu(&popupMenu);
//}
//event.Skip();
wxMenu popupMenu;
popupMenu.Append(IDM_BNRSAVEAS, _("Save as..."));
PopupMenu(&popupMenu);
event.Skip();
}
void CFilesystemViewer::OnBannerImageSave(wxCommandEvent& event)
{
wxString dirHome;
wxFileDialog dialog(this, _("Save as..."), wxGetHomeDir(&dirHome), wxString::Format("%s.png", m_GameID->GetLabel()),
_("*.*"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT, wxDefaultPosition, wxDefaultSize);
if (dialog.ShowModal() == wxID_OK)
{
m_Banner->GetBitmap().ConvertToImage().SaveFile(dialog.GetPath());
}
}
void CFilesystemViewer::OnRightClickOnTree(wxTreeEvent& event)
@ -274,11 +292,6 @@ void CFilesystemViewer::OnRightClickOnTree(wxTreeEvent& event)
event.Skip();
}
void CFilesystemViewer::OnBannerImageSave(wxCommandEvent& WXUNUSED (event))
{
}
void CFilesystemViewer::OnExtractFile(wxCommandEvent& WXUNUSED (event))
{
wxString Path;

View File

@ -73,16 +73,15 @@ class CFilesystemViewer : public wxDialog
wxTextCtrl *m_Date;
wxTextCtrl *m_FST;
wxTextCtrl *m_Version;
wxArrayString arrayStringFor_Lang;
wxChoice *m_Lang;
wxTextCtrl *m_ShortName;
wxTextCtrl *m_LongName;
wxTextCtrl *m_Maker;
wxTextCtrl *m_Comment;
wxTextCtrl *m_Banner;
wxStaticBitmap *m_Banner;
wxTreeItemId RootId;
wxChoice *m_Lang;
wxButton *m_SaveBNR;
enum
{
ID_CLOSE = 1000,
@ -128,13 +127,10 @@ class CFilesystemViewer : public wxDialog
void CreateGUIControls();
void OnClose(wxCloseEvent& event);
void OnCloseClick(wxCommandEvent& event);
void OnRightClick(wxMouseEvent& event);
void OnRightClickOnTree(wxTreeEvent& event);
void OnSaveBNRClick(wxCommandEvent& event);
void RightClickOnBanner(wxMouseEvent& event);
void OnBannerImageSave(wxCommandEvent& event);
void OnRightClickOnTree(wxTreeEvent& event);
void OnExtractFile(wxCommandEvent& event);
void OnReplaceFile(wxCommandEvent& event);
void OnRenameFile(wxCommandEvent& event);
typedef std::vector<const DiscIO::SFileInfo *>::iterator fileIter;

View File

@ -339,10 +339,10 @@ void CGameListCtrl::ScanForISOs(bool Loadcache)
if (Loadcache)
{
ScanIso = false;
if((CacheFile = fopen ("DolphinWx.cache","rb")) == NULL)
if((CacheFile = fopen("DolphinWx.cache","rb")) == NULL)
{
ScanIso = true;
if((CacheFile = fopen ("DolphinWx.cache","wb")) == NULL)
if((CacheFile = fopen("DolphinWx.cache","wb")) == NULL)
{
PanicAlert("Unable to make or open the dolphin iso cache: is the directory write protected?");
}
@ -350,36 +350,38 @@ void CGameListCtrl::ScanForISOs(bool Loadcache)
}
else
{
if((CacheFile = fopen ("DolphinWx.cache","wb")) == NULL)
if((CacheFile = fopen("DolphinWx.cache","wb")) == NULL)
{
//Normally the file should be made when it opens it so if it can't open the file it's
//write protected or something is stoping us from writing
// Normally the file should be made when it is opened so if it can't open the file it's
// write protected or something is stopping us from writing
PanicAlert("Unable to make or open the dolphin iso cache: is the directory write protected?");
}
}
m_ISOFiles.clear();
if (!ScanIso)
{
//TODO: complete cache loading here. this means ADDING THE BANNER >_<
// TODO: complete cache loading here. this means ADDING THE BANNER >_<
char Buffer[257];
char temp[257];
std::string Filename = " ";
GameListItem ISOFile(Filename.c_str());
//looping every line of the file
while (fgets(Buffer,256,CacheFile) !=NULL)
// Looping every line of the file
while (fgets(Buffer, 256, CacheFile) != NULL)
{
strncpy(temp,"",257);
int i = 0;
switch(Buffer[0])
{
/*! = file name
/*
! = file name
I = Game ID
N = Game Name
D = Description
C = Country
O = company
S = file size
V = Volume Size*/
V = Volume Size
*/
case '!':
while (i < 256)
{
@ -391,7 +393,7 @@ void CGameListCtrl::ScanForISOs(bool Loadcache)
ISOFile.m_FileName = Filename.c_str();
break;
case 'I':
memcpy(temp,&Buffer[1],6);
memcpy(temp, &Buffer[1], 6);
ISOFile.m_UniqueID = temp;
break;
case 'N':
@ -423,60 +425,59 @@ void CGameListCtrl::ScanForISOs(bool Loadcache)
break;
case 'C':
memcpy(temp,&Buffer[1],3);
ISOFile.m_Country = (DiscIO::IVolume::ECountry) atoi (temp);
ISOFile.m_Country = (DiscIO::IVolume::ECountry) atoi(temp);
break;
case 'S':
memcpy(temp,&Buffer[1],11);
ISOFile.m_FileSize = atoi (temp);
ISOFile.m_FileSize = atoi(temp);
break;
case 'V':
memcpy(temp,&Buffer[1],11);
ISOFile.m_VolumeSize = atoi (temp);
memcpy(temp, &Buffer[1], 11);
ISOFile.m_VolumeSize = atoi(temp);
break;
case 'B':
memcpy(temp,&Buffer[1],1);
memcpy(temp, &Buffer[1], 1);
if (temp[0] == '1')
ISOFile.m_BlobCompressed = true;
else if(temp[0] == '0')
ISOFile.m_BlobCompressed = false;
else
PanicAlert("unknown Compressed value %c",temp[1]);
PanicAlert("unknown Compressed value %c", temp[1]);
break;
case '$':
if(ISOFile.GetFileName().c_str() != NULL)
if (ISOFile.GetFileName().c_str() != NULL)
{
//TODO: it would be good to check if the iso is valid but this would mean adding
//the banner cache and fixing the ISOFile declaration to have the right file name
//from the start (not " " but the Filename from the '!' case)
/*if (ISOFile.IsValid())
// TODO: it would be good to check if the iso is valid but this would mean adding
// the banner cache and fixing the ISOFile declaration to have the right file name
// from the start (not " " but the Filename from the '!' case)
/*
if (ISOFile.IsValid())
{
//PanicAlert("pushing %s in stack...",ISOFile.GetFileName().c_str());
m_ISOFiles.push_back(ISOFile);
}
else
PanicAlert("Invalid ISO file %s", ISOFile.GetFileName().c_str());*/
//TODO: stick the banners in 1 file ;_;
PanicAlert("Invalid ISO file %s", ISOFile.GetFileName().c_str());
*/
// TODO: stick the banners in 1 file ;_;
strcpy(temp,"Gameini\\");
strcpy(&temp[8],ISOFile.GetUniqueID().c_str());
strcpy(&temp[14],".png");
if(fopen(temp,"rb"))
strcpy(temp, "GameIni\\");
strcpy(&temp[8], ISOFile.GetUniqueID().c_str());
strcpy(&temp[14], ".png");
if (fopen(temp, "rb"))
{
ISOFile.m_Image.LoadFile(temp,wxBITMAP_TYPE_PNG);
ISOFile.m_Image.LoadFile(temp, wxBITMAP_TYPE_PNG);
}
else
{
PanicAlert("Could not find banner for %s",ISOFile.GetName().c_str());
//remove any data left of the image of the game before the current. or you'll get the same
//banner twice :P
ISOFile.m_Image.Destroy();
// Don't worry about it, the no_banner_png was saved before.
}
m_ISOFiles.push_back(ISOFile);
}
break;
default:
PanicAlert("Unknown Cache line Found:\n%s",Buffer);
PanicAlert("Unknown Cache line Found:\n%s", Buffer);
break;
}
}
@ -533,11 +534,11 @@ void CGameListCtrl::ScanForISOs(bool Loadcache)
fprintf(CacheFile,"!%s\nI%s\nN%s\nD%s\nC%u\nO%s\nS%u\n",ISOFile.GetFileName().c_str(),
ISOFile.GetUniqueID().c_str(), ISOFile.GetName().c_str(), ISOFile.GetDescription().c_str()
,ISOFile.GetCountry(), ISOFile.GetCompany().c_str(), ISOFile.GetFileSize());
//why a new fprintf? cause volume size got writen as 0 for some bloody odd reason
// Why a new fprintf? cause volume size got writen as 0 for some bloody odd reason
fprintf(CacheFile,"V%u\nB%u\n$\n", ISOFile.GetVolumeSize(), ISOFile.IsCompressed());
ISOFile.m_Image.SaveFile("Gameini\\" + ISOFile.GetUniqueID() + ".png",wxBITMAP_TYPE_PNG);//".JPG",wxBITMAP_TYPE_JPEG);
//TODO: add the banner saving TO 1 FILE AND JPG as well & make the cache MUCH better.
//this is ugly as fuck
ISOFile.m_Image.SaveFile("GameIni\\" + ISOFile.GetUniqueID() + ".png",wxBITMAP_TYPE_PNG);//".JPG",wxBITMAP_TYPE_JPEG);
// TODO: add the banner saving TO 1 FILE AND JPG as well & make the cache MUCH better.
// This is ugly as fuck
}
m_ISOFiles.push_back(ISOFile);
}

View File

@ -27,6 +27,9 @@
#include "BannerLoader.h"
#include "FileSearch.h"
#include "CompressedBlob.h"
#include "../resources/no_banner.cpp"
#include <wx/mstream.h>
#define DVD_BANNER_WIDTH 96
#define DVD_BANNER_HEIGHT 32
@ -82,6 +85,9 @@ GameListItem::GameListItem(const std::string& _rFileName)
else
{
// default banner
wxMemoryInputStream istream(no_banner_png, sizeof no_banner_png);
wxImage iNoBanner(istream, wxBITMAP_TYPE_PNG);
m_Image = iNoBanner;
}

View File

@ -54,6 +54,7 @@ void CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
if (rFilenames.size() > 0)
{
/*
wxProgressDialog dialog(_T("Scanning for Plugins"),
_T("Scanning..."),
(int)rFilenames.size(), // range
@ -67,6 +68,7 @@ void CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
);
dialog.CenterOnParent();
*/
for (size_t i = 0; i < rFilenames.size(); i++)
{
@ -79,6 +81,7 @@ void CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
return;
}
/*
wxString msg;
char temp[128];
sprintf(temp,"Scanning %s", FileName.c_str());
@ -89,7 +92,7 @@ void CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
{
break;
}
*/
CPluginInfo PluginInfo(orig_name.c_str());
if (PluginInfo.IsValid())
{