mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Try to use the Sounds enum type as much as possible
This commit is contained in:
parent
c9aea77afc
commit
19329c0d63
@ -2732,7 +2732,7 @@ static const DescAction action_table[] =
|
||||
|
||||
bool Action (
|
||||
Sint16 action, Sint16 direct, Sint16 & phase, Sint16 & step, Sint16 & channel,
|
||||
Sint16 & icon, POINT & pos, Sint16 & posZ, Sint16 & sound)
|
||||
Sint16 & icon, POINT & pos, Sint16 & posZ, Sounds & sound)
|
||||
{
|
||||
const auto * pTable = action_table;
|
||||
Sint16 nbIcon, nbPhase, nbMove, nbSound, i;
|
||||
@ -2757,9 +2757,10 @@ bool Action (
|
||||
icon = pTable->icons[direct / 16][1 + step % nbIcon];
|
||||
|
||||
if (nbSound == 0 || step >= nbSound)
|
||||
sound = -1;
|
||||
sound = SOUND_NONE;
|
||||
else
|
||||
sound = pTable->sounds[1 + step % nbSound];
|
||||
sound =
|
||||
static_cast<Sounds> (pTable->sounds[1 + step % nbSound]); // FIXME
|
||||
|
||||
for (i = 0; i < phase; i++)
|
||||
{
|
||||
|
@ -21,10 +21,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "blupi.h"
|
||||
#include "def.h"
|
||||
|
||||
extern bool Action (
|
||||
Sint16 action, Sint16 direct, Sint16 & phase, Sint16 & step, Sint16 & channel,
|
||||
Sint16 & icon, POINT & pos, Sint16 & posZ, Sint16 & sound);
|
||||
Sint16 & icon, POINT & pos, Sint16 & posZ, Sounds & sound);
|
||||
bool Rotate (Sint16 & icon, Sint16 direct);
|
||||
Sint32 GetIconDirect (Sint16 icon);
|
||||
Sint32 GetAmplitude (Sint16 action);
|
||||
|
@ -311,7 +311,7 @@ void CDecor::BlupiCheat (Sint32 cheat)
|
||||
|
||||
void CDecor::BlupiActualise (Sint32 rank)
|
||||
{
|
||||
Sint16 sound;
|
||||
Sounds sound;
|
||||
|
||||
Action (
|
||||
m_blupi[rank].action, m_blupi[rank].aDirect, m_blupi[rank].phase,
|
||||
@ -416,9 +416,9 @@ void CDecor::BlupiAdaptIcon (Sint32 rank)
|
||||
// Si bStop=true, on stoppe le son précédent associé
|
||||
// à ce blupi (rank), si nécessaire.
|
||||
|
||||
void CDecor::BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop)
|
||||
void CDecor::BlupiSound (Sint32 rank, Sounds sound, POINT pos, bool bStop)
|
||||
{
|
||||
Sint32 newSound;
|
||||
Sounds newSound;
|
||||
|
||||
if (rank == -1)
|
||||
rank = m_rankBlupiHili;
|
||||
@ -428,7 +428,7 @@ void CDecor::BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop)
|
||||
if (
|
||||
sound == SOUND_HOP || sound == SOUND_BURN || sound == SOUND_TCHAO ||
|
||||
sound == SOUND_FLOWER || sound == SOUND_ARROSE)
|
||||
newSound = -1;
|
||||
newSound = SOUND_NONE;
|
||||
else
|
||||
newSound = sound;
|
||||
|
||||
@ -451,7 +451,7 @@ void CDecor::BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop)
|
||||
sound == SOUND_TERM4 || sound == SOUND_TERM5 || sound == SOUND_TERM6)
|
||||
newSound = SOUND_D_TERM;
|
||||
|
||||
if (newSound == -1)
|
||||
if (newSound == SOUND_NONE)
|
||||
return;
|
||||
sound = newSound;
|
||||
}
|
||||
@ -464,34 +464,33 @@ void CDecor::BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop)
|
||||
|
||||
// Sons associés à des actions.
|
||||
// clang-format off
|
||||
static const Sint16 tableSound[] = {
|
||||
ACTION_BURN, SOUND_BURN,
|
||||
ACTION_TCHAO, SOUND_TCHAO,
|
||||
ACTION_EAT, SOUND_EAT,
|
||||
ACTION_DRINK, SOUND_DRINK,
|
||||
ACTION_SLIDE, SOUND_SLIDE,
|
||||
ACTION_R_LOAD, SOUND_R_LOAD,
|
||||
-1
|
||||
static const struct {
|
||||
Sint16 action;
|
||||
Sounds sound;
|
||||
} tableSound[] = {
|
||||
{ACTION_BURN, SOUND_BURN},
|
||||
{ACTION_TCHAO, SOUND_TCHAO},
|
||||
{ACTION_EAT, SOUND_EAT},
|
||||
{ACTION_DRINK, SOUND_DRINK},
|
||||
{ACTION_SLIDE, SOUND_SLIDE},
|
||||
{ACTION_R_LOAD, SOUND_R_LOAD},
|
||||
};
|
||||
// clang-format on
|
||||
// Effectue quelques initialisations pour une nouvelle action.
|
||||
|
||||
void CDecor::BlupiInitAction (Sint32 rank, Sint32 action, Sint32 direct)
|
||||
{
|
||||
const auto * pTable = tableSound;
|
||||
POINT pos;
|
||||
Sint32 rand;
|
||||
POINT pos;
|
||||
Sint32 rand;
|
||||
|
||||
while (*pTable != -1)
|
||||
for (size_t i = 0; i < countof (tableSound); ++i)
|
||||
{
|
||||
if (pTable[0] == action)
|
||||
if (tableSound[i].action == action)
|
||||
{
|
||||
pos = ConvCelToPos (m_blupi[rank].cel);
|
||||
BlupiSound (rank, pTable[1], pos);
|
||||
BlupiSound (rank, tableSound[i].sound, pos);
|
||||
break;
|
||||
}
|
||||
|
||||
pTable += 2;
|
||||
}
|
||||
|
||||
m_blupi[rank].action = action;
|
||||
@ -1834,7 +1833,7 @@ bool CDecor::GoalNextOp (Sint32 rank, Sint16 * pTable)
|
||||
if (op == GOAL_SOUND)
|
||||
{
|
||||
icon = *pTable++;
|
||||
BlupiSound (rank, icon, pos);
|
||||
BlupiSound (rank, static_cast<Sounds> (icon), pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2151,12 +2150,12 @@ void CDecor::GoalStop (Sint32 rank, bool bError, bool bSound)
|
||||
{
|
||||
POINT pos;
|
||||
|
||||
static Sint32 table_sound_term[6] = {
|
||||
static Sounds table_sound_term[] = {
|
||||
SOUND_TERM1, SOUND_TERM2, SOUND_TERM3,
|
||||
SOUND_TERM4, SOUND_TERM5, SOUND_TERM6,
|
||||
};
|
||||
|
||||
static Sint32 table_sound_boing[3] = {
|
||||
static Sounds table_sound_boing[] = {
|
||||
SOUND_BOING1, SOUND_BOING2, SOUND_BOING3,
|
||||
};
|
||||
|
||||
@ -2195,12 +2194,16 @@ void CDecor::GoalStop (Sint32 rank, bool bError, bool bSound)
|
||||
{
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
BlupiSound (rank, table_sound_boing[Random (0, 2)], pos, true);
|
||||
BlupiSound (
|
||||
rank, table_sound_boing[Random (0, countof (table_sound_boing) - 1)],
|
||||
pos, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = ConvCelToPos (m_blupi[rank].cel);
|
||||
BlupiSound (rank, table_sound_term[Random (0, 5)], pos, true);
|
||||
BlupiSound (
|
||||
rank, table_sound_term[Random (0, countof (table_sound_term) - 1)], pos,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2426,7 +2429,7 @@ bool CDecor::BlupiNextAction (Sint32 rank)
|
||||
bool bOK;
|
||||
POINT pos, iCel;
|
||||
Sint32 a, min;
|
||||
Sint16 sound;
|
||||
Sounds sound;
|
||||
|
||||
if (!m_blupi[rank].bExist)
|
||||
return false;
|
||||
@ -2473,7 +2476,7 @@ bool CDecor::BlupiNextAction (Sint32 rank)
|
||||
m_blupi[rank].pos, m_blupi[rank].posZ, sound);
|
||||
BlupiAdaptIcon (rank);
|
||||
|
||||
if (sound != -1)
|
||||
if (sound != SOUND_NONE)
|
||||
{
|
||||
pos = ConvCelToPos (m_blupi[rank].cel);
|
||||
BlupiSound (rank, sound, pos);
|
||||
@ -3379,20 +3382,21 @@ void CDecor::BlupiHiliMove (POINT pos)
|
||||
|
||||
void CDecor::BlupiHiliUp (POINT pos)
|
||||
{
|
||||
Sint32 rank, r, nb, sound;
|
||||
Sint32 rank, r, nb;
|
||||
Sounds sound;
|
||||
bool bEnerve = false;
|
||||
POINT c1, c2;
|
||||
|
||||
static Sint32 table_sound_ok[6] = {
|
||||
static Sounds table_sound_ok[] = {
|
||||
SOUND_OK1, SOUND_OK2, SOUND_OK3, SOUND_OK4, SOUND_OK5, SOUND_OK6,
|
||||
};
|
||||
|
||||
static Sint32 table_sound_okf[3] = // si fatigué
|
||||
static Sounds table_sound_okf[] = // si fatigué
|
||||
{
|
||||
SOUND_OK1f, SOUND_OK2f, SOUND_OK3f,
|
||||
};
|
||||
|
||||
static Sint32 table_sound_oke[3] = // si énervé
|
||||
static Sounds table_sound_oke[] = // si énervé
|
||||
{
|
||||
SOUND_OK1e, SOUND_OK2e, SOUND_OK3e,
|
||||
};
|
||||
@ -3470,15 +3474,15 @@ void CDecor::BlupiHiliUp (POINT pos)
|
||||
if (nb > 0)
|
||||
{
|
||||
if (nb > 1) // sélection multiple ?
|
||||
sound = table_sound_ok[Random (0, 5)];
|
||||
sound = table_sound_ok[Random (0, countof (table_sound_ok) - 1)];
|
||||
else
|
||||
{
|
||||
if (m_blupi[rank].energy <= MAXENERGY / 4)
|
||||
sound = table_sound_okf[Random (0, 2)];
|
||||
sound = table_sound_okf[Random (0, countof (table_sound_okf) - 1)];
|
||||
else
|
||||
sound = table_sound_ok[Random (0, 5)];
|
||||
sound = table_sound_ok[Random (0, countof (table_sound_ok) - 1)];
|
||||
if (bEnerve) // déjà sélectionné y'a peu ?
|
||||
sound = table_sound_oke[Random (0, 2)];
|
||||
sound = table_sound_oke[Random (0, countof (table_sound_oke) - 1)];
|
||||
}
|
||||
BlupiSound (rank, sound, pos, true);
|
||||
}
|
||||
@ -4019,22 +4023,23 @@ void CDecor::BlupiGoal (POINT cel, Buttons button)
|
||||
POINT bPos, avg;
|
||||
Sint32 rank, nb, nbHili;
|
||||
|
||||
static Sint32 table_sound_go[6] = {
|
||||
static Sounds table_sound_go[] = {
|
||||
SOUND_GO1, SOUND_GO2, SOUND_GO3, SOUND_GO4, SOUND_GO5, SOUND_GO6,
|
||||
};
|
||||
|
||||
static Sint32 table_sound_gom[3] = {
|
||||
static Sounds table_sound_gom[] = {
|
||||
SOUND_GO4, SOUND_GO5, SOUND_GO6,
|
||||
};
|
||||
|
||||
static Sint32 table_sound_boing[3] = {
|
||||
static Sounds table_sound_boing[] = {
|
||||
SOUND_BOING1, SOUND_BOING2, SOUND_BOING3,
|
||||
};
|
||||
|
||||
if (button == -1)
|
||||
{
|
||||
avg = ConvCelToPos (cel);
|
||||
m_pSound->PlayImage (table_sound_boing[Random (0, 2)], avg);
|
||||
m_pSound->PlayImage (
|
||||
table_sound_boing[Random (0, countof (table_sound_boing) - 1)], avg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ public:
|
||||
void BlupiActualise (Sint32 rank);
|
||||
void BlupiAdaptIcon (Sint32 rank);
|
||||
void BlupiPushFog (Sint32 rank);
|
||||
void BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop = false);
|
||||
void BlupiSound (Sint32 rank, Sounds sound, POINT pos, bool bStop = false);
|
||||
void BlupiInitAction (Sint32 rank, Sint32 action, Sint32 direct = -1);
|
||||
void BlupiChangeAction (Sint32 rank, Sint32 action, Sint32 direct = -1);
|
||||
void ListFlush (Sint32 rank);
|
||||
|
@ -218,6 +218,7 @@ enum Actions {
|
||||
|
||||
// Sounds:
|
||||
enum Sounds {
|
||||
SOUND_NONE = -1,
|
||||
SOUND_CLICK = 0,
|
||||
SOUND_BOING = 1,
|
||||
SOUND_OK1 = 2,
|
||||
|
@ -2665,7 +2665,8 @@ void CEvent::HideMouse (bool bHide)
|
||||
bool CEvent::EventButtons (const SDL_Event & event, POINT pos)
|
||||
{
|
||||
POINT test;
|
||||
Sint32 lg, sound;
|
||||
Sint32 lg;
|
||||
Sounds sound;
|
||||
|
||||
// Cherche le tool tips à utiliser pour la souris.
|
||||
m_textToolTips[0] = 0;
|
||||
@ -3540,7 +3541,7 @@ bool CEvent::PlayMove (POINT pos)
|
||||
|
||||
bool CEvent::PlayUp (POINT pos)
|
||||
{
|
||||
static Sint32 table_sound_boing[3] = {
|
||||
static Sounds table_sound_boing[] = {
|
||||
SOUND_BOING1, SOUND_BOING2, SOUND_BOING3,
|
||||
};
|
||||
|
||||
@ -3555,7 +3556,9 @@ bool CEvent::PlayUp (POINT pos)
|
||||
m_pDecor->BlupiGetButtons (
|
||||
pos, m_menuNb, m_menuButtons, m_menuErrors, m_menuTexts, m_menuPerso);
|
||||
if (m_menuNb == 0)
|
||||
m_pDecor->BlupiSound (-1, table_sound_boing[Random (0, 2)], pos);
|
||||
m_pDecor->BlupiSound (
|
||||
-1, table_sound_boing[Random (0, countof (table_sound_boing) - 1)],
|
||||
pos);
|
||||
else
|
||||
{
|
||||
m_menuCel = m_pDecor->ConvPosToCel (pos);
|
||||
@ -4809,7 +4812,8 @@ bool CEvent::TreatEvent (const SDL_Event & event)
|
||||
bool CEvent::TreatEventBase (const SDL_Event & event)
|
||||
{
|
||||
POINT pos;
|
||||
Sint32 i, sound;
|
||||
Sint32 i;
|
||||
Sounds sound;
|
||||
char c;
|
||||
bool bEnable;
|
||||
|
||||
|
@ -61,7 +61,7 @@ CSound::CSound ()
|
||||
m_bStopped = false;
|
||||
|
||||
for (i = 0; i < MAXBLUPI; i++)
|
||||
m_channelBlupi[i] = -1;
|
||||
m_channelBlupi[i] = SOUND_NONE;
|
||||
|
||||
memset (m_lpSDL, 0, sizeof (m_lpSDL));
|
||||
}
|
||||
@ -238,9 +238,10 @@ bool CSound::Play (Sint32 channel, Sint32 volume, Uint8 panLeft, Uint8 panRight)
|
||||
// Si rank != -1, il indique le rang du blupi dont il faudra
|
||||
// �ventuellement stopper le dernier son en cours !
|
||||
|
||||
bool CSound::PlayImage (Sint32 channel, POINT pos, Sint32 rank)
|
||||
bool CSound::PlayImage (Sounds channel, POINT pos, Sint32 rank)
|
||||
{
|
||||
Sint32 stopCh, volumex, volumey, volume;
|
||||
Sint32 volumex, volumey, volume;
|
||||
Sounds stopCh;
|
||||
|
||||
if (rank >= 0 && rank < MAXBLUPI)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
bool Play (
|
||||
Sint32 channel, Sint32 volume = 0, Uint8 panLeft = 255,
|
||||
Uint8 panRight = 255);
|
||||
bool PlayImage (Sint32 channel, POINT pos, Sint32 rank = -1);
|
||||
bool PlayImage (Sounds channel, POINT pos, Sint32 rank = -1);
|
||||
bool PlayMusic (const std::string & lpszMIDIFilename);
|
||||
bool RestartMusic ();
|
||||
void SuspendMusic ();
|
||||
@ -71,7 +71,7 @@ protected:
|
||||
Mix_Music * m_pMusic;
|
||||
Mix_Chunk * m_lpSDL[MAXSOUND];
|
||||
std::vector<std::string> m_sndFiles;
|
||||
Sint16 m_channelBlupi[MAXBLUPI];
|
||||
Sounds m_channelBlupi[MAXBLUPI];
|
||||
std::string m_MIDIFilename;
|
||||
Sint32 m_audioVolume;
|
||||
Sint32 m_midiVolume;
|
||||
|
Loading…
x
Reference in New Issue
Block a user