Skip to content

Commit

Permalink
Improve screen tiles listing
Browse files Browse the repository at this point in the history
Add option to show all tiles on the screen.
Show screen shot name for unmatched tiles when All is selected
  • Loading branch information
mkwong98 committed Aug 24, 2014
1 parent 91141c5 commit 5829aa5
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 28 deletions.
61 changes: 46 additions & 15 deletions hdnes/fraHDNesImp.cpp
Expand Up @@ -488,6 +488,11 @@ void fraHDNesImp::loadImage(){
delete objDC;
}

void fraHDNesImp::toggleShowAllTiles( wxCommandEvent& event ){
loadScreenTiles();
}


void fraHDNesImp::loadScreenTiles(){
bitmapE b;
bitmapF c;
Expand All @@ -502,31 +507,51 @@ void fraHDNesImp::loadScreenTiles(){
}

for(unsigned int i = 0; i < vid->packSize; i++){
if(vid->editData[i] != BAD_ADDRESS){
for(unsigned int j = 0; j < vid->etiledata[vid->editData[i]].bitmapP.size(); j++){
if((vid->etiledata[vid->editData[i]].bitmapP[j].bitmapID == cboScreen->GetSelection()) || (cboScreen->GetSelection() == (cboScreen->GetCount() - 1))){
c = vid->etiledata[vid->editData[i]].bitmapP[j];
b.bitmapID = c.bitmapID;
b.colors = c.colors;
b.rawDat = c.rawDat;
b.patternAddress = vid->etiledata[vid->editData[i]].patternAddress;
b.x = c.x;
b.y = c.y;
b.brightness = c.brightness;
v.push_back(b);
if(chkShowAllTiles->GetValue() && (cboScreen->GetSelection() != (cboScreen->GetCount() - 1))){
if(vid->allEditData[i] != BAD_ADDRESS){
for(unsigned int j = 0; j < vid->allEtiledata[vid->allEditData[i]].bitmapP.size(); j++){
if(vid->allEtiledata[vid->allEditData[i]].bitmapP[j].bitmapID == cboScreen->GetSelection()){
c = vid->allEtiledata[vid->allEditData[i]].bitmapP[j];
b.bitmapID = c.bitmapID;
b.colors = c.colors;
b.rawDat = c.rawDat;
b.patternAddress = vid->allEtiledata[vid->allEditData[i]].patternAddress;
b.x = c.x;
b.y = c.y;
b.brightness = c.brightness;
v.push_back(b);
}
}
}
}
else{
if(vid->editData[i] != BAD_ADDRESS){
for(unsigned int j = 0; j < vid->etiledata[vid->editData[i]].bitmapP.size(); j++){
if((vid->etiledata[vid->editData[i]].bitmapP[j].bitmapID == cboScreen->GetSelection()) || (cboScreen->GetSelection() == (cboScreen->GetCount() - 1))){
c = vid->etiledata[vid->editData[i]].bitmapP[j];
b.bitmapID = c.bitmapID;
b.colors = c.colors;
b.rawDat = c.rawDat;
b.patternAddress = vid->etiledata[vid->editData[i]].patternAddress;
b.x = c.x;
b.y = c.y;
b.brightness = c.brightness;
v.push_back(b);
}
}
}
}
}

if(v.size() > 0){
screenTileCache = (bitmapE*)malloc(v.size() * sizeof(bitmapE));
for(unsigned int i = 0; i < v.size(); i++){
bool tileFound = false;
screenTileCache[i] = v[i];
tiledisplay = to_string((long double)(screenTileCache[i].patternAddress)) + "," + vid->GetPaletteString(screenTileCache[i].colors);
//check for custom tile
if(vid->packData[v[i].patternAddress] != BAD_ADDRESS){
TileData t = vid->tdata[vid->packData[v[i].patternAddress]];
bool tileFound = false;
for(unsigned int j = 0; j < t.bitmapP.size(); j++){
if(t.bitmapP[j].colors.colorValues == v[i].colors.colorValues){
if(romDat->chrPageCount > 0){
Expand All @@ -544,10 +569,16 @@ void fraHDNesImp::loadScreenTiles(){
}
}
}
if(t.defaultID != -1 && !tileFound){
tiledisplay = tiledisplay + "-> Using default";
if(!tileFound){
if(t.defaultID != -1){
tiledisplay = tiledisplay + "-> Using default";
tileFound = true;
}
}
}
if(!tileFound && cboScreen->GetSelection() == (cboScreen->GetCount() - 1)){
tiledisplay = tiledisplay + " @ " + vid->screenFileNameList[v[i].bitmapID];
}
lstScreenTiles->Append(wxString(tiledisplay.c_str(), wxConvUTF8), &screenTileCache[i]);
}
}
Expand Down
2 changes: 2 additions & 0 deletions hdnes/fraHDNesImp.h
Expand Up @@ -79,6 +79,8 @@ class fraHDNesImp :
void toggleAudioPack( wxCommandEvent& event );
void removeImageFromPack( wxCommandEvent& event );
void AddDarkMapping( wxCommandEvent& event );
void toggleShowAllTiles( wxCommandEvent& event );


public:
fraHDNesImp();
Expand Down
5 changes: 5 additions & 0 deletions wxwidget/formHDNes.cpp
Expand Up @@ -663,6 +663,9 @@ fraHDNes::fraHDNes( wxWindow* parent, wxWindowID id, const wxString& title, cons
optPackScale4 = new wxRadioButton( m_panel7, wxID_ANY, wxT("4x"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer39->Add( optPackScale4, 0, wxALL, 5 );

chkShowAllTiles = new wxCheckBox( m_panel7, wxID_ANY, wxT("Show all tiles in the screen shot"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer39->Add( chkShowAllTiles, 0, wxALL, 5 );


bSizer341->Add( bSizer39, 0, 0, 5 );

Expand Down Expand Up @@ -1103,6 +1106,7 @@ fraHDNes::fraHDNes( wxWindow* parent, wxWindowID id, const wxString& title, cons
optPackScale1->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( fraHDNes::setPackScale ), NULL, this );
optPackScale2->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( fraHDNes::setPackScale ), NULL, this );
optPackScale4->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( fraHDNes::setPackScale ), NULL, this );
chkShowAllTiles->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( fraHDNes::toggleShowAllTiles ), NULL, this );
cboScreen->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( fraHDNes::showScreenShot ), NULL, this );
btnOptimizeScreenEdit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( fraHDNes::optimizeScreenEdit ), NULL, this );
lstScreenTiles->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( fraHDNes::screenTileSelected ), NULL, this );
Expand Down Expand Up @@ -1169,6 +1173,7 @@ fraHDNes::~fraHDNes()
optPackScale1->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( fraHDNes::setPackScale ), NULL, this );
optPackScale2->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( fraHDNes::setPackScale ), NULL, this );
optPackScale4->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( fraHDNes::setPackScale ), NULL, this );
chkShowAllTiles->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( fraHDNes::toggleShowAllTiles ), NULL, this );
cboScreen->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( fraHDNes::showScreenShot ), NULL, this );
btnOptimizeScreenEdit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( fraHDNes::optimizeScreenEdit ), NULL, this );
lstScreenTiles->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( fraHDNes::screenTileSelected ), NULL, this );
Expand Down

0 comments on commit 5829aa5

Please sign in to comment.