@@ -27,10 +27,19 @@ RamStep *StepEditWidget::step() const
27
27
28
28
void StepEditWidget::reInit (RamObject *obj)
29
29
{
30
+ bool same = m_step == obj;
31
+
30
32
m_step = qobject_cast<RamStep*>( obj );
31
33
34
+ if (!same)
35
+ connect (m_step->project (), &RamProject::estimationComputed,
36
+ this , [this ](){ reInit (m_step); });
37
+
32
38
while (ui_statesLayout->rowCount () > 0 )
33
39
ui_statesLayout->removeRow (0 );
40
+ while (ui_difficultiesLayout->rowCount () > 0 )
41
+ ui_difficultiesLayout->removeRow (0 );
42
+
34
43
35
44
if (m_step)
36
45
{
@@ -62,14 +71,35 @@ void StepEditWidget::reInit(RamObject *obj)
62
71
ui_estimationMultiplierCheckBox->setChecked (true );
63
72
ui_estimationMultiplierBox->setObject ( m_step->estimationMultiplyGroup () );
64
73
}
74
+ else
75
+ {
76
+ ui_estimationMultiplierBox->setEnabled (false );
77
+ ui_estimationMultiplierCheckBox->setChecked (false );
78
+ ui_estimationMultiplierBox->setCurrentIndex (-1 );
79
+ }
65
80
66
81
updateEstimationSuffix ();
67
82
68
83
RamStep::Type stepType = m_step->type ();
69
84
if (stepType == RamStep::AssetProduction || stepType == RamStep::ShotProduction) {
85
+ ui_completionWidget->show ();
86
+
87
+ int completion = m_step->completionRatio ();
88
+ ui_progressWidget->setCompletionRatio (completion);
89
+ if (completion > 99 )
90
+ ui_completionLabel->setText (" Finished!" );
91
+ else {
92
+ ui_completionLabel->setText (
93
+ QString (" <i>Completion: <b>%1%</b> (%2 / %3 days)</i>" )
94
+ .arg (completion)
95
+ .arg (int (m_step->daysSpent ()))
96
+ .arg (int (m_step->estimation ()))
97
+ );
98
+ }
99
+
70
100
const QVector<RamStep::StateCount> stateCount = m_step->stateCount ();
71
101
RamState *noState = Ramses::instance ()->noState ();
72
- int total = 0 ;
102
+ float total = 0 ;
73
103
74
104
for (const auto count: stateCount) {
75
105
int c = count.count ;
@@ -80,24 +110,102 @@ void StepEditWidget::reInit(RamObject *obj)
80
110
if (state->is (noState))
81
111
continue ;
82
112
83
- QString cStr = " <b>" +QString::number (c)+" </b> " ;
113
+ total += c;
114
+ }
115
+
116
+ if (total > 0 ) {
117
+
118
+ ui_statesLayout->setWidget ( 0 , QFormLayout::LabelRole, new QLabel (" <b>" +tr (" States:" )+" </b>" ) );
119
+
120
+ for (const auto count: stateCount) {
121
+ float c = count.count ;
122
+ if (c == 0 )
123
+ continue ;
124
+
125
+ RamState *state = count.state ;
126
+ if (state->is (noState))
127
+ continue ;
128
+
129
+ QString cStr = " <b>" +QString::number (c)+" </b> " ;
130
+ if (stepType == RamStep::AssetProduction) cStr += " assets (" ;
131
+ else cStr += " shots (" ;
132
+ cStr += QString::number (int (c/total*100 )) + " %)" ;
133
+
134
+ auto l = new QLabel (state->name (), this );
135
+ l->setStyleSheet (" QLabel { color: " +state->color ().name () + " ; }" );
136
+ ui_statesLayout->addRow ( l, new QLabel (cStr, this ) );
137
+ }
138
+
139
+ QString cStr = " <b>" +QString::number (total)+" </b> " ;
84
140
if (stepType == RamStep::AssetProduction) cStr += " assets" ;
85
141
else cStr += " shots" ;
86
142
87
- auto l = new QLabel (state->name (), this );
88
- l->setStyleSheet (" QLabel { color: " +state->color ().name () + " ; }" );
89
- ui_statesLayout->addRow ( l, new QLabel (cStr, this ) );
143
+ ui_statesLayout->addRow ( " Total" , new QLabel (cStr, this ) );
144
+ }
145
+
146
+ const QMap<RamStatus::Difficulty, int > difficulties = m_step->difficultyCount ();
147
+ total = 0 ;
148
+
149
+ QMapIterator<RamStatus::Difficulty, int > i (difficulties);
150
+ while (i.hasNext ()) {
151
+ i.next ();
152
+ float c = i.value ();
153
+ if (c == 0 )
154
+ continue ;
90
155
total += c;
91
156
}
92
157
93
158
if (total > 0 ) {
159
+
160
+ ui_difficultiesLayout->setWidget ( 0 , QFormLayout::LabelRole, new QLabel (" <b>" +tr (" Difficulty:" )+" </b>" ) );
161
+
162
+ i.toFront ();
163
+ while (i.hasNext ()) {
164
+ i.next ();
165
+ float c = i.value ();
166
+ if (c == 0 )
167
+ continue ;
168
+
169
+ QString cStr = " <b>" +QString::number (c)+" </b> " ;
170
+ if (stepType == RamStep::AssetProduction) cStr += " assets (" ;
171
+ else cStr += " shots (" ;
172
+ cStr += QString::number (int (c/total*100 )) + " %)" ;
173
+
174
+ QString label;
175
+
176
+ switch (i.key ()) {
177
+ case RamStatus::VeryEasy:
178
+ label = tr (" Very easy" );
179
+ break ;
180
+ case RamStatus::Easy:
181
+ label = tr (" Easy" );
182
+ break ;
183
+ case RamStatus::Medium:
184
+ label = tr (" Medium" );
185
+ break ;
186
+ case RamStatus::Hard:
187
+ label = tr (" Hard" );
188
+ break ;
189
+ case RamStatus::VeryHard:
190
+ label = tr (" Very hard" );
191
+ break ;
192
+ }
193
+
194
+ auto l = new QLabel (label, this );
195
+ ui_difficultiesLayout->addRow ( l, new QLabel (cStr, this ) );
196
+ }
197
+
94
198
QString cStr = " <b>" +QString::number (total)+" </b> " ;
95
199
if (stepType == RamStep::AssetProduction) cStr += " assets" ;
96
200
else cStr += " shots" ;
97
201
98
- ui_statesLayout ->addRow ( " Total" , new QLabel (cStr, this ) );
202
+ ui_difficultiesLayout ->addRow ( " Total" , new QLabel (cStr, this ) );
99
203
}
100
204
}
205
+ else
206
+ {
207
+ ui_completionWidget->hide ();
208
+ }
101
209
}
102
210
else
103
211
{
@@ -118,6 +226,7 @@ void StepEditWidget::reInit(RamObject *obj)
118
226
ui_estimationMultiplierCheckBox->setChecked (false );
119
227
ui_estimationMultiplierBox->setCurrentIndex (-1 );
120
228
ui_estimationMultiplierBox->setEnabled (false );
229
+ ui_completionWidget->hide ();
121
230
}
122
231
}
123
232
@@ -296,10 +405,28 @@ void StepEditWidget::setupUi()
296
405
" <b>" +tr (" Status" )+" </b>"
297
406
));
298
407
408
+ ui_completionWidget = new QWidget (this );
409
+ estimLayout->addWidget (ui_completionWidget);
410
+
411
+ auto completionLayout = new QVBoxLayout (ui_completionWidget);
412
+ completionLayout->setContentsMargins (0 ,0 ,0 ,0 );
413
+ completionLayout->setSpacing (1 );
414
+
415
+ ui_progressWidget = new ProgressWidget (this );
416
+ completionLayout->addWidget (ui_progressWidget);
417
+
418
+ ui_completionLabel = new QLabel (this );
419
+ completionLayout->addWidget (ui_completionLabel);
420
+ completionLayout->setAlignment (ui_completionLabel, Qt::AlignCenter);
421
+
299
422
ui_statesWidget = new QWidget (ui_tabWidget);
300
423
ui_statesLayout = new QFormLayout (ui_statesWidget);
301
424
estimLayout->addWidget (ui_statesWidget);
302
425
426
+ ui_difficultiesWidget = new QWidget (ui_tabWidget);
427
+ ui_difficultiesLayout = new QFormLayout (ui_difficultiesWidget);
428
+ estimLayout->addWidget (ui_difficultiesWidget);
429
+
303
430
estimLayout->addStretch (1 );
304
431
305
432
QFormLayout *estimationLayout = new QFormLayout (ui_estimationWidget);
0 commit comments