Fix `Save` button on Tile Viewer for GB and GBA.
For some reason this was not implemented yet.
This commit is contained in:
parent
d05e8fc141
commit
dcaa1b9abc
|
@ -1582,6 +1582,44 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SaveGBATile(wxCommandEvent& ev)
|
||||||
|
{
|
||||||
|
(void)ev; // unused params
|
||||||
|
GameArea* panel = wxGetApp().frame->GetPanel();
|
||||||
|
wxString bmp_save_dir = wxGetApp().frame->GetGamePath(gopts.scrshot_dir);
|
||||||
|
// no attempt is made here to translate the dialog type name
|
||||||
|
// it's just a suggested name, anyway
|
||||||
|
wxString def_name = panel->game_name() + wxT('-') + dname;
|
||||||
|
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
||||||
|
|
||||||
|
if (captureFormat)
|
||||||
|
def_name += wxT(".bmp");
|
||||||
|
else
|
||||||
|
def_name += wxT(".png");
|
||||||
|
|
||||||
|
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
||||||
|
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
|
dlg.SetFilterIndex(captureFormat);
|
||||||
|
int ret = dlg.ShowModal();
|
||||||
|
bmp_save_dir = dlg.GetDirectory();
|
||||||
|
|
||||||
|
if (ret != wxID_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxBitmap obmp = gv->bm->GetSubBitmap(wxRect(0, 0, gv->bmw, gv->bmh));
|
||||||
|
wxString fn = dlg.GetPath();
|
||||||
|
wxBitmapType fmt = dlg.GetFilterIndex() ? wxBITMAP_TYPE_BMP : wxBITMAP_TYPE_PNG;
|
||||||
|
|
||||||
|
if (fn.size() > 4) {
|
||||||
|
if (wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".bmp"), false))
|
||||||
|
fmt = wxBITMAP_TYPE_BMP;
|
||||||
|
else if (wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".png"), false))
|
||||||
|
fmt = wxBITMAP_TYPE_PNG;
|
||||||
|
}
|
||||||
|
|
||||||
|
obmp.SaveFile(fn, fmt);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int charbase, is256, palette;
|
int charbase, is256, palette;
|
||||||
wxControl *tileno, *addr;
|
wxControl *tileno, *addr;
|
||||||
|
@ -1591,6 +1629,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(TileViewer, GfxViewer)
|
BEGIN_EVENT_TABLE(TileViewer, GfxViewer)
|
||||||
|
EVT_BUTTON(XRCID("SaveGBATile"), TileViewer::SaveGBATile)
|
||||||
EVT_GFX_CLICK(wxID_ANY, TileViewer::UpdateMouseInfoEv)
|
EVT_GFX_CLICK(wxID_ANY, TileViewer::UpdateMouseInfoEv)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
@ -1685,6 +1724,44 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SaveGBTile(wxCommandEvent& ev)
|
||||||
|
{
|
||||||
|
(void)ev; // unused params
|
||||||
|
GameArea* panel = wxGetApp().frame->GetPanel();
|
||||||
|
wxString bmp_save_dir = wxGetApp().frame->GetGamePath(gopts.scrshot_dir);
|
||||||
|
// no attempt is made here to translate the dialog type name
|
||||||
|
// it's just a suggested name, anyway
|
||||||
|
wxString def_name = panel->game_name() + wxT('-') + dname;
|
||||||
|
def_name.resize(def_name.size() - 6); // strlen("Viewer")
|
||||||
|
|
||||||
|
if (captureFormat)
|
||||||
|
def_name += wxT(".bmp");
|
||||||
|
else
|
||||||
|
def_name += wxT(".png");
|
||||||
|
|
||||||
|
wxFileDialog dlg(GetGrandParent(), _("Select output file"), bmp_save_dir, def_name,
|
||||||
|
_("PNG images|*.png|BMP images|*.bmp"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
|
dlg.SetFilterIndex(captureFormat);
|
||||||
|
int ret = dlg.ShowModal();
|
||||||
|
bmp_save_dir = dlg.GetDirectory();
|
||||||
|
|
||||||
|
if (ret != wxID_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxBitmap obmp = gv->bm->GetSubBitmap(wxRect(0, 0, gv->bmw, gv->bmh));
|
||||||
|
wxString fn = dlg.GetPath();
|
||||||
|
wxBitmapType fmt = dlg.GetFilterIndex() ? wxBITMAP_TYPE_BMP : wxBITMAP_TYPE_PNG;
|
||||||
|
|
||||||
|
if (fn.size() > 4) {
|
||||||
|
if (wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".bmp"), false))
|
||||||
|
fmt = wxBITMAP_TYPE_BMP;
|
||||||
|
else if (wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".png"), false))
|
||||||
|
fmt = wxBITMAP_TYPE_PNG;
|
||||||
|
}
|
||||||
|
|
||||||
|
obmp.SaveFile(fn, fmt);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int bank, charbase, palette;
|
int bank, charbase, palette;
|
||||||
wxControl *addr, *tileno;
|
wxControl *addr, *tileno;
|
||||||
|
@ -1694,6 +1771,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(GBTileViewer, GfxViewer)
|
BEGIN_EVENT_TABLE(GBTileViewer, GfxViewer)
|
||||||
|
EVT_BUTTON(XRCID("SaveGBTile"), GBTileViewer::SaveGBTile)
|
||||||
EVT_GFX_CLICK(wxID_ANY, GBTileViewer::UpdateMouseInfoEv)
|
EVT_GFX_CLICK(wxID_ANY, GBTileViewer::UpdateMouseInfoEv)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
<border>5</border>
|
<border>5</border>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
<object class="wxButton" name="wxID_SAVE">
|
<object class="wxButton" name="SaveGBTile">
|
||||||
<label>_Save...</label>
|
<label>_Save...</label>
|
||||||
</object>
|
</object>
|
||||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||||
|
|
|
@ -164,7 +164,7 @@
|
||||||
<border>5</border>
|
<border>5</border>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
<object class="wxButton" name="wxID_SAVE">
|
<object class="wxButton" name="SaveGBATile">
|
||||||
<label>_Save...</label>
|
<label>_Save...</label>
|
||||||
</object>
|
</object>
|
||||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||||
|
|
Loading…
Reference in New Issue