-
Notifications
You must be signed in to change notification settings - Fork 224
/
dat_debug_view.cpp
122 lines (99 loc) · 3.25 KB
/
dat_debug_view.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//////////////////////////////////////////////////////////////////////
// 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/>.
//////////////////////////////////////////////////////////////////////
#include "main.h"
#include "dat_debug_view.h"
#include "graphics.h"
#include "gui.h"
// ============================================================================
//
class DatDebugViewListBox : public wxVListBox
{
public:
DatDebugViewListBox(wxWindow* parent, wxWindowID id);
~DatDebugViewListBox();
void OnDrawItem(wxDC& dc, const wxRect& rect, size_t index) const;
wxCoord OnMeasureItem(size_t index) const;
protected:
typedef std::map<int, Sprite*> SpriteMap;
SpriteMap sprites;
};
DatDebugViewListBox::DatDebugViewListBox(wxWindow* parent, wxWindowID id) :
wxVListBox(parent, id, wxDefaultPosition, wxDefaultSize, wxLB_SINGLE)
{
int n = 0;
for(int id = 0; id < g_gui.gfx.getItemSpriteMaxID(); ++id) {
Sprite* spr = g_gui.gfx.getSprite(id);
if(spr) {
sprites[n] = spr;
++n;
}
}
SetItemCount(n);
}
DatDebugViewListBox::~DatDebugViewListBox()
{
////
}
void DatDebugViewListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
{
SpriteMap::const_iterator spr_iter = sprites.find(int(n));
if(spr_iter != sprites.end())
spr_iter->second->DrawTo(&dc, SPRITE_SIZE_32x32, rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight());
if(IsSelected(n)) {
if(HasFocus())
dc.SetTextForeground(wxColor(0xFF, 0xFF, 0xFF));
else
dc.SetTextForeground(wxColor(0x00, 0x00, 0xFF));
} else {
dc.SetTextForeground(wxColor(0x00, 0x00, 0x00));
}
dc.DrawText(wxString() << n, rect.GetX() + 40, rect.GetY() + 6);
}
wxCoord DatDebugViewListBox::OnMeasureItem(size_t n) const
{
return 32;
}
// ============================================================================
//
BEGIN_EVENT_TABLE(DatDebugView, wxPanel)
EVT_TEXT(wxID_ANY, DatDebugView::OnTextChange)
EVT_LISTBOX_DCLICK(wxID_ANY, DatDebugView::OnClickList)
END_EVENT_TABLE()
DatDebugView::DatDebugView(wxWindow* parent) : wxPanel(parent)
{
wxSizer* sizer = newd wxBoxSizer(wxVERTICAL);
search_field = newd wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize);
search_field->SetFocus();
sizer->Add(search_field, 0, wxEXPAND, 2);
item_list = newd DatDebugViewListBox(this, wxID_ANY);
item_list->SetMinSize(wxSize(470, 400));
sizer->Add(item_list, 1, wxEXPAND | wxALL, 2);
SetSizerAndFit(sizer);
Centre(wxBOTH);
}
DatDebugView::~DatDebugView()
{
////
}
void DatDebugView::OnTextChange(wxCommandEvent& evt)
{
////
}
void DatDebugView::OnClickList(wxCommandEvent& evt)
{
////
}