Compare commits
26 Commits
fd94aea99b
...
v2.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| a7d7cdd047 | |||
| bffefcad77 | |||
| b408de5fa0 | |||
| f70145a0bf | |||
| 02c7790835 | |||
| 2d10e640bd | |||
| 737829cb68 | |||
| d3f17bc93a | |||
| b7490ed1c1 | |||
| 836deb720d | |||
| 7e9a1cb049 | |||
| f928195a05 | |||
| 84b09a4987 | |||
| f0b9a1d134 | |||
| 64369921ec | |||
| 70ae7f67a9 | |||
| 2ea86ef39f | |||
| 658bb71441 | |||
| 0b996ea321 | |||
| cf072424c6 | |||
| 42c0f19c68 | |||
| 8d1cabb288 | |||
| 87aeaab6b8 | |||
| ad5fb0fc22 | |||
| 8e6d546b97 | |||
| f916381a9b |
7
Makefile
@@ -1,6 +1,9 @@
|
|||||||
|
executable = coffee_crisis
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
g++ -std=c++11 -Wall -O2 source/*.cpp -o bin/coffee_crisis_macos -lSDL2
|
g++ -std=c++11 -Wall -O2 source/*.cpp -o bin/$(executable)_macos -lSDL2
|
||||||
linux:
|
linux:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
g++ -std=c++11 -Wall -O2 source/*.cpp -o bin/coffee_crisis_linux -lSDL2
|
g++ source/*.cpp -std=c++11 -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o bin/$(executable)_linux
|
||||||
|
strip -s -R .comment -R .gnu.version bin/$(executable)_linux --strip-unneeded
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
# box height
|
# box height
|
||||||
10
|
10
|
||||||
# 32 espacio ( )
|
# 32 espacio ( )
|
||||||
7
|
5
|
||||||
# 33 !
|
# 33 !
|
||||||
4
|
4
|
||||||
# 34 "
|
# 34 "
|
||||||
|
|||||||
BIN
media/font/nokia2.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
194
media/font/nokia2.txt
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
# box width
|
||||||
|
10
|
||||||
|
# box height
|
||||||
|
10
|
||||||
|
# 32 espacio ( )
|
||||||
|
5
|
||||||
|
# 33 !
|
||||||
|
4
|
||||||
|
# 34 "
|
||||||
|
5
|
||||||
|
# 35 #
|
||||||
|
7
|
||||||
|
# 36 $
|
||||||
|
7
|
||||||
|
# 37 %
|
||||||
|
8
|
||||||
|
# 38 &
|
||||||
|
8
|
||||||
|
# 39 '
|
||||||
|
3
|
||||||
|
# 40 (
|
||||||
|
5
|
||||||
|
# 41 )
|
||||||
|
5
|
||||||
|
# 42 *
|
||||||
|
7
|
||||||
|
# 43 +
|
||||||
|
7
|
||||||
|
# 44 ,
|
||||||
|
4
|
||||||
|
# 45 -
|
||||||
|
6
|
||||||
|
# 46 .
|
||||||
|
4
|
||||||
|
# 47 /
|
||||||
|
5
|
||||||
|
# 48 0
|
||||||
|
7
|
||||||
|
# 49 1
|
||||||
|
5
|
||||||
|
# 50 2
|
||||||
|
7
|
||||||
|
# 51 3
|
||||||
|
7
|
||||||
|
# 52 4
|
||||||
|
7
|
||||||
|
# 53 5
|
||||||
|
7
|
||||||
|
# 54 6
|
||||||
|
7
|
||||||
|
# 55 7
|
||||||
|
7
|
||||||
|
# 56 8
|
||||||
|
7
|
||||||
|
# 57 9
|
||||||
|
7
|
||||||
|
# 58 :
|
||||||
|
4
|
||||||
|
# 59 ;
|
||||||
|
4
|
||||||
|
# 60 <
|
||||||
|
6
|
||||||
|
# 61 =
|
||||||
|
6
|
||||||
|
# 62 >
|
||||||
|
6
|
||||||
|
# 63 ?
|
||||||
|
7
|
||||||
|
# 64 @
|
||||||
|
8
|
||||||
|
# 65 A
|
||||||
|
7
|
||||||
|
# 66 B
|
||||||
|
7
|
||||||
|
# 67 C
|
||||||
|
7
|
||||||
|
# 68 D
|
||||||
|
7
|
||||||
|
# 69 E
|
||||||
|
7
|
||||||
|
# 70 F
|
||||||
|
7
|
||||||
|
# 71 G
|
||||||
|
7
|
||||||
|
# 72 H
|
||||||
|
7
|
||||||
|
# 73 I
|
||||||
|
4
|
||||||
|
# 74 J
|
||||||
|
6
|
||||||
|
# 75 K
|
||||||
|
8
|
||||||
|
# 76 L
|
||||||
|
6
|
||||||
|
# 77 M
|
||||||
|
9
|
||||||
|
# 78 N
|
||||||
|
8
|
||||||
|
# 79 O
|
||||||
|
8
|
||||||
|
# 80 P
|
||||||
|
7
|
||||||
|
# 81 Q
|
||||||
|
8
|
||||||
|
# 82 R
|
||||||
|
7
|
||||||
|
# 83 S
|
||||||
|
6
|
||||||
|
# 84 T
|
||||||
|
8
|
||||||
|
# 85 U
|
||||||
|
7
|
||||||
|
# 86 V
|
||||||
|
8
|
||||||
|
# 87 W
|
||||||
|
9
|
||||||
|
# 88 X
|
||||||
|
8
|
||||||
|
# 89 Y
|
||||||
|
8
|
||||||
|
# 90 Z
|
||||||
|
7
|
||||||
|
# 91 [
|
||||||
|
4
|
||||||
|
# 92 \
|
||||||
|
5
|
||||||
|
# 93 ]
|
||||||
|
4
|
||||||
|
# 94 ^
|
||||||
|
5
|
||||||
|
# 95 _
|
||||||
|
8
|
||||||
|
# 96 `
|
||||||
|
4
|
||||||
|
# 97 a
|
||||||
|
7
|
||||||
|
# 98 b
|
||||||
|
7
|
||||||
|
# 99 c
|
||||||
|
6
|
||||||
|
# 100 d
|
||||||
|
7
|
||||||
|
# 101 e
|
||||||
|
7
|
||||||
|
# 102 f
|
||||||
|
5
|
||||||
|
# 103 g
|
||||||
|
7
|
||||||
|
# 104 h
|
||||||
|
7
|
||||||
|
# 105 i
|
||||||
|
4
|
||||||
|
# 106 j
|
||||||
|
5
|
||||||
|
# 107 k
|
||||||
|
7
|
||||||
|
# 108 l
|
||||||
|
4
|
||||||
|
# 109 m
|
||||||
|
10
|
||||||
|
# 110 n
|
||||||
|
7
|
||||||
|
# 111 o
|
||||||
|
7
|
||||||
|
# 112 p
|
||||||
|
7
|
||||||
|
# 113 q
|
||||||
|
7
|
||||||
|
# 114 r
|
||||||
|
6
|
||||||
|
# 115 s
|
||||||
|
6
|
||||||
|
# 116 t
|
||||||
|
5
|
||||||
|
# 117 u
|
||||||
|
7
|
||||||
|
# 118 v
|
||||||
|
7
|
||||||
|
# 119 w
|
||||||
|
9
|
||||||
|
# 120 x
|
||||||
|
7
|
||||||
|
# 121 y
|
||||||
|
7
|
||||||
|
# 122 z
|
||||||
|
7
|
||||||
|
# 123 { -> ñ
|
||||||
|
7
|
||||||
|
# 124 | -> ç
|
||||||
|
7
|
||||||
|
# 125 }
|
||||||
|
0
|
||||||
|
# 126 ~
|
||||||
|
0
|
||||||
|
Before Width: | Height: | Size: 3.8 KiB |
BIN
media/font/nokia_big2.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
@@ -3,7 +3,7 @@
|
|||||||
# box height
|
# box height
|
||||||
20
|
20
|
||||||
# 32 espacio ( )
|
# 32 espacio ( )
|
||||||
14
|
8
|
||||||
# 33 !
|
# 33 !
|
||||||
8
|
8
|
||||||
# 34 "
|
# 34 "
|
||||||
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 773 B After Width: | Height: | Size: 654 B |
@@ -75,7 +75,7 @@ Temps detes:
|
|||||||
## 37 - TEXTOS DEL JUEGO
|
## 37 - TEXTOS DEL JUEGO
|
||||||
D E M O
|
D E M O
|
||||||
## 38 - TEXTOS DEL JUEGO
|
## 38 - TEXTOS DEL JUEGO
|
||||||
PANTALLA
|
Pantalla
|
||||||
## 39 - MARCADOR
|
## 39 - MARCADOR
|
||||||
PUNTS
|
PUNTS
|
||||||
## 40 - MARCADOR
|
## 40 - MARCADOR
|
||||||
@@ -99,7 +99,7 @@ SI
|
|||||||
## 49 - MENU GAME OVER
|
## 49 - MENU GAME OVER
|
||||||
NO
|
NO
|
||||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||||
FELICITATS!!
|
Felicitats!!
|
||||||
## 51 - MENU DEL TITULO
|
## 51 - MENU DEL TITULO
|
||||||
1 JUGADOR
|
1 JUGADOR
|
||||||
## 52 - MENU DEL TITULO
|
## 52 - MENU DEL TITULO
|
||||||
@@ -113,7 +113,7 @@ mult
|
|||||||
## 56 MARCADOR
|
## 56 MARCADOR
|
||||||
max. puntuacio
|
max. puntuacio
|
||||||
## 57 MARCADOR
|
## 57 MARCADOR
|
||||||
nivell
|
pantalla
|
||||||
## 58 - MENU DE OPCIONES
|
## 58 - MENU DE OPCIONES
|
||||||
MODE DE VISUALITZACIO
|
MODE DE VISUALITZACIO
|
||||||
## 59 - MENU DE OPCIONES
|
## 59 - MENU DE OPCIONES
|
||||||
@@ -148,7 +148,11 @@ NEAREST
|
|||||||
ACTIVADA
|
ACTIVADA
|
||||||
## 74 - MENU DE OPCIONES
|
## 74 - MENU DE OPCIONES
|
||||||
DESACTIVADA
|
DESACTIVADA
|
||||||
## 75 - MENU DE OPCIONES
|
## 75 - JUEGO
|
||||||
ENDAVANT!
|
Endavant!
|
||||||
## 76 - JUEGO
|
## 76 - JUEGO
|
||||||
1.000.000 DE PUNTS!
|
1.000.000 de punts!
|
||||||
|
## 77 - PANTALLA DE GAME OVER
|
||||||
|
PUNTS J1:
|
||||||
|
## 78 - PANTALLA DE GAME OVER
|
||||||
|
PUNTS J2:
|
||||||
@@ -71,11 +71,11 @@ FUCKING MACHINE!
|
|||||||
## 35 - INTRO
|
## 35 - INTRO
|
||||||
Blop... blop... blop...
|
Blop... blop... blop...
|
||||||
## 36 - TEXTOS DEL JUEGO
|
## 36 - TEXTOS DEL JUEGO
|
||||||
Time Stopped:
|
Time stopped:
|
||||||
## 37 - TEXTOS DEL JUEGO
|
## 37 - TEXTOS DEL JUEGO
|
||||||
D E M O
|
D E M O
|
||||||
## 38 - TEXTOS DEL JUEGO
|
## 38 - TEXTOS DEL JUEGO
|
||||||
STAGE
|
Stage
|
||||||
## 39 - MARCADOR
|
## 39 - MARCADOR
|
||||||
SCORE
|
SCORE
|
||||||
## 40 - MARCADOR
|
## 40 - MARCADOR
|
||||||
@@ -99,7 +99,7 @@ YES
|
|||||||
## 49 - MENU GAME OVER
|
## 49 - MENU GAME OVER
|
||||||
NO
|
NO
|
||||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||||
NICE!!
|
Congratulations!!
|
||||||
## 51 - MENU DEL TITULO
|
## 51 - MENU DEL TITULO
|
||||||
1 PLAYER
|
1 PLAYER
|
||||||
## 52 - MENU DEL TITULO
|
## 52 - MENU DEL TITULO
|
||||||
@@ -149,6 +149,10 @@ ON
|
|||||||
## 74 - MENU DE OPCIONES
|
## 74 - MENU DE OPCIONES
|
||||||
OFF
|
OFF
|
||||||
## 75 - JUEGO
|
## 75 - JUEGO
|
||||||
GET READY!
|
Get Ready!
|
||||||
## 76 - JUEGO
|
## 76 - JUEGO
|
||||||
1.000.000 POINTS!
|
1.000.000 points!
|
||||||
|
## 77 - PANTALLA DE GAME OVER
|
||||||
|
PLAYER1 SCORE:
|
||||||
|
## 78 - PANTALLA DE GAME OVER
|
||||||
|
PLAYER2 SCORE:
|
||||||
@@ -75,7 +75,7 @@ Tiempo:
|
|||||||
## 37 - TEXTOS DEL JUEGO
|
## 37 - TEXTOS DEL JUEGO
|
||||||
D E M O
|
D E M O
|
||||||
## 38 - TEXTOS DEL JUEGO
|
## 38 - TEXTOS DEL JUEGO
|
||||||
FASE
|
Fase
|
||||||
## 39 - MARCADOR
|
## 39 - MARCADOR
|
||||||
PUNTOS
|
PUNTOS
|
||||||
## 40 - MARCADOR
|
## 40 - MARCADOR
|
||||||
@@ -99,7 +99,7 @@ SI
|
|||||||
## 49 - MENU GAME OVER
|
## 49 - MENU GAME OVER
|
||||||
NO
|
NO
|
||||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||||
FELICIDADES!!
|
Felicidades!!
|
||||||
## 51 - MENU DEL TITULO
|
## 51 - MENU DEL TITULO
|
||||||
1 JUGADOR
|
1 JUGADOR
|
||||||
## 52 - MENU DEL TITULO
|
## 52 - MENU DEL TITULO
|
||||||
@@ -148,7 +148,11 @@ NEAREST
|
|||||||
ACTIVADA
|
ACTIVADA
|
||||||
## 74 - MENU DE OPCIONES
|
## 74 - MENU DE OPCIONES
|
||||||
DESACTIVADA
|
DESACTIVADA
|
||||||
## 75 - MENU DE OPCIONES
|
## 75 - JUEGO
|
||||||
ADELANTE!
|
Adelante!
|
||||||
## 76 - JUEGO
|
## 76 - JUEGO
|
||||||
1.000.000 DE PUNTOS!
|
1.000.000 de puntos!
|
||||||
|
## 77 - PANTALLA DE GAME OVER
|
||||||
|
PUNTUACION J1:
|
||||||
|
## 78 - PANTALLA DE GAME OVER
|
||||||
|
PUNTUACION J2:
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
#define WINDOW_CAPTION "Coffee Crisis"
|
#define WINDOW_CAPTION "Coffee Crisis"
|
||||||
#define TEXT_COPYRIGHT "@2020,2021 JailDesigner (v2.0)"
|
#define TEXT_COPYRIGHT "@2020,2021 JailDesigner (v2.0.2)"
|
||||||
|
|
||||||
// Recursos
|
// Recursos
|
||||||
#define BINFILE_SCORE 0
|
#define BINFILE_SCORE 0
|
||||||
|
|||||||
@@ -33,17 +33,14 @@ Director::Director(std::string path)
|
|||||||
mOptions->windowSize = 3;
|
mOptions->windowSize = 3;
|
||||||
mOptions->language = en_UK;
|
mOptions->language = en_UK;
|
||||||
mOptions->difficulty = DIFFICULTY_NORMAL;
|
mOptions->difficulty = DIFFICULTY_NORMAL;
|
||||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
mOptions->filter = FILTER_NEAREST;
|
mOptions->filter = FILTER_NEAREST;
|
||||||
mOptions->vSync = true;
|
mOptions->vSync = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
mInput = new Input(mFileList[52]);
|
mInput = new Input(mFileList[53]);
|
||||||
//mInput2 = new Input(mOptions->input[1]);
|
|
||||||
//mInput[0] = new Input(INPUT_USE_KEYBOARD);
|
|
||||||
//mInput[1] = new Input(INPUT_USE_GAMECONTROLLER);
|
|
||||||
|
|
||||||
// Inicializa SDL
|
// Inicializa SDL
|
||||||
initSDL();
|
initSDL();
|
||||||
@@ -51,6 +48,11 @@ Director::Director(std::string path)
|
|||||||
// Inicializa JailAudio
|
// Inicializa JailAudio
|
||||||
initJailAudio();
|
initJailAudio();
|
||||||
|
|
||||||
|
// Aplica las opciones
|
||||||
|
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
||||||
|
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
||||||
|
mLang->setLang(mOptions->language);
|
||||||
|
|
||||||
#ifdef __MIPSEL__
|
#ifdef __MIPSEL__
|
||||||
DIR *dir = opendir("/media/data/local/home/.coffee_crisis");
|
DIR *dir = opendir("/media/data/local/home/.coffee_crisis");
|
||||||
if (dir)
|
if (dir)
|
||||||
@@ -126,7 +128,7 @@ void Director::init(Uint8 name)
|
|||||||
mInput->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_X);
|
mInput->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_X);
|
||||||
mInput->bindGameControllerButton(INPUT_BUTTON_2, SDL_CONTROLLER_BUTTON_Y);
|
mInput->bindGameControllerButton(INPUT_BUTTON_2, SDL_CONTROLLER_BUTTON_Y);
|
||||||
mInput->bindGameControllerButton(INPUT_BUTTON_3, SDL_CONTROLLER_BUTTON_B);
|
mInput->bindGameControllerButton(INPUT_BUTTON_3, SDL_CONTROLLER_BUTTON_B);
|
||||||
mInput->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
mInput->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
||||||
mInput->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE); // ESCAPE
|
mInput->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE); // ESCAPE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,13 +145,17 @@ bool Director::initSDL()
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
// Inicializa SDL
|
// Inicializa SDL
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0)
|
//if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0)
|
||||||
|
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
|
||||||
{
|
{
|
||||||
printf("SDL could not initialize!\nSDL Error: %s\n", SDL_GetError());
|
printf("SDL could not initialize!\nSDL Error: %s\n", SDL_GetError());
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Inicia el generador de numeros aleatorios
|
||||||
|
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
||||||
|
|
||||||
// Establece el filtro de la textura a nearest
|
// Establece el filtro de la textura a nearest
|
||||||
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(mOptions->filter).c_str()))
|
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(mOptions->filter).c_str()))
|
||||||
{
|
{
|
||||||
@@ -259,7 +265,11 @@ void Director::setFileList()
|
|||||||
mFileList[27] = mExecutablePath + "/" + "../media/font/8bithud.png";
|
mFileList[27] = mExecutablePath + "/" + "../media/font/8bithud.png";
|
||||||
mFileList[46] = mExecutablePath + "/" + "../media/font/8bithud.txt";
|
mFileList[46] = mExecutablePath + "/" + "../media/font/8bithud.txt";
|
||||||
mFileList[28] = mExecutablePath + "/" + "../media/font/nokia.png";
|
mFileList[28] = mExecutablePath + "/" + "../media/font/nokia.png";
|
||||||
|
mFileList[54] = mExecutablePath + "/" + "../media/font/nokia_big2.png";
|
||||||
mFileList[52] = mExecutablePath + "/" + "../media/font/nokia.txt";
|
mFileList[52] = mExecutablePath + "/" + "../media/font/nokia.txt";
|
||||||
|
mFileList[56] = mExecutablePath + "/" + "../media/font/nokia2.png";
|
||||||
|
mFileList[57] = mExecutablePath + "/" + "../media/font/nokia2.txt";
|
||||||
|
mFileList[55] = mExecutablePath + "/" + "../media/font/nokia_big2.txt";
|
||||||
mFileList[29] = mExecutablePath + "/" + "../media/font/smb2_big.png";
|
mFileList[29] = mExecutablePath + "/" + "../media/font/smb2_big.png";
|
||||||
mFileList[47] = mExecutablePath + "/" + "../media/font/smb2_big.txt";
|
mFileList[47] = mExecutablePath + "/" + "../media/font/smb2_big.txt";
|
||||||
mFileList[30] = mExecutablePath + "/" + "../media/font/smb2.png";
|
mFileList[30] = mExecutablePath + "/" + "../media/font/smb2.png";
|
||||||
@@ -271,7 +281,7 @@ void Director::setFileList()
|
|||||||
mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt";
|
mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt";
|
||||||
|
|
||||||
// DATA
|
// DATA
|
||||||
mFileList[52] = mExecutablePath + "/" + "../media/data/gamecontrollerdb.txt";
|
mFileList[53] = mExecutablePath + "/" + "../data/gamecontrollerdb.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
|
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
|
||||||
@@ -345,8 +355,8 @@ bool Director::loadConfigFile()
|
|||||||
mOptions->windowSize = 3;
|
mOptions->windowSize = 3;
|
||||||
mOptions->language = en_UK;
|
mOptions->language = en_UK;
|
||||||
mOptions->difficulty = DIFFICULTY_NORMAL;
|
mOptions->difficulty = DIFFICULTY_NORMAL;
|
||||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
mOptions->filter = FILTER_NEAREST;
|
mOptions->filter = FILTER_NEAREST;
|
||||||
mOptions->vSync = true;
|
mOptions->vSync = true;
|
||||||
|
|
||||||
@@ -373,8 +383,8 @@ bool Director::loadConfigFile()
|
|||||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||||
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||||
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||||
SDL_RWwrite(file, &mOptions->input[0], sizeof(mOptions->input[0]), 1);
|
SDL_RWwrite(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
|
||||||
SDL_RWwrite(file, &mOptions->input[1], sizeof(mOptions->input[1]), 1);
|
SDL_RWwrite(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
|
||||||
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||||
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||||
|
|
||||||
@@ -396,8 +406,8 @@ bool Director::loadConfigFile()
|
|||||||
SDL_RWread(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
SDL_RWread(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||||
SDL_RWread(file, &mOptions->language, sizeof(mOptions->language), 1);
|
SDL_RWread(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||||
SDL_RWread(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
SDL_RWread(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||||
SDL_RWread(file, &mOptions->input[0], sizeof(mOptions->input[0]), 1);
|
SDL_RWread(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
|
||||||
SDL_RWread(file, &mOptions->input[1], sizeof(mOptions->input[1]), 1);
|
SDL_RWread(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
|
||||||
SDL_RWread(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
SDL_RWread(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||||
SDL_RWread(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
SDL_RWread(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||||
|
|
||||||
@@ -411,11 +421,6 @@ bool Director::loadConfigFile()
|
|||||||
if ((mOptions->language < 0) || (mOptions->language > MAX_LANGUAGES))
|
if ((mOptions->language < 0) || (mOptions->language > MAX_LANGUAGES))
|
||||||
mOptions->language = en_UK;
|
mOptions->language = en_UK;
|
||||||
|
|
||||||
// Aplica las opciones
|
|
||||||
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
|
||||||
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
|
||||||
mLang->setLang(mOptions->language);
|
|
||||||
|
|
||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
}
|
}
|
||||||
@@ -437,8 +442,8 @@ bool Director::saveConfigFile()
|
|||||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||||
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||||
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||||
SDL_RWwrite(file, &mOptions->input[0], sizeof(mOptions->input[0]), 1);
|
SDL_RWwrite(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
|
||||||
SDL_RWwrite(file, &mOptions->input[1], sizeof(mOptions->input[1]), 1);
|
SDL_RWwrite(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
|
||||||
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||||
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
#include <math.h>
|
//#include <math.h>
|
||||||
|
|
||||||
#ifndef DIRECTOR_H
|
#ifndef DIRECTOR_H
|
||||||
#define DIRECTOR_H
|
#define DIRECTOR_H
|
||||||
|
|||||||
181
source/game.cpp
@@ -13,13 +13,13 @@ Game::Game(int numPlayers, SDL_Renderer *renderer, std::string *filelist, Lang *
|
|||||||
mLang = lang;
|
mLang = lang;
|
||||||
mInput = input;
|
mInput = input;
|
||||||
mOptions = options;
|
mOptions = options;
|
||||||
mOnePlayerControl = mOptions->input[0];
|
mOnePlayerControl = mOptions->input[0].deviceType;
|
||||||
|
|
||||||
// Pasa variables
|
// Pasa variables
|
||||||
mDemo.enabled = demo;
|
mDemo.enabled = demo;
|
||||||
mNumPlayers = numPlayers;
|
mNumPlayers = numPlayers;
|
||||||
if (mNumPlayers == 1)
|
if (mNumPlayers == 1)
|
||||||
mOptions->input[0] = INPUT_USE_ANY;
|
mOptions->input[0].deviceType = INPUT_USE_ANY;
|
||||||
mDifficulty = mOptions->difficulty;
|
mDifficulty = mOptions->difficulty;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
@@ -50,10 +50,14 @@ Game::Game(int numPlayers, SDL_Renderer *renderer, std::string *filelist, Lang *
|
|||||||
mTextureText = new LTexture();
|
mTextureText = new LTexture();
|
||||||
mTextureTextScoreBoard = new LTexture();
|
mTextureTextScoreBoard = new LTexture();
|
||||||
mTextureTextBig = new LTexture();
|
mTextureTextBig = new LTexture();
|
||||||
|
mTextureTextNokia2 = new LTexture();
|
||||||
|
mTextureTextNokiaBig2 = new LTexture();
|
||||||
|
|
||||||
mText = new Text(mFileList[48], mTextureText, mRenderer);
|
mText = new Text(mFileList[48], mTextureText, mRenderer);
|
||||||
mTextScoreBoard = new Text(mFileList[46], mTextureTextScoreBoard, mRenderer);
|
mTextScoreBoard = new Text(mFileList[46], mTextureTextScoreBoard, mRenderer);
|
||||||
mTextBig = new Text(mFileList[47], mTextureTextBig, mRenderer);
|
mTextBig = new Text(mFileList[47], mTextureTextBig, mRenderer);
|
||||||
|
mTextNokia2 = new Text(mFileList[57], mTextureTextNokia2, mRenderer);
|
||||||
|
mTextNokiaBig2 = new Text(mFileList[55], mTextureTextNokiaBig2, mRenderer);
|
||||||
|
|
||||||
mMenuGameOver = new Menu(mRenderer, mText, mInput, mFileList);
|
mMenuGameOver = new Menu(mRenderer, mText, mInput, mFileList);
|
||||||
mMenuPause = new Menu(mRenderer, mText, mInput, mFileList);
|
mMenuPause = new Menu(mRenderer, mText, mInput, mFileList);
|
||||||
@@ -93,7 +97,7 @@ Game::~Game()
|
|||||||
saveScoreFile();
|
saveScoreFile();
|
||||||
saveDemoFile();
|
saveDemoFile();
|
||||||
|
|
||||||
mOptions->input[0] = mOnePlayerControl;
|
mOptions->input[0].deviceType = mOnePlayerControl;
|
||||||
|
|
||||||
mRenderer = nullptr;
|
mRenderer = nullptr;
|
||||||
mFileList = nullptr;
|
mFileList = nullptr;
|
||||||
@@ -190,14 +194,28 @@ Game::~Game()
|
|||||||
delete mTextureTextBig;
|
delete mTextureTextBig;
|
||||||
mTextureTextBig = nullptr;
|
mTextureTextBig = nullptr;
|
||||||
|
|
||||||
|
mTextureTextNokia2->unload();
|
||||||
|
delete mTextureTextNokia2;
|
||||||
|
mTextureTextNokia2 = nullptr;
|
||||||
|
|
||||||
|
mTextureTextNokiaBig2->unload();
|
||||||
|
delete mTextureTextNokiaBig2;
|
||||||
|
mTextureTextNokiaBig2 = nullptr;
|
||||||
|
|
||||||
delete mText;
|
delete mText;
|
||||||
mText = nullptr;
|
mText = nullptr;
|
||||||
|
|
||||||
|
delete mTextBig;
|
||||||
|
mTextBig = nullptr;
|
||||||
|
|
||||||
delete mTextScoreBoard;
|
delete mTextScoreBoard;
|
||||||
mTextScoreBoard = nullptr;
|
mTextScoreBoard = nullptr;
|
||||||
|
|
||||||
delete mTextureTextBig;
|
delete mTextNokia2;
|
||||||
mTextureTextBig = nullptr;
|
mTextNokia2 = nullptr;
|
||||||
|
|
||||||
|
delete mTextNokiaBig2;
|
||||||
|
mTextNokiaBig2 = nullptr;
|
||||||
|
|
||||||
delete mMenuGameOver;
|
delete mMenuGameOver;
|
||||||
mMenuGameOver = nullptr;
|
mMenuGameOver = nullptr;
|
||||||
@@ -370,6 +388,9 @@ void Game::init()
|
|||||||
initEnemyPools();
|
initEnemyPools();
|
||||||
initGameStages();
|
initGameStages();
|
||||||
|
|
||||||
|
// BORRAR
|
||||||
|
//mStage[mCurrentStage].currentPower = mStage[mCurrentStage].powerToComplete - 10;
|
||||||
|
|
||||||
// Modo debug
|
// Modo debug
|
||||||
mDebug.enabled = false;
|
mDebug.enabled = false;
|
||||||
mDebug.enemySet = 0;
|
mDebug.enemySet = 0;
|
||||||
@@ -523,6 +544,8 @@ bool Game::loadMedia()
|
|||||||
success &= loadTextureFromFile(mTextureText, mFileList[30], mRenderer);
|
success &= loadTextureFromFile(mTextureText, mFileList[30], mRenderer);
|
||||||
success &= loadTextureFromFile(mTextureTextScoreBoard, mFileList[27], mRenderer);
|
success &= loadTextureFromFile(mTextureTextScoreBoard, mFileList[27], mRenderer);
|
||||||
success &= loadTextureFromFile(mTextureTextBig, mFileList[29], mRenderer);
|
success &= loadTextureFromFile(mTextureTextBig, mFileList[29], mRenderer);
|
||||||
|
success &= loadTextureFromFile(mTextureTextNokia2, mFileList[56], mRenderer);
|
||||||
|
success &= loadTextureFromFile(mTextureTextNokiaBig2, mFileList[54], mRenderer);
|
||||||
|
|
||||||
success &= loadTextureFromFile(mTexturePlayer1Legs, mFileList[39], mRenderer);
|
success &= loadTextureFromFile(mTexturePlayer1Legs, mFileList[39], mRenderer);
|
||||||
success &= loadTextureFromFile(mTexturePlayer1Head, mFileList[41], mRenderer);
|
success &= loadTextureFromFile(mTexturePlayer1Head, mFileList[41], mRenderer);
|
||||||
@@ -1389,7 +1412,7 @@ void Game::initGameStages()
|
|||||||
mStage[2].currentPower = 0;
|
mStage[2].currentPower = 0;
|
||||||
mStage[2].powerToComplete = 600;
|
mStage[2].powerToComplete = 600;
|
||||||
mStage[2].minMenace = 7 + (4 * 3);
|
mStage[2].minMenace = 7 + (4 * 3);
|
||||||
mStage[2].maxMenace = 7 + (4 * 6);
|
mStage[2].maxMenace = 7 + (4 * 5);
|
||||||
mStage[2].enemyPool = &mEnemyPool[2];
|
mStage[2].enemyPool = &mEnemyPool[2];
|
||||||
|
|
||||||
// STAGE 4
|
// STAGE 4
|
||||||
@@ -1397,7 +1420,7 @@ void Game::initGameStages()
|
|||||||
mStage[3].currentPower = 0;
|
mStage[3].currentPower = 0;
|
||||||
mStage[3].powerToComplete = 600;
|
mStage[3].powerToComplete = 600;
|
||||||
mStage[3].minMenace = 7 + (4 * 3);
|
mStage[3].minMenace = 7 + (4 * 3);
|
||||||
mStage[3].maxMenace = 7 + (4 * 7);
|
mStage[3].maxMenace = 7 + (4 * 5);
|
||||||
mStage[3].enemyPool = &mEnemyPool[3];
|
mStage[3].enemyPool = &mEnemyPool[3];
|
||||||
|
|
||||||
// STAGE 5
|
// STAGE 5
|
||||||
@@ -1405,47 +1428,47 @@ void Game::initGameStages()
|
|||||||
mStage[4].currentPower = 0;
|
mStage[4].currentPower = 0;
|
||||||
mStage[4].powerToComplete = 600;
|
mStage[4].powerToComplete = 600;
|
||||||
mStage[4].minMenace = 7 + (4 * 4);
|
mStage[4].minMenace = 7 + (4 * 4);
|
||||||
mStage[4].maxMenace = 7 + (4 * 8);
|
mStage[4].maxMenace = 7 + (4 * 6);
|
||||||
mStage[4].enemyPool = &mEnemyPool[4];
|
mStage[4].enemyPool = &mEnemyPool[4];
|
||||||
|
|
||||||
// STAGE 6
|
// STAGE 6
|
||||||
mStage[5].number = 6;
|
mStage[5].number = 6;
|
||||||
mStage[5].currentPower = 0;
|
mStage[5].currentPower = 0;
|
||||||
mStage[5].powerToComplete = 600;
|
mStage[5].powerToComplete = 600;
|
||||||
mStage[5].minMenace = 7 + (4 * 5);
|
mStage[5].minMenace = 7 + (4 * 4);
|
||||||
mStage[5].maxMenace = 7 + (4 * 10);
|
mStage[5].maxMenace = 7 + (4 * 6);
|
||||||
mStage[5].enemyPool = &mEnemyPool[5];
|
mStage[5].enemyPool = &mEnemyPool[5];
|
||||||
|
|
||||||
// STAGE 7
|
// STAGE 7
|
||||||
mStage[6].number = 7;
|
mStage[6].number = 7;
|
||||||
mStage[6].currentPower = 0;
|
mStage[6].currentPower = 0;
|
||||||
mStage[6].powerToComplete = 650;
|
mStage[6].powerToComplete = 650;
|
||||||
mStage[6].minMenace = 7 + (4 * 6);
|
mStage[6].minMenace = 7 + (4 * 5);
|
||||||
mStage[6].maxMenace = 7 + (4 * 11);
|
mStage[6].maxMenace = 7 + (4 * 7);
|
||||||
mStage[6].enemyPool = &mEnemyPool[6];
|
mStage[6].enemyPool = &mEnemyPool[6];
|
||||||
|
|
||||||
// STAGE 8
|
// STAGE 8
|
||||||
mStage[7].number = 8;
|
mStage[7].number = 8;
|
||||||
mStage[7].currentPower = 0;
|
mStage[7].currentPower = 0;
|
||||||
mStage[7].powerToComplete = 750;
|
mStage[7].powerToComplete = 750;
|
||||||
mStage[7].minMenace = 7 + (4 * 7);
|
mStage[7].minMenace = 7 + (4 * 5);
|
||||||
mStage[7].maxMenace = 7 + (4 * 12);
|
mStage[7].maxMenace = 7 + (4 * 7);
|
||||||
mStage[7].enemyPool = &mEnemyPool[7];
|
mStage[7].enemyPool = &mEnemyPool[7];
|
||||||
|
|
||||||
// STAGE 9
|
// STAGE 9
|
||||||
mStage[8].number = 9;
|
mStage[8].number = 9;
|
||||||
mStage[8].currentPower = 0;
|
mStage[8].currentPower = 0;
|
||||||
mStage[8].powerToComplete = 850;
|
mStage[8].powerToComplete = 850;
|
||||||
mStage[8].minMenace = 7 + (4 * 8);
|
mStage[8].minMenace = 7 + (4 * 6);
|
||||||
mStage[8].maxMenace = 7 + (4 * 13);
|
mStage[8].maxMenace = 7 + (4 * 8);
|
||||||
mStage[8].enemyPool = &mEnemyPool[8];
|
mStage[8].enemyPool = &mEnemyPool[8];
|
||||||
|
|
||||||
// STAGE 10
|
// STAGE 10
|
||||||
mStage[9].number = 10;
|
mStage[9].number = 10;
|
||||||
mStage[9].currentPower = 0;
|
mStage[9].currentPower = 0;
|
||||||
mStage[9].powerToComplete = 950;
|
mStage[9].powerToComplete = 950;
|
||||||
mStage[9].minMenace = 7 + (4 * 9);
|
mStage[9].minMenace = 7 + (4 * 7);
|
||||||
mStage[9].maxMenace = 7 + (4 * 15);
|
mStage[9].maxMenace = 7 + (4 * 10);
|
||||||
mStage[9].enemyPool = &mEnemyPool[9];
|
mStage[9].enemyPool = &mEnemyPool[9];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1492,7 +1515,7 @@ void Game::deployEnemyFormation()
|
|||||||
mStage[mCurrentStage].enemyPool->set[set]->init[i].creationCounter,
|
mStage[mCurrentStage].enemyPool->set[set]->init[i].creationCounter,
|
||||||
mTextureBalloon);
|
mTextureBalloon);
|
||||||
|
|
||||||
mEnemyDeployCounter = 255;
|
mEnemyDeployCounter = 300;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2065,8 +2088,8 @@ void Game::destroyBalloon(Uint8 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otorga los puntos correspondientes al globo
|
// Otorga los puntos correspondientes al globo
|
||||||
mPlayer[0]->addScore(Uint32(score * mPlayer[0]->getScoreMultiplier() * mDifficultyScoreMultiplier));
|
for (int i = 0; i < mNumPlayers; i++)
|
||||||
//setScore(mPlayer[0]->getScore());
|
mPlayer[i]->addScore(Uint32(score * mPlayer[i]->getScoreMultiplier() * mDifficultyScoreMultiplier));
|
||||||
updateHiScore();
|
updateHiScore();
|
||||||
|
|
||||||
// Aumenta el poder de la fase
|
// Aumenta el poder de la fase
|
||||||
@@ -2259,7 +2282,7 @@ void Game::moveBullets()
|
|||||||
for (int i = 0; i < MAX_BULLETS; i++)
|
for (int i = 0; i < MAX_BULLETS; i++)
|
||||||
if (mBullet[i]->isActive())
|
if (mBullet[i]->isActive())
|
||||||
if (mBullet[i]->move() == MSG_BULLET_OUT)
|
if (mBullet[i]->move() == MSG_BULLET_OUT)
|
||||||
mPlayer[0]->decScoreMultiplier();
|
mPlayer[mBullet[i]->getOwner()]->decScoreMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pinta las balas activas
|
// Pinta las balas activas
|
||||||
@@ -2334,10 +2357,10 @@ void Game::resetItems()
|
|||||||
// Devuelve un item en función del azar
|
// Devuelve un item en función del azar
|
||||||
Uint8 Game::dropItem()
|
Uint8 Game::dropItem()
|
||||||
{
|
{
|
||||||
if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled))
|
//if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled))
|
||||||
return NO_KIND;
|
// return NO_KIND;
|
||||||
else
|
//else
|
||||||
return ITEM_COFFEE_MACHINE;
|
// return ITEM_COFFEE_MACHINE;
|
||||||
|
|
||||||
const Uint8 luckyNumber = rand() % 100;
|
const Uint8 luckyNumber = rand() % 100;
|
||||||
const Uint8 item = rand() % 6;
|
const Uint8 item = rand() % 6;
|
||||||
@@ -2861,7 +2884,7 @@ void Game::checkGameInput()
|
|||||||
if (mPlayer[i]->isAlive())
|
if (mPlayer[i]->isAlive())
|
||||||
{
|
{
|
||||||
// Input a la izquierda
|
// Input a la izquierda
|
||||||
if (mInput->checkInput(INPUT_LEFT, REPEAT_TRUE, mOptions->input[i]))
|
if (mInput->checkInput(INPUT_LEFT, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||||
{
|
{
|
||||||
mPlayer[i]->setInput(INPUT_LEFT);
|
mPlayer[i]->setInput(INPUT_LEFT);
|
||||||
mDemo.keys.left = 1;
|
mDemo.keys.left = 1;
|
||||||
@@ -2869,7 +2892,7 @@ void Game::checkGameInput()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Input a la derecha
|
// Input a la derecha
|
||||||
if (mInput->checkInput(INPUT_RIGHT, REPEAT_TRUE, mOptions->input[i]))
|
if (mInput->checkInput(INPUT_RIGHT, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||||
{
|
{
|
||||||
mPlayer[i]->setInput(INPUT_RIGHT);
|
mPlayer[i]->setInput(INPUT_RIGHT);
|
||||||
mDemo.keys.right = 1;
|
mDemo.keys.right = 1;
|
||||||
@@ -2882,7 +2905,7 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Comprueba el input de disparar al centro
|
// Comprueba el input de disparar al centro
|
||||||
if (mInput->checkInput(INPUT_BUTTON_2, REPEAT_TRUE, mOptions->input[i]))
|
if (mInput->checkInput(INPUT_BUTTON_2, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||||
{
|
{
|
||||||
if (mPlayer[i]->canFire())
|
if (mPlayer[i]->canFire())
|
||||||
{
|
{
|
||||||
@@ -2898,7 +2921,7 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de disparar a la izquierda
|
// Comprueba el input de disparar a la izquierda
|
||||||
if (mInput->checkInput(INPUT_BUTTON_1, REPEAT_TRUE, mOptions->input[i]))
|
if (mInput->checkInput(INPUT_BUTTON_1, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||||
{
|
{
|
||||||
if (mPlayer[i]->canFire())
|
if (mPlayer[i]->canFire())
|
||||||
{
|
{
|
||||||
@@ -2914,7 +2937,7 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de disparar a la derecha
|
// Comprueba el input de disparar a la derecha
|
||||||
if (mInput->checkInput(INPUT_BUTTON_3, REPEAT_TRUE, mOptions->input[i]))
|
if (mInput->checkInput(INPUT_BUTTON_3, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||||
{
|
{
|
||||||
if (mPlayer[i]->canFire())
|
if (mPlayer[i]->canFire())
|
||||||
{
|
{
|
||||||
@@ -2930,7 +2953,7 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de pausa
|
// Comprueba el input de pausa
|
||||||
if (mInput->checkInput(INPUT_CANCEL, REPEAT_FALSE, mOptions->input[i]))
|
if (mInput->checkInput(INPUT_CANCEL, REPEAT_FALSE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||||
{
|
{
|
||||||
mSection.subsection = GAME_SECTION_PAUSE;
|
mSection.subsection = GAME_SECTION_PAUSE;
|
||||||
|
|
||||||
@@ -2959,16 +2982,21 @@ void Game::renderMessages()
|
|||||||
{
|
{
|
||||||
mSpriteGetReady->setPosX((int)mGetReadyBitmapPath[mCounter]);
|
mSpriteGetReady->setPosX((int)mGetReadyBitmapPath[mCounter]);
|
||||||
//mSpriteGetReady->render();
|
//mSpriteGetReady->render();
|
||||||
const color_t color = {0x17, 0x17, 0x26};
|
//const color_t color = {0x17, 0x17, 0x26};
|
||||||
//mTextBig->writeShadowed((int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), color, 2);
|
//mTextBig->writeShadowed((int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), color, 2);
|
||||||
mTextBig->writeDX(TXT_STROKE, (int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), 1, noColor, 1, shdwTxtColor);
|
//mTextBig->writeDX(TXT_STROKE, (int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), 1, noColor, 1, shdwTxtColor);
|
||||||
|
mTextNokiaBig2->write((int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), -2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time Stopped
|
// Time Stopped
|
||||||
if (mTimeStopped)
|
if (mTimeStopped)
|
||||||
{
|
{
|
||||||
if ((mTimeStoppedCounter > 100) || (mTimeStoppedCounter % 10 > 4))
|
if ((mTimeStoppedCounter > 100) || (mTimeStoppedCounter % 10 > 4))
|
||||||
mText->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36) + std::to_string(mTimeStoppedCounter / 10), 1, noColor, 1, shdwTxtColor);
|
mTextNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36) + std::to_string(mTimeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor);
|
||||||
|
//{
|
||||||
|
// mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36), -2);
|
||||||
|
// mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y + mTextNokiaBig2->getCharacterWidth() + 2, std::to_string(mTimeStoppedCounter / 10), -2);
|
||||||
|
//}
|
||||||
|
|
||||||
if (mTimeStoppedCounter > 100)
|
if (mTimeStoppedCounter > 100)
|
||||||
{
|
{
|
||||||
@@ -2985,7 +3013,7 @@ void Game::renderMessages()
|
|||||||
// D E M O
|
// D E M O
|
||||||
if (mDemo.enabled)
|
if (mDemo.enabled)
|
||||||
if (mDemo.counter % 30 > 14)
|
if (mDemo.counter % 30 > 14)
|
||||||
mTextBig->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(37), 0, noColor, 2, shdwTxtColor);
|
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(37), 0, noColor, 2, shdwTxtColor);
|
||||||
|
|
||||||
// STAGE NUMBER
|
// STAGE NUMBER
|
||||||
if (mStageBitmapCounter < STAGE_COUNTER)
|
if (mStageBitmapCounter < STAGE_COUNTER)
|
||||||
@@ -2993,13 +3021,13 @@ void Game::renderMessages()
|
|||||||
std::string text = mLang->getText(38) + std::to_string(mStage[mCurrentStage].number);
|
std::string text = mLang->getText(38) + std::to_string(mStage[mCurrentStage].number);
|
||||||
if (!mGameCompleted)
|
if (!mGameCompleted)
|
||||||
{
|
{
|
||||||
mTextBig->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, 1, noColor, 2, shdwTxtColor);
|
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, -2, noColor, 2, shdwTxtColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Texto de juego completado
|
{ // Texto de juego completado
|
||||||
text = mLang->getText(50);
|
text = mLang->getText(50);
|
||||||
mTextBig->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, 1, noColor, 1, shdwTxtColor);
|
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, -2, noColor, 1, shdwTxtColor);
|
||||||
mText->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter] + 17, mLang->getText(76), 1, noColor, 1, shdwTxtColor);
|
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter] + mTextNokiaBig2->getCharacterWidth() + 2, mLang->getText(76), -1, noColor, 1, shdwTxtColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3108,62 +3136,6 @@ section_t Game::run()
|
|||||||
mSection.name = PROG_SECTION_QUIT;
|
mSection.name = PROG_SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((mEventHandler->type == SDL_KEYDOWN) && (mEventHandler->key.repeat == 0))
|
|
||||||
{
|
|
||||||
if (mDebug.enabled)
|
|
||||||
{
|
|
||||||
switch (mEventHandler->key.keysym.scancode)
|
|
||||||
{
|
|
||||||
case SDL_SCANCODE_F:
|
|
||||||
mDebug.enemySet--;
|
|
||||||
if (mDebug.enemySet == 255)
|
|
||||||
mDebug.enemySet = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_R:
|
|
||||||
mDebug.enemySet = std::min((int)++mDebug.enemySet, 9);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_T:
|
|
||||||
mTicksSpeed *= 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_G:
|
|
||||||
createNewBalloon(100, 0, BALLOON_1, BALLOON_VELX_POSITIVE, 1.0F, 0, mTextureBalloon);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_P:
|
|
||||||
popAllBalloons();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_Z:
|
|
||||||
incBalloonSpeed();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_X:
|
|
||||||
decBalloonSpeed();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_C:
|
|
||||||
mDebug.gradB += 10;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_I:
|
|
||||||
mPlayer[0]->setInvulnerable(true);
|
|
||||||
mPlayer[0]->setInvulnerableCounter(65000);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_M:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_N:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la lógica del juego
|
// Actualiza la lógica del juego
|
||||||
@@ -3271,6 +3243,9 @@ void Game::runPausedGame()
|
|||||||
// Bucle para la pantalla de game over
|
// Bucle para la pantalla de game over
|
||||||
void Game::runGameOverScreen()
|
void Game::runGameOverScreen()
|
||||||
{
|
{
|
||||||
|
// Guarda los puntos
|
||||||
|
saveScoreFile();
|
||||||
|
|
||||||
// Reinicia el menu
|
// Reinicia el menu
|
||||||
mMenuGameOver->reset();
|
mMenuGameOver->reset();
|
||||||
|
|
||||||
@@ -3327,8 +3302,17 @@ void Game::runGameOverScreen()
|
|||||||
SDL_RenderClear(mRenderer);
|
SDL_RenderClear(mRenderer);
|
||||||
|
|
||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
mTextBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), mLang->getText(43));
|
if (mNumPlayers == 1)
|
||||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), mLang->getText(44) + std::to_string(mPlayer[0]->getScore()));
|
{
|
||||||
|
mTextBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), mLang->getText(43));
|
||||||
|
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), mLang->getText(44) + std::to_string(mPlayer[0]->getScore()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTextBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - 36, mLang->getText(43));
|
||||||
|
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - 12, mLang->getText(77) + std::to_string(mPlayer[0]->getScore()));
|
||||||
|
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y, mLang->getText(78) + std::to_string(mPlayer[1]->getScore()));
|
||||||
|
}
|
||||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y + BLOCK * 2, mLang->getText(45));
|
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y + BLOCK * 2, mLang->getText(45));
|
||||||
mMenuGameOver->render();
|
mMenuGameOver->render();
|
||||||
mFade->render();
|
mFade->render();
|
||||||
@@ -3424,7 +3408,7 @@ void Game::initPaths()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Letrero de GetReady
|
// Letrero de GetReady
|
||||||
const int size = mTextBig->lenght(mLang->getText(75));
|
const int size = mTextNokiaBig2->lenght(mLang->getText(75), -2);
|
||||||
|
|
||||||
const float start1 = PLAY_AREA_LEFT - size;
|
const float start1 = PLAY_AREA_LEFT - size;
|
||||||
const float finish1 = PLAY_AREA_CENTER_X - (size / 2);
|
const float finish1 = PLAY_AREA_CENTER_X - (size / 2);
|
||||||
@@ -3467,6 +3451,7 @@ void Game::updateGameCompleted()
|
|||||||
// Actualiza las variables de ayuda
|
// Actualiza las variables de ayuda
|
||||||
void Game::updateHelper()
|
void Game::updateHelper()
|
||||||
{
|
{
|
||||||
|
// El ayudante solo funciona para un jugador
|
||||||
// Solo ofrece ayuda cuando la amenaza o la velocidad es elevada
|
// Solo ofrece ayuda cuando la amenaza o la velocidad es elevada
|
||||||
if (mMenaceCurrent > 15)
|
if (mMenaceCurrent > 15)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -108,10 +108,14 @@ private:
|
|||||||
LTexture *mTextureText; // Textura para el texto del juego
|
LTexture *mTextureText; // Textura para el texto del juego
|
||||||
LTexture *mTextureTextScoreBoard; // Textura para el texto del marcador
|
LTexture *mTextureTextScoreBoard; // Textura para el texto del marcador
|
||||||
LTexture *mTextureTextBig; // Textura para el texto grande
|
LTexture *mTextureTextBig; // Textura para el texto grande
|
||||||
|
LTexture *mTextureTextNokia2; // Textura para la fuente de texto Nokia
|
||||||
|
LTexture *mTextureTextNokiaBig2; // Textura para la fuente de texto Nokia grande
|
||||||
|
|
||||||
Text *mText; // Fuente para los textos del juego
|
Text *mText; // Fuente para los textos del juego
|
||||||
Text *mTextScoreBoard; // Fuente para el marcador del juego
|
|
||||||
Text *mTextBig; // Fuente de texto grande
|
Text *mTextBig; // Fuente de texto grande
|
||||||
|
Text *mTextScoreBoard; // Fuente para el marcador del juego
|
||||||
|
Text *mTextNokia2; // Otra fuente de texto para mesajes
|
||||||
|
Text *mTextNokiaBig2; // Y la versión en grande
|
||||||
|
|
||||||
Menu *mMenuGameOver; // Menú de la pantalla de game over
|
Menu *mMenuGameOver; // Menú de la pantalla de game over
|
||||||
Menu *mMenuPause; // Menú de la pantalla de pausa
|
Menu *mMenuPause; // Menú de la pantalla de pausa
|
||||||
@@ -176,7 +180,7 @@ private:
|
|||||||
SDL_Rect mGradientRect[4]; // Vector con las coordenadas de los 4 gradientes
|
SDL_Rect mGradientRect[4]; // Vector con las coordenadas de los 4 gradientes
|
||||||
Uint16 mBalloonsPopped; // Lleva la cuenta de los globos explotados
|
Uint16 mBalloonsPopped; // Lleva la cuenta de los globos explotados
|
||||||
Uint8 mLastEnemyDeploy; // Guarda cual ha sido la última formación desplegada para no repetir;
|
Uint8 mLastEnemyDeploy; // Guarda cual ha sido la última formación desplegada para no repetir;
|
||||||
Uint8 mEnemyDeployCounter; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero
|
int mEnemyDeployCounter; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero
|
||||||
float mEnemySpeed; // Velocidad a la que se mueven los enemigos
|
float mEnemySpeed; // Velocidad a la que se mueven los enemigos
|
||||||
float mDefaultEnemySpeed; // Velocidad base de los enemigos, sin incrementar
|
float mDefaultEnemySpeed; // Velocidad base de los enemigos, sin incrementar
|
||||||
effect_t mEffect; // Variable para gestionar los efectos visuales
|
effect_t mEffect; // Variable para gestionar los efectos visuales
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "/Library/Frameworks/SDL2.framework/Versions/A/Headers/SDL.h"
|
//#include "/Library/Frameworks/SDL2.framework/Versions/A/Headers/SDL.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
//#include <stdio.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
// Contestar cuantos joystics ha detectado
|
||||||
|
// Preguntarlepor los joystics que ha encontrado para ir poniendolos en la variable de opciones
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Input::Input(std::string file)
|
Input::Input(std::string file)
|
||||||
{
|
{
|
||||||
@@ -24,9 +26,8 @@ Input::Input(std::string file)
|
|||||||
// Destructor
|
// Destructor
|
||||||
Input::~Input()
|
Input::~Input()
|
||||||
{
|
{
|
||||||
//SDL_GameControllerClose(mGameController);
|
for (int i = 0; i < mNumGamepads; i++)
|
||||||
//if (mGameController)
|
mConnectedControllers[i] = nullptr;
|
||||||
mGameController = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||||
@@ -42,11 +43,14 @@ void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton butto
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool Input::checkInput(Uint8 input, bool repeat, int device)
|
bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||||
{
|
{
|
||||||
bool successKeyboard = false;
|
bool successKeyboard = false;
|
||||||
bool successGameController = false;
|
bool successGameController = false;
|
||||||
|
|
||||||
|
if (device == INPUT_USE_ANY)
|
||||||
|
index = 0;
|
||||||
|
|
||||||
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
|
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
|
||||||
{
|
{
|
||||||
const Uint8 *mKeystates = SDL_GetKeyboardState(NULL);
|
const Uint8 *mKeystates = SDL_GetKeyboardState(NULL);
|
||||||
@@ -92,7 +96,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device)
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(mGameController, mGameControllerBindings[input].button) != 0)
|
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
else
|
else
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
@@ -101,7 +105,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device)
|
|||||||
{
|
{
|
||||||
if (!mGameControllerBindings[input].active)
|
if (!mGameControllerBindings[input].active)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(mGameController, mGameControllerBindings[input].button) != 0)
|
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
||||||
{
|
{
|
||||||
mGameControllerBindings[input].active = true;
|
mGameControllerBindings[input].active = true;
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
@@ -113,7 +117,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(mGameController, mGameControllerBindings[input].button) == 0)
|
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) == 0)
|
||||||
{
|
{
|
||||||
mGameControllerBindings[input].active = false;
|
mGameControllerBindings[input].active = false;
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
@@ -137,6 +141,9 @@ bool Input::discoverGameController()
|
|||||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1)
|
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1)
|
||||||
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||||
|
|
||||||
|
if (SDL_GameControllerAddMappingsFromFile(mDBpath.c_str()) < 0)
|
||||||
|
printf("Error, could not load %s file: %s\n", mDBpath.c_str(), SDL_GetError());
|
||||||
|
|
||||||
int nJoysticks = SDL_NumJoysticks();
|
int nJoysticks = SDL_NumJoysticks();
|
||||||
mNumGamepads = 0;
|
mNumGamepads = 0;
|
||||||
|
|
||||||
@@ -159,18 +166,19 @@ bool Input::discoverGameController()
|
|||||||
if (SDL_GameControllerGetAttached(pad) == 1)
|
if (SDL_GameControllerGetAttached(pad) == 1)
|
||||||
{
|
{
|
||||||
mConnectedControllers.push_back(pad);
|
mConnectedControllers.push_back(pad);
|
||||||
|
std::string separator(" #");
|
||||||
std::string name = SDL_GameControllerNameForIndex(i);
|
std::string name = SDL_GameControllerNameForIndex(i);
|
||||||
std::cout << SDL_GameControllerNameForIndex(i) << std::endl;
|
|
||||||
name.resize(25);
|
name.resize(25);
|
||||||
|
name = name + separator + std::to_string(i);
|
||||||
|
std::cout << name << std::endl;
|
||||||
mControllerNames.push_back(name);
|
mControllerNames.push_back(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGameController = mConnectedControllers[0];
|
//mGameController = mConnectedControllers[0];
|
||||||
SDL_GameControllerEventState(SDL_ENABLE);
|
SDL_GameControllerEventState(SDL_ENABLE);
|
||||||
SDL_GameControllerAddMappingsFromFile(mDBpath.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
@@ -191,5 +199,11 @@ std::string Input::getControllerName(int index)
|
|||||||
if (mNumGamepads > 0)
|
if (mNumGamepads > 0)
|
||||||
return mControllerNames[index];
|
return mControllerNames[index];
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obten el numero de mandos conectados
|
||||||
|
int Input::getNumControllers()
|
||||||
|
{
|
||||||
|
return mNumGamepads;
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ private:
|
|||||||
};
|
};
|
||||||
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||||
|
|
||||||
SDL_GameController *mGameController; // Manejador para el mando
|
//SDL_GameController *mGameController; // Manejador para el mando
|
||||||
std::vector<SDL_GameController*> mConnectedControllers;
|
std::vector<SDL_GameController*> mConnectedControllers;
|
||||||
std::vector<std::string> mControllerNames;
|
std::vector<std::string> mControllerNames;
|
||||||
int mNumGamepads;
|
int mNumGamepads;
|
||||||
@@ -72,11 +72,14 @@ public:
|
|||||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool checkInput(Uint8 input, bool repeat, int device=INPUT_USE_ANY);
|
bool checkInput(Uint8 input, bool repeat, int device=INPUT_USE_ANY, int index=0);
|
||||||
|
|
||||||
// Comprueba si hay algun mando conectado
|
// Comprueba si hay algun mando conectado
|
||||||
bool gameControllerFound();
|
bool gameControllerFound();
|
||||||
|
|
||||||
|
// Obten el numero de mandos conectados
|
||||||
|
int getNumControllers();
|
||||||
|
|
||||||
// Obten el nombre de un mando de juego
|
// Obten el nombre de un mando de juego
|
||||||
std::string getControllerName(int index);
|
std::string getControllerName(int index);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
# define INIT_FADE 100
|
||||||
|
# define END_LOGO 200
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(SDL_Renderer *renderer, std::string *fileList)
|
Logo::Logo(SDL_Renderer *renderer, std::string *fileList)
|
||||||
{
|
{
|
||||||
@@ -71,6 +74,7 @@ section_t Logo::run()
|
|||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
const SDL_Rect rect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
const SDL_Rect rect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
||||||
|
const int fadeLenght = END_LOGO - INIT_FADE;
|
||||||
|
|
||||||
while (mSection.name == PROG_SECTION_LOGO)
|
while (mSection.name == PROG_SECTION_LOGO)
|
||||||
{
|
{
|
||||||
@@ -92,9 +96,6 @@ section_t Logo::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el destino donde se pinta todo
|
|
||||||
//SDL_SetRenderTarget(mRenderer, mBackbuffer);
|
|
||||||
|
|
||||||
// Limpia el destino
|
// Limpia el destino
|
||||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||||
SDL_RenderClear(mRenderer);
|
SDL_RenderClear(mRenderer);
|
||||||
@@ -103,22 +104,16 @@ section_t Logo::run()
|
|||||||
mSprite->render();
|
mSprite->render();
|
||||||
|
|
||||||
// Dibuja el fade
|
// Dibuja el fade
|
||||||
if (mCounter >= 200)
|
if (mCounter >= INIT_FADE)
|
||||||
{
|
{
|
||||||
Uint16 alpha = mCounter - 200;
|
Uint16 alpha = (255 * (mCounter - INIT_FADE)) / fadeLenght;
|
||||||
if (alpha < 256)
|
if (alpha < 256)
|
||||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, alpha);
|
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, alpha);
|
||||||
else
|
else
|
||||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255); // alpha - 0 trans, 255 opaco
|
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||||
SDL_RenderFillRect(mRenderer, &rect);
|
SDL_RenderFillRect(mRenderer, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vuelve a usar el renderizador como destino
|
|
||||||
//SDL_SetRenderTarget(mRenderer, NULL);
|
|
||||||
|
|
||||||
// Copia el backbufer al renderizador
|
|
||||||
//SDL_RenderCopy(mRenderer, mBackbuffer, NULL, NULL);
|
|
||||||
|
|
||||||
// Actualiza la pantalla
|
// Actualiza la pantalla
|
||||||
SDL_RenderPresent(mRenderer);
|
SDL_RenderPresent(mRenderer);
|
||||||
|
|
||||||
@@ -134,7 +129,7 @@ section_t Logo::run()
|
|||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCounter == 500) // minimo 200 + 255
|
if (mCounter == END_LOGO + 20)
|
||||||
{
|
{
|
||||||
mCounter = 0;
|
mCounter = 0;
|
||||||
mSection.name = PROG_SECTION_INTRO;
|
mSection.name = PROG_SECTION_INTRO;
|
||||||
|
|||||||
@@ -36,13 +36,9 @@ un tipo asociado diferente a NO_KIND
|
|||||||
|
|
||||||
#include "director.h"
|
#include "director.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
int main(int argc, char *args[])
|
int main(int argc, char *args[])
|
||||||
{
|
{
|
||||||
// Inicia el generador de numeros aleatorios
|
|
||||||
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
|
||||||
|
|
||||||
printf("Starting the game...\n\n");
|
printf("Starting the game...\n\n");
|
||||||
|
|
||||||
// Crea el objeto Director
|
// Crea el objeto Director
|
||||||
@@ -54,6 +50,7 @@ int main(int argc, char *args[])
|
|||||||
// Destruye el objeto Director
|
// Destruye el objeto Director
|
||||||
delete mDirector;
|
delete mDirector;
|
||||||
mDirector = nullptr;
|
mDirector = nullptr;
|
||||||
|
|
||||||
printf("\nShutting down the game...\n");
|
printf("\nShutting down the game...\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -227,11 +227,21 @@ bool Menu::increaseSelectorIndex()
|
|||||||
mSelector.h = mSelector.originH = getSelectorHeight(mSelector.index);
|
mSelector.h = mSelector.originH = getSelectorHeight(mSelector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
if (mSelector.index < (mTotalItems - 1))
|
//if (mSelector.index < (mTotalItems - 1))
|
||||||
|
//{
|
||||||
|
// mSelector.index++;
|
||||||
|
// while ((!mItem[mSelector.index].selectable) && (mSelector.index < (mTotalItems - 1)))
|
||||||
|
// mSelector.index++;
|
||||||
|
// success = true;
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Calcula cual es el siguiente elemento (versión con loop)
|
||||||
|
//if (mSelector.index < (mTotalItems - 1))
|
||||||
{
|
{
|
||||||
mSelector.index++;
|
++mSelector.index %= mTotalItems;
|
||||||
while ((!mItem[mSelector.index].selectable) && (mSelector.index < (mTotalItems - 1)))
|
while (!mItem[mSelector.index].selectable)
|
||||||
mSelector.index++;
|
//mSelector.index++;
|
||||||
|
++mSelector.index %= mTotalItems;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,11 +271,28 @@ bool Menu::decreaseSelectorIndex()
|
|||||||
mSelector.h = mSelector.originH = getSelectorHeight(mSelector.index);
|
mSelector.h = mSelector.originH = getSelectorHeight(mSelector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
if (mSelector.index > 0)
|
//if (mSelector.index > 0)
|
||||||
|
//{
|
||||||
|
// mSelector.index--;
|
||||||
|
// while ((!mItem[mSelector.index].selectable) && (mSelector.index > 0))
|
||||||
|
// mSelector.index--;
|
||||||
|
// success = true;
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Calcula cual es el siguiente elemento (versión con loop)
|
||||||
|
//if (mSelector.index > 0)
|
||||||
{
|
{
|
||||||
mSelector.index--;
|
if (mSelector.index == 0)
|
||||||
while ((!mItem[mSelector.index].selectable) && (mSelector.index > 0))
|
mSelector.index = mTotalItems;
|
||||||
|
else
|
||||||
mSelector.index--;
|
mSelector.index--;
|
||||||
|
while (!mItem[mSelector.index].selectable)
|
||||||
|
{
|
||||||
|
if (mSelector.index == 0)
|
||||||
|
mSelector.index = mTotalItems;
|
||||||
|
else
|
||||||
|
mSelector.index--;
|
||||||
|
}
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* stb_image - v2.26 - public domain image loader - http://nothings.org/stb
|
/* stb_image - v2.27 - public domain image loader - http://nothings.org/stb
|
||||||
no warranty implied; use at your own risk
|
no warranty implied; use at your own risk
|
||||||
|
|
||||||
Do this:
|
Do this:
|
||||||
@@ -48,6 +48,7 @@ LICENSE
|
|||||||
|
|
||||||
RECENT REVISION HISTORY:
|
RECENT REVISION HISTORY:
|
||||||
|
|
||||||
|
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
|
||||||
2.26 (2020-07-13) many minor fixes
|
2.26 (2020-07-13) many minor fixes
|
||||||
2.25 (2020-02-02) fix warnings
|
2.25 (2020-02-02) fix warnings
|
||||||
2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically
|
2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically
|
||||||
@@ -89,7 +90,7 @@ RECENT REVISION HISTORY:
|
|||||||
Jeremy Sawicki (handle all ImageNet JPGs)
|
Jeremy Sawicki (handle all ImageNet JPGs)
|
||||||
Optimizations & bugfixes Mikhail Morozov (1-bit BMP)
|
Optimizations & bugfixes Mikhail Morozov (1-bit BMP)
|
||||||
Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query)
|
Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query)
|
||||||
Arseny Kapoulkine
|
Arseny Kapoulkine Simon Breuss (16-bit PNM)
|
||||||
John-Mark Allen
|
John-Mark Allen
|
||||||
Carmelo J Fdez-Aguera
|
Carmelo J Fdez-Aguera
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ RECENT REVISION HISTORY:
|
|||||||
Thomas Ruf Ronny Chevalier github:rlyeh
|
Thomas Ruf Ronny Chevalier github:rlyeh
|
||||||
Janez Zemva John Bartholomew Michal Cichon github:romigrou
|
Janez Zemva John Bartholomew Michal Cichon github:romigrou
|
||||||
Jonathan Blow Ken Hamada Tero Hanninen github:svdijk
|
Jonathan Blow Ken Hamada Tero Hanninen github:svdijk
|
||||||
Laurent Gomila Cort Stratton github:snagar
|
Eugene Golushkov Laurent Gomila Cort Stratton github:snagar
|
||||||
Aruelien Pocheville Sergio Gonzalez Thibault Reuille github:Zelex
|
Aruelien Pocheville Sergio Gonzalez Thibault Reuille github:Zelex
|
||||||
Cass Everitt Ryamond Barbiero github:grim210
|
Cass Everitt Ryamond Barbiero github:grim210
|
||||||
Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw
|
Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw
|
||||||
@@ -110,11 +111,13 @@ RECENT REVISION HISTORY:
|
|||||||
Josh Tobin Matthew Gregan github:poppolopoppo
|
Josh Tobin Matthew Gregan github:poppolopoppo
|
||||||
Julian Raschke Gregory Mullen Christian Floisand github:darealshinji
|
Julian Raschke Gregory Mullen Christian Floisand github:darealshinji
|
||||||
Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007
|
Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007
|
||||||
Brad Weinberger Matvey Cherevko [reserved]
|
Brad Weinberger Matvey Cherevko github:mosra
|
||||||
Luca Sas Alexander Veselov Zack Middleton [reserved]
|
Luca Sas Alexander Veselov Zack Middleton [reserved]
|
||||||
Ryan C. Gordon [reserved] [reserved]
|
Ryan C. Gordon [reserved] [reserved]
|
||||||
DO NOT ADD YOUR NAME HERE
|
DO NOT ADD YOUR NAME HERE
|
||||||
|
|
||||||
|
Jacko Dirks
|
||||||
|
|
||||||
To add your name to the credits, pick a random blank space in the middle and fill it.
|
To add your name to the credits, pick a random blank space in the middle and fill it.
|
||||||
80% of merge conflicts on stb PRs are due to people adding their name at the end
|
80% of merge conflicts on stb PRs are due to people adding their name at the end
|
||||||
of the credits.
|
of the credits.
|
||||||
@@ -176,6 +179,32 @@ RECENT REVISION HISTORY:
|
|||||||
//
|
//
|
||||||
// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
|
// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
|
||||||
//
|
//
|
||||||
|
// To query the width, height and component count of an image without having to
|
||||||
|
// decode the full file, you can use the stbi_info family of functions:
|
||||||
|
//
|
||||||
|
// int x,y,n,ok;
|
||||||
|
// ok = stbi_info(filename, &x, &y, &n);
|
||||||
|
// // returns ok=1 and sets x, y, n if image is a supported format,
|
||||||
|
// // 0 otherwise.
|
||||||
|
//
|
||||||
|
// Note that stb_image pervasively uses ints in its public API for sizes,
|
||||||
|
// including sizes of memory buffers. This is now part of the API and thus
|
||||||
|
// hard to change without causing breakage. As a result, the various image
|
||||||
|
// loaders all have certain limits on image size; these differ somewhat
|
||||||
|
// by format but generally boil down to either just under 2GB or just under
|
||||||
|
// 1GB. When the decoded image would be larger than this, stb_image decoding
|
||||||
|
// will fail.
|
||||||
|
//
|
||||||
|
// Additionally, stb_image will reject image files that have any of their
|
||||||
|
// dimensions set to a larger value than the configurable STBI_MAX_DIMENSIONS,
|
||||||
|
// which defaults to 2**24 = 16777216 pixels. Due to the above memory limit,
|
||||||
|
// the only way to have an image with such dimensions load correctly
|
||||||
|
// is for it to have a rather extreme aspect ratio. Either way, the
|
||||||
|
// assumption here is that such larger images are likely to be malformed
|
||||||
|
// or malicious. If you do need to load an image with individual dimensions
|
||||||
|
// larger than that, and it still fits in the overall size limit, you can
|
||||||
|
// #define STBI_MAX_DIMENSIONS on your own to be something larger.
|
||||||
|
//
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
//
|
//
|
||||||
// UNICODE:
|
// UNICODE:
|
||||||
@@ -281,11 +310,10 @@ RECENT REVISION HISTORY:
|
|||||||
//
|
//
|
||||||
// iPhone PNG support:
|
// iPhone PNG support:
|
||||||
//
|
//
|
||||||
// By default we convert iphone-formatted PNGs back to RGB, even though
|
// We optionally support converting iPhone-formatted PNGs (which store
|
||||||
// they are internally encoded differently. You can disable this conversion
|
// premultiplied BGRA) back to RGB, even though they're internally encoded
|
||||||
// by calling stbi_convert_iphone_png_to_rgb(0), in which case
|
// differently. To enable this conversion, call
|
||||||
// you will always just get the native iphone "format" through (which
|
// stbi_convert_iphone_png_to_rgb(1).
|
||||||
// is BGR stored in RGB).
|
|
||||||
//
|
//
|
||||||
// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per
|
// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per
|
||||||
// pixel to remove any premultiplied alpha *only* if the image file explicitly
|
// pixel to remove any premultiplied alpha *only* if the image file explicitly
|
||||||
@@ -489,6 +517,8 @@ STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip);
|
|||||||
// as above, but only applies to images loaded on the thread that calls the function
|
// as above, but only applies to images loaded on the thread that calls the function
|
||||||
// this function is only available if your compiler supports thread-local variables;
|
// this function is only available if your compiler supports thread-local variables;
|
||||||
// calling it will fail to link if your compiler doesn't
|
// calling it will fail to link if your compiler doesn't
|
||||||
|
STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply);
|
||||||
|
STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert);
|
||||||
STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip);
|
STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip);
|
||||||
|
|
||||||
// ZLIB client - used by PNG, available for other purposes
|
// ZLIB client - used by PNG, available for other purposes
|
||||||
@@ -634,7 +664,7 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
|
|||||||
#ifdef STBI_HAS_LROTL
|
#ifdef STBI_HAS_LROTL
|
||||||
#define stbi_lrot(x,y) _lrotl(x,y)
|
#define stbi_lrot(x,y) _lrotl(x,y)
|
||||||
#else
|
#else
|
||||||
#define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y))))
|
#define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (-(y) & 31)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED))
|
#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED))
|
||||||
@@ -748,9 +778,12 @@ static int stbi__sse2_available(void)
|
|||||||
|
|
||||||
#ifdef STBI_NEON
|
#ifdef STBI_NEON
|
||||||
#include <arm_neon.h>
|
#include <arm_neon.h>
|
||||||
// assume GCC or Clang on ARM targets
|
#ifdef _MSC_VER
|
||||||
|
#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name
|
||||||
|
#else
|
||||||
#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
|
#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef STBI_SIMD_ALIGN
|
#ifndef STBI_SIMD_ALIGN
|
||||||
#define STBI_SIMD_ALIGN(type, name) type name
|
#define STBI_SIMD_ALIGN(type, name) type name
|
||||||
@@ -924,6 +957,7 @@ static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp);
|
|||||||
static int stbi__pnm_test(stbi__context *s);
|
static int stbi__pnm_test(stbi__context *s);
|
||||||
static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
|
static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
|
||||||
static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);
|
static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);
|
||||||
|
static int stbi__pnm_is16(stbi__context *s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -998,7 +1032,7 @@ static int stbi__mad3sizes_valid(int a, int b, int c, int add)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
|
// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
|
||||||
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
|
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM)
|
||||||
static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
|
static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
|
||||||
{
|
{
|
||||||
return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
|
return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
|
||||||
@@ -1021,7 +1055,7 @@ static void *stbi__malloc_mad3(int a, int b, int c, int add)
|
|||||||
return stbi__malloc(a*b*c + add);
|
return stbi__malloc(a*b*c + add);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
|
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM)
|
||||||
static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
|
static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
|
||||||
{
|
{
|
||||||
if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
|
if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
|
||||||
@@ -1087,9 +1121,8 @@ static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int re
|
|||||||
ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order
|
ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order
|
||||||
ri->num_channels = 0;
|
ri->num_channels = 0;
|
||||||
|
|
||||||
#ifndef STBI_NO_JPEG
|
// test the formats with a very explicit header first (at least a FOURCC
|
||||||
if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri);
|
// or distinctive magic number first)
|
||||||
#endif
|
|
||||||
#ifndef STBI_NO_PNG
|
#ifndef STBI_NO_PNG
|
||||||
if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri);
|
if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri);
|
||||||
#endif
|
#endif
|
||||||
@@ -1107,6 +1140,13 @@ static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int re
|
|||||||
#ifndef STBI_NO_PIC
|
#ifndef STBI_NO_PIC
|
||||||
if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri);
|
if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// then the formats that can end up attempting to load with just 1 or 2
|
||||||
|
// bytes matching expectations; these are prone to false positives, so
|
||||||
|
// try them later
|
||||||
|
#ifndef STBI_NO_JPEG
|
||||||
|
if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri);
|
||||||
|
#endif
|
||||||
#ifndef STBI_NO_PNM
|
#ifndef STBI_NO_PNM
|
||||||
if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri);
|
if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri);
|
||||||
#endif
|
#endif
|
||||||
@@ -1262,12 +1302,12 @@ static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, in
|
|||||||
|
|
||||||
#ifndef STBI_NO_STDIO
|
#ifndef STBI_NO_STDIO
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
|
#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8)
|
||||||
STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
|
STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
|
||||||
STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
|
STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
|
#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8)
|
||||||
STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
|
STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
|
||||||
{
|
{
|
||||||
return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
|
return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
|
||||||
@@ -1277,16 +1317,16 @@ STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wch
|
|||||||
static FILE *stbi__fopen(char const *filename, char const *mode)
|
static FILE *stbi__fopen(char const *filename, char const *mode)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
|
#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8)
|
||||||
wchar_t wMode[64];
|
wchar_t wMode[64];
|
||||||
wchar_t wFilename[1024];
|
wchar_t wFilename[1024];
|
||||||
if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))
|
if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))
|
if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#if _MSC_VER >= 1400
|
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||||
if (0 != _wfopen_s(&f, wFilename, wMode))
|
if (0 != _wfopen_s(&f, wFilename, wMode))
|
||||||
f = 0;
|
f = 0;
|
||||||
#else
|
#else
|
||||||
@@ -1662,7 +1702,8 @@ static int stbi__get16le(stbi__context *s)
|
|||||||
static stbi__uint32 stbi__get32le(stbi__context *s)
|
static stbi__uint32 stbi__get32le(stbi__context *s)
|
||||||
{
|
{
|
||||||
stbi__uint32 z = stbi__get16le(s);
|
stbi__uint32 z = stbi__get16le(s);
|
||||||
return z + (stbi__get16le(s) << 16);
|
z += (stbi__uint32)stbi__get16le(s) << 16;
|
||||||
|
return z;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2090,13 +2131,12 @@ stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n)
|
|||||||
int sgn;
|
int sgn;
|
||||||
if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
|
if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
|
||||||
|
|
||||||
sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB
|
sgn = j->code_buffer >> 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative)
|
||||||
k = stbi_lrot(j->code_buffer, n);
|
k = stbi_lrot(j->code_buffer, n);
|
||||||
if (n < 0 || n >= (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))) return 0;
|
|
||||||
j->code_buffer = k & ~stbi__bmask[n];
|
j->code_buffer = k & ~stbi__bmask[n];
|
||||||
k &= stbi__bmask[n];
|
k &= stbi__bmask[n];
|
||||||
j->code_bits -= n;
|
j->code_bits -= n;
|
||||||
return k + (stbi__jbias[n] & ~sgn);
|
return k + (stbi__jbias[n] & (sgn - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get some unsigned bits
|
// get some unsigned bits
|
||||||
@@ -2146,7 +2186,7 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman
|
|||||||
|
|
||||||
if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
|
if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
|
||||||
t = stbi__jpeg_huff_decode(j, hdc);
|
t = stbi__jpeg_huff_decode(j, hdc);
|
||||||
if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG");
|
if (t < 0 || t > 15) return stbi__err("bad huffman code","Corrupt JPEG");
|
||||||
|
|
||||||
// 0 all the ac values now so we can do it 32-bits at a time
|
// 0 all the ac values now so we can do it 32-bits at a time
|
||||||
memset(data,0,64*sizeof(data[0]));
|
memset(data,0,64*sizeof(data[0]));
|
||||||
@@ -2203,12 +2243,12 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__
|
|||||||
// first scan for DC coefficient, must be first
|
// first scan for DC coefficient, must be first
|
||||||
memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
|
memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
|
||||||
t = stbi__jpeg_huff_decode(j, hdc);
|
t = stbi__jpeg_huff_decode(j, hdc);
|
||||||
if (t == -1) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
|
if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
|
||||||
diff = t ? stbi__extend_receive(j, t) : 0;
|
diff = t ? stbi__extend_receive(j, t) : 0;
|
||||||
|
|
||||||
dc = j->img_comp[b].dc_pred + diff;
|
dc = j->img_comp[b].dc_pred + diff;
|
||||||
j->img_comp[b].dc_pred = dc;
|
j->img_comp[b].dc_pred = dc;
|
||||||
data[0] = (short) (dc << j->succ_low);
|
data[0] = (short) (dc * (1 << j->succ_low));
|
||||||
} else {
|
} else {
|
||||||
// refinement scan for DC coefficient
|
// refinement scan for DC coefficient
|
||||||
if (stbi__jpeg_get_bit(j))
|
if (stbi__jpeg_get_bit(j))
|
||||||
@@ -2245,7 +2285,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__
|
|||||||
j->code_buffer <<= s;
|
j->code_buffer <<= s;
|
||||||
j->code_bits -= s;
|
j->code_bits -= s;
|
||||||
zig = stbi__jpeg_dezigzag[k++];
|
zig = stbi__jpeg_dezigzag[k++];
|
||||||
data[zig] = (short) ((r >> 8) << shift);
|
data[zig] = (short) ((r >> 8) * (1 << shift));
|
||||||
} else {
|
} else {
|
||||||
int rs = stbi__jpeg_huff_decode(j, hac);
|
int rs = stbi__jpeg_huff_decode(j, hac);
|
||||||
if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
|
if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
|
||||||
@@ -2263,7 +2303,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__
|
|||||||
} else {
|
} else {
|
||||||
k += r;
|
k += r;
|
||||||
zig = stbi__jpeg_dezigzag[k++];
|
zig = stbi__jpeg_dezigzag[k++];
|
||||||
data[zig] = (short) (stbi__extend_receive(j,s) << shift);
|
data[zig] = (short) (stbi__extend_receive(j,s) * (1 << shift));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (k <= j->spec_end);
|
} while (k <= j->spec_end);
|
||||||
@@ -3227,6 +3267,13 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan)
|
|||||||
if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
|
if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check that plane subsampling factors are integer ratios; our resamplers can't deal with fractional ratios
|
||||||
|
// and I've never seen a non-corrupted JPEG file actually use them
|
||||||
|
for (i=0; i < s->img_n; ++i) {
|
||||||
|
if (h_max % z->img_comp[i].h != 0) return stbi__err("bad H","Corrupt JPEG");
|
||||||
|
if (v_max % z->img_comp[i].v != 0) return stbi__err("bad V","Corrupt JPEG");
|
||||||
|
}
|
||||||
|
|
||||||
// compute interleaved mcu info
|
// compute interleaved mcu info
|
||||||
z->img_h_max = h_max;
|
z->img_h_max = h_max;
|
||||||
z->img_v_max = v_max;
|
z->img_v_max = v_max;
|
||||||
@@ -3782,6 +3829,10 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp
|
|||||||
else
|
else
|
||||||
decode_n = z->s->img_n;
|
decode_n = z->s->img_n;
|
||||||
|
|
||||||
|
// nothing to do if no components requested; check this now to avoid
|
||||||
|
// accessing uninitialized coutput[0] later
|
||||||
|
if (decode_n <= 0) { stbi__cleanup_jpeg(z); return NULL; }
|
||||||
|
|
||||||
// resample and color-convert
|
// resample and color-convert
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
@@ -3924,6 +3975,7 @@ static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int re
|
|||||||
{
|
{
|
||||||
unsigned char* result;
|
unsigned char* result;
|
||||||
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
|
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
|
||||||
|
if (!j) return stbi__errpuc("outofmem", "Out of memory");
|
||||||
STBI_NOTUSED(ri);
|
STBI_NOTUSED(ri);
|
||||||
j->s = s;
|
j->s = s;
|
||||||
stbi__setup_jpeg(j);
|
stbi__setup_jpeg(j);
|
||||||
@@ -3936,6 +3988,7 @@ static int stbi__jpeg_test(stbi__context *s)
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
|
stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
|
||||||
|
if (!j) return stbi__err("outofmem", "Out of memory");
|
||||||
j->s = s;
|
j->s = s;
|
||||||
stbi__setup_jpeg(j);
|
stbi__setup_jpeg(j);
|
||||||
r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
|
r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
|
||||||
@@ -3960,6 +4013,7 @@ static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
|
stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
|
||||||
|
if (!j) return stbi__err("outofmem", "Out of memory");
|
||||||
j->s = s;
|
j->s = s;
|
||||||
result = stbi__jpeg_info_raw(j, x, y, comp);
|
result = stbi__jpeg_info_raw(j, x, y, comp);
|
||||||
STBI_FREE(j);
|
STBI_FREE(j);
|
||||||
@@ -3979,6 +4033,7 @@ static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
|
|||||||
// fast-way is faster to check than jpeg huffman, but slow way is slower
|
// fast-way is faster to check than jpeg huffman, but slow way is slower
|
||||||
#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables
|
#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables
|
||||||
#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1)
|
#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1)
|
||||||
|
#define STBI__ZNSYMS 288 // number of symbols in literal/length alphabet
|
||||||
|
|
||||||
// zlib-style huffman encoding
|
// zlib-style huffman encoding
|
||||||
// (jpegs packs from left, zlib from right, so can't share code)
|
// (jpegs packs from left, zlib from right, so can't share code)
|
||||||
@@ -3988,8 +4043,8 @@ typedef struct
|
|||||||
stbi__uint16 firstcode[16];
|
stbi__uint16 firstcode[16];
|
||||||
int maxcode[17];
|
int maxcode[17];
|
||||||
stbi__uint16 firstsymbol[16];
|
stbi__uint16 firstsymbol[16];
|
||||||
stbi_uc size[288];
|
stbi_uc size[STBI__ZNSYMS];
|
||||||
stbi__uint16 value[288];
|
stbi__uint16 value[STBI__ZNSYMS];
|
||||||
} stbi__zhuffman;
|
} stbi__zhuffman;
|
||||||
|
|
||||||
stbi_inline static int stbi__bitreverse16(int n)
|
stbi_inline static int stbi__bitreverse16(int n)
|
||||||
@@ -4120,7 +4175,7 @@ static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z)
|
|||||||
if (s >= 16) return -1; // invalid code!
|
if (s >= 16) return -1; // invalid code!
|
||||||
// code size is s, so:
|
// code size is s, so:
|
||||||
b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];
|
b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];
|
||||||
if (b >= sizeof (z->size)) return -1; // some data was corrupt somewhere!
|
if (b >= STBI__ZNSYMS) return -1; // some data was corrupt somewhere!
|
||||||
if (z->size[b] != s) return -1; // was originally an assert, but report failure instead.
|
if (z->size[b] != s) return -1; // was originally an assert, but report failure instead.
|
||||||
a->code_buffer >>= s;
|
a->code_buffer >>= s;
|
||||||
a->num_bits -= s;
|
a->num_bits -= s;
|
||||||
@@ -4317,7 +4372,7 @@ static int stbi__parse_zlib_header(stbi__zbuf *a)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const stbi_uc stbi__zdefault_length[288] =
|
static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] =
|
||||||
{
|
{
|
||||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||||
@@ -4363,7 +4418,7 @@ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header)
|
|||||||
} else {
|
} else {
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
// use fixed code lengths
|
// use fixed code lengths
|
||||||
if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0;
|
if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , STBI__ZNSYMS)) return 0;
|
||||||
if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0;
|
if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0;
|
||||||
} else {
|
} else {
|
||||||
if (!stbi__compute_huffman_codes(a)) return 0;
|
if (!stbi__compute_huffman_codes(a)) return 0;
|
||||||
@@ -4759,6 +4814,7 @@ static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint3
|
|||||||
|
|
||||||
// de-interlacing
|
// de-interlacing
|
||||||
final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0);
|
final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0);
|
||||||
|
if (!final) return stbi__err("outofmem", "Out of memory");
|
||||||
for (p=0; p < 7; ++p) {
|
for (p=0; p < 7; ++p) {
|
||||||
int xorig[] = { 0,4,0,2,0,1,0 };
|
int xorig[] = { 0,4,0,2,0,1,0 };
|
||||||
int yorig[] = { 0,0,4,0,2,0,1 };
|
int yorig[] = { 0,0,4,0,2,0,1 };
|
||||||
@@ -4879,19 +4935,46 @@ static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stbi__unpremultiply_on_load = 0;
|
static int stbi__unpremultiply_on_load_global = 0;
|
||||||
static int stbi__de_iphone_flag = 0;
|
static int stbi__de_iphone_flag_global = 0;
|
||||||
|
|
||||||
STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply)
|
STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply)
|
||||||
{
|
{
|
||||||
stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply;
|
stbi__unpremultiply_on_load_global = flag_true_if_should_unpremultiply;
|
||||||
}
|
}
|
||||||
|
|
||||||
STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert)
|
STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert)
|
||||||
{
|
{
|
||||||
stbi__de_iphone_flag = flag_true_if_should_convert;
|
stbi__de_iphone_flag_global = flag_true_if_should_convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef STBI_THREAD_LOCAL
|
||||||
|
#define stbi__unpremultiply_on_load stbi__unpremultiply_on_load_global
|
||||||
|
#define stbi__de_iphone_flag stbi__de_iphone_flag_global
|
||||||
|
#else
|
||||||
|
static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set;
|
||||||
|
static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set;
|
||||||
|
|
||||||
|
STBIDEF void stbi__unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply)
|
||||||
|
{
|
||||||
|
stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply;
|
||||||
|
stbi__unpremultiply_on_load_set = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert)
|
||||||
|
{
|
||||||
|
stbi__de_iphone_flag_local = flag_true_if_should_convert;
|
||||||
|
stbi__de_iphone_flag_set = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define stbi__unpremultiply_on_load (stbi__unpremultiply_on_load_set \
|
||||||
|
? stbi__unpremultiply_on_load_local \
|
||||||
|
: stbi__unpremultiply_on_load_global)
|
||||||
|
#define stbi__de_iphone_flag (stbi__de_iphone_flag_set \
|
||||||
|
? stbi__de_iphone_flag_local \
|
||||||
|
: stbi__de_iphone_flag_global)
|
||||||
|
#endif // STBI_THREAD_LOCAL
|
||||||
|
|
||||||
static void stbi__de_iphone(stbi__png *z)
|
static void stbi__de_iphone(stbi__png *z)
|
||||||
{
|
{
|
||||||
stbi__context *s = z->s;
|
stbi__context *s = z->s;
|
||||||
@@ -5272,6 +5355,32 @@ typedef struct
|
|||||||
int extra_read;
|
int extra_read;
|
||||||
} stbi__bmp_data;
|
} stbi__bmp_data;
|
||||||
|
|
||||||
|
static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, int compress)
|
||||||
|
{
|
||||||
|
// BI_BITFIELDS specifies masks explicitly, don't override
|
||||||
|
if (compress == 3)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (compress == 0) {
|
||||||
|
if (info->bpp == 16) {
|
||||||
|
info->mr = 31u << 10;
|
||||||
|
info->mg = 31u << 5;
|
||||||
|
info->mb = 31u << 0;
|
||||||
|
} else if (info->bpp == 32) {
|
||||||
|
info->mr = 0xffu << 16;
|
||||||
|
info->mg = 0xffu << 8;
|
||||||
|
info->mb = 0xffu << 0;
|
||||||
|
info->ma = 0xffu << 24;
|
||||||
|
info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0
|
||||||
|
} else {
|
||||||
|
// otherwise, use defaults, which is all-0
|
||||||
|
info->mr = info->mg = info->mb = info->ma = 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0; // error
|
||||||
|
}
|
||||||
|
|
||||||
static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
|
static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
|
||||||
{
|
{
|
||||||
int hsz;
|
int hsz;
|
||||||
@@ -5299,6 +5408,8 @@ static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
|
|||||||
if (hsz != 12) {
|
if (hsz != 12) {
|
||||||
int compress = stbi__get32le(s);
|
int compress = stbi__get32le(s);
|
||||||
if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE");
|
if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE");
|
||||||
|
if (compress >= 4) return stbi__errpuc("BMP JPEG/PNG", "BMP type not supported: unsupported compression"); // this includes PNG/JPEG modes
|
||||||
|
if (compress == 3 && info->bpp != 16 && info->bpp != 32) return stbi__errpuc("bad BMP", "bad BMP"); // bitfields requires 16 or 32 bits/pixel
|
||||||
stbi__get32le(s); // discard sizeof
|
stbi__get32le(s); // discard sizeof
|
||||||
stbi__get32le(s); // discard hres
|
stbi__get32le(s); // discard hres
|
||||||
stbi__get32le(s); // discard vres
|
stbi__get32le(s); // discard vres
|
||||||
@@ -5313,17 +5424,7 @@ static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
|
|||||||
}
|
}
|
||||||
if (info->bpp == 16 || info->bpp == 32) {
|
if (info->bpp == 16 || info->bpp == 32) {
|
||||||
if (compress == 0) {
|
if (compress == 0) {
|
||||||
if (info->bpp == 32) {
|
stbi__bmp_set_mask_defaults(info, compress);
|
||||||
info->mr = 0xffu << 16;
|
|
||||||
info->mg = 0xffu << 8;
|
|
||||||
info->mb = 0xffu << 0;
|
|
||||||
info->ma = 0xffu << 24;
|
|
||||||
info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0
|
|
||||||
} else {
|
|
||||||
info->mr = 31u << 10;
|
|
||||||
info->mg = 31u << 5;
|
|
||||||
info->mb = 31u << 0;
|
|
||||||
}
|
|
||||||
} else if (compress == 3) {
|
} else if (compress == 3) {
|
||||||
info->mr = stbi__get32le(s);
|
info->mr = stbi__get32le(s);
|
||||||
info->mg = stbi__get32le(s);
|
info->mg = stbi__get32le(s);
|
||||||
@@ -5338,6 +5439,7 @@ static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
|
|||||||
return stbi__errpuc("bad BMP", "bad BMP");
|
return stbi__errpuc("bad BMP", "bad BMP");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// V4/V5 header
|
||||||
int i;
|
int i;
|
||||||
if (hsz != 108 && hsz != 124)
|
if (hsz != 108 && hsz != 124)
|
||||||
return stbi__errpuc("bad BMP", "bad BMP");
|
return stbi__errpuc("bad BMP", "bad BMP");
|
||||||
@@ -5345,6 +5447,8 @@ static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
|
|||||||
info->mg = stbi__get32le(s);
|
info->mg = stbi__get32le(s);
|
||||||
info->mb = stbi__get32le(s);
|
info->mb = stbi__get32le(s);
|
||||||
info->ma = stbi__get32le(s);
|
info->ma = stbi__get32le(s);
|
||||||
|
if (compress != 3) // override mr/mg/mb unless in BI_BITFIELDS mode, as per docs
|
||||||
|
stbi__bmp_set_mask_defaults(info, compress);
|
||||||
stbi__get32le(s); // discard color space
|
stbi__get32le(s); // discard color space
|
||||||
for (i=0; i < 12; ++i)
|
for (i=0; i < 12; ++i)
|
||||||
stbi__get32le(s); // discard color space parameters
|
stbi__get32le(s); // discard color space parameters
|
||||||
@@ -5394,8 +5498,7 @@ static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req
|
|||||||
psize = (info.offset - info.extra_read - info.hsz) >> 2;
|
psize = (info.offset - info.extra_read - info.hsz) >> 2;
|
||||||
}
|
}
|
||||||
if (psize == 0) {
|
if (psize == 0) {
|
||||||
STBI_ASSERT(info.offset == s->callback_already_read + (int) (s->img_buffer - s->img_buffer_original));
|
if (info.offset != s->callback_already_read + (s->img_buffer - s->img_buffer_original)) {
|
||||||
if (info.offset != s->callback_already_read + (s->img_buffer - s->buffer_start)) {
|
|
||||||
return stbi__errpuc("bad offset", "Corrupt BMP");
|
return stbi__errpuc("bad offset", "Corrupt BMP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6342,6 +6445,7 @@ static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_c
|
|||||||
|
|
||||||
// intermediate buffer is RGBA
|
// intermediate buffer is RGBA
|
||||||
result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0);
|
result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0);
|
||||||
|
if (!result) return stbi__errpuc("outofmem", "Out of memory");
|
||||||
memset(result, 0xff, x*y*4);
|
memset(result, 0xff, x*y*4);
|
||||||
|
|
||||||
if (!stbi__pic_load_core(s,x,y,comp, result)) {
|
if (!stbi__pic_load_core(s,x,y,comp, result)) {
|
||||||
@@ -6457,6 +6561,7 @@ static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_in
|
|||||||
static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp)
|
static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp)
|
||||||
{
|
{
|
||||||
stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));
|
stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));
|
||||||
|
if (!g) return stbi__err("outofmem", "Out of memory");
|
||||||
if (!stbi__gif_header(s, g, comp, 1)) {
|
if (!stbi__gif_header(s, g, comp, 1)) {
|
||||||
STBI_FREE(g);
|
STBI_FREE(g);
|
||||||
stbi__rewind( s );
|
stbi__rewind( s );
|
||||||
@@ -6766,6 +6871,17 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **delays)
|
||||||
|
{
|
||||||
|
STBI_FREE(g->out);
|
||||||
|
STBI_FREE(g->history);
|
||||||
|
STBI_FREE(g->background);
|
||||||
|
|
||||||
|
if (out) STBI_FREE(out);
|
||||||
|
if (delays && *delays) STBI_FREE(*delays);
|
||||||
|
return stbi__errpuc("outofmem", "Out of memory");
|
||||||
|
}
|
||||||
|
|
||||||
static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
|
static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
|
||||||
{
|
{
|
||||||
if (stbi__gif_test(s)) {
|
if (stbi__gif_test(s)) {
|
||||||
@@ -6777,6 +6893,10 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
|
|||||||
int stride;
|
int stride;
|
||||||
int out_size = 0;
|
int out_size = 0;
|
||||||
int delays_size = 0;
|
int delays_size = 0;
|
||||||
|
|
||||||
|
STBI_NOTUSED(out_size);
|
||||||
|
STBI_NOTUSED(delays_size);
|
||||||
|
|
||||||
memset(&g, 0, sizeof(g));
|
memset(&g, 0, sizeof(g));
|
||||||
if (delays) {
|
if (delays) {
|
||||||
*delays = 0;
|
*delays = 0;
|
||||||
@@ -6794,26 +6914,29 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
|
|||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
|
void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
|
||||||
if (NULL == tmp) {
|
if (!tmp)
|
||||||
STBI_FREE(g.out);
|
return stbi__load_gif_main_outofmem(&g, out, delays);
|
||||||
STBI_FREE(g.history);
|
|
||||||
STBI_FREE(g.background);
|
|
||||||
return stbi__errpuc("outofmem", "Out of memory");
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
out = (stbi_uc*) tmp;
|
out = (stbi_uc*) tmp;
|
||||||
out_size = layers * stride;
|
out_size = layers * stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delays) {
|
if (delays) {
|
||||||
*delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
|
int *new_delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
|
||||||
|
if (!new_delays)
|
||||||
|
return stbi__load_gif_main_outofmem(&g, out, delays);
|
||||||
|
*delays = new_delays;
|
||||||
delays_size = layers * sizeof(int);
|
delays_size = layers * sizeof(int);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out = (stbi_uc*)stbi__malloc( layers * stride );
|
out = (stbi_uc*)stbi__malloc( layers * stride );
|
||||||
|
if (!out)
|
||||||
|
return stbi__load_gif_main_outofmem(&g, out, delays);
|
||||||
out_size = layers * stride;
|
out_size = layers * stride;
|
||||||
if (delays) {
|
if (delays) {
|
||||||
*delays = (int*) stbi__malloc( layers * sizeof(int) );
|
*delays = (int*) stbi__malloc( layers * sizeof(int) );
|
||||||
|
if (!*delays)
|
||||||
|
return stbi__load_gif_main_outofmem(&g, out, delays);
|
||||||
delays_size = layers * sizeof(int);
|
delays_size = layers * sizeof(int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7138,9 +7261,10 @@ static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp)
|
|||||||
|
|
||||||
info.all_a = 255;
|
info.all_a = 255;
|
||||||
p = stbi__bmp_parse_header(s, &info);
|
p = stbi__bmp_parse_header(s, &info);
|
||||||
stbi__rewind( s );
|
if (p == NULL) {
|
||||||
if (p == NULL)
|
stbi__rewind( s );
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if (x) *x = s->img_x;
|
if (x) *x = s->img_x;
|
||||||
if (y) *y = s->img_y;
|
if (y) *y = s->img_y;
|
||||||
if (comp) {
|
if (comp) {
|
||||||
@@ -7206,8 +7330,8 @@ static int stbi__psd_is16(stbi__context *s)
|
|||||||
stbi__rewind( s );
|
stbi__rewind( s );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
(void) stbi__get32be(s);
|
STBI_NOTUSED(stbi__get32be(s));
|
||||||
(void) stbi__get32be(s);
|
STBI_NOTUSED(stbi__get32be(s));
|
||||||
depth = stbi__get16be(s);
|
depth = stbi__get16be(s);
|
||||||
if (depth != 16) {
|
if (depth != 16) {
|
||||||
stbi__rewind( s );
|
stbi__rewind( s );
|
||||||
@@ -7286,7 +7410,6 @@ static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp)
|
|||||||
// Known limitations:
|
// Known limitations:
|
||||||
// Does not support comments in the header section
|
// Does not support comments in the header section
|
||||||
// Does not support ASCII image data (formats P2 and P3)
|
// Does not support ASCII image data (formats P2 and P3)
|
||||||
// Does not support 16-bit-per-channel
|
|
||||||
|
|
||||||
#ifndef STBI_NO_PNM
|
#ifndef STBI_NO_PNM
|
||||||
|
|
||||||
@@ -7307,7 +7430,8 @@ static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req
|
|||||||
stbi_uc *out;
|
stbi_uc *out;
|
||||||
STBI_NOTUSED(ri);
|
STBI_NOTUSED(ri);
|
||||||
|
|
||||||
if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n))
|
ri->bits_per_channel = stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n);
|
||||||
|
if (ri->bits_per_channel == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
|
if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
|
||||||
@@ -7317,12 +7441,12 @@ static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req
|
|||||||
*y = s->img_y;
|
*y = s->img_y;
|
||||||
if (comp) *comp = s->img_n;
|
if (comp) *comp = s->img_n;
|
||||||
|
|
||||||
if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0))
|
if (!stbi__mad4sizes_valid(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0))
|
||||||
return stbi__errpuc("too large", "PNM too large");
|
return stbi__errpuc("too large", "PNM too large");
|
||||||
|
|
||||||
out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0);
|
out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0);
|
||||||
if (!out) return stbi__errpuc("outofmem", "Out of memory");
|
if (!out) return stbi__errpuc("outofmem", "Out of memory");
|
||||||
stbi__getn(s, out, s->img_n * s->img_x * s->img_y);
|
stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8));
|
||||||
|
|
||||||
if (req_comp && req_comp != s->img_n) {
|
if (req_comp && req_comp != s->img_n) {
|
||||||
out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
|
out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
|
||||||
@@ -7398,11 +7522,19 @@ static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp)
|
|||||||
stbi__pnm_skip_whitespace(s, &c);
|
stbi__pnm_skip_whitespace(s, &c);
|
||||||
|
|
||||||
maxv = stbi__pnm_getinteger(s, &c); // read max value
|
maxv = stbi__pnm_getinteger(s, &c); // read max value
|
||||||
|
if (maxv > 65535)
|
||||||
if (maxv > 255)
|
return stbi__err("max value > 65535", "PPM image supports only 8-bit and 16-bit images");
|
||||||
return stbi__err("max value > 255", "PPM image not 8-bit");
|
else if (maxv > 255)
|
||||||
|
return 16;
|
||||||
else
|
else
|
||||||
return 1;
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int stbi__pnm_is16(stbi__context *s)
|
||||||
|
{
|
||||||
|
if (stbi__pnm_info(s, NULL, NULL, NULL) == 16)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -7458,6 +7590,9 @@ static int stbi__is_16_main(stbi__context *s)
|
|||||||
if (stbi__psd_is16(s)) return 1;
|
if (stbi__psd_is16(s)) return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef STBI_NO_PNM
|
||||||
|
if (stbi__pnm_is16(s)) return 1;
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ Uint16 Text::lenght(std::string text, int kerning)
|
|||||||
{
|
{
|
||||||
Uint16 shift = 0;
|
Uint16 shift = 0;
|
||||||
|
|
||||||
for (int i = 0; i < text.length(); ++i)
|
for (int i = 0; i < (int)text.length(); ++i)
|
||||||
shift += (mOffset[int(text[i])].w + kerning);
|
shift += (mOffset[int(text[i])].w + kerning);
|
||||||
|
|
||||||
return shift;
|
return shift;
|
||||||
@@ -143,6 +143,7 @@ void Text::initOffsetFromFile()
|
|||||||
if (rfile.is_open() && rfile.good())
|
if (rfile.is_open() && rfile.good())
|
||||||
{
|
{
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
//printf("Reading %s file\n", mFile.c_str());
|
||||||
|
|
||||||
// Lee los dos primeros valores del fichero
|
// Lee los dos primeros valores del fichero
|
||||||
std::getline(rfile, buffer);
|
std::getline(rfile, buffer);
|
||||||
|
|||||||
119
source/title.cpp
@@ -136,10 +136,27 @@ void Title::init(bool demo, Uint8 subsection)
|
|||||||
mFade->init(0x17, 0x17, 0x26);
|
mFade->init(0x17, 0x17, 0x26);
|
||||||
mDemo = demo;
|
mDemo = demo;
|
||||||
|
|
||||||
if (!mInput->gameControllerFound())
|
//if (!mInput->gameControllerFound())
|
||||||
{
|
{
|
||||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
mOptions->input[0].id = 0;
|
||||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
mOptions->input[0].name = "KEYBOARD";
|
||||||
|
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||||
|
|
||||||
|
mOptions->input[1].id = 0;
|
||||||
|
mOptions->input[1].name = "GAME CONTROLLER";
|
||||||
|
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkInputDevices();
|
||||||
|
|
||||||
|
mDeviceIndex[0] = mAvailableInputDevices.size() - 1;
|
||||||
|
mDeviceIndex[1] = 0;
|
||||||
|
|
||||||
|
if (mInput->gameControllerFound())
|
||||||
|
{
|
||||||
|
mOptions->input[1].id = mAvailableInputDevices[mDeviceIndex[1]].id;
|
||||||
|
mOptions->input[1].name = mAvailableInputDevices[mDeviceIndex[1]].name;
|
||||||
|
mOptions->input[1].deviceType = mAvailableInputDevices[mDeviceIndex[1]].deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el bitmap de Coffee
|
// Inicializa el bitmap de Coffee
|
||||||
@@ -349,7 +366,7 @@ void Title::updateMenuLabels()
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
// PLAYER 1 CONTROLS - OPTIONS
|
// PLAYER 1 CONTROLS - OPTIONS
|
||||||
switch (mOptions->input[0])
|
switch (mOptions->input[0].deviceType)
|
||||||
{
|
{
|
||||||
case INPUT_USE_KEYBOARD:
|
case INPUT_USE_KEYBOARD:
|
||||||
mMenu.options->setItemCaption(i, mLang->getText(69)); // KEYBOARD
|
mMenu.options->setItemCaption(i, mLang->getText(69)); // KEYBOARD
|
||||||
@@ -363,7 +380,8 @@ void Title::updateMenuLabels()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mMenu.options->setGreyed(i, false);
|
mMenu.options->setGreyed(i, false);
|
||||||
mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
//mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
||||||
|
mMenu.options->setItemCaption(i, mOptions->input[0].name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -378,7 +396,7 @@ void Title::updateMenuLabels()
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
// PLAYER 2 CONTROLS - OPTIONS
|
// PLAYER 2 CONTROLS - OPTIONS
|
||||||
switch (mOptions->input[1])
|
switch (mOptions->input[1].deviceType)
|
||||||
{
|
{
|
||||||
case INPUT_USE_KEYBOARD:
|
case INPUT_USE_KEYBOARD:
|
||||||
mMenu.options->setItemCaption(i, mLang->getText(69)); // KEYBOARD
|
mMenu.options->setItemCaption(i, mLang->getText(69)); // KEYBOARD
|
||||||
@@ -392,7 +410,8 @@ void Title::updateMenuLabels()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mMenu.options->setGreyed(i, false);
|
mMenu.options->setGreyed(i, false);
|
||||||
mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
//mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
||||||
|
mMenu.options->setItemCaption(i, mOptions->input[1].name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -755,11 +774,11 @@ section_t Title::run(Uint8 subsection)
|
|||||||
updateMenuLabels();
|
updateMenuLabels();
|
||||||
break;
|
break;
|
||||||
case 1: // PLAYER 1 CONTROLS
|
case 1: // PLAYER 1 CONTROLS
|
||||||
switchInputs(1);
|
updatePlayerInputs(0);
|
||||||
updateMenuLabels();
|
updateMenuLabels();
|
||||||
break;
|
break;
|
||||||
case 3: // PLAYER 2 CONTROLS
|
case 3: // PLAYER 2 CONTROLS
|
||||||
switchInputs(2);
|
updatePlayerInputs(1);
|
||||||
updateMenuLabels();
|
updateMenuLabels();
|
||||||
break;
|
break;
|
||||||
case 5: // Language
|
case 5: // Language
|
||||||
@@ -908,17 +927,58 @@ void Title::runDemoGame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Modifica las opciones para los controles de los jugadores
|
// Modifica las opciones para los controles de los jugadores
|
||||||
void Title::switchInputs(int value)
|
bool Title::updatePlayerInputs(int numPlayer)
|
||||||
{
|
{
|
||||||
Uint8 temp;
|
const int numDevices = mAvailableInputDevices.size();
|
||||||
temp = mOptions->input[0];
|
|
||||||
mOptions->input[0] = mOptions->input[1];
|
|
||||||
mOptions->input[1] = temp;
|
|
||||||
|
|
||||||
|
// Si no hay mandos se deja todo de manera prefijada
|
||||||
if (!mInput->gameControllerFound())
|
if (!mInput->gameControllerFound())
|
||||||
{
|
{
|
||||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
mDeviceIndex[0] = 0;
|
||||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
mDeviceIndex[1] = 0;
|
||||||
|
|
||||||
|
mOptions->input[0].id = -1;
|
||||||
|
mOptions->input[0].name = "KEYBOARD";
|
||||||
|
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||||
|
|
||||||
|
mOptions->input[1].id = 0;
|
||||||
|
mOptions->input[1].name = "GAME CONTROLLER";
|
||||||
|
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else // Si hay mas de un dispositivo, se recorre el vector
|
||||||
|
{
|
||||||
|
printf("numplayer:%i\n",numPlayer);
|
||||||
|
printf("deviceindex:%i\n",mDeviceIndex[numPlayer]);
|
||||||
|
|
||||||
|
// Incrementa el indice
|
||||||
|
if (mDeviceIndex[numPlayer] < numDevices - 1)
|
||||||
|
mDeviceIndex[numPlayer]++;
|
||||||
|
else
|
||||||
|
mDeviceIndex[numPlayer] = 0;
|
||||||
|
printf("deviceindex:%i\n",mDeviceIndex[numPlayer]);
|
||||||
|
|
||||||
|
// Si coincide con el del otro jugador, se lo intercambian
|
||||||
|
if (mDeviceIndex[0] == mDeviceIndex[1])
|
||||||
|
{
|
||||||
|
printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]);
|
||||||
|
|
||||||
|
//const int temp = mDeviceIndex[0];
|
||||||
|
//mDeviceIndex[0] = mDeviceIndex[1];
|
||||||
|
//mDeviceIndex[1] = temp;
|
||||||
|
const int theOtherPlayer = (numPlayer + 1) % 2;
|
||||||
|
mDeviceIndex[theOtherPlayer]--;
|
||||||
|
if (mDeviceIndex[theOtherPlayer] < 0)
|
||||||
|
mDeviceIndex[theOtherPlayer]=numDevices-1;
|
||||||
|
printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador
|
||||||
|
mOptions->input[0] = mAvailableInputDevices[mDeviceIndex[0]];
|
||||||
|
mOptions->input[1] = mAvailableInputDevices[mDeviceIndex[1]];
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -941,3 +1001,30 @@ void Title::createTiledBackground()
|
|||||||
|
|
||||||
SDL_SetRenderTarget(mRenderer, nullptr);
|
SDL_SetRenderTarget(mRenderer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba cuantos mandos hay conectados para gestionar el menu de opciones
|
||||||
|
void Title::checkInputDevices()
|
||||||
|
{
|
||||||
|
printf("Filling devices for options menu...\n");
|
||||||
|
int numControllers = mInput->getNumControllers();
|
||||||
|
mAvailableInputDevices.clear();
|
||||||
|
input_t temp;
|
||||||
|
|
||||||
|
// Añade todos los mandos
|
||||||
|
if (numControllers > 0)
|
||||||
|
for (int i = 0; i < numControllers; i++)
|
||||||
|
{
|
||||||
|
temp.id = i;
|
||||||
|
temp.name = mInput->getControllerName(i);
|
||||||
|
temp.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
|
mAvailableInputDevices.push_back(temp);
|
||||||
|
printf("Device %i:\t%s\n", (int)mAvailableInputDevices.size(), temp.name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade el teclado al final
|
||||||
|
temp.id = -1;
|
||||||
|
temp.name = "KEYBOARD";
|
||||||
|
temp.deviceType = INPUT_USE_KEYBOARD;
|
||||||
|
mAvailableInputDevices.push_back(temp);
|
||||||
|
printf("Device %i:\t%s\n\n", (int)mAvailableInputDevices.size(), temp.name.c_str());
|
||||||
|
}
|
||||||
@@ -72,6 +72,8 @@ private:
|
|||||||
|
|
||||||
struct options_t *mOptions; // Variable con todas las variables de las opciones del programa
|
struct options_t *mOptions; // Variable con todas las variables de las opciones del programa
|
||||||
options_t mOptionsPrevious; // Variable de respaldo para las opciones
|
options_t mOptionsPrevious; // Variable de respaldo para las opciones
|
||||||
|
std::vector<input_t> mAvailableInputDevices; // Vector con todos los metodos de control disponibles
|
||||||
|
int mDeviceIndex[2]; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
|
||||||
|
|
||||||
// Carga los recursos necesarios para la sección 'Title'
|
// Carga los recursos necesarios para la sección 'Title'
|
||||||
bool loadMedia();
|
bool loadMedia();
|
||||||
@@ -92,11 +94,14 @@ private:
|
|||||||
void runDemoGame();
|
void runDemoGame();
|
||||||
|
|
||||||
// Modifica las opciones para los controles de los jugadores
|
// Modifica las opciones para los controles de los jugadores
|
||||||
void switchInputs(int value);
|
bool updatePlayerInputs(int numPlayer);
|
||||||
|
|
||||||
// Crea el mosaico de fondo del titulo
|
// Crea el mosaico de fondo del titulo
|
||||||
void createTiledBackground();
|
void createTiledBackground();
|
||||||
|
|
||||||
|
// Comprueba cuantos mandos hay conectados para gestionar el menu de opciones
|
||||||
|
void checkInputDevices();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::string *fileList, options_t *options, Lang *lang);
|
Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::string *fileList, options_t *options, Lang *lang);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "ifdefs.h"
|
#include "ifdefs.h"
|
||||||
#include "ltexture.h"
|
#include "ltexture.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
@@ -39,11 +40,19 @@ struct demoKeys_t
|
|||||||
Uint8 fireRight;
|
Uint8 fireRight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estructura para albergar métodos de control
|
||||||
|
struct input_t
|
||||||
|
{
|
||||||
|
int id; // Identificador en el vector de mandos
|
||||||
|
std::string name; // Nombre del dispositivo
|
||||||
|
Uint8 deviceType; // Tipo de dispositivo (teclado o mando)
|
||||||
|
};
|
||||||
|
|
||||||
// Estructura con todas las opciones de configuración del programa
|
// Estructura con todas las opciones de configuración del programa
|
||||||
struct options_t
|
struct options_t
|
||||||
{
|
{
|
||||||
Uint8 difficulty; // Dificultad del juego
|
Uint8 difficulty; // Dificultad del juego
|
||||||
Uint8 input[2]; // Modo de control (teclado o mando)
|
input_t input[2]; // Modo de control (teclado o mando)
|
||||||
Uint8 language; // Idioma usado en el juego
|
Uint8 language; // Idioma usado en el juego
|
||||||
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
||||||
Uint8 windowSize; // Contiene el valor del tamaño de la ventana
|
Uint8 windowSize; // Contiene el valor del tamaño de la ventana
|
||||||
|
|||||||