Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 9cfa8bb

Browse files
committed
Show difficulty count
1 parent cb660c8 commit 9cfa8bb

File tree

6 files changed

+166
-9
lines changed

6 files changed

+166
-9
lines changed

src/rameditwidgets/objecteditwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected slots:
3737
void setName();
3838
void setComment();
3939

40-
void objectChanged(RamObject *o);
40+
void objectChanged(RamObject *o = nullptr);
4141

4242
void checkPath();
4343

src/rameditwidgets/stepeditwidget.cpp

Lines changed: 133 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@ RamStep *StepEditWidget::step() const
2727

2828
void 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);

src/rameditwidgets/stepeditwidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "duqf-widgets/duqffolderdisplaywidget.h"
1414
#include "duqf-widgets/duqfcolorselector.h"
1515
#include "objectlistwidget.h"
16+
#include "progresswidget.h"
1617

1718
class StepEditWidget : public ObjectEditWidget
1819
{
@@ -52,7 +53,12 @@ private slots:
5253
DuComboBox *ui_typeBox;
5354
QWidget *ui_estimationWidget;
5455
QWidget *ui_statesWidget;
56+
QWidget *ui_completionWidget;
57+
ProgressWidget *ui_progressWidget;
58+
QLabel *ui_completionLabel;
59+
QWidget *ui_difficultiesWidget;
5560
QFormLayout *ui_statesLayout;
61+
QFormLayout *ui_difficultiesLayout;
5662
DuComboBox *ui_estimationTypeBox;
5763
QLabel *ui_estimationTypeLabel;
5864
DuQFTextEdit *ui_publishSettingsEdit;

src/ramobjects/ramstatus.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class RamStatus : public RamObject
104104

105105
QString restoreVersionFile(QString fileName) const;
106106

107-
virtual QString name() const;
108-
virtual QString shortName() const;
107+
virtual QString name() const override;
108+
virtual QString shortName() const override;
109109

110110
virtual QString previewImagePath() const override;
111111

src/ramobjects/ramstep.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "ramworkingfolder.h"
1111
#include "stepeditwidget.h"
1212
#include "ramshot.h"
13+
#include "ramses.h"
1314

1415
// STATIC //
1516

@@ -206,6 +207,27 @@ QVector<RamStep::StateCount> RamStep::stateCount()
206207
return count;
207208
}
208209

210+
QMap<RamStatus::Difficulty, int> RamStep::difficultyCount()
211+
{
212+
QMap<RamStatus::Difficulty, int> difficulty;
213+
214+
RamProject *proj = project();
215+
if (!proj) return difficulty;
216+
217+
RamState *noState = Ramses::instance()->noState();
218+
219+
const QSet<RamStatus*> status = proj->stepStatus(this);
220+
for(auto st: status) {
221+
if (noState->is(st->state()))
222+
continue;
223+
RamStatus::Difficulty d = st->difficulty();
224+
int c = difficulty.value(d, 0);
225+
difficulty.insert(d, c+1);
226+
}
227+
228+
return difficulty;
229+
}
230+
209231
QVector<float> RamStep::stats(RamUser *user)
210232
{
211233
float estim = estimation();

src/ramobjects/ramstep.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <QDesktopServices>
55

66
#include "ramtemplatestep.h"
7+
#include "ramstatus.h"
78

89
class RamAssetGroup;
910
class RamProject;
@@ -48,6 +49,7 @@ class RamStep : public RamTemplateStep
4849
float neededDays() ;
4950

5051
QVector<StateCount> stateCount();
52+
QMap<RamStatus::Difficulty,int> difficultyCount();
5153

5254
/**
5355
* @brief stats

0 commit comments

Comments
 (0)