-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAliasDialog.cpp
152 lines (131 loc) · 3.69 KB
/
AliasDialog.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Statsgen Includes
#include "AliasDialog.h"
#include "GenericOKCancelDialog.h"
#include "GlobalStatistics.h"
BEGIN_EVENT_TABLE(AliasDialog, GenericOKCancelDialog)
EVT_BUTTON(WINDOW_ID_BUTTON_AUTO,AliasDialog::OnAuto)
END_EVENT_TABLE()
AliasDialog::AliasDialog(wxWindow *parent,
wxWindowID id,
const wxString &title,
const wxPoint &pos,
const wxSize &size,
long style,
const wxString &name) : GenericOKCancelDialog
(parent,
id,
title,
pos,
size,
style,
name)
{
panel=new AliasEditorPanel();
panel->Create(this,
-1,
wxDefaultPosition,
wxDefaultSize);
}
bool AliasDialog::DisplayDialog()
{
return (GenericOKCancelDialog::DisplayDialog((wxPanel *)panel));
}
AliasDialog::~AliasDialog()
{
}
void AliasDialog::CreateDialog()
{
wxString label="Generic Configuration";
wxString defaultValue="";
wxString configKey;
wxSizeEvent event;
wxPoint configItemsPosition=wxDefaultPosition;
wxSize configItemsSize=wxDefaultSize;
STATSGEN_DEBUG_FUNCTION_START("AliasDialog","CreateDialog")
autoButton.Create(this,
WINDOW_ID_BUTTON_AUTO,
_T(WINDOW_ID_BUTTON_AUTO_TEXT),
wxDefaultPosition);
GenericOKCancelDialog::CreateDialog();
//OnResize(event);
STATSGEN_DEBUG_FUNCTION_END
}
void AliasDialog::OnResize(wxSizeEvent &event)
{
wxString msg;
int saveWidth;
wxSize itemSize;
wxPoint itemPosition;
STATSGEN_DEBUG_FUNCTION_START("AliasDialog","OnResize")
GenericOKCancelDialog::OnResize(event);
STATSGEN_DEBUG(DEBUG_ALWAYS,"Generic Resize Done")
// Auto button
itemSize=quitButton.GetSize();
itemPosition=quitButton.GetPosition();
itemPosition.x+=(itemSize.GetWidth()+BUTTON_WIDTH_GAP);
STATSGEN_DEBUG_CODE(msg.Printf("AUTO POSITION X=[%d] Y=[%d]",itemPosition.x,itemPosition.y);)
STATSGEN_DEBUG(DEBUG_ALWAYS,msg);
itemSize=autoButton.GetSize();
STATSGEN_DEBUG_CODE(msg.Printf("AUTO SIZE=[%d] HEIGHT=[%d]",itemSize.GetWidth(),itemSize.GetWidth());)
STATSGEN_DEBUG(DEBUG_ALWAYS,msg);
autoButton.SetPosition(itemPosition);
STATSGEN_DEBUG_FUNCTION_END
}
void AliasDialog::OnAuto(wxCommandEvent &event)
{
wxString msg;
wxArrayInt shownPlayers;
PlayerCacheEntry cacheEntry;
int cacheIndex;
int shownIndex;
int shownCount;
ArrayOfPlayerCacheEntry shownPlayerCache;
wxString parentGUID;
wxString parentName;
wxString childGUID;
wxString childName;
AliasListEntry aliasEntry;
panel->GetShownPlayers(shownPlayers);
shownCount=shownPlayers.GetCount();
for (shownIndex=0;shownIndex<shownCount;shownIndex++)
{
cacheIndex=shownPlayers.Item(shownIndex);
cacheEntry=globalStatistics.playerCache.Item(cacheIndex);
shownPlayerCache.Add(cacheEntry);
}
shownPlayerCache.Sort(PlayerCacheEntry::GUIDCompare);
parentGUID="";
parentName="";
for (shownIndex=0;shownIndex<shownCount;shownIndex++)
{
cacheEntry=shownPlayerCache.Item(shownIndex);
childGUID=cacheEntry.guid;
childName=cacheEntry.name;
if (parentGUID.Cmp(childGUID)!=0)
{
// this guid is different from the current parent
// so it must be a new parent
parentGUID=childGUID;
parentName=childName;
}
// We need to add an alias for the parent and child now
aliasEntry.primaryGUID=parentGUID;
aliasEntry.primaryName=parentName;
aliasEntry.aliasGUID=childGUID;
aliasEntry.aliasName=childName;
globalStatistics.AddAlias(aliasEntry);
}
panel->RefreshAliasTree();
// TEMP FOR TEST
//globalStatistics.WriteAliasList();
//globalStatistics.configData.CommitChanges();
// TEMP FOR TEST
}
void AliasDialog::OnSave(wxCommandEvent &event)
{
wxString msg;
// Write the Alias List to disk
globalStatistics.WriteAliasList();
// Do any standard Save
GenericOKCancelDialog::OnSave(event);
}