forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsc_SampleProfilesTab.cpp
151 lines (130 loc) · 5.35 KB
/
sc_SampleProfilesTab.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
#include "sc_SampleProfilesTab.hpp"
#include <QDir>
#include "simulationcraftqt.hpp"
SC_SampleProfilesTab::SC_SampleProfilesTab( QWidget* parent ) :
QGroupBox( parent ),
tree( new QTreeWidget( this ) )
{
QStringList headerLabels( tr( "Player Class" ) ); headerLabels += QString( tr( "Location" ) );
tree -> setColumnCount( 1 );
tree -> setHeaderLabels( headerLabels );
tree -> setColumnWidth( 0, 300 );
// Create BiS Introduction
QFormLayout* bisIntroductionFormLayout = new QFormLayout();
QLabel* bisText = new QLabel( tr( "These sample profiles are attempts at creating the best possible gear, talent, and action priority list setups to achieve the highest possible average damage per second.\n"
"The profiles are created with a lot of help from the theorycrafting community.\n"
"They are only as good as the thorough testing done on them, and the feedback and critic we receive from the community, including yourself.\n"
"If you have ideas for improvements, try to simulate them. If they result in increased dps, please open a ticket on our Issue tracker.\n"
"The more people help improve BiS profiles, the better will they reach their goal of representing the highest possible dps." ) );
bisIntroductionFormLayout -> addRow( bisText );
QWidget* bisIntroduction = new QWidget();
bisIntroduction -> setLayout( bisIntroductionFormLayout );
for(const auto& path : SC_PATHS::getDataPaths())
{
QDir baseDir(path + "/profiles");
qDebug() << "Sample Profiles Base Path: " << baseDir.absolutePath() << " exists: " << baseDir.exists();
if ( baseDir.exists() )
{
fillTree( baseDir );
}
}
QVBoxLayout* bisTabLayout = new QVBoxLayout();
bisTabLayout -> addWidget( bisIntroduction, 1 );
bisTabLayout -> addWidget( tree, 9 );
setLayout( bisTabLayout );
}
void SC_SampleProfilesTab::fillTree( QDir baseDir )
{
baseDir.setFilter( QDir::Dirs );
static const char* tierNames[] = { "T22", "T23", "T24", "PR", "DS" };
static const int TIER_MAX = 5; // = sizeof_array( tierNames );
QTreeWidgetItem* playerItems[PLAYER_MAX];
range::fill( playerItems, 0 );
std::array<std::array<QTreeWidgetItem*, TIER_MAX>,PLAYER_MAX> rootItems;
if ( rootItems.size() )
{
for ( size_t i = 0u; i < rootItems.size(); ++i )
{
range::fill( rootItems[i], nullptr );
}
}
QStringList tprofileList = baseDir.entryList();
int tnumProfiles = tprofileList.count();
// Main loop through all subfolders of ./profiles/
for ( int i = 0; i < tnumProfiles; i++ )
{
QDir dir = baseDir.absolutePath() + "/" + tprofileList[ i ];
dir.setSorting( QDir::Name );
dir.setFilter( QDir::Files );
dir.setNameFilters( QStringList( "*.simc" ) );
QStringList profileList = dir.entryList();
int numProfiles = profileList.count();
for ( int k = 0; k < numProfiles; k++ )
{
QString profile = dir.absolutePath() + "/";
profile = QDir::toNativeSeparators( profile );
profile += profileList[k];
player_e player = PLAYER_MAX;
// Hack! For now... Need to decide sim-wide just how the heck we want to refer to DKs.
// Hack²! For now... I didn't know how to add DH :D
if ( profile.contains( "Death_Knight" ) )
player = DEATH_KNIGHT;
else if ( profile.contains( "Demon_Hunter" ) )
player = DEMON_HUNTER;
else
{
for ( player_e j = PLAYER_NONE; j < PLAYER_MAX; j++ )
{
if ( profile.contains( util::player_type_string( j ), Qt::CaseInsensitive ) )
{
player = j;
break;
}
}
}
// exclude generate profiles
if ( profile.contains( "generate" ) )
continue;
int tier = TIER_MAX;
for ( int j = 0; j < TIER_MAX && tier == TIER_MAX; j++ )
if ( profile.contains( tierNames[j] ) )
tier = j;
if ( player != PLAYER_MAX && tier != TIER_MAX )
{
if ( !rootItems[player][tier] )
{
if ( !playerItems[player] )
{
QTreeWidgetItem* top = new QTreeWidgetItem( QStringList( util::inverse_tokenize( util::player_type_string( player ) ).c_str() ) );
playerItems[player] = top;
}
if ( !rootItems[player][tier] )
{
QTreeWidgetItem* tieritem = new QTreeWidgetItem( QStringList( tierNames[tier] ) );
playerItems[player] -> addChild( rootItems[player][tier] = tieritem );
}
}
QTreeWidgetItem* item = new QTreeWidgetItem( QStringList() << profileList[k] << profile );
assert(rootItems[player][tier]);
assert(item);
rootItems[player][tier] -> addChild( item );
}
}
}
// Register all the added profiles ( done here so they show up alphabetically )
for ( player_e i = DEATH_KNIGHT; i <= WARRIOR; i++ )
{
if ( playerItems[i] )
{
tree -> addTopLevelItem( playerItems[i] );
for ( int j = 0; j < TIER_MAX; j++ )
{
if ( rootItems[i][j] )
{
rootItems[i][j] -> setExpanded( true ); // Expand the subclass Tier bullets by default
rootItems[i][j] -> sortChildren( 0, Qt::AscendingOrder );
}
}
}
}
}