Fixed the GUI properties for multiplayer view, though the screen is way too full right now. Some changes (to GUI or screen) have to be done!

This commit is contained in:
Bart Cools
2014-06-01 18:29:11 +02:00
parent cdb0e88895
commit 07b6579529
6 changed files with 90 additions and 44 deletions

View File

@@ -38,7 +38,8 @@ using namespace irr;
// -----------------------------------------------------------------------------
KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
std::string kart_group) : Widget(WTYPE_DIV)
std::string kart_group,
bool multiplayer) : Widget(WTYPE_DIV)
{
m_player_id = player_id;
@@ -75,31 +76,31 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
}
const int offset = (m_h - (SKILL_COUNT*m_skill_bar_h)) / 2;;
const int offset = (m_h - (SKILL_COUNT*m_skill_bar_h)) / 2;
for (int i = 0; i < SKILL_COUNT; ++i)
{
irr::core::recti skillArea(m_skill_bar_x, m_skill_bar_y + offset*i,
m_skill_bar_x + m_skill_bar_w,
m_skill_bar_y + offset*i + m_skill_bar_h);
m_skill_bar_y + m_skill_bar_h + offset*i);
SkillLevelWidget* skill_bar = NULL;
skill_bar = new SkillLevelWidget(skillArea, m_player_id);
skill_bar = new SkillLevelWidget(skillArea, m_player_id, multiplayer);
m_skills.push_back(skill_bar);
m_children.push_back(skill_bar);
}
m_skills[SKILL_MASS]->setValue(props->getMass()/10);
m_skills[SKILL_MASS]->setLabel("Weight");
m_skills[SKILL_MASS]->setLabel("WEIGHT");
m_skills[SKILL_MASS]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_mass", m_player_id);
m_skills[SKILL_ACCEL]->setValue(props->getTrackConnectionAccel()/10);
m_skills[SKILL_ACCEL]->setLabel("Accel");
m_skills[SKILL_ACCEL]->setLabel("ACCEL");
m_skills[SKILL_ACCEL]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_accel", m_player_id);
m_skills[SKILL_SPEED]->setValue(props->getMaxSpeed()/10);
m_skills[SKILL_SPEED]->setLabel("Speed");
m_skills[SKILL_SPEED]->setLabel("SPEED");
m_skills[SKILL_SPEED]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_speed", m_player_id);
} // KartStatsWidget
@@ -153,7 +154,7 @@ void KartStatsWidget::setSize(const int x, const int y, const int w, const int h
// -- sizes
m_skill_bar_w = w;
m_skill_bar_h = 100;
m_skill_bar_h = GUIEngine::getTitleFontHeight();
// for shrinking effect
if (h < 175)

View File

@@ -70,7 +70,8 @@ class KartStatsWidget : public Widget
LEAK_CHECK()
KartStatsWidget(core::recti area, const int player_id,
std::string kart_group);
std::string kart_group,
bool multiplayer);
virtual ~KartStatsWidget() {};
// ------------------------------------------------------------------------

View File

@@ -38,7 +38,8 @@ using namespace irr;
// -----------------------------------------------------------------------------
SkillLevelWidget::SkillLevelWidget(core::recti area, const int player_id,
const int value, const stringw& label) : Widget(WTYPE_DIV)
bool multiplayer, const int value,
const stringw& label) : Widget(WTYPE_DIV)
{
m_player_id = player_id;
@@ -59,7 +60,7 @@ SkillLevelWidget::SkillLevelWidget(core::recti area, const int player_id,
m_label = NULL;
m_label = new LabelWidget(true, true);
m_label = new LabelWidget(!multiplayer, true);
m_label->setText(label,false);
m_label->m_x = m_label_x;
@@ -115,9 +116,9 @@ void SkillLevelWidget::setSize(const int x, const int y, const int w, const int
// -- sizes
m_bar_w = w/2;
m_bar_h = GUIEngine::getFontHeight();
m_bar_h = h;
m_label_w = w/2;
m_label_h = GUIEngine::getFontHeight();
m_label_h = h;
// for shrinking effect
if (h < 175)

View File

@@ -62,8 +62,9 @@ class SkillLevelWidget : public Widget
LabelWidget* m_label;
ProgressBarWidget* m_bar;
SkillLevelWidget(core::recti area, const int player_id,
SkillLevelWidget(core::recti area, const int player_id, bool multiplayer,
const int value = 0, const irr::core::stringw& label = "default");
virtual ~SkillLevelWidget() {};
// ------------------------------------------------------------------------
@@ -89,6 +90,12 @@ class SkillLevelWidget : public Widget
/** Change the label of the widget */
void setLabel(const irr::core::stringw& label);
/** Get the current label of the widget. */
const irr::core::stringw& getLabel()
{
return m_label->getText();
}
};
}

View File

@@ -236,13 +236,26 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
m_kart_stats = NULL;
// area for the stats widget
core::recti statsArea(m_kart_stats_x,
m_kart_stats_y,
m_kart_stats_x + m_kart_stats_w,
m_kart_stats_y + m_kart_stats_h);
core::recti statsArea;
if (!parent->m_multiplayer)
{
statsArea = core::recti(m_kart_stats_x,
m_kart_stats_y,
m_kart_stats_x + m_kart_stats_w,
m_kart_stats_y + m_kart_stats_h);
}
else
{
statsArea = core::recti(m_x , m_y + m_h/2,
m_x + m_w, m_y + m_h);
}
m_kart_stats = new GUIEngine::KartStatsWidget(statsArea, player_id, kart_group);
m_kart_stats = new GUIEngine::KartStatsWidget(statsArea, player_id, kart_group,
m_parent_screen->m_multiplayer);
m_kart_stats->m_properties[PROP_ID] =
StringUtils::insertValues("@p%i_stats", m_player_id);
m_children.push_back(m_kart_stats);
if (parent->m_multiplayer && associated_player)
{
@@ -284,10 +297,6 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
//m_player_ident_spinner->m_event_handler = this;
m_children.push_back(m_player_ident_spinner);
m_kart_stats->m_properties[PROP_ID] =
StringUtils::insertValues("@p%i_stats", m_player_id);
m_children.push_back(m_kart_stats);
// ----- Kart model view
m_model_view = new ModelViewWidget();
@@ -673,10 +682,19 @@ void PlayerKartWidget::onUpdate(float delta)
core::recti(core::position2di(player_name_x, player_name_y),
core::dimension2di(player_name_w, player_name_h)) );
}
m_kart_stats->move(m_kart_stats_x,
m_kart_stats_y,
m_kart_stats_w,
m_kart_stats_h);
if (!m_parent_screen->m_multiplayer)
{
m_kart_stats->move(m_kart_stats_x,
m_kart_stats_y,
m_kart_stats_w,
m_kart_stats_h);
}
else
{
m_kart_stats->move(m_x, m_y + m_h/2,
m_w, m_h/2);
}
m_model_view->move(model_x,
model_y,
@@ -759,9 +777,6 @@ void PlayerKartWidget::setSize(const int x, const int y, const int w, const int
kart_name_w = w;
kart_name_h = 25;
m_kart_stats_w = w/2;
m_kart_stats_h = h;
// for shrinking effect
if (h < 175)
{
@@ -769,7 +784,6 @@ void PlayerKartWidget::setSize(const int x, const int y, const int w, const int
kart_name_h = (int)(kart_name_h*factor);
player_name_h = (int)(player_name_h*factor);
player_id_h = (int)(player_id_h*factor);
m_kart_stats_h = (int)(m_kart_stats_h*factor);
}
// --- layout
@@ -779,20 +793,44 @@ void PlayerKartWidget::setSize(const int x, const int y, const int w, const int
player_name_x = x + w/2 - player_name_w/2;
player_name_y = y + player_id_h;
const int modelMaxHeight = h - kart_name_h - player_name_h
- player_id_h;
const int modelMaxWidth = w;
const int bestSize = std::min(modelMaxWidth, modelMaxHeight);
const int modelY = y + player_name_h + player_id_h;
model_x = x + w/4 - (int)(bestSize/2);
model_y = modelY + modelMaxHeight/2 - bestSize/2;
model_w = (int)(bestSize);
model_h = bestSize;
if (m_parent_screen->m_multiplayer)
{
const int modelMaxHeight = (h - kart_name_h - player_name_h
- player_id_h)/2;
const int modelMaxWidth = w;
const int bestSize = std::min(modelMaxWidth, modelMaxHeight);
model_x = x + w/2 - (int)(bestSize/2);
model_y = y + player_name_h + player_id_h;
model_w = (int)(bestSize);
model_h = bestSize;
m_kart_stats_w = model_w;
m_kart_stats_h = model_h;
m_kart_stats_x = x + w/2 - (int)(bestSize/2);
m_kart_stats_y = model_y + model_h;
}
else
{
const int modelMaxHeight = h - kart_name_h - player_name_h
- player_id_h;
const int modelMaxWidth = w;
const int bestSize = std::min(modelMaxWidth, modelMaxHeight);
const int modelY = y + player_name_h + player_id_h;
model_x = x + w/4 - (int)(bestSize/2);
model_y = modelY + modelMaxHeight/2 - bestSize/2;
model_w = (int)(bestSize);
model_h = bestSize;
m_kart_stats_w = w/2;
m_kart_stats_h = h;
m_kart_stats_x = x + w/2;
m_kart_stats_y = y;
}
kart_name_x = x;
kart_name_y = y + h - kart_name_h;
m_kart_stats_x = x + w/2;
m_kart_stats_y = y;
} // setSize
// -------------------------------------------------------------------------
@@ -1488,7 +1526,6 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
kart_properties_manager->getKart(selection);
if (kp != NULL)
{
Log::verbose("updateKartStats", StringUtils::toString((int)kp->getMass()/10).c_str());
w->setValue(KartStatsWidget::SKILL_MASS, (int)kp->getMass()/10);
w->setValue(KartStatsWidget::SKILL_SPEED, (int)kp->getMaxSpeed()/10);
w->setValue(KartStatsWidget::SKILL_ACCEL, (int)kp->getTrackConnectionAccel()/10);

View File

@@ -274,7 +274,6 @@ public:
/** Sub-widgets created by this widget */
PlayerNameSpinner* m_player_ident_spinner;
GUIEngine::ProgressBarWidget* m_kart_stat_mass;
GUIEngine::KartStatsWidget* m_kart_stats;
GUIEngine::ModelViewWidget* m_model_view;
GUIEngine::LabelWidget* m_kart_name;