1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00
planetblupi/src/jauge.cxx

111 lines
2.0 KiB
C++
Raw Normal View History

2017-01-21 17:27:46 +01:00
#include <stdlib.h>
#include <stdio.h>
#include "def.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "jauge.h"
#include "misc.h"
CJauge::CJauge()
{
m_type = 0;
m_bHide = true;
m_pPixmap = nullptr;
m_pDecor = nullptr;
m_pSound = nullptr;
2017-01-21 17:27:46 +01:00
}
CJauge::~CJauge()
{
}
2017-02-12 00:44:46 +01:00
// Crée un nouveau bouton.
2017-01-21 17:27:46 +01:00
bool CJauge::Create (CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 type)
2017-01-21 17:27:46 +01:00
{
m_pPixmap = pPixmap;
m_pSound = pSound;
m_type = type;
m_bHide = true;
m_pos = pos;
m_dim.x = DIMJAUGEX;
m_dim.y = DIMJAUGEY;
m_level = 0;
return true;
2017-01-21 17:27:46 +01:00
}
2017-02-12 00:44:46 +01:00
// Dessine un bouton dans son état.
2017-01-21 17:27:46 +01:00
void CJauge::Draw()
{
Sint32 part;
RECT rect;
if (m_bHide) // bouton caché ?
{
rect.left = m_pos.x;
rect.right = m_pos.x + m_dim.x;
rect.top = m_pos.y;
rect.bottom = m_pos.y + m_dim.y;
m_pPixmap->DrawPart (-1, CHBACK, m_pos, rect, 1); // dessine le fond
return;
}
part = (m_level * (DIMJAUGEX - 6 - 4)) / 100;
rect.left = 0;
rect.right = DIMJAUGEX;
rect.top = DIMJAUGEY * 0;
rect.bottom = DIMJAUGEY * 1;
m_pPixmap->DrawPart (-1, CHJAUGE, m_pos, rect); // partie noire
if (part > 0)
{
rect.left = 0;
rect.right = 6 + part;
rect.top = DIMJAUGEY * m_type;
rect.bottom = DIMJAUGEY * (m_type + 1);
m_pPixmap->DrawPart (-1, CHJAUGE, m_pos, rect); // partie colorée
}
2017-01-21 17:27:46 +01:00
}
// Modifie le niveau.
void CJauge::SetLevel (Sint32 level)
2017-01-21 17:27:46 +01:00
{
if (level < 0)
level = 0;
if (level > 100)
level = 100;
2017-01-21 17:27:46 +01:00
m_level = level;
2017-01-21 17:27:46 +01:00
}
// Modifie le type.
void CJauge::SetType (Sint32 type)
2017-01-21 17:27:46 +01:00
{
m_type = type;
2017-01-21 17:27:46 +01:00
}
bool CJauge::GetHide()
2017-01-21 17:27:46 +01:00
{
return m_bHide;
2017-01-21 17:27:46 +01:00
}
void CJauge::SetHide (bool bHide)
2017-01-21 17:27:46 +01:00
{
m_bHide = bHide;
2017-01-21 17:27:46 +01:00
}
POINT CJauge::GetPos()
{
return m_pos;
2017-01-21 17:27:46 +01:00
}