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

Remove windows headers

This commit is contained in:
Mathieu Schroeter 2017-02-10 00:14:28 +01:00
parent c3d9dd6e48
commit 350f31f17a
17 changed files with 103 additions and 80 deletions

View File

@ -3,6 +3,8 @@
#pragma once #pragma once
#include "blupi.h"
extern extern
bool Action(short action, short direct, bool Action(short action, short direct,
short &phase, short &step, short &phase, short &step,

View File

@ -40,7 +40,7 @@ int g_mouseType = MOUSETYPEGRA;
bool g_bActive = true; // is application active ? bool g_bActive = true; // is application active ?
bool g_bTermInit = false; // initialisation en cours bool g_bTermInit = false; // initialisation en cours
UINT g_lastPhase = 999; unsigned int g_lastPhase = 999;
@ -115,7 +115,7 @@ bool ReadConfig(int argc, char *argv[])
void UpdateFrame(void) void UpdateFrame(void)
{ {
RECT clip, rcRect; RECT clip, rcRect;
UINT phase; unsigned int phase;
POINT posMouse; POINT posMouse;
int i, term, speed; int i, term, speed;
@ -360,7 +360,6 @@ void WindowProc2 (const SDL_Event &event)
{ {
switch (event.user.code) switch (event.user.code)
{ {
case WM_TIMER:
case WM_UPDATE: case WM_UPDATE:
if (!g_pEvent->IsMovie ()) // pas de film en cours ? if (!g_pEvent->IsMovie ()) // pas de film en cours ?
{ {
@ -423,13 +422,7 @@ static bool DoInit(int argc, char *argv[])
// Create a window. // Create a window.
if ( g_bFullScreen ) if ( g_bFullScreen )
{ {
g_window = SDL_CreateWindow ( g_window = SDL_CreateWindow (NAME, 0, 0, LXIMAGE, LYIMAGE, SDL_WINDOW_FULLSCREEN);
NAME,
0, 0,
GetSystemMetrics (SM_CXSCREEN),
GetSystemMetrics (SM_CYSCREEN),
SDL_WINDOW_FULLSCREEN
);
} }
else else
{ {

43
blupi.h
View File

@ -5,3 +5,46 @@
extern SDL_Window *g_window; extern SDL_Window *g_window;
extern SDL_Renderer *g_renderer; extern SDL_Renderer *g_renderer;
struct POINT
{
long x;
long y;
};
struct RECT
{
long left;
long top;
long right;
long bottom;
};
typedef unsigned long COLORREF;
#if defined(_WIN64)
typedef unsigned __int64 WPARAM;
typedef __int64 LPARAM;
#else
typedef unsigned int WPARAM;
typedef long LPARAM;
#endif
#define LOWORD(l) ((unsigned short)(((unsigned long)(l)) & 0xffff))
#define HIWORD(l) ((unsigned short)((((unsigned long)(l)) >> 16) & 0xffff))
#define MAX_PATH 260
#define VK_END 0x23
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define WM_KEYDOWN 0x0100
#define WM_KEYUP 0x0101
#define WM_MOUSEMOVE 0x0200
#define WM_LBUTTONDOWN 0x0201
#define WM_LBUTTONUP 0x0202
#define WM_RBUTTONDOWN 0x0204
#define WM_RBUTTONUP 0x0205

View File

@ -45,7 +45,7 @@ bool CButton::Create(CPixmap *pPixmap, CSound *pSound,
POINT pos, int type, bool bMinimizeRedraw, POINT pos, int type, bool bMinimizeRedraw,
int *pMenu, int nbMenu, int *pMenu, int nbMenu,
const char **pToolTips, const char **pToolTips,
int region, UINT message) int region, unsigned int message)
{ {
POINT iconDim; POINT iconDim;
int i, icon; int i, icon;

View File

@ -16,7 +16,7 @@ public:
POINT pos, int type, bool bMinimizeRedraw, POINT pos, int type, bool bMinimizeRedraw,
int *pMenu, int nbMenu, int *pMenu, int nbMenu,
const char **pToolTips, const char **pToolTips,
int region, UINT message); int region, unsigned int message);
void Draw(); void Draw();
void Redraw(); void Redraw();
@ -50,7 +50,7 @@ protected:
int m_type; // type de bouton int m_type; // type de bouton
bool m_bEnable; // true si bouton actif bool m_bEnable; // true si bouton actif
bool m_bHide; // true si bouton caché bool m_bHide; // true si bouton caché
UINT m_message; // message envoyé si bouton actionné unsigned int m_message; // message envoyé si bouton actionné
POINT m_pos; // coin sup/gauche POINT m_pos; // coin sup/gauche
POINT m_dim; // dimensions POINT m_dim; // dimensions
int m_state; // 0=relâché, 1=pressé, +2=survollé int m_state; // 0=relâché, 1=pressé, +2=survollé

View File

@ -286,7 +286,7 @@ bool CDecor::CheminCherche(int rank, int &action)
return false; return false;
} }
memset(m_cheminWork, 0, (BYTE)MAXCELX*(BYTE)MAXCELY); memset(m_cheminWork, 0, (Uint8)MAXCELX*(Uint8)MAXCELY);
CheminMemPos(rank); CheminMemPos(rank);
// fait un remplissage du map de travail // fait un remplissage du map de travail

View File

@ -483,7 +483,6 @@ void CDecor::MapPutCel(POINT pos)
bool CDecor::GenerateMap() bool CDecor::GenerateMap()
{ {
HBITMAP hbm;
POINT dim, pos, cel; POINT dim, pos, cel;
int dx, rank, i; int dx, rank, i;
@ -535,11 +534,6 @@ bool CDecor::GenerateMap()
g_map32_bits[i][pos.x+MAPCADREX] = m_colors[MAP_CADRE]; g_map32_bits[i][pos.x+MAPCADREX] = m_colors[MAP_CADRE];
} }
hbm = CreateBitmap(DIMMAPX, DIMMAPY, 1, 32, g_map32_bits);
if ( hbm == nullptr ) return false;
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(g_map32_bits, DIMMAPX, DIMMAPY, 32, 4 * DIMMAPX, 0, 0, 0, 0); SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(g_map32_bits, DIMMAPX, DIMMAPY, 32, 4 * DIMMAPX, 0, 0, 0, 0);
dim.x = DIMMAPX; dim.x = DIMMAPX;
@ -550,7 +544,7 @@ bool CDecor::GenerateMap()
pos.y = POSMAPY; pos.y = POSMAPY;
m_pPixmap->DrawIcon(-1, CHMAP, 0, pos); m_pPixmap->DrawIcon(-1, CHMAP, 0, pos);
DeleteObject(hbm); SDL_FreeSurface (surface);
return true; return true;
} }

View File

@ -516,7 +516,7 @@ protected:
int m_infoHeight; int m_infoHeight;
POINT m_memoPos[4]; POINT m_memoPos[4];
BYTE m_cheminWork[MAXCELX*MAXCELY]; Uint8 m_cheminWork[MAXCELX*MAXCELY];
int m_cheminNbPos; int m_cheminNbPos;
POINT m_cheminPos[MAXBLUPI*2]; POINT m_cheminPos[MAXBLUPI*2];
int m_cheminRank[MAXBLUPI*2]; int m_cheminRank[MAXBLUPI*2];

4
def.h
View File

@ -3,8 +3,6 @@
#pragma once #pragma once
#include <Windows.h>
#define _INTRO false // true si images d'introduction #define _INTRO false // true si images d'introduction
@ -370,7 +368,7 @@ enum MouseSprites
}; };
// User define message #define WM_USER 0x0400
#define WM_UPDATE (WM_USER+1) #define WM_UPDATE (WM_USER+1)

View File

@ -1573,7 +1573,7 @@ int CEvent::GetButtonIndex(int button)
while ( table[m_index].buttons[i].message != 0 ) while ( table[m_index].buttons[i].message != 0 )
{ {
if ( (UINT)button == table[m_index].buttons[i].message ) if ( (unsigned int) button == table[m_index].buttons[i].message )
{ {
return i; return i;
} }
@ -1753,7 +1753,7 @@ void AddCheatCode(char *pDst, char *pSrc)
j = strlen(pDst); j = strlen(pDst);
while ( pSrc[i] != 0 ) while ( pSrc[i] != 0 )
{ {
pDst[j++] = tolower(pSrc[i++]); pDst[j++] = pSrc[i++];
} }
pDst[j] = 0; pDst[j] = 0;
} }
@ -2689,7 +2689,7 @@ bool CEvent::MouseOnButton(POINT pos)
// Retourne l'index dans table pour une phase donnée. // Retourne l'index dans table pour une phase donnée.
int CEvent::SearchPhase(UINT phase) int CEvent::SearchPhase(unsigned int phase)
{ {
int i=0; int i=0;
@ -2747,7 +2747,7 @@ bool CEvent::IsHelpHide()
// Change de phase. // Change de phase.
bool CEvent::ChangePhase(UINT phase) bool CEvent::ChangePhase(unsigned int phase)
{ {
int index, world, time, total, music, i, max; int index, world, time, total, music, i, max;
POINT totalDim, iconDim; POINT totalDim, iconDim;
@ -3151,7 +3151,7 @@ bool CEvent::ChangePhase(UINT phase)
// Retourne la phase en cours. // Retourne la phase en cours.
UINT CEvent::GetPhase() unsigned int CEvent::GetPhase()
{ {
return m_phase; return m_phase;
} }
@ -4349,7 +4349,7 @@ void CEvent::DemoRecStop()
if ( m_pDemoBuffer != nullptr ) if ( m_pDemoBuffer != nullptr )
{ {
DeleteFile("data\\demo.blp"); _unlink ("data\\demo.blp");
file = fopen("data\\demo.blp", "wb"); file = fopen("data\\demo.blp", "wb");
if ( file != nullptr ) if ( file != nullptr )
{ {
@ -4442,12 +4442,12 @@ void CEvent::DemoPlayStop()
ChangePhase(WM_PHASE_INIT); ChangePhase(WM_PHASE_INIT);
} }
void CEvent::WinToSDLEvent (UINT msg, WPARAM wParam, LPARAM lParam, SDL_Event &event) void CEvent::WinToSDLEvent (unsigned int msg, WPARAM wParam, LPARAM lParam, SDL_Event &event)
{ {
#define GET_X_LPARAM(lp) ((int) (short) LOWORD (lp)) #define GET_X_LPARAM(lp) ((int) (short) LOWORD (lp))
#define GET_Y_LPARAM(lp) ((int) (short) HIWORD (lp)) #define GET_Y_LPARAM(lp) ((int) (short) HIWORD (lp))
static const std::unordered_map<UINT, SDL_Keysym> keycodes = { static const std::unordered_map<unsigned int, SDL_Keysym> keycodes = {
{ '0', { SDL_SCANCODE_0, SDLK_0, 0, 0 } }, { '0', { SDL_SCANCODE_0, SDLK_0, 0, 0 } },
{ '1', { SDL_SCANCODE_1, SDLK_1, 0, 0 } }, { '1', { SDL_SCANCODE_1, SDLK_1, 0, 0 } },
{ '2', { SDL_SCANCODE_2, SDLK_2, 0, 0 } }, { '2', { SDL_SCANCODE_2, SDLK_2, 0, 0 } },
@ -4539,7 +4539,7 @@ void CEvent::WinToSDLEvent (UINT msg, WPARAM wParam, LPARAM lParam, SDL_Event &e
void CEvent::DemoStep() void CEvent::DemoStep()
{ {
int time; int time;
UINT message; unsigned int message;
WPARAM wParam; WPARAM wParam;
LPARAM lParam; LPARAM lParam;
@ -4593,7 +4593,7 @@ void CEvent::DemoStep()
// Mémorise un événement. // Mémorise un événement.
void CEvent::DemoRecEvent(UINT message, WPARAM wParam, LPARAM lParam) void CEvent::DemoRecEvent(unsigned int message, WPARAM wParam, LPARAM lParam)
{ {
if ( m_bDemoRec && m_pDemoBuffer != nullptr && if ( m_bDemoRec && m_pDemoBuffer != nullptr &&
(message == WM_KEYDOWN || (message == WM_KEYDOWN ||
@ -4609,15 +4609,15 @@ void CEvent::DemoRecEvent(UINT message, WPARAM wParam, LPARAM lParam)
m_pDemoBuffer[m_demoIndex-1].time == m_demoTime && m_pDemoBuffer[m_demoIndex-1].time == m_demoTime &&
m_pDemoBuffer[m_demoIndex-1].message == message ) m_pDemoBuffer[m_demoIndex-1].message == message )
{ {
m_pDemoBuffer[m_demoIndex-1].wParam = static_cast<UINT> (wParam); m_pDemoBuffer[m_demoIndex-1].wParam = static_cast<unsigned int> (wParam);
m_pDemoBuffer[m_demoIndex-1].lParam = static_cast<UINT> (lParam); m_pDemoBuffer[m_demoIndex-1].lParam = static_cast<unsigned int> (lParam);
} }
else else
{ {
m_pDemoBuffer[m_demoIndex].time = m_demoTime; m_pDemoBuffer[m_demoIndex].time = m_demoTime;
m_pDemoBuffer[m_demoIndex].message = message; m_pDemoBuffer[m_demoIndex].message = message;
m_pDemoBuffer[m_demoIndex].wParam = static_cast<UINT> (wParam); m_pDemoBuffer[m_demoIndex].wParam = static_cast<unsigned int> (wParam);
m_pDemoBuffer[m_demoIndex].lParam = static_cast<UINT> (lParam); m_pDemoBuffer[m_demoIndex].lParam = static_cast<unsigned int> (lParam);
m_demoIndex ++; m_demoIndex ++;
if ( m_demoIndex >= MAXDEMO ) if ( m_demoIndex >= MAXDEMO )
@ -4992,7 +4992,6 @@ bool CEvent::TreatEventBase(const SDL_Event &event)
case SDLK_LCTRL: case SDLK_LCTRL:
case SDLK_RCTRL: case SDLK_RCTRL:
m_keymod &= ~KMOD_CTRL; m_keymod &= ~KMOD_CTRL;
OutputDebugString ("CTRL: UP");
m_bFillMouse = false; m_bFillMouse = false;
MouseSprite(GetMousePos()); MouseSprite(GetMousePos());
return true; return true;

21
event.h
View File

@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include "blupi.h"
#include "jauge.h" #include "jauge.h"
#include "menu.h" #include "menu.h"
#include "button.h" #include "button.h"
@ -14,7 +15,7 @@ class CMovie;
typedef struct typedef struct
{ {
UINT message; unsigned int message;
int type; int type;
int iconMenu[20]; int iconMenu[20];
int x, y; int x, y;
@ -24,7 +25,7 @@ Button;
typedef struct typedef struct
{ {
UINT phase; unsigned int phase;
char backName[20]; char backName[20];
int bCDrom; int bCDrom;
Button buttons[MAXBUTTON]; Button buttons[MAXBUTTON];
@ -47,9 +48,9 @@ DemoHeader;
typedef struct typedef struct
{ {
int time; int time;
UINT message; unsigned int message;
UINT wParam; // WPARAM unsigned int wParam; // WPARAM
UINT lParam; // LPARAM unsigned int lParam; // LPARAM
} }
DemoEvent; DemoEvent;
@ -68,9 +69,9 @@ public:
int GetPhysicalWorld(); int GetPhysicalWorld();
int GetImageWorld(); int GetImageWorld();
bool IsHelpHide(); bool IsHelpHide();
bool ChangePhase(UINT phase); bool ChangePhase(unsigned int phase);
void MovieToStart(); void MovieToStart();
UINT GetPhase(); unsigned int GetPhase();
void TryInsert(); void TryInsert();
void RestoreGame(); void RestoreGame();
@ -119,7 +120,7 @@ protected:
bool CreateButtons(); bool CreateButtons();
bool EventButtons(const SDL_Event &event, POINT pos); bool EventButtons(const SDL_Event &event, POINT pos);
bool MouseOnButton(POINT pos); bool MouseOnButton(POINT pos);
int SearchPhase(UINT phase); int SearchPhase(unsigned int phase);
void DecorShift(int dx, int dy); void DecorShift(int dx, int dy);
bool PlayDown(POINT pos, const SDL_Event &event); bool PlayDown(POINT pos, const SDL_Event &event);
@ -142,8 +143,8 @@ protected:
void DemoRecStop(); void DemoRecStop();
bool DemoPlayStart(); bool DemoPlayStart();
void DemoPlayStop(); void DemoPlayStop();
static void WinToSDLEvent (UINT msg, WPARAM wParam, LPARAM lParam, SDL_Event &event); static void WinToSDLEvent (unsigned int msg, WPARAM wParam, LPARAM lParam, SDL_Event &event);
void DemoRecEvent(UINT message, WPARAM wParam, LPARAM lParam); void DemoRecEvent(unsigned int message, WPARAM wParam, LPARAM lParam);
protected: protected:
int m_speed; int m_speed;

2
menu.h
View File

@ -47,7 +47,7 @@ protected:
int m_buttons[MAXBUTTON]; int m_buttons[MAXBUTTON];
int m_errors[MAXBUTTON]; int m_errors[MAXBUTTON];
std::unordered_map<int, const char *> m_texts; std::unordered_map<int, const char *> m_texts;
UINT m_messages[MAXBUTTON]; unsigned int m_messages[MAXBUTTON];
int m_selRank; int m_selRank;
}; };

View File

@ -1,12 +1,15 @@
// misc.cpp // misc.cpp
// //
#include <SDL_log.h>
#include <SDL_mouse.h> #include <SDL_mouse.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <direct.h>
#include "blupi.h"
#include "def.h" #include "def.h"
// Variables globales // Variables globales
extern bool g_bFullScreen; // false si mode de test extern bool g_bFullScreen; // false si mode de test
@ -17,9 +20,7 @@ extern int g_mouseType;
void OutputDebug(char *pMessage) void OutputDebug(char *pMessage)
{ {
#ifdef _DEBUG SDL_LogDebug (SDL_LOG_CATEGORY_APPLICATION, "%s", pMessage);
OutputDebugString(pMessage);
#endif
} }
// Conversion de la position de la souris. // Conversion de la position de la souris.
@ -65,18 +66,13 @@ int Random(int min, int max)
void GetCurrentDir(char *pName, size_t lg) void GetCurrentDir(char *pName, size_t lg)
{ {
size_t i; char *basePath = SDL_GetBasePath ();
strncpy(pName, basePath, lg-1);
strncpy(pName, _pgmptr, lg-1);
pName[lg-1] = 0; pName[lg-1] = 0;
lg = strlen(pName); lg = strlen(pName);
if ( lg == 0 ) return; if (lg == 0)
goto out;
for ( i=0 ; i<lg ; i++ )
{
pName[i] = tolower(pName[i]);
}
while ( lg > 0 ) while ( lg > 0 )
{ {
@ -88,10 +84,13 @@ void GetCurrentDir(char *pName, size_t lg)
} }
} }
if ( lg > 6 && strcmp(pName+lg-6, "\\debug\\") == 0 ) if ( lg > 6 && strcmp(pName+lg-6, "\\Debug\\") == 0 )
{ {
pName[lg-5] = 0; // ignore le dossier \debug ! pName[lg-5] = 0; // ignore le dossier \debug !
} }
out:
SDL_free (basePath);
} }
// Ajoute le chemin permettant de lire un fichier // Ajoute le chemin permettant de lire un fichier
@ -99,18 +98,12 @@ void GetCurrentDir(char *pName, size_t lg)
void AddUserPath(char *pFilename) void AddUserPath(char *pFilename)
{ {
char temp[MAX_PATH]; char *temp;
char* pText; char* pText;
size_t pos; size_t pos;
char last; char last;
SECURITY_ATTRIBUTES att;
strcpy(temp, "c:\\Planète Blupi\\"); temp = SDL_GetPrefPath ("Epsitec SA", "Planet Blupi");
att.nLength = sizeof(SECURITY_ATTRIBUTES);
att.lpSecurityDescriptor = nullptr;
att.bInheritHandle = false;
CreateDirectory(temp, &att);
pText = strstr(pFilename, "\\"); pText = strstr(pFilename, "\\");
if ( pText != nullptr ) if ( pText != nullptr )
@ -119,7 +112,7 @@ void AddUserPath(char *pFilename)
strcat(temp, pFilename); strcat(temp, pFilename);
last = temp[pos]; last = temp[pos];
temp[pos] = 0; temp[pos] = 0;
CreateDirectory(temp, &att); _mkdir (temp);
temp[pos] = last; temp[pos] = last;
} }
else else
@ -128,4 +121,5 @@ void AddUserPath(char *pFilename)
} }
strcpy(pFilename, temp); strcpy(pFilename, temp);
SDL_free (temp);
} }

2
misc.h
View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include <Windows.h> #include "blupi.h"
extern void OutputDebug(char *pMessage); extern void OutputDebug(char *pMessage);

View File

@ -4,7 +4,7 @@
#include <SDL.h> #include <SDL.h>
///////////////////////////////////////////////////////////////////////////// #include "blupi.h"
#define MAXIMAGE 100 #define MAXIMAGE 100
#define MAXCURSORS 14 #define MAXCURSORS 14

View File

@ -266,7 +266,7 @@ bool CSound::PlayImage(int channel, POINT pos, int rank)
// Uses MCI to play a MIDI file. The window procedure // Uses MCI to play a MIDI file. The window procedure
// is notified when playback is complete. // is notified when playback is complete.
bool CSound::PlayMusic(LPSTR lpszMIDIFilename) bool CSound::PlayMusic(const char *lpszMIDIFilename)
{ {
char string[MAX_PATH]; char string[MAX_PATH];

View File

@ -4,9 +4,8 @@
#pragma once #pragma once
#include <stdio.h> #include <stdio.h>
#include <Windows.h>
#include <SDL_mixer.h> #include <SDL_mixer.h>
#include "blupi.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -35,7 +34,7 @@ public:
bool Play(int channel, int volume=0, Uint8 panLeft = 255, Uint8 panRight = 255); bool Play(int channel, int volume=0, Uint8 panLeft = 255, Uint8 panRight = 255);
bool PlayImage(int channel, POINT pos, int rank=-1); bool PlayImage(int channel, POINT pos, int rank=-1);
bool PlayMusic(LPSTR lpszMIDIFilename); bool PlayMusic(const char *lpszMIDIFilename);
bool RestartMusic(); bool RestartMusic();
void SuspendMusic(); void SuspendMusic();
void StopMusic(); void StopMusic();