@@ -27,10 +27,19 @@ RamStep *StepEditWidget::step() const
2727
2828void StepEditWidget::reInit (RamObject *obj)
2929{
30+ bool same = m_step == obj;
31+
3032 m_step = qobject_cast<RamStep*>( obj );
3133
34+ if (!same)
35+ connect (m_step->project (), &RamProject::estimationComputed,
36+ this , [this ](){ reInit (m_step); });
37+
3238 while (ui_statesLayout->rowCount () > 0 )
3339 ui_statesLayout->removeRow (0 );
40+ while (ui_difficultiesLayout->rowCount () > 0 )
41+ ui_difficultiesLayout->removeRow (0 );
42+
3443
3544 if (m_step)
3645 {
@@ -62,14 +71,35 @@ void StepEditWidget::reInit(RamObject *obj)
6271 ui_estimationMultiplierCheckBox->setChecked (true );
6372 ui_estimationMultiplierBox->setObject ( m_step->estimationMultiplyGroup () );
6473 }
74+ else
75+ {
76+ ui_estimationMultiplierBox->setEnabled (false );
77+ ui_estimationMultiplierCheckBox->setChecked (false );
78+ ui_estimationMultiplierBox->setCurrentIndex (-1 );
79+ }
6580
6681 updateEstimationSuffix ();
6782
6883 RamStep::Type stepType = m_step->type ();
6984 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+
70100 const QVector<RamStep::StateCount> stateCount = m_step->stateCount ();
71101 RamState *noState = Ramses::instance ()->noState ();
72- int total = 0 ;
102+ float total = 0 ;
73103
74104 for (const auto count: stateCount) {
75105 int c = count.count ;
@@ -80,24 +110,102 @@ void StepEditWidget::reInit(RamObject *obj)
80110 if (state->is (noState))
81111 continue ;
82112
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> " ;
84140 if (stepType == RamStep::AssetProduction) cStr += " assets" ;
85141 else cStr += " shots" ;
86142
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 ;
90155 total += c;
91156 }
92157
93158 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+
94198 QString cStr = " <b>" +QString::number (total)+" </b> " ;
95199 if (stepType == RamStep::AssetProduction) cStr += " assets" ;
96200 else cStr += " shots" ;
97201
98- ui_statesLayout ->addRow ( " Total" , new QLabel (cStr, this ) );
202+ ui_difficultiesLayout ->addRow ( " Total" , new QLabel (cStr, this ) );
99203 }
100204 }
205+ else
206+ {
207+ ui_completionWidget->hide ();
208+ }
101209 }
102210 else
103211 {
@@ -118,6 +226,7 @@ void StepEditWidget::reInit(RamObject *obj)
118226 ui_estimationMultiplierCheckBox->setChecked (false );
119227 ui_estimationMultiplierBox->setCurrentIndex (-1 );
120228 ui_estimationMultiplierBox->setEnabled (false );
229+ ui_completionWidget->hide ();
121230 }
122231}
123232
@@ -296,10 +405,28 @@ void StepEditWidget::setupUi()
296405 " <b>" +tr (" Status" )+" </b>"
297406 ));
298407
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+
299422 ui_statesWidget = new QWidget (ui_tabWidget);
300423 ui_statesLayout = new QFormLayout (ui_statesWidget);
301424 estimLayout->addWidget (ui_statesWidget);
302425
426+ ui_difficultiesWidget = new QWidget (ui_tabWidget);
427+ ui_difficultiesLayout = new QFormLayout (ui_difficultiesWidget);
428+ estimLayout->addWidget (ui_difficultiesWidget);
429+
303430 estimLayout->addStretch (1 );
304431
305432 QFormLayout *estimationLayout = new QFormLayout (ui_estimationWidget);
0 commit comments