2017-08-03 22:51:40 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the planetblupi source code
|
|
|
|
* Copyright (C) 1997, Daniel Roux & EPSITEC SA
|
|
|
|
* Copyright (C) 2017, Mathieu Schroeter
|
|
|
|
* http://epsitec.ch; http://www.blupi.org; http://github.com/blupi-games
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see http://gnu.org/licenses
|
|
|
|
*/
|
2017-01-21 17:27:46 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2017-08-04 00:21:47 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "decor.h"
|
2017-01-21 17:27:46 +01:00
|
|
|
#include "def.h"
|
2017-08-04 00:21:47 +02:00
|
|
|
#include "misc.h"
|
2017-01-21 17:27:46 +01:00
|
|
|
#include "pixmap.h"
|
2017-07-09 13:35:48 +02:00
|
|
|
#include "progress.h"
|
2017-08-04 00:21:47 +02:00
|
|
|
#include "sound.h"
|
2017-01-21 17:27:46 +01:00
|
|
|
|
2017-08-04 00:21:47 +02:00
|
|
|
CJauge::CJauge ()
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02:00
|
|
|
m_type = 0;
|
|
|
|
m_bHide = true;
|
|
|
|
m_pPixmap = nullptr;
|
|
|
|
m_pDecor = nullptr;
|
|
|
|
m_pSound = nullptr;
|
2017-01-21 17:27:46 +01:00
|
|
|
}
|
|
|
|
|
2018-02-13 23:44:08 +01:00
|
|
|
CJauge::~CJauge () {}
|
2017-01-21 17:27:46 +01:00
|
|
|
|
2017-02-12 00:44:46 +01:00
|
|
|
// Crée un nouveau bouton.
|
2017-01-21 17:27:46 +01:00
|
|
|
|
2017-08-14 22:10:26 +02:00
|
|
|
bool
|
2017-08-21 22:08:25 +02:00
|
|
|
CJauge::Create (CPixmap * pPixmap, CSound * pSound, Point pos, Sint32 type)
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02: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
|
|
|
|
2017-08-14 22:10:26 +02:00
|
|
|
void
|
|
|
|
CJauge::Draw ()
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02:00
|
|
|
Sint32 part;
|
2017-08-21 22:08:25 +02:00
|
|
|
Rect rect;
|
2017-08-04 00:21:47 +02:00
|
|
|
|
|
|
|
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;
|
2017-10-18 07:04:35 +02:00
|
|
|
m_pPixmap->DrawPart (-1, CHBACK, m_pos, rect); // dessine le fond
|
2017-08-04 00:21:47 +02:00
|
|
|
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)
|
|
|
|
{
|
2017-02-12 13:14:22 +01:00
|
|
|
rect.left = 0;
|
2017-08-04 00:21:47 +02:00
|
|
|
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.
|
|
|
|
|
2017-08-14 22:10:26 +02:00
|
|
|
void
|
|
|
|
CJauge::SetLevel (Sint32 level)
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02:00
|
|
|
if (level < 0)
|
|
|
|
level = 0;
|
|
|
|
if (level > 100)
|
|
|
|
level = 100;
|
2017-01-21 17:27:46 +01:00
|
|
|
|
2017-08-04 00:21:47 +02:00
|
|
|
m_level = level;
|
2017-01-21 17:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Modifie le type.
|
|
|
|
|
2017-08-14 22:10:26 +02:00
|
|
|
void
|
|
|
|
CJauge::SetType (Sint32 type)
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02:00
|
|
|
m_type = type;
|
2017-01-21 17:27:46 +01:00
|
|
|
}
|
|
|
|
|
2017-08-14 22:10:26 +02:00
|
|
|
bool
|
|
|
|
CJauge::GetHide ()
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02:00
|
|
|
return m_bHide;
|
2017-01-21 17:27:46 +01:00
|
|
|
}
|
|
|
|
|
2017-08-14 22:10:26 +02:00
|
|
|
void
|
|
|
|
CJauge::SetHide (bool bHide)
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02:00
|
|
|
m_bHide = bHide;
|
2017-01-21 17:27:46 +01:00
|
|
|
}
|
|
|
|
|
2017-08-21 22:08:25 +02:00
|
|
|
Point
|
2017-08-14 22:10:26 +02:00
|
|
|
CJauge::GetPos ()
|
2017-01-21 17:27:46 +01:00
|
|
|
{
|
2017-08-04 00:21:47 +02:00
|
|
|
return m_pos;
|
2017-01-21 17:27:46 +01:00
|
|
|
}
|