2020-07-30 11:42:28 -03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// This file is part of Remere's Map Editor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Remere's Map Editor is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Remere's Map Editor is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-06-29 16:44:26 +02:00
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
#include "dat_debug_view.h"
|
|
|
|
|
|
|
|
|
|
#include "graphics.h"
|
|
|
|
|
#include "gui.h"
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
2016-09-29 19:24:45 -03:00
|
|
|
//
|
2012-06-29 16:44:26 +02:00
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
class DatDebugViewListBox : public wxVListBox {
|
2012-06-29 16:44:26 +02:00
|
|
|
public:
|
|
|
|
|
DatDebugViewListBox(wxWindow* parent, wxWindowID id);
|
|
|
|
|
~DatDebugViewListBox();
|
2016-09-29 19:24:45 -03:00
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void OnDrawItem(wxDC &dc, const wxRect &rect, size_t index) const;
|
2012-06-29 16:44:26 +02:00
|
|
|
wxCoord OnMeasureItem(size_t index) const;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
typedef std::map<int, Sprite*> SpriteMap;
|
|
|
|
|
SpriteMap sprites;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DatDebugViewListBox::DatDebugViewListBox(wxWindow* parent, wxWindowID id) :
|
2023-10-09 19:12:16 -07:00
|
|
|
wxVListBox(parent, id, wxDefaultPosition, wxDefaultSize, wxLB_SINGLE) {
|
2012-06-29 16:44:26 +02:00
|
|
|
int n = 0;
|
2023-10-09 19:12:16 -07:00
|
|
|
for (int id = 0; id < g_gui.gfx.getItemSpriteMaxID(); ++id) {
|
2016-09-29 20:30:54 -03:00
|
|
|
Sprite* spr = g_gui.gfx.getSprite(id);
|
2023-10-09 19:12:16 -07:00
|
|
|
if (spr) {
|
2012-06-29 16:44:26 +02:00
|
|
|
sprites[n] = spr;
|
|
|
|
|
++n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SetItemCount(n);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
DatDebugViewListBox::~DatDebugViewListBox() {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void DatDebugViewListBox::OnDrawItem(wxDC &dc, const wxRect &rect, size_t n) const {
|
2012-06-29 16:44:26 +02:00
|
|
|
SpriteMap::const_iterator spr_iter = sprites.find(int(n));
|
2023-10-09 19:12:16 -07:00
|
|
|
if (spr_iter != sprites.end()) {
|
2012-06-29 16:44:26 +02:00
|
|
|
spr_iter->second->DrawTo(&dc, SPRITE_SIZE_32x32, rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight());
|
2023-10-09 19:12:16 -07:00
|
|
|
}
|
2012-06-29 16:44:26 +02:00
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
if (IsSelected(n)) {
|
|
|
|
|
if (HasFocus()) {
|
2016-03-17 07:09:40 -03:00
|
|
|
dc.SetTextForeground(wxColor(0xFF, 0xFF, 0xFF));
|
2023-10-09 19:12:16 -07:00
|
|
|
} else {
|
2016-03-17 07:09:40 -03:00
|
|
|
dc.SetTextForeground(wxColor(0x00, 0x00, 0xFF));
|
2023-10-09 19:12:16 -07:00
|
|
|
}
|
2015-12-06 11:42:37 -03:00
|
|
|
} else {
|
2012-06-29 16:44:26 +02:00
|
|
|
dc.SetTextForeground(wxColor(0x00, 0x00, 0x00));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dc.DrawText(wxString() << n, rect.GetX() + 40, rect.GetY() + 6);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
wxCoord DatDebugViewListBox::OnMeasureItem(size_t n) const {
|
2012-06-29 16:44:26 +02:00
|
|
|
return 32;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
2016-09-29 19:24:45 -03:00
|
|
|
//
|
2012-06-29 16:44:26 +02:00
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(DatDebugView, wxPanel)
|
2023-10-09 19:12:16 -07:00
|
|
|
EVT_TEXT(wxID_ANY, DatDebugView::OnTextChange)
|
|
|
|
|
EVT_LISTBOX_DCLICK(wxID_ANY, DatDebugView::OnClickList)
|
2012-06-29 16:44:26 +02:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
DatDebugView::DatDebugView(wxWindow* parent) :
|
|
|
|
|
wxPanel(parent) {
|
2023-10-15 21:52:40 +00:00
|
|
|
std::shared_ptr<wxSizer> sizer = newd<wxBoxSizer>(wxVERTICAL);
|
2012-06-29 16:44:26 +02:00
|
|
|
|
2023-10-15 18:51:57 -03:00
|
|
|
search_field = newd<wxTextCtrl>(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize);
|
2012-06-29 16:44:26 +02:00
|
|
|
search_field->SetFocus();
|
2023-10-15 18:51:57 -03:00
|
|
|
sizer->Add(search_field.get(), 0, wxEXPAND, 2);
|
2012-06-29 16:44:26 +02:00
|
|
|
|
2023-10-15 18:51:57 -03:00
|
|
|
item_list = newd<DatDebugViewListBox>(this, wxID_ANY);
|
2012-06-29 16:44:26 +02:00
|
|
|
item_list->SetMinSize(wxSize(470, 400));
|
2023-10-15 18:51:57 -03:00
|
|
|
sizer->Add(item_list.get(), 1, wxEXPAND | wxALL, 2);
|
2012-06-29 16:44:26 +02:00
|
|
|
|
2023-10-15 18:51:57 -03:00
|
|
|
SetSizerAndFit(sizer.get());
|
2016-02-29 21:47:54 -03:00
|
|
|
Centre(wxBOTH);
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
DatDebugView::~DatDebugView() {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void DatDebugView::OnTextChange(wxCommandEvent &evt) {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void DatDebugView::OnClickList(wxCommandEvent &evt) {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|