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

Merge branch 'master' into wip/gettext

This commit is contained in:
Mathieu Schroeter 2017-02-14 18:18:03 +01:00
commit d44f4bba4a
43 changed files with 16 additions and 34318 deletions

View File

@ -43,17 +43,27 @@ pkg_search_module (SDL2_IMAGE REQUIRED SDL2_image)
##################
## SDL_kitchensink
ExternalProject_Add (SDL_kitchensink
ExternalProject_Add (SDL_kitchensink_Project
GIT_REPOSITORY https://github.com/katajakasa/SDL_kitchensink.git
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
)
ExternalProject_Get_Property (SDL_kitchensink install_dir)
ExternalProject_Get_Property (SDL_kitchensink_Project install_dir)
include_directories (${install_dir}/include)
if (WIN32)
add_library (SDL_kitchensink STATIC IMPORTED)
set_property (TARGET SDL_kitchensink PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libSDL_kitchensink.dll.a)
else ()
add_library (SDL_kitchensink SHARED IMPORTED)
set_property (TARGET SDL_kitchensink PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libSDL_kitchensink.so)
endif ()
add_dependencies (planetblupi SDL_kitchensink)
## SDL_kitchensink
## ##################
@ -62,7 +72,7 @@ target_link_libraries (planetblupi PUBLIC
${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
${install_dir}/lib/libSDL_kitchensink.dll.a
SDL_kitchensink
)
## GetText

View File

@ -27,7 +27,7 @@ pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain make mingw-w64-x86_64-
**Install SDL2 development packages**
```
pacman -S --noconfirm --needed mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_mixer
pacman -S --noconfirm --needed mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_image
```
**Install SDL_kitchensink dependencies**

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
// Action.h
//
#pragma once
#include "blupi.h"
extern
bool Action(Sint16 action, Sint16 direct,
Sint16 &phase, Sint16 &step,
Sint16 &channel, Sint16 &icon, POINT &pos, Sint16 &posZ,
Sint16 &sound);
extern
bool Rotate(Sint16 &icon, Sint16 direct);
extern
Sint32 GetIconDirect(Sint16 icon);
extern
Sint32 GetAmplitude(Sint16 action);

View File

@ -1,977 +0,0 @@
// Arrange.cpp
//
#include "decor.h"
#include "misc.h"
// Cette table indique les quarts de cases contenant de
// l'eau lorsque la valeur est à un.
// 0 1
// 2 3
static char tableSee[14*4] =
{
0,0,0,0, // 1
0,1,0,1, // 2
0,0,1,1, // 3
1,0,1,0, // 4
1,1,0,0, // 5
0,0,0,1, // 6
0,0,1,0, // 7
1,0,0,0, // 8
0,1,0,0, // 9
0,1,1,1, // 10
1,0,1,1, // 11
1,1,1,0, // 12
1,1,0,1, // 13
1,1,1,1, // 14
};
// Cette table indique les quarts de cases contenant de
// la mousse ou de la terre lorsque la valeur est à un.
// 0 1
// 2 3
static char tableDark[13*4] =
{
1,1,1,1, // 20
0,1,0,1, // 21
0,0,1,1, // 22
1,0,1,0, // 23
1,1,0,0, // 24
0,0,0,1, // 25
0,0,1,0, // 26
1,0,0,0, // 27
0,1,0,0, // 28
1,1,1,0, // 29
1,1,0,1, // 30
0,1,1,1, // 31
1,0,1,1, // 32
};
// Retourne les bits contenant de l'eau.
bool CDecor::GetSeeBits(POINT cel, char *pBits, Sint32 index)
{
Sint32 icon;
pBits[0] = 0;
pBits[1] = 0;
pBits[2] = 0;
pBits[3] = 0;
if ( cel.x < 0 || cel.x >= MAXCELX ||
cel.y < 0 || cel.y >= MAXCELY ) return false;
icon = m_decor[cel.x/2][cel.y/2].floorIcon;
if ( index == 0 ) // eau ?
{
if ( icon < 1 || icon > 14 ) return true;
icon -= 1;
pBits[0] = tableSee[icon*4+0];
pBits[1] = tableSee[icon*4+1];
pBits[2] = tableSee[icon*4+2];
pBits[3] = tableSee[icon*4+3];
}
if ( index == 1 ) // mousse ?
{
if ( icon >= 2 && icon <= 14 ) return false; // eau ?
if ( icon == 66 || icon == 79 ) // mousse spéciale ?
{
pBits[0] = 1;
pBits[1] = 1;
pBits[2] = 1;
pBits[3] = 1;
return true;
}
if ( icon < 20 || icon > 32 ) return true;
icon -= 20;
pBits[0] = tableDark[icon*4+0];
pBits[1] = tableDark[icon*4+1];
pBits[2] = tableDark[icon*4+2];
pBits[3] = tableDark[icon*4+3];
}
if ( index == 2 ) // terre ?
{
if ( icon >= 2 && icon <= 14 ) return false; // eau ?
if ( (icon >= 46 && icon <= 48) || // terre spéciale ?
icon == 71 ) // terre à fer ?
{
pBits[0] = 1;
pBits[1] = 1;
pBits[2] = 1;
pBits[3] = 1;
return true;
}
if ( icon < 33 || icon > 45 ) return true;
icon -= 33;
pBits[0] = tableDark[icon*4+0];
pBits[1] = tableDark[icon*4+1];
pBits[2] = tableDark[icon*4+2];
pBits[3] = tableDark[icon*4+3];
}
return true;
}
void CopyBits(char *pDst, char *pSrc)
{
for ( Sint32 i=0 ; i<4 ; i++ )
{
*pDst++ = *pSrc++;
}
}
bool ChangeBits(char *pDst, char *pSrc)
{
for ( Sint32 i=0 ; i<4 ; i++ )
{
if ( *pDst++ != *pSrc++ ) return true;
}
return false;
}
// Retourne l'icône correspondant aux bits d'eaux.
Sint32 CDecor::GetSeeIcon(char *pBits, Sint32 index)
{
Sint32 i;
if ( index == 0 ) // eau ?
{
for ( i=0 ; i<14 ; i++ )
{
if ( tableSee[i*4+0] == pBits[0] &&
tableSee[i*4+1] == pBits[1] &&
tableSee[i*4+2] == pBits[2] &&
tableSee[i*4+3] == pBits[3] ) return i+1;
}
}
if ( index == 1 ) // mousse ?
{
for ( i=0 ; i<13 ; i++ )
{
if ( tableDark[i*4+0] == pBits[0] &&
tableDark[i*4+1] == pBits[1] &&
tableDark[i*4+2] == pBits[2] &&
tableDark[i*4+3] == pBits[3] ) return i+20;
}
}
if ( index == 2 ) // terre ?
{
for ( i=0 ; i<13 ; i++ )
{
if ( tableDark[i*4+0] == pBits[0] &&
tableDark[i*4+1] == pBits[1] &&
tableDark[i*4+2] == pBits[2] &&
tableDark[i*4+3] == pBits[3] ) return i+33;
}
}
if ( pBits[0] == 0 &&
pBits[1] == 0 &&
pBits[2] == 0 &&
pBits[3] == 0 ) return 1; // herbe
return -1;
}
// Arrange le sol après une modification.
void CDecor::ArrangeFloor(POINT cel)
{
POINT test;
Sint32 max, index, icon;
char here[4], bits[4], init[4];
bool bModif = false;
icon = m_decor[cel.x/2][cel.y/2].floorIcon;
if ( icon >= 59 && icon <= 64 ) return; // pont ?
max = 3;
if ( icon >= 15 && icon <= 18 ) // dalle spéciale ?
{
max = 1; // s'occupe que de l'eau !
}
for ( index=0 ; index<max ; index++ )
{
if ( !GetSeeBits(cel, here, index) ) continue;
test.x = cel.x -2; // en bas à gauche
test.y = cel.y +2;
if ( GetSeeBits(test, bits, index) )
{
if ( bits[2] == here[2] &&
bits[0] != here[2] &&
bits[1] != here[2] &&
bits[3] != here[2] )
{
here[2] = bits[1];
bModif = true;
}
}
test.x = cel.x -2; // en haut à gauche
test.y = cel.y -2;
if ( GetSeeBits(test, bits, index) )
{
if ( bits[0] == here[0] &&
bits[1] != here[0] &&
bits[2] != here[0] &&
bits[3] != here[0] )
{
here[0] = bits[3];
bModif = true;
}
}
test.x = cel.x +2; // en haut à droite
test.y = cel.y -2;
if ( GetSeeBits(test, bits, index) )
{
if ( bits[1] == here[1] &&
bits[0] != here[1] &&
bits[2] != here[1] &&
bits[3] != here[1] )
{
here[1] = bits[2];
bModif = true;
}
}
test.x = cel.x +2; // en bas à droite
test.y = cel.y +2;
if ( GetSeeBits(test, bits, index) )
{
if ( bits[3] == here[3] &&
bits[0] != here[3] &&
bits[1] != here[3] &&
bits[2] != here[3] )
{
here[3] = bits[0];
bModif = true;
}
}
if ( bModif )
{
icon = GetSeeIcon(here, index);
if ( icon != -1 ) m_decor[cel.x/2][cel.y/2].floorIcon = icon;
}
test.x = cel.x -2; // à gauche
test.y = cel.y;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[1] = here[0]?1:0;
bits[3] = here[2]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
test.x = cel.x -2; // en haut à gauche
test.y = cel.y -2;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[3] = here[0]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
test.x = cel.x; // en haut
test.y = cel.y -2;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[2] = here[0]?1:0;
bits[3] = here[1]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
test.x = cel.x +2; // en haut à droite
test.y = cel.y -2;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[2] = here[1]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
test.x = cel.x +2; // à droite
test.y = cel.y;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[0] = here[1]?1:0;
bits[2] = here[3]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
test.x = cel.x +2; // en bas à droite
test.y = cel.y +2;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[0] = here[3]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
test.x = cel.x; // en bas
test.y = cel.y +2;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[0] = here[2]?1:0;
bits[1] = here[3]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
test.x = cel.x -2; // en bas à gauche
test.y = cel.y +2;
if ( GetSeeBits(test, bits, index) )
{
CopyBits(init, bits);
bits[1] = here[2]?1:0;
icon = GetSeeIcon(bits, index);
if ( ChangeBits(init, bits) && icon != -1 )
{
m_decor[test.x/2][test.y/2].floorIcon = icon;
}
}
}
}
// Cette table donne les directions dans l'ordre
// est-sud-ouest-nord pour les murs.
static char tableMur[5*15] =
{
20, 1,0,1,0,
21, 0,1,0,1,
22, 1,1,0,0,
23, 0,1,1,0,
24, 0,0,1,1,
25, 1,0,0,1,
26, 1,1,1,1,
26, 0,1,1,1,
26, 1,0,1,1,
26, 1,1,0,1,
26, 1,1,1,0,
20, 1,0,0,0,
20, 0,0,1,0,
21, 0,1,0,0,
21, 0,0,0,1,
};
static Sint16 tableMurDir[4*2] =
{
+2, 0, // est
0,+2, // sur
-2, 0, // ouest
0,-2, // nord
};
// Arrange un mur en fonction des autres murs dans toutes
// les directions.
// index=0 si mur (20..26)
// index=1 si palissade (65..71)
// index=2 si barrière (106..112)
void CDecor::ArrangeMur(POINT cel, Sint32 &icon, Sint32 index)
{
Sint32 i, x, y, channel;
Sint32 first, last, matiere;
Sint32 icons[4];
char murs[4];
if ( index == 0 )
{
first = 20;
last = 26;
matiere = 44; // pierres
}
if ( index == 1 )
{
first = 65;
last = 71;
matiere = 36; // planches
}
if ( index == 2 )
{
first = 106;
last = 112;
matiere = 36; // planches
}
for ( i=0 ; i<4 ; i++ )
{
x = cel.x + tableMurDir[i*2+0];
y = cel.y + tableMurDir[i*2+1];
if ( IsValid(GetCel(x,y)) )
{
icons[i] = m_decor[x/2][y/2].objectIcon;
if ( icons[i] == matiere ) // pierres/planches ?
{
MoveGetObject(GetCel(x,y), channel, icons[i]);
}
if ( icons[i] < first || icons[i] > last )
{
icons[i] = -1;
}
}
else
{
icons[i] = -1;
}
}
for ( i=0 ; i<4 ; i++ )
{
if ( icons[i] == -1 )
{
murs[i] = 0;
}
else
{
murs[i] = tableMur[(icons[i]-first)*5+1+((i+2)%4)];
}
}
for ( i=0 ; i<15 ; i++ )
{
if ( murs[0] == tableMur[i*5+1] &&
murs[1] == tableMur[i*5+2] &&
murs[2] == tableMur[i*5+3] &&
murs[3] == tableMur[i*5+4] )
{
icon = tableMur[i*5+0];
icon += first-20;
return;
}
}
icon = -1;
}
// Arrange les objets avant une construction.
void CDecor::ArrangeBuild(POINT cel, Sint32 &channel, Sint32 &icon)
{
Sint32 index, i, x, y;
Sint32 first, last, matiere;
Sint32 oldChannel, oldIcon;
for ( index=0 ; index<3 ; index++ )
{
if ( index == 0 )
{
first = 20;
last = 26;
matiere = 44; // pierres
}
if ( index == 1 )
{
first = 65;
last = 71;
matiere = 36; // planches
}
if ( index == 2 )
{
first = 106;
last = 112;
matiere = 36; // planches
}
// Rien à faire si pas mur.
if ( channel != CHOBJECT || icon != last ) continue;
oldChannel = m_decor[cel.x/2][cel.y/2].objectChannel;
oldIcon = m_decor[cel.x/2][cel.y/2].objectIcon;
m_decor[cel.x/2][cel.y/2].objectChannel = channel;
m_decor[cel.x/2][cel.y/2].objectIcon = icon;
for ( i=0 ; i<4 ; i++ )
{
x = cel.x + tableMurDir[i*2+0];
y = cel.y + tableMurDir[i*2+1];
if ( IsValid(GetCel(x,y)) )
{
icon = m_decor[x/2][y/2].objectIcon;
if ( icon == matiere ) // pierres/planches ?
{
MoveGetObject(GetCel(x,y), channel, icon);
}
if ( icon >= first && icon <= last )
{
ArrangeMur(GetCel(x,y), icon, index);
if ( icon != -1 )
{
if ( !MovePutObject(GetCel(x,y), channel, icon) )
{
m_decor[x/2][y/2].objectChannel = channel;
m_decor[x/2][y/2].objectIcon = icon;
}
}
}
}
}
m_decor[cel.x/2][cel.y/2].objectChannel = oldChannel;
m_decor[cel.x/2][cel.y/2].objectIcon = oldIcon;
ArrangeMur(cel, icon, index);
if ( icon == -1 ) icon = last;
}
}
// Arrange les objets après une modification.
void CDecor::ArrangeObject(POINT cel)
{
Sint32 channel, icon;
Sint32 first, last;
Sint32 index, i, j, k, x, y;
POINT vector, test, pos;
bool bTour;
for ( index=0 ; index<3 ; index++ )
{
if ( index == 0 )
{
first = 20; // murs
last = 26;
}
if ( index == 1 )
{
first = 65; // palissades
last = 71;
}
if ( index == 2 )
{
first = 106; // barrière
last = 112;
}
for ( i=0 ; i<4 ; i++ )
{
x = cel.x + tableMurDir[i*2+0];
y = cel.y + tableMurDir[i*2+1];
if ( IsValid(GetCel(x,y)) )
{
icon = m_decor[x/2][y/2].objectIcon;
if ( icon >= first && icon <= last )
{
ArrangeMur(GetCel(x,y), icon, index);
if ( icon != -1 )
{
m_decor[x/2][y/2].objectChannel = CHOBJECT;
m_decor[x/2][y/2].objectIcon = icon;
}
}
}
}
if ( m_decor[cel.x/2][cel.y/2].objectIcon == last )
{
ArrangeMur(cel, icon, index);
if ( icon == -1 ) icon = last;
m_decor[cel.x/2][cel.y/2].objectChannel = CHOBJECT;
m_decor[cel.x/2][cel.y/2].objectIcon = icon;
}
}
// Arrange les rayons entre les tours.
if ( m_decor[cel.x/2][cel.y/2].objectIcon == 27 || // tour ?
m_decor[cel.x/2][cel.y/2].objectIcon == -1 ) // rien ?
{
for ( i=0 ; i<4 ; i++ )
{
vector = GetVector(i*2*16);
test = cel;
bTour = false;
j = 0;
while ( true )
{
test.x += vector.x*2;
test.y += vector.y*2;
if ( m_decor[test.x/2][test.y/2].objectIcon == 27 ) // tour ?
{
bTour = true;
break;
}
if ( m_decor[test.x/2][test.y/2].objectIcon != -1 &&
m_decor[test.x/2][test.y/2].objectIcon != 10001-i%2 )
{
break;
}
j ++;
if ( j >= 2+1 ) break;
}
if ( m_decor[cel.x/2][cel.y/2].objectIcon != 27 ) // pas tour ?
{
bTour = false;
}
test = cel;
for ( k=0 ; k<j ; k++ )
{
test.x += vector.x*2;
test.y += vector.y*2;
if ( bTour )
{
channel = CHOBJECT;
icon = 10001-i%2; // rayon e-o (10001) ou n-s (10000)
}
else
{
channel = -1;
icon = -1;
}
m_decor[test.x/2][test.y/2].objectChannel = channel;
m_decor[test.x/2][test.y/2].objectIcon = icon;
if ( !m_bBuild && bTour )
{
if ( MoveCreate(test, -1, false, CHOBJECT,-1,
-1,-1, 9999,1,0, true) )
{
MoveAddIcons(test, 5-i%2, true); // éclairs
}
pos = ConvCelToPos(test);
m_pSound->PlayImage(SOUND_RAYON1, pos);
}
if ( !m_bBuild && !bTour )
{
MoveFinish(test);
}
}
}
}
}
// Test s'il faut remplir le sol ici.
bool CDecor::ArrangeFillTestFloor(POINT cel1, POINT cel2)
{
POINT cel;
Sint32 icon1, icon2;
icon1 = m_fillSearchIcon;
icon2 = m_fillSearchIcon;
if ( m_fillPutChannel == CHFLOOR &&
m_fillPutIcon == 1 && // met de l'herbe..
m_fillSearchIcon == 14 ) // ..sur de l'eau ?
{
icon1 = 2;
icon2 = 14; // eau & rives
}
if ( m_fillPutChannel == CHFLOOR &&
m_fillPutIcon == 14 && // met de l'eau..
m_fillSearchIcon == 1 ) // ..sur de l'herbe ?
{
icon1 = 1;
icon2 = 13; // herbe & rives
}
for ( cel.x=cel1.x ; cel.x<=cel2.x ; cel.x+=2 )
{
for ( cel.y=cel1.y ; cel.y<=cel2.y ; cel.y+=2 )
{
if ( !IsValid(cel) ) continue;
if ( m_decor[cel.x/2][cel.y/2].floorChannel != m_fillSearchChannel ||
m_decor[cel.x/2][cel.y/2].floorIcon < icon1 ||
m_decor[cel.x/2][cel.y/2].floorIcon > icon2 )
{
return false;
}
if ( m_fillPutChannel == CHFLOOR &&
m_fillPutIcon == 14 && // met de l'eau ?
m_decor[cel.x/2][cel.y/2].objectIcon != -1 )
{
return false;
}
}
}
if ( m_fillPutChannel == CHFLOOR &&
m_fillPutIcon == 14 && // met de l'eau ?
IsBlupiHereEx(cel1, cel2, -1, false) )
{
return false;
}
return true;
}
// Test s'il faut remplir ici.
bool CDecor::ArrangeFillTest(POINT pos)
{
POINT cel1, cel2;
if ( m_pFillMap[(pos.x/2)+(pos.y/2)*(MAXCELX/2)] == 1 )
{
return false;
}
if ( m_bFillFloor )
{
cel1.x = pos.x-2;
cel1.y = pos.y-2;
cel2.x = pos.x+3;
cel2.y = pos.y+3;
return ArrangeFillTestFloor(cel1, cel2);
}
else
{
if ( m_decor[pos.x/2][pos.y/2].objectChannel == m_fillSearchChannel &&
m_decor[pos.x/2][pos.y/2].objectIcon == m_fillSearchIcon &&
!IsBlupiHereEx(GetCel(pos.x+0,pos.y+0),
GetCel(pos.x+1,pos.y+1), -1, false) )
{
if ( m_decor[pos.x/2][pos.y/2].floorChannel == CHFLOOR &&
m_decor[pos.x/2][pos.y/2].floorIcon >= 2 &&
m_decor[pos.x/2][pos.y/2].floorIcon <= 14 ) // rive ou eau ?
{
return false;
}
return true;
}
}
return false;
}
// Modifie le décor lors d'un remplissage.
void CDecor::ArrangeFillPut(POINT pos, Sint32 channel, Sint32 icon)
{
if ( m_bFillFloor )
{
PutFloor(pos, channel, icon);
ArrangeFloor(pos);
}
else
{
if ( icon >= 0 && icon <= 5 ) // plantes ?
{
icon = Random(0,5);
}
if ( icon >= 6 && icon <= 11 ) // arbres ?
{
icon = Random(6,11);
}
if ( icon >= 37 && icon <= 43 ) // rochers ?
{
icon = Random(37,43);
}
PutObject(pos, channel, icon);
ArrangeObject(pos);
}
}
// Rempli un sol à partir d'une position donnée.
void CDecor::ArrangeFillSearch(POINT pos)
{
Sint32 startX, endX;
// Cherche la borne gauche.
startX = pos.x;
endX = pos.x;
while ( pos.x > 0 && ArrangeFillTest(pos) )
{
pos.x -= 2;
}
startX = pos.x+2;
// Cherche la borne droite.
pos.x = endX;
while ( pos.x < MAXCELX-2 && ArrangeFillTest(pos) )
{
pos.x += 2;
}
endX = pos.x-2;
// Rempli toute la ligne trouvée.
pos.x = startX;
while ( pos.x <= endX )
{
m_pFillMap[(pos.x/2)+(pos.y/2)*(MAXCELX/2)] = 1;
pos.x += 2;
}
// Cherche la ligne au-dessus.
if ( pos.y > 0 )
{
pos.y -= 2;
pos.x = startX;
while ( pos.x <= endX )
{
while ( pos.x <= endX && !ArrangeFillTest(pos) )
{
pos.x += 2;
}
if ( pos.x > endX ) break;
if ( ArrangeFillTest(pos) )
{
ArrangeFillSearch(pos); // appel récursif
}
while ( pos.x <= endX && ArrangeFillTest(pos) )
{
pos.x += 2;
}
}
pos.y += 2;
}
// Cherche la ligne au-dessous.
if ( pos.y < MAXCELY-2 )
{
pos.y += 2;
pos.x = startX;
while ( pos.x <= endX )
{
while ( pos.x <= endX && !ArrangeFillTest(pos) )
{
pos.x += 2;
}
if ( pos.x > endX ) break;
if ( ArrangeFillTest(pos) )
{
ArrangeFillSearch(pos); // appel récursif
}
while ( pos.x <= endX && ArrangeFillTest(pos) )
{
pos.x += 2;
}
}
}
}
// Rempli un sol à partir d'une position donnée.
void CDecor::ArrangeFill(POINT pos, Sint32 channel, Sint32 icon, bool bFloor)
{
m_bFillFloor = bFloor;
pos.x = (pos.x/2)*2;
pos.y = (pos.y/2)*2;
m_fillPutChannel = channel;
m_fillPutIcon = icon;
if ( bFloor )
{
GetFloor(pos, m_fillSearchChannel, m_fillSearchIcon);
}
else
{
GetObject(pos, m_fillSearchChannel, m_fillSearchIcon);
}
m_pFillMap = (char*)malloc(MAXCELX*MAXCELY*sizeof(char)/4);
if ( m_pFillMap == nullptr ) return;
memset(m_pFillMap, 0, MAXCELX*MAXCELY*sizeof(char)/4);
ArrangeFillSearch(pos);
for ( pos.x=0 ; pos.x<MAXCELX ; pos.x+=2 )
{
for ( pos.y=0 ; pos.y<MAXCELY ; pos.y+=2 )
{
if ( m_pFillMap[(pos.x/2)+(pos.y/2)*(MAXCELX/2)] == 1 )
{
ArrangeFillPut(pos, channel, icon);
}
}
}
free(m_pFillMap);
}
// Supprime tous les personnages bloqués dans des murs
// ou debout sur l'eau.
void CDecor::ArrangeBlupi()
{
Sint32 rank;
for ( rank=0 ; rank<MAXBLUPI ; rank++ )
{
if ( m_blupi[rank].bExist )
{
if ( !IsFreeCel(m_blupi[rank].cel, rank) )
{
m_blupi[rank].bExist = false;
}
}
}
}

View File

@ -415,10 +415,10 @@ static bool DoInit (Sint32 argc, char *argv[])
// Create a window.
if (g_bFullScreen)
g_window = SDL_CreateWindow (NAME, 0, 0, LXIMAGE, LYIMAGE,
SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_INPUT_GRABBED);
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_INPUT_GRABBED);
else
g_window = SDL_CreateWindow (NAME, SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, LXIMAGE, LYIMAGE, SDL_WINDOW_RESIZABLE);
SDL_WINDOWPOS_CENTERED, LXIMAGE, LYIMAGE, 0);
if (!g_window)
{
@ -434,8 +434,6 @@ static bool DoInit (Sint32 argc, char *argv[])
return false;
}
SDL_RenderSetLogicalSize (g_renderer, LXIMAGE, LYIMAGE);
if (!bOK) // config.ini pas correct ?
return InitFail ("Game not correctly installed", false);

View File

@ -1,640 +0,0 @@
// blupi.cpp
//
#include <stdlib.h>
#include <stdio.h>
#include "blupi.h"
#include "def.h"
#include "resource.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "movie.h"
#include "button.h"
#include "menu.h"
#include "jauge.h"
#include "event.h"
#include "misc.h"
// D�finitions globales
#define NAME "Blupi"
#define TITLE "Blupi"
// Variables globales
SDL_Window *g_window;
SDL_Renderer *g_renderer;
CEvent* g_pEvent = nullptr;
CPixmap* g_pPixmap = nullptr; // pixmap principal
CSound* g_pSound = nullptr; // sound principal
CMovie* g_pMovie = nullptr; // movie principal
CDecor* g_pDecor = nullptr;
bool g_bFullScreen = false; // false si mode de test
Sint32 g_speedRate = 1;
Sint32 g_timerInterval = 50; // inverval = 50ms
Sint32 g_mouseType = MOUSETYPEGRA;
bool g_bActive = true; // is application active ?
bool g_bTermInit = false; // initialisation en cours
Uint32 g_lastPhase = 999;
// Lit un num�ro d�cimal.
Sint32 GetNum(char *p)
{
Sint32 n = 0;
while ( *p >= '0' && *p <= '9' )
{
n *= 10;
n += (*p++)-'0';
}
return n;
}
// Lit le fichier de configuration.
bool ReadConfig(Sint32 argc, char *argv[])
{
FILE* file = nullptr;
char buffer[200];
char* pText;
size_t nb;
const auto config = GetBaseDir () + "data/config.ini";
file = fopen(config.c_str (), "rb");
if ( file == nullptr ) return false;
nb = fread(buffer, sizeof(char), 200-1, file);
buffer[nb] = 0;
fclose(file);
pText = strstr(buffer, "SpeedRate=");
if ( pText != nullptr )
{
g_speedRate = GetNum(pText+10);
if ( g_speedRate < 1 ) g_speedRate = 1;
if ( g_speedRate > 2 ) g_speedRate = 2;
}
pText = strstr(buffer, "Timer=");
if ( pText != nullptr )
{
g_timerInterval = GetNum(pText+6);
if ( g_timerInterval < 10 ) g_timerInterval = 10;
if ( g_timerInterval > 1000 ) g_timerInterval = 1000;
}
pText = strstr(buffer, "FullScreen=");
if ( pText != nullptr )
{
g_bFullScreen = !!GetNum(pText+11);
if ( g_bFullScreen != 0 ) g_bFullScreen = 1;
}
pText = strstr(buffer, "MouseType=");
if ( pText != nullptr )
{
g_mouseType = GetNum(pText+10);
if ( g_mouseType < 1 ) g_mouseType = 1;
if ( g_mouseType > 9 ) g_mouseType = 9;
}
return true;
}
// Mise � jour principale.
void UpdateFrame(void)
{
RECT clip, rcRect;
Uint32 phase;
POINT posMouse;
Sint32 i, term, speed;
posMouse = g_pEvent->GetLastMousePos();
phase = g_pEvent->GetPhase();
if (!(phase == g_lastPhase && phase == WM_PHASE_PLAY))
{
rcRect.left = 0;
rcRect.top = 0;
rcRect.right = LXIMAGE;
rcRect.bottom = LYIMAGE;
g_pPixmap->DrawImage(-1, CHBACK, rcRect); // dessine le fond
}
if ( phase == WM_PHASE_INTRO1 ||
phase == WM_PHASE_INTRO2 )
{
g_pEvent->IntroStep();
}
if ( phase == WM_PHASE_PLAY )
{
clip.left = POSDRAWX;
clip.top = POSDRAWY+g_pDecor->GetInfoHeight();
clip.right = POSDRAWX+DIMDRAWX;
clip.bottom = POSDRAWY+DIMDRAWY;
if ( g_pEvent->IsShift() ) // shift en cours ?
{
g_pEvent->DecorAutoShift(posMouse);
g_pDecor->Build(clip, posMouse); // construit juste le d�cor
}
else
{
if ( !g_pEvent->GetPause() )
{
speed = g_pEvent->GetSpeed() * g_speedRate;
for ( i=0 ; i<speed ; i++ )
{
g_pDecor->BlupiStep(i==0); // avance tous les blupi
g_pDecor->MoveStep(i==0); // avance tous les d�cors
g_pEvent->DemoStep(); // avance enregistrement/reproduction
}
}
g_pEvent->DecorAutoShift(posMouse);
g_pDecor->Build(clip, posMouse); // construit le d�cor
g_pDecor->NextPhase(1); // refait la carte de temps en temps
}
}
if ( phase == WM_PHASE_BUILD )
{
clip.left = POSDRAWX;
clip.top = POSDRAWY;
clip.right = POSDRAWX+DIMDRAWX;
clip.bottom = POSDRAWY+DIMDRAWY;
g_pEvent->DecorAutoShift(posMouse);
g_pDecor->Build(clip, posMouse); // construit le d�cor
g_pDecor->NextPhase(-1); // refait la carte chaque fois
}
if ( phase == WM_PHASE_INIT )
{
g_pEvent->DemoStep(); // d�marre �v. d�mo automatique
}
g_pEvent->DrawButtons();
g_lastPhase = phase;
if ( phase == WM_PHASE_H0MOVIE ||
phase == WM_PHASE_H1MOVIE ||
phase == WM_PHASE_H2MOVIE ||
phase == WM_PHASE_PLAYMOVIE ||
phase == WM_PHASE_WINMOVIE )
{
g_pEvent->MovieToStart(); // fait d�marrer un film si n�cessaire
}
if ( phase == WM_PHASE_INSERT )
{
g_pEvent->TryInsert();
}
if ( phase == WM_PHASE_PLAY )
{
term = g_pDecor->IsTerminated();
if ( term == 1 ) g_pEvent->ChangePhase(WM_PHASE_LOST); // perdu
if ( term == 2 ) g_pEvent->ChangePhase(WM_PHASE_WINMOVIE); // gagn�
}
}
void Benchmark()
{
Sint32 i;
POINT pos = { 0, 0 };
g_pPixmap->DrawIcon(-1, 2, 10, pos, 0);
pos.x = 300;
pos.y = 350;
for ( i=0 ; i<10000 ; i++ )
{
g_pPixmap->DrawIcon(-1, 2, i%4, pos, 0);
}
g_pPixmap->DrawIcon(-1, 2, 10, pos, 0);
g_pSound->Play(0);
}
// Restitue le jeu apr�s une activation en mode fullScreen.
bool RestoreGame()
{
if ( g_pPixmap == nullptr ) return false;
g_pEvent->RestoreGame();
return true;
}
// Lib�re le jeu avant une d�sactivation en mode fullScreen.
bool FlushGame()
{
if ( g_pPixmap == nullptr ) return false;
return g_pPixmap->Flush();
}
// Finished with all objects we use; release them.
static void FinishObjects(void)
{
if ( g_pMovie != nullptr )
{
delete g_pMovie;
g_pMovie = nullptr;
}
if ( g_pEvent != nullptr )
{
delete g_pEvent;
g_pEvent = nullptr;
}
if ( g_pDecor != nullptr )
{
delete g_pDecor;
g_pDecor = nullptr;
}
if ( g_pSound != nullptr )
{
g_pSound->StopMusic(); // stoppe la musique Midi
delete g_pSound;
g_pSound = nullptr;
}
if ( g_pPixmap != nullptr )
{
delete g_pPixmap;
g_pPixmap = nullptr;
}
}
void WindowProc2 (const SDL_Event &event)
{
POINT totalDim, iconDim;
if ( g_pEvent != nullptr &&
g_pEvent->TreatEvent(event) )
return;
switch (event.type)
{
case SDL_WINDOWEVENT:
{
switch (event.window.event)
{
case SDL_WINDOWEVENT_FOCUS_GAINED:
if (g_bFullScreen)
{
RestoreGame ();
g_lastPhase = 999;
}
if (!g_bFullScreen && g_bTermInit)
{
totalDim.x = 64;
totalDim.y = 66;
iconDim.x = 64;
iconDim.y = 66 / 2;
g_pPixmap->Cache (CHHILI, "image/hili.blp", totalDim, iconDim);
}
SDL_SetWindowTitle (g_window, "Blupi");
if (g_pSound != nullptr) g_pSound->RestartMusic ();
if (g_pMovie)
g_pMovie->Resume ();
return;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (g_bFullScreen)
{
FlushGame ();
}
SDL_SetWindowTitle (g_window, "Blupi -- stop");
if (g_pSound != nullptr) g_pSound->SuspendMusic ();
if (g_pMovie)
g_pMovie->Pause ();
return;
}
break;
}
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_F5:
g_pEvent->SetSpeed (1);
break;
case SDLK_F6:
g_pEvent->SetSpeed (2);
break;
case SDLK_F7:
g_pEvent->SetSpeed (4);
break;
case SDLK_F8:
g_pEvent->SetSpeed (8);
break;
}
break;
case SDL_USEREVENT:
{
switch (event.user.code)
{
case WM_UPDATE:
if (!g_pEvent->IsMovie ()) // pas de film en cours ?
{
if (g_bActive)
{
UpdateFrame ();
}
g_pPixmap->Display ();
}
break;
case WM_MUSIC_STOP:
if (g_pSound->IsStoppedOnDemand ())
break;
g_pSound->RestartMusic ();
break;
case WM_MOVIE_PLAY:
if (!g_pMovie->Render ())
g_pEvent->StopMovie ();
break;
}
break;
}
}
}
// Erreur dans DoInit.
static bool InitFail(const char *msg, bool bDirectX)
{
char buffer[100];
if ( bDirectX ) strcpy(buffer, "DirectX Init FAILED\n(while ");
else strcpy(buffer, "Error (");
strcat(buffer, msg);
strcat(buffer, ")");
SDL_ShowSimpleMessageBox (SDL_MessageBoxFlags::SDL_MESSAGEBOX_ERROR, "Error", buffer, g_window);
FinishObjects();
return false;
}
// Initialisation de l'application.
static bool DoInit(Sint32 argc, char *argv[])
{
POINT totalDim, iconDim;
RECT rcRect;
bool bOK;
bOK = ReadConfig(argc, argv); // lit le fichier config.ini
auto res = SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
if (res < 0)
return false;
// Create a window.
if ( g_bFullScreen )
{
g_window = SDL_CreateWindow (NAME, 0, 0, LXIMAGE, LYIMAGE, SDL_WINDOW_FULLSCREEN);
}
else
{
g_window = SDL_CreateWindow (NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, LXIMAGE, LYIMAGE, 0);
}
if (!g_window)
{
printf (SDL_GetError ());
return false;
}
g_renderer = SDL_CreateRenderer (g_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE | SDL_RENDERER_PRESENTVSYNC);
if (!g_renderer)
{
printf (SDL_GetError ());
SDL_DestroyWindow (g_window);
return false;
}
SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, "linear");
if ( !bOK ) // config.ini pas correct ?
{
return InitFail("Game not correctly installed", false);
}
// Cr�e le pixmap principal.
g_pPixmap = new CPixmap;
if ( g_pPixmap == nullptr ) return InitFail("New pixmap", true);
totalDim.x = LXIMAGE;
totalDim.y = LYIMAGE;
if ( !g_pPixmap->Create(totalDim, g_bFullScreen, g_mouseType) )
return InitFail("Create pixmap", true);
OutputDebug("Image: init\n");
totalDim.x = LXIMAGE;
totalDim.y = LYIMAGE;
iconDim.x = 0;
iconDim.y = 0;
#if _INTRO
if ( !g_pPixmap->Cache(CHBACK, "image/intro1.blp", totalDim, iconDim) )
#else
if ( !g_pPixmap->Cache(CHBACK, "image/init.blp", totalDim, iconDim) )
#endif
return false;
OutputDebug("Image: init\n");
totalDim.x = LXIMAGE;
totalDim.y = LYIMAGE;
iconDim.x = 0;
iconDim.y = 0;
if ( !g_pPixmap->Cache(CHGROUND, "image/init.blp", totalDim, iconDim) )
return false;
rcRect.left = 0;
rcRect.top = 0;
rcRect.right = LXIMAGE;
rcRect.bottom = LYIMAGE;
g_pPixmap->DrawImage(-1, CHBACK, rcRect); // dessine le fond
g_pPixmap->Display();
totalDim.x = DIMCELX*2*16;
totalDim.y = DIMCELY*2*6;
iconDim.x = DIMCELX*2;
iconDim.y = DIMCELY*2;
if ( !g_pPixmap->Cache(CHFLOOR, "image/floor000.blp", totalDim, iconDim) )
return InitFail("Cache floor000.blp", true);
totalDim.x = DIMOBJX*16;
totalDim.y = DIMOBJY*8;
iconDim.x = DIMOBJX;
iconDim.y = DIMOBJY;
if ( !g_pPixmap->Cache(CHOBJECT, "image/obj000.blp", totalDim, iconDim) )
return InitFail("Cache obj000.blp", true);
if ( !g_pPixmap->Cache(CHOBJECTo, "image/obj-o000.blp", totalDim, iconDim) )
return InitFail("Cache obj-o000.blp", true);
totalDim.x = DIMBLUPIX*16;
totalDim.y = DIMBLUPIY*23;
iconDim.x = DIMBLUPIX;
iconDim.y = DIMBLUPIY;
if ( !g_pPixmap->Cache(CHBLUPI, "image/blupi.blp", totalDim, iconDim) )
return InitFail("Cache blupi.blp", true);
totalDim.x = 64;
totalDim.y = 66;
iconDim.x = 64;
iconDim.y = 66/2;
if ( !g_pPixmap->Cache(CHHILI, "image/hili.blp", totalDim, iconDim) )
return InitFail("Cache hili.blp", true);
totalDim.x = DIMCELX*2*3;
totalDim.y = DIMCELY*2*5;
iconDim.x = DIMCELX*2;
iconDim.y = DIMCELY*2;
if ( !g_pPixmap->Cache(CHFOG, "image/fog.blp", totalDim, iconDim) )
return InitFail("Cache fog.blp", true);
totalDim.x = DIMCELX*2*16;
totalDim.y = DIMCELY*2*1;
iconDim.x = DIMCELX*2;
iconDim.y = DIMCELY*2;
if ( !g_pPixmap->Cache(CHMASK1, "image/mask1.blp", totalDim, iconDim) )
return InitFail("Cache mask1.blp", true);
totalDim.x = DIMBUTTONX*6;
totalDim.y = DIMBUTTONY*21;
iconDim.x = DIMBUTTONX;
iconDim.y = DIMBUTTONY;
if ( !g_pPixmap->Cache(CHBUTTON, "image/button00.blp", totalDim, iconDim) )
return InitFail("Cache button00.blp", true);
totalDim.x = DIMJAUGEX*1;
totalDim.y = DIMJAUGEY*4;
iconDim.x = DIMJAUGEX;
iconDim.y = DIMJAUGEY;
if ( !g_pPixmap->Cache(CHJAUGE, "image/jauge.blp", totalDim, iconDim) )
return InitFail("Cache jauge.blp", true);
totalDim.x = DIMTEXTX*16;
totalDim.y = DIMTEXTY*8*3;
iconDim.x = DIMTEXTX;
iconDim.y = DIMTEXTY;
if ( !g_pPixmap->Cache(CHTEXT, "image/text.blp", totalDim, iconDim) )
return InitFail("Cache text.blp", true);
totalDim.x = DIMLITTLEX*16;
totalDim.y = DIMLITTLEY*8;
iconDim.x = DIMLITTLEX;
iconDim.y = DIMLITTLEY;
if ( !g_pPixmap->Cache(CHLITTLE, "image/little.blp", totalDim, iconDim) )
return InitFail("Cache little.blp", true);
totalDim.x = 426;
totalDim.y = 52;
iconDim.x = 426;
iconDim.y = 52;
if ( !g_pPixmap->Cache(CHBIGNUM, "image/bignum.blp", totalDim, iconDim) )
return InitFail("Cache bignum.blp", true);
// Load all cursors
g_pPixmap->LoadCursors ();
g_pPixmap->ChangeSprite (SPRITE_WAIT); // met le sablier maison
// Cr�e le gestionnaire de son.
g_pSound = new CSound;
if ( g_pSound == nullptr ) return InitFail("New sound", true);
g_pSound->Create();
g_pSound->CacheAll();
g_pSound->SetState(true);
// Cr�e le gestionnaire de films.
g_pMovie = new CMovie;
if ( g_pMovie == nullptr ) return InitFail("New movie", false);
g_pMovie->Create();
// Cr�e le gestionnaire de d�cors.
g_pDecor = new CDecor;
if ( g_pDecor == nullptr ) return InitFail("New decor", false);
g_pDecor->Create(g_pSound, g_pPixmap);
g_pDecor->MapInitColors();
// Cr�e le gestionnaire d'�v�nements.
g_pEvent = new CEvent;
if ( g_pEvent == nullptr ) return InitFail("New event", false);
g_pEvent->Create(g_pPixmap, g_pDecor, g_pSound, g_pMovie);
g_pEvent->SetFullScreen(g_bFullScreen);
g_pEvent->SetMouseType(g_mouseType);
#if _INTRO
g_pEvent->ChangePhase(WM_PHASE_INTRO1);
#else
g_pEvent->ChangePhase(WM_PHASE_TESTCD);
#endif
g_bTermInit = true; // initialisation termin�e
return true;
}
// Programme principal.
Sint32 main (Sint32 argc, char *argv[])
{
if (!DoInit(argc, argv))
return -1;
SDL_TimerID updateTimer = SDL_AddTimer (g_timerInterval, [] (Uint32 interval, void *param) -> Uint32
{
CEvent::PushUserEvent (WM_UPDATE);
return interval;
}, nullptr);
SDL_Event event;
while (SDL_WaitEvent (&event))
{
WindowProc2 (event);
if (event.type == SDL_QUIT)
break;
}
if (g_window)
SDL_DestroyWindow (g_window);
SDL_RemoveTimer (updateTimer);
FinishObjects ();
SDL_Quit ();
return 0;
}

View File

@ -1,50 +0,0 @@
#pragma once
#include <SDL2/SDL.h>
#include <libintl.h>
extern SDL_Window *g_window;
extern SDL_Renderer *g_renderer;
struct POINT
{
Sint32 x;
Sint32 y;
};
struct RECT
{
Sint32 left;
Sint32 top;
Sint32 right;
Sint32 bottom;
};
typedef Uint32 COLORREF;
#if defined(_WIN64)
typedef unsigned __int64 WPARAM;
typedef __int64 LPARAM;
#else
typedef Uint32 WPARAM;
typedef Sint32 LPARAM;
#endif
#define LOWORD(l) ((Uint16)(((Uint32)(l)) & 0xffff))
#define HIWORD(l) ((Uint16)((((Uint32)(l)) >> 16) & 0xffff))
#define MAX_PATH 260
#define VK_END 0x23
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define WM_KEYDOWN 0x0100
#define WM_KEYUP 0x0101
#define WM_MOUSEMOVE 0x0200
#define WM_LBUTTONDOWN 0x0201
#define WM_LBUTTONUP 0x0202
#define WM_RBUTTONDOWN 0x0204
#define WM_RBUTTONUP 0x0205

View File

@ -1,440 +0,0 @@
// Button.cpp
//
#include <stdlib.h>
#include <stdio.h>
#include "gettext.h"
#include "def.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "button.h"
#include "misc.h"
#include "event.h"
/////////////////////////////////////////////////////////////////////////////
// Constructeur.
CButton::CButton()
{
m_type = 0;
m_bEnable = true;
m_bHide = false;
m_state = 0;
m_mouseState = 0;
m_nbMenu = 0;
m_nbToolTips = 0;
m_selMenu = 0;
m_bMouseDown = false;
m_bMinimizeRedraw = false;
m_bRedraw = false;
m_message = static_cast<Uint32> (-1);
}
// Destructeur.
CButton::~CButton()
{
}
// Crée un nouveau bouton.
bool CButton::Create(CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 type, bool bMinimizeRedraw,
Sint32 *pMenu, Sint32 nbMenu,
const char **pToolTips,
Sint32 region, Uint32 message)
{
POINT iconDim;
Sint32 i, icon;
static Sint32 ttypes[] =
{
DIMBUTTONX,DIMBUTTONY, // button00.bmp
};
if ( type < 0 || type > 0 ) return false;
iconDim.x = ttypes[type*2+0];
iconDim.y = ttypes[type*2+1];
m_pPixmap = pPixmap;
m_pSound = pSound;
m_type = type;
m_bMinimizeRedraw = bMinimizeRedraw;
m_bEnable = true;
m_bHide = false;
m_message = message;
m_pos = pos;
m_dim = iconDim;
m_nbMenu = nbMenu;
m_selMenu = 0;
m_state = 0;
m_mouseState = 0;
m_bMouseDown = false;
m_bRedraw = true;
m_nbToolTips = 0;
while (pToolTips[m_nbToolTips])
++m_nbToolTips;
for ( i=0 ; i<nbMenu ; i++ )
{
icon = pMenu[i];
if ( region == 1 ) // palmiers ?
{
if ( icon == 0 ) icon = 90; // sol normal
if ( icon == 1 ) icon = 91; // sol inflammable
if ( icon == 2 ) icon = 92; // sol inculte
if ( icon == 7 ) icon = 9; // plante
if ( icon == 8 ) icon = 10; // arbre
}
if ( region == 2 ) // hiver ?
{
if ( icon == 0 ) icon = 96; // sol normal
if ( icon == 1 ) icon = 97; // sol inflammable
if ( icon == 2 ) icon = 98; // sol inculte
if ( icon == 8 ) icon = 99; // arbre
}
if ( region == 3 ) // sapin ?
{
if ( icon == 0 ) icon = 102; // sol normal
if ( icon == 1 ) icon = 103; // sol inflammable
if ( icon == 2 ) icon = 104; // sol inculte
if ( icon == 8 ) icon = 105; // arbre
}
m_iconMenu[i] = icon;
}
m_toolTips = pToolTips;
return true;
}
// Dessine un bouton dans son état.
void CButton::Draw()
{
Sint32 i;
POINT pos;
RECT rect;
if ( m_bMinimizeRedraw && !m_bRedraw ) return;
m_bRedraw = false;
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;
}
if ( m_bEnable ) // bouton actif ?
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_mouseState, m_pos);
}
else
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, 4, m_pos);
}
if ( m_nbMenu == 0 ) return;
pos = m_pos;
if ( m_nbMenu > 0 )
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type,
m_iconMenu[m_selMenu]+6, pos);
}
if ( m_nbMenu == 1 || !m_bEnable || !m_bMouseDown ) return;
pos = m_pos;
pos.x += m_dim.x+2;
for ( i=0 ; i<m_nbMenu ; i++ )
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, i==m_selMenu?1:0, pos);
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_iconMenu[i]+6, pos);
pos.x += m_dim.x-1;
}
}
void CButton::Redraw()
{
m_bRedraw = true;
}
Sint32 CButton::GetState()
{
return m_state;
}
void CButton::SetState(Sint32 state)
{
if ( m_state != state ||
m_mouseState != state )
{
m_bRedraw = true;
}
m_state = state;
m_mouseState = state;
}
Sint32 CButton::GetMenu()
{
return m_selMenu;
}
void CButton::SetMenu(Sint32 menu)
{
if ( m_selMenu != menu )
{
m_bRedraw = true;
}
m_selMenu = menu;
}
bool CButton::GetEnable()
{
return m_bEnable;
}
void CButton::SetEnable(bool bEnable)
{
if ( m_bEnable != bEnable )
{
m_bRedraw = true;
}
m_bEnable = bEnable;
}
bool CButton::GetHide()
{
return m_bHide;
}
void CButton::SetHide(bool bHide)
{
if ( m_bHide != bHide )
{
m_bRedraw = true;
}
m_bHide = bHide;
}
// Traitement d'un événement.
bool CButton::TreatEvent(const SDL_Event &event)
{
POINT pos;
if ( m_bHide || !m_bEnable ) return false;
//pos = ConvLongToPos(lParam);
switch (event.type)
{
case SDL_MOUSEBUTTONDOWN:
if ( event.button.button != SDL_BUTTON_LEFT
&& event.button.button != SDL_BUTTON_RIGHT)
break;
pos.x = event.button.x;
pos.y = event.button.y;
if ( MouseDown(pos) ) return true;
break;
case SDL_MOUSEMOTION:
pos.x = event.motion.x;
pos.y = event.motion.y;
if ( MouseMove(pos) ) return true;
break;
case SDL_MOUSEBUTTONUP:
if ( event.button.button != SDL_BUTTON_LEFT
&& event.button.button != SDL_BUTTON_RIGHT)
break;
pos.x = event.button.x;
pos.y = event.button.y;
if ( MouseUp(pos) ) return false; // (*)
break;
}
return false;
}
// (*) Tous les boutons doivent recevoir l'événement BUTTONUP !
// Indique si la souris est sur ce bouton.
bool CButton::MouseOnButton(POINT pos)
{
return Detect(pos);
}
// Retourne le tooltips pour un bouton, en fonction
// de la position de la souris.
const char *CButton::GetToolTips(POINT pos)
{
Sint32 width = m_dim.x;
Sint32 rank;
if (m_bHide || !m_bEnable)
return nullptr;
if ( m_nbMenu > 1 && m_bMouseDown ) // sous-menu déroulé ?
{
width += 2+(m_dim.x-1)*m_nbMenu;
}
if ( pos.x < m_pos.x
|| pos.x > m_pos.x+width
|| pos.y < m_pos.y
|| pos.y > m_pos.y+m_dim.y)
return nullptr;
rank = (pos.x-(m_pos.x+2+1))/(m_dim.x-1);
if ( rank < 0 ) rank = 0;
if (rank > m_nbToolTips)
return nullptr;
if ( m_nbMenu > 1 )
{
if ( m_bMouseDown && rank > 0 )
{
rank --;
}
else
{
rank = m_selMenu;
}
}
return gettext (m_toolTips[rank]);
}
// Détecte si la souris est dans le bouton.
bool CButton::Detect(POINT pos)
{
Sint32 width = m_dim.x;
if ( m_bHide || !m_bEnable ) return false;
if ( m_nbMenu > 1 && m_bMouseDown ) // sous-menu déroulé ?
{
width += 2+(m_dim.x-1)*m_nbMenu;
}
if ( pos.x < m_pos.x ||
pos.x > m_pos.x+width ||
pos.y < m_pos.y ||
pos.y > m_pos.y+m_dim.y ) return false;
return true;
}
// Bouton de la souris pressé.
bool CButton::MouseDown(POINT pos)
{
if ( !Detect(pos) ) return false;
m_mouseState = 1;
m_bMouseDown = true;
m_bRedraw = true;
CEvent::PushUserEvent (WM_UPDATE);
m_pSound->PlayImage(SOUND_CLICK, pos);
return true;
}
// Souris déplacés.
bool CButton::MouseMove(POINT pos)
{
bool bDetect;
Sint32 iState, iMenu;
iState = m_mouseState;
iMenu = m_selMenu;
bDetect = Detect(pos);
if ( m_bMouseDown )
{
if ( bDetect ) m_mouseState = 1; // pressé
else m_mouseState = m_state;
}
else
{
if ( bDetect ) m_mouseState = m_state+2; // survollé
else m_mouseState = m_state;
}
if ( m_nbMenu > 1 &&
m_bMouseDown &&
pos.x > m_pos.x+m_dim.x+2 ) // dans sous-menu ?
{
m_selMenu = (pos.x-(m_pos.x+m_dim.x+2))/(m_dim.x-1);
if ( m_selMenu >= m_nbMenu )
{
m_selMenu = m_nbMenu-1;
}
}
if ( iState != m_mouseState ||
iMenu != m_selMenu )
{
m_bRedraw = true;
CEvent::PushUserEvent (WM_UPDATE);
}
return m_bMouseDown;
}
// Bouton de la souris relâché.
bool CButton::MouseUp(POINT pos)
{
bool bDetect;
bDetect = Detect(pos);
m_mouseState = m_state;
m_bMouseDown = false;
m_bRedraw = true;
if ( !bDetect ) return false;
if ( m_message != static_cast<Uint32> (-1) )
{
CEvent::PushUserEvent (m_message);
}
return true;
}

View File

@ -1,68 +0,0 @@
// Button.h
#pragma once
#include <vector>
/////////////////////////////////////////////////////////////////////////////
class CButton
{
public:
CButton();
~CButton();
bool Create(CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 type, bool bMinimizeRedraw,
Sint32 *pMenu, Sint32 nbMenu,
const char **pToolTips,
Sint32 region, Uint32 message);
void Draw();
void Redraw();
Sint32 GetState();
void SetState(Sint32 state);
Sint32 GetMenu();
void SetMenu(Sint32 menu);
bool GetEnable();
void SetEnable(bool bEnable);
bool GetHide();
void SetHide(bool bHide);
bool TreatEvent(const SDL_Event &event);
bool MouseOnButton(POINT pos);
const char *GetToolTips(POINT pos);
protected:
bool Detect(POINT pos);
bool MouseDown(POINT pos);
bool MouseMove(POINT pos);
bool MouseUp(POINT pos);
protected:
CPixmap* m_pPixmap;
CDecor* m_pDecor;
CSound* m_pSound;
Sint32 m_type; // type de bouton
bool m_bEnable; // true si bouton actif
bool m_bHide; // true si bouton caché
Uint32 m_message; // message envoyé si bouton actionné
POINT m_pos; // coin sup/gauche
POINT m_dim; // dimensions
Sint32 m_state; // 0=relâché, 1=pressé, +2=survollé
Sint32 m_mouseState; // 0=relâché, 1=pressé, +2=survollé
Sint32 m_iconMenu[20]; // icônes du sous-menu
const char **m_toolTips; // info-bulles
Sint32 m_nbMenu; // nb de case du sous-menu
Sint32 m_nbToolTips; // nb d'info-bulles
Sint32 m_selMenu; // sous-menu sélectionné
bool m_bMouseDown; // true -> bouton souris pressé
bool m_bMinimizeRedraw;
bool m_bRedraw; // true -> doit être redessiné
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,369 +0,0 @@
// chemin.cpp
// (c) 1997, Denis Dumoulin
#include "decor.h"
#include "fifo.h"
#include "action.h"
// Mémorise toutes les positions des blupi.
void CDecor::CheminMemPos(Sint32 exRank)
{
Sint32 rank, index;
m_cheminNbPos = 0;
index = 0;
for ( rank=0 ; rank<MAXBLUPI ; rank++ )
{
if ( m_blupi[rank].bExist &&
m_blupi[rank].perso != 6 && // pas le détonnateur de mine
rank != exRank )
{
m_cheminPos[index] = m_blupi[rank].cel;
m_cheminRank[index] = rank;
m_cheminNbPos ++;
index ++;
if ( m_blupi[rank].destCel.x != m_blupi[rank].cel.x ||
m_blupi[rank].destCel.y != m_blupi[rank].cel.y )
{
m_cheminPos[index] = m_blupi[rank].destCel;
m_cheminRank[index] = rank;
m_cheminNbPos ++;
index ++;
}
}
}
}
// Teste si une positiion est occupée par un blupi.
bool CDecor::CheminTestPos(POINT pos, Sint32 &rank)
{
Sint32 i;
for ( i=0 ; i<m_cheminNbPos ; i++ )
{
if ( pos.x == m_cheminPos[i].x &&
pos.y == m_cheminPos[i].y )
{
rank = m_cheminRank[i];
return true;
}
}
return false;
}
// une fois le but trouvé, reprend en arrière
// à la recherche du chemin le plus court
// retourne la direction à prendre
Sint32 CDecor::CheminARebours(Sint32 rank)
{
Sint32 pos, rebours, last, dir, set;
POINT v;
pos = m_blupi[rank].goalCel.y*MAXCELX + m_blupi[rank].goalCel.x;
rebours = m_cheminWork[pos];
if ( rebours == 0 ) return -1;
while ( true )
{
bis:
for ( set=0 ; set<2 ; set++ )
{
for ( dir=set ; dir<8 ; dir+=2 )
{
v = GetVector(dir*16);
last = pos + v.y*MAXCELX+v.x;
if ( m_cheminWork[last] > 0 &&
m_cheminWork[last] < rebours )
{
pos = last;
rebours = m_cheminWork[pos];
if (rebours==1) return (dir>=4) ? dir-4 : dir+4;
goto bis; // interrompt le for...
}
}
}
// ne devrait jamais arriver !
return -1;
}
}
// troisième méthode de recherche
// semblable à la précédente,
// mais les points à explorer sont classés selon leur distance à la cible
void CDecor::CheminFillTerrain(Sint32 rank)
{
Sint32 pos, last, dest, dist;
Sint32 step, dir, cout, action, max, next, ampli;
Sint32 dx, dy;
Sint32 but = 1000;
if ( m_blupi[rank].cel.x == m_blupi[rank].goalCel.x &&
m_blupi[rank].cel.y == m_blupi[rank].goalCel.y ) return;
pos = m_blupi[rank].cel.y*MAXCELX + m_blupi[rank].cel.x;
dest = m_blupi[rank].goalCel.y*MAXCELX + m_blupi[rank].goalCel.x;
CPileTriee fifo(2*MAXCELX+2*MAXCELY); // les variantes possibles
fifo.put(pos, 0); // position de départ
m_cheminWork[pos] = 1; // première position
// répète jusqu'à trouvé ou plus de possibilités
max = 500;
while ( max-- > 0 )
{
// reprend une variante de chemin
pos = fifo.get();
if ( pos < 0 ) break;
step = m_cheminWork[pos];
// on est arrivé au but ?
//? if ( pos == dest ) return;
if ( pos == dest )
{
but = step; // hélas trop lent !
max = 50;
}
// est-ce vraiment trop loin ?
if ( step > 200 ) return;
// marque les cases autour du point
if ( step < but ) for ( dir=0 ; dir<8 ; dir++ )
{
if ( CheminTestDirection(rank, pos, dir, next, ampli, cout, action) )
{
last = pos + ampli*next;
if ( last<0 || last>=MAXCELX*MAXCELY ) continue;
if ( m_cheminWork[last] == 0 ||
m_cheminWork[last] > step+cout )
{
// marque les cases sautées
for (Sint32 i=1; i<ampli;i++)
{
m_cheminWork[pos+i*next] = step+cout-ampli+i;
}
m_cheminWork[last] = step+cout;
//? char buffer[50];
//? sprintf(buffer, "word = %d;%d %d\n", last%200, last/200, step+cout);
//? OutputDebug(buffer);
dx = m_blupi[rank].goalCel.x - last%MAXCELX;
dy = m_blupi[rank].goalCel.y - last/MAXCELX;
//? dist = dy*dy + dx*dx;
dist = (Sint32)(dy*dy) + (Sint32)(dx*dx);
fifo.put(last, dist);
}
}
}
}
}
// routine déterninant si une direction est possible
// retourne l'incrément pour passer à la nouvelle case
// et le "prix à payer" pour aller dans cette direction
// coût doit être déterminé en sortie
bool CDecor::CheminTestDirection(Sint32 rank, Sint32 pos, Sint32 dir,
Sint32 &next, Sint32 &ampli,
Sint32 &cout, Sint32 &action)
{
POINT cel, vector, newCel;
bool bFree;
Sint32 tryDirect, workBlupi, rankHere;
cel.x = pos%MAXCELX;
cel.y = pos/MAXCELX;
tryDirect = dir*16;
vector = GetVector(tryDirect);
// Peut-on glisser dans cette direction ?
bFree = IsFreeGlisse(cel, tryDirect, rank, action);
cout = 5; // coût élevé
if ( !bFree )
{
// Peut-on marcher normalement ?
bFree = IsFreeDirect(cel, tryDirect, rank);
action = ACTION_MARCHE;
cout = 1; // coût minimal
}
if ( !bFree )
{
// Peut-on sauter ?
bFree = IsFreeJump(cel, tryDirect, rank, action);
cout = 3; // coût élevé
}
ampli = GetAmplitude(action); // a <- amplitude (1..5)
cout *= ampli; // coût plus élevé si grande amplitude
// Blupi peut aller sur le lieu de la construction.
if ( !bFree && m_blupi[rank].passCel.x != -1 )
{
newCel = m_blupi[rank].passCel;
workBlupi = m_decor[newCel.x/2][newCel.y/2].workBlupi;
if ( m_blupi[rank].passCel.x/2 == (cel.x+vector.x*ampli)/2 &&
m_blupi[rank].passCel.y/2 == (cel.y+vector.y*ampli)/2 &&
(workBlupi < 0 || workBlupi == rank) )
{
bFree = true;
cout = 1;
}
}
if ( bFree ) // chemin libre (sans tenir compte des perso) ?
{
newCel.x = cel.x + vector.x*ampli;
newCel.y = cel.y + vector.y*ampli; // newCel <- arrivée suposée
if ( m_blupi[rank].perso == 3 ) // tracks ?
{
// Le tracks peut aller sur les blupi
// pour les écraser !
if ( IsTracksHere(newCel, false) ) // autre perso ici ?
{
return false;
}
}
else
{
//? if ( IsBlupiHere(newCel, false) ) // autre perso ici ?
if ( CheminTestPos(newCel, rankHere) ) // autre perso ici ?
{
// Si blupi immobile, comme si obstacle qq.
//? if ( m_blupi[m_blupiHere].goalCel.x == -1 ) return false;
if ( m_blupi[rankHere].goalCel.x == -1 ) return false;
// Si blupi mobile, possible mais coût élevé.
cout = 20;
}
}
next = vector.y*MAXCELX + vector.x;
return true;
}
return false;
}
// Retourne true si on a assigné une nouvelle direction à blupi.
bool CDecor::CheminCherche(Sint32 rank, Sint32 &action)
{
Sint32 cout; // prix pour aller dans une direction
Sint32 pos, dir, next, ampli;
// Déjà à destination ?
if ( m_blupi[rank].cel.x == m_blupi[rank].goalCel.x &&
m_blupi[rank].cel.y == m_blupi[rank].goalCel.y )
{
return false;
}
// Destination occupée ?
if ( IsBlupiHereEx(m_blupi[rank].goalCel, rank, false) )
{
return false;
}
memset(m_cheminWork, 0, (Uint8)MAXCELX*(Uint8)MAXCELY);
CheminMemPos(rank);
// fait un remplissage du map de travail
// autour du point de départ
CheminFillTerrain(rank);
// cherche le chemin à partir de la destination
dir = CheminARebours(rank);
if ( dir < 0 ) return false;
pos = m_blupi[rank].cel.y*MAXCELX + m_blupi[rank].cel.x;
if ( CheminTestDirection(rank, pos, dir, next, ampli, cout, action) &&
cout < 20 )
{
m_blupi[rank].sDirect = 16*dir;
return true;
}
// ne devrait jamais arriver !
return false;
}
// Teste s'il est possible de se rendre à un endroit donné.
bool CDecor::IsCheminFree(Sint32 rank, POINT dest, Sint32 button)
{
Sint32 action, sDirect;
POINT goalCel, passCel, limit;
bool bOK;
if ( button == BUTTON_STOP ) return true;
goalCel = m_blupi[rank].goalCel;
passCel = m_blupi[rank].passCel;
sDirect = m_blupi[rank].sDirect;
if ( IsFreeCelEmbarque(dest, rank, action, limit) )
{
dest = limit;
}
if ( IsFreeCelDebarque(dest, rank, action, limit) )
{
dest = limit;
}
if ( button == BUTTON_GO &&
m_decor[dest.x/2][dest.y/2].objectChannel == CHOBJECT &&
(m_decor[dest.x/2][dest.y/2].objectIcon == 118 || // jeep ?
m_decor[dest.x/2][dest.y/2].objectIcon == 16 ) && // armure ?
dest.x%2 == 1 && dest.y%2 == 1 )
{
dest.y --; // va à côté jeep/armure
}
if ( button == BUTTON_GO &&
m_decor[dest.x/2][dest.y/2].objectChannel == CHOBJECT &&
m_decor[dest.x/2][dest.y/2].objectIcon == 113 ) // maison ?
{
dest.x = (dest.x/2)*2+1;
dest.y = (dest.y/2)*2+1; // sous la porte
}
if ( m_blupi[rank].cel.x == dest.x &&
m_blupi[rank].cel.y == dest.y ) return true;
m_blupi[rank].goalCel = dest;
if ( m_decor[dest.x/2][dest.y/2].objectChannel == CHOBJECT &&
button != BUTTON_GO )
{
m_blupi[rank].passCel = dest; // si arbres/fleurs/bateau/etc.
}
bOK = CheminCherche(rank, action);
m_blupi[rank].goalCel = goalCel;
m_blupi[rank].passCel = passCel;
m_blupi[rank].sDirect = sDirect;
return bOK;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +0,0 @@
#pragma once
#include <SDL2/SDL_stdinc.h>
// Méta opérations (goal).
#define GOAL_TERM 0 //
#define GOAL_GOHILI 1 // dx,dy, bPass
#define GOAL_GOHILI2 2 // dx,dy, bPass
#define GOAL_GOBLUPI 3 // dx,dy, bPass
#define GOAL_PUTFLOOR 4 // dx,dy, channel,icon
#define GOAL_PUTOBJECT 5 // dx,dy, channel,icon
#define GOAL_BUILDFLOOR 6 // dx,dy, ch,i,mch, mi,total,delai,step
#define GOAL_BUILDOBJECT 7 // dx,dy, ch,i,mch, mi,total,delai,step
#define GOAL_ACTION 8 // action,direction
#define GOAL_INTERRUPT 9 // niveau (0..2)
#define GOAL_ENERGY 10 // niveau minimum requis
#define GOAL_ADDMOVES 11 // dx,dy,no
#define GOAL_OTHER 12 // channel,first,last,fitst,last,action
#define GOAL_FINISHMOVE 13 //
#define GOAL_TAKE 14 // dx,dy
#define GOAL_DEPOSE 15 //
#define GOAL_GROUP 16 // nb
#define GOAL_WORK 17 // dx,dy
#define GOAL_TESTOBJECT 18 // dx,dy, channel,icon
#define GOAL_FIX 19 // dx,dy
#define GOAL_OTHERFIX 20 // channel,first,last,first,last,action
#define GOAL_ADDICONS 21 // dx,dy,no
#define GOAL_NEWBLUPI 22 // dx,dy
#define GOAL_SOUND 23 // sound
#define GOAL_REPEAT 24 // true/false
#define GOAL_OTHERLOOP 25 // action
#define GOAL_NEXTLOOP 26 //
#define GOAL_ARRANGEOBJECT 27 // dx,dy
#define GOAL_LABO 28 //
#define GOAL_CACHE 29 // true/false, bDynamite
#define GOAL_DELETE 30 //
#define GOAL_ELECTRO 31 // dx,dy,no
#define GOAL_NEWPERSO 32 // dx,dy, perso
#define GOAL_USINEBUILD 33 // dx,dy,
#define GOAL_USINEFREE 34 // dx,dy,
#define GOAL_EXPLOSE1 35 // dx,dy
#define GOAL_EXPLOSE2 36 // dx,dy
#define GOAL_VEHICULE 37 // type
#define GOAL_TAKEOBJECT 38 // dx,dy, channel,icon
#define GOAL_FLOORJUMP 39 // channel,icon,action
#define GOAL_ADDDRAPEAU 40 // dx,dy
#define GOAL_AMORCE 41 // dx,dy
#define GOAL_MALADE 42 // bMalade
#define GOAL_IFTERM 43 // dx,dy
#define GOAL_IFDEBARQUE 44 // dx,dy
#define GOAL_ISNOMALADE 45 //
#define GOAL_SKIPSKILL 46 // skill,d
#define GOAL_TELEPORTE 47 // dx,dy
#define GOAL_ACTUALISE 48 //
#define GOAL_WAITFREE 49 // dx,dy
Sint16* GetTableGoal (Sint32 action);
extern Sint16 table_goal_nbop[];

View File

@ -1,489 +0,0 @@
// DecIO.cpp
//
#include "def.h"
#include "decor.h"
#include "misc.h"
typedef struct
{
Sint16 majRev;
Sint16 minRev;
Sint32 nbDecor;
Sint32 lgDecor;
Sint32 nbBlupi;
Sint32 lgBlupi;
Sint32 nbMove;
Sint32 lgMove;
Sint16 reserve1[100];
POINT celCoin;
Sint16 world;
Sint32 time;
char buttonExist[MAXBUTTON];
Term term;
Sint16 music;
Sint16 region;
Sint32 totalTime;
Sint16 skill;
POINT memoPos[4];
Sint16 reserve2[29];
}
DescFile;
typedef struct
{
Sint32 bExist; // true -> utilisé
Sint32 bHili; // true -> sélectionné
Sint16 perso; // personnage, voir (*)
Sint16 goalAction; // action (Sint32 terme)
Sint16 goalPhase; // phase (Sint32 terme)
POINT goalCel; // cellule visée (Sint32 terme)
POINT passCel; // cellule tranversante
Sint16 energy; // énergie restante
POINT cel; // cellule actuelle
POINT destCel; // cellule destination
Sint16 action; // action en cours
Sint16 aDirect; // direction actuelle
Sint16 sDirect; // direction souhaitée
POINT pos; // position relative à partir de la cellule
Sint16 posZ; // déplacement z
Sint16 channel;
Sint16 lastIcon;
Sint16 icon;
Sint16 phase; // phase dans l'action
Sint16 step; // pas global
Sint16 interrupt; // 0=prioritaire, 1=normal, 2=misc
Sint16 clipLeft;
Sint32 nbUsed; // nb de points déjà visités
char nextRankUsed;
POINT posUsed[MAXUSED];
char rankUsed[MAXUSED];
Sint16 takeChannel; // objet transporté
Sint16 takeIcon;
POINT fix; // point fixe (cultive, pont)
Sint16 jaugePhase;
Sint16 jaugeMax;
Sint16 stop; // 1 -> devra stopper
Sint16 bArrow; // true -> flèche en dessus de blupi
Sint16 bRepeat; // true -> répète l'action
Sint16 nLoop; // nb de boucles pour GOAL_OTHERLOOP
Sint16 cLoop; // boucle en cours
Sint16 vIcon; // icône variable
POINT goalHili; // but visé
Sint16 bMalade; // true -> blupi malade
Sint16 bCache; // true -> caché (pas dessiné)
Sint16 vehicule; // véhicule utilisé par blupi, voir (**)
char busyCount;
char busyDelay;
char clicCount;
char clicDelay;
char reserve2[2];
}
OldBlupi;
// Sauve le décor sur disque.
bool CDecor::Write(Sint32 rank, bool bUser, Sint32 world, Sint32 time, Sint32 total)
{
char filename[MAX_PATH];
FILE* file = nullptr;
DescFile* pBuffer = nullptr;
Sint32 i;
size_t nb;
if ( bUser )
{
sprintf(filename, "data/user%.3d.blp", rank);
AddUserPath(filename);
}
else
{
sprintf(filename, "data/world%.3d.blp", rank);
}
file = fopen(filename, "wb");
if ( file == nullptr ) goto error;
pBuffer = (DescFile*)malloc(sizeof(DescFile));
if ( pBuffer == nullptr ) goto error;
memset(pBuffer, 0, sizeof(DescFile));
pBuffer->majRev = 1;
pBuffer->minRev = 5;
pBuffer->celCoin = m_celCoin;
pBuffer->world = world;
pBuffer->time = time;
pBuffer->totalTime = total;
pBuffer->term = m_term;
pBuffer->music = m_music;
pBuffer->region = m_region;
pBuffer->skill = m_skill;
pBuffer->nbDecor = MAXCELX*MAXCELY;
pBuffer->lgDecor = sizeof(Cellule);
pBuffer->nbBlupi = MAXBLUPI;
pBuffer->lgBlupi = sizeof(Blupi);
pBuffer->nbMove = MAXMOVE;
pBuffer->lgMove = sizeof(Move);
for ( i=0 ; i<MAXBUTTON ; i++ )
{
pBuffer->buttonExist[i] = m_buttonExist[i];
}
for ( i=0 ; i<4 ; i++ )
{
pBuffer->memoPos[i] = m_memoPos[i];
}
nb = fwrite(pBuffer, sizeof(DescFile), 1, file);
if ( nb < 1 ) goto error;
nb = fwrite(m_decor, sizeof(Cellule), MAXCELX*MAXCELY/4, file);
if ( nb < MAXCELX*MAXCELY/4 ) goto error;
nb = fwrite(m_blupi, sizeof(Blupi), MAXBLUPI, file);
if ( nb < MAXBLUPI ) goto error;
nb = fwrite(m_move, sizeof(Move), MAXMOVE, file);
if ( nb < MAXMOVE ) goto error;
nb = fwrite(m_lastDrapeau, sizeof(POINT), MAXLASTDRAPEAU, file);
if ( nb < MAXLASTDRAPEAU ) goto error;
free(pBuffer);
fclose(file);
return true;
error:
if ( pBuffer != nullptr ) free(pBuffer);
if ( file != nullptr ) fclose(file);
return false;
}
// Lit le décor sur disque.
bool CDecor::Read(Sint32 rank, bool bUser, Sint32 &world, Sint32 &time, Sint32 &total)
{
char filename[MAX_PATH];
FILE* file = nullptr;
DescFile* pBuffer = nullptr;
Sint32 majRev, minRev;
Sint32 i, x, y;
size_t nb;
OldBlupi oldBlupi;
Init(-1, -1);
if ( bUser )
{
sprintf(filename, "data/user%.3d.blp", rank);
AddUserPath(filename);
}
else
{
sprintf(filename, (GetBaseDir () + "data/world%.3d.blp").c_str (), rank);
}
file = fopen(filename, "rb");
if ( file == nullptr ) goto error;
pBuffer = (DescFile*)malloc(sizeof(DescFile));
if ( pBuffer == nullptr ) goto error;
nb = fread(pBuffer, sizeof(DescFile), 1, file);
if ( nb < 1 ) goto error;
majRev = pBuffer->majRev;
minRev = pBuffer->minRev;
if ( majRev == 1 && minRev == 0 ) goto error;
if ( majRev == 1 && minRev == 3 )
{
if ( pBuffer->nbDecor != MAXCELX*MAXCELY ||
pBuffer->lgDecor != sizeof(Cellule) ||
pBuffer->nbBlupi != MAXBLUPI ||
pBuffer->lgBlupi != sizeof(OldBlupi)||
pBuffer->nbMove != MAXMOVE ||
pBuffer->lgMove != sizeof(Move) ) goto error;
}
else
{
if ( pBuffer->nbDecor != MAXCELX*MAXCELY ||
pBuffer->lgDecor != sizeof(Cellule) ||
pBuffer->nbBlupi != MAXBLUPI ||
pBuffer->lgBlupi != sizeof(Blupi) ||
pBuffer->nbMove != MAXMOVE ||
pBuffer->lgMove != sizeof(Move) ) goto error;
}
SetCoin(pBuffer->celCoin);
if ( bUser )
{
world = pBuffer->world;
time = pBuffer->time;
total = pBuffer->totalTime;
}
m_celHome = pBuffer->celCoin;
m_term = pBuffer->term;
m_music = pBuffer->music;
m_region = pBuffer->region;
if ( bUser )
{
m_skill = pBuffer->skill;
}
for ( i=0 ; i<MAXBUTTON ; i++ )
{
m_buttonExist[i] = pBuffer->buttonExist[i];
}
for ( i=0 ; i<4 ; i++ )
{
m_memoPos[i] = pBuffer->memoPos[i];
}
nb = fread(m_decor, sizeof(Cellule), MAXCELX*MAXCELY/4, file);
if ( nb < MAXCELX*MAXCELY/4 ) goto error;
if ( majRev == 1 && minRev < 5 )
{
for ( x=0 ; x<MAXCELX/2 ; x++ )
{
for ( y=0 ; y<MAXCELY/2 ; y++ )
{
if ( m_decor[x][y].objectIcon >= 128 &&
m_decor[x][y].objectIcon <= 130 )
{
m_decor[x][y].objectIcon -= 128-17;
}
}
}
}
if ( majRev == 1 && minRev == 3 )
{
memset(m_blupi, 0, sizeof(Blupi)*MAXBLUPI);
for ( i=0 ; i<MAXBLUPI ; i++ )
{
nb = fread(&oldBlupi, sizeof(OldBlupi), 1, file);
if ( nb != 1 ) goto error;
memcpy(m_blupi+i, &oldBlupi, sizeof(OldBlupi));
ListFlush(i);
}
}
else
{
nb = fread(m_blupi, sizeof(Blupi), MAXBLUPI, file);
if ( nb < MAXBLUPI ) goto error;
}
nb = fread(m_move, sizeof(Move), MAXMOVE, file);
if ( nb < MAXMOVE ) goto error;
nb = fread(m_lastDrapeau, sizeof(POINT), MAXLASTDRAPEAU, file);
if ( nb < MAXLASTDRAPEAU )
{
InitDrapeau();
}
BlupiDeselect(); // désélectionne tous les blupi
free(pBuffer);
fclose(file);
return true;
error:
if ( pBuffer != nullptr ) free(pBuffer);
if ( file != nullptr ) fclose(file);
Flush(); // initialise un décor neutre
return false;
}
// Indique si un fichier existe sur disque.
bool CDecor::FileExist(Sint32 rank, bool bUser, Sint32 &world, Sint32 &time, Sint32 &total)
{
char filename[MAX_PATH];
FILE* file = nullptr;
DescFile* pBuffer = nullptr;
Sint32 majRev, minRev;
size_t nb;
if ( bUser )
{
sprintf(filename, "data/user%.3d.blp", rank);
AddUserPath(filename);
}
else
{
sprintf(filename, "data/world%.3d.blp", rank);
}
file = fopen(filename, "rb");
if ( file == nullptr ) goto error;
pBuffer = (DescFile*)malloc(sizeof(DescFile));
if ( pBuffer == nullptr ) goto error;
nb = fread(pBuffer, sizeof(DescFile), 1, file);
if ( nb < 1 ) goto error;
majRev = pBuffer->majRev;
minRev = pBuffer->minRev;
if ( majRev == 1 && minRev == 0 ) goto error;
if ( majRev == 1 && minRev == 3 )
{
if ( pBuffer->nbDecor != MAXCELX*MAXCELY ||
pBuffer->lgDecor != sizeof(Cellule) ||
pBuffer->nbBlupi != MAXBLUPI ||
pBuffer->lgBlupi != sizeof(OldBlupi)||
pBuffer->nbMove != MAXMOVE ||
pBuffer->lgMove != sizeof(Move) ) goto error;
}
else
{
if ( pBuffer->nbDecor != MAXCELX*MAXCELY ||
pBuffer->lgDecor != sizeof(Cellule) ||
pBuffer->nbBlupi != MAXBLUPI ||
pBuffer->lgBlupi != sizeof(Blupi) ||
pBuffer->nbMove != MAXMOVE ||
pBuffer->lgMove != sizeof(Move) ) goto error;
}
world = pBuffer->world;
time = pBuffer->time;
total = pBuffer->totalTime;
free(pBuffer);
fclose(file);
return true;
error:
if ( pBuffer != nullptr ) free(pBuffer);
if ( file != nullptr ) fclose(file);
return false;
}
#define MARG 18
// Initialise un décor neutre.
void CDecor::Flush()
{
Sint32 x, y, i, icon;
Init(-1, -1);
for ( x=0 ; x<MAXCELX ; x+=2 )
{
for ( y=0 ; y<MAXCELY ; y+=2 )
{
if ( x < MARG || x > MAXCELX-MARG ||
y < MARG || y > MAXCELY-MARG )
{
icon = 14; // eau
goto put;
}
if ( x == MARG && y == MARG )
{
icon = 12;
goto put;
}
if ( x == MAXCELX-MARG && y == MARG )
{
icon = 13;
goto put;
}
if ( x == MARG && y == MAXCELY-MARG )
{
icon = 11;
goto put;
}
if ( x == MAXCELX-MARG && y == MAXCELY-MARG )
{
icon = 10;
goto put;
}
if ( x == MARG )
{
icon = 4;
goto put;
}
if ( x == MAXCELX-MARG )
{
icon = 2;
goto put;
}
if ( y == MARG )
{
icon = 5;
goto put;
}
if ( y == MAXCELY-MARG )
{
icon = 3;
goto put;
}
icon = 1; // terre
put:
m_decor[x/2][y/2].floorChannel = CHFLOOR;
m_decor[x/2][y/2].floorIcon = icon;
}
}
for ( i=0 ; i<MAXBLUPI ; i++ )
{
m_blupi[i].bExist = false;
}
BlupiCreate(GetCel(102,100), ACTION_STOP, DIRECT_S, 0, MAXENERGY);
m_decor[98/2][100/2].floorChannel = CHFLOOR;
m_decor[98/2][100/2].floorIcon = 16;
m_decor[98/2][100/2].objectChannel = CHOBJECT;
m_decor[98/2][100/2].objectIcon = 113;
for ( i=0 ; i<MAXBUTTON ; i++ )
{
m_buttonExist[i] = 1;
}
for ( i=0 ; i<4 ; i++ )
{
m_memoPos[i].x = 0;
m_memoPos[i].y = 0;
}
memset(&m_term, 0, sizeof(Term));
m_term.bHomeBlupi = true;
m_term.nbMinBlupi = 1;
m_term.nbMaxBlupi = 1;
m_music = 0;
m_region = 0;
m_celHome.x = 90;
m_celHome.y = 98;
SetCoin(m_celHome);
InitAfterBuild();
LoadImages();
}

View File

@ -1,545 +0,0 @@
// DecMap.cpp
//
#include "blupi.h"
#include "def.h"
#include "decor.h"
#define MAP_CADRE 1
#define MAP_FOG 2
#define MAP_BLUPI 3
#define MAP_SEE 4
#define MAP_TREE 5
#define MAP_HERB1 6
#define MAP_HERB2 7
#define MAP_TERRE 8
#define MAP_DALLE 9
#define MAP_PERSO 10
#define MAP_NURSE 11
#define MAP_ROC 12
#define MAP_MUR 13
#define MAP_EGG 14
#define MAP_FIRE 15
#define MAP_TOMAT 16
#define MAP_BUILD 17
#define MAP_ENNEMI 18
#define MAP_FLEUR 19
#define MAPCADREX ((DIMDRAWX/DIMCELX)*2+1)
#define MAPCADREY (DIMDRAWY/DIMCELY+1)
// Bitmap de la carte.
static Uint32 g_map32_bits[DIMMAPY][DIMMAPX];
// Initialise les couleurs pour la carte.
void CDecor::MapInitColors()
{
// FIXME: add big-endian support
const auto MapRGB = [] (Uint8 r, Uint8 g, Uint8 b) {
return r << 16 | g << 8 | b << 0;
};
m_colors[MAP_CADRE] = MapRGB (255, 0, 0); // rouge
m_colors[MAP_FOG] = MapRGB (0, 0, 0); // noir
m_colors[MAP_BLUPI] = MapRGB (255, 255, 0); // jaune
m_colors[MAP_SEE] = MapRGB (102, 102, 204); // bleu
m_colors[MAP_DALLE] = MapRGB (192, 192, 192); // gris
m_colors[MAP_PERSO] = MapRGB (255, 0, 0); // rouge
m_colors[MAP_NURSE] = MapRGB (255, 0, 0); // rouge
m_colors[MAP_ROC] = MapRGB (214, 214, 214); // gris clair
m_colors[MAP_MUR] = MapRGB (100, 100, 100); // gris moyen
m_colors[MAP_EGG] = MapRGB (255, 255, 255); // blanc
m_colors[MAP_FIRE] = MapRGB (255, 0, 0); // rouge
m_colors[MAP_TOMAT] = MapRGB (255, 0, 0); // rouge
m_colors[MAP_BUILD] = MapRGB (0, 0, 0); // noir
m_colors[MAP_ENNEMI]= MapRGB (0, 192, 255); // bleu métal
m_colors[MAP_FLEUR] = MapRGB (255, 206, 0); // jaune
m_colors[MAP_TREE] = MapRGB (0 ,102, 0); // vert foncé
m_colors[MAP_HERB1] = MapRGB (0 ,204, 51); // vert clair
m_colors[MAP_HERB2] = MapRGB (0 ,156, 8); // vert moyen
m_colors[MAP_TERRE] = MapRGB (94, 78, 12); // brun
if ( m_region == 1 ) // palmiers
{
m_colors[MAP_TREE] = MapRGB (38, 197, 42);
m_colors[MAP_HERB1] = MapRGB (184, 140, 1);
m_colors[MAP_HERB2] = MapRGB (145, 110, 5);
m_colors[MAP_TERRE] = MapRGB (192, 192, 192);
}
if ( m_region == 2 ) // hiver
{
m_colors[MAP_TREE] = MapRGB (152, 205, 222);
m_colors[MAP_HERB1] = MapRGB (219, 234, 239);
m_colors[MAP_HERB2] = MapRGB (223, 173, 90);
m_colors[MAP_TERRE] = MapRGB (152, 205, 222);
}
if ( m_region == 3 ) // sapins
{
m_colors[MAP_TREE] = MapRGB (0, 102, 0);
m_colors[MAP_HERB1] = MapRGB (38, 197, 42);
m_colors[MAP_HERB2] = MapRGB (140, 140, 0);
m_colors[MAP_TERRE] = MapRGB (172, 178, 173);
}
}
// COnversion d'un cellule en point dans la carte.
POINT CDecor::ConvCelToMap(POINT cel)
{
POINT pos;
pos.x = (cel.x-m_celCoin.x)-(cel.y-m_celCoin.y);
pos.y = ((cel.x-m_celCoin.x)+(cel.y-m_celCoin.y))/2;
pos.x += (DIMMAPX-MAPCADREX)/2;
pos.y += (DIMMAPY-MAPCADREY)/2;
return pos;
}
// Conversion d'un point dans la carte en cellule.
POINT CDecor::ConvMapToCel(POINT pos)
{
POINT cel;
pos.x -= ((DIMMAPX-MAPCADREX)/4)*2;
pos.y -= ((DIMMAPY-MAPCADREY)/4)*2;
cel.x = pos.y + pos.x/2;
cel.y = pos.y - pos.x/2;
cel.x += m_celCoin.x;
cel.y += m_celCoin.y;
return cel;
}
// Déplace le décor suite à un clic dans la carte.
bool CDecor::MapMove(POINT pos)
{
POINT cel;
if ( pos.x >= POSMAPX && pos.x < POSMAPX+DIMMAPX &&
pos.y >= POSMAPY && pos.y < POSMAPY+DIMMAPY )
{
pos.x -= POSMAPX;
pos.y -= POSMAPY;
cel = ConvMapToCel(pos);
cel.x = cel.x-10;
cel.y = cel.y;
SetCoin(cel);
NextPhase(0); // faudra refaire la carte tout de suite
return true;
}
return false;
}
static char color_floor[] =
{
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1, // 0
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_HERB1, MAP_SEE, MAP_SEE, MAP_SEE,
MAP_SEE, MAP_SEE, MAP_SEE, MAP_HERB1,
MAP_SEE, MAP_SEE, MAP_SEE, MAP_HERB1,
MAP_HERB1, MAP_SEE, MAP_SEE, MAP_SEE,
MAP_HERB1, MAP_SEE, MAP_SEE, MAP_HERB1,
MAP_SEE, MAP_SEE, MAP_HERB1, MAP_HERB1,
MAP_HERB1, MAP_SEE, MAP_SEE, MAP_HERB1,
MAP_HERB1, MAP_HERB1, MAP_SEE, MAP_SEE,
MAP_SEE, MAP_HERB1, MAP_HERB1, MAP_SEE,
MAP_SEE, MAP_SEE, MAP_HERB1, MAP_HERB1,
MAP_SEE, MAP_HERB1, MAP_HERB1, MAP_SEE,
MAP_HERB1, MAP_HERB1, MAP_SEE, MAP_SEE,
MAP_SEE, MAP_SEE, MAP_SEE, MAP_SEE,
MAP_DALLE, MAP_DALLE, MAP_DALLE, MAP_DALLE,
MAP_DALLE, MAP_DALLE, MAP_DALLE, MAP_DALLE, // 16
MAP_DALLE, MAP_DALLE, MAP_DALLE, MAP_DALLE,
MAP_DALLE, MAP_DALLE, MAP_DALLE, MAP_DALLE,
MAP_DALLE, MAP_DALLE, MAP_DALLE, MAP_DALLE,
MAP_HERB2, MAP_HERB2, MAP_HERB2, MAP_HERB2,
MAP_HERB1, MAP_HERB2, MAP_HERB2, MAP_HERB2,
MAP_HERB2, MAP_HERB2, MAP_HERB2, MAP_HERB1,
MAP_HERB2, MAP_HERB2, MAP_HERB2, MAP_HERB1,
MAP_HERB1, MAP_HERB2, MAP_HERB2, MAP_HERB2,
MAP_HERB2, MAP_HERB2, MAP_HERB2, MAP_HERB1,
MAP_HERB1, MAP_HERB2, MAP_HERB2, MAP_HERB1,
MAP_HERB1, MAP_HERB2, MAP_HERB2, MAP_HERB2,
MAP_HERB1, MAP_HERB2, MAP_HERB2, MAP_HERB1,
MAP_HERB2, MAP_HERB2, MAP_HERB2, MAP_HERB2,
MAP_HERB1, MAP_HERB2, MAP_HERB2, MAP_HERB2,
MAP_HERB2, MAP_HERB2, MAP_HERB2, MAP_HERB2,
MAP_HERB2, MAP_HERB2, MAP_HERB2, MAP_HERB1, // 32
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_HERB1, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_HERB1,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_HERB1,
MAP_HERB1, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_HERB1,
MAP_HERB1, MAP_TERRE, MAP_TERRE, MAP_HERB1,
MAP_HERB1, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_HERB1, MAP_TERRE, MAP_TERRE, MAP_HERB1,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_HERB1, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_HERB1,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE, // 48
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_NURSE, MAP_NURSE, MAP_NURSE, MAP_NURSE,
MAP_NURSE, MAP_NURSE, MAP_NURSE, MAP_NURSE,
MAP_NURSE, MAP_NURSE, MAP_NURSE, MAP_NURSE,
MAP_NURSE, MAP_NURSE, MAP_NURSE, MAP_NURSE,
MAP_NURSE, MAP_NURSE, MAP_NURSE, MAP_NURSE,
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE, // 64
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_SEE, MAP_SEE, MAP_SEE, MAP_SEE,
MAP_SEE, MAP_SEE, MAP_SEE, MAP_SEE,
MAP_SEE, MAP_SEE, MAP_SEE, MAP_SEE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
};
static char color_object[] =
{
0, MAP_TREE, 0, MAP_TREE,
MAP_TREE, 0, MAP_TREE, 0,
0, MAP_TREE, 0, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
0, MAP_TREE, 0, MAP_TREE, // arbre
MAP_TREE, 0, MAP_TREE, 0,
0, MAP_TREE, 0, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
0, MAP_TREE, 0, MAP_TREE, // sapin
MAP_TREE, 0, MAP_TREE, 0,
0, MAP_TREE, 0, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE, // palmiers
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR, // mur
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD, // maison
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE, // arbre sans feuille
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE, // planches
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC, // rochers
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC,
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC,
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC,
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC,
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC,
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC,
MAP_ROC, MAP_ROC, MAP_ROC, MAP_ROC, // pierres
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE, // feu
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR, // test
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, // tomates
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT,
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT,
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT,
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD, // cabane
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD,
MAP_EGG, MAP_EGG, MAP_EGG, MAP_EGG, // oeufs
MAP_EGG, MAP_EGG, MAP_EGG, MAP_EGG,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR, // palissade
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR, // pont construction
MAP_MUR, MAP_MUR, MAP_MUR, MAP_MUR,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE, // rayon
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI, // bouteille
MAP_FLEUR, MAP_FLEUR, MAP_FLEUR, MAP_FLEUR, // fleurs
MAP_FLEUR, MAP_FLEUR, MAP_FLEUR, MAP_FLEUR,
MAP_FLEUR, MAP_FLEUR, MAP_FLEUR, MAP_FLEUR,
MAP_FLEUR, MAP_FLEUR, MAP_FLEUR, MAP_FLEUR,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE, // dynamite
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, // poison
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT,
MAP_FLEUR, MAP_FLEUR, MAP_FLEUR, MAP_FLEUR,
MAP_FLEUR, MAP_FLEUR, MAP_FLEUR, MAP_FLEUR,
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1, // ennemi piégé
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI, // usine
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI, // barrière
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD, // maison
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1, // ennemi piégé
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,MAP_ENNEMI,
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, // bateau
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, // jeep
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD, // usine
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD,
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD, // mine de fer
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD,
MAP_TERRE, MAP_TERRE, MAP_TERRE, MAP_TERRE, // fer
MAP_EGG, MAP_EGG, MAP_EGG, MAP_EGG, // drapeau
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, // mine
MAP_BUILD, MAP_BUILD, MAP_BUILD, MAP_BUILD,
MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, MAP_TOMAT, // mine
};
static char color_deffog[4] =
{
MAP_FOG, MAP_FOG, MAP_FOG, MAP_FOG,
};
static char color_deftree[4] =
{
MAP_TREE, MAP_TREE, MAP_TREE, MAP_TREE,
};
static char color_deffloor[4] =
{
MAP_HERB1, MAP_HERB1, MAP_HERB1, MAP_HERB1,
};
static char color_fire[4] =
{
MAP_FIRE, MAP_FIRE, MAP_FIRE, MAP_FIRE,
};
// Met le contenu d'une cellule dans le bitmap de la carte
// (sol, objets et brouillard).
void CDecor::MapPutCel(POINT pos)
{
POINT cel, fogCel;
Sint32 icon, i;
char* pColors;
cel = ConvMapToCel(pos);
cel.x = (cel.x/2)*2;
cel.y = (cel.y/2)*2;
if ( !IsValid(cel) )
{
pColors = color_deffog;
goto color;
}
if ( m_bFog )
{
// fogPos.x = (pos.x/4)*4;
// fogPos.y = (pos.y/4)*4;
// fogCel = ConvMapToCel(fogPos);
fogCel = cel;
fogCel.x = (fogCel.x/4)*4;
fogCel.y = (fogCel.y/4)*4;
if ( fogCel.x < 0 || fogCel.x >= MAXCELX ||
fogCel.y < 0 || fogCel.y >= MAXCELY ||
m_decor[fogCel.x/2][fogCel.y/2].fog == FOGHIDE ) // caché ?
{
pColors = color_deffog;
goto color;
}
}
icon = m_decor[cel.x/2][cel.y/2].objectIcon;
if ( icon != -1 )
{
if ( m_decor[cel.x/2][cel.y/2].fire > 0 &&
m_decor[cel.x/2][cel.y/2].fire < MoveMaxFire() )
{
pColors = color_fire;
goto color;
}
if ( icon >= 0 && icon <= 127 ) pColors = color_object+4*(icon-0);
else pColors = color_deftree;
goto color;
}
icon = m_decor[cel.x/2][cel.y/2].floorIcon;
if ( icon >= 0 && icon <= 71 ) pColors = color_floor+4*(icon-0);
else pColors = color_deffloor;
color:
for ( i=0 ; i<4 ; i++ )
{
if ( pos.x+i >= 0 && pos.x+i < DIMMAPX )
{
icon = *pColors++;
if ( icon != 0 )
{
g_map32_bits[pos.y][pos.x+i] = m_colors[icon];
}
}
}
}
// Génère la carte.
bool CDecor::GenerateMap()
{
POINT dim, pos, cel;
Sint32 dx, rank, i;
if ( m_phase != -1 && m_phase%20 != 0 ) return true;
// Dessine le décor (sol, objets et brouillard).
for ( pos.y=0 ; pos.y<DIMMAPY ; pos.y++ )
{
dx = pos.y%2;
for ( pos.x=-dx*2 ; pos.x<DIMMAPX ; pos.x+=4 )
{
MapPutCel(pos);
}
}
// Dessine les blupi.
for ( rank=0 ; rank<MAXBLUPI ; rank++ )
{
if ( m_blupi[rank].bExist )
{
pos = ConvCelToMap(m_blupi[rank].cel);
if ( pos.x >= 0 && pos.x < DIMMAPX-1 &&
pos.y >= 0 && pos.y < DIMMAPY-1 )
{
if ( m_blupi[rank].perso == 0 ||
m_blupi[rank].perso == 8 ) i = MAP_BLUPI;
else i = MAP_PERSO;
g_map32_bits[pos.y+0][pos.x+0] = m_colors[i];
g_map32_bits[pos.y+0][pos.x+1] = m_colors[i];
g_map32_bits[pos.y+1][pos.x+0] = m_colors[i];
g_map32_bits[pos.y+1][pos.x+1] = m_colors[i];
}
}
}
// Dessine le cadre.
cel = m_celCoin;
pos = ConvCelToMap(cel);
for ( i=pos.x ; i<pos.x+MAPCADREX ; i++ )
{
g_map32_bits[pos.y] [i] = m_colors[MAP_CADRE];
g_map32_bits[pos.y+MAPCADREY][i] = m_colors[MAP_CADRE];
}
for ( i=pos.y ; i<=pos.y+MAPCADREY ; i++ )
{
g_map32_bits[i][pos.x] = m_colors[MAP_CADRE];
g_map32_bits[i][pos.x+MAPCADREX] = m_colors[MAP_CADRE];
}
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(g_map32_bits, DIMMAPX, DIMMAPY, 32, 4 * DIMMAPX, 0, 0, 0, 0);
dim.x = DIMMAPX;
dim.y = DIMMAPY;
m_pPixmap->Cache(CHMAP, surface, dim);
pos.x = POSMAPX;
pos.y = POSMAPY;
m_pPixmap->DrawIcon(-1, CHMAP, 0, pos);
SDL_FreeSurface (surface);
return true;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +0,0 @@
#pragma once
Sint16 * GetListMoves (Sint32 rank);
Sint16 * GetListIcons (Sint32 rank);

File diff suppressed because it is too large Load Diff

View File

@ -1,545 +0,0 @@
// Decor.h
#pragma once
#include <unordered_map>
#include "def.h"
#include "sound.h"
#include "pixmap.h"
/////////////////////////////////////////////////////////////////////////////
#define MAXENERGY 4000
#define MAXFIRE 400
#define ICON_HILI_STAT 112
#define ICON_HILI_SEL 113
#define ICON_HILI_ANY 114
#define ICON_HILI_OP 115
#define ICON_HILI_GO 117
#define ICON_HILI_BUILD 118
#define ICON_HILI_ERR 119
// Descripteur d'une cellule du décor.
typedef struct
{
Sint16 floorChannel;
Sint16 floorIcon;
Sint16 objectChannel;
Sint16 objectIcon;
Sint16 fog; // brouillard
Sint16 rankMove; // rang dans m_move
Sint16 workBlupi; // rang du blupi travaillant ici
Sint16 fire;
}
Cellule;
// Cette structure doit être la plus petite possible, car
// il en existe un tableau de 100x100 = 10'000 cellules !
// Descripteur d'un blupi animé.
#define MAXBLUPI 100
#define MAXUSED 50
#define MAXLIST 10
typedef struct
{
Sint32 bExist; // true -> utilisé
Sint32 bHili; // true -> sélectionné
Sint16 perso; // personnage, voir (*)
Sint16 goalAction; // action (Sint32 terme)
Sint16 goalPhase; // phase (Sint32 terme)
POINT goalCel; // cellule visée (Sint32 terme)
POINT passCel; // cellule tranversante
Sint16 energy; // énergie restante
POINT cel; // cellule actuelle
POINT destCel; // cellule destination
Sint16 action; // action en cours
Sint16 aDirect; // direction actuelle
Sint16 sDirect; // direction souhaitée
POINT pos; // position relative à partir de la cellule
Sint16 posZ; // déplacement z
Sint16 channel;
Sint16 lastIcon;
Sint16 icon;
Sint16 phase; // phase dans l'action
Sint16 step; // pas global
Sint16 interrupt; // 0=prioritaire, 1=normal, 2=misc
Sint16 clipLeft;
Sint32 nbUsed; // nb de points déjà visités
char nextRankUsed;
POINT posUsed[MAXUSED];
char rankUsed[MAXUSED];
Sint16 takeChannel; // objet transporté
Sint16 takeIcon;
POINT fix; // point fixe (cultive, pont)
Sint16 jaugePhase;
Sint16 jaugeMax;
Sint16 stop; // 1 -> devra stopper
Sint16 bArrow; // true -> flèche en dessus de blupi
Sint16 bRepeat; // true -> répète l'action
Sint16 nLoop; // nb de boucles pour GOAL_OTHERLOOP
Sint16 cLoop; // boucle en cours
Sint16 vIcon; // icône variable
POINT goalHili; // but visé
Sint16 bMalade; // true -> blupi malade
Sint16 bCache; // true -> caché (pas dessiné)
Sint16 vehicule; // véhicule utilisé par blupi, voir (**)
char busyCount;
char busyDelay;
char clicCount;
char clicDelay;
char reserve2[2];
Sint16 listButton[MAXLIST];
POINT listCel[MAXLIST];
Sint16 listParam[MAXLIST];
Sint16 repeatLevelHope;
Sint16 repeatLevel;
Sint16 reserve3[88];
}
Blupi;
// (*) Personnages :
// 0 -> blupi
// 1 -> araignée
// 2 -> virus
// 3 -> tracks
// 4 -> robot
// 5 -> bombe
// 6 -> détonnateur de mine (invisible)
// 7 -> électro
// 8 -> disciple (robot2)
// (**) Véhicule :
// 0 -> à pied
// 1 -> en bateau
// 2 -> en jeep
// 3 -> armure
// Descripteur d'un décor animé.
#define MAXMOVE 100
#define MOVEICONNB 1000
typedef struct
{
Sint32 bExist; // true -> utilisé
POINT cel; // cellule du décor
Sint16 rankBlupi; // blupi travaillant ici
Sint32 bFloor; // true -> floor, false -> object
Sint16 channel;
Sint16 icon;
Sint16 maskChannel;
Sint16 maskIcon;
Sint16 phase; // phase pour pMoves ou pIcon
Sint16 rankMoves; // *nb,dx,dy,...
Sint16 rankIcons; // *nb,i,i,...
Sint16 total; // nb total d'étapes
Sint16 delai; // délai entre deux pas
Sint16 stepY; // pas vertical *100
Sint16 cTotal;
Sint16 cDelai;
}
Move;
#define MAXLASTDRAPEAU 50
class CDecor
{
public:
CDecor();
~CDecor();
// Arrange.cpp
void ArrangeFloor(POINT cel);
void ArrangeMur(POINT cel, Sint32 &icon, Sint32 index);
void ArrangeBuild(POINT cel, Sint32 &channel, Sint32 &icon);
void ArrangeObject(POINT cel);
bool ArrangeFillTestFloor(POINT cel1, POINT cel2);
bool ArrangeFillTest(POINT pos);
void ArrangeFillPut(POINT pos, Sint32 channel, Sint32 icon);
void ArrangeFillSearch(POINT pos);
void ArrangeFill(POINT pos, Sint32 channel, Sint32 icon, bool bFloor);
void ArrangeBlupi();
// Obstacle.cpp
void SearchFloor(Sint32 rank, Sint32 icon, POINT cel, Sint32 *pBits);
void SearchObject(Sint32 rank, Sint32 icon, POINT cel, Sint32 *pBits);
void AjustFloor(Sint32 rank, Sint32 icon, POINT cel, Sint32 *pBits);
void AjustObject(Sint32 rank, Sint32 icon, POINT cel, Sint32 *pBits);
bool IsFreeDirect(POINT cel, Sint32 direct, Sint32 rank);
bool IsFreeCelObstacle(POINT cel);
bool IsFreeCelFloor(POINT cel, Sint32 rank);
bool IsFreeCelGo(POINT cel, Sint32 rank);
bool IsFreeCelHili(POINT cel, Sint32 rank);
bool IsFreeCel(POINT cel, Sint32 rank);
bool IsFreeCelDepose(POINT cel, Sint32 rank);
bool IsFreeCelEmbarque(POINT cel, Sint32 rank, Sint32 &action, POINT &limit);
bool IsFreeCelDebarque(POINT cel, Sint32 rank, Sint32 &action, POINT &limit);
bool IsFreeJump(POINT cel, Sint32 direct, Sint32 rank, Sint32 &action);
bool IsFreeGlisse(POINT cel, Sint32 direct, Sint32 rank, Sint32 &action);
Sint32 DirectSearch(POINT cel, POINT goal);
void FlushUsed(Sint32 rank);
void AddUsedPos(Sint32 rank, POINT pos);
bool IsUsedPos(Sint32 rank, POINT pos);
bool SearchBestBase(Sint32 rank, Sint32 &action, POINT &newCel, Sint32 &direct);
bool SearchBestPass(Sint32 rank, Sint32 &action);
bool IsWorkableObject(POINT cel, Sint32 rank);
bool SearchOtherObject(Sint32 rank, POINT initCel, Sint32 action,
Sint32 distMax, Sint32 channel,
Sint32 firstIcon1, Sint32 lastIcon1,
Sint32 firstIcon2, Sint32 lastIcon2,
POINT &foundCel, Sint32 &foundIcon);
bool SearchOtherDrapeau(Sint32 rank, POINT initCel, Sint32 distMax,
POINT &foundCel, Sint32 &foundIcon);
bool SearchOtherBateau(Sint32 rank, POINT initCel, Sint32 distMax,
POINT &foundCel, Sint32 &foundIcon);
bool IsSpiderObject(Sint32 icon);
bool SearchSpiderObject(Sint32 rank, POINT initCel, Sint32 distMax,
POINT &foundCel, Sint32 &foundIcon);
bool IsTracksObject(Sint32 icon);
bool SearchTracksObject(Sint32 rank, POINT initCel, Sint32 distMax,
POINT &foundCel, Sint32 &foundIcon);
bool IsRobotObject(Sint32 icon);
bool SearchRobotObject(Sint32 rank, POINT initCel, Sint32 distMax,
POINT &foundCel, Sint32 &foundIcon,
Sint32 &foundAction);
bool IsBombeObject(Sint32 icon);
bool SearchBombeObject(Sint32 rank, POINT initCel, Sint32 distMax,
POINT &foundCel, Sint32 &foundIcon);
bool SearchElectroObject(Sint32 rank, POINT initCel, Sint32 distMax,
POINT &foundCel, Sint32 &foundIcon);
bool IsUsineBuild(Sint32 rank, POINT cel);
bool IsUsineFree(Sint32 rank, POINT cel);
bool IsFireCel(POINT cel);
bool IsVirusCel(POINT cel);
Sint32 IsBuildPont(POINT &cel, Sint32 &iconBuild);
bool IsBuildBateau(POINT cel, Sint32 &direct);
void InitDrapeau();
void AddDrapeau(POINT cel);
void SubDrapeau(POINT cel);
bool TestDrapeau(POINT cel);
// DecBlupi.cpp
void BlupiFlush();
Sint32 BlupiCreate(POINT cel, Sint32 action, Sint32 direct,
Sint32 perso, Sint32 energy);
bool BlupiDelete(POINT cel, Sint32 perso=-1);
void BlupiDelete(Sint32 rank);
void BlupiKill(Sint32 exRank, POINT cel, Sint32 type);
bool BlupiIfExist(Sint32 rank);
void BlupiCheat(Sint32 cheat);
void BlupiActualise(Sint32 rank);
void BlupiAdaptIcon(Sint32 rank);
void BlupiPushFog(Sint32 rank);
void BlupiSound(Sint32 rank, Sint32 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);
Sint32 ListGetParam(Sint32 rank, Sint32 button, POINT cel);
bool ListPut(Sint32 rank, Sint32 button, POINT cel, POINT cMem);
void ListRemove(Sint32 rank);
Sint32 ListSearch(Sint32 rank, Sint32 button, POINT cel, const char *&textForButton);
bool RepeatAdjust(Sint32 rank, Sint32 button, POINT &cel, POINT &cMem,
Sint32 param, Sint32 list);
void GoalStart(Sint32 rank, Sint32 action, POINT cel);
bool GoalNextPhase(Sint32 rank);
void SetTotalTime(Sint32 total);
Sint32 GetTotalTime();
void GoalInitJauge(Sint32 rank);
void GoalInitPassCel(Sint32 rank);
void GoalAdjustCel(Sint32 rank, Sint32 &x, Sint32 &y);
bool GoalNextOp(Sint32 rank, Sint16 *pTable);
void GoalUnwork(Sint32 rank);
void GoalStop(Sint32 rank, bool bError=false, bool bSound=true);
bool BlupiIsGoalUsed(POINT cel);
void BlupiStartStopRayon(Sint32 rank, POINT startCel, POINT endCel);
bool BlupiRotate(Sint32 rank);
bool BlupiNextAction(Sint32 rank);
void BlupiNextGoal(Sint32 rank);
void BlupiStep(bool bFirst);
void BlupiGetRect(Sint32 rank, RECT &rect);
Sint32 GetTargetBlupi(POINT pos);
void BlupiDeselect();
void BlupiDeselect(Sint32 rank);
void BlupiSetArrow(Sint32 rank, bool bArrow);
void InitOutlineRect();
void BlupiHiliDown(POINT pos, bool bAdd=false);
void BlupiHiliMove(POINT pos, bool bAdd=false);
void BlupiHiliUp(POINT pos, bool bAdd=false);
void BlupiDrawHili();
Sint32 GetDefButton(POINT cel);
bool BlupiGoal(Sint32 rank, Sint32 button, POINT cel, POINT cMem);
void BlupiGoal(POINT cel, Sint32 button);
void BlupiDestCel(Sint32 rank);
bool IsTracksHere(POINT cel, bool bSkipInMove);
bool IsBlupiHereEx(POINT cel1, POINT cel2, Sint32 exRank, bool bSkipInMove);
bool IsBlupiHereEx(POINT cel, Sint32 exRank, bool bSkipInMove);
bool IsBlupiHere(POINT cel, bool bSkipInMove);
bool IsBlupiHere(POINT cel, Sint32 direct, bool bSkipInMove);
void GetLevelJauge(Sint32 *pLevels, Sint32 *pTypes);
bool IsWorkBlupi(Sint32 rank);
void BlupiGetButtons(POINT pos, Sint32 &nb, Sint32 *pButtons, Sint32 *pErrors,
std::unordered_map<Sint32, const char *> &texts, Sint32 &perso);
void TerminatedInit();
Sint32 IsTerminated();
Term* GetTerminated();
// DecMove.cpp
void MoveFlush();
Sint32 MoveMaxFire();
void MoveFixInit();
bool MoveCreate(POINT cel, Sint32 rankBlupi, bool bFloor,
Sint32 channel, Sint32 icon,
Sint32 maskChannel, Sint32 maskIcon,
Sint32 total, Sint32 delai, Sint32 stepY,
bool bMisc=false, bool bNotIfExist=false);
bool MoveAddMoves(POINT cel, Sint32 rankMoves);
bool MoveAddIcons(POINT cel, Sint32 rankIcons, bool bContinue=false);
bool MoveStartFire(POINT cel);
void MoveProxiFire(POINT cel);
void MoveFire(Sint32 rank);
void MoveStep(bool bFirst);
void MoveFinish(POINT cel);
void MoveFinish(Sint32 rankBlupi);
bool MoveIsUsed(POINT cel);
bool MoveGetObject(POINT cel, Sint32 &channel, Sint32 &icon);
bool MovePutObject(POINT cel, Sint32 channel, Sint32 icon);
// DecIO.cpp
bool Write(Sint32 rank, bool bUser, Sint32 world, Sint32 time, Sint32 total);
bool Read(Sint32 rank, bool bUser, Sint32 &world, Sint32 &time, Sint32 &total);
bool FileExist(Sint32 rank, bool bUser, Sint32 &world, Sint32 &time, Sint32 &total);
void Flush();
// DecMap.cpp
void MapInitColors();
POINT ConvCelToMap(POINT cel);
POINT ConvMapToCel(POINT pos);
bool MapMove(POINT pos);
void MapPutCel(POINT pos);
bool GenerateMap();
// DecStat.cpp
void StatisticInit();
void StatisticUpdate();
Sint32 StatisticGetBlupi();
Sint32 StatisticGetFire();
void StatisticDraw();
void GenerateStatictic();
bool StatisticDown(POINT pos);
bool StatisticMove(POINT pos);
bool StatisticUp(POINT pos);
Sint32 StatisticDetect(POINT pos);
// Chemin.cpp
void CheminMemPos(Sint32 exRank);
bool CheminTestPos(POINT pos, Sint32 &rank);
Sint32 CheminARebours(Sint32 rank);
void CheminFillTerrain(Sint32 rank);
bool CheminTestDirection(Sint32 rank, Sint32 pos, Sint32 dir,
Sint32 &next, Sint32 &ampli,
Sint32 &cout, Sint32 &action);
bool CheminCherche(Sint32 rank, Sint32 &action);
bool IsCheminFree(Sint32 rank, POINT dest, Sint32 button);
// Decor.cpp
void SetShiftOffset(POINT offset);
POINT ConvCelToPos(POINT cel);
POINT ConvPosToCel(POINT pos, bool bMap=false);
POINT ConvPosToCel2(POINT pos);
void Create(CSound *pSound, CPixmap *pPixmap);
void Init(Sint32 channel, Sint32 icon);
void InitAfterBuild();
void ResetHili();
bool LoadImages();
void ClearFog();
void ClearFire();
void SetBuild(bool bBuild);
void EnableFog(bool bEnable);
bool GetInvincible();
void SetInvincible(bool bInvincible);
bool GetSuper();
void SetSuper(bool bSuper);
void FlipOutline();
bool PutFloor(POINT cel, Sint32 channel, Sint32 icon);
bool PutObject(POINT cel, Sint32 channel, Sint32 icon);
bool GetFloor(POINT cel, Sint32 &channel, Sint32 &icon);
bool GetObject(POINT cel, Sint32 &channel, Sint32 &icon);
bool SetFire(POINT cel, bool bFire);
void SetCoin(POINT coin, bool bCenter=false);
POINT GetCoin();
POINT GetHome();
void MemoPos(Sint32 rank, bool bRecord);
void SetTime(Sint32 time);
Sint32 GetTime();
void SetMusic(Sint32 music);
Sint32 GetMusic();
void SetSkill(Sint32 skill);
Sint32 GetSkill();
void SetRegion(Sint32 region);
Sint32 GetRegion();
void SetInfoMode(bool bInfo);
bool GetInfoMode();
void SetInfoHeight(Sint32 height);
Sint32 GetInfoHeight();
char* GetButtonExist();
void BuildPutBlupi();
void BuildMoveFloor(Sint32 x, Sint32 y, POINT pos, Sint32 rank);
void BuildMoveObject(Sint32 x, Sint32 y, POINT pos, Sint32 rank);
void BuildGround(RECT clip);
void Build(RECT clip, POINT posMouse);
void NextPhase(Sint32 mode);
Sint32 CountFloor(Sint32 channel, Sint32 icon);
Sint32 CelOkForAction(POINT cel, Sint32 action, Sint32 rank,
Sint32 icons[4][4],
POINT &celOutline1,
POINT &celOutline2);
Sint32 CelOkForAction(POINT cel, Sint32 action, Sint32 rank);
Sint32 GetHiliRankBlupi(Sint32 nb);
void CelHili(POINT pos, Sint32 action);
void CelHiliButton(POINT cel, Sint32 button);
void CelHiliRepeat(Sint32 list);
const char *GetResHili(POINT posMouse);
void HideTooltips(bool bHide);
void UndoOpen();
void UndoClose();
void UndoCopy();
void UndoBack();
bool IsUndo();
protected:
bool GetSeeBits(POINT cel, char *pBits, Sint32 index);
Sint32 GetSeeIcon(char *pBits, Sint32 index);
protected:
CSound* m_pSound;
CPixmap* m_pPixmap;
Cellule* m_pUndoDecor;
Cellule m_decor[MAXCELX/2][MAXCELY/2];
Sint16 m_rankBlupi[MAXCELX][MAXCELY];
Blupi m_blupi[MAXBLUPI];
Move m_move[MAXMOVE];
POINT m_celCoin; // cellule sup/gauche
POINT m_celHome; // pour touche Home
POINT m_celHili;
POINT m_celOutline1;
POINT m_celOutline2;
POINT m_shiftOffset;
Sint32 m_iconHili[4][4];
Sint32 m_rankHili; // rang du blupi visé
bool m_bHiliRect;
POINT m_p1Hili; // coins rectangle de sélection
POINT m_p2Hili;
Sint32 m_shiftHili;
Sint32 m_nbBlupiHili; // nb de blupi sélectionnés
Sint32 m_rankBlupiHili; // rang blupi sélectionné
bool m_bFog; // true -> brouillard (jeu)
bool m_bBuild; // true -> construction
bool m_bInvincible; // true -> cheat code
bool m_bSuper; // true -> cheat code
Uint32 m_colors[100];
Sint32 m_time; // temps relatif global
Sint32 m_timeConst; // temps relatif global constant
Sint32 m_timeFlipOutline; // temps quand basculer mode outline
Sint32 m_totalTime; // temps total passé sur une partie
Sint32 m_phase; // phase pour la carte
POINT m_celArrow; // cellule avec flèche
bool m_bOutline;
bool m_bGroundRedraw;
char m_buttonExist[MAXBUTTON];
Sint32 m_statNb; // nb de statistiques
Sint32 m_statFirst; // première statistique visible
Sint32 m_bStatUp; // flèche up statistique
Sint32 m_bStatDown; // flèche down statistique
Sint32 m_statHili; // statistique survolée
bool m_bStatRecalc; // true -> recalcule les statistiques
bool m_bStatRedraw; // true -> redessine les statistiques
Sint32 m_nbStatHach; // nb de hachures
Sint32 m_nbStatHachBlupi; // hachures occupées par blupi
Sint32 m_nbStatHachPlanche;// hachures occupées par planches
Sint32 m_nbStatHachTomate; // hachures occupées par tomates
Sint32 m_nbStatHachMetal; // hachures occupées par métal
Sint32 m_nbStatHachRobot; // hachures occupées par robot
Sint32 m_nbStatHome; // nb de maisons
Sint32 m_nbStatHomeBlupi; // maisons occupées par blupi
Sint32 m_nbStatRobots; // nb d'ennemis
Term m_term; // conditions pour gagner
Sint32 m_winCount; // compteur avant gagné
Sint32 m_winLastHachBlupi; // dernier nombre atteint
Sint32 m_winLastHachPlanche;// dernier nombre atteint
Sint32 m_winLastHachTomate;// dernier nombre atteint
Sint32 m_winLastHachMetal; // dernier nombre atteint
Sint32 m_winLastHachRobot; // dernier nombre atteint
Sint32 m_winLastHome; // dernier nombre atteint
Sint32 m_winLastHomeBlupi; // dernier nombre atteint
Sint32 m_winLastRobots; // dernier nombre atteint
Sint32 m_music; // numéro musique
Sint32 m_region; // numéro région (*)
Sint32 m_lastRegion; // numéro dernière région
Sint32 m_blupiHere;
POINT m_lastDrapeau[MAXLASTDRAPEAU];
bool m_bHideTooltips; // true -> menu présent
char m_text[50];
POINT m_textLastPos;
Sint32 m_textCount;
Sint32 m_skill;
bool m_bInfo;
Sint32 m_infoHeight;
POINT m_memoPos[4];
Uint8 m_cheminWork[MAXCELX*MAXCELY];
Sint32 m_cheminNbPos;
POINT m_cheminPos[MAXBLUPI*2];
Sint32 m_cheminRank[MAXBLUPI*2];
bool m_bFillFloor;
Sint32 m_fillSearchChannel;
Sint32 m_fillSearchIcon;
Sint32 m_fillPutChannel;
Sint32 m_fillPutIcon;
char* m_pFillMap;
};
// (*) Régions :
// 0 -> normal
// 1 -> palmier
// 2 -> hiver
// 3 -> sapin
/////////////////////////////////////////////////////////////////////////////
POINT GetCel (Sint32 x, Sint32 y);
POINT GetCel (POINT cel, Sint32 x, Sint32 y);
bool IsValid (POINT cel);
POINT GetVector (Sint32 direct);
extern Sint32 table_multi_goal[];
extern Sint16 table_actions[];

File diff suppressed because it is too large Load Diff

View File

@ -1,621 +0,0 @@
// Def.h
//
#pragma once
#include <SDL2/SDL_stdinc.h>
#define _INTRO false // true si images d'introduction
#define LXIMAGE 640 // dimensions de la fenêtre de jeu
#define LYIMAGE 480
#define POSDRAWX 144 // surface de dessin
#define POSDRAWY 15
#define DIMDRAWX 480
#define DIMDRAWY 450
#define POSMAPX 8 // surface pour la carte
#define POSMAPY 15
#define DIMMAPX 128
#define DIMMAPY 128
#define MAXCELX 200 // nb max de cellules d'un monde
#define MAXCELY 200
#define DIMCELX 60 // dimensions d'une cellule (décor)
#define DIMCELY 30
#define DIMOBJX 120 // dimensions d'un objet
#define DIMOBJY 120
#define DIMBLUPIX 60 // dimensions de blupi
#define DIMBLUPIY 60
#define SHIFTBLUPIY 5 // petit décalage vers le haut
#define DIMBUTTONX 40 // dimensions d'un button
#define DIMBUTTONY 40
#define DIMJAUGEX 124 // dimensions de la jauge
#define DIMJAUGEY 22
#define POSSTATX 12 // statistiques
#define POSSTATY 220
#define DIMSTATX 60
#define DIMSTATY 30
#define DIMTEXTX 16 // dimensions max d'un caractère
#define DIMTEXTY 16
#define DIMLITTLEX 16 // dimensions max d'un petit caractère
#define DIMLITTLEY 12
#define CHBACK 0
#define CHFLOOR 1
#define CHOBJECT 2
#define CHOBJECTo 3
#define CHBLUPI 4
#define CHHILI 5
#define CHFOG 6
#define CHMASK1 7
#define CHLITTLE 8
#define CHMAP 9
#define CHBUTTON 10
#define CHGROUND 11
#define CHJAUGE 12
#define CHTEXT 13
#define CHBIGNUM 14
#define FOGHIDE 4
// Directions :
#define DIRECT_E (0*16) // est
#define DIRECT_SE (1*16) // sud-est
#define DIRECT_S (2*16) // sud
#define DIRECT_SO (3*16) // sud-ouest
#define DIRECT_O (4*16) // ouest
#define DIRECT_NO (5*16) // nord-ouest
#define DIRECT_N (6*16) // nord
#define DIRECT_NE (7*16) // nord-est
/* NO
* O | N
* \ | /
* \ | /
* \|/
* SO -------o------- NE
* /|\
* / | \
* / | \
* S | E
* (y) SE (x)
*/
// Actions :
#define ACTION_STOP 0 // arrêt
#define ACTION_STOPf 1 // arrêt fatigué
#define ACTION_MARCHE 2 // marche
#define ACTION_MARCHEf 3 // marche fatigué
#define ACTION_BUILD 4 // construit
#define ACTION_PIOCHE 5 // pioche
#define ACTION_ENERGY 6 // prend de l'énergie
#define ACTION_TAKE 8 // fait sauter un objet sur la tête (est)
#define ACTION_DEPOSE 9 // repose l'objet sur la tête (est)
#define ACTION_SCIE 10 // scie du bois
#define ACTION_BRULE 11 // blupi crame !
#define ACTION_TCHAO 12 // blupi disparait !
#define ACTION_MANGE 13 // blupi mange
#define ACTION_NAISSANCE 14 // naissance
#define ACTION_SAUTE2 15 // saute par-dessus un obstacle
#define ACTION_SAUTE3 16 // saute par-dessus un obstacle
#define ACTION_SAUTE4 17 // saute par-dessus un obstacle
#define ACTION_SAUTE5 18 // saute par-dessus un obstacle
#define ACTION_PONT 19 // pousse un pont
#define ACTION_MISC1 20 // divers 1 (hausse les épaules)
#define ACTION_MISC2 21 // divers 2 (grat-grat)
#define ACTION_MISC3 22 // divers 3 (yoyo)
#define ACTION_MISC1f 23 // divers 1 fatigué (bof-bof)
#define ACTION_GLISSE 24 // glisse en marchant
#define ACTION_BOIT 25 // blupi boit
#define ACTION_LABO 26 // blupi travaille dans son laboratoire
#define ACTION_DYNAMITE 27 // blupi fait péter la dynamite
#define ACTION_DELAY 28 // blupi attend un frame
#define ACTION_CUEILLE1 29 // blupi cueille des fleurs
#define ACTION_CUEILLE2 30 // blupi cueille des fleurs
#define ACTION_MECHE 31 // blupi se bouche les oreilles
#define ACTION_STOPb 32 // arrêt en bateau
#define ACTION_MARCHEb 33 // avance en bateau
#define ACTION_STOPj 34 // arrêt en jeep
#define ACTION_MARCHEj 35 // avance en jeep
#define ACTION_ELECTRO 36 // blupi électrocuté
#define ACTION_GRILLE1 37 // blupi grille (phase 1)
#define ACTION_GRILLE2 38 // blupi grille (phase 2)
#define ACTION_GRILLE3 39 // blupi grille (phase 3)
#define ACTION_MISC4 40 // divers 4 (ferme les yeux)
#define ACTION_CONTENT 41 // blupi est content
#define ACTION_ARROSE 42 // blupi arrose
#define ACTION_BECHE 43 // blupi bèche
#define ACTION_CUEILLE3 44 // blupi cueille des fleurs
#define ACTION_BUILDBREF 45 // construit
#define ACTION_BUILDSEC 46 // construit
#define ACTION_BUILDSOURD 47 // construit
#define ACTION_BUILDPIERRE 48 // construit
#define ACTION_PIOCHEPIERRE 49 // pioche
#define ACTION_PIOCHESOURD 50 // pioche
#define ACTION_MISC5 51 // divers 5 (ohé)
#define ACTION_TELEPORTE1 52 // téléporte
#define ACTION_TELEPORTE2 53 // téléporte
#define ACTION_TELEPORTE3 54 // téléporte
#define ACTION_STOPa 55 // arrêt armure
#define ACTION_MARCHEa 56 // marche armure
#define ACTION_ARMUREOPEN 57 // ouvre armure
#define ACTION_ARMURECLOSE 58 // ferme armure
#define ACTION_SAUTE1 59 // saute dans la jeep
#define ACTION_MISC6 60 // divers 6 (diabolo)
#define ACTION_A_STOP 100 // araignée: arrêt
#define ACTION_A_MARCHE 101 // araignée: marche
#define ACTION_A_SAUT 102 // araignée: saute
#define ACTION_A_GRILLE 103 // araignée: grille dans rayon
#define ACTION_A_POISON 105 // araignée: empoisonée
#define ACTION_A_MORT1 106 // araignée: meurt
#define ACTION_A_MORT2 107 // araignée: meurt
#define ACTION_A_MORT3 108 // araignée: meurt
#define ACTION_V_STOP 200 // virus: arrêt
#define ACTION_V_MARCHE 201 // virus: marche
#define ACTION_V_GRILLE 202 // virus: grille dans rayon
#define ACTION_T_STOP 300 // tracks: arrêt
#define ACTION_T_MARCHE 301 // tracks: marche
#define ACTION_T_ECRASE 302 // tracks: écrase un objet
#define ACTION_R_STOP 400 // robot: arrêt
#define ACTION_R_MARCHE 401 // robot: marche
#define ACTION_R_APLAT 402 // robot: applatit
#define ACTION_R_BUILD 403 // robot: construit
#define ACTION_R_DELAY 404 // robot: construit
#define ACTION_R_CHARGE 405 // robot: recharge
#define ACTION_R_ECRASE 406 // robot: écrase un objet
#define ACTION_B_STOP 500 // bombe: arrêt
#define ACTION_B_MARCHE 501 // bombe: marche
#define ACTION_D_DELAY 600 // détonnateur: attend
#define ACTION_E_STOP 700 // électro: arrêt
#define ACTION_E_MARCHE 701 // électro: marche
#define ACTION_E_DEBUT 702 // électro: débute
#define ACTION_E_RAYON 703 // électro: rayonne
#define ACTION_D_STOP 800 // disciple: arrêt
#define ACTION_D_MARCHE 801 // disciple: marche
#define ACTION_D_BUILD 802 // disciple: construit
#define ACTION_D_PIOCHE 803 // disciple: pioche
#define ACTION_D_SCIE 804 // disciple: scie du bois
#define ACTION_D_TCHAO 805 // disciple: disparait !
#define ACTION_D_CUEILLE1 806 // disciple: cueille des fleurs
#define ACTION_D_CUEILLE2 807 // disciple: cueille des fleurs
#define ACTION_D_MECHE 808 // disciple: se bouche les oreilles
#define ACTION_D_ARROSE 809 // disciple: arrose
#define ACTION_D_BECHE 810 // disciple: bèche
// Sons :
#define SOUND_CLICK 0
#define SOUND_BOING 1
#define SOUND_OK1 2
#define SOUND_OK2 3
#define SOUND_OK3 4
#define SOUND_GO1 5
#define SOUND_GO2 6
#define SOUND_GO3 7
#define SOUND_TERM1 8
#define SOUND_TERM2 9
#define SOUND_TERM3 10
#define SOUND_COUPTERRE 11
#define SOUND_COUPTOC 12
#define SOUND_SAUT 13
#define SOUND_HOP 14
#define SOUND_SCIE 15
#define SOUND_FEU 16
#define SOUND_BRULE 17
#define SOUND_TCHAO 18
#define SOUND_MANGE 19
#define SOUND_NAISSANCE 20
#define SOUND_A_SAUT 21
#define SOUND_A_HIHI 22
#define SOUND_PLOUF 23
#define SOUND_BUT 24
#define SOUND_RAYON1 25
#define SOUND_RAYON2 26
#define SOUND_VIRUS 27
#define SOUND_GLISSE 28
#define SOUND_BOIT 29
#define SOUND_LABO 30
#define SOUND_DYNAMITE 31
#define SOUND_PORTE 32
#define SOUND_FLEUR 33
#define SOUND_T_MOTEUR 34
#define SOUND_T_ECRASE 35
#define SOUND_PIEGE 36
#define SOUND_AIE 37
#define SOUND_A_POISON 38
#define SOUND_R_MOTEUR 39
#define SOUND_R_APLAT 40
#define SOUND_R_ROTATE 41
#define SOUND_R_CHARGE 42
#define SOUND_B_SAUT 43
#define SOUND_BATEAU 44
#define SOUND_JEEP 45
#define SOUND_MINE 46
#define SOUND_USINE 47
#define SOUND_E_RAYON 48
#define SOUND_E_TOURNE 49
#define SOUND_ARROSE 50
#define SOUND_BECHE 51
#define SOUND_D_BOING 52
#define SOUND_D_OK 53
#define SOUND_D_GO 54
#define SOUND_D_TERM 55
#define SOUND_BOING1 56
#define SOUND_BOING2 57
#define SOUND_BOING3 58
#define SOUND_OK4 59
#define SOUND_OK5 60
#define SOUND_OK6 61
#define SOUND_OK1f 62
#define SOUND_OK2f 63
#define SOUND_OK3f 64
#define SOUND_OK1e 65
#define SOUND_OK2e 66
#define SOUND_OK3e 67
#define SOUND_GO4 68
#define SOUND_GO5 69
#define SOUND_GO6 70
#define SOUND_TERM4 71
#define SOUND_TERM5 72
#define SOUND_TERM6 73
#define SOUND_COUPSEC 74
#define SOUND_COUPPIERRE 75
#define SOUND_COUPSOURD 76
#define SOUND_COUPBREF 77
#define SOUND_OPEN 78
#define SOUND_CLOSE 79
#define SOUND_TELEPORTE 80
#define SOUND_ARMUREOPEN 81
#define SOUND_ARMURECLOSE 82
#define SOUND_WIN 83
#define SOUND_LOST 84
// Boutons (play) :
#define MAXBUTTON 40
#define BUTTON_GO 0
#define BUTTON_STOP 1
#define BUTTON_MANGE 2
#define BUTTON_CARRY 3
#define BUTTON_DEPOSE 4
#define BUTTON_ABAT 5
#define BUTTON_ROC 6
#define BUTTON_CULTIVE 7
#define BUTTON_BUILD1 8
#define BUTTON_BUILD2 9
#define BUTTON_BUILD3 10
#define BUTTON_BUILD4 11
#define BUTTON_BUILD5 12
#define BUTTON_BUILD6 13
#define BUTTON_MUR 14
#define BUTTON_PALIS 15
#define BUTTON_ABATn 16
#define BUTTON_ROCn 17
#define BUTTON_PONT 18
#define BUTTON_TOUR 19
#define BUTTON_BOIT 20
#define BUTTON_LABO 21
#define BUTTON_FLEUR 22
#define BUTTON_FLEURn 23
#define BUTTON_DYNAMITE 24
#define BUTTON_BATEAU 25
#define BUTTON_DJEEP 26
#define BUTTON_DRAPEAU 27
#define BUTTON_EXTRAIT 28
#define BUTTON_FABJEEP 29
#define BUTTON_FABMINE 30
#define BUTTON_FABDISC 31
#define BUTTON_REPEAT 32
#define BUTTON_DARMURE 33
#define BUTTON_FABARMURE 34
// Erreurs :
#define ERROR_MISC 1
#define ERROR_GROUND 2
#define ERROR_FREE 3
#define ERROR_PONTOP 4
#define ERROR_PONTTERM 5
#define ERROR_TOURISOL 6
#define ERROR_TOUREAU 7
#define ERROR_TELE2 8
// Lutins pour la souris
enum MouseSprites
{
SPRITE_BEGIN = 1,
SPRITE_ARROW = 1,
SPRITE_POINTER = 2,
SPRITE_MAP = 3,
SPRITE_ARROWU = 4,
SPRITE_ARROWD = 5,
SPRITE_ARROWL = 6,
SPRITE_ARROWR = 7,
SPRITE_ARROWUL = 8,
SPRITE_ARROWUR = 9,
SPRITE_ARROWDL = 10,
SPRITE_ARROWDR = 11,
SPRITE_WAIT = 12,
SPRITE_EMPTY = 13,
SPRITE_FILL = 14,
SPRITE_END = 14,
};
#define WM_USER 0x0400
#define WM_UPDATE (WM_USER+1)
#define WM_DECOR1 (WM_USER+20)
#define WM_DECOR2 (WM_USER+21)
#define WM_DECOR3 (WM_USER+22)
#define WM_DECOR4 (WM_USER+23)
#define WM_DECOR5 (WM_USER+24)
#define WM_ACTION_GO (WM_USER+30)
#define WM_ACTION_ABAT1 (WM_USER+31)
#define WM_ACTION_ABAT2 (WM_USER+32)
#define WM_ACTION_ABAT3 (WM_USER+33)
#define WM_ACTION_ABAT4 (WM_USER+34)
#define WM_ACTION_ABAT5 (WM_USER+35)
#define WM_ACTION_ABAT6 (WM_USER+36)
#define WM_ACTION_BUILD1 (WM_USER+37)
#define WM_ACTION_BUILD2 (WM_USER+38)
#define WM_ACTION_BUILD3 (WM_USER+39)
#define WM_ACTION_BUILD4 (WM_USER+40)
#define WM_ACTION_BUILD5 (WM_USER+41)
#define WM_ACTION_BUILD6 (WM_USER+42)
#define WM_ACTION_STOP (WM_USER+43)
#define WM_ACTION_CARRY (WM_USER+44)
#define WM_ACTION_DEPOSE (WM_USER+45)
#define WM_ACTION_ROC1 (WM_USER+46)
#define WM_ACTION_ROC2 (WM_USER+47)
#define WM_ACTION_ROC3 (WM_USER+48)
#define WM_ACTION_ROC4 (WM_USER+49)
#define WM_ACTION_ROC5 (WM_USER+50)
#define WM_ACTION_ROC6 (WM_USER+51)
#define WM_ACTION_ROC7 (WM_USER+52)
#define WM_ACTION_MUR (WM_USER+53)
#define WM_ACTION_CULTIVE (WM_USER+54)
#define WM_ACTION_CULTIVE2 (WM_USER+55)
#define WM_ACTION_MANGE (WM_USER+56)
#define WM_ACTION_MAKE (WM_USER+57)
#define WM_ACTION_BUILD (WM_USER+58)
#define WM_ACTION_PALIS (WM_USER+59)
#define WM_ACTION_NEWBLUPI (WM_USER+60)
#define WM_ACTION_PONTE (WM_USER+61)
#define WM_ACTION_PONTS (WM_USER+62)
#define WM_ACTION_PONTO (WM_USER+63)
#define WM_ACTION_PONTN (WM_USER+64)
#define WM_ACTION_PONTEL (WM_USER+65)
#define WM_ACTION_PONTSL (WM_USER+66)
#define WM_ACTION_PONTOL (WM_USER+67)
#define WM_ACTION_PONTNL (WM_USER+68)
#define WM_ACTION_TOUR (WM_USER+69)
#define WM_ACTION_CARRY2 (WM_USER+70)
#define WM_ACTION_DEPOSE2 (WM_USER+71)
#define WM_ACTION_MANGE2 (WM_USER+72)
#define WM_ACTION_BOIT (WM_USER+73)
#define WM_ACTION_BOIT2 (WM_USER+74)
#define WM_ACTION_LABO (WM_USER+75)
#define WM_ACTION_FLEUR1 (WM_USER+76)
#define WM_ACTION_FLEUR2 (WM_USER+77)
#define WM_ACTION_DYNAMITE (WM_USER+78)
#define WM_ACTION_DYNAMITE2 (WM_USER+79)
#define WM_ACTION_T_DYNAMITE (WM_USER+80)
#define WM_ACTION_FLEUR3 (WM_USER+81)
#define WM_ACTION_R_BUILD1 (WM_USER+82)
#define WM_ACTION_R_BUILD2 (WM_USER+83)
#define WM_ACTION_R_BUILD3 (WM_USER+84)
#define WM_ACTION_R_BUILD4 (WM_USER+85)
#define WM_ACTION_R_MAKE1 (WM_USER+86)
#define WM_ACTION_R_MAKE2 (WM_USER+87)
#define WM_ACTION_R_MAKE3 (WM_USER+88)
#define WM_ACTION_R_MAKE4 (WM_USER+89)
#define WM_ACTION_R_BUILD5 (WM_USER+90)
#define WM_ACTION_R_MAKE5 (WM_USER+91)
#define WM_ACTION_BATEAUE (WM_USER+92)
#define WM_ACTION_BATEAUS (WM_USER+93)
#define WM_ACTION_BATEAUO (WM_USER+94)
#define WM_ACTION_BATEAUN (WM_USER+95)
#define WM_ACTION_BATEAUDE (WM_USER+96)
#define WM_ACTION_BATEAUDS (WM_USER+97)
#define WM_ACTION_BATEAUDO (WM_USER+98)
#define WM_ACTION_BATEAUDN (WM_USER+99)
#define WM_ACTION_BATEAUAE (WM_USER+100)
#define WM_ACTION_BATEAUAS (WM_USER+101)
#define WM_ACTION_BATEAUAO (WM_USER+102)
#define WM_ACTION_BATEAUAN (WM_USER+103)
#define WM_ACTION_MJEEP (WM_USER+104)
#define WM_ACTION_DJEEP (WM_USER+105)
#define WM_ACTION_DRAPEAU (WM_USER+106)
#define WM_ACTION_DRAPEAU2 (WM_USER+107)
#define WM_ACTION_DRAPEAU3 (WM_USER+108)
#define WM_ACTION_EXTRAIT (WM_USER+109)
#define WM_ACTION_FABJEEP (WM_USER+110)
#define WM_ACTION_FABMINE (WM_USER+111)
#define WM_ACTION_MINE (WM_USER+112)
#define WM_ACTION_MINE2 (WM_USER+113)
#define WM_ACTION_R_BUILD6 (WM_USER+114)
#define WM_ACTION_R_MAKE6 (WM_USER+115)
#define WM_ACTION_E_RAYON (WM_USER+116)
#define WM_ACTION_ELECTRO (WM_USER+117)
#define WM_ACTION_ELECTROm (WM_USER+118)
#define WM_ACTION_GRILLE (WM_USER+119)
#define WM_ACTION_MAISON (WM_USER+120)
#define WM_ACTION_FABDISC (WM_USER+121)
#define WM_ACTION_A_MORT (WM_USER+122)
#define WM_ACTION_REPEAT (WM_USER+123)
#define WM_ACTION_TELEPORTE00 (WM_USER+124)
#define WM_ACTION_TELEPORTE10 (WM_USER+125)
#define WM_ACTION_TELEPORTE01 (WM_USER+126)
#define WM_ACTION_TELEPORTE11 (WM_USER+127)
#define WM_ACTION_FABARMURE (WM_USER+128)
#define WM_ACTION_MARMURE (WM_USER+129)
#define WM_ACTION_DARMURE (WM_USER+130)
#define WM_BUTTON0 (WM_USER+200)
#define WM_BUTTON1 (WM_USER+201)
#define WM_BUTTON2 (WM_USER+202)
#define WM_BUTTON3 (WM_USER+203)
#define WM_BUTTON4 (WM_USER+204)
#define WM_BUTTON5 (WM_USER+205)
#define WM_BUTTON6 (WM_USER+206)
#define WM_BUTTON7 (WM_USER+207)
#define WM_BUTTON8 (WM_USER+208)
#define WM_BUTTON9 (WM_USER+209)
#define WM_BUTTON10 (WM_USER+210)
#define WM_BUTTON11 (WM_USER+211)
#define WM_BUTTON12 (WM_USER+212)
#define WM_BUTTON13 (WM_USER+213)
#define WM_BUTTON14 (WM_USER+214)
#define WM_BUTTON15 (WM_USER+215)
#define WM_BUTTON16 (WM_USER+216)
#define WM_BUTTON17 (WM_USER+217)
#define WM_BUTTON18 (WM_USER+218)
#define WM_BUTTON19 (WM_USER+219)
#define WM_BUTTON20 (WM_USER+220)
#define WM_BUTTON21 (WM_USER+221)
#define WM_BUTTON22 (WM_USER+222)
#define WM_BUTTON23 (WM_USER+223)
#define WM_BUTTON24 (WM_USER+224)
#define WM_BUTTON25 (WM_USER+225)
#define WM_BUTTON26 (WM_USER+226)
#define WM_BUTTON27 (WM_USER+227)
#define WM_BUTTON28 (WM_USER+228)
#define WM_BUTTON29 (WM_USER+229)
#define WM_BUTTON30 (WM_USER+230)
#define WM_BUTTON31 (WM_USER+231)
#define WM_BUTTON32 (WM_USER+232)
#define WM_BUTTON33 (WM_USER+233)
#define WM_BUTTON34 (WM_USER+234)
#define WM_BUTTON35 (WM_USER+235)
#define WM_BUTTON36 (WM_USER+236)
#define WM_BUTTON37 (WM_USER+237)
#define WM_BUTTON38 (WM_USER+238)
#define WM_BUTTON39 (WM_USER+239)
#define WM_READ0 (WM_USER+300)
#define WM_READ1 (WM_USER+301)
#define WM_READ2 (WM_USER+302)
#define WM_READ3 (WM_USER+303)
#define WM_READ4 (WM_USER+304)
#define WM_READ5 (WM_USER+305)
#define WM_READ6 (WM_USER+306)
#define WM_READ7 (WM_USER+307)
#define WM_READ8 (WM_USER+308)
#define WM_READ9 (WM_USER+309)
#define WM_WRITE0 (WM_USER+310)
#define WM_WRITE1 (WM_USER+311)
#define WM_WRITE2 (WM_USER+312)
#define WM_WRITE3 (WM_USER+313)
#define WM_WRITE4 (WM_USER+314)
#define WM_WRITE5 (WM_USER+315)
#define WM_WRITE6 (WM_USER+316)
#define WM_WRITE7 (WM_USER+317)
#define WM_WRITE8 (WM_USER+318)
#define WM_WRITE9 (WM_USER+319)
#define WM_PHASE_INIT (WM_USER+500)
#define WM_PHASE_PLAY (WM_USER+501)
#define WM_PHASE_BUILD (WM_USER+502)
#define WM_PHASE_READ (WM_USER+503)
#define WM_PHASE_WRITE (WM_USER+504)
#define WM_PHASE_INFO (WM_USER+505)
#define WM_PHASE_BUTTON (WM_USER+506)
#define WM_PHASE_TERM (WM_USER+507)
#define WM_PHASE_WIN (WM_USER+508)
#define WM_PHASE_LOST (WM_USER+509)
#define WM_PHASE_STOP (WM_USER+510)
#define WM_PHASE_SETUP (WM_USER+511)
#define WM_PHASE_MUSIC (WM_USER+512)
#define WM_PHASE_PLAYMOVIE (WM_USER+513)
#define WM_PHASE_WINMOVIE (WM_USER+514)
#define WM_PHASE_SCHOOL (WM_USER+515)
#define WM_PHASE_MISSION (WM_USER+516)
#define WM_PHASE_LASTWIN (WM_USER+517)
#define WM_PHASE_WRITEp (WM_USER+518)
#define WM_PHASE_SETUPp (WM_USER+519)
#define WM_PHASE_REGION (WM_USER+520)
#define WM_PHASE_INSERT (WM_USER+521)
#define WM_PHASE_HISTORY0 (WM_USER+522)
#define WM_PHASE_HISTORY1 (WM_USER+523)
#define WM_PHASE_HELP (WM_USER+524)
#define WM_PHASE_H0MOVIE (WM_USER+525)
#define WM_PHASE_H1MOVIE (WM_USER+526)
#define WM_PHASE_H2MOVIE (WM_USER+527)
#define WM_PHASE_TESTCD (WM_USER+528)
#define WM_PHASE_MANUEL (WM_USER+529)
#define WM_PHASE_PRIVATE (WM_USER+530)
#define WM_PHASE_UNDO (WM_USER+531)
#define WM_PHASE_BYE (WM_USER+532)
#define WM_PHASE_SKILL1 (WM_USER+533)
#define WM_PHASE_SKILL2 (WM_USER+534)
#define WM_PHASE_DEMO (WM_USER+535)
#define WM_PHASE_INTRO1 (WM_USER+536)
#define WM_PHASE_INTRO2 (WM_USER+537)
#define WM_MUSIC_STOP (WM_USER+550)
#define WM_PREV (WM_USER+600)
#define WM_NEXT (WM_USER+601)
#define WM_MOVIE (WM_USER+602)
#define WM_MOVIE_PLAY (WM_USER+603)
// Types de gestion de la souris.
#define MOUSETYPEGRA 1
#define MOUSETYPEWIN 2
#define MOUSETYPEWINPOS 3
// Conditions pour gagner.
typedef struct
{
Sint16 bHachBlupi; // blupi sur dalle hachurée
Sint16 bHachPlanche; // planches sur dalle hachurée
Sint16 bStopFire; // feu éteint
Sint16 nbMinBlupi; // nb de blupi nécessaires
Sint16 nbMaxBlupi; // nb de blupi nécessaires
Sint16 bHomeBlupi; // blupi à la maison
Sint16 bKillRobots; // plus d'ennemis
Sint16 bHachTomate; // tomates sur dalle hachurée
Sint16 bHachMetal; // métal sur dalle hachurée
Sint16 bHachRobot; // robot sur dalle hachurée
Sint16 reserve[14];
}
Term;

File diff suppressed because it is too large Load Diff

View File

@ -1,228 +0,0 @@
// Event.h
#pragma once
#include <vector>
#include <unordered_map>
#include "blupi.h"
#include "jauge.h"
#include "menu.h"
#include "button.h"
class CMovie;
/////////////////////////////////////////////////////////////////////////////
typedef struct
{
Uint32 message;
Sint32 type;
Sint32 iconMenu[20];
Sint32 x, y;
const char *toolTips[16];
}
Button;
typedef struct
{
Uint32 phase;
char backName[20];
Sint32 bCDrom;
Button buttons[MAXBUTTON];
}
Phase;
typedef struct
{
Sint16 majRev;
Sint16 minRev;
Sint16 bSchool;
Sint16 bPrivate;
Sint16 world;
Sint16 skill;
Sint16 reserve1[99];
}
DemoHeader;
typedef struct
{
Sint32 time;
Uint32 message;
Uint32 wParam; // WPARAM
Uint32 lParam; // LPARAM
}
DemoEvent;
class CEvent
{
public:
CEvent();
~CEvent();
POINT GetMousePos();
void Create(CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CMovie *pMovie);
void SetFullScreen(bool bFullScreen);
void SetMouseType(Sint32 mouseType);
Sint32 GetWorld();
Sint32 GetPhysicalWorld();
Sint32 GetImageWorld();
bool IsHelpHide();
bool ChangePhase(Uint32 phase);
void MovieToStart();
Uint32 GetPhase();
void TryInsert();
void RestoreGame();
Sint32 GetButtonIndex(Sint32 button);
Sint32 GetState(Sint32 button);
void SetState(Sint32 button, Sint32 state);
bool GetEnable(Sint32 button);
void SetEnable(Sint32 button, bool bEnable);
bool GetHide(Sint32 button);
void SetHide(Sint32 button, bool bHide);
Sint32 GetMenu(Sint32 button);
void SetMenu(Sint32 button, Sint32 menu);
bool DrawButtons();
MouseSprites MousePosToSprite(POINT pos);
void MouseSprite(POINT pos);
void WaitMouse(bool bWait);
void HideMouse(bool bHide);
POINT GetLastMousePos();
bool TreatEvent(const SDL_Event &event);
bool TreatEventBase(const SDL_Event &event);
void DecorAutoShift(POINT pos);
bool StartMovie(const char *pFilename);
void StopMovie();
bool IsMovie();
void Read(Sint32 message);
void Write(Sint32 message);
void SetSpeed(Sint32 speed);
Sint32 GetSpeed();
bool GetPause();
bool IsShift();
void DemoStep();
void IntroStep();
public:
static void PushUserEvent (Sint32 code);
protected:
void DrawTextCenter(const char *text, Sint32 x, Sint32 y, Sint32 font=0);
bool CreateButtons();
bool EventButtons(const SDL_Event &event, POINT pos);
bool MouseOnButton(POINT pos);
Sint32 SearchPhase(Uint32 phase);
void DecorShift(Sint32 dx, Sint32 dy);
bool PlayDown(POINT pos, const SDL_Event &event);
bool PlayMove(POINT pos, Uint16 mod);
bool PlayUp(POINT pos, Uint16 mod);
void ChangeButtons(Sint32 message);
void BuildFloor(POINT cel, Sint32 insIcon);
void BuildWater(POINT cel, Sint32 insIcon);
bool BuildDown(POINT pos, Uint16 mod, bool bMix=true);
bool BuildMove(POINT pos, Uint16 mod, const SDL_Event &event);
bool BuildUp(POINT pos);
void PrivateLibelle();
bool ReadLibelle(Sint32 world, bool bSchool, bool bHelp);
bool WriteInfo();
bool ReadInfo();
void DemoRecStart();
void DemoRecStop();
bool DemoPlayStart();
void DemoPlayStop();
static void WinToSDLEvent (Uint32 msg, WPARAM wParam, LPARAM lParam, SDL_Event &event);
void DemoRecEvent(Uint32 message, WPARAM wParam, LPARAM lParam);
protected:
Sint32 m_speed;
Sint32 m_exercice;
Sint32 m_mission;
Sint32 m_private;
Sint32 m_maxMission;
Uint32 m_phase;
Sint32 m_index;
bool m_bSchool;
bool m_bPrivate;
bool m_bAccessBuild;
bool m_bFullScreen;
Sint32 m_mouseType;
CPixmap* m_pPixmap;
CDecor* m_pDecor;
CSound* m_pSound;
CMovie* m_pMovie;
char m_movieToStart[MAX_PATH];
Sint32 m_phaseAfterMovie;
CButton m_buttons[MAXBUTTON];
Sint32 m_lastFloor[MAXBUTTON];
Sint32 m_lastObject[MAXBUTTON];
Sint32 m_lastHome[MAXBUTTON];
bool m_bRunMovie;
bool m_bBuildModify;
CJauge m_jauges[2];
CMenu m_menu;
bool m_bMenu;
POINT m_menuPos;
Sint32 m_menuNb;
Sint32 m_menuButtons[MAXBUTTON];
Sint32 m_menuErrors[MAXBUTTON];
std::unordered_map<Sint32, const char *> m_menuTexts;
Sint32 m_menuPerso;
POINT m_menuCel;
POINT m_oldMousePos;
bool m_bMouseDown;
bool m_bHili;
Sint32 m_fileWorld[10];
Sint32 m_fileTime[10];
POINT m_posToolTips;
char m_textToolTips[50];
MouseSprites m_mouseSprite;
bool m_bFillMouse;
bool m_bWaitMouse;
bool m_bHideMouse;
Sint32 m_rankCheat;
Sint32 m_posCheat;
bool m_bMovie;
bool m_bSpeed;
bool m_bHelp;
bool m_bAllMissions;
bool m_bChangeCheat;
Sint32 m_scrollSpeed;
bool m_bPause;
bool m_bShift;
Sint32 m_shiftPhase;
POINT m_shiftVector;
POINT m_shiftOffset;
char m_libelle[1000];
Sint32 m_tryPhase;
Sint32 m_tryInsertCount;
POINT m_posInfoButton;
POINT m_posHelpButton;
bool m_bHiliInfoButton;
bool m_bHiliHelpButton;
bool m_bInfoHelp;
bool m_bDemoRec;
bool m_bDemoPlay;
DemoEvent* m_pDemoBuffer;
Sint32 m_demoTime;
size_t m_demoIndex;
size_t m_demoEnd;
Sint32 m_demoNumber;
Uint16 m_keymod;
POINT m_debugPos;
Sint32 m_introTime;
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,64 +0,0 @@
// Class CFifo, gestion d'une liste en fifo
#include <stdlib.h>
#include <SDL2/SDL_stdinc.h>
#include "fifo.h"
// gestion d'une pile classée en valeur croissantes
// typiquement reprend les coordonnées les plus proches
// du but en premier lieu
CPileTriee::CPileTriee(Sint32 taille)
{
m_taille = taille;
m_max = m_out = 0;
m_data = (Element*) malloc (sizeof(Element)*taille);
}
CPileTriee::~CPileTriee()
{
free( m_data );
}
Sint32 CPileTriee::get()
{
if (m_out == m_max) return -1;
Sint32 val = m_data [m_out].pos;
m_out++;
if (m_out>=m_taille) m_out = 0;
return val;
}
void CPileTriee::put(Sint32 pos, Sint32 dist)
{
Sint32 i=m_out;
Sint32 p,d,m;
while (i!=m_max)
{
// le point est-il plus proche que celui-là ?
if (dist<m_data[i].dist)
{
// oui, insert et décale le suivant
p = m_data[i].pos;
d = m_data[i].dist;
m_data[i].pos = pos;
m_data[i].dist = dist;
pos = p;
dist = d;
}
i++;
if (i>=m_taille) i=0;
}
// ajoute le point éloigné à la suite
m = m_max+1;
if (m>=m_taille) m=0;
if (m!=m_out)
{
m_data[m_max].pos = pos;
m_data[m_max].dist = dist;
m_max = m;
}
}

View File

@ -1,33 +0,0 @@
#pragma once
// traitement d'une liste en fifo
// stucture pour enpiler des positions
// en fonction de leur distance à la cible
typedef struct
{
Sint32 pos;
Sint32 dist;
}
Element;
// traitement d'une pile triée
class CPileTriee
{
private:
Sint32 m_taille; // nombre de polongs max
Sint32 m_max; // position limite
Sint32 m_out; // position pour reprendre
Element* m_data; // données
public:
CPileTriee(Sint32 taille);
~CPileTriee();
void put(Sint32 pos, Sint32 dist);
Sint32 get();
};

View File

@ -1,152 +0,0 @@
// Fog.cpp
#include "decor.h"
// Cette table indique les quarts de cases contenant du
// brouillard lorsque la valeur est à un.
// 0 1
// 2 3
static char tableFog[15*4] =
{
1,1,1,0, // 0
1,1,0,0, // 1
1,1,0,1, // 2
1,0,1,0, // 3
1,1,1,1, // 4
0,1,0,1, // 5
1,0,1,1, // 6
0,0,1,1, // 7
0,1,1,1, // 8
0,0,0,1, // 9
0,0,1,0, // 10
1,0,0,1, // 11
0,1,0,0, // 12
1,0,0,0, // 13
0,1,1,0, // 14
};
// Retourne les bits contenant du brouillard.
bool GetFogBits(Sint32 icon, char *pBits)
{
pBits[0] = 0;
pBits[1] = 0;
pBits[2] = 0;
pBits[3] = 0;
if ( icon < 0 || icon >= 15 ) return true;
pBits[0] = tableFog[icon*4+0];
pBits[1] = tableFog[icon*4+1];
pBits[2] = tableFog[icon*4+2];
pBits[3] = tableFog[icon*4+3];
return true;
}
// Retourne l'icône correspondant aux bits de brouillard.
Sint32 GetFogIcon(char *pBits)
{
Sint32 i;
for ( i=0 ; i<15 ; i++ )
{
if ( tableFog[i*4+0] == pBits[0] &&
tableFog[i*4+1] == pBits[1] &&
tableFog[i*4+2] == pBits[2] &&
tableFog[i*4+3] == pBits[3] ) return i;
}
return -1;
}
// Table donnant la "vision" d'un blupi dans le
// brouillard.
static char table_fog[17*17] =
{
#if 1
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 1,-1, 5, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 1,-1,-1,-1, 5, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 1,-1,-1,-1,-1,-1, 5, 4, 4, 4, 4, 4, 4,
4, 4, 4, 1,-1,-1,-1,-1,-1,-1,-1, 5, 4, 4, 4, 4, 4,
4, 4, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 5, 4, 4, 4, 4,
4, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 5, 4, 4, 4,
4, 4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 5, 4, 4,
4, 4, 4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 8, 4,
4, 4, 4, 4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1, 7, 4, 4,
4, 4, 4, 4, 4, 3,-1,-1,-1,-1,-1,-1,-1, 7, 4, 4, 4,
4, 4, 4, 4, 4, 4, 3,-1,-1,-1,-1,-1, 7, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 3,-1,-1,-1, 7, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 3,-1, 7, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
#else
4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 1,-1, 5, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 1,-1,-1,-1, 5, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 1,-1,-1,-1,-1,-1, 5, 4, 4, 4, 4, 4,
4, 4, 4, 4, 1,-1,-1,-1,-1,-1,-1,-1, 5, 4, 4, 4, 4,
4, 4, 4, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 5, 4, 4, 4,
4, 4, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 5, 4, 4,
4, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 5, 4,
0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 8,
4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 7, 4,
4, 4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 7, 4, 4,
4, 4, 4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1, 7, 4, 4, 4,
4, 4, 4, 4, 3,-1,-1,-1,-1,-1,-1,-1, 7, 4, 4, 4, 4,
4, 4, 4, 4, 4, 3,-1,-1,-1,-1,-1, 7, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 3,-1,-1,-1, 7, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 3,-1, 7, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4,
#endif
};
// Ecarte le brouillard autour d'un blupi.
void CDecor::BlupiPushFog(Sint32 rank)
{
Sint32 x, y, i;
POINT cel;
char cBits[4];
char nBits[4];
if ( m_blupi[rank].perso != 0 &&
m_blupi[rank].perso != 8 ) return;
for ( y=0 ; y<17 ; y++ )
{
for ( x=0 ; x<17 ; x++ )
{
if ( x%2 != y%2 ) continue;
if ( table_fog[x+y*17] == FOGHIDE ) continue;
cel.x = (x + ((m_blupi[rank].cel.x+1)/4)*2 - 8)*2;
cel.y = (y + ((m_blupi[rank].cel.y+1)/4)*2 - 8)*2;
// Ne pas utiliser IsValid pour permettre d'aller
// jusqu'au bord !
if ( cel.x >= 0 && cel.x < MAXCELX &&
cel.y >= 0 && cel.y < MAXCELX )
{
if ( m_decor[cel.x/2][cel.y/2].fog != -1 )
{
GetFogBits(m_decor[cel.x/2][cel.y/2].fog, cBits);
GetFogBits(table_fog[x+y*17], nBits);
for ( i=0 ; i<4 ; i++ )
{
nBits[i] &= cBits[i]; // "ou" visibilité
}
m_decor[cel.x/2][cel.y/2].fog = GetFogIcon(nBits);
}
}
}
}
}

View File

@ -1,150 +0,0 @@
// Jauge.cpp
//
#include <stdlib.h>
#include <stdio.h>
#include "def.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "jauge.h"
#include "misc.h"
/////////////////////////////////////////////////////////////////////////////
// Constructeur.
CJauge::CJauge()
{
m_type = 0;
m_bHide = true;
m_bMinimizeRedraw = false;
m_bRedraw = false;
}
// Destructeur.
CJauge::~CJauge()
{
}
// Crée un nouveau bouton.
bool CJauge::Create(CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 type, bool bMinimizeRedraw)
{
m_pPixmap = pPixmap;
m_pSound = pSound;
m_type = type;
m_bMinimizeRedraw = bMinimizeRedraw;
m_bHide = true;
m_pos = pos;
m_dim.x = DIMJAUGEX;
m_dim.y = DIMJAUGEY;
m_level = 0;
m_bRedraw = true;
return true;
}
// Dessine un bouton dans son état.
void CJauge::Draw()
{
Sint32 part;
RECT rect;
if ( m_bMinimizeRedraw && !m_bRedraw ) return;
m_bRedraw = false;
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
}
}
// Redessine une jauge.
void CJauge::Redraw()
{
m_bRedraw = true;
}
// Modifie le niveau.
void CJauge::SetLevel(Sint32 level)
{
if ( level < 0 ) level = 0;
if ( level > 100 ) level = 100;
if ( m_level != level )
{
m_bRedraw = true;
}
m_level = level;
}
// Modifie le type.
void CJauge::SetType(Sint32 type)
{
if ( m_type != type )
{
m_bRedraw = true;
}
m_type = type;
}
bool CJauge::GetHide()
{
return m_bHide;
}
void CJauge::SetHide(bool bHide)
{
if ( m_bHide != bHide )
{
m_bRedraw = true;
}
m_bHide = bHide;
}
POINT CJauge::GetPos()
{
return m_pos;
}
void CJauge::SetRedraw()
{
m_bRedraw = true;
}

View File

@ -1,44 +0,0 @@
// Jauge.h
#pragma once
class CPixmap;
class CDecor;
class CSound;
/////////////////////////////////////////////////////////////////////////////
class CJauge
{
public:
CJauge();
~CJauge();
bool Create(CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 type, bool bMinimizeRedraw);
void Draw();
void Redraw();
void SetLevel(Sint32 level);
void SetType(Sint32 type);
bool GetHide();
void SetHide(bool bHide);
POINT GetPos();
void SetRedraw();
protected:
CPixmap* m_pPixmap;
CDecor* m_pDecor;
CSound* m_pSound;
bool m_bHide; // true si bouton caché
POINT m_pos; // coin sup/gauche
POINT m_dim; // dimensions
Sint32 m_type;
Sint32 m_level;
bool m_bMinimizeRedraw;
bool m_bRedraw; // true -> doit être redessiné
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,496 +0,0 @@
// Menu.cpp
//
#include <stdlib.h>
#include <stdio.h>
#include "blupi.h"
#include "def.h"
#include "resource.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "button.h"
#include "menu.h"
#include "text.h"
#include "misc.h"
#include "event.h"
/////////////////////////////////////////////////////////////////////////////
#define MARGMENU 0
static const Sint16 table_button_icon[] =
{
24, // go
40, // stop
32, // mange
30, // carry
31, // depose
22, // abat
27, // roc
28, // cultive
19, // build1 (cabane)
25, // build2 (couveuse)
35, // build3 (laboratoire)
61, // build4 (mine)
59, // build5 (usine)
101, // build6 (téléporteur)
20, // mur
26, // palis
42, // abat n
43, // roc n
23, // pont
33, // tour
34, // boit
39, // labo
54, // fleur
55, // fleur n
41, // dynamite
58, // bateau
60, // djeep
64, // drapeau
62, // extrait du fer
65, // fabrique jeep
63, // fabrique mine
83, // fabrique disciple
100, // repeat
107, // qarmure
106, // fabarmure
};
static const char *GetText(Sint32 rank)
{
static const char *list[] = {
"Go",
"Stop",
"Eat",
"Take",
"Drop",
"Cut down a tree",
"Carve a rock",
"Grow tomatoes",
"Garden shed",
"Incubator",
"Laboratory",
"Mine",
"Workshop",
"Teleporter",
"Wall",
"Palisade",
"Cut down trees",
"Carve rocks",
"Bridge",
"Protection tower",
"Drink",
"Transform",
"Make bunch of flowers",
"Make bunches of flowers",
"Blow up",
"Boat",
"Leave Jeep",
"Prospect for iron",
"Extract iron",
"Make a Jeep",
"Make a time bomb",
"Make a helper robot",
"Repeat",
"Quit",
"Make armour",
};
return gettext (list[rank]);
}
static const char *GetErr(Sint32 rank)
{
static const char *list[] = {
"Impossible",
"Inadequate ground",
"Occupied ground",
"Opposite bank no good",
"Bridge finished",
"(isolated tower)",
"Too close to water",
"Already two teleporters",
};
return gettext (list[rank]);
}
/////////////////////////////////////////////////////////////////////////////
// Constructeur.
CMenu::CMenu()
{
m_nbButtons = 0;
m_selRank = -1;
}
// Destructeur.
CMenu::~CMenu()
{
}
// Crée un nouveau bouton.
bool CMenu::Create(CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
std::unordered_map<Sint32, const char *> &texts,
Sint32 perso)
{
pos.x -= DIMBUTTONX/2;
pos.y -= DIMBUTTONY/2;
m_pPixmap = pPixmap;
m_pSound = pSound;
m_nbButtons = nb;
m_pos = pos;
m_perso = perso;
Update(nb, pButtons, pErrors, texts);
if ( m_pos.x < POSDRAWX ) m_pos.x = POSDRAWX;
if ( m_pos.y < POSDRAWY ) m_pos.y = POSDRAWY;
if ( m_pos.x > POSDRAWX+DIMDRAWX-2-m_dim.x ) m_pos.x = POSDRAWX+DIMDRAWX-2-m_dim.x;
if ( m_pos.y > POSDRAWY+DIMDRAWY-2-m_dim.y ) m_pos.y = POSDRAWY+DIMDRAWY-2-m_dim.y;
if ( m_pos.x != pos.x || m_pos.y != pos.y )
{
pos = m_pos;
pos.x += DIMBUTTONX/2;
pos.y += DIMBUTTONY/2;
SDL_WarpMouseInWindow (g_window, pos.x, pos.y);
}
m_selRank = Detect(pos);
return true;
}
// Met à jour le menu.
void CMenu::Update(Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
std::unordered_map<Sint32, const char *> &texts)
{
Sint32 i;
m_nbButtons = nb;
if ( nb < 5 ) m_nbCel.x = 1;
else m_nbCel.x = 2;
m_nbCel.y = (nb+m_nbCel.x-1)/m_nbCel.x;
m_dim.x = (DIMBUTTONX+MARGMENU)*m_nbCel.x;
m_dim.y = (DIMBUTTONY+MARGMENU)*m_nbCel.y;
for ( i=0 ; i<nb ; i++ )
{
m_buttons[i] = pButtons[i];
m_errors[i] = pErrors[i];
}
m_texts = texts;
}
// Détruit le menu.
void CMenu::Delete()
{
m_nbButtons = 0;
m_selRank = -1;
}
// Dessine un bouton dans son état.
void CMenu::Draw()
{
Sint32 i, state, icon;
POINT pos;
RECT oldClip, clipRect;
char text[50];
char* pText;
if ( m_nbButtons == 0 ) return;
oldClip = m_pPixmap->GetClipping();
clipRect.left = POSDRAWX;
clipRect.top = POSDRAWY;
clipRect.right = POSDRAWX+DIMDRAWX;
clipRect.bottom = POSDRAWY+DIMDRAWY;
m_pPixmap->SetClipping(clipRect);
for ( i=0 ; i<m_nbButtons ; i++ )
{
pos.x = m_pos.x+((i/m_nbCel.y)*(DIMBUTTONX+MARGMENU));
pos.y = m_pos.y+((i%m_nbCel.y)*(DIMBUTTONY+MARGMENU));
if ( i == m_selRank ) state = 2; // hilite
else state = 0; // release
if ( m_errors[i] != 0 &&
m_errors[i] != ERROR_TOURISOL &&
m_errors[i] < 100 )
{
state = 4; // disable
}
m_pPixmap->DrawIcon(-1, CHBUTTON, state, pos);
icon = table_button_icon[m_buttons[i]];
if ( m_perso == 8 ) // disciple ?
{
if ( icon == 30 ) icon = 88; // prend
if ( icon == 31 ) icon = 89; // dépose
}
m_pPixmap->DrawIcon(-1, CHBUTTON, icon+6, pos);
}
// Affiche le texte d'aide.
if ( m_selRank != -1 )
{
i = m_selRank;
pos.y = m_pos.y+((i%m_nbCel.y)*(DIMBUTTONY+MARGMENU));
if ( m_errors[i] == 0 )
{
pos.y += (DIMBUTTONY-DIMTEXTY)/2;
}
else
{
pos.y += (DIMBUTTONY-DIMTEXTY*2)/2;
}
if ( m_errors[i] >= 100 ) // no ressource au lieu erreur ?
{
snprintf (text, sizeof (text), m_texts[i]);
pText = strchr(text, '\n');
if ( pText != nullptr ) *pText = 0;
}
else
{
const auto tr = GetText(m_buttons[i]);
snprintf (text, sizeof (text), tr);
}
if ( m_nbCel.x > 1 && i < m_nbCel.y )
{
// if ( bLeft )
// {
pos.x = m_pos.x-4-GetTextWidth(text); // texte à gauche
// }
// else
// {
// pos.x = m_pos.x+((i/m_nbCel.y)+1)+(DIMBUTTONX+MARGMENU)+4;
// }
}
else
{
// if ( bRight )
// {
pos.x = m_pos.x+m_dim.x+4; // texte à droite
// }
// else
// {
// pos.x = m_pos.x+(i/m_nbCel.y)*(DIMBUTTONX+MARGMENU)-4-GetTextWidth(text);
// }
}
DrawText(m_pPixmap, pos, text, FONTWHITE);
if ( m_errors[i] != 0 )
{
if ( m_errors[i] >= 100 ) // no ressource au lieu erreur ?
{
snprintf (text, sizeof (text), m_texts[i]);
pText = strchr(text, '\n');
if ( pText != nullptr ) strcpy(text, pText+1);
}
else
{
const auto tr = GetErr (m_errors[i]-1); // impossible ici
snprintf (text, sizeof (text), tr);
}
if ( m_nbCel.x > 1 && i < m_nbCel.y )
{
// if ( bLeft )
// {
pos.x = m_pos.x-4-GetTextWidth(text); // texte à gauche
// }
// else
// {
// pos.x = m_pos.x+((i/m_nbCel.y)+1)+(DIMBUTTONX+MARGMENU)+4;
// }
}
else
{
// if ( bRight )
// {
pos.x = m_pos.x+m_dim.x+4; // texte à droite
// }
// else
// {
// pos.x = m_pos.x+(i/m_nbCel.y)*(DIMBUTTONX+MARGMENU)-4-GetTextWidth(text);
// }
}
pos.y += DIMTEXTY;
if ( m_errors[i] >= 100 ) // no ressource au lieu erreur ?
{
DrawText(m_pPixmap, pos, text, FONTWHITE);
}
else
{
DrawText(m_pPixmap, pos, text, FONTRED);
}
}
}
m_pPixmap->SetClipping(oldClip);
}
// Retourne le bouton sélectionné.
Sint32 CMenu::GetSel()
{
if ( m_selRank == -1 ) return -1;
return m_buttons[m_selRank];
}
// Retourne le rang sélectionné.
Sint32 CMenu::GetRank()
{
return m_selRank;
}
// Retourne true si le bouton sélectionné a une erreur.
bool CMenu::IsError()
{
if ( m_selRank == -1 ) return true;
if ( m_errors[m_selRank] != 0 &&
m_errors[m_selRank] < 100 ) return true;
return false;
}
// Indique si le menu existe.
bool CMenu::IsExist()
{
return ( m_nbButtons == 0 ) ? false:true;
}
// Traitement d'un événement.
bool CMenu::TreatEvent(const SDL_Event &event)
{
POINT pos;
if ( m_nbButtons == 0 ) return false;
//pos = ConvLongToPos(lParam);
switch (event.type)
{
case SDL_MOUSEBUTTONDOWN:
if ( event.button.button != SDL_BUTTON_LEFT
&& event.button.button != SDL_BUTTON_RIGHT)
break;
pos.x = event.button.x;
pos.y = event.button.y;
if ( MouseDown(pos) ) return true;
break;
case SDL_MOUSEMOTION:
pos.x = event.motion.x;
pos.y = event.motion.y;
if ( MouseMove(pos) ) return true;
break;
case SDL_MOUSEBUTTONUP:
if ( event.button.button != SDL_BUTTON_LEFT
&& event.button.button != SDL_BUTTON_RIGHT)
break;
pos.x = event.button.x;
pos.y = event.button.y;
if ( MouseUp(pos) ) return true;
break;
}
return false;
}
// Détecte dans quel bouton est la souris.
Sint32 CMenu::Detect(POINT pos)
{
Sint32 rank;
if ( pos.x < m_pos.x || pos.x > m_pos.x+m_dim.x ||
pos.y < m_pos.y || pos.y > m_pos.y+m_dim.y ) return -1;
rank = (pos.y-m_pos.y)/(DIMBUTTONY+MARGMENU);
rank += ((pos.x-m_pos.x)/(DIMBUTTONX+MARGMENU))*m_nbCel.y;
if ( rank >= m_nbButtons ) return -1;
return rank;
}
// Bouton de la souris pressé.
bool CMenu::MouseDown(POINT pos)
{
return false;
}
// Souris déplacés.
bool CMenu::MouseMove(POINT pos)
{
m_selRank = Detect(pos);
if ( pos.x < m_pos.x-(DIMBUTTONX+MARGMENU) ||
pos.x > m_pos.x+m_dim.x+(DIMBUTTONX+MARGMENU) ||
pos.y < m_pos.y-(DIMBUTTONY+MARGMENU) ||
pos.y > m_pos.y+m_dim.y+(DIMBUTTONY+MARGMENU) )
{
Delete(); // enlève le menu si souris trop loin !
}
return false;
}
// Bouton de la souris relâché.
bool CMenu::MouseUp(POINT pos)
{
m_selRank = Detect(pos);
return false;
}
// Envoie le message.
void CMenu::Message()
{
if ( m_selRank != -1 )
{
CEvent::PushUserEvent (WM_BUTTON0 + m_selRank);
}
}

View File

@ -1,54 +0,0 @@
// Menu.h
#pragma once
#include <unordered_map>
#include "def.h"
/////////////////////////////////////////////////////////////////////////////
class CMenu
{
public:
CMenu();
~CMenu();
bool Create(CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
std::unordered_map<Sint32, const char *> &texts,
Sint32 perso);
void Update(Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
std::unordered_map<Sint32, const char *> &texts);
void Delete();
void Draw();
Sint32 GetSel();
Sint32 GetRank();
bool IsError();
bool IsExist();
void Message();
bool TreatEvent(const SDL_Event &event);
protected:
Sint32 Detect(POINT pos);
bool MouseDown(POINT pos);
bool MouseMove(POINT pos);
bool MouseUp(POINT pos);
protected:
CPixmap* m_pPixmap;
CDecor* m_pDecor;
CSound* m_pSound;
POINT m_pos; // coin sup/gauche
POINT m_dim; // dimensions
Sint32 m_nbButtons;
POINT m_nbCel;
Sint32 m_perso;
Sint32 m_buttons[MAXBUTTON];
Sint32 m_errors[MAXBUTTON];
std::unordered_map<Sint32, const char *> m_texts;
Uint32 m_messages[MAXBUTTON];
Sint32 m_selRank;
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,121 +0,0 @@
// misc.cpp
//
#include <SDL2/SDL_log.h>
#include <SDL2/SDL_mouse.h>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <direct.h>
#define mkdir(a, b) _mkdir(a)
#else /* _WIN32 */
#include <sys/stat.h>
#endif /*! _WIN32 */
#include "misc.h"
#include "blupi.h"
#include "def.h"
// Variables globales
extern bool g_bFullScreen; // false si mode de test
extern Sint32 g_mouseType;
// Affiche un message de debug.
void OutputDebug(const char *pMessage)
{
SDL_LogDebug (SDL_LOG_CATEGORY_APPLICATION, "%s", pMessage);
}
// Conversion de la position de la souris.
POINT ConvLongToPos(LPARAM lParam)
{
POINT pos;
pos.x = LOWORD(lParam); // horizontal position of cursor
pos.y = HIWORD(lParam); // vertical position of cursor
// if ( !g_bFullScreen )
// {
// pos.y -= GetSystemMetrics(SM_CYCAPTION);
// }
return pos;
}
// R�initialise le g�n�rateur al�atoire.
void InitRandom()
{
srand(1);
}
// Retourne un nombre al�atoire compris entre
// deux bornes (inclues).
Sint32 Random(Sint32 min, Sint32 max)
{
Sint32 n;
n = rand();
n = min+(n%(max-min+1));
return (Sint32)n;
}
// Retourne le nom de dossier en cours.
std::string GetBaseDir ()
{
static std::string basePath;
if (!basePath.size ())
{
auto sdlBasePath = SDL_GetBasePath ();
sdlBasePath[strlen (sdlBasePath) - 1] = '\0';
basePath = sdlBasePath;
std::replace (basePath.begin (), basePath.end (), '\\', '/');
basePath = basePath.substr (0, basePath.find_last_of ("//") + 1);
SDL_free (sdlBasePath);
}
return basePath;
}
// Ajoute le chemin permettant de lire un fichier
// utilisateur.
void AddUserPath(char *pFilename)
{
char *temp;
char* pText;
size_t pos;
char last;
temp = SDL_GetPrefPath ("Epsitec SA", "Planet Blupi");
std::string path = temp;
pText = strstr(pFilename, "/");
if ( pText != nullptr )
{
pos = path.size () + (pText - pFilename) + 1;
path += pFilename;
last = path[pos];
path[pos] = 0;
mkdir (path.c_str (), 755);
path[pos] = last;
}
else
path += pFilename;
strcpy(pFilename, path.c_str ());
SDL_free (temp);
}

View File

@ -1,17 +0,0 @@
// misc.h
//
#pragma once
#include <string>
#include "blupi.h"
extern void OutputDebug(const char *pMessage);
extern POINT ConvLongToPos(LPARAM lParam);
extern void InitRandom();
extern Sint32 Random(Sint32 min, Sint32 max);
std::string GetBaseDir();
extern void AddUserPath(char *pFilename);

View File

@ -1,293 +0,0 @@
// movie.cpp
//
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "def.h"
#include "blupi.h"
#include "movie.h"
#include "misc.h"
#include "event.h"
#include "kitchensink/kitchensink.h"
//----------------------------------------------------------------------------
#define AVI_VIDEO "avivideo"
#define IDM_PLAY 10
//----------------------------------------------------------------------------
// Initialize avi libraries.
bool CMovie::initAVI()
{
// Initialize Kitchensink with network support and all formats.
Sint32 err = Kit_Init (KIT_INIT_FORMATS);
if (err != 0)
{
fprintf (stderr, "Unable to initialize Kitchensink: %s", Kit_GetError ());
return false;
}
return true;
}
// Closes the opened AVI file and the opened device type. |
void CMovie::termAVI()
{
Kit_Quit ();
}
// Close the movie and anything associated with it. |
// This function clears the <m_fPlaying> and <m_fMovieOpen> flags |
void CMovie::fileCloseMovie()
{
m_fPlaying = false; // can't be playing any longer
m_fMovieOpen = false; // no more movies open
if (m_videoTex)
{
SDL_DestroyTexture (m_videoTex);
m_videoTex = nullptr;
}
if (m_player)
{
SDL_CloseAudioDevice (m_audioDev);
Kit_ClosePlayer (m_player);
m_player = nullptr;
}
if (m_movie)
{
Kit_CloseSource (m_movie);
m_movie = nullptr;
}
}
// Open an AVI movie. Use CommDlg open box to
// open and then handle the initialization to
// show the movie and position it properly. Keep
// the movie paused when opened.
// Sets <m_fMovieOpen> on success.
bool CMovie::fileOpenMovie(RECT rect, const char *pFilename)
{
const auto path = GetBaseDir () + pFilename;
// we got a filename, now close any old movie and open the new one. */
if ( m_fMovieOpen ) fileCloseMovie();
// Open up the sourcefile.
// This can be a local file, network url, ...
m_movie = Kit_CreateSourceFromUrl (path.c_str ());
if (m_movie)
{
// Create the player
m_player = Kit_CreatePlayer (m_movie);
if (m_player == nullptr)
return false;
pinfo = new Kit_PlayerInfo;
Kit_GetPlayerInfo (m_player, pinfo);
SDL_AudioSpec wanted_spec, audio_spec;
SDL_memset (&wanted_spec, 0, sizeof (wanted_spec));
wanted_spec.freq = pinfo->audio.samplerate;
wanted_spec.format = pinfo->audio.format;
wanted_spec.channels = pinfo->audio.channels;
m_audioDev = SDL_OpenAudioDevice (nullptr, 0, &wanted_spec, &audio_spec, 0);
SDL_PauseAudioDevice (m_audioDev, 0);
m_videoTex = SDL_CreateTexture (
g_renderer,
pinfo->video.format,
SDL_TEXTUREACCESS_STATIC,
pinfo->video.width,
pinfo->video.height
);
if (m_videoTex == nullptr)
return false;
return true;
}
else
{
// generic error for open
m_fMovieOpen = false;
return false;
}
}
// Play/pause the movie depending on the state
void CMovie::playMovie()
{
m_fPlaying = !m_fPlaying; // swap the play flag
// play/pause the AVI movie
if (m_fPlaying)
{
SDL_RenderSetLogicalSize (g_renderer, pinfo->video.width, pinfo->video.height);
Kit_PlayerPlay (m_player);
}
else
Kit_PlayerPause (m_player);
}
//----------------------------------------------------------------------------
// Constructeur.
CMovie::CMovie()
{
m_bEnable = false;
m_fPlaying = false;
m_fMovieOpen = false;
m_movie = nullptr;
m_player = nullptr;
m_videoTex = nullptr;
pinfo = nullptr;
}
// Destructeur.
CMovie::~CMovie()
{
termAVI();
}
// Ouvre la librairie avi.
bool CMovie::Create()
{
if ( initAVI() )
{
m_bEnable = true;
return true;
}
else
{
m_bEnable = false;
return false;
}
}
// Retourne l'état de DirectMovie.
bool CMovie::GetEnable()
{
return m_bEnable;
}
// Indique si un film existe.
bool CMovie::IsExist(const char *pFilename)
{
const auto path = GetBaseDir () + pFilename;
FILE* file;
file = fopen(path.c_str (), "rb");
if ( file == nullptr ) return false;
fclose(file);
return true;
}
// Montre un film avi.
bool CMovie::Play(RECT rect, const char *pFilename)
{
if ( !m_bEnable ) return false;
if ( !fileOpenMovie(rect, pFilename) ) return false;
playMovie();
CEvent::PushUserEvent (WM_MOVIE_PLAY);
return true;
}
// Stoppe le film avi.
void CMovie::Stop()
{
if ( !m_bEnable ) return;
fileCloseMovie();
SDL_RenderSetLogicalSize (g_renderer, 0, 0);
}
void CMovie::Pause ()
{
if (!m_bEnable || !m_fPlaying)
return;
if (Kit_GetPlayerState (m_player) != KIT_PLAYING)
return;
Kit_PlayerPause (m_player);
}
void CMovie::Resume ()
{
if (!m_bEnable || !m_fPlaying)
return;
if (Kit_GetPlayerState (m_player) != KIT_PAUSED)
return;
Kit_PlayerPlay (m_player);
}
bool CMovie::Render ()
{
if (!m_bEnable || !m_fPlaying)
return false;
if (Kit_GetPlayerState (m_player) == KIT_STOPPED)
return false;
// Refresh audio
if (SDL_GetQueuedAudioSize (m_audioDev) < AUDIOBUFFER_SIZE)
{
Sint32 need = AUDIOBUFFER_SIZE - m_ret;
SDL_LockAudio ();
while (need > 0)
{
m_ret = Kit_GetAudioData (m_player, (unsigned char*) m_audiobuf,
AUDIOBUFFER_SIZE, (size_t) SDL_GetQueuedAudioSize (m_audioDev));
need -= m_ret;
if (m_ret > 0)
{
SDL_QueueAudio (m_audioDev, m_audiobuf, m_ret);
}
else
{
break;
}
}
SDL_UnlockAudio ();
SDL_PauseAudioDevice (m_audioDev, 0);
}
// Clear screen with black
SDL_SetRenderDrawColor (g_renderer, 0, 0, 0, 255);
SDL_RenderClear (g_renderer);
// Refresh videotexture and render it
Kit_GetVideoData (m_player, m_videoTex);
SDL_RenderCopy (g_renderer, m_videoTex, nullptr, nullptr);
SDL_RenderPresent (g_renderer);
CEvent::PushUserEvent (WM_MOVIE_PLAY);
return true;
}

View File

@ -1,48 +0,0 @@
// movie.h
//
#pragma once
struct Kit_Source;
struct Kit_Player;
struct Kit_PlayerInfo;
struct SDL_Texture;
#define AUDIOBUFFER_SIZE (32768)
class CMovie
{
public:
CMovie();
~CMovie();
bool Create();
bool GetEnable();
bool IsExist(const char *pFilename);
bool Play(RECT rect, const char *pFilename);
void Stop();
void Pause ();
void Resume ();
bool Render ();
protected:
void playMovie();
bool fileOpenMovie(RECT rect, const char *pFilename);
void fileCloseMovie();
void termAVI();
bool initAVI();
protected:
Kit_PlayerInfo *pinfo;
Kit_Source *m_movie;
Kit_Player *m_player;
SDL_Texture *m_videoTex;
Sint32 m_ret;
SDL_AudioDeviceID m_audioDev;
char m_audiobuf[AUDIOBUFFER_SIZE];
bool m_bEnable;
bool m_fPlaying; // Play flag: true == playing, false == paused
bool m_fMovieOpen; // Open flag: true == movie open, false = none
};

File diff suppressed because it is too large Load Diff

View File

@ -1,708 +0,0 @@
// CPixmap.cpp
//
#include <stdlib.h>
#include <stdio.h>
#include <string>
#ifdef _WIN32
#include <io.h>
#define access _access
#else /* _WIN32 */
#include <unistd.h>
#endif /* !_WIN32 */
#include "def.h"
#include "pixmap.h"
#include "misc.h"
#include "blupi.h"
/////////////////////////////////////////////////////////////////////////////
// Constructeur.
CPixmap::CPixmap()
{
Sint32 i;
m_bFullScreen = false;
m_mouseType = MOUSETYPEGRA;
m_bDebug = true;
m_bPalette = true;
m_mouseSprite = SPRITE_WAIT;
m_bBackDisplayed = false;
for (i = 0; i < MAXCURSORS; i++)
m_lpSDLCursors[i] = nullptr;
for ( i=0 ; i<MAXIMAGE ; i++ )
{
m_lpSDLTexture[i] = nullptr;
}
m_lpCurrentCursor = nullptr;
}
// Destructeur.
CPixmap::~CPixmap()
{
Sint32 i;
for (i = 0; i < MAXIMAGE; i++)
{
if (m_lpSDLCursors[i])
{
SDL_FreeCursor (m_lpSDLCursors[i]);
m_lpSDLCursors[i] = nullptr;
}
}
for ( i=0 ; i<MAXIMAGE ; i++ )
{
if ( m_lpSDLTexture[i] != nullptr )
{
SDL_DestroyTexture (m_lpSDLTexture[i]);
m_lpSDLTexture[i] = nullptr;
}
}
}
// Cr�e l'objet DirectDraw principal.
// Retourne false en cas d'erreur.
bool CPixmap::Create(POINT dim,
bool bFullScreen, Sint32 mouseType)
{
m_bFullScreen = bFullScreen;
m_mouseType = mouseType;
m_dim = dim;
m_clipRect.left = 0;
m_clipRect.top = 0;
m_clipRect.right = dim.x;
m_clipRect.bottom = dim.y;
return true;
}
// Lib�re les bitmaps.
bool CPixmap::Flush()
{
return true;
}
// Rempli une zone rectangulaire avec une couleur uniforme.
void CPixmap::Fill(RECT rect, COLORREF color)
{
// � faire si n�cessaire ...
}
// Effectue un appel BltFast.
// Les modes sont 0=transparent, 1=opaque.
Sint32 CPixmap::BltFast(Sint32 chDst, Sint32 channel, POINT dst, RECT rcRect)
{
Sint32 res, limit;
// Effectue un peu de clipping.
if ( dst.x < m_clipRect.left )
{
rcRect.left += m_clipRect.left-dst.x;
dst.x = m_clipRect.left;
}
limit = (m_clipRect.right-dst.x)+rcRect.left;
if ( rcRect.right > limit )
{
rcRect.right = limit;
}
if ( dst.y < m_clipRect.top )
{
rcRect.top += m_clipRect.top-dst.y;
dst.y = m_clipRect.top;
}
limit = (m_clipRect.bottom-dst.y)+rcRect.top;
if ( rcRect.bottom > limit )
{
rcRect.bottom = limit;
}
if ( rcRect.left >= rcRect.right ||
rcRect.top >= rcRect.bottom )
return 0;
if ( chDst < 0 )
{
SDL_Rect srcRect, dstRect;
srcRect.x = rcRect.left;
srcRect.y = rcRect.top;
srcRect.w = rcRect.right - rcRect.left;
srcRect.h = rcRect.bottom - rcRect.top;
dstRect = srcRect;
dstRect.x = dst.x;
dstRect.y = dst.y;
res = SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect);
}
else
{
SDL_Rect srcRect, dstRect;
srcRect.x = rcRect.left;
srcRect.y = rcRect.top;
srcRect.w = rcRect.right - rcRect.left;
srcRect.h = rcRect.bottom - rcRect.top;
dstRect = srcRect;
dstRect.x = dst.x;
dstRect.y = dst.y;
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[chDst]);
res = SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect);
SDL_SetRenderTarget (g_renderer, nullptr);
}
return res;
}
// Effectue un appel BltFast.
// Les modes sont 0=transparent, 1=opaque.
Sint32 CPixmap::BltFast(SDL_Texture *lpSDL, Sint32 channel, POINT dst, RECT rcRect)
{
Sint32 res;
SDL_Rect srcRect, dstRect;
srcRect.x = rcRect.left;
srcRect.y = rcRect.top;
srcRect.w = rcRect.right - rcRect.left;
srcRect.h = rcRect.bottom - rcRect.top;
dstRect = srcRect;
dstRect.x = dst.x;
dstRect.y = dst.y;
SDL_SetRenderTarget (g_renderer, lpSDL);
res = SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect);
SDL_SetRenderTarget (g_renderer, nullptr);
return res;
}
// Cache une image contenant des ic�nes.
bool CPixmap::Cache(Sint32 channel, const char *pFilename, POINT totalDim, POINT iconDim)
{
if ( channel < 0 || channel >= MAXIMAGE ) return false;
std::string file = GetBaseDir () + pFilename;
if (access ((file + ".bmp").c_str (), 0 /* F_OK */) != -1)
file += ".bmp";
SDL_Surface *surface = SDL_LoadBMP (file.c_str ());
if (channel == CHBLUPI)
m_lpSDLBlupi = surface;
SDL_Texture *texture = SDL_CreateTextureFromSurface (g_renderer, surface);
Uint32 format;
Sint32 access, w, h;
SDL_QueryTexture (texture, &format, &access, &w, &h);
if (!m_lpSDLTexture[channel])
{
m_lpSDLTexture[channel] = SDL_CreateTexture (g_renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, w, h);
SDL_SetTextureBlendMode (m_lpSDLTexture[channel], SDL_BLENDMODE_BLEND);
}
else
{
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[channel]);
SDL_SetRenderDrawColor (g_renderer, 0, 0, 0, 0);
SDL_RenderClear (g_renderer);
SDL_SetRenderTarget (g_renderer, nullptr);
}
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[channel]);
SDL_RenderCopy (g_renderer, texture, nullptr, nullptr);
SDL_SetRenderTarget (g_renderer, nullptr);
SDL_DestroyTexture (texture);
//m_lpSDLTexture[channel] = SDL_CreateTextureFromSurface (g_renderer, surface);
if (!m_lpSDLTexture[channel])
{
SDL_LogError (SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture from surface: %s", SDL_GetError ());
return false;
}
if (channel != CHBLUPI)
SDL_FreeSurface (surface);
strcpy(m_filename[channel], pFilename);
m_totalDim[channel] = totalDim;
m_iconDim[channel] = iconDim;
return true;
}
// Cache une image globale.
bool CPixmap::Cache(Sint32 channel, const char *pFilename, POINT totalDim)
{
POINT iconDim;
if ( channel < 0 || channel >= MAXIMAGE ) return false;
iconDim.x = 0;
iconDim.y = 0;
return Cache(channel, pFilename, totalDim, iconDim);
}
// Cache une image provenant d'un bitmap.
bool CPixmap::Cache(Sint32 channel, SDL_Surface *surface, POINT totalDim)
{
if ( channel < 0 || channel >= MAXIMAGE ) return false;
// Create the offscreen surface, by loading our bitmap.
if (m_lpSDLTexture[channel])
SDL_DestroyTexture (m_lpSDLTexture[channel]);
m_lpSDLTexture[channel] = SDL_CreateTextureFromSurface (g_renderer, surface);
if (!m_lpSDLTexture[channel])
return false;
m_totalDim[channel] = totalDim;
m_iconDim[channel] = totalDim;
return true;
}
// Modifie la r�gion de clipping.
void CPixmap::SetClipping(RECT clip)
{
m_clipRect = clip;
}
// Retourne la r�gion de clipping.
RECT CPixmap::GetClipping()
{
return m_clipRect;
}
// Teste si un point fait partie d'une ic�ne.
bool CPixmap::IsIconPixel(Sint32 channel, Sint32 rank, POINT pos)
{
Sint32 nbx, nby;
if ( channel < 0 || channel >= MAXIMAGE ) return false;
if (m_lpSDLTexture[channel] == nullptr ) return false;
if ( m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0 ) return false;
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / m_iconDim[channel].y;
if ( rank < 0 || rank >= nbx*nby ) return false;
pos.x += (rank % nbx) * m_iconDim[channel].x;
pos.y += (rank / nbx) * m_iconDim[channel].y;
SDL_Rect rect;
rect.x = pos.x;
rect.y = pos.y;
rect.w = 1;
rect.h = 1;
Uint32 pixel = 0;
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[channel]);
SDL_RenderReadPixels (g_renderer, &rect, 0, &pixel, 4);
SDL_SetRenderTarget (g_renderer, nullptr);
return !!pixel;
}
// Dessine une partie d'image rectangulaire.
// Les modes sont 0=transparent, 1=opaque.
bool CPixmap::DrawIcon(Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos, bool bMask)
{
Sint32 nbx, nby;
RECT rect;
if ( channel < 0 || channel >= MAXIMAGE ) return false;
if ( channel != CHMAP && m_lpSDLTexture[channel] == nullptr ) return false;
if ( m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0 ) return false;
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / m_iconDim[channel].y;
if ( rank < 0 || rank >= nbx*nby ) return false;
rect.left = (rank%nbx)*m_iconDim[channel].x;
rect.top = (rank/nbx)*m_iconDim[channel].y;
rect.right = rect.left + m_iconDim[channel].x;
rect.bottom = rect.top + m_iconDim[channel].y;
return !BltFast (chDst, channel, pos, rect);
}
// Dessine une partie d'image rectangulaire.
// Les modes sont 0=transparent, 1=opaque.
//
// Correspondances in,out :
// 0,0 2,1 ...
// 1,16 3,17
//
// 32,32 34,33
// 33,48 35,49
bool CPixmap::DrawIconDemi(Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos, bool bMask)
{
Sint32 nbx, nby;
RECT rect;
if ( channel < 0 || channel >= MAXIMAGE ) return false;
if (m_lpSDLTexture[channel] == nullptr ) return false;
if ( m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0 ) return false;
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / (m_iconDim[channel].y/2);
rank = (rank/32)*32+((rank%32)/2)+((rank%2)*16);
if ( rank < 0 || rank >= nbx*nby ) return false;
rect.left = (rank%nbx)* m_iconDim[channel].x;
rect.top = (rank/nbx)*(m_iconDim[channel].y/2);
rect.right = rect.left + m_iconDim[channel].x;
rect.bottom = rect.top +(m_iconDim[channel].y/2);
return !BltFast (chDst, channel, pos, rect);
}
// Dessine une partie d'image rectangulaire.
bool CPixmap::DrawIconPart(Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos,
Sint32 startY, Sint32 endY, bool bMask)
{
Sint32 nbx, nby;
RECT rect;
if ( channel < 0 || channel >= MAXIMAGE ) return false;
if (m_lpSDLTexture[channel] == nullptr ) return false;
if ( m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0 ) return false;
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / m_iconDim[channel].y;
if ( rank < 0 || rank >= nbx*nby ) return false;
rect.left = (rank%nbx)*m_iconDim[channel].x;
rect.top = (rank/nbx)*m_iconDim[channel].y;
rect.right = rect.left + m_iconDim[channel].x;
rect.bottom = rect.top + endY;
pos.y += startY;
rect.top += startY;
return !BltFast (chDst, channel, pos, rect);
}
// Dessine une partie d'image n'importe o�.
bool CPixmap::DrawPart(Sint32 chDst, Sint32 channel, POINT dest, RECT rect, bool bMask)
{
if ( channel < 0 || channel >= MAXIMAGE ) return false;
if (m_lpSDLTexture[channel] == nullptr ) return false;
return !BltFast (chDst, channel, dest, rect);
}
// Dessine une partie d'image rectangulaire.
bool CPixmap::DrawImage(Sint32 chDst, Sint32 channel, RECT rect)
{
POINT dst;
Sint32 res;
if ( channel < 0 || channel >= MAXIMAGE ) return false;
if (m_lpSDLTexture[channel] == nullptr ) return false;
dst.x = rect.left;
dst.y = rect.top;
res = BltFast(chDst, channel, dst, rect);
if (res)
return false;
if ( channel == CHBACK )
{
m_bBackDisplayed = false;
}
return true;
}
// Construit une ic�ne en utilisant un masque.
bool CPixmap::BuildIconMask(Sint32 channelMask, Sint32 rankMask,
Sint32 channel, Sint32 rankSrc, Sint32 rankDst)
{
Sint32 nbx, nby;
POINT posDst;
RECT rect;
Sint32 res;
if ( channel < 0 || channel >= MAXIMAGE ) return false;
if (m_lpSDLTexture[channel] == nullptr ) return false;
if ( m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0 ) return false;
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / m_iconDim[channel].y;
if ( rankSrc < 0 || rankSrc >= nbx*nby ) return false;
if ( rankDst < 0 || rankDst >= nbx*nby ) return false;
rect.left = (rankSrc%nbx)*m_iconDim[channel].x;
rect.top = (rankSrc/nbx)*m_iconDim[channel].y;
rect.right = rect.left + m_iconDim[channel].x;
rect.bottom = rect.top + m_iconDim[channel].y;
posDst.x = (rankDst%nbx)*m_iconDim[channel].x;
posDst.y = (rankDst/nbx)*m_iconDim[channel].y;
res = BltFast(m_lpSDLTexture[channel], channel, posDst, rect);
if (res)
return false;
if ( m_iconDim[channelMask].x == 0 ||
m_iconDim[channelMask].y == 0 ) return false;
nbx = m_totalDim[channelMask].x / m_iconDim[channelMask].x;
nby = m_totalDim[channelMask].y / m_iconDim[channelMask].y;
if ( rankMask < 0 || rankMask >= nbx*nby ) return false;
rect.left = (rankMask%nbx)*m_iconDim[channelMask].x;
rect.top = (rankMask/nbx)*m_iconDim[channelMask].y;
rect.right = rect.left + m_iconDim[channelMask].x;
rect.bottom = rect.top + m_iconDim[channelMask].y;
res = BltFast(m_lpSDLTexture[channel], channelMask, posDst, rect);
return !res;
}
// Affiche le pixmap � l'�cran.
// Retourne false en cas d'erreur.
bool CPixmap::Display()
{
m_bBackDisplayed = true;
SDL_RenderPresent (g_renderer);
return true;
}
// Change le lutin de la souris.
void CPixmap::SetMouseSprite(Sint32 sprite, bool bDemoPlay)
{
if ( m_mouseSprite == sprite ) return;
m_mouseSprite = sprite;
SDL_SetCursor (m_lpSDLCursors[sprite - 1]);
}
// Montre ou cache la souris.
void CPixmap::MouseShow(bool bShow)
{
SDL_ShowCursor (bShow);
}
// Retourne le rectangle correspondant au sprite
// de la souris dans CHBLUPI.
RECT CPixmap::MouseRectSprite()
{
Sint32 rank, nbx;
RECT rcRect;
rank = 348;
if ( m_mouseSprite == SPRITE_ARROW ) rank = 348;
if ( m_mouseSprite == SPRITE_POINTER ) rank = 349;
if ( m_mouseSprite == SPRITE_MAP ) rank = 350;
if ( m_mouseSprite == SPRITE_WAIT ) rank = 351;
if ( m_mouseSprite == SPRITE_FILL ) rank = 352;
if ( m_mouseSprite == SPRITE_ARROWL ) rank = 353;
if ( m_mouseSprite == SPRITE_ARROWR ) rank = 354;
if ( m_mouseSprite == SPRITE_ARROWU ) rank = 355;
if ( m_mouseSprite == SPRITE_ARROWD ) rank = 356;
if ( m_mouseSprite == SPRITE_ARROWDL ) rank = 357;
if ( m_mouseSprite == SPRITE_ARROWDR ) rank = 358;
if ( m_mouseSprite == SPRITE_ARROWUL ) rank = 359;
if ( m_mouseSprite == SPRITE_ARROWUR ) rank = 360;
nbx = m_totalDim[CHBLUPI].x / m_iconDim[CHBLUPI].x;
rcRect.left = (rank%nbx)*m_iconDim[CHBLUPI].x;
rcRect.top = (rank/nbx)*m_iconDim[CHBLUPI].y;
rcRect.right = rcRect.left+m_iconDim[CHBLUPI].x;
rcRect.bottom = rcRect.top +m_iconDim[CHBLUPI].y;
return rcRect;
}
SDL_Point CPixmap::GetCursorHotSpot (Sint32 sprite)
{
static const Sint32 hotspots[MAXCURSORS * 2] =
{
30, 30, // SPRITE_ARROW
20, 15, // SPRITE_POINTER
31, 26, // SPRITE_MAP
25, 14, // SPRITE_ARROWU
24, 35, // SPRITE_ARROWD
15, 24, // SPRITE_ARROWL
35, 24, // SPRITE_ARROWR
18, 16, // SPRITE_ARROWUL
32, 18, // SPRITE_ARROWUR
17, 30, // SPRITE_ARROWDL
32, 32, // SPRITE_ARROWDR
30, 30, // SPRITE_WAIT
30, 30, // SPRITE_EMPTY
21, 51, // SPRITE_FILL
};
SDL_Point hotspot = { 0, 0 };
if (sprite >= SPRITE_BEGIN && sprite <= SPRITE_END)
{
const Sint32 rank = sprite - SPRITE_BEGIN; // rank <- 0..n
hotspot.x = hotspots[rank * 2 + 0];
hotspot.y = hotspots[rank * 2 + 1];
}
return hotspot;
}
SDL_Rect CPixmap::GetCursorRect (Sint32 sprite)
{
Sint32 rank;
SDL_Rect rcRect;
switch (sprite)
{
default:
case SPRITE_ARROW:
rank = 348;
break;
case SPRITE_POINTER:
rank = 349;
break;
case SPRITE_MAP:
rank = 350;
break;
case SPRITE_WAIT:
rank = 351;
break;
case SPRITE_FILL:
rank = 352;
break;
case SPRITE_ARROWL:
rank = 353;
break;
case SPRITE_ARROWR:
rank = 354;
break;
case SPRITE_ARROWU:
rank = 355;
break;
case SPRITE_ARROWD:
rank = 356;
break;
case SPRITE_ARROWDL:
rank = 357;
break;
case SPRITE_ARROWDR:
rank = 358;
break;
case SPRITE_ARROWUL:
rank = 359;
break;
case SPRITE_ARROWUR:
rank = 360;
break;
}
Sint32 nbx = m_totalDim[CHBLUPI].x / m_iconDim[CHBLUPI].x;
rcRect.x = (rank % nbx) * m_iconDim[CHBLUPI].x;
rcRect.y = (rank / nbx) * m_iconDim[CHBLUPI].y;
rcRect.w = m_iconDim[CHBLUPI].x;
rcRect.h = m_iconDim[CHBLUPI].y;
return rcRect;
}
void CPixmap::LoadCursors ()
{
Uint32 rmask, gmask, bmask, amask;
/* SDL interprets each pixel as a 32-bit number, so our masks must depend
on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
for (Sint32 sprite = SPRITE_BEGIN; sprite <= SPRITE_END; ++sprite)
{
SDL_Point hotspot = this->GetCursorHotSpot (sprite);
SDL_Rect rect = this->GetCursorRect (sprite);
SDL_Surface *surface = SDL_CreateRGBSurface (0, rect.w, rect.h, 32, rmask, gmask, bmask, amask);
SDL_BlitSurface (m_lpSDLBlupi, &rect, surface, nullptr);
// FIXME: change cursor first value to 0
m_lpSDLCursors[sprite - 1] = SDL_CreateColorCursor (surface, hotspot.x, hotspot.y);
}
}
void CPixmap::ChangeSprite (MouseSprites sprite)
{
if (m_lpCurrentCursor == m_lpSDLCursors[sprite - 1])
return;
SDL_SetCursor (m_lpSDLCursors[sprite - 1]);
m_lpCurrentCursor = m_lpSDLCursors[sprite - 1];
}

View File

@ -1,76 +0,0 @@
// CPixmap.h
#pragma once
#include <SDL2/SDL.h>
#include "blupi.h"
#define MAXIMAGE 100
#define MAXCURSORS 14
class CPixmap
{
public:
CPixmap();
~CPixmap();
bool Create(POINT dim, bool bFullScreen, Sint32 mouseType);
bool Flush();
void Fill(RECT rect, COLORREF color);
bool Cache(Sint32 channel, const char *pFilename, POINT totalDim, POINT iconDim);
bool Cache(Sint32 channel, const char *pFilename, POINT totalDim);
bool Cache(Sint32 channel, SDL_Surface *surface, POINT totalDim);
void SetClipping(RECT clip);
RECT GetClipping();
bool IsIconPixel(Sint32 channel, Sint32 rank, POINT pos);
bool DrawIcon(Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos, bool bMask=false);
bool DrawIconDemi(Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos, bool bMask=false);
bool DrawIconPart(Sint32 chDst, Sint32 channel, Sint32 rank, POINT pos, Sint32 startY, Sint32 endY, bool bMask=false);
bool DrawPart(Sint32 chDst, Sint32 channel, POINT dest, RECT rect, bool bMask=false);
bool DrawImage(Sint32 chDst, Sint32 channel, RECT rect);
bool BuildIconMask(Sint32 channelMask, Sint32 rankMask,
Sint32 channel, Sint32 rankSrc, Sint32 rankDst);
bool Display();
void SetMouseSprite(Sint32 sprite, bool bDemoPlay);
void MouseShow(bool bShow);
void LoadCursors ();
void ChangeSprite (MouseSprites sprite);
protected:
Sint32 BltFast(Sint32 chDst, Sint32 channel, POINT dst, RECT rcRect);
Sint32 BltFast(SDL_Texture *lpSDL, Sint32 channel, POINT dst, RECT rcRect);
RECT MouseRectSprite();
SDL_Point GetCursorHotSpot (Sint32 sprite);
SDL_Rect GetCursorRect (Sint32 sprite);
protected:
bool m_bFullScreen;
Sint32 m_mouseType;
bool m_bDebug;
bool m_bPalette;
POINT m_dim; // dimensions totales
RECT m_clipRect; // rectangle de clipping
Sint32 m_mouseSprite;
bool m_bBackDisplayed;
SDL_Cursor * m_lpCurrentCursor;
SDL_Cursor * m_lpSDLCursors[MAXCURSORS];
SDL_Surface * m_lpSDLBlupi;
SDL_Texture * m_lpSDLTexture[MAXIMAGE];
COLORREF m_colorSurface[2*MAXIMAGE];
char m_filename[MAXIMAGE][20];
POINT m_totalDim[MAXIMAGE]; // dimensions totale image
POINT m_iconDim[MAXIMAGE]; // dimensions d'une ic�ne
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,278 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by blupi-e.rc
//
#define TX_ACTION_GO 1
#define TX_ACTION_STOP 2
#define TX_ACTION_MANGE 3
#define TX_ACTION_CARRY 4
#define TX_ACTION_DEPOSE 5
#define TX_ACTION_ABAT 6
#define TX_ACTION_ROC 7
#define TX_ACTION_CULTIVE 8
#define TX_ACTION_BUILD1 9
#define TX_ACTION_BUILD2 10
#define TX_ACTION_BUILD3 11
#define TX_ACTION_BUILD4 12
#define TX_ACTION_BUILD5 13
#define TX_ACTION_BUILD6 14
#define TX_ACTION_MUR 15
#define TX_ACTION_PALIS 16
#define TX_ACTION_ABATn 17
#define TX_ACTION_ROCn 18
#define TX_ACTION_PONT 19
#define TX_ACTION_TOUR 20
#define TX_ACTION_BOIT 21
#define TX_ACTION_LABO 22
#define TX_ACTION_FLEUR 23
#define TX_ACTION_FLEURn 24
#define TX_ACTION_DYNAMITE 25
#define TX_ACTION_BATEAU 26
#define TX_ACTION_DJEEP 27
#define TX_ACTION_DRAPEAU 28
#define TX_ACTION_EXTRAIT 29
#define TX_ACTION_FABJEEP 30
#define TX_ACTION_FABMINE 31
#define TX_ACTION_FABDISC 32
#define TX_ACTION_REPEAT 33
#define TX_ACTION_QARMURE 34
#define TX_ACTION_FABARMURE 35
#define TX_IONAMEEX 100
#define TX_IOFREE 101
#define IDR_MENU 102
#define TX_TERMMIN 102
#define TX_TERMMAX 103
#define TX_BUTTON_JOUER 104
#define TX_BUTTON_APPRENDRE 105
#define TX_BUTTON_QUITTER 106
#define TX_BUTTON_PREVP 107
#define TX_BUTTON_NEXTP 108
#define TX_BUTTON_PLAYP 109
#define TX_BUTTON_BUILDP 110
#define TX_BUTTON_TERM 111
#define TX_BUTTON_READP 112
#define TX_BUTTON_WRITEP 113
#define TX_BUTTON_CANCELP 114
#define TX_BUTTON_CONTP 115
#define TX_BUTTON_REPEAT 116
#define TX_BUTTON_BUTTON 117
#define TX_BUTTON_CTERM 118
#define TX_BUTTON_TERMC 119
#define TX_BUTTON_TERMHBLUPI 120
#define TX_BUTTON_TERMHPLANCHE 121
#define TX_BUTTON_TERMFIRE 122
#define TX_BUTTON_TERMDEC 123
#define TX_BUTTON_TERMINC 124
#define TX_PAUSE 125
#define TX_JAUGE1 126
#define TX_JAUGE2 127
#define TX_BUTTON_SETUP 128
#define TX_BUTTON_MUSIC 129
#define TX_BUTTON_SETUP1 130
#define TX_BUTTON_SETUP2 131
#define TX_BUTTON_SETUP3 132
#define TX_BUTTON_SETUP4 133
#define TX_BUTTON_MUSIC1 134
#define TX_BUTTON_MUSIC2 135
#define TX_BUTTON_MUSIC3 136
#define TX_BUTTON_MUSIC4 137
#define TX_BUTTON_MUSIC5 138
#define TX_BUTTON_MUSIC6 139
#define TX_BUTTON_MUSIC7 140
#define TX_BUTTON_MUSIC8 141
#define TX_BUTTON_MUSIC9 142
#define TX_BUTTON_MUSIC10 143
#define TX_BUTTON_REGION 144
#define TX_BUTTON_TERMMBLUPI 145
#define TX_BUTTON_TERMKILL 146
#define TX_TERM 147
#define TX_BUTTON 148
#define TX_MUSIC 149
#define TX_SCHOOL 150
#define TX_MISSION 151
#define TX_IONAMEMI 152
#define TX_BUTTON_TERMHTOMATE 153
#define TX_BUTTON_SETUP5 154
#define TX_BUTTON_SETUP6 155
#define TX_BUTTON_SETUP7 156
#define TX_BUTTON_SETUP8 157
#define TX_OUI 158
#define TX_NON 159
#define TX_BUTTON_SETUP9 160
#define TX_BUTTON_SETUP10 161
#define TX_INFO_SETUP1 162
#define TX_INFO_SETUP2 163
#define TX_INFO_SETUP3 164
#define TX_INFO_SETUP4 165
#define TX_INFO_SETUP5 166
#define TX_INFO_SETUP6 167
#define TX_INFO_SETUP7 168
#define TX_INFO_SETUP8 169
#define TX_INFO_SETUP9 170
#define TX_INFO_SETUP10 171
#define TX_INFO_SETUP10b 172
#define TX_INFO_NOSCROLL 173
#define TX_BUTTON_REGION1 174
#define TX_BUTTON_REGION2 175
#define TX_BUTTON_REGION3 176
#define TX_BUTTON_REGION4 177
#define TX_REGION 178
#define TX_BUTTON_PLAY_STOP 179
#define TX_BUTTON_PLAY_SETUP 180
#define TX_BUTTON_PLAY_WRITE 181
#define TX_INSERT 182
#define TX_BUTTON_PREVH 183
#define TX_BUTTON_NEXTH 184
#define TX_BUTTON_TERMHMETAL 185
#define TX_BUTTON_HELP 186
#define TX_HELP 187
#define TX_BUTTON_PRIVE 188
#define TX_PRIVATE 189
#define TX_IONAMEPR 190
#define TX_PRIVATE_HACHBLUPI 191
#define TX_PRIVATE_HACHPLANCHE 192
#define TX_PRIVATE_HACHTOMATE 193
#define TX_PRIVATE_HACHMETAL 194
#define TX_PRIVATE_STOPFIRE 195
#define TX_PRIVATE_HOMEBLUPI 196
#define TX_PRIVATE_KILLROBOTS 197
#define TX_BUTTON_UNDO 198
#define TX_FULL_END1 203
#define TX_FULL_END2 204
#define TX_FULL_END3 205
#define TX_FULL_END4 206
#define TX_PRIVATE_OBJECTIF 207
#define TX_PRIVATE_NBBLUPI 208
#define TX_BUTTON_SKILL 209
#define TX_SKILL1 210
#define TX_SKILL2 211
#define TX_BUTTON_DEMO 212
#define TX_DEMOREC 213
#define TX_DEMOPLAY 214
#define TX_BUTTON_TERMHROBOT 215
#define TX_PRIVATE_HACHROBOT 216
#define TX_REPEAT_CULTIVE 500
#define TX_REPEAT_FLEUR 501
#define TX_REPEAT_FLEURQ 502
#define TX_REPEAT_FABMINE 503
#define TX_REPEAT_FABJEEP 504
#define TX_REPEAT_PALIS 505
#define TX_REPEAT_PALISQ 506
#define TX_REPEAT_PONT 507
#define TX_REPEAT_PONTQ 508
#define TX_REPEAT_BATEAU 509
#define TX_REPEAT_BATEAUQ 510
#define TX_REPEAT_FABARMURE 511
#define TX_DIRECT_N 512
#define TX_DIRECT_S 513
#define TX_DIRECT_E 514
#define TX_DIRECT_O 515
#define IDR_WAVE_BOING 1000
#define TX_ERROR_MISC 1000
#define IDR_WAVE_BLOW 1001
#define TX_ERROR_GROUND 1001
#define TX_ERROR_FREE 1002
#define TX_ERROR_PONTOP 1003
#define TX_ERROR_PONTTERM 1004
#define TX_ERROR_TOURISOL 1005
#define TX_ERROR_TOUREAU 1006
#define TX_ERROR_TELE2 1007
#define TX_OBJ_BLUPIm 2000
#define TX_OBJ_BLUPIf 2001
#define TX_OBJ_BLUPI 2002
#define TX_OBJ_BATEAU 2003
#define TX_OBJ_JEEP 2004
#define TX_OBJ_PIEGE 2005
#define TX_OBJ_POISON 2006
#define TX_OBJ_DYNAMITE 2007
#define TX_OBJ_MINE 2008
#define TX_OBJ_TOMATE 2009
#define TX_OBJ_POTION 2010
#define TX_OBJ_PLANCHE 2011
#define TX_OBJ_PIERRE 2012
#define TX_OBJ_DRAPEAU 2013
#define TX_OBJ_FER 2014
#define TX_OBJ_FLEUR1 2015
#define TX_OBJ_FLEUR2 2016
#define TX_OBJ_FLEUR3 2017
#define TX_OBJ_CABANE 2018
#define TX_OBJ_LABO 2019
#define TX_OBJ_MINEFER 2020
#define TX_OBJ_USINE 2021
#define TX_OBJ_TOUR 2022
#define TX_OBJ_FEU 2023
#define TX_OBJ_ROBOT 2024
#define TX_OBJ_TRACKS 2025
#define TX_OBJ_BOMBE 2026
#define TX_OBJ_ARAIGNEE 2027
#define TX_OBJ_VIRUS 2028
#define TX_OBJ_ELECTRO 2029
#define TX_OBJ_ARBRE 2030
#define TX_OBJ_MUR 2031
#define TX_OBJ_ARBREb 2032
#define TX_OBJ_ROC 2033
#define TX_OBJ_OEUF 2034
#define TX_OBJ_PALISSADE 2035
#define TX_OBJ_ENNEMIp 2036
#define TX_OBJ_ENNEMI 2037
#define TX_OBJ_HERBE 2038
#define TX_OBJ_MOUSSE 2039
#define TX_OBJ_TERRE 2040
#define TX_OBJ_EAU 2041
#define TX_OBJ_RIVE 2042
#define TX_OBJ_MIXTE 2043
#define TX_OBJ_PONT 2044
#define TX_OBJ_COUVEUSE 2045
#define TX_OBJ_GLACE 2046
#define TX_OBJ_MAISON 2047
#define TX_OBJ_HACHURE 2048
#define TX_OBJ_MOUSSEb 2049
#define TX_OBJ_BOUQUET1 2050
#define TX_OBJ_BOUQUET2 2051
#define TX_OBJ_BOUQUET3 2052
#define TX_OBJ_DALLE 2053
#define TX_OBJ_ENNEMIs 2054
#define TX_OBJ_DISCIPLE 2055
#define TX_OBJ_METAL 2056
#define TX_OBJ_FUSEE 2057
#define TX_OBJ_TELEPORTE 2058
#define TX_OBJ_ARMURE 2059
#define TX_OBJ_DALLESPEC 2060
#define TX_OBJ_COUVTELE 2061
#define TX_OBJ_BATIMENT 2062
#define TX_OBJ_BATENNEMIS 2063
#define TX_OBJ_MURPAL 2064
#define TX_OBJ_OBJET 2065
#define TX_OBJ_ARME 2066
#define TX_OBJ_VEHICULE 2067
#define TX_OBJ_STARTFEU 2068
#define TX_OBJ_DELOBJ 2069
#define TX_OBJ_DELPERSO 2070
#define TX_OBJ_DELFEU 2071
#define TX_OBJ_PLANTE 2072
#define TX_OBJ_BARENNEMIS 2073
#define TX_WIN1 3000
#define TX_WIN2 3001
#define TX_WIN3 3002
#define TX_WIN4 3003
#define TX_WIN5 3004
#define TX_LOST1 3100
#define TX_LOST2 3101
#define TX_LOST3 3102
#define TX_LOST4 3103
#define TX_LOST5 3104
#define TX_LASTWIN1 3200
#define TX_LASTWIN2 3201
#define TX_LASTWIN3 3202
#define IDM_EXIT 40001
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 109
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,366 +0,0 @@
// sound.cpp
//
#include <stdio.h>
#include "sound.h"
#include "event.h"
#include "misc.h"
#include "def.h"
#include "resource.h"
// Stops all sounds.
bool CSound::StopAllSounds()
{
for (Sint32 i = 0; i < MAXSOUND; i ++)
{
if (!m_lpSDL[i])
continue;
if (Mix_Playing (i + 1) == SDL_TRUE)
Mix_FadeOutChannel (i + 1, 500);
}
return true;
}
CSound::CSound()
{
Sint32 i;
m_bEnable = false;
m_bState = false;
m_MIDIFilename[0] = 0;
m_audioVolume = 20;
m_midiVolume = 15;
m_lastMidiVolume = 0;
m_nbSuspendSkip = 0;
m_pMusic = nullptr;
m_bStopped = false;
for ( i=0 ; i<MAXBLUPI ; i++ )
{
m_channelBlupi[i] = -1;
}
memset (m_lpSDL, 0, sizeof (m_lpSDL));
}
// Destructeur.
CSound::~CSound()
{
Sint32 i;
for ( i=0 ; i<MAXSOUND ; i++ )
{
if (!m_lpSDL[i])
continue;
Mix_FreeChunk (m_lpSDL[i]);
m_lpSDL[i] = nullptr;
}
}
// Initialisation de DirectSound.
bool CSound::Create()
{
m_bEnable = true;
if (Mix_OpenAudio (44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096) == -1)
return false;
Mix_AllocateChannels (MAXSOUND);
Mix_HookMusicFinished ([] ()
{
CEvent::PushUserEvent (WM_MUSIC_STOP);
});
return true;
}
// Retourne l'�tat de DirectSound.
bool CSound::GetEnable()
{
return m_bEnable;
}
// Enclenche ou d�clenche le son.
void CSound::SetState(bool bState)
{
m_bState = bState;
}
// Gestion des volumes audio (.wav) et midi (.mid).
void CSound::SetAudioVolume(Sint32 volume)
{
m_audioVolume = volume;
}
Sint32 CSound::GetAudioVolume()
{
if ( !m_bEnable ) return 0;
return m_audioVolume;
}
void CSound::SetMidiVolume(Sint32 volume)
{
m_midiVolume = volume;
}
Sint32 CSound::GetMidiVolume()
{
if ( !m_bEnable ) return 0;
return m_midiVolume;
}
// Cache tous les ficheirs son (.wav).
void CSound::CacheAll()
{
Sint32 i;
char name[50];
if ( !m_bEnable ) return;
for ( i=0 ; i<MAXSOUND ; i++ )
{
sprintf(name, "sound/sound%.3d.blp", i);
if ( !Cache(i, name) ) break;
}
}
// Charge un fichier son (.wav).
bool CSound::Cache(Sint32 channel, const char *pFilename)
{
if ( !m_bEnable ) return false;
if ( channel < 0 || channel >= MAXSOUND ) return false;
if (m_lpSDL[channel])
Flush(channel);
const auto file = GetBaseDir () + pFilename;
m_lpSDL[channel] = Mix_LoadWAV (file.c_str ());
if (!m_lpSDL[channel])
{
SDL_Log ("Mix_LoadWAV: %s\n", Mix_GetError ());
return false;
}
return true;
}
// D�charge un son.
void CSound::Flush(Sint32 channel)
{
if ( !m_bEnable ) return;
if ( channel < 0 || channel >= MAXSOUND ) return;
if (m_lpSDL[channel])
{
Mix_FreeChunk (m_lpSDL[channel]);
m_lpSDL[channel] = nullptr;
}
}
// Fait entendre un son.
// Le volume est compris entre 128 (max) et 0 (silence).
// Le panoramique est compris entre 255,0 (gauche), 127,128 (centre)
// et 0,255 (droite).
bool CSound::Play(Sint32 channel, Sint32 volume, Uint8 panLeft, Uint8 panRight)
{
if (!m_bEnable)
return true;
if (!m_bState || !m_audioVolume)
return true;
if (channel < 0 || channel >= MAXSOUND)
return false;
Mix_SetPanning (channel + 1, panLeft, panRight);
volume = volume * 100 * m_audioVolume / 20 / 100;
Mix_Volume (channel + 1, volume);
if (Mix_Playing (channel + 1) == SDL_FALSE)
Mix_PlayChannel (channel + 1, m_lpSDL[channel], 0);
return true;
}
// Fait entendre un son dans une image.
// 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)
{
Sint32 stopCh, volumex, volumey, volume;
if ( rank >= 0 && rank < MAXBLUPI )
{
stopCh = m_channelBlupi[rank];
if ( stopCh >= 0 && m_lpSDL[stopCh] != nullptr )
Mix_FadeOutChannel (stopCh + 1, 500);
m_channelBlupi[rank] = channel;
}
Uint8 panRight, panLeft;
volumex = MIX_MAX_VOLUME;
volumey = MIX_MAX_VOLUME;
if (pos.x < 0)
{
panRight = 0;
panLeft = 255;
volumex += pos.x;
if (volumex < 0)
volumex = 0;
}
else if (pos.x > LXIMAGE)
{
panRight = 255;
panLeft = 0;
volumex -= pos.x - LXIMAGE;
if (volumex < 0)
volumex = 0;
}
else
{
panRight = 255 * static_cast<Uint16> (pos.x) / LXIMAGE;
panLeft = 255 - panRight;
}
if (pos.y < 0)
{
volumey += pos.y;
if (volumey < 0)
volumey = 0;
}
else if (pos.y > LYIMAGE)
{
volumey -= pos.y - LYIMAGE;
if (volumey < 0)
volumey = 0;
}
volume = volumex < volumey ? volumex : volumey;
return Play(channel, volume, panLeft, panRight);
}
// Uses MCI to play a MIDI file. The window procedure
// is notified when playback is complete.
bool CSound::PlayMusic(const char *lpszMIDIFilename)
{
std::string path = GetBaseDir ();
if ( !m_bEnable ) return true;
if ( m_midiVolume == 0 ) return true;
Mix_VolumeMusic (MIX_MAX_VOLUME * 100 * m_midiVolume / 20 / 100);
m_lastMidiVolume = m_midiVolume;
path += lpszMIDIFilename;
m_pMusic = Mix_LoadMUS (path.c_str ());
if (!m_pMusic)
{
printf ("%s\n", Mix_GetError ());
return false;
}
if (Mix_PlayMusic (m_pMusic, 0) == -1)
{
printf ("%s\n", Mix_GetError ());
return false;
}
m_bStopped = false;
strcpy(m_MIDIFilename, lpszMIDIFilename);
return true;
}
// Restart the MIDI player.
bool CSound::RestartMusic()
{
OutputDebug("RestartMusic\n");
if ( !m_bEnable ) return true;
if ( m_midiVolume == 0 ) return true;
if ( m_MIDIFilename[0] == 0 ) return false;
return PlayMusic(m_MIDIFilename);
}
// Shuts down the MIDI player.
void CSound::SuspendMusic()
{
if ( !m_bEnable ) return;
if ( m_nbSuspendSkip != 0 )
{
m_nbSuspendSkip --;
return;
}
m_bStopped = true;
Mix_HaltMusic ();
}
// Shuts down the MIDI player.
void CSound::StopMusic()
{
SuspendMusic();
m_MIDIFilename[0] = 0;
}
// Retourne true si une musique est en cours.
bool CSound::IsPlayingMusic()
{
return (m_MIDIFilename[0] != 0);
}
bool CSound::IsStoppedOnDemand ()
{
return m_bStopped;
}
// Adapte le volume de la musique en cours, si n�cessaire.
void CSound::AdaptVolumeMusic()
{
if (m_midiVolume != m_lastMidiVolume)
{
Mix_VolumeMusic (MIX_MAX_VOLUME * 100 * m_midiVolume / 20 / 100);
m_lastMidiVolume = m_midiVolume;
}
}
// Indique le nombre de suspend � sauter.
void CSound::SetSuspendSkip(Sint32 nb)
{
m_nbSuspendSkip = nb;
}

View File

@ -1,61 +0,0 @@
// sound.h
//
#pragma once
#include <stdio.h>
#include <SDL2/SDL_mixer.h>
#include "blupi.h"
/////////////////////////////////////////////////////////////////////////////
#define MAXSOUND 100
#define MAXVOLUME 20
#define MAXBLUPI 100
class CSound
{
public:
CSound();
~CSound();
bool Create();
void SetState(bool bState);
bool GetEnable();
void SetAudioVolume(Sint32 volume);
Sint32 GetAudioVolume();
void SetMidiVolume(Sint32 volume);
Sint32 GetMidiVolume();
void CacheAll();
bool Cache(Sint32 channel, const char *pFilename);
void Flush(Sint32 channel);
bool Play(Sint32 channel, Sint32 volume=0, Uint8 panLeft = 255, Uint8 panRight = 255);
bool PlayImage(Sint32 channel, POINT pos, Sint32 rank=-1);
bool PlayMusic(const char *lpszMIDIFilename);
bool RestartMusic();
void SuspendMusic();
void StopMusic();
bool IsPlayingMusic();
bool IsStoppedOnDemand ();
void AdaptVolumeMusic();
void SetSuspendSkip(Sint32 nb);
bool StopAllSounds();
protected:
bool m_bEnable;
bool m_bState;
bool m_bStopped;
Mix_Music *m_pMusic;
Mix_Chunk *m_lpSDL[MAXSOUND];
Sint16 m_channelBlupi[MAXBLUPI];
char m_MIDIFilename[50];
Sint32 m_audioVolume;
Sint32 m_midiVolume;
Sint32 m_lastMidiVolume;
Sint32 m_nbSuspendSkip;
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,344 +0,0 @@
// Text.cpp
#include <stdlib.h>
#include <stdio.h>
#include "def.h"
#include "pixmap.h"
#include "text.h"
/////////////////////////////////////////////////////////////////////////////
// Retourne l'offset pour un caractère donné.
Sint32 GetOffset(char c)
{
Sint32 i;
static unsigned char table_accents[15] =
{
0xFC, 0xE0, 0xE2, 0xE9, 0xE8, 0xEB, 0xEA, 0xEF,
0xEE, 0xF4, 0xF9, 0xFB, 0xE4, 0xF6, 0xE7
};
for ( i=0 ; i<15 ; i++ )
{
if ( (unsigned char)c == table_accents[i] )
{
return 15+i;
}
}
if ( c<0 || c>128 ) return 1; // carré
return c;
}
// Retourne la longueur d'un caractère.
Sint32 GetCharWidth(char c, Sint32 font)
{
static unsigned char table_width[128] =
{
9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,8,
9,9,8,8,8,8,5,5,8,8,8,9,8,8,10,10,
5,6,9,13,11,12,12,6,6,6,12,12,5,9,6,9,
8,8,9,9,8,9,8,8,9,9,6,6,8,9,10,11,
12,8,9,9,9,8,8,8,9,4,8,9,8,10,9,9,
8,9,8,9,10,8,9,11,9,8,10,7,10,7,13,13,
9,9,8,8,8,8,6,8,8,4,6,8,4,12,8,8,
8,8,7,6,7,8,8,10,8,8,7,6,6,6,10,0,
};
static unsigned char table_width_little[128] =
{
6,6,6,6,6,6,6,6,6,6,6,6,5,6,6,7,
6,6,6,6,6,6,3,3,6,6,6,6,6,6,5,5,
3,3,5,8,5,11,9,3,4,4,6,6,3,4,3,6,
5,5,5,5,5,5,5,5,5,5,3,3,7,6,7,6,
9,8,6,7,7,5,5,8,7,2,4,7,5,10,7,8,
6,8,7,6,6,6,8,12,7,6,6,3,5,3,6,8,
4,6,6,6,6,6,4,6,6,2,3,5,2,10,6,6,
6,6,3,5,3,6,6,8,6,6,5,4,6,4,7,0,
};
if ( font == FONTLITTLE )
{
return table_width_little[GetOffset(c)];
}
else
{
return table_width[GetOffset(c)]-1;
}
}
// Affiche un texte.
void DrawText(CPixmap *pPixmap, POINT pos, const char *pText, Sint32 font)
{
Sint32 rank;
if ( font == FONTLITTLE )
{
while ( *pText != 0 )
{
rank = GetOffset(*pText);
pPixmap->DrawIcon(-1, CHLITTLE, rank, pos);
pos.x += GetCharWidth(*pText++, font);
}
}
else
{
while ( *pText != 0 )
{
rank = GetOffset(*pText);
rank += 128*font;
pPixmap->DrawIcon(-1, CHTEXT, rank, pos);
pos.x += GetCharWidth(*pText++, font);
}
}
}
// Affiche un texte penché.
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
Sint32 pente, Sint32 font)
{
Sint32 rank, lg, rel, start;
start = pos.y;
rel = 0;
while ( *pText != 0 )
{
rank = GetOffset(*pText);
rank += 128*font;
pPixmap->DrawIcon(-1, CHTEXT, rank, pos);
lg = GetCharWidth(*pText++, font);
rel += lg;
pos.x += lg;
pos.y = start + rel/pente;
}
}
// Affiche un pavé de texte.
// Une ligne vide est affichée avec un demi interligne !
// Si part != -1, n'affiche que les lignes qui commencent
// par "n|", avec n=part.
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
Sint32 pente, Sint32 font, Sint32 part)
{
char text[100];
char* pDest;
Sint32 itl;
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while ( *pText != 0 )
{
pDest = text;
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
{
*pDest++ = *pText++;
}
*pDest = 0;
if ( *pText == '\r' ) pText ++; // saute '\r'
if ( *pText == '\n' ) pText ++; // saute '\n'
pDest = text;
if ( text[0] != 0 && text[1] == '|' ) // commence par "n|" ?
{
if ( part != -1 && part != text[0]-'0' ) continue;
pDest += 2; // saute "n|"
}
else
{
if ( part != -1 ) continue;
}
if ( pente == 0 )
{
DrawText(pPixmap, pos, pDest, font);
}
else
{
DrawTextPente(pPixmap, pos, pDest, pente, font);
}
if ( pDest[0] == 0 ) // ligne vide ?
{
pos.y += itl/2; // descend de 1/2 ligne
}
else
{
pos.y += itl; // passe à la ligne suivante
}
}
}
// Affiche un texte centré pouvant éventuellement
// contenir plusieurs lignes séparées par des '\n'.
void DrawTextCenter(CPixmap *pPixmap, POINT pos, const char *pText, Sint32 font)
{
char text[100];
char* pDest;
Sint32 itl;
POINT start;
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while ( *pText != 0 )
{
pDest = text;
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
{
*pDest++ = *pText++;
}
*pDest = 0;
if ( *pText == '\r' ) pText ++; // saute '\r'
if ( *pText == '\n' ) pText ++; // saute '\n'
pDest = text;
start.x = pos.x - GetTextWidth(pDest)/2;
start.y = pos.y;
DrawText(pPixmap, start, pDest, font);
if ( pDest[0] == 0 ) // ligne vide ?
{
pos.y += itl/2; // descend de 1/2 ligne
}
else
{
pos.y += itl; // passe à la ligne suivante
}
}
}
// Retourne la hauteur d'un texte.
Sint32 GetTextHeight(char *pText, Sint32 font, Sint32 part)
{
char text[100];
char* pDest;
Sint32 itl;
Sint32 h=0;
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while ( *pText != 0 )
{
pDest = text;
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
{
*pDest++ = *pText++;
}
*pDest = 0;
if ( *pText == '\r' ) pText ++; // saute '\r'
if ( *pText == '\n' ) pText ++; // saute '\n'
pDest = text;
if ( text[0] != 0 && text[1] == '|' ) // commence par "n|" ?
{
if ( part != -1 && part != text[0]-'0' ) continue;
pDest += 2; // saute "n|"
}
else
{
if ( part != -1 ) continue;
}
if ( pDest[0] == 0 ) // ligne vide ?
{
h += itl/2; // descend de 1/2 ligne
}
else
{
h += itl; // passe à la ligne suivante
}
}
return h;
}
// Retourne la longueur d'un texte.
Sint32 GetTextWidth(const char *pText, Sint32 font)
{
Sint32 width = 0;
while ( *pText != 0 )
{
width += GetCharWidth(*pText++, font);
}
return width;
}
// Retourne la longueur d'un grand chiffre.
void GetBignumInfo(Sint32 num, Sint32 &start, Sint32 &lg)
{
static Sint32 table[11] =
{
0,53,87,133,164,217,253,297,340,382,426
};
start = table[num];
lg = table[num+1]-table[num];
}
// Affiche un grand nombre.
void DrawBignum(CPixmap *pPixmap, POINT pos, Sint32 num)
{
char string[10];
Sint32 i = 0;
Sint32 start, lg;
RECT rect;
sprintf(string, "%d", num);
rect.top = 0;
rect.bottom = 52;
while ( string[i] != 0 )
{
GetBignumInfo(string[i]-'0', start, lg);
rect.left = start;
rect.right = start+lg;
pPixmap->DrawPart(-1, CHBIGNUM, pos, rect);
pos.x += lg+4;
i ++;
}
}
// Retourne la longueur d'un grand nombre.
Sint32 GetBignumWidth(Sint32 num)
{
char string[10];
Sint32 i = 0;
Sint32 start, lg;
Sint32 width = -4;
sprintf(string, "%d", num);
while ( string[i] != 0 )
{
GetBignumInfo(string[i]-'0', start, lg);
width += lg+4;
i ++;
}
return width;
}

View File

@ -1,35 +0,0 @@
// Text.h
#pragma once
#define FONTWHITE 0
#define FONTRED 1
#define FONTSLIM 2
#define FONTLITTLE 10
extern
void DrawText(CPixmap *pPixmap, POINT pos, const char *pText, Sint32 font=0);
extern
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
Sint32 pente, Sint32 font=0);
extern
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
Sint32 pente, Sint32 font=0, Sint32 part=-1);
extern
void DrawTextCenter(CPixmap *pPixmap, POINT pos, const char *pText, Sint32 font=0);
extern
Sint32 GetTextHeight(char *pText, Sint32 font=0, Sint32 part=-1);
extern
Sint32 GetTextWidth(const char *pText, Sint32 font=0);
extern
void DrawBignum(CPixmap *pPixmap, POINT pos, Sint32 num);
extern
Sint32 GetBignumWidth(Sint32 num);