diff --git a/README.md b/README.md index e46fcad..88ccc6e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Speedy Eggbert 2 Source Code Decomp WIP Source Tree for Speedy Eggbert (Blupi) 2 + + As of now (5/17/24), there hasn't been any source code found for SE2. So we are using the released (original) source code from Planet Blupi to compare code and help us with the proccess. diff --git a/jauge.cpp b/jauge.cpp new file mode 100644 index 0000000..6fe1c68 --- /dev/null +++ b/jauge.cpp @@ -0,0 +1,143 @@ +// Jauge.cpp +// + +#include +#include +#include +#include +#include "def.h" +#include "pixmap.h" +#include "sound.h" +#include "decor.h" +#include "jauge.h" +#include "misc.h" + + + +///////////////////////////////////////////////////////////////// + +// Constructor + +CJauge::CJauge() +{ + m_type = 0; + m_bHide = TRUE; + m_bMinimizeRedraw = FALSE; + m_bRedraw = FALSE; +} + +// Destructor + +CJauge::~CJauge() +{ +} + +// Create a new Button. + +BOOL CJauge::Create(HWND hWnd, CPixmap *pPixmap, CDecor *pDecor, + POINT pos, int type, BOOL bMinimizeRedraw) +{ + m_hWnd = hWnd; + m_pPixmap = pPixmap; + m_pDecor = pDecor; + m_type = type; + m_bMinimizeRedraw = bMinimizeRedraw; + m_bHide = TRUE; + m_pos = pos; + m_dim.x = DIMJAUGEX; + m_dim.y = DIMJAUGEY; + m_level = 0; + m_bRedraw = TRUE; +} + +void CJauge::Draw() +{ + int part; + RECT rect; + + if ( m_bMinimizeRedraw && !m_bRedraw ) return; + m_bRedraw = FALSE; + + if ( m_bHide ) // bouton cach� ? + { + rect.left = m_pos.x; + rect.right = m_pos.x+m_dim.x; + rect.top = m_pos.y; + rect.bottom = m_pos.y+m_dim.y; + m_pPixmap->DrawPart(-1, CHBACK, m_pos, rect, 1); // dessine le fond + return; + } + + part = (m_level*(DIMJAUGEX-6-4))/100; + + rect.left = 0; + rect.right = DIMJAUGEX; + rect.top = DIMJAUGEY*0; + rect.bottom = DIMJAUGEY*1; + m_pPixmap->DrawPart(-1, CHJAUGE, m_pos, rect); // partie noire + + if ( part > 0 ) + { + rect.left = 0; + rect.right = 6+part; + rect.top = DIMJAUGEY*m_type; + rect.bottom = DIMJAUGEY*(m_type+1); + m_pPixmap->DrawPart(-1, CHJAUGE, m_pos, rect); // partie color�e + } +} + +void CJauge::Redraw() +{ + m_bRedraw = TRUE; +} + +void CJauge::SetLevel(int level) +{ + if ( level < 0 ) level = 0; + if ( level > 100 ) level = 100; + + if ( m_level != level ) + { + m_bRedraw = TRUE; + } + + m_level = level; +} + +int CJauge::GetLevel() +{ + return m_level; +} + + +int CJauge::GetType() +{ + return m_type; +} + + +void CJauge::SetType(int type) +{ + if ( m_type != type ) + { + m_bRedraw = TRUE; + } + + m_type = type; +} + +BOOL CJauge::GetHide() +{ + return m_bHide; +} + +void CJauge::SetHide(BOOL bHide) +{ + if ( m_bHide != bHide ) + { + m_bRedraw = TRUE; + } + + m_bHide = bHide; +} + diff --git a/menu.cpp b/menu.cpp new file mode 100644 index 0000000..7b5843b --- /dev/null +++ b/menu.cpp @@ -0,0 +1,168 @@ +// Menu.cpp +// + +#include +#include +#include +#include +#include "def.h" +#include "resource.h" +#include "pixmap.h" +#include "sound.h" +#include "decor.h" +#include "button.h" +#include "menu.h" +#include "text.h" +#include "misc.h" + + +///////////////////////////////////////////////////////////////////////////// + + +#define MARGMENU 0 + + +static short table_button_icon[] = +{ + 24, // go + 40, // stop + 32, // mange + 30, // carry + 31, // depose + 22, // abat + 27, // roc + 28, // cultive + 19, // build1 (cabane) + 25, // build2 (couveuse) + 35, // build3 (laboratoire) + 61, // build4 (mine) + 59, // build5 (usine) + 101, // build6 (t�l�porteur) + 20, // mur + 26, // palis + 42, // abat n + 43, // roc n + 23, // pont + 33, // tour + 34, // boit + 39, // labo + 54, // fleur + 55, // fleur n + 41, // dynamite + 58, // bateau + 60, // djeep + 64, // drapeau + 62, // extrait du fer + 65, // fabrique jeep + 63, // fabrique mine + 83, // fabrique disciple + 100, // repeat + 107, // qarmure + 106, // fabarmure +}; + +void GetText(int rank, char *pBuffer, int lgBuffer) +{ + LoadString(TX_ACTION_GO+rank, pBuffer, lgBuffer); +} + +void GetErr(int rank, char *pBuffer, int lgBuffer) +{ + LoadString(TX_ERROR_MISC+rank, pBuffer, lgBuffer); +} + +///////////////////////////////////////////////////////////////////////////// + +CMenu::CMenu() +{ + m_nbButtons = 0; + m_selRank = -1; +} + +CMenu::~CMenu() +{ +} + +void CMenu::Delete() +{ + m_nbButtons = 0; + m_selRank = -1; +} + +BOOL CMenu::TreatEvent(UINT message, WPARAM wParam, LPARAM lParam) +{ + POINT pos; + + if ( m_nbButtons == 0 ) return FALSE; + + pos = ConvLongToPos(lParam); + + switch( message ) + { + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + if ( MouseDown(pos) ) return TRUE; + break; + + case WM_MOUSEMOVE: + if ( MouseMove(pos) ) return TRUE; + break; + case WM_LBUTTONUP: + case WM_RBUTTONUP: + if ( MouseUp(pos) ) return TRUE; + break; + } + + return FALSE; +} + +int CMenu::Detect(POINT pos) +{ + int rank; + + if ( pos.x < m_pos.x || pos.x > m_pos.x+m_dim.x || + pos.y < m_pos.y || pos.y > m_pos.y+m_dim.y ) return -1; + + rank = (pos.y-m_pos.y)/(DIMBUTTONY+MARGMENU); + rank += ((pos.x-m_pos.x)/(DIMBUTTONX+MARGMENU))*m_nbCel.y; + + if ( rank >= m_nbButtons ) return -1; + return rank; +} + +BOOL CMenu::MouseDown(POINT pos) +{ + return FALSE; +} + +BOOL CMenu::MouseMove(POINT pos) +{ + m_mousePos = pos; + m_selRank = Detect(pos); + + if ( pos.x < m_pos.x-(DIMBUTTONX+MARGMENU) || + pos.x > m_pos.x+m_dim.x+(DIMBUTTONX+MARGMENU) || + pos.y < m_pos.y-(DIMBUTTONY+MARGMENU) || + pos.y > m_pos.y+m_dim.y+(DIMBUTTONY+MARGMENU) ) + { + Delete(); // enl�ve le menu si souris trop loin ! + } + + return FALSE; +} + +BOOL CMenu::MouseUp(POINT pos) +{ + m_mousePos = pos; + m_selRank = Detect(pos); + + return FALSE; +} + +void CMenu::Message() +{ + if ( m_selRank != -1 ) + { + PostMessage(m_hWnd, WM_BUTTON0+m_selRank, 0, 0); + } +} diff --git a/misc.cpp b/misc.cpp new file mode 100644 index 0000000..b32b0fc --- /dev/null +++ b/misc.cpp @@ -0,0 +1,157 @@ +// Misc.cpp +// + + +#include +#include +#include +#include +#include "def.h" + + +// Global Variables + +HINSTANCE g_hInstance; +int g_lastSprite = 0; +extern BOOL g_bFullScreen; +extern int g_mouseType; +extern char g_CDPath[MAX_PATH]; + +//Initalize HInstance. + +void InitHInstance(HINSTANCE hInstance) +{ + g_hInstance = hInstance; +} + +void OutputDebug(char *pMessage) +{ +#ifdef _DEBUG + OutputDebugString(pMessage); +#endif +} + +void LoadString(UINT nID, char *pBuffer, int lgBuffer) +{ + LoadString(g_hInstance, nID, pBuffer, lgBuffer); +} + +void ChangeSprite(int sprite) +{ + HCURSOR hCursor = nullptr; + + if ( g_mouseType == MOUSETYPEGRA ) return; + if ( g_lastSprite == sprite ) return; + + if ( sprite == SPRITE_ARROW ) hCursor = LoadCursor(g_hInstance, "IDC_ARROW"); + if ( sprite == SPRITE_POINTER ) hCursor = LoadCursor(g_hInstance, "IDC_POINTER"); + if ( sprite == SPRITE_MAP ) hCursor = LoadCursor(g_hInstance, "IDC_MAP"); + if ( sprite == SPRITE_ARROWU ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWU"); + if ( sprite == SPRITE_ARROWD ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWD"); + if ( sprite == SPRITE_ARROWL ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWL"); + if ( sprite == SPRITE_ARROWR ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWR"); + if ( sprite == SPRITE_ARROWUL ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWUL"); + if ( sprite == SPRITE_ARROWUR ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWUR"); + if ( sprite == SPRITE_ARROWDL ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWDL"); + if ( sprite == SPRITE_ARROWDR ) hCursor = LoadCursor(g_hInstance, "IDC_ARROWDR"); + if ( sprite == SPRITE_WAIT ) hCursor = LoadCursor(g_hInstance, "IDC_WAIT"); + if ( sprite == SPRITE_EMPTY ) hCursor = LoadCursor(g_hInstance, "IDC_EMPTY"); + if ( sprite == SPRITE_FILL ) hCursor = LoadCursor(g_hInstance, "IDC_FILL"); + SetCursor(hCursor); + + g_lastSprite = sprite; +} + +POINT ConvLongToPos(LPARAM lParam) +{ + POINT pos; + + pos.x = LOWORD(lParam); + pos.y = HIWORD(lParam); + + return; +} + +void InitRandom() +{ + srand(1); +} + +int Random(int min, int max) +{ + long n; + + n = rand(); + n = min+(n%(max-min+1)); + + return (int)n; +} + +void GetCurrentDir(char *pName, int lg) +{ + int i; + + strncpy(pName, _pgmptr, lg-1); + pName[lg-1] = 0; + + lg = strlen(pName); + if ( lg == 0 ) return; + + for ( i=0 ; i 0 ) + { + lg --; + if ( pName[lg] == '\\' ) + { + pName[lg+1] = 0; + break; + } + } + + if ( lg > 6 && strcmp(pName+lg-6, "\\debug\\") == 0 ) + { + pName[lg-5] = 0; // ignore le dossier \debug ! + } +} + +void AddCDPath(char *pFilename) +{ + char temp[MAX_PATH]; + int lg; + BOOL bDaniel = FALSE; + + if ( g_CDPath[0] == 0 ) return; + + lg = strlen(g_CDPath); + if ( lg > 14 && strstr(g_CDPath+lg-14, "\\daniel\\blupi\\") ) + { + bDaniel = TRUE; + } + +#if _DEMO + strcpy(temp, g_CDPath); + strcat(temp, pFilename); +#else + if ( !bDaniel && + (strstr(pFilename, "image08\\") == pFilename || + strstr(pFilename, "data\\") == pFilename || + strstr(pFilename, "image16\\") == pFilename || + strstr(pFileName, "sound\\")) ) + { + strcpy(temp, g_CDPath); + strcat(temp, "..\\"); + strcat(temp, pFilename); + } + else + { + strcpy(temp, g_CDPath); + strcat(temp, pFilename); + } +#endif + + strcpy(pFilename, temp); +} \ No newline at end of file