89 |
cycrow |
1 |
//#include "stdafx.h"
|
|
|
2 |
#include "CommandSlots.h"
|
|
|
3 |
#include "../../common/spknet.h"
|
|
|
4 |
|
|
|
5 |
namespace PluginManager {
|
|
|
6 |
|
|
|
7 |
void CommandSlots::updateCommands()
|
|
|
8 |
{
|
|
|
9 |
this->listView1->Items->Clear();
|
|
|
10 |
this->listView1->Groups->Clear();
|
|
|
11 |
|
|
|
12 |
CLinkList<SCommandSlot> list;
|
|
|
13 |
|
|
|
14 |
if ( _pPackages->readCommands(0, list) ) {
|
|
|
15 |
_updateCommands(list, this->listView1);
|
|
|
16 |
_updateCommandConflicts(list, false);
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
list.clear(true);
|
|
|
20 |
if ( _pPackages->readWingCommands(0, list) ) {
|
|
|
21 |
_updateCommands(list, this->listView2);
|
|
|
22 |
_updateCommandConflicts(list, true);
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
26 |
this->listView2->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
27 |
this->listView3->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
void CommandSlots::_updateCommands(CLinkList<SCommandSlot> &list, ListView ^listView)
|
|
|
31 |
{
|
|
|
32 |
for(SCommandSlot *slot = list.First(); slot; slot = list.Next()) {
|
|
|
33 |
System::String ^group = _commandType(slot->slot);
|
|
|
34 |
|
|
|
35 |
ListViewGroup ^g = nullptr;
|
|
|
36 |
for(int i = 0; i < listView->Groups->Count; i++) {
|
|
|
37 |
if ( String::Compare(listView->Groups[i]->ToString(), group) == 0 ) {
|
|
|
38 |
g = listView->Groups[i];
|
|
|
39 |
break;
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
if ( !g ) {
|
|
|
44 |
g = gcnew ListViewGroup(group);
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
listView->Groups->Add(g);
|
|
|
48 |
|
|
|
49 |
ListViewItem ^item = gcnew ListViewItem(Convert::ToString(slot->slot));
|
|
|
50 |
item->SubItems->Add(_US(slot->name));
|
170 |
cycrow |
51 |
item->SubItems->Add(_US(slot->package->getFullPackageName(_pPackages->GetLanguage())));
|
89 |
cycrow |
52 |
item->SubItems->Add(_US(slot->shortName));
|
|
|
53 |
item->SubItems->Add(_US(slot->info));
|
|
|
54 |
item->SubItems->Add(_US(slot->id));
|
|
|
55 |
item->Group = g;
|
|
|
56 |
item->ImageIndex = _commandIcon(slot->slot);
|
|
|
57 |
|
|
|
58 |
listView->Items->Add(item);
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
void CommandSlots::_updateCommandConflicts(CLinkList<SCommandSlot> &list, bool bWing)
|
|
|
63 |
{
|
|
|
64 |
for(SCommandSlot *slot = list.First(); slot; slot = list.Next()) {
|
|
|
65 |
System::String ^group = _commandSlot(slot->slot, bWing);
|
|
|
66 |
|
|
|
67 |
ListViewGroup ^g = nullptr;
|
|
|
68 |
int c = this->listView3->Groups->Count;
|
|
|
69 |
for(int i = 0; i < this->listView3->Groups->Count; i++) {
|
|
|
70 |
if ( String::Compare(this->listView3->Groups[i]->ToString(), group) == 0 ) {
|
|
|
71 |
g = this->listView3->Groups[i];
|
|
|
72 |
for(int j = 0; j < g->Items->Count; j++) {
|
|
|
73 |
g->Items[j]->ImageIndex = 14;
|
|
|
74 |
}
|
|
|
75 |
break;
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
bool bConflict = (g != nullptr);
|
|
|
80 |
if ( !g ) {
|
|
|
81 |
g = gcnew ListViewGroup(group);
|
|
|
82 |
this->listView3->Groups->Add(g);
|
|
|
83 |
}
|
|
|
84 |
|
170 |
cycrow |
85 |
ListViewItem ^item = gcnew ListViewItem(_US(slot->package->getFullPackageName(_pPackages->GetLanguage())));
|
89 |
cycrow |
86 |
item->SubItems->Add(_US(slot->name));
|
|
|
87 |
item->SubItems->Add(_US(slot->info));
|
|
|
88 |
item->ImageIndex = (bConflict) ? 14 : 13;
|
|
|
89 |
item->Group = g;
|
|
|
90 |
this->listView3->Items->Add(item);
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
System::String ^CommandSlots::_commandSlot(int id, bool bWing)
|
|
|
95 |
{
|
|
|
96 |
int type = id / 100;
|
|
|
97 |
int s = id % 100;
|
|
|
98 |
|
|
|
99 |
System::String ^slot = "COMMAND_";
|
|
|
100 |
if ( bWing ) slot += "WING_";
|
|
|
101 |
slot += _commandType(id)->ToUpper();
|
|
|
102 |
slot += "_";
|
|
|
103 |
if ( id >= 1400 )
|
|
|
104 |
slot += Convert::ToString(id - 1400);
|
|
|
105 |
else
|
|
|
106 |
slot += Convert::ToString(s);
|
|
|
107 |
|
|
|
108 |
return slot;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
System::String ^CommandSlots::_commandType(int id)
|
|
|
112 |
{
|
|
|
113 |
int type = id / 100;
|
|
|
114 |
switch(type) {
|
|
|
115 |
case 2: return "Navigation";
|
|
|
116 |
case 3: return "Fight";
|
|
|
117 |
case 4: return "Trade";
|
|
|
118 |
case 5: return "Special";
|
|
|
119 |
case 6: return "Priacy";
|
|
|
120 |
case 7: return "Custom";
|
|
|
121 |
case 8: return "General";
|
|
|
122 |
case 9: return "Turret";
|
|
|
123 |
case 11: return "Station";
|
|
|
124 |
case 12: return "Ship";
|
|
|
125 |
case 13: return "Fleet";
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
return "Additional";
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
int CommandSlots::_commandIcon(int id)
|
|
|
132 |
{
|
|
|
133 |
int type = id / 100;
|
|
|
134 |
|
|
|
135 |
if ( type <= 13 ) return type - 2;
|
|
|
136 |
|
|
|
137 |
return 12;
|
|
|
138 |
}
|
|
|
139 |
}
|