Initial commit
This commit is contained in:
99
engines/bagel/hodjnpodj/archeroids/init.cpp
Normal file
99
engines/bagel/hodjnpodj/archeroids/init.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/archeroids/init.h"
|
||||
#include "bagel/hodjnpodj/archeroids/main.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Archeroids {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunArch
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke poker
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
HWND FAR PASCAL RunArch(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CMainWindow *pMainWnd;
|
||||
|
||||
pGameParams = lpGameInfo;
|
||||
|
||||
// invoke you game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMainWnd = new CMainWindow) != nullptr) {
|
||||
|
||||
pMainWnd->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
pMainWnd->UpdateWindow();
|
||||
|
||||
pMainWnd->SetActiveWindow();
|
||||
|
||||
if (pGameParams->bPlayingMetagame)
|
||||
pMainWnd->PlayGame();
|
||||
}
|
||||
|
||||
// these must be set in this function
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMainWnd->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMainWnd->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace Archeroids
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
37
engines/bagel/hodjnpodj/archeroids/init.h
Normal file
37
engines/bagel/hodjnpodj/archeroids/init.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARCHEROIDS_DLLINIT_H
|
||||
#define HODJNPODJ_ARCHEROIDS_DLLINIT_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Archeroids {
|
||||
|
||||
HWND FAR PASCAL RunArch(HWND, LPGAMESTRUCT);
|
||||
|
||||
} // namespace Archeroids
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
3345
engines/bagel/hodjnpodj/archeroids/main.cpp
Normal file
3345
engines/bagel/hodjnpodj/archeroids/main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
183
engines/bagel/hodjnpodj/archeroids/main.h
Normal file
183
engines/bagel/hodjnpodj/archeroids/main.h
Normal file
@@ -0,0 +1,183 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARCHEROIDS_MAIN_H
|
||||
#define HODJNPODJ_ARCHEROIDS_MAIN_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
#include "bagel/boflib/error.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/boflib/llist.h"
|
||||
#include "bagel/hodjnpodj/archeroids/usercfg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Archeroids {
|
||||
|
||||
class CMainWindow : public CFrameWnd {
|
||||
public:
|
||||
CMainWindow();
|
||||
void PlayGame();
|
||||
void PlayNextWave();
|
||||
void PaintScreen();
|
||||
ERROR_CODE RepaintSpriteList(CDC *);
|
||||
void LoadIniSettings();
|
||||
bool MainLoop();
|
||||
|
||||
protected:
|
||||
void FlushInputEvents();
|
||||
bool CheckMessages();
|
||||
ERROR_CODE LoadMasterSprites();
|
||||
void ReleaseMasterSprites();
|
||||
ERROR_CODE LoadMasterSounds();
|
||||
void ReleaseMasterSounds();
|
||||
void InitializeJoystick();
|
||||
void GameReset();
|
||||
void WaveReset();
|
||||
CSprite *NewLife(int);
|
||||
ERROR_CODE CreateLives();
|
||||
ERROR_CODE CreateGoodGuy();
|
||||
ERROR_CODE CreateBadGuys();
|
||||
ERROR_CODE CreateHay();
|
||||
ERROR_CODE CreateBurningHay(CPoint);
|
||||
ERROR_CODE CreateGoodArrow();
|
||||
ERROR_CODE CreateBadArrow(CSprite *);
|
||||
void GamePause();
|
||||
void GameResume();
|
||||
|
||||
void DestroyGoodArrow(CLList *);
|
||||
void DestroyBadArrow(CLList *);
|
||||
void DestroyBadGuy(CLList *, CDC *);
|
||||
void PruneDeadBadGuys();
|
||||
void DestroyHay(CLList *, CRect, CDC *, bool);
|
||||
void DeleteSprite(CSprite *);
|
||||
bool MoveArrows(CDC *);
|
||||
bool MoveBadGuys(CDC *);
|
||||
void MoveHodj(int);
|
||||
void LoseLife(CDC *, bool);
|
||||
void HandleError(ERROR_CODE);
|
||||
void KillAnimation();
|
||||
void OnSoundNotify(CSound *pSound);
|
||||
POINT GetLeftMostBadGuy();
|
||||
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
void OnPaint();
|
||||
void OnSysKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnSysChar(unsigned int, unsigned int, unsigned int);
|
||||
void OnTimer(uintptr);
|
||||
void OnClose();
|
||||
long OnJoyStick(unsigned int, long);
|
||||
void OnActivate(unsigned int, CWnd *, bool) override;
|
||||
void OnLButtonDown(unsigned int, CPoint);
|
||||
void OnRButtonUp(unsigned int, CPoint);
|
||||
void OnMouseMove(unsigned int, CPoint);
|
||||
LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
//
|
||||
// protected data members
|
||||
//
|
||||
CRect m_rNewGameButton;
|
||||
CPalette *m_pGamePalette = nullptr;
|
||||
CSprite *m_pMasterBadArrow = nullptr;
|
||||
CSprite *m_pMasterGoodArrow = nullptr;
|
||||
CSprite *m_pMasterBurn = nullptr;
|
||||
CSprite *m_pMasterBadWalk = nullptr;
|
||||
CSprite *m_pMasterBadShoot = nullptr;
|
||||
CSprite *m_pMasterBadDie = nullptr;
|
||||
CSprite *m_pMasterGoodWalk = nullptr;
|
||||
CSprite *m_pMasterGoodShoot = nullptr;
|
||||
CSprite *m_pMasterGoodDie = nullptr;
|
||||
CSprite *m_pMasterHeart = nullptr;
|
||||
CSprite *m_pHodj = nullptr;
|
||||
CSprite *m_pScrollSprite = nullptr;
|
||||
CSprite *m_pLives[LIVES_MAX] = {};
|
||||
CLList *m_pBadGuyList = nullptr;
|
||||
CLList *m_pBadArrowList = nullptr;
|
||||
CLList *m_pGoodArrowList = nullptr;
|
||||
CLList *m_pHayList = nullptr;
|
||||
CLList *m_pFXList = nullptr;
|
||||
CSound *m_pSoundTrack = nullptr;
|
||||
|
||||
char * m_pBadDieSound = nullptr;
|
||||
char * m_pBoltSound = nullptr;
|
||||
char * m_pArrowSound = nullptr;
|
||||
char * m_pBurnSound = nullptr;
|
||||
char * m_pExtraLifeSound = nullptr;
|
||||
HANDLE m_hBadDieRes = nullptr;
|
||||
HANDLE m_hBoltRes = nullptr;
|
||||
HANDLE m_hArrowRes = nullptr;
|
||||
HANDLE m_hBurnRes = nullptr;
|
||||
HANDLE m_hExtraLifeRes = nullptr;
|
||||
|
||||
POINT m_ptAnchor;
|
||||
unsigned long m_lScore = 0;
|
||||
unsigned long m_lNewLifeScore = 0;
|
||||
int m_nGoodArrows, m_nBadArrows = 0;
|
||||
int m_nGameSpeed = 0;
|
||||
unsigned int m_nBadGuySpeed = 0;
|
||||
unsigned int m_nArrowSpeed = 0;
|
||||
unsigned int m_nState = 0;
|
||||
int m_nMoveArrows = 0;
|
||||
int m_nBadGuys = 0;
|
||||
int m_nLives = 0;
|
||||
int m_nLevel = 0;
|
||||
int m_nWave = 0;
|
||||
unsigned int m_nJoyLast = 0;
|
||||
bool m_bPause = false;
|
||||
bool m_bGameActive = false;
|
||||
bool m_bJoyActive = false;
|
||||
bool m_bMoveMode = false;
|
||||
bool m_bInMenu = false;
|
||||
bool m_bNewGame = false;
|
||||
bool m_bAnimationsOn = false;
|
||||
bool m_bTimerActive = false;
|
||||
|
||||
|
||||
// User Setup variables
|
||||
//
|
||||
int m_nInitGameSpeed = 0;
|
||||
int m_nInitArcherLevel = 0;
|
||||
int m_nInitNumLives = 0;
|
||||
int m_nInitNumBadGuys = 0;
|
||||
};
|
||||
|
||||
////
|
||||
//
|
||||
// CTheApp:
|
||||
//
|
||||
class CTheApp : public CWinApp {
|
||||
public:
|
||||
bool InitInstance();
|
||||
virtual int ExitInstance();
|
||||
};
|
||||
|
||||
} // namespace Archeroids
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
439
engines/bagel/hodjnpodj/archeroids/usercfg.cpp
Normal file
439
engines/bagel/hodjnpodj/archeroids/usercfg.cpp
Normal file
@@ -0,0 +1,439 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/menures.h"
|
||||
#include "bagel/hodjnpodj/archeroids/usercfg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Archeroids {
|
||||
|
||||
#define ID_OK 101
|
||||
#define ID_CANCEL 102
|
||||
#define ID_RESET 103
|
||||
#define ID_GAMESPEED 112
|
||||
#define ID_LIVES 110
|
||||
#define ID_ARCHER_LEVEL 107
|
||||
#define ID_BADGUYS 113
|
||||
|
||||
#define IDS_GAMESPEED 104
|
||||
#define IDS_LIVES 111
|
||||
#define IDS_ARCHER_LEVEL 108
|
||||
|
||||
extern const char *INI_SECTION;
|
||||
|
||||
static const char *apszSpeeds[10] = {
|
||||
"Injured Snail",
|
||||
"Snail",
|
||||
"Turtle",
|
||||
"Old Gray Mare",
|
||||
"Ferret",
|
||||
"Rabbit",
|
||||
"Race Horse",
|
||||
"Cheetah",
|
||||
"Scared Cheetah",
|
||||
"Cheetah on Steroids"
|
||||
};
|
||||
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
|
||||
static CColorButton *pDefaultsButton = nullptr; // Defaults button on scroll
|
||||
|
||||
CUserCfgDlg::CUserCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, nID, ".\\ART\\SSCROLL.BMP") {
|
||||
m_nInitGameSpeed = DEFAULT_GAME_SPEED;
|
||||
m_nInitArcherLevel = DEFAULT_ARCHER_LEVEL;
|
||||
m_nInitNumLives = DEFAULT_LIVES;
|
||||
m_nInitNumBadGuys = DEFAULT_BADGUYS;
|
||||
|
||||
DoModal();
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::PutDlgData() {
|
||||
char buf[20];
|
||||
CDC *pDC;
|
||||
|
||||
pDC = GetDC();
|
||||
m_pTxtSpeedSetting->DisplayString(pDC, apszSpeeds[m_nInitGameSpeed - 1], 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
|
||||
Common::sprintf_s(buf, "Level: %d", m_nInitArcherLevel);
|
||||
m_pTxtLevel->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
|
||||
Common::sprintf_s(buf, "Lives: %d", m_nInitNumLives);
|
||||
m_pTxtLives->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
MFC::SetScrollPos(GetDlgItem(IDS_GAMESPEED)->m_hWnd, SB_CTL, m_nInitGameSpeed, true);
|
||||
MFC::SetScrollPos(GetDlgItem(IDS_LIVES)->m_hWnd, SB_CTL, m_nInitNumLives, true);
|
||||
MFC::SetScrollPos(GetDlgItem(IDS_ARCHER_LEVEL)->m_hWnd, SB_CTL, m_nInitArcherLevel, true);
|
||||
}
|
||||
|
||||
|
||||
bool CUserCfgDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
/*
|
||||
* respond to user
|
||||
*/
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
|
||||
switch (wParam) {
|
||||
|
||||
case ID_OK:
|
||||
m_bShouldSave = true;
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
return false;
|
||||
|
||||
case ID_CANCEL:
|
||||
ClearDialogImage();
|
||||
EndDialog(IDCANCEL);
|
||||
return false;
|
||||
|
||||
/*
|
||||
* reset params to default
|
||||
*/
|
||||
case ID_RESET:
|
||||
|
||||
m_nInitGameSpeed = DEFAULT_GAME_SPEED;
|
||||
m_nInitArcherLevel = DEFAULT_ARCHER_LEVEL;
|
||||
m_nInitNumLives = DEFAULT_LIVES;
|
||||
m_nInitNumBadGuys = DEFAULT_BADGUYS;
|
||||
|
||||
PutDlgData();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CBmpDialog::OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar *pScroll) {
|
||||
char szBuf[40];
|
||||
CDC *pDC;
|
||||
|
||||
// can't access a null pointer
|
||||
assert(pScroll != nullptr);
|
||||
|
||||
switch (pScroll->GetDlgCtrlID()) {
|
||||
|
||||
case IDS_GAMESPEED:
|
||||
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_LEFT:
|
||||
m_nInitGameSpeed = SPEED_MIN;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
case SB_PAGELEFT:
|
||||
if (m_nInitGameSpeed > SPEED_MIN)
|
||||
m_nInitGameSpeed--;
|
||||
break;
|
||||
|
||||
case SB_RIGHT:
|
||||
m_nInitGameSpeed = SPEED_MAX;
|
||||
break;
|
||||
|
||||
case SB_LINERIGHT:
|
||||
case SB_PAGERIGHT:
|
||||
if (m_nInitGameSpeed < SPEED_MAX)
|
||||
m_nInitGameSpeed++;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
m_nInitGameSpeed = nPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
assert(m_nInitGameSpeed >= SPEED_MIN && m_nInitGameSpeed <= SPEED_MAX);
|
||||
|
||||
pScroll->SetScrollPos(m_nInitGameSpeed);
|
||||
|
||||
pDC = GetDC();
|
||||
m_pTxtSpeedSetting->DisplayString(pDC, apszSpeeds[m_nInitGameSpeed - 1], 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
ReleaseDC(pDC);
|
||||
break;
|
||||
|
||||
case IDS_LIVES:
|
||||
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_BOTTOM:
|
||||
m_nInitNumLives = LIVES_MIN;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
case SB_PAGELEFT:
|
||||
if (m_nInitNumLives > LIVES_MIN)
|
||||
m_nInitNumLives--;
|
||||
break;
|
||||
|
||||
case SB_TOP:
|
||||
m_nInitNumLives = LIVES_MAX;
|
||||
break;
|
||||
|
||||
case SB_LINERIGHT:
|
||||
case SB_PAGERIGHT:
|
||||
if (m_nInitNumLives < LIVES_MAX)
|
||||
m_nInitNumLives++;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
m_nInitNumLives = nPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
assert(m_nInitNumLives >= LIVES_MIN && m_nInitNumLives <= LIVES_MAX);
|
||||
|
||||
pScroll->SetScrollPos(m_nInitNumLives);
|
||||
|
||||
pDC = GetDC();
|
||||
Common::sprintf_s(szBuf, "Lives: %d", m_nInitNumLives);
|
||||
m_pTxtLives->DisplayString(pDC, szBuf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
ReleaseDC(pDC);
|
||||
|
||||
break;
|
||||
|
||||
case IDS_ARCHER_LEVEL:
|
||||
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_BOTTOM:
|
||||
m_nInitArcherLevel = LEVEL_MIN;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
case SB_PAGELEFT:
|
||||
if (m_nInitArcherLevel > LEVEL_MIN)
|
||||
m_nInitArcherLevel--;
|
||||
break;
|
||||
|
||||
case SB_TOP:
|
||||
m_nInitArcherLevel = LEVEL_MAX;
|
||||
break;
|
||||
|
||||
case SB_LINERIGHT:
|
||||
case SB_PAGERIGHT:
|
||||
if (m_nInitArcherLevel < LEVEL_MAX)
|
||||
m_nInitArcherLevel++;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
m_nInitArcherLevel = nPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
assert(m_nInitArcherLevel >= LEVEL_MIN && m_nInitArcherLevel <= LEVEL_MAX);
|
||||
|
||||
pScroll->SetScrollPos(m_nInitArcherLevel);
|
||||
|
||||
pDC = GetDC();
|
||||
Common::sprintf_s(szBuf, "Level: %d", m_nInitArcherLevel);
|
||||
m_pTxtLevel->DisplayString(pDC, szBuf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
ReleaseDC(pDC);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CUserCfgDlg::OnInitDialog() {
|
||||
CRect tmpRect;
|
||||
CDC *pDC;
|
||||
int nVal;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
m_bShouldSave = false;
|
||||
|
||||
// Get the game speed (1..10)
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "GameSpeed", DEFAULT_GAME_SPEED, INI_FILENAME);
|
||||
m_nInitGameSpeed = nVal;
|
||||
if (nVal < SPEED_MIN || nVal > SPEED_MAX)
|
||||
m_nInitGameSpeed = DEFAULT_GAME_SPEED;
|
||||
|
||||
// Get the Archer level (1..8)
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "ArcherLevel", DEFAULT_ARCHER_LEVEL, INI_FILENAME);
|
||||
m_nInitArcherLevel = nVal;
|
||||
if (nVal < LEVEL_MIN || nVal > LEVEL_MAX)
|
||||
m_nInitArcherLevel = DEFAULT_ARCHER_LEVEL;
|
||||
|
||||
// Get initial number of lives (1..5)
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "NumberOfLives", DEFAULT_LIVES, INI_FILENAME);
|
||||
m_nInitNumLives = nVal;
|
||||
if (nVal < LIVES_MIN || nVal > LIVES_MAX)
|
||||
m_nInitNumLives = DEFAULT_LIVES;
|
||||
|
||||
// Get initial number of badguys
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "NumberOfBadGuys", DEFAULT_BADGUYS, INI_FILENAME);
|
||||
m_nInitNumBadGuys = nVal;
|
||||
if (nVal < BADGUYS_MIN || nVal > BADGUYS_MAX)
|
||||
m_nInitNumBadGuys = DEFAULT_BADGUYS;
|
||||
|
||||
MFC::SetScrollRange(GetDlgItem(IDS_GAMESPEED)->m_hWnd, SB_CTL, SPEED_MIN, SPEED_MAX, true);
|
||||
MFC::SetScrollRange(GetDlgItem(IDS_LIVES)->m_hWnd, SB_CTL, LIVES_MIN, LIVES_MAX, true);
|
||||
MFC::SetScrollRange(GetDlgItem(IDS_ARCHER_LEVEL)->m_hWnd, SB_CTL, LEVEL_MIN, LEVEL_MAX, true);
|
||||
|
||||
pDC = GetDC();
|
||||
tmpRect.SetRect(18, 113, 65, 132);
|
||||
m_pTxtSpeed = new CText;
|
||||
m_pTxtSpeed->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
|
||||
tmpRect.SetRect(66, 113, 200, 132);
|
||||
m_pTxtSpeedSetting = new CText;
|
||||
m_pTxtSpeedSetting->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
|
||||
tmpRect.SetRect(18, 25, 68, 42);
|
||||
m_pTxtLevel = new CText;
|
||||
m_pTxtLevel->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
|
||||
tmpRect.SetRect(18, 66, 68, 83);
|
||||
m_pTxtLives = new CText;
|
||||
m_pTxtLives->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pOKButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*pOKButton).SetControl(ID_OK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pCancelButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*pCancelButton).SetControl(ID_CANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pDefaultsButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pDefaultsButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*pDefaultsButton).SetControl(ID_RESET, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnPaint() {
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
PutDlgData();
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
m_pTxtSpeed->DisplayString(pDC, "Speed:", 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnDestroy() {
|
||||
ClearDialogImage();
|
||||
|
||||
assert(m_pTxtSpeed != nullptr);
|
||||
if (m_pTxtSpeed != nullptr) {
|
||||
delete m_pTxtSpeed;
|
||||
m_pTxtSpeed = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtSpeedSetting != nullptr);
|
||||
if (m_pTxtSpeedSetting != nullptr) {
|
||||
delete m_pTxtSpeedSetting;
|
||||
}
|
||||
|
||||
assert(m_pTxtLevel != nullptr);
|
||||
if (m_pTxtLevel != nullptr) {
|
||||
delete m_pTxtLevel;
|
||||
}
|
||||
|
||||
assert(m_pTxtLives != nullptr);
|
||||
if (m_pTxtLives != nullptr) {
|
||||
delete m_pTxtLives;
|
||||
}
|
||||
|
||||
if (m_bShouldSave) {
|
||||
|
||||
WritePrivateProfileString(INI_SECTION, "GameSpeed", Common::String::format("%d", m_nInitGameSpeed).c_str(), INI_FILENAME);
|
||||
WritePrivateProfileString(INI_SECTION, "ArcherLevel", Common::String::format("%d", m_nInitArcherLevel).c_str(), INI_FILENAME);
|
||||
WritePrivateProfileString(INI_SECTION, "NumberOfLives", Common::String::format("%d", m_nInitNumLives).c_str(), INI_FILENAME);
|
||||
WritePrivateProfileString(INI_SECTION, "NumberOfBadGuys", Common::String::format("%d", m_nInitNumBadGuys).c_str(), INI_FILENAME);
|
||||
}
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
void CUserCfgDlg::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (pDefaultsButton != nullptr) { // release the button
|
||||
delete pDefaultsButton;
|
||||
pDefaultsButton = nullptr;
|
||||
}
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CUserCfgDlg, CBmpDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_DESTROY()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace Archeroids
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
84
engines/bagel/hodjnpodj/archeroids/usercfg.h
Normal file
84
engines/bagel/hodjnpodj/archeroids/usercfg.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARCHEROIDS_USERCFG_H
|
||||
#define HODJNPODJ_ARCHEROIDS_USERCFG_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Archeroids {
|
||||
|
||||
#define IDD_USERCFG 100
|
||||
|
||||
#define DEFAULT_GAME_SPEED 4
|
||||
#define DEFAULT_ARCHER_LEVEL 1
|
||||
#define DEFAULT_LIVES 3
|
||||
#define DEFAULT_BADGUYS 16
|
||||
|
||||
#define SPEED_MIN 1
|
||||
#define SPEED_MAX 10
|
||||
#define LEVEL_MIN 1
|
||||
#define LEVEL_MAX 8
|
||||
#define LIVES_MIN 1
|
||||
#define LIVES_MAX 5
|
||||
#define BADGUYS_MIN 1
|
||||
#define BADGUYS_MAX 16
|
||||
|
||||
class CUserCfgDlg : public CBmpDialog {
|
||||
public:
|
||||
CUserCfgDlg(CWnd *, CPalette *, unsigned int);
|
||||
|
||||
protected:
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
virtual bool OnInitDialog() override;
|
||||
void PutDlgData();
|
||||
void ClearDialogImage();
|
||||
|
||||
void OnDestroy();
|
||||
void OnHScroll(unsigned int, unsigned int, CScrollBar *);
|
||||
void OnPaint();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
//
|
||||
// user preference data
|
||||
//
|
||||
CText *m_pTxtSpeed = nullptr;
|
||||
CText *m_pTxtSpeedSetting = nullptr;
|
||||
CText *m_pTxtLevel = nullptr;
|
||||
CText *m_pTxtLives = nullptr;
|
||||
int m_nInitGameSpeed = 0;
|
||||
int m_nInitArcherLevel = 0;
|
||||
int m_nInitNumLives = 0;
|
||||
int m_nInitNumBadGuys = 0;
|
||||
bool m_bShouldSave = false; // True if we should save theses settings
|
||||
};
|
||||
|
||||
} // namespace Archeroids
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
1994
engines/bagel/hodjnpodj/artparts/artparts.cpp
Normal file
1994
engines/bagel/hodjnpodj/artparts/artparts.cpp
Normal file
File diff suppressed because it is too large
Load Diff
211
engines/bagel/hodjnpodj/artparts/artparts.h
Normal file
211
engines/bagel/hodjnpodj/artparts/artparts.h
Normal file
@@ -0,0 +1,211 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARTPARTS_ARTPARTS_H
|
||||
#define HODJNPODJ_ARTPARTS_ARTPARTS_H
|
||||
|
||||
#include "bagel/boflib/sound.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace ArtParts {
|
||||
|
||||
// Border info
|
||||
#define SIDE_BORDER 20
|
||||
#define TOP_BORDER 28 //32
|
||||
#define BOTTOM_BORDER 20 //16
|
||||
#define HILITE_BORDER 3
|
||||
|
||||
// Art Parts constants
|
||||
#define ART_WIDTH 600
|
||||
#define ART_HEIGHT 432
|
||||
|
||||
// For the "frame" of correct pieces around the artwork:
|
||||
#define FRAME_WIDTH 4
|
||||
#define FRAME_HEIGHT 4
|
||||
|
||||
// Starting value defaults
|
||||
#define MAX_COLUMNS 30
|
||||
#define MIN_COLUMNS 1
|
||||
|
||||
#define MAX_ROWS 24
|
||||
#define MIN_ROWS 1
|
||||
|
||||
#define START_COLUMNS 4
|
||||
#define START_ROWS 4
|
||||
|
||||
// Timer constants
|
||||
#define MIN_TIME 0 // 15 Seconds
|
||||
#define MAX_TIME 600 // 180 Seconds = 3 minute max
|
||||
#define TIMER_START 0 // Increment scrollbar in steps of 15 Secs
|
||||
#define TIMER_MAX 12 // if Time > MAX_TIME, No Time Limit
|
||||
|
||||
#define DISPLAY_TIMER 1
|
||||
#define SHOW_TIMER 2
|
||||
#define MS_SCALE 1000 // Scale seconds to milliseconds
|
||||
|
||||
#define CLICK_TIME 1000 // Every Second, update timer clock
|
||||
#define PAUSE_TIME 3000 // Wait three seconds before erasing hint screen
|
||||
|
||||
// Sound files
|
||||
#define PICK_SOUND ".\\sound\\pickart.wav"
|
||||
#define SWITCH_SOUND ".\\sound\\moveart.wav"
|
||||
#define WIN_SOUND ".\\sound\\sound146.wav"
|
||||
#define UNDO_SOUND ".\\sound\\sound355.wav"
|
||||
#define LOSE_SOUND ".\\sound\\buzzer.wav"
|
||||
#define RULES_WAV ".\\sound\\artparts.wav"
|
||||
|
||||
#define GAME_THEME ".\\sound\\artparts.mid"
|
||||
|
||||
// Backdrop bitmaps
|
||||
#define MAINSCREEN ".\\ART\\ARTPART1.BMP"
|
||||
#define FRAMESCREEN ".\\ART\\ARTPART1.BMP"
|
||||
#define TEXTSCREEN ".\\ART\\ARTTEMP.BMP"
|
||||
|
||||
#define DATA_FILE "artfiles.dat"
|
||||
#define MAX_FILE_LENGTH 20 // Longest Art file name length allowed
|
||||
|
||||
// New Game button area
|
||||
#define NEWGAME_LOCATION_X 70
|
||||
#define NEWGAME_LOCATION_Y 5
|
||||
#define NEWGAME_WIDTH 113
|
||||
#define NEWGAME_HEIGHT 13
|
||||
|
||||
// Time Display area
|
||||
#define TIME_LOCATION_X 457
|
||||
#define TIME_LOCATION_Y 4
|
||||
#define TIME_WIDTH 117
|
||||
#define TIME_HEIGHT 16
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CMainWindow:
|
||||
// See game.cpp for the code to the member functions and the message map.
|
||||
//
|
||||
class CMainWindow : public CFrameWnd {
|
||||
public:
|
||||
CMainWindow();
|
||||
~CMainWindow();
|
||||
|
||||
bool LoadArtWork();
|
||||
void DrawPart(const CPoint &Src, const CPoint &Dst, int nWidth, int nHeight);
|
||||
void SwitchAreas(const CRect &Src, const CRect &Dst);
|
||||
void InitValues();
|
||||
void NewGame();
|
||||
void CheckForWin();
|
||||
void ShowOutOfPlace();
|
||||
|
||||
//added data members:
|
||||
bool m_bPlaying = false; // Flag True if playing, False if setting options
|
||||
bool m_bNewGame = false; // Flag to check if a new game is being played
|
||||
bool m_bFirst = false; // Flag to check if the first area is being selected
|
||||
CPoint First;
|
||||
CPoint Second;
|
||||
CPoint Center;
|
||||
CPoint UpLeft;
|
||||
CRect BaseRect; // The part that is the base of the select area
|
||||
CRect OldRect; // The last area highlighted
|
||||
CRect HiLiteRect; // The new area to highlight
|
||||
CRect SrcRect; // The area to be moved
|
||||
CRect DstRect; // The destination of the moving area
|
||||
|
||||
void SplashScreen();
|
||||
void SplashScratch();
|
||||
void SplashScratchPaint();
|
||||
|
||||
private:
|
||||
POINT Grid[MAX_COLUMNS][MAX_ROWS]; // Location of the art parts
|
||||
|
||||
CBmpButton *m_pScrollButton = nullptr;
|
||||
CBitmap *pScratch1 = nullptr, // Off-screen bitmap of current positions
|
||||
*pScratch2 = nullptr, // Off-screen bitmap of new positions
|
||||
*pOldBmp1 = nullptr,
|
||||
*pOldBmp2 = nullptr;
|
||||
CPalette *pOldPal1 = nullptr,
|
||||
*pOldPal2 = nullptr;
|
||||
CDC *pScratch1DC = nullptr,
|
||||
*pScratch2DC = nullptr;
|
||||
CText *m_pTimeText = nullptr; // Time to be posted in Locale box of screen
|
||||
CBitmap *pLocaleBitmap = nullptr, // Locale of game bitmap for title bar
|
||||
*pBlankBitmap = nullptr; // Blank area of locale for time display
|
||||
|
||||
bool bStartOkay = true;
|
||||
bool bGameStarted = false; // becomes true at start time, false at game end
|
||||
bool bSwitched = false; // flag for undo -- only true after a part switch
|
||||
bool bSuccess;
|
||||
bool m_bIgnoreScrollClick;
|
||||
bool m_bShowOutOfPlace = false;
|
||||
char szCurrentArt[64] = {};
|
||||
|
||||
static CPalette *pGamePalette; // Palette of current artwork
|
||||
static int nSeconds;
|
||||
static int nMinutes;
|
||||
static int nLastPick;
|
||||
static int m_nTime; // Time is in SECONDS
|
||||
static int m_nRows; // Number of rows in the artwork grid
|
||||
static int m_nColumns; // Number of columns in the artwork grid
|
||||
static int m_nWidth; // The Width of each Part
|
||||
static int m_nHeight; // The Height of each Part
|
||||
static float m_nScore; // The current percentage of correctly placed parts
|
||||
static bool bFramed; // Framed (hint) mode is turned off by default
|
||||
|
||||
static int tempTime; // temporary holding places
|
||||
static int tempRows; //...for options changes,
|
||||
static int tempColumns; //...which only get used
|
||||
static bool tempFramed; //...when NewGame is called.
|
||||
|
||||
CSound *pGameSound = nullptr; // Game theme song
|
||||
|
||||
private:
|
||||
void initStatics();
|
||||
void OnSoundNotify(CSound *pSound);
|
||||
static bool CopyPaletteContents(CPalette *pSource, CPalette *pDest);
|
||||
void MyFocusRect(CDC *pDC, CRect rect, int nDrawMode);
|
||||
static void GetSubOptions(CWnd *pParentWind);
|
||||
|
||||
protected:
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
|
||||
//{{AFX_MSG( CMainWindow )
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnSysKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnTimer(uintptr nIDEvent);
|
||||
afx_msg void OnLButtonDown(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnRButtonDown(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnMButtonDown(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnClose();
|
||||
afx_msg LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace ArtParts
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
45
engines/bagel/hodjnpodj/artparts/globals.h
Normal file
45
engines/bagel/hodjnpodj/artparts/globals.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARTPARTS_GLOBALS_H
|
||||
#define HODJNPODJ_ARTPARTS_GLOBALS_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace ArtParts {
|
||||
|
||||
// Main Window positioning constants
|
||||
#define GAME_WIDTH 640
|
||||
#define GAME_HEIGHT 480
|
||||
|
||||
// Scroll button size and positioning information
|
||||
#define IDC_SCROLL 850
|
||||
|
||||
#define SCROLL_BUTTON_X 250
|
||||
#define SCROLL_BUTTON_Y 0
|
||||
#define SCROLL_BUTTON_DX 140
|
||||
#define SCROLL_BUTTON_DY 23
|
||||
|
||||
} // namespace ArtParts
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
71
engines/bagel/hodjnpodj/artparts/init.cpp
Normal file
71
engines/bagel/hodjnpodj/artparts/init.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "artparts.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace ArtParts {
|
||||
|
||||
HWND FAR PASCAL RunArtp(HWND, LPGAMESTRUCT);
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
|
||||
LPGAMESTRUCT pGameInfo;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
HWND FAR PASCAL RunArtp(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CMainWindow *pMain;
|
||||
|
||||
pGameInfo = lpGameInfo;
|
||||
|
||||
// invoke your game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMain = new CMainWindow) != nullptr) {
|
||||
|
||||
// pMain->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
// pMain->UpdateWindow();
|
||||
|
||||
pMain->SetActiveWindow();
|
||||
}
|
||||
|
||||
// these must be set in this function
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMain->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace ArtParts
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
65
engines/bagel/hodjnpodj/artparts/init.h
Normal file
65
engines/bagel/hodjnpodj/artparts/init.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARTPARTS_GAMEDLL_H
|
||||
#define HODJNPODJ_ARTPARTS_GAMEDLL_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace ArtParts {
|
||||
|
||||
/**
|
||||
*****************************************************************
|
||||
*
|
||||
* RunArtp
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke poker
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
***************************************************************
|
||||
*/
|
||||
extern HWND FAR PASCAL RunArtp(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
|
||||
|
||||
} // namespace ArtParts
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
378
engines/bagel/hodjnpodj/artparts/optndlg.cpp
Normal file
378
engines/bagel/hodjnpodj/artparts/optndlg.cpp
Normal file
@@ -0,0 +1,378 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/artparts/globals.h"
|
||||
#include "bagel/hodjnpodj/artparts/resource.h"
|
||||
#include "bagel/hodjnpodj/artparts/artparts.h"
|
||||
#include "bagel/hodjnpodj/artparts/optndlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace ArtParts {
|
||||
|
||||
static CPalette *pSubOptionsPalette;
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
|
||||
static CCheckButton *pFramedButton = nullptr; // Framed check box
|
||||
|
||||
|
||||
CText *m_pPartsText = nullptr;
|
||||
CText *m_pColumnText = nullptr;
|
||||
CText *m_pRowText = nullptr;
|
||||
CText *m_pTimerText = nullptr;
|
||||
|
||||
int m_nColumnFactors[14] = {1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 25, 30}; // 14 factors
|
||||
int m_nRowFactors[11] = {1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24}; // 11 factors
|
||||
int m_nTimeScale[12] = {15, 30, 45, 60, 75, 90, 120, 180, 240, 300, 600, 700};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg dialog
|
||||
|
||||
|
||||
COptnDlg::COptnDlg(CWnd* pParent, CPalette* pPalette)
|
||||
: CBmpDialog(pParent, pPalette, IDD_SUBOPTIONS, ".\\ART\\SSCROLL.BMP") {
|
||||
//{{AFX_DATA_INIT(COptnDlg)
|
||||
m_nTime = MIN_TIME;
|
||||
m_nColumns = MIN_COLUMNS;
|
||||
m_nRows = MIN_ROWS;
|
||||
m_nNumParts = m_nColumns * m_nRows;
|
||||
nCFacs = 14;
|
||||
nRFacs = 11;
|
||||
m_bFramed = false;
|
||||
pSubOptionsPalette = pPalette;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
COptnDlg::~COptnDlg() {
|
||||
if (m_pPartsText != nullptr)
|
||||
delete m_pPartsText;
|
||||
if (m_pColumnText != nullptr)
|
||||
delete m_pColumnText;
|
||||
if (m_pRowText != nullptr)
|
||||
delete m_pRowText;
|
||||
if (m_pTimerText != nullptr)
|
||||
delete m_pTimerText;
|
||||
// if( m_pFramedText != nullptr )
|
||||
// delete m_pFramedText;
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
void COptnDlg::DoDataExchange(CDataExchange* pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(COptnDlg)
|
||||
DDX_Control(pDX, IDC_NUMCOLUMNS, m_ScrollColumns);
|
||||
DDX_Control(pDX, IDC_NUMROWS, m_ScrollRows);
|
||||
DDX_Control(pDX, IDC_TIMELIMIT, m_ScrollTime);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(COptnDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(COptnDlg)
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_CREATE()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_PAINT()
|
||||
ON_BN_CLICKED(IDC_FRAMED, COptnDlg::OnFramed)
|
||||
ON_WM_DESTROY()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg message handlers
|
||||
|
||||
int COptnDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) {
|
||||
if (CBmpDialog::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool COptnDlg::OnInitDialog() {
|
||||
CBmpDialog::OnInitDialog();
|
||||
int i;
|
||||
|
||||
CDC *pDC;
|
||||
CRect statRect;
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 45, LEFT_SIDE + 100, 60);
|
||||
if ((m_pPartsText = new CText()) != nullptr) {
|
||||
(*m_pPartsText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 65, LEFT_SIDE + 100, 80);
|
||||
if ((m_pColumnText = new CText()) != nullptr) {
|
||||
(*m_pColumnText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
m_ScrollColumns.SetScrollRange(0, nCFacs - 1, 0); // Array starts at zero, so
|
||||
for (i = 0; i < nCFacs; i++) {
|
||||
if (m_nColumnFactors[i] == m_nColumns)
|
||||
m_ScrollColumns.SetScrollPos(i, true);
|
||||
}
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 99, LEFT_SIDE + 100, 114);
|
||||
if ((m_pRowText = new CText()) != nullptr) {
|
||||
(*m_pRowText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
m_ScrollRows.SetScrollRange(0, nRFacs - 1, 0); //...last element is Max - 1
|
||||
for (i = 0; i < nRFacs; i++) {
|
||||
if (m_nRowFactors[i] == m_nRows)
|
||||
m_ScrollRows.SetScrollPos(i, true);
|
||||
}
|
||||
|
||||
m_nNumParts = m_nColumns * m_nRows;
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 132, LEFT_SIDE + 100, 146);
|
||||
if ((m_pTimerText = new CText()) != nullptr) {
|
||||
(*m_pTimerText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
m_ScrollTime.SetScrollRange(TIMER_START, TIMER_MAX - 1, 0);
|
||||
if (m_nTime == 0) m_nTime = m_nTimeScale[TIMER_MAX - 1];
|
||||
for (i = 0; i < TIMER_MAX; i++) {
|
||||
if (m_nTimeScale[i] == m_nTime)
|
||||
m_ScrollTime.SetScrollPos(i, true);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
statRect.SetRect(155, 45, 205, 60);
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pOKButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pCancelButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pCancelButton).SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pFramedButton = new CCheckButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pFramedButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pFramedButton).SetControl(IDC_FRAMED, this); // tie to the dialog control
|
||||
}
|
||||
((CWnd *)this)->CheckDlgButton(IDC_FRAMED, m_bFramed); // Set the frame option box
|
||||
|
||||
return true; // return true unless you set the focus to a control
|
||||
}
|
||||
|
||||
|
||||
bool COptnDlg::OnEraseBkgnd(CDC *pDC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void COptnDlg::OnDestroy() {
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
void COptnDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar) {
|
||||
int pMin,
|
||||
pMax;
|
||||
int OldPos = pScrollBar->GetScrollPos();
|
||||
int NewPos = OldPos;
|
||||
|
||||
pScrollBar->GetScrollRange(&pMin, &pMax);
|
||||
|
||||
switch (nSBCode) {
|
||||
case SB_LINERIGHT:
|
||||
case SB_PAGERIGHT:
|
||||
NewPos ++;
|
||||
break;
|
||||
case SB_RIGHT:
|
||||
NewPos = pMax;
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
case SB_PAGELEFT:
|
||||
NewPos--;
|
||||
break;
|
||||
case SB_LEFT:
|
||||
NewPos = pMin;
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
NewPos = nPos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (NewPos < pMin) NewPos = pMin;
|
||||
if (NewPos > pMax) NewPos = pMax;
|
||||
|
||||
if (NewPos != OldPos) { //To prevent "flicker"
|
||||
(*pScrollBar).SetScrollPos(NewPos, true); //...only update when
|
||||
} //...changed
|
||||
|
||||
UpdateScrollbars();
|
||||
|
||||
CDialog::OnHScroll(nSBCode, NewPos, pScrollBar);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* UpdateScrollbars
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Updates data adjusted with scrollbars
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* none
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* CScrollbar pScrollTime, pScrollColumns, pScrollRows
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* int m_nTime, m_nNumParts, m_nColumns, m_nRows
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
void COptnDlg::UpdateScrollbars() {
|
||||
int OldValue;
|
||||
CDC *pDC;
|
||||
char msg[64];
|
||||
int nMins, nSecs;
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
OldValue = m_nTime;
|
||||
m_nTime = m_nTimeScale[m_ScrollTime.GetScrollPos()];
|
||||
if (OldValue != m_nTime) {
|
||||
if (m_nTime == m_nTimeScale[TIMER_MAX - 1])
|
||||
Common::sprintf_s(msg, "Time Limit: None");
|
||||
else {
|
||||
nMins = m_nTime / 60;
|
||||
nSecs = m_nTime % 60;
|
||||
|
||||
Common::sprintf_s(msg, "Time Limit: %02d:%02d", nMins, nSecs);
|
||||
}
|
||||
(*m_pTimerText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
OldValue = m_nColumns;
|
||||
m_nColumns = m_nColumnFactors[m_ScrollColumns.GetScrollPos()];
|
||||
if (OldValue != m_nColumns) {
|
||||
Common::sprintf_s(msg, "Columns: %d", m_nColumns);
|
||||
(*m_pColumnText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
OldValue = m_nRows;
|
||||
m_nRows = m_nRowFactors[m_ScrollRows.GetScrollPos()];
|
||||
if (OldValue != m_nRows) {
|
||||
Common::sprintf_s(msg, "Rows: %d", m_nRows);
|
||||
(*m_pRowText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
OldValue = m_nNumParts;
|
||||
m_nNumParts = m_nColumns * m_nRows;
|
||||
if (OldValue != m_nNumParts) {
|
||||
Common::sprintf_s(msg, "Parts: %d", m_nNumParts);
|
||||
(*m_pPartsText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
|
||||
void COptnDlg::OnFramed() {
|
||||
m_bFramed = !m_bFramed;
|
||||
((CWnd *)this)->CheckDlgButton(IDC_FRAMED, m_bFramed);
|
||||
}
|
||||
|
||||
void COptnDlg::OnOK() {
|
||||
if (m_nTime > MAX_TIME) m_nTime = MIN_TIME;
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
|
||||
void COptnDlg::OnCancel() {
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
}
|
||||
|
||||
void COptnDlg::OnPaint() {
|
||||
CDC *pDC;
|
||||
char msg[64];
|
||||
int nMins, nSecs;
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
Common::sprintf_s(msg, "Parts: %d", m_nNumParts);
|
||||
(*m_pPartsText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
Common::sprintf_s(msg, "Columns: %d", m_nColumns);
|
||||
(*m_pColumnText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
Common::sprintf_s(msg, "Rows: %d", m_nRows);
|
||||
(*m_pRowText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
if (m_nTime == m_nTimeScale[TIMER_MAX - 1])
|
||||
Common::sprintf_s(msg, "Time Limit: None");
|
||||
else {
|
||||
nMins = m_nTime / 60;
|
||||
nSecs = m_nTime % 60;
|
||||
Common::sprintf_s(msg, "Time Limit: %02d:%02d", nMins, nSecs);
|
||||
}
|
||||
(*m_pTimerText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
}
|
||||
|
||||
void COptnDlg::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (pFramedButton != nullptr) { // release the button
|
||||
delete pFramedButton;
|
||||
pFramedButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
} // namespace ArtParts
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
89
engines/bagel/hodjnpodj/artparts/optndlg.h
Normal file
89
engines/bagel/hodjnpodj/artparts/optndlg.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARTPARTS_OPTNDLG_H
|
||||
#define HODJNPODJ_ARTPARTS_OPTNDLG_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace ArtParts {
|
||||
|
||||
#define LEFT_SIDE 30
|
||||
#define OPTIONS_COLOR RGB(0, 0, 0) // Color of the stats info CText
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg dialog
|
||||
|
||||
class COptnDlg : public CBmpDialog {
|
||||
// Construction
|
||||
public:
|
||||
COptnDlg(CWnd* pParent = nullptr, CPalette *pPalette = nullptr); // standard constructor
|
||||
~COptnDlg(); // destructor
|
||||
void UpdateScrollbars();
|
||||
void ClearDialogImage();
|
||||
|
||||
int m_nTime = 0;
|
||||
int m_nRows = 0;
|
||||
int m_nColumns = 0;
|
||||
int m_nMins = 0;
|
||||
int m_nSecs = 0;
|
||||
float m_nScore = 0.0;
|
||||
bool m_bFramed = false;
|
||||
int m_nNumParts = 0;
|
||||
|
||||
int nCFacs = 0;
|
||||
int nRFacs = 0;
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(COptnDlg)
|
||||
enum { IDD = IDD_SUBOPTIONS };
|
||||
CScrollBar m_ScrollTime;
|
||||
CScrollBar m_ScrollColumns;
|
||||
CScrollBar m_ScrollRows;
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COptnDlg)
|
||||
virtual bool OnInitDialog() override;
|
||||
afx_msg void OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar);
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
virtual void OnOK() override;
|
||||
virtual void OnCancel() override;
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnFramed();
|
||||
afx_msg void OnDestroy();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace ArtParts
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
47
engines/bagel/hodjnpodj/artparts/resource.h
Normal file
47
engines/bagel/hodjnpodj/artparts/resource.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_ARTPARTS_RESOURCE_H
|
||||
#define HODJNPODJ_ARTPARTS_RESOURCE_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace ArtParts {
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// App Studio generated include file.
|
||||
// Used by GAME.RC
|
||||
//
|
||||
#define IDD_SUBOPTIONS 115
|
||||
|
||||
//#define IDB_LOCALE_BMP 301
|
||||
|
||||
#define IDC_RULES 1002
|
||||
#define IDC_NUMCOLUMNS 1021
|
||||
#define IDC_NUMROWS 1022
|
||||
#define IDC_TIMELIMIT 1023
|
||||
#define IDC_FRAMED 1025
|
||||
|
||||
} // namespace ArtParts
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
266
engines/bagel/hodjnpodj/barbershop/animate.cpp
Normal file
266
engines/bagel/hodjnpodj/barbershop/animate.cpp
Normal file
@@ -0,0 +1,266 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/boflib/misc.h"
|
||||
#include "bagel/hodjnpodj/barbershop/main.h"
|
||||
#include "bagel/hodjnpodj/barbershop/animate.h"
|
||||
#include "bagel/hodjnpodj/hodjnpodj.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
// globals!!
|
||||
//
|
||||
//
|
||||
extern CPalette *pGamePalette;
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
|
||||
CAnimate::CAnimate(CSound *pSound) {
|
||||
m_pSprite = nullptr;
|
||||
m_cClownRect = CRect(CLOWN_LEFT, CLOWN_TOP, CLOWN_RIG, CLOWN_BOT);
|
||||
m_cUFORect = CRect(UFO_LEFT, UFO_TOP, UFO_RIG, UFO_BOT);
|
||||
m_cCarRect = CRect(CAR_LEFT, CAR_TOP, CAR_RIG, CAR_BOT);
|
||||
m_cBratRect = CRect(BRAT_LEFT, BRAT_TOP, BRAT_RIG, BRAT_BOT);
|
||||
m_cLolliRect = CRect(LOLLI_LEFT, LOLLI_TOP, LOLLI_RIG, LOLLI_BOT);
|
||||
m_cCutRect = CRect(CUT_LEFT, CUT_TOP, CUT_RIG, CUT_BOT);
|
||||
m_pSound = pSound;
|
||||
|
||||
//srand((unsigned) time(nullptr)); // seed the random number generator
|
||||
} // CAnimate
|
||||
|
||||
CAnimate::~CAnimate() {
|
||||
} // ~CAnimate
|
||||
|
||||
bool CAnimate::Clown(CDC *pDC, CPoint point) {
|
||||
bool bSuccess;
|
||||
int i;
|
||||
|
||||
if (m_cClownRect.PtInRect(point) == false)
|
||||
return false;
|
||||
|
||||
m_pSprite = new CSprite;
|
||||
(*m_pSprite).SharePalette(pGamePalette);
|
||||
bSuccess = (*m_pSprite).LoadCels(pDC, CLOWN_BMP, CLOWN_FRAMES);
|
||||
ASSERT(bSuccess);
|
||||
(*m_pSprite).SetMasked(false);
|
||||
(*m_pSprite).SetMobile(false);
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
CLOWN_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
m_pSound->play();
|
||||
} // end if
|
||||
|
||||
if (bSuccess == true) {
|
||||
(*m_pSprite).SetCel(CLOWN_FRAMES);
|
||||
for (i = 0; i < CLOWN_FRAMES - 1; i++) {
|
||||
(*m_pSprite).PaintSprite(
|
||||
pDC,
|
||||
m_cClownRect.TopLeft()
|
||||
);
|
||||
Sleep(CLOWN_TIME_SLICE);
|
||||
} // end for
|
||||
} // end if
|
||||
|
||||
m_pSprite->EraseSprite(pDC);
|
||||
|
||||
delete m_pSprite;
|
||||
m_pSprite = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAnimate::UFO(CDC *pDC, CPoint point) {
|
||||
bool bSuccess;
|
||||
int i;
|
||||
|
||||
if (m_cCarRect.PtInRect(point) == false)
|
||||
return false;
|
||||
|
||||
m_pSprite = new CSprite;
|
||||
(*m_pSprite).SharePalette(pGamePalette);
|
||||
bSuccess = (*m_pSprite).LoadCels(pDC, UFOA_BMP, UFOA_FRAMES);
|
||||
ASSERT(bSuccess);
|
||||
(*m_pSprite).SetMasked(false);
|
||||
(*m_pSprite).SetMobile(false);
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
SPACESHIP_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
m_pSound->play();
|
||||
} // end if
|
||||
|
||||
if (bSuccess == true) {
|
||||
int j;
|
||||
(*m_pSprite).SetCel(UFOA_FRAMES);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
(*m_pSprite).PaintSprite(
|
||||
pDC,
|
||||
m_cUFORect.TopLeft()
|
||||
);
|
||||
Sleep(UFOA_TIME_SLICE);
|
||||
} // end for
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
SPACERAY_WAV,
|
||||
SOUND_WAVE
|
||||
);
|
||||
m_pSound->play();
|
||||
|
||||
m_pSound->initialize(
|
||||
SPACESHIP_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
m_pSound->play();
|
||||
} // end if
|
||||
|
||||
for (j = i; j < UFOA_FRAMES - 1; j++) {
|
||||
(*m_pSprite).PaintSprite(
|
||||
pDC,
|
||||
m_cUFORect.TopLeft()
|
||||
);
|
||||
Sleep(UFOA_TIME_SLICE);
|
||||
} // end for
|
||||
} // end if
|
||||
|
||||
Sleep(UFO_PAUSE); // pause for a few seconds between animations
|
||||
|
||||
bSuccess = (*m_pSprite).LoadCels(pDC, UFOB_BMP, UFOB_FRAMES);
|
||||
ASSERT(bSuccess);
|
||||
(*m_pSprite).SetMasked(false);
|
||||
(*m_pSprite).SetMobile(false);
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
SPACESHIP_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
m_pSound->play();
|
||||
} // end if
|
||||
|
||||
if (bSuccess == true) {
|
||||
int j;
|
||||
(*m_pSprite).SetCel(UFOB_FRAMES);
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
(*m_pSprite).PaintSprite(
|
||||
pDC,
|
||||
m_cUFORect.TopLeft()
|
||||
);
|
||||
Sleep(UFOB_TIME_SLICE);
|
||||
} // end for
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize( // play synchronous beam up sound
|
||||
SPACERAY_WAV,
|
||||
SOUND_WAVE
|
||||
);
|
||||
m_pSound->play();
|
||||
|
||||
m_pSound->initialize( // async space ship sound
|
||||
SPACESHIP_WAV,
|
||||
SOUND_WAVE | SOUND_QUEUE | SOUND_ASYNCH
|
||||
);
|
||||
m_pSound->play();
|
||||
} // end if
|
||||
|
||||
for (j = i; j < UFOB_FRAMES - 1; j++) {
|
||||
(*m_pSprite).PaintSprite(
|
||||
pDC,
|
||||
m_cUFORect.TopLeft()
|
||||
);
|
||||
Sleep(UFOB_TIME_SLICE);
|
||||
} // end for
|
||||
} // end if
|
||||
|
||||
m_pSprite->EraseSprite(pDC);
|
||||
|
||||
delete m_pSprite;
|
||||
m_pSprite = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAnimate::Brat(CPoint point) {
|
||||
if (m_cBratRect.PtInRect(point) == false)
|
||||
return false;
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
BRAT_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
m_pSound->play();
|
||||
} // end if
|
||||
|
||||
return true;
|
||||
} // Brat
|
||||
|
||||
bool CAnimate::Lollipop(CPoint point) {
|
||||
if (m_cLolliRect.PtInRect(point) == false)
|
||||
return false;
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled == false)
|
||||
return true;
|
||||
|
||||
if ((brand() % 2) == 0) { // randomly chose sound wave to play
|
||||
m_pSound->initialize(
|
||||
LOLLI_A_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
} else {
|
||||
m_pSound->initialize(
|
||||
LOLLI_B_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
} // end if
|
||||
|
||||
m_pSound->play();
|
||||
return true;
|
||||
} // Lollipop
|
||||
|
||||
bool CAnimate::Haircut(CPoint point) {
|
||||
if (m_cCutRect.PtInRect(point) == false)
|
||||
return false;
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled == false)
|
||||
return true;
|
||||
|
||||
m_pSound->initialize(
|
||||
CUT_WAV,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
|
||||
m_pSound->play();
|
||||
return true;
|
||||
} // Haircut
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
135
engines/bagel/hodjnpodj/barbershop/animate.h
Normal file
135
engines/bagel/hodjnpodj/barbershop/animate.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_ANIMATE_H
|
||||
#define HODJNPODJ_BARBERSHOP_ANIMATE_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
//
|
||||
// animation sounds
|
||||
//
|
||||
#define CLOWN_WAV ".\\sound\\horns.wav"
|
||||
#define SPACESHIP_WAV ".\\sound\\spaceshp.wav"
|
||||
#define SPACERAY_WAV ".\\sound\\spaceray.wav"
|
||||
#define CUT_WAV ".\\sound\\haircut.wav"
|
||||
#define BRAT_WAV ".\\sound\\doneyet.wav"
|
||||
#define LOLLI_A_WAV ".\\sound\\lollipop.wav"
|
||||
#define LOLLI_B_WAV ".\\sound\\hairpop.wav"
|
||||
|
||||
|
||||
//
|
||||
// Clown animation
|
||||
//
|
||||
#define CLOWN_BMP ".\\art\\gum.bmp"
|
||||
|
||||
#define CLOWN_FRAMES 24 // Clown morph frames
|
||||
|
||||
#define CLOWN_BMP_HEI 96 // demensions of clown art
|
||||
#define CLOWN_BMP_WID 110
|
||||
|
||||
#define CLOWN_LEFT 16 // demensions of clown rect
|
||||
#define CLOWN_TOP 27
|
||||
#define CLOWN_RIG (CLOWN_LEFT + CLOWN_BMP_HEI)
|
||||
#define CLOWN_BOT (CLOWN_TOP + CLOWN_BMP_WID)
|
||||
|
||||
#define CLOWN_TIME_SLICE 1 // millisecs, pause between animation cells
|
||||
|
||||
//
|
||||
// UFO beam up animation
|
||||
//
|
||||
#define UFOA_BMP ".\\art\\ufo1a.bmp"
|
||||
#define UFOB_BMP ".\\art\\ufo1b.bmp"
|
||||
|
||||
#define UFOA_FRAMES 16 // UFOa frames
|
||||
#define UFOB_FRAMES 14 // UFOa frames
|
||||
|
||||
#define UFO_BMP_HEI 198 // demensions of UFO art
|
||||
#define UFO_BMP_WID 123
|
||||
|
||||
#define UFO_LEFT 134 // demensions of UFO rect
|
||||
#define UFO_TOP 24
|
||||
#define UFO_RIG (UFO_LEFT + UFO_BMP_HEI)
|
||||
#define UFO_BOT (UFO_TOP + UFO_BMP_WID)
|
||||
|
||||
#define CAR_LEFT 136 // demensions of race car rect
|
||||
#define CAR_TOP 116
|
||||
#define CAR_RIG 228
|
||||
#define CAR_BOT 145
|
||||
|
||||
#define UFOA_TIME_SLICE 1 // millisecs, pause between animation cells
|
||||
#define UFOB_TIME_SLICE 100 // millisecs, pause between animation cells
|
||||
#define UFO_PAUSE 1000 // wait a second after stealing the car
|
||||
//
|
||||
// Brat effect
|
||||
//
|
||||
#define BRAT_LEFT 405
|
||||
#define BRAT_TOP 24
|
||||
#define BRAT_RIG 463
|
||||
#define BRAT_BOT 62
|
||||
|
||||
//
|
||||
// Lollipop effect
|
||||
//
|
||||
#define LOLLI_LEFT 472
|
||||
#define LOLLI_TOP 52
|
||||
#define LOLLI_RIG 483
|
||||
#define LOLLI_BOT 59
|
||||
|
||||
//
|
||||
// Haircut effect
|
||||
//
|
||||
#define CUT_LEFT 563 //355
|
||||
#define CUT_TOP 26 //120
|
||||
#define CUT_RIG 625 //418
|
||||
#define CUT_BOT 178 //154
|
||||
|
||||
class CAnimate {
|
||||
private: // variables
|
||||
CSprite *m_pSprite;
|
||||
CRect m_cClownRect;
|
||||
CRect m_cUFORect;
|
||||
CRect m_cCarRect;
|
||||
CRect m_cBratRect;
|
||||
CRect m_cLolliRect;
|
||||
CRect m_cCutRect;
|
||||
CSound *m_pSound;
|
||||
|
||||
public: // functions
|
||||
CAnimate(CSound*);
|
||||
~CAnimate();
|
||||
|
||||
bool Clown(CDC*, CPoint);
|
||||
bool UFO(CDC*, CPoint);
|
||||
bool Brat(CPoint);
|
||||
bool Lollipop(CPoint);
|
||||
bool Haircut(CPoint);
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
802
engines/bagel/hodjnpodj/barbershop/barb.cpp
Normal file
802
engines/bagel/hodjnpodj/barbershop/barb.cpp
Normal file
@@ -0,0 +1,802 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cmessbox.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
#include "bagel/hodjnpodj/barbershop/barb.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
//
|
||||
// global
|
||||
//
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* CBarber
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Initializes members.
|
||||
*
|
||||
* FORMAL PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: barbershop quintet object
|
||||
*
|
||||
****************************************************************/
|
||||
CBarber::CBarber(CDC *pDC, CSound *pSound) {
|
||||
m_cDck = new CDeck();
|
||||
m_cPnt = new CPaint(pDC);
|
||||
m_cBrd = new CBoard(m_cPnt);
|
||||
m_pLogic = new CLogic();
|
||||
m_pUndo = new CUndo();
|
||||
m_pSound = pSound;
|
||||
m_pCrd = nullptr; // remembers cur card
|
||||
|
||||
/********************************************************
|
||||
* Switchs used to prevent further user updates *
|
||||
* after timer has run out, no moves left, or is solved. *
|
||||
********************************************************/
|
||||
m_bIsGameOver = false; // Initialize solved switch
|
||||
m_bIsWin = false; // Initialize win/lose switch
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* ~Barber
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Destructor
|
||||
*
|
||||
* FORMAL PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
CBarber::~CBarber() {
|
||||
|
||||
if (m_pSound != nullptr) {
|
||||
m_pSound = nullptr; // never init with a "new" operator
|
||||
}
|
||||
|
||||
if (m_pUndo != nullptr) {
|
||||
delete m_pUndo;
|
||||
m_pUndo = nullptr;
|
||||
}
|
||||
|
||||
if (m_pLogic != nullptr) {
|
||||
delete m_pLogic;
|
||||
m_pLogic = nullptr;
|
||||
}
|
||||
|
||||
if (m_cBrd != nullptr) {
|
||||
delete m_cBrd;
|
||||
m_cBrd = nullptr;
|
||||
}
|
||||
|
||||
if (m_cPnt != nullptr) {
|
||||
delete m_cPnt;
|
||||
m_cPnt = nullptr;
|
||||
}
|
||||
|
||||
if (m_cDck != nullptr) {
|
||||
delete m_cDck;
|
||||
m_cDck = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* NewGame
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Resets interal state, and starts a new game.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* pDC - device context for painting images to the window.
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CBarber::NewGame(CDC *pDC) {
|
||||
m_cDck->Shuffle();
|
||||
m_cDck->Deal(m_cBrd);
|
||||
m_cPnt->Board(pDC, m_cBrd); // paint the cards visually on the board
|
||||
m_pUndo->Reset(); // clear all undo info
|
||||
m_bIsGameOver = false; // turn off game over switch
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Refresh
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Repaints all cards on the board.
|
||||
*
|
||||
* FORMAL PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CBarber::Refresh(CDC *pDC) {
|
||||
m_cPnt->Refresh(pDC, m_cBrd);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnLButtonDown
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Determines if user clicked on a card or on the undo area.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* pWnd - the parent window used for poping up message dialog
|
||||
* boxes.
|
||||
* pPalette - passed to any message box that needs to be
|
||||
* displayed.
|
||||
* point - point where user double clicked.
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_pCrd - will remember what card user clicked on.
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CBarber::OnLButtonDown(CWnd *pWnd, CPalette *pPalette, CPoint point) {
|
||||
CDC *pDC = nullptr; // device context for painting
|
||||
CCard *pCard; // for stack push and pop operations
|
||||
int i; // index
|
||||
|
||||
if ( // user want to undo a change?
|
||||
m_pUndo->m_cUndoRect.PtInRect(point) == true &&
|
||||
m_pCrd == nullptr
|
||||
) {
|
||||
pDC = pWnd->GetDC();
|
||||
|
||||
if (pGameParams->bSoundEffectsEnabled != false)
|
||||
m_pSound->initialize(
|
||||
UNDO,
|
||||
SOUND_WAVE | SOUND_ASYNCH
|
||||
);
|
||||
|
||||
if (m_pUndo->Undo(pDC, m_cBrd, m_cPnt) == true) { // undo successful?
|
||||
if (pGameParams->bSoundEffectsEnabled != false)
|
||||
m_pSound->play();
|
||||
|
||||
// undoing does not always guarantee there is a move left,
|
||||
// but it is okay to reset game over switch anyway.
|
||||
//
|
||||
m_bIsGameOver = false; // yes - undo successful.
|
||||
} // end if
|
||||
pWnd->ReleaseDC(pDC);
|
||||
return;
|
||||
} // end if
|
||||
|
||||
if (m_bIsGameOver == true)
|
||||
return;
|
||||
|
||||
if ((m_pCrd = m_cPnt->IsOnCard(point)) == nullptr) { // get card corr to point
|
||||
/********************************************************
|
||||
* Find out if stock cards need to be recycled. This *
|
||||
* will occur if the stock card stack is empty and there *
|
||||
* are cards on the used stack. *
|
||||
********************************************************/
|
||||
if (
|
||||
m_cBrd->GetStack((loc) stock)->m_cRect.PtInRect(point) == true &&
|
||||
m_cBrd->GetStack((loc) stock)->IsEmpty() == true
|
||||
) {
|
||||
int nFlipSnd = 0; // keeps track of when to play fwap sound
|
||||
pDC = pWnd->GetDC();
|
||||
|
||||
// user wants to recycle used stack
|
||||
//
|
||||
if (pGameParams->bSoundEffectsEnabled != false) // init sound if it is enabled
|
||||
m_pSound->initialize(
|
||||
STOCKCARDS,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
|
||||
while (m_cBrd->GetStack((loc) used)->IsEmpty() != true) {
|
||||
pCard = m_cBrd->GetStack((loc) used)->Pop(); // take top card off used stack
|
||||
m_cBrd->GetStack((loc) stock)->Push(pCard); // put it on stock stack
|
||||
|
||||
// sound (if enabled)
|
||||
if (
|
||||
pGameParams->bSoundEffectsEnabled != false &&
|
||||
nFlipSnd % RECYCLE_SOUND_FREQ == 0
|
||||
)
|
||||
m_pSound->play(); // make flap sound...
|
||||
nFlipSnd++; // every three cards
|
||||
|
||||
m_cPnt->FlipCard(pDC, pCard); // repaint top card
|
||||
m_cPnt->Stack(pDC, pCard); // indented on approp stack
|
||||
} // end while
|
||||
pWnd->ReleaseDC(pDC); // release device context!
|
||||
m_pUndo->Reset(); // Can't undo recycled used stack
|
||||
} // end if
|
||||
return;
|
||||
} // end if
|
||||
|
||||
/*****************************************************************
|
||||
* Figure out what stack user clicked on, and behave accordingly. *
|
||||
*****************************************************************/
|
||||
switch (m_pCrd->m_pStack->GetID()) {
|
||||
|
||||
case fnd: { // foundation stack
|
||||
/************************************************
|
||||
* Not allowed to remove cards from foundation. *
|
||||
* Tell the user his score. *
|
||||
************************************************/
|
||||
char buf[32];
|
||||
Common::sprintf_s(buf, "Score: %d", Score());
|
||||
CMessageBox cmsgboxScore(
|
||||
pWnd,
|
||||
pPalette,
|
||||
buf
|
||||
);
|
||||
m_pCrd = nullptr; // don't remember the clicked card
|
||||
return;
|
||||
}
|
||||
|
||||
case stock: { // stock stack
|
||||
/****************************************************
|
||||
* Flip cards from stock to used stack, or recycle *
|
||||
* cards on used stack if used stack is empty. *
|
||||
****************************************************/
|
||||
CStack *pStock, *pUsed;
|
||||
|
||||
pStock = m_cBrd->GetStack(stock); // get stock stack for future ref
|
||||
pUsed = m_cBrd->GetStack(used); // get used stack too.
|
||||
|
||||
// sound (if enabled)
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
STOCKCARDS,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
m_pSound->play();
|
||||
}
|
||||
|
||||
pDC = pWnd->GetDC();
|
||||
|
||||
for (i = 0; i < STOCK_DRAW; i++) { // flip over three cards onto used stack
|
||||
if ((pCard = pStock->Pop()) == nullptr) { // Out of cards on the Stock stack?
|
||||
break;
|
||||
}
|
||||
|
||||
// Move card from stock stack, to used stack.
|
||||
//
|
||||
m_cPnt->FlipCard(pDC, pCard); // give card a flipped sprite
|
||||
pUsed->Push(pCard); // put stock card on used stack
|
||||
m_cPnt->Stack(pDC, pCard); // paint card appropriately indented
|
||||
} // end for
|
||||
|
||||
pWnd->ReleaseDC(pDC);
|
||||
|
||||
if (pStock->IsEmpty() == true) // game over?
|
||||
IsGameOver(pWnd);
|
||||
|
||||
m_pUndo->Record(i); // note stack flip for possible undoing
|
||||
m_pCrd = nullptr; // don't remember the clicked card
|
||||
return;
|
||||
} // end case
|
||||
|
||||
case used: // used stack rules
|
||||
return; // have fun with these! (no special function)
|
||||
|
||||
default: // tab stack
|
||||
if (m_pCrd->m_bIsBack == true) { // want to flip over card?
|
||||
pDC = pWnd->GetDC(); // yes
|
||||
m_cPnt->FlipCard(pDC, m_pCrd); // flip card
|
||||
m_cPnt->UpdateCard(pDC, m_pCrd); // paint it
|
||||
pWnd->ReleaseDC(pDC);
|
||||
|
||||
m_pUndo->Reset(); // Can't undo flipped card
|
||||
m_pCrd = nullptr; // don't remember the clicked card
|
||||
return;
|
||||
} // end if
|
||||
} // end switch
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnLButtonDblClk
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Handles undo and stock card flips only. Will not remember
|
||||
* card moving.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* pWnd - the parent window used for poping up message dialog
|
||||
* boxes.
|
||||
* pPalette - passed to any message box that needs to be
|
||||
* displayed.
|
||||
* point - point where user double clicked.
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_pCrd - will remember what card user clicked on.
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CBarber::OnLButtonDblClk(CWnd *pWnd, CPalette *pPalette, CPoint point) {
|
||||
CDC *pDC = nullptr;
|
||||
CCard *pCard;
|
||||
int i;
|
||||
|
||||
if ( // user want to undo a change?
|
||||
m_pUndo->m_cUndoRect.PtInRect(point) == true &&
|
||||
m_pCrd == nullptr
|
||||
) {
|
||||
pDC = pWnd->GetDC();
|
||||
if (pGameParams->bSoundEffectsEnabled != false)
|
||||
m_pSound->initialize(
|
||||
UNDO,
|
||||
SOUND_WAVE | SOUND_QUEUE
|
||||
);
|
||||
|
||||
if (m_pUndo->Undo(pDC, m_cBrd, m_cPnt) == true) { // undo successful?
|
||||
if (pGameParams->bSoundEffectsEnabled != false)
|
||||
m_pSound->play();
|
||||
|
||||
m_bIsGameOver = false; // yes
|
||||
}
|
||||
pWnd->ReleaseDC(pDC);
|
||||
return;
|
||||
} // end if
|
||||
|
||||
if (m_bIsGameOver == true)
|
||||
return;
|
||||
|
||||
if ((m_pCrd = m_cPnt->IsOnCard(point)) == nullptr) { // get card corr to point
|
||||
/********************************************************
|
||||
* Find out if stock cards need to be recycled. This *
|
||||
* will occur if the stock card stack is empty and there *
|
||||
* are cards on the used stack. *
|
||||
********************************************************/
|
||||
if (
|
||||
m_cBrd->GetStack((loc) stock)->m_cRect.PtInRect(point) == true &&
|
||||
m_cBrd->GetStack((loc) stock)->IsEmpty() == true
|
||||
) {
|
||||
int nFlipSnd = 0; // keeps track of when to play fwap sound
|
||||
|
||||
// user wants to recycle used stack
|
||||
//
|
||||
if (pGameParams->bSoundEffectsEnabled != false) // init sound if it is enabled
|
||||
m_pSound->initialize(
|
||||
STOCKCARDS,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
|
||||
pDC = pWnd->GetDC();
|
||||
while (m_cBrd->GetStack((loc) used)->IsEmpty() != true) {
|
||||
pCard = m_cBrd->GetStack((loc) used)->Pop(); // get used card
|
||||
m_cBrd->GetStack((loc) stock)->Push(pCard); // put used card onto stock
|
||||
|
||||
// sound (if enabled)
|
||||
if ( // play fwap sound...
|
||||
pGameParams->bSoundEffectsEnabled != false && // every RECYCLE_'_FREQ card
|
||||
nFlipSnd % RECYCLE_SOUND_FREQ == 0
|
||||
)
|
||||
m_pSound->play(); // make flap sound...
|
||||
nFlipSnd++; // update fwap counter
|
||||
|
||||
m_cPnt->FlipCard(pDC, pCard); // change card sprite
|
||||
m_cPnt->Stack(pDC, pCard); // paint card properly indented on approp stack
|
||||
} // end while
|
||||
pWnd->ReleaseDC(pDC);
|
||||
m_pUndo->Reset(); // Can't undo recycled used stack
|
||||
|
||||
} // end if
|
||||
|
||||
return;
|
||||
} // end if
|
||||
|
||||
/*****************************************************************
|
||||
* Figure out what stack user clicked on, and behave accordingly. *
|
||||
*****************************************************************/
|
||||
switch (m_pCrd->m_pStack->GetID()) {
|
||||
|
||||
case fnd: { // foundation stack rules
|
||||
/***********************************************
|
||||
* Not allowed to remove cards from foundation. *
|
||||
***********************************************/
|
||||
char buf[32];
|
||||
Common::sprintf_s(buf, "Score: %d", Score());
|
||||
CMessageBox cGameOver(
|
||||
pWnd,
|
||||
pPalette,
|
||||
buf
|
||||
);
|
||||
m_pCrd = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
case stock: { // stock stack rules
|
||||
/****************************************************
|
||||
* Flip cards from stock to used stack, or recycle *
|
||||
* cards on used stack if used stack is empty. *
|
||||
****************************************************/
|
||||
CStack *pStock, *pUsed;
|
||||
|
||||
pStock = m_cBrd->GetStack(stock);
|
||||
pUsed = m_cBrd->GetStack(used);
|
||||
|
||||
// sound (if enabled)
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
STOCKCARDS,
|
||||
SOUND_WAVE | SOUND_ASYNCH | SOUND_QUEUE
|
||||
);
|
||||
m_pSound->play();
|
||||
} // end if
|
||||
|
||||
for (i = 0; i < STOCK_DRAW; i++) {
|
||||
if ((pCard = pStock->Pop()) == nullptr) { // Out of cards on the Stock stack?
|
||||
break;
|
||||
}
|
||||
pDC = pWnd->GetDC();
|
||||
m_cPnt->FlipCard(pDC, pCard);
|
||||
pUsed->Push(pCard);
|
||||
m_cPnt->Stack(pDC, pCard);
|
||||
pWnd->ReleaseDC(pDC);
|
||||
} // end for
|
||||
|
||||
if (pStock->IsEmpty() == true)
|
||||
IsGameOver(pWnd);
|
||||
|
||||
m_pUndo->Record(i); // note stack flip for possible undoing
|
||||
m_pCrd = nullptr;
|
||||
return;
|
||||
} // end case
|
||||
|
||||
default: // tab stacks
|
||||
if (m_pCrd->m_bIsBack == true) { // user want to flip a card?
|
||||
pDC = pWnd->GetDC();
|
||||
m_cPnt->FlipCard(pDC, m_pCrd);
|
||||
m_cPnt->UpdateCard(pDC, m_pCrd);
|
||||
pWnd->ReleaseDC(pDC);
|
||||
|
||||
m_pUndo->Reset(); // Can't undo flipped card
|
||||
|
||||
m_pCrd = nullptr;
|
||||
return;
|
||||
} // end if
|
||||
} // end switch
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnMouseMove
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Paint the card at the mouse position if user is holding onto
|
||||
* a card.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* pDC - device context for painting images to the window.
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_pCrd - contains the card the user is holding.
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CBarber::OnMouseMove(CDC *pDC, CPoint point) {
|
||||
if (m_pCrd == nullptr) // no card selected
|
||||
return;
|
||||
|
||||
m_cPnt->MoveCard(pDC, m_pCrd, point);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnMouseMove
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Paint the card at the mouse position if user is holding onto
|
||||
* a card.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* pDC - Device context for painting images on the window.
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_pCrd - contains the card the user is holding.
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CBarber::OnLButtonUp(CWnd *pWnd) {
|
||||
CDC *pDC = nullptr;
|
||||
bool bSuccess = false;
|
||||
CRect cTest;
|
||||
CStack *pStack;
|
||||
int i;
|
||||
|
||||
if (m_pCrd == nullptr) // no card selected
|
||||
return;
|
||||
|
||||
/************************************************************
|
||||
* Updates interal stack reps. Flip thru all stacks. *
|
||||
* Find card interception on any stack. Adds card to first *
|
||||
* intercepted stack. *
|
||||
************************************************************/
|
||||
for (i = 0; i <= used; i++) {
|
||||
pStack = m_cBrd->GetStack((loc) i); // get appropriate stack
|
||||
if (pStack->IsEmpty() == true) { // assigns rect of interest as
|
||||
cTest = pStack->m_cRect; // either base rect
|
||||
} else { // or card rect from top of stack
|
||||
cTest = pStack->Top()->m_pSprite->GetRect();
|
||||
} // end if
|
||||
|
||||
/************************************************************
|
||||
* Handles special case of current stack is same as *
|
||||
* stack that the card is in. In this case, either the *
|
||||
* the rect of previous card (if any) needs to be used as *
|
||||
* the test region. *
|
||||
************************************************************/
|
||||
if (m_pCrd->m_pStack == pStack) { // is card on original stack?
|
||||
if (m_pCrd->m_pPrevCard != nullptr) { // Yes - any other cards on this stack?
|
||||
cTest = pStack->Top()->m_pPrevCard->m_pSprite->GetRect();
|
||||
} else {
|
||||
cTest = pStack->m_cRect; // either base rect
|
||||
} // end if
|
||||
} // end if
|
||||
|
||||
/********************************************************
|
||||
* find out if corner points of the card line anywhere *
|
||||
* within a stack's rect. *
|
||||
********************************************************/
|
||||
//b
|
||||
if (IsInRect(cTest, m_pCrd->m_pSprite->GetRect()) == false) { //!= true ) { // is card on invalid area?
|
||||
continue;
|
||||
} // end if
|
||||
|
||||
if (m_pLogic->IsMoveOk(m_pCrd, pStack) == true) {
|
||||
m_pUndo->Record(m_pCrd->m_pStack, m_pCrd); // note move for possible undoing
|
||||
|
||||
m_pCrd->m_pStack->Pop();
|
||||
pStack->Push(m_pCrd);
|
||||
bSuccess = true;
|
||||
} // end if
|
||||
continue;
|
||||
//b break;
|
||||
} // end for
|
||||
|
||||
/*************************
|
||||
* Update visual display. *
|
||||
*************************/
|
||||
pDC = (*pWnd).GetDC();
|
||||
if (bSuccess != true) { // card dropped over stack?
|
||||
m_cPnt->UpdateCard(pDC, m_pCrd); // no - redraw card over original stack
|
||||
} else {
|
||||
m_cPnt->Stack(pDC, m_pCrd); // draw card apro stack
|
||||
} // end if
|
||||
(*pWnd).ReleaseDC(pDC);
|
||||
|
||||
m_pCrd = nullptr; // clear current card
|
||||
if (m_cBrd->GetStack(stock)->IsEmpty() == true)
|
||||
IsGameOver(pWnd); // game over?
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* IsInRect
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Determines if card's hotspot is intercepts the stack rectangle.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* cStk - The rectangle of the stack.
|
||||
* cCrd - The rectangle of the card.
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_pCrd - it assumes that the user is currently holding a card.
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
bool CBarber::IsInRect(CRect cStk, CRect cCrd) {
|
||||
//b CPoint point;
|
||||
CRect inter;
|
||||
bool bTL;
|
||||
/*
|
||||
point.x = cCrd.TopLeft().x + m_pCrd->m_pSprite->GetHotspot().x;
|
||||
point.y = cCrd.TopLeft().y + m_pCrd->m_pSprite->GetHotspot().y;
|
||||
*/
|
||||
|
||||
//b bTL = cStk.PtInRect(point);
|
||||
cStk.InflateRect(5, 5);
|
||||
|
||||
bTL = inter.IntersectRect(cStk, cCrd);
|
||||
return bTL;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* IsGameOver
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Checks every possible move to determine if there are any moves
|
||||
* left.
|
||||
*
|
||||
* FORMAL PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
bool CBarber::IsGameOver(CWnd *pWnd) {
|
||||
/*****************************
|
||||
* Determine if game is over. *
|
||||
*****************************/
|
||||
m_bIsGameOver = m_pLogic->IsGameOver(m_cBrd);
|
||||
if (m_bIsGameOver == false)
|
||||
return false;
|
||||
|
||||
/**********************
|
||||
* Determine win/loss. *
|
||||
**********************/
|
||||
if (m_cBrd->GetStack((loc) fnd)->Size() == DECK) {
|
||||
// sound (if enabled)
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
WIN_SOUND,
|
||||
SOUND_WAVE | SOUND_ASYNCH
|
||||
);
|
||||
m_pSound->play();
|
||||
}
|
||||
|
||||
m_bIsWin = true;
|
||||
} else {
|
||||
// sound (if enabled)
|
||||
if (pGameParams->bSoundEffectsEnabled != false) {
|
||||
m_pSound->initialize(
|
||||
LOSE_SOUND,
|
||||
SOUND_WAVE | SOUND_ASYNCH
|
||||
);
|
||||
m_pSound->play();
|
||||
}
|
||||
|
||||
m_bIsWin = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* IsNewBack
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
*
|
||||
* FORMAL PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
bool CBarber::IsNewBack(int nCardBack) {
|
||||
return m_cPnt->IsNewBack(nCardBack);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* ChangeBack
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
*
|
||||
* FORMAL PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CBarber::ChangeBack(CDC* pDC, int nCardBack) {
|
||||
m_cPnt->ChangeBack(pDC, m_cBrd, nCardBack);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Score
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Returns number of cards on the foundation, defined as the
|
||||
* score.
|
||||
*
|
||||
* FORMAL PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS: n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS: n/a
|
||||
*
|
||||
* RETURN VALUE: n/a
|
||||
*
|
||||
****************************************************************/
|
||||
int CBarber::Score() {
|
||||
return m_cBrd->GetStack(fnd)->Size();
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
90
engines/bagel/hodjnpodj/barbershop/barb.h
Normal file
90
engines/bagel/hodjnpodj/barbershop/barb.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_BARB_H
|
||||
#define HODJNPODJ_BARBERSHOP_BARB_H
|
||||
|
||||
#include "bagel/hodjnpodj/barbershop/deck.h"
|
||||
#include "bagel/hodjnpodj/barbershop/board.h"
|
||||
#include "bagel/hodjnpodj/barbershop/paint.h"
|
||||
#include "bagel/hodjnpodj/barbershop/logic.h"
|
||||
#include "bagel/hodjnpodj/barbershop/undo.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define NOT_USED -1
|
||||
#define USED 0
|
||||
|
||||
//
|
||||
// sounds
|
||||
//
|
||||
#define STOCKCARDS ".\\sound\\carddeal.wav"
|
||||
#define UNDO ".\\sound\\sound355.wav"
|
||||
#define WIN_SOUND ".\\sound\\applause.wav"
|
||||
#define LOSE_SOUND ".\\sound\\sosorry.wav"
|
||||
|
||||
//
|
||||
// related to stock card flipping sounds
|
||||
//
|
||||
#define RECYCLE_SOUND_FREQ 3
|
||||
|
||||
class CBarber {
|
||||
private:
|
||||
CDeck *m_cDck = nullptr; // Handles card shuffling
|
||||
CBoard *m_cBrd = nullptr; // contains position info for all card stacks on screen
|
||||
CLogic *m_pLogic = nullptr; // determines whether a given move is valid or not
|
||||
CUndo *m_pUndo = nullptr; // records moves made by user and handles move undoing
|
||||
CSound *m_pSound = nullptr;
|
||||
|
||||
public:
|
||||
CBarber(CDC*, CSound*);
|
||||
~CBarber();
|
||||
|
||||
void NewGame(CDC*);
|
||||
void Refresh(CDC*);
|
||||
void OnLButtonDown(CWnd*, CPalette*, CPoint);
|
||||
void OnLButtonDblClk(CWnd*, CPalette*, CPoint);
|
||||
void OnMouseMove(CDC*, CPoint);
|
||||
void OnLButtonUp(CWnd*);
|
||||
bool IsInRect(CRect cStk, CRect cCrd);
|
||||
bool IsGameOver(CWnd*);
|
||||
bool IsNewBack(int);
|
||||
void ChangeBack(CDC*, int);
|
||||
int Score();
|
||||
|
||||
CPaint *m_cPnt = nullptr; // used to visually paint cards on screen
|
||||
CCard *m_pCrd = nullptr; // the card being moved
|
||||
bool m_bIsGameOver = false; // tells if game has ended
|
||||
bool m_bIsWin = false; // tells if game was won or lost
|
||||
};
|
||||
|
||||
// Globals!
|
||||
extern CPalette *pGamePalette;
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
109
engines/bagel/hodjnpodj/barbershop/board.cpp
Normal file
109
engines/bagel/hodjnpodj/barbershop/board.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/barbershop/board.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
CBoard::CBoard(CPaint *m_cPnt) {
|
||||
int i;
|
||||
|
||||
m_pFound = new CStack(m_cPnt->m_cFound, fnd);
|
||||
|
||||
for (i = 0; i < TAB_COUNT; i++)
|
||||
m_pTab[i] = new CStack(m_cPnt->m_cTab[i], tab + i);
|
||||
|
||||
m_pStock = new CStack(m_cPnt->m_cStock, stock);
|
||||
m_pUsed = new CStack(m_cPnt->m_cUsed, used);
|
||||
}
|
||||
|
||||
CBoard::~CBoard() {
|
||||
int i;
|
||||
|
||||
if (m_pUsed != nullptr) {
|
||||
delete m_pUsed;
|
||||
m_pUsed = nullptr;
|
||||
}
|
||||
|
||||
if (m_pStock != nullptr) {
|
||||
delete m_pStock;
|
||||
m_pStock = nullptr;
|
||||
}
|
||||
|
||||
for (i = 0; i < TAB_COUNT; i++) {
|
||||
if (m_pTab[i] != nullptr) {
|
||||
delete m_pTab[i];
|
||||
m_pTab[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pFound != nullptr) {
|
||||
delete m_pFound;
|
||||
m_pFound = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
CStack *CBoard::GetStack(loc nStack) {
|
||||
int i;
|
||||
|
||||
switch (nStack) {
|
||||
|
||||
case fnd:
|
||||
return m_pFound;
|
||||
|
||||
case stock:
|
||||
return m_pStock;
|
||||
|
||||
case used:
|
||||
return m_pUsed;
|
||||
|
||||
default:
|
||||
for (i = 0; i < TAB_COUNT; i++)
|
||||
if (m_pTab[i]->GetID() == nStack)
|
||||
return m_pTab[i];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CBoard::IsTabStack(int nStack) {
|
||||
switch (nStack) {
|
||||
|
||||
case fnd:
|
||||
return false;
|
||||
|
||||
case stock:
|
||||
return false;
|
||||
|
||||
case used:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
51
engines/bagel/hodjnpodj/barbershop/board.h
Normal file
51
engines/bagel/hodjnpodj/barbershop/board.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_BOARD_H
|
||||
#define HODJNPODJ_BARBERSHOP_BOARD_H
|
||||
|
||||
#include "bagel/hodjnpodj/barbershop/paint.h"
|
||||
#include "bagel/hodjnpodj/barbershop/stack.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
class CBoard {
|
||||
public: // functions
|
||||
CBoard(CPaint*);
|
||||
~CBoard();
|
||||
|
||||
CStack *GetStack(loc);
|
||||
bool IsTabStack(int);
|
||||
|
||||
public: // vars
|
||||
CStack *m_pFound = nullptr;
|
||||
CStack *m_pTab[TAB_COUNT] = {};
|
||||
CStack *m_pStock = nullptr;
|
||||
CStack *m_pUsed = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
99
engines/bagel/hodjnpodj/barbershop/card.cpp
Normal file
99
engines/bagel/hodjnpodj/barbershop/card.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/barbershop/card.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
OSpr::OSpr() : CSprite() {
|
||||
m_cCard = nullptr;
|
||||
}
|
||||
|
||||
CCard::CCard() {
|
||||
m_enSuit = (suit) suit_none;
|
||||
m_nPip = 0;
|
||||
m_pPrevCard = nullptr;
|
||||
m_pNextCard = nullptr;
|
||||
m_pSprite = nullptr;
|
||||
m_pStack = nullptr;
|
||||
m_bIsBack = false;
|
||||
m_cOrigin = CPoint(0, 0);
|
||||
}
|
||||
|
||||
CCard::CCard(int nValue) {
|
||||
if (nValue >= SUITS * PIPS) { // Is this a joker card?
|
||||
m_enSuit = manicurist; // Yes - assign joker suit
|
||||
m_nPip = MANI_CARD; // and joker pip
|
||||
} else {
|
||||
m_enSuit = (suit)(nValue % SUITS); // No - assign usual suit
|
||||
m_nPip = nValue % PIPS;
|
||||
}
|
||||
|
||||
m_pPrevCard = nullptr;
|
||||
m_pNextCard = nullptr;
|
||||
m_pSprite = nullptr;
|
||||
m_pStack = nullptr;
|
||||
m_bIsBack = false;
|
||||
m_cOrigin = CPoint(0, 0);
|
||||
}
|
||||
|
||||
CCard::CCard(suit enSuit, int nPip) {
|
||||
m_enSuit = enSuit;
|
||||
m_nPip = nPip;
|
||||
m_pPrevCard = nullptr;
|
||||
m_pNextCard = nullptr;
|
||||
m_pSprite = nullptr;
|
||||
m_pStack = nullptr;
|
||||
m_bIsBack = false;
|
||||
m_cOrigin = CPoint(0, 0);
|
||||
}
|
||||
|
||||
CCard::~CCard() {
|
||||
}
|
||||
|
||||
int CCard::GetValue() const {
|
||||
if (m_enSuit == manicurist) { // Is Joker suit?
|
||||
return m_nPip; // return it's special pip
|
||||
} else {
|
||||
return m_nPip + (m_enSuit * PIPS);
|
||||
}
|
||||
}
|
||||
|
||||
CCard &CCard::operator=(const CCard& cCard) {
|
||||
m_enSuit = cCard.m_enSuit; // Private members
|
||||
m_nPip = cCard.m_nPip;
|
||||
|
||||
m_pPrevCard = cCard.m_pPrevCard; // Public members
|
||||
m_pNextCard = cCard.m_pNextCard;
|
||||
m_pStack = cCard.m_pStack;
|
||||
m_bIsBack = cCard.m_bIsBack;
|
||||
m_pSprite = cCard.m_pSprite;
|
||||
m_cOrigin = cCard.m_cOrigin;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
114
engines/bagel/hodjnpodj/barbershop/card.h
Normal file
114
engines/bagel/hodjnpodj/barbershop/card.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_CARD_H
|
||||
#define HODJNPODJ_BARBERSHOP_CARD_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define TAB_COUNT 5
|
||||
#define TAB_STACK 7
|
||||
#define TABLEAU 35
|
||||
|
||||
#define STOCK 27
|
||||
#define STOCK_DRAW 3
|
||||
|
||||
#define SUITS 5
|
||||
#define PIPS 12
|
||||
|
||||
#define ONE_CARD 0
|
||||
#define TWO_CARD 1
|
||||
#define THREE_CARD 2
|
||||
#define FOUR_CARD 3
|
||||
#define FIVE_CARD 4
|
||||
#define SIX_CARD 5
|
||||
#define SEVEN_CARD 6
|
||||
#define EIGHT_CARD 7
|
||||
#define NINE_CARD 8
|
||||
#define TEN_CARD 9
|
||||
#define CUST_CARD 10
|
||||
#define BARB_CARD 11
|
||||
#define MANI_CARD 60
|
||||
|
||||
enum suit {suit_none = -1, brush, comb, mirror, razor, sissor, manicurist};
|
||||
enum loc {loc_none = -1, fnd, tab, stock = 6, used};
|
||||
|
||||
class CStack;
|
||||
class CCard;
|
||||
|
||||
class OSpr : public CSprite {
|
||||
public:
|
||||
OSpr();
|
||||
|
||||
CCard *m_cCard;
|
||||
};
|
||||
|
||||
class CCard {
|
||||
private: // vars
|
||||
suit m_enSuit;
|
||||
int m_nPip;
|
||||
|
||||
public: // functions
|
||||
|
||||
CCard(suit enSuit, int nPip);
|
||||
CCard(int);
|
||||
CCard();
|
||||
~CCard();
|
||||
|
||||
int GetValue() const;
|
||||
int GetPip() const {
|
||||
return m_nPip;
|
||||
}
|
||||
bool IsFace() const {
|
||||
return m_nPip >= CUST_CARD;
|
||||
}
|
||||
bool IsCustomer() const {
|
||||
return m_nPip == CUST_CARD;
|
||||
}
|
||||
bool IsBarber() const {
|
||||
return m_nPip == BARB_CARD;
|
||||
}
|
||||
bool IsManicurist() {
|
||||
return m_nPip == MANI_CARD;
|
||||
}
|
||||
bool operator==(int nValue) const {
|
||||
return nValue == GetValue();
|
||||
}
|
||||
CCard &operator=(const CCard &);
|
||||
|
||||
public: // vars
|
||||
CCard *m_pPrevCard;
|
||||
CCard *m_pNextCard;
|
||||
OSpr *m_pSprite;
|
||||
CStack *m_pStack;
|
||||
bool m_bIsBack;
|
||||
CPoint m_cOrigin;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
91
engines/bagel/hodjnpodj/barbershop/deck.cpp
Normal file
91
engines/bagel/hodjnpodj/barbershop/deck.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/barbershop/deck.h"
|
||||
#include "bagel/hodjnpodj/barbershop/board.h"
|
||||
#include "bagel/hodjnpodj/barbershop/stack.h"
|
||||
#include "bagel/hodjnpodj/hodjnpodj.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
CDeck::CDeck() {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DECK; i++)
|
||||
m_cDeck[i] = CCard(i); // Reset deck
|
||||
|
||||
//srand((unsigned) time(nullptr)); // seed the random number generator
|
||||
}
|
||||
|
||||
CDeck::~CDeck() {
|
||||
}
|
||||
|
||||
void CDeck::Shuffle() {
|
||||
int nNewDeck[DECK];
|
||||
int nCard;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DECK; i++)
|
||||
nNewDeck[i] = NOT_USED;
|
||||
|
||||
/******************************
|
||||
* Find an unused encrypt map. *
|
||||
******************************/
|
||||
for (i = 0; i < DECK; i++) {
|
||||
|
||||
#ifndef REVEAL // change ifndef to ifdef for debugging purposes
|
||||
do {
|
||||
nCard = brand() % DECK;
|
||||
} while (nNewDeck[nCard] == USED); // find unshuffled card
|
||||
|
||||
nNewDeck[nCard] = USED; // mark card as shuffled
|
||||
|
||||
#else
|
||||
nCard = i % 2;
|
||||
if (nCard == 1)
|
||||
nCard = CUST_CARD;
|
||||
#endif
|
||||
|
||||
m_cDeck[i] = CCard(nCard); // put card into it's new location
|
||||
}
|
||||
}
|
||||
|
||||
void CDeck::Deal(CBoard *pBoard) {
|
||||
int nStack, nCard, i;
|
||||
|
||||
for (nStack = fnd; nStack <= used; nStack++)
|
||||
pBoard->GetStack((loc) nStack)->Reset();
|
||||
|
||||
|
||||
for (nStack = tab, i = 1, nCard = 0; nStack < stock; nStack++, i++)
|
||||
for (; nCard < (i * (TAB_STACK)); nCard++)
|
||||
pBoard->GetStack((loc) nStack)->Push(&m_cDeck[nCard]);
|
||||
|
||||
for (; nCard < (STOCK + TABLEAU); nCard++)
|
||||
pBoard->GetStack(stock)->Push(&m_cDeck[nCard]);
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
56
engines/bagel/hodjnpodj/barbershop/deck.h
Normal file
56
engines/bagel/hodjnpodj/barbershop/deck.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_DECK_H
|
||||
#define HODJNPODJ_BARBERSHOP_DECK_H
|
||||
|
||||
#include "bagel/hodjnpodj/barbershop/card.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define DECK 62
|
||||
#define STOCK 27
|
||||
|
||||
#define NOT_USED -1
|
||||
#define USED 0
|
||||
|
||||
class CBoard;
|
||||
|
||||
class CDeck {
|
||||
public: // func
|
||||
|
||||
CDeck(); // constructor
|
||||
~CDeck(); // destructor
|
||||
|
||||
void Shuffle();
|
||||
void Deal(CBoard*);
|
||||
|
||||
public: // vars
|
||||
CCard m_cDeck[DECK];
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
95
engines/bagel/hodjnpodj/barbershop/init.cpp
Normal file
95
engines/bagel/hodjnpodj/barbershop/init.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/barbershop/main.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunBarb
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke Barbershop Quintet.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
HWND FAR PASCAL RunBarb(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CMainWindow *pMain;
|
||||
|
||||
pGameParams = lpGameInfo;
|
||||
|
||||
// invoke your game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMain = new CMainWindow) != nullptr) {
|
||||
|
||||
pMain->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
pMain->UpdateWindow();
|
||||
|
||||
pMain->SetActiveWindow();
|
||||
}
|
||||
|
||||
// these must be set in this function
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMain->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
38
engines/bagel/hodjnpodj/barbershop/init.h
Normal file
38
engines/bagel/hodjnpodj/barbershop/init.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_GAMEDLL_H
|
||||
#define HODJNPODJ_BARBERSHOP_GAMEDLL_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
extern HWND FAR PASCAL RunBarb(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
66
engines/bagel/hodjnpodj/barbershop/jay.cpp
Normal file
66
engines/bagel/hodjnpodj/barbershop/jay.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/barbershop/resource.h"
|
||||
#include "bagel/hodjnpodj/barbershop/usercfg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
void MyFocusRect(CDC *pDC, CRect rect, int nDrawMode) {
|
||||
CBrush *pMyBrush = nullptr; // New Brush
|
||||
CBrush *pOldBrush = nullptr; // Pointer to old brush
|
||||
CPen *pMyPen = nullptr; // New Pen
|
||||
CPen *pOldPen = nullptr; // Pointer to old pen
|
||||
CPalette *pPalOld = nullptr; // Pointer to old palette
|
||||
int OldDrawMode; // Holder for old draw mode
|
||||
|
||||
pMyBrush = new CBrush(); // Construct new brush
|
||||
pMyPen = new CPen(); // Construct new pen
|
||||
|
||||
LOGBRUSH lb; // log brush type
|
||||
lb.lbStyle = BS_HOLLOW; // Don't fill in area
|
||||
pMyBrush->CreateBrushIndirect(&lb); // Create a new brush
|
||||
pMyPen->CreatePen(PS_INSIDEFRAME, HILITE_BORDER, RGBCOLOR_DARKRED); // Create a new pen
|
||||
|
||||
pPalOld = (*pDC).SelectPalette(pGamePalette, false); // Select in game palette
|
||||
(*pDC).RealizePalette(); // Use it
|
||||
pOldPen = pDC->SelectObject(pMyPen); // Select the new pen & save old
|
||||
pOldBrush = pDC->SelectObject(pMyBrush); // Select the new brush & save old
|
||||
OldDrawMode = pDC->SetROP2(nDrawMode); // Set pen mode, saving old state
|
||||
pDC->Rectangle(rect); // Draw the Rectangle to the DC
|
||||
pDC->SelectObject(pOldPen); // Select the old pen
|
||||
pDC->SelectObject(pOldBrush); // Select the old brush
|
||||
pDC->SetROP2(OldDrawMode); // Set pen mode back to old state
|
||||
(*pDC).SelectPalette(pPalOld, false); // Select back the old palette
|
||||
|
||||
pMyBrush->DeleteObject();
|
||||
delete pMyBrush;
|
||||
|
||||
pMyPen->DeleteObject();
|
||||
delete pMyPen;
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
315
engines/bagel/hodjnpodj/barbershop/logic.cpp
Normal file
315
engines/bagel/hodjnpodj/barbershop/logic.cpp
Normal file
@@ -0,0 +1,315 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/barbershop/logic.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Logic
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Destructor
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
CLogic::CLogic() {
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* ~Logic
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Destructor
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
CLogic::~CLogic() {
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* IsMoveOk
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Destructor
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
bool CLogic::IsMoveOk(CCard *pCard, CStack *pStack) {
|
||||
CCard *pTopCard;
|
||||
|
||||
switch (pStack->GetID()) {
|
||||
|
||||
case fnd: // foundation rules
|
||||
if (pCard->IsFace() == true)
|
||||
return true;
|
||||
if (pStack->IsEmpty() == true)
|
||||
return false;
|
||||
|
||||
pTopCard = pStack->Top();
|
||||
if (pTopCard->IsManicurist() == true)
|
||||
return true;
|
||||
|
||||
if (
|
||||
pTopCard->IsCustomer() == true &&
|
||||
pCard->GetPip() == ONE_CARD
|
||||
)
|
||||
return true;
|
||||
|
||||
if (
|
||||
pTopCard->IsBarber() == true &&
|
||||
pCard->GetPip() == TEN_CARD
|
||||
)
|
||||
return true;
|
||||
|
||||
if (pTopCard->GetPip() == ONE_CARD) {
|
||||
if (pCard->GetPip() == TWO_CARD) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTopCard->GetPip() == TEN_CARD) {
|
||||
if (pCard->GetPip() == NINE_CARD) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(
|
||||
pTopCard->GetPip() == (pCard->GetPip() + 1) ||
|
||||
pTopCard->GetPip() == (pCard->GetPip() - 1)
|
||||
) &&
|
||||
pTopCard->IsFace() == false
|
||||
)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
case stock:
|
||||
return false;
|
||||
case used:
|
||||
return false;
|
||||
default: // tab
|
||||
if (pStack->IsEmpty() == true) { // empty space on tab?
|
||||
if ( // yes - source card from stack with other face cards?
|
||||
pCard->m_pStack->GetID() >= tab &&
|
||||
pCard->m_pStack->GetID() < stock &&
|
||||
pCard->m_pPrevCard != nullptr &&
|
||||
pCard->m_pPrevCard->m_bIsBack == true
|
||||
)
|
||||
return true; // this is a valid move
|
||||
if ( // yes - source card from stock?
|
||||
pCard->m_pStack->GetID() == used
|
||||
)
|
||||
return true; // this is a valid move
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
pStack->IsEmpty() == true &&
|
||||
pCard->m_pStack->GetID() >= tab &&
|
||||
pCard->m_pStack->GetID() < stock &&
|
||||
pCard->m_pPrevCard != nullptr &&
|
||||
pCard->m_pPrevCard->m_bIsBack == true
|
||||
) // when there's an empty space on the tab
|
||||
return true;
|
||||
|
||||
|
||||
pTopCard = pStack->Top();
|
||||
if (pCard == pTopCard) // card back on it's own stack?
|
||||
return false; // yes, illegal
|
||||
|
||||
if (pTopCard->m_bIsBack == true)
|
||||
return false;
|
||||
|
||||
if (
|
||||
pTopCard->IsManicurist() == true &&
|
||||
pCard->IsManicurist() == true
|
||||
)
|
||||
return true;
|
||||
|
||||
if (pTopCard->GetPip() == pCard->GetPip()) {
|
||||
if (pCard->m_pStack->GetID() == used) // Card from used stack?
|
||||
return true; // yes - acceptable move
|
||||
if (pCard->m_pPrevCard == nullptr) // anything under cur card?
|
||||
return true; // no
|
||||
if (pCard->m_pPrevCard->m_bIsBack == true) // card under cur card a card back?
|
||||
return true; // yes
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CLogic::IsGameOver(CBoard *pBoard) {
|
||||
CStack *pFnd;
|
||||
CCard *pCard;
|
||||
int i, j;
|
||||
|
||||
pFnd = pBoard->GetStack((loc) fnd);
|
||||
if (pFnd->Size() == DECK) // All cards on foundation?
|
||||
return true; // Yes
|
||||
|
||||
/******************************************************
|
||||
* Check all combinations of tableau to tableau moves. *
|
||||
******************************************************/
|
||||
for (i = tab; i < stock; i++) {
|
||||
if ((pCard = pBoard->GetStack((loc) i)->Top()) == nullptr)
|
||||
continue;
|
||||
|
||||
if (pCard->m_bIsBack == true)
|
||||
return false;
|
||||
|
||||
for (j = tab; j < stock; j++) {
|
||||
if (pCard->m_pStack == pBoard->GetStack((loc) j))
|
||||
continue;
|
||||
if (IsMoveOk(pCard, pBoard->GetStack((loc) j)) == true)
|
||||
return false;
|
||||
} // end for
|
||||
} // end for
|
||||
|
||||
//return false; // used for debugging purposes
|
||||
|
||||
/*********************************************************
|
||||
* Check all combinations of tableau to foundation moves. *
|
||||
*********************************************************/
|
||||
for (i = tab; i < stock; i++) {
|
||||
if ((pCard = pBoard->GetStack((loc) i)->Top()) == nullptr)
|
||||
continue;
|
||||
|
||||
if (IsMoveOk(pCard, pFnd) == true)
|
||||
return false;
|
||||
} // end for
|
||||
|
||||
/************************************
|
||||
* Check all combinations of *
|
||||
* - used stack to tableau moves. *
|
||||
* - used stack to foundation. *
|
||||
* - stock to tableau moves. *
|
||||
* - stock to foundation. *
|
||||
************************************/
|
||||
pCard = pBoard->GetStack((loc) stock)->Top();
|
||||
while (pCard != nullptr) {
|
||||
for (j = 0; j < STOCK_DRAW; j++) {
|
||||
if (pCard->m_pStack->Bottom() == pCard) // Out of cards on the Stock stack?
|
||||
break;
|
||||
|
||||
if (pCard->m_pStack->Top() == pCard) // if top, skip a count
|
||||
j++;
|
||||
|
||||
pCard = pCard->m_pPrevCard;
|
||||
} // end for
|
||||
|
||||
for (j = fnd; j < stock; j++) {
|
||||
if (IsMoveOk(pCard, pBoard->GetStack((loc) j)) == true)
|
||||
return false;
|
||||
} // end for
|
||||
|
||||
if (pCard->m_pStack->Bottom() == pCard) // Out of cards on the Stock stack?
|
||||
break;
|
||||
} // end while
|
||||
|
||||
pCard = pBoard->GetStack((loc) used)->Bottom();
|
||||
while (pCard != nullptr) {
|
||||
for (j = 0; j < STOCK_DRAW; j++) {
|
||||
if (pCard->m_pStack->Top() == pCard) // Out of cards on the Stock stack?
|
||||
break;
|
||||
|
||||
if (pCard->m_pStack->Bottom() == pCard) // if bottom, skip a count
|
||||
j++;
|
||||
|
||||
pCard = pCard->m_pNextCard;
|
||||
} // end for
|
||||
|
||||
for (j = fnd; j < stock; j++) {
|
||||
if (IsMoveOk(pCard, pBoard->GetStack((loc) j)) == true)
|
||||
return false;
|
||||
} // end for
|
||||
|
||||
if (pCard->m_pStack->Top() == pCard) // Out of cards on the Stock stack?
|
||||
break;
|
||||
} // end while
|
||||
|
||||
return true; // Game over, no other possible moves
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
46
engines/bagel/hodjnpodj/barbershop/logic.h
Normal file
46
engines/bagel/hodjnpodj/barbershop/logic.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_LOGIC_H
|
||||
#define HODJNPODJ_BARBERSHOP_LOGIC_H
|
||||
|
||||
#include "bagel/hodjnpodj/barbershop/stack.h"
|
||||
#include "bagel/hodjnpodj/barbershop/board.h"
|
||||
#include "bagel/hodjnpodj/barbershop/card.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
class CLogic {
|
||||
public:
|
||||
CLogic();
|
||||
~CLogic();
|
||||
|
||||
bool IsMoveOk(CCard*, CStack*);
|
||||
bool IsGameOver(CBoard *pBoard);
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
953
engines/bagel/hodjnpodj/barbershop/main.cpp
Normal file
953
engines/bagel/hodjnpodj/barbershop/main.cpp
Normal file
@@ -0,0 +1,953 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/mainmenu.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cmessbox.h"
|
||||
#include "bagel/boflib/misc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/rules.h"
|
||||
#include "bagel/boflib/error.h"
|
||||
#include "bagel/hodjnpodj/barbershop/init.h"
|
||||
#include "bagel/hodjnpodj/barbershop/main.h"
|
||||
#include "bagel/hodjnpodj/barbershop/undo.h"
|
||||
#include "bagel/hodjnpodj/barbershop/usercfg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
//
|
||||
// This mini-game's main screen bitmap
|
||||
//
|
||||
#define MINI_GAME_MAP ".\\ART\\barb.BMP"
|
||||
|
||||
//
|
||||
// This mini-game's sound file
|
||||
//
|
||||
#define MIDI_SOUND ".\\SOUND\\barber.mid"
|
||||
|
||||
#define RULES_TXT "barb.txt"
|
||||
#define RULES_WAV ".\\sound\\rlbq.wav"
|
||||
|
||||
|
||||
//
|
||||
// Win/Lose conditions
|
||||
//
|
||||
#define WIN 1
|
||||
#define LOSE 0
|
||||
|
||||
//
|
||||
// Button ID constants
|
||||
//
|
||||
#define IDC_MENU 100
|
||||
|
||||
#define TIMER_ID 10
|
||||
|
||||
// Local Prototypes
|
||||
//
|
||||
void CALLBACK GetGameParams(CWnd *);
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
CPalette *pGamePalette;
|
||||
LPGAMESTRUCT pGameParams;
|
||||
int g_nCardBack;
|
||||
extern HWND ghParentWnd;
|
||||
|
||||
|
||||
CMainWindow::CMainWindow() {
|
||||
CString WndClass;
|
||||
CRect tmpRect;
|
||||
CDC *pDC = nullptr;
|
||||
CDibDoc *pDibDoc;
|
||||
ERROR_CODE errCode;
|
||||
bool bSuccess;
|
||||
|
||||
// assume no error
|
||||
errCode = ERR_NONE;
|
||||
|
||||
// Initialize members
|
||||
//
|
||||
m_pScrollSprite = nullptr;
|
||||
m_pGamePalette = nullptr;
|
||||
m_bPause = false;
|
||||
m_bGameActive = false;
|
||||
m_bInMenu = false;
|
||||
m_bMIDIPlaying = false;
|
||||
m_pBarb = nullptr;
|
||||
m_pMIDISound = nullptr;
|
||||
|
||||
// Initialize score to LOSE condition in case the user bails out
|
||||
//
|
||||
pGameParams->lScore = LOSE;
|
||||
|
||||
|
||||
// Set the coordinates for the "Start New Game" button
|
||||
//
|
||||
m_rNewGameButton.SetRect(15, 4, 233, 20);
|
||||
|
||||
// Define a special window class which traps double-clicks, is byte aligned
|
||||
// to maximize BITBLT performance, and creates "owned" DCs rather than sharing
|
||||
// the five system defined DCs which are not guaranteed to be available;
|
||||
// this adds a bit to our app size but avoids hangs/freezes/lockups.
|
||||
WndClass = AfxRegisterWndClass(CS_DBLCLKS | CS_BYTEALIGNWINDOW | CS_OWNDC, nullptr, nullptr, nullptr);
|
||||
|
||||
// can't play this game if the background art is not available
|
||||
//
|
||||
if (FileExists(MINI_GAME_MAP)) {
|
||||
|
||||
// Acquire the shared palette for our game from the splash screen art
|
||||
//
|
||||
if ((pDibDoc = new CDibDoc()) != nullptr) {
|
||||
if (pDibDoc->OpenDocument(MINI_GAME_MAP) != false)
|
||||
pGamePalette = m_pGamePalette = pDibDoc->DetachPalette();
|
||||
else
|
||||
errCode = ERR_UNKNOWN;
|
||||
delete pDibDoc;
|
||||
} else {
|
||||
errCode = ERR_MEMORY;
|
||||
}
|
||||
} else {
|
||||
errCode = ERR_FFIND;
|
||||
}
|
||||
|
||||
// Center our window on the screen
|
||||
//
|
||||
tmpRect.SetRect(0, 0, GAME_WIDTH, GAME_HEIGHT);
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
tmpRect.left = (pDC->GetDeviceCaps(HORZRES) - GAME_WIDTH) >> 1;
|
||||
tmpRect.top = (pDC->GetDeviceCaps(VERTRES) - GAME_HEIGHT) >> 1;
|
||||
tmpRect.right = tmpRect.left + GAME_WIDTH;
|
||||
tmpRect.bottom = tmpRect.top + GAME_HEIGHT;
|
||||
ReleaseDC(pDC);
|
||||
} else {
|
||||
errCode = ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
// Create the window as a POPUP so no boarders, title, or menu are present;
|
||||
// this is because the game's background art will fill the entire 640x480 area.
|
||||
//
|
||||
Create(WndClass, "Boffo Games -- Barbershop Quintet", WS_POPUP, tmpRect, nullptr, 0);
|
||||
|
||||
BeginWaitCursor();
|
||||
ShowWindow(SW_SHOWNORMAL);
|
||||
PaintScreen();
|
||||
EndWaitCursor();
|
||||
|
||||
// only continue if there was no error
|
||||
//
|
||||
if (errCode == ERR_NONE) {
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
//
|
||||
// build our main menu button
|
||||
//
|
||||
if ((m_pScrollSprite = new CSprite) != nullptr) {
|
||||
m_pScrollSprite->SharePalette(m_pGamePalette);
|
||||
bSuccess = m_pScrollSprite->LoadSprite(pDC, ".\\ART\\SCROLBTN.BMP");
|
||||
assert(bSuccess);
|
||||
if (bSuccess) {
|
||||
m_pScrollSprite->SetMasked(true);
|
||||
m_pScrollSprite->SetMobile(true);
|
||||
} else {
|
||||
errCode = ERR_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
errCode = ERR_MEMORY;
|
||||
}
|
||||
|
||||
// only continue if there was no error
|
||||
//
|
||||
if (errCode == ERR_NONE) {
|
||||
|
||||
// seed the random number generator
|
||||
//srand((unsigned)time(nullptr));
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
//
|
||||
// Initialize midi music
|
||||
//
|
||||
if ((m_pMIDISound = new CSound((CWnd *) this, MIDI_SOUND, SOUND_MIDI | SOUND_LOOP | SOUND_DONT_LOOP_TO_END)) == nullptr) {
|
||||
errCode = ERR_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
//
|
||||
// Initialize wav sound
|
||||
//
|
||||
if ((m_pWavSound = new CSound) == nullptr) {
|
||||
errCode = ERR_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
//
|
||||
// Initialize Barbershop Quintet!
|
||||
//
|
||||
if ((m_pBarb = new CBarber(pDC, m_pWavSound)) == nullptr) {
|
||||
errCode = ERR_MEMORY;
|
||||
} else {
|
||||
g_nCardBack = m_pBarb->m_cPnt->m_nCardBack;
|
||||
} // end if
|
||||
}
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
//
|
||||
// Initialize animations
|
||||
//
|
||||
if ((m_pAnim = new CAnimate(m_pWavSound)) == nullptr) {
|
||||
errCode = ERR_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
// Start the game theme song
|
||||
//
|
||||
if (pGameParams->bMusicEnabled) {
|
||||
m_bMIDIPlaying = true;
|
||||
m_pMIDISound->midiLoopPlaySegment(2000L, 33560L, 00L, FMT_MILLISEC);
|
||||
}
|
||||
|
||||
// Automatically bring up the main menu if in stand alone mode
|
||||
//
|
||||
if (pGameParams->bPlayingMetagame != false) {
|
||||
PostMessage(WM_COMMAND, IDC_OPTIONS_NEWGAME, BN_CLICKED);
|
||||
} else {
|
||||
PostMessage(WM_COMMAND, IDC_MENU, BN_CLICKED);
|
||||
}
|
||||
}
|
||||
|
||||
HandleError(errCode);
|
||||
}
|
||||
|
||||
void CMainWindow::HandleError(ERROR_CODE errCode) {
|
||||
//
|
||||
// Exit this application on fatal errors
|
||||
//
|
||||
if (errCode != ERR_NONE) {
|
||||
|
||||
// pause the current game (if any)
|
||||
GamePause();
|
||||
|
||||
// Display Error Message to the user
|
||||
MessageBox(errList[errCode], "Fatal Error!", MB_OK | MB_ICONSTOP);
|
||||
|
||||
// Force this application to terminate
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
|
||||
// Don't allow a repaint (remove all WM_PAINT messages)
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::OnPaint() {
|
||||
PAINTSTRUCT lpPaint;
|
||||
|
||||
Invalidate(false);
|
||||
BeginPaint(&lpPaint);
|
||||
PaintScreen();
|
||||
EndPaint(&lpPaint);
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::PaintScreen() {
|
||||
//CSprite *pSprite;
|
||||
CDibDoc myDoc;
|
||||
CRect rcDest;
|
||||
CRect rcDIB;
|
||||
HDIB hDIB;
|
||||
CDC *pDC;
|
||||
|
||||
//
|
||||
// Paint the background art and upadate any sprites
|
||||
// called by OnPaint
|
||||
//
|
||||
if (FileExists(MINI_GAME_MAP)) {
|
||||
|
||||
myDoc.OpenDocument(MINI_GAME_MAP);
|
||||
hDIB = myDoc.GetHDIB();
|
||||
|
||||
pDC = GetDC();
|
||||
assert(pDC != nullptr);
|
||||
|
||||
if (pDC != nullptr) {
|
||||
|
||||
if (hDIB && (m_pGamePalette != nullptr)) {
|
||||
|
||||
GetClientRect(rcDest);
|
||||
rcDIB.top = rcDIB.left = 0;
|
||||
rcDIB.right = (int) DIBWidth(hDIB);
|
||||
rcDIB.bottom = (int) DIBHeight(hDIB);
|
||||
PaintDIB(pDC->m_hDC, &rcDest, hDIB, &rcDIB, m_pGamePalette);
|
||||
}
|
||||
|
||||
// repaint the command scroll
|
||||
//
|
||||
if (!m_bInMenu && (m_pScrollSprite != nullptr)) {
|
||||
m_pScrollSprite->PaintSprite(pDC, SCROLL_BUTTON_X, SCROLL_BUTTON_Y);
|
||||
}
|
||||
|
||||
if (m_pBarb != nullptr)
|
||||
m_pBarb->Refresh(pDC); // repaint the board of cards
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CMainWindow::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
CDC *pDC;
|
||||
bool bSuccess;
|
||||
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
switch (wParam) {
|
||||
|
||||
//
|
||||
// must bring up our menu of controls
|
||||
//
|
||||
case IDC_MENU: {
|
||||
|
||||
GamePause();
|
||||
|
||||
// don't display the command scroll when in the menu
|
||||
m_bInMenu = true;
|
||||
|
||||
// hide the command scroll
|
||||
//
|
||||
pDC = GetDC();
|
||||
bSuccess = m_pScrollSprite->EraseSprite(pDC);
|
||||
|
||||
// Create the commands menu
|
||||
//
|
||||
CMainMenu COptionsWind(
|
||||
(CWnd *)this,
|
||||
m_pGamePalette,
|
||||
//NO_OPTIONS |
|
||||
(m_bGameActive ? 0 : NO_RETURN) |
|
||||
(pGameParams->bPlayingMetagame ? NO_OPTIONS : 0) |
|
||||
(pGameParams->bPlayingMetagame ? NO_NEWGAME : 0),
|
||||
GetGameParams,
|
||||
RULES_TXT,
|
||||
pGameParams->bSoundEffectsEnabled ? RULES_WAV : nullptr,
|
||||
pGameParams
|
||||
);
|
||||
|
||||
CSound::waitWaveSounds();
|
||||
|
||||
// Get users choice from command menu
|
||||
//
|
||||
switch (COptionsWind.DoModal()) {
|
||||
|
||||
// User has chosen to play a new game
|
||||
//
|
||||
case IDC_OPTIONS_NEWGAME:
|
||||
if (m_pBarb->IsNewBack(g_nCardBack) == true) { // need to card back?
|
||||
m_pBarb->ChangeBack(pDC, g_nCardBack); // yes - change it
|
||||
} // end if
|
||||
|
||||
PlayGame();
|
||||
break;
|
||||
|
||||
// User has chosen to quit this mini-game
|
||||
//
|
||||
case IDC_OPTIONS_QUIT:
|
||||
pGameParams->lScore = LOSE; // make sure the score is zero if they quit
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (m_pBarb->IsNewBack(g_nCardBack) == true) { // need to card back?
|
||||
m_pBarb->ChangeBack(pDC, g_nCardBack); // yes - change it
|
||||
Invalidate(true); // set up for a redraw window
|
||||
} // end if
|
||||
break;
|
||||
|
||||
} // end switch
|
||||
|
||||
if (!pGameParams->bMusicEnabled && m_bMIDIPlaying) {
|
||||
|
||||
m_pMIDISound->stop();
|
||||
m_bMIDIPlaying = false;
|
||||
|
||||
} else if (pGameParams->bMusicEnabled && !m_bMIDIPlaying) {
|
||||
|
||||
m_pMIDISound->midiLoopPlaySegment(2470, 32160, 0, FMT_MILLISEC);
|
||||
m_bMIDIPlaying = true;
|
||||
}
|
||||
|
||||
// show the command scroll
|
||||
//
|
||||
bSuccess = m_pScrollSprite->PaintSprite(pDC, SCROLL_BUTTON_X, SCROLL_BUTTON_Y);
|
||||
assert(bSuccess);
|
||||
ReleaseDC(pDC);
|
||||
|
||||
// ok to display the command scroll now
|
||||
//
|
||||
m_bInMenu = false;
|
||||
GameResume();
|
||||
return true;
|
||||
} // end case
|
||||
|
||||
case IDC_OPTIONS_NEWGAME:
|
||||
PlayGame();
|
||||
break;
|
||||
|
||||
} // end switch
|
||||
} // end if
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::GamePause() {
|
||||
m_bPause = true;
|
||||
}
|
||||
|
||||
void CMainWindow::GameResume() {
|
||||
m_bPause = false;
|
||||
}
|
||||
|
||||
void CMainWindow::PlayGame() {
|
||||
CDC *pDC;
|
||||
ERROR_CODE errCode;
|
||||
|
||||
// assume no error
|
||||
errCode = ERR_NONE;
|
||||
|
||||
// load the .INI settings
|
||||
//
|
||||
LoadIniSettings();
|
||||
|
||||
// reset all game parameters
|
||||
//
|
||||
GameReset();
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
//
|
||||
// Start game
|
||||
//
|
||||
//CSprite::FlushSprites();
|
||||
CSprite::FlushSpriteChain(); // Delete cards from memory
|
||||
Invalidate(true);
|
||||
UpdateWindow();
|
||||
/*
|
||||
if ( pGameParams->bMusicEnabled != false ) {
|
||||
m_pMIDISound->midiLoopPlaySegment(2000L, 33560L, 00L, FMT_MILLISEC);
|
||||
}
|
||||
*/
|
||||
m_pBarb->NewGame(pDC);
|
||||
m_bGameActive = true;
|
||||
ReleaseDC(pDC);
|
||||
} else {
|
||||
errCode = ERR_MEMORY;
|
||||
} // end if
|
||||
} // end if
|
||||
|
||||
HandleError(errCode);
|
||||
}
|
||||
|
||||
void CMainWindow::LoadIniSettings() {
|
||||
}
|
||||
|
||||
void CMainWindow::SaveIniSettings() {
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::GameReset() {
|
||||
//sndPlaySound(nullptr, SND_SYNC); // stop all sounds
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CMainWindow::OnTimer(uintptr nEvent) {
|
||||
//CDC *pDC;
|
||||
|
||||
// continue as long as there is a currently active non-paused game
|
||||
//
|
||||
//if (m_bGameActive && !m_bPause) {
|
||||
// nEvent = 0x00; // bull shit code rids warnings
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::OnMouseMove(unsigned int nFlags, CPoint point) {
|
||||
CDC *pDC;
|
||||
|
||||
SetCursor(LoadCursor(nullptr, IDC_ARROW));
|
||||
if (m_pBarb->m_pCrd != nullptr) {
|
||||
pDC = GetDC();
|
||||
m_pBarb->OnMouseMove(pDC, point);
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
//nFlags = 0x00;
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::OnRButtonDown(unsigned int nFlags, CPoint point) {
|
||||
CPoint UndoPoint(UNDO_LEF + (UNDO_RIG - UNDO_LEF) / 2, UNDO_TOP + (UNDO_BOT - UNDO_TOP) / 2);
|
||||
|
||||
if (m_pBarb->m_pCrd != nullptr) // r we currently moving a card?
|
||||
return; // Yes - just quit.
|
||||
|
||||
if (m_pBarb->m_bIsGameOver == false) {
|
||||
m_pBarb->OnLButtonDown(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
UndoPoint
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void CMainWindow::OnLButtonDown(unsigned int nFlags, CPoint point) {
|
||||
CDC *pDC;
|
||||
char buf[32];
|
||||
CRect tmpRect;
|
||||
|
||||
if (m_pBarb->m_pCrd != nullptr) // r we currently moving a card?
|
||||
return; // Yes - just quit.
|
||||
|
||||
if (m_pScrollSprite != nullptr)
|
||||
tmpRect = m_pScrollSprite->GetRect();
|
||||
|
||||
pDC = GetDC();
|
||||
// User clicked on the Menu button
|
||||
//
|
||||
if (tmpRect.PtInRect(point)) {
|
||||
|
||||
// bring up the menu
|
||||
PostMessage(WM_COMMAND, IDC_MENU, BN_CLICKED);
|
||||
|
||||
// User clicked on the Title - NewGame button
|
||||
//
|
||||
} else if (m_rNewGameButton.PtInRect(point)) {
|
||||
|
||||
// start a new game
|
||||
if (pGameParams->bPlayingMetagame == false)
|
||||
PlayGame();
|
||||
|
||||
} else if (m_pAnim->Clown(pDC, point) == true) {
|
||||
/************************************
|
||||
* user clicked animation. *
|
||||
* animation handled in it's call. *
|
||||
************************************/
|
||||
FlushInputEvents();
|
||||
} else if (m_pAnim->UFO(pDC, point) == true) {
|
||||
/************************************
|
||||
* user clicked animation. *
|
||||
* animation handled in it's call. *
|
||||
************************************/
|
||||
FlushInputEvents();
|
||||
} else if (m_pAnim->Brat(point) == true) {
|
||||
/************************************
|
||||
* user clicked animation. *
|
||||
* animation handled in it's call. *
|
||||
************************************/
|
||||
FlushInputEvents();
|
||||
} else if (m_pAnim->Lollipop(point) == true) {
|
||||
/************************************
|
||||
* user clicked animation. *
|
||||
* animation handled in it's call. *
|
||||
************************************/
|
||||
FlushInputEvents();
|
||||
} else if (m_pAnim->Haircut(point) == true) {
|
||||
/************************************
|
||||
* user clicked animation. *
|
||||
* animation handled in it's call. *
|
||||
************************************/
|
||||
FlushInputEvents();
|
||||
} else if (m_pBarb->m_bIsGameOver == false) {
|
||||
m_pBarb->OnLButtonDown(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
point
|
||||
);
|
||||
|
||||
// is this needed ?
|
||||
CFrameWnd::OnLButtonDown(nFlags, point);
|
||||
|
||||
if (m_pBarb->m_bIsGameOver == true) {
|
||||
if (pGameParams->bPlayingMetagame) {
|
||||
Common::sprintf_s(buf, "Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
} else if (m_pBarb->m_bIsWin) {
|
||||
Common::sprintf_s(buf, "You win! Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
} else {
|
||||
Common::sprintf_s(buf, "Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
} // end if
|
||||
} // end if
|
||||
} // end if
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::OnLButtonDblClk(unsigned int nFlags, CPoint point) {
|
||||
char buf[32];
|
||||
CRect tmpRect;
|
||||
|
||||
if (m_pScrollSprite != nullptr)
|
||||
tmpRect = m_pScrollSprite->GetRect();
|
||||
|
||||
// User clicked on the Menu button
|
||||
//
|
||||
if (tmpRect.PtInRect(point)) {
|
||||
|
||||
// bring up the menu
|
||||
PostMessage(WM_COMMAND, IDC_MENU, BN_CLICKED);
|
||||
|
||||
// User clicked on the Title - NewGame button
|
||||
//
|
||||
} else if (m_rNewGameButton.PtInRect(point)) {
|
||||
|
||||
// start a new game
|
||||
if (pGameParams->bPlayingMetagame == false)
|
||||
PlayGame();
|
||||
|
||||
} else if (m_pBarb->m_bIsGameOver == false) {
|
||||
m_pBarb->OnLButtonDblClk(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
point
|
||||
);
|
||||
|
||||
if (m_pBarb->m_bIsGameOver == true) {
|
||||
if (pGameParams->bPlayingMetagame) {
|
||||
Common::sprintf_s(buf, "Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game Over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
} else if (m_pBarb->m_bIsWin) {
|
||||
Common::sprintf_s(buf, "You win! Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game Over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
} else {
|
||||
Common::sprintf_s(buf, "Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game Over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
} // end if
|
||||
} // end if
|
||||
} // end if
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::OnLButtonUp(unsigned int nFlags, CPoint point) {
|
||||
char buf[32];
|
||||
|
||||
if (m_pBarb->m_bIsGameOver == false) {
|
||||
|
||||
m_pBarb->OnLButtonUp((CWnd*) this);
|
||||
|
||||
if (m_pBarb->m_bIsGameOver == true) {
|
||||
if (pGameParams->bPlayingMetagame) {
|
||||
Common::sprintf_s(buf, "Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game Over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
} else if (m_pBarb->m_bIsWin) {
|
||||
Common::sprintf_s(buf, "You win! Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game Over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
} else {
|
||||
Common::sprintf_s(buf, "Score: %d", m_pBarb->Score());
|
||||
CMessageBox cGameOver(
|
||||
(CWnd*) this,
|
||||
m_pGamePalette,
|
||||
"Game Over.",
|
||||
buf
|
||||
);
|
||||
pGameParams->lScore = m_pBarb->Score();
|
||||
} // end if
|
||||
} // end if
|
||||
} // end if
|
||||
}
|
||||
|
||||
void CMainWindow::DeleteSprite(CSprite *pSprite) {
|
||||
CDC *pDC;
|
||||
|
||||
// can't delete a null pointer
|
||||
assert(pSprite != nullptr);
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
pSprite->EraseSprite(pDC); // erase it from screen
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
pSprite->UnlinkSprite(); // unlink it
|
||||
|
||||
delete pSprite; // delete it
|
||||
}
|
||||
|
||||
void CMainWindow::OnSysChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags) {
|
||||
// terminate app on ALT_Q
|
||||
//
|
||||
if ((nChar == 'q') && (nFlags & 0x2000)) {
|
||||
pGameParams->lScore = LOSE; // make sure the score is zero if they quit
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
|
||||
} else {
|
||||
|
||||
// default action
|
||||
CFrameWnd ::OnSysChar(nChar, nRepCnt, nFlags);
|
||||
}
|
||||
}
|
||||
|
||||
void CMainWindow::OnSysKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags) {
|
||||
switch (nChar) {
|
||||
|
||||
// User has hit ALT_F4 so close down this App
|
||||
//
|
||||
case VK_F4:
|
||||
pGameParams->lScore = LOSE; // make sure the score is zero if they quit
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
CFrameWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CMainWindow::OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags) {
|
||||
// Handle keyboard input
|
||||
//
|
||||
switch (nChar) {
|
||||
|
||||
//
|
||||
// Bring up the Rules
|
||||
//
|
||||
case VK_F1: {
|
||||
if (m_pBarb->m_pCrd != nullptr) { // user holding a card?
|
||||
break; // yeap, can't allow this
|
||||
}
|
||||
|
||||
GamePause();
|
||||
CSound::waitWaveSounds();
|
||||
CRules RulesDlg(this, RULES_TXT, m_pGamePalette, pGameParams->bSoundEffectsEnabled ? RULES_WAV : nullptr);
|
||||
RulesDlg.DoModal();
|
||||
GameResume();
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
// Bring up the options menu
|
||||
//
|
||||
case VK_F2:
|
||||
if (m_pBarb->m_pCrd != nullptr) { // user holding a card?
|
||||
break; // yeap, can't allow this
|
||||
}
|
||||
|
||||
SendMessage(WM_COMMAND, IDC_MENU, BN_CLICKED);
|
||||
break;
|
||||
|
||||
default:
|
||||
CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CMainWindow::FlushInputEvents() {
|
||||
MSG msg;
|
||||
|
||||
while (true) { // find and remove all keyboard events
|
||||
if (!PeekMessage(&msg, nullptr, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
|
||||
break;
|
||||
} // end while
|
||||
|
||||
while (true) { // find and remove all mouse events
|
||||
if (!PeekMessage(&msg, nullptr, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE))
|
||||
break;
|
||||
} // end while
|
||||
}
|
||||
|
||||
void CMainWindow::OnActivate(unsigned int nState, CWnd *pWndOther, bool bMinimized) {
|
||||
if (!bMinimized) {
|
||||
|
||||
switch (nState) {
|
||||
case WA_ACTIVE:
|
||||
case WA_CLICKACTIVE:
|
||||
InvalidateRect(nullptr, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LRESULT CMainWindow::OnMCINotify(WPARAM wParam, LPARAM lParam) {
|
||||
//CSound *pSound;
|
||||
|
||||
CSound::OnMCIStopped(wParam, lParam);
|
||||
// if (pSound != nullptr)
|
||||
// OnSoundNotify(pSound);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CMainWindow::OnMMIONotify(WPARAM wParam, LPARAM lParam) {
|
||||
//CSound *pSound;
|
||||
|
||||
CSound::OnMMIOStopped(wParam, lParam);
|
||||
//if (pSound != nullptr)
|
||||
// OnSoundNotify(pSound);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CMainWindow::OnClose() {
|
||||
CDC *pDC = GetDC();
|
||||
CRect rctFillRect(0, 0, GAME_WIDTH, GAME_HEIGHT);
|
||||
CBrush Brush(RGB(0, 0, 0));
|
||||
|
||||
pDC->FillRect(&rctFillRect, &Brush);
|
||||
ReleaseDC(pDC);
|
||||
|
||||
// perform cleanup
|
||||
//
|
||||
GameReset();
|
||||
|
||||
if (m_pAnim != nullptr) {
|
||||
delete m_pAnim;
|
||||
m_pAnim = nullptr;
|
||||
}
|
||||
|
||||
if (m_pMIDISound != nullptr || m_pWavSound != nullptr) {
|
||||
CSound::clearSounds(); // turn all sounds totally off and delete the objects
|
||||
m_pMIDISound = nullptr;
|
||||
m_pWavSound = nullptr;
|
||||
}
|
||||
|
||||
if (m_pBarb != nullptr) {
|
||||
delete m_pBarb;
|
||||
m_pBarb = nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
// de-allocate any controls that we used
|
||||
//
|
||||
assert(m_pScrollSprite != nullptr);
|
||||
if (m_pScrollSprite != nullptr)
|
||||
delete m_pScrollSprite;
|
||||
|
||||
//
|
||||
// need to de-allocate the game palette
|
||||
//
|
||||
assert(m_pGamePalette != nullptr);
|
||||
if (m_pGamePalette != nullptr) {
|
||||
//m_pGamePalette->DeleteObject();
|
||||
delete m_pGamePalette;
|
||||
}
|
||||
|
||||
CFrameWnd::OnClose();
|
||||
|
||||
MFC::PostMessage(ghParentWnd, WM_PARENTNOTIFY, WM_DESTROY, (LPARAM)pGameParams);
|
||||
}
|
||||
|
||||
//
|
||||
// CMainWindow message map:
|
||||
// Associate messages with member functions.
|
||||
//
|
||||
BEGIN_MESSAGE_MAP(CMainWindow, CFrameWnd)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_TIMER()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_SYSCHAR()
|
||||
ON_WM_KEYDOWN()
|
||||
ON_WM_SYSKEYDOWN()
|
||||
ON_WM_RBUTTONDOWN()
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_LBUTTONDBLCLK()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_MESSAGE(MM_MCINOTIFY, CMainWindow::OnMCINotify)
|
||||
ON_MESSAGE(MM_WOM_DONE, CMainWindow::OnMMIONotify)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CALLBACK GetGameParams(CWnd *pParentWnd) {
|
||||
//
|
||||
// Our user preference dialog box is self contained in this object
|
||||
//
|
||||
CUserCfgDlg dlgUserCfg(pParentWnd, pGamePalette, IDD_USERCFG);
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
91
engines/bagel/hodjnpodj/barbershop/main.h
Normal file
91
engines/bagel/hodjnpodj/barbershop/main.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_MAIN_H
|
||||
#define HODJNPODJ_BARBERSHOP_MAIN_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/boflib/error.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
#include "bagel/hodjnpodj/barbershop/barb.h"
|
||||
#include "bagel/hodjnpodj/barbershop/animate.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
class CMainWindow : public CFrameWnd {
|
||||
private:
|
||||
CBarber *m_pBarb;
|
||||
CSound *m_pMIDISound;
|
||||
CSound *m_pWavSound;
|
||||
CAnimate *m_pAnim;
|
||||
bool m_bMIDIPlaying;
|
||||
|
||||
public:
|
||||
CMainWindow();
|
||||
void PlayGame();
|
||||
void PaintScreen();
|
||||
void LoadIniSettings();
|
||||
void SaveIniSettings();
|
||||
void FlushInputEvents();
|
||||
LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
|
||||
protected:
|
||||
void GameReset();
|
||||
void GamePause();
|
||||
void GameResume();
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
void HandleError(ERROR_CODE);
|
||||
void DeleteSprite(CSprite *);
|
||||
|
||||
void OnPaint();
|
||||
void OnTimer(uintptr);
|
||||
void OnMouseMove(unsigned int, CPoint);
|
||||
void OnLButtonDown(unsigned int, CPoint);
|
||||
void OnLButtonDblClk(unsigned int, CPoint);
|
||||
void OnRButtonDown(unsigned int, CPoint);
|
||||
void OnSysChar(unsigned int, unsigned int, unsigned int);
|
||||
void OnSysKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnActivate(unsigned int, CWnd *, bool) override;
|
||||
void OnClose();
|
||||
void OnLButtonUp(unsigned int, CPoint);
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CRect m_rNewGameButton;
|
||||
CPalette *m_pGamePalette;
|
||||
CSprite *m_pScrollSprite;
|
||||
bool m_bGameActive;
|
||||
bool m_bPause;
|
||||
bool m_bInMenu;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
523
engines/bagel/hodjnpodj/barbershop/paint.cpp
Normal file
523
engines/bagel/hodjnpodj/barbershop/paint.cpp
Normal file
@@ -0,0 +1,523 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/barbershop/paint.h"
|
||||
#include "bagel/hodjnpodj/barbershop/barb.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/bitmaps.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
static const char *DECKS[] = { // bitmap loading
|
||||
"art\\deck0.bmp",
|
||||
"art\\deck1.bmp",
|
||||
"art\\deck2.bmp",
|
||||
"art\\deck3.bmp",
|
||||
"art\\deck4.bmp",
|
||||
"art\\deck5.bmp",
|
||||
"art\\deck6.bmp",
|
||||
"art\\deck7.bmp"
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* CPaint
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
CPaint::CPaint(CDC *pDC) {
|
||||
CBitmap *pBmpCardSet = nullptr;
|
||||
CBitmap *pCard = nullptr;
|
||||
bool bSuccess;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < CARDS_PER_COL; i++) { // Initialize master alphabet list
|
||||
pBmpCardSet = FetchBitmap(pDC, (CPalette**) nullptr, DECKS[i]);
|
||||
ASSERT(pBmpCardSet);
|
||||
|
||||
for (j = 0; j < CARDS_PER_ROW; j ++) {
|
||||
pCard = ExtractBitmap( // fetch the proper card
|
||||
pDC,
|
||||
pBmpCardSet,
|
||||
pGamePalette,
|
||||
j * BITMAP_WTH,
|
||||
0,
|
||||
BITMAP_WTH,
|
||||
BITMAP_HEI
|
||||
);
|
||||
|
||||
ASSERT(pCard);
|
||||
|
||||
m_cCardSet[(i * CARDS_PER_ROW) + j] = new OSpr(); // Initize the individual letter of the alphabet list
|
||||
bSuccess = (*m_cCardSet[(i * CARDS_PER_ROW) + j]).LoadSprite(pCard, pGamePalette);
|
||||
ASSERT(bSuccess);
|
||||
|
||||
(*m_cCardSet[(i * CARDS_PER_ROW) + j]).SetHotspot(CARD_HOT_X, CARD_HOT_Y);
|
||||
(*m_cCardSet[(i * CARDS_PER_ROW) + j]).SetMobile(true);
|
||||
(*m_cCardSet[(i * CARDS_PER_ROW) + j]).SetMasked(true);
|
||||
} // end for
|
||||
|
||||
delete pBmpCardSet;
|
||||
pBmpCardSet = nullptr;
|
||||
} // end for
|
||||
|
||||
m_nCardBack = CARD_BACK1;
|
||||
m_nUsedInd = 0; // Used in Stack() proc; for indenting cards placed on used stack
|
||||
|
||||
m_cFound.SetRect(
|
||||
FND_LEF,
|
||||
FND_TOP,
|
||||
FND_RIG,
|
||||
FND_BOT
|
||||
);
|
||||
|
||||
for (i = 0; i < TAB_COUNT; i++)
|
||||
m_cTab[i].SetRect(
|
||||
TAB_LEF + (TAB_OFFSET * i),
|
||||
TAB_TOP,
|
||||
TAB_RIG + (TAB_OFFSET * i),
|
||||
TAB_BOT
|
||||
);
|
||||
|
||||
m_cStock.SetRect(
|
||||
STOC_LEF,
|
||||
STOC_TOP,
|
||||
STOC_RIG,
|
||||
STOC_BOT
|
||||
);
|
||||
|
||||
m_cUsed.SetRect(
|
||||
STOC_LEF + USED_OFFSET,
|
||||
STOC_TOP,
|
||||
STOC_RIG + USED_OFFSET,
|
||||
STOC_BOT
|
||||
);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* ~CPaint
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
CPaint::~CPaint() {
|
||||
int i;
|
||||
|
||||
CSprite::FlushSpriteChain();
|
||||
for (i = 0; i < CARD_SET; i++)
|
||||
delete m_cCardSet[i]; // each letter in the alpha
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Board
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
void CPaint::Board(CDC *pDC, CBoard *pBoard) {
|
||||
int i, j;
|
||||
CCard *pCard[TAB_COUNT];
|
||||
|
||||
/************************************************************
|
||||
* Goes thru each stack on the tableau, dealing cards one at *
|
||||
* a time rotating to next stack, in turn. *
|
||||
************************************************************/
|
||||
for (i = 0; i < TAB_COUNT; i++)
|
||||
pCard[i] = pBoard->GetStack((loc)(tab + (loc) i))->Bottom();
|
||||
|
||||
for (i = 0; i < TABLEAU; i++) {
|
||||
j = i % TAB_COUNT;
|
||||
|
||||
m_pSprite = new OSpr();
|
||||
if (pCard[j] == pCard[j]->m_pStack->Top()) {
|
||||
m_cCardSet[pCard[j]->GetValue()]->DuplicateSprite(pDC, (CSprite*) m_pSprite);
|
||||
m_pSprite->m_cCard = pCard[j];
|
||||
(*m_pSprite).LinkSprite();
|
||||
|
||||
pCard[j]->m_bIsBack = false;
|
||||
} else {
|
||||
m_cCardSet[m_nCardBack]->DuplicateSprite(pDC, (CSprite*) m_pSprite);
|
||||
m_pSprite->m_cCard = pCard[j];
|
||||
(*m_pSprite).LinkSprite();
|
||||
|
||||
pCard[j]->m_bIsBack = true;
|
||||
} // end if
|
||||
|
||||
pCard[j]->m_pSprite = m_pSprite;
|
||||
Stack(pDC, pCard[j], (int) i / TAB_COUNT);
|
||||
pCard[j] = pCard[j]->m_pNextCard; // Advance to next card
|
||||
} // end for
|
||||
|
||||
/************************************************************
|
||||
* used any random pCard index, didn't matter, so 0 is used. *
|
||||
************************************************************/
|
||||
pCard[0] = pBoard->GetStack(stock)->Bottom(); // Get first card in stack
|
||||
i = 0;
|
||||
while (pCard[0] != nullptr) {
|
||||
m_pSprite = new OSpr(); // set up visual sprite
|
||||
m_cCardSet[m_nCardBack]->DuplicateSprite(pDC, (CSprite*) m_pSprite);
|
||||
(*m_pSprite).LinkSprite();
|
||||
|
||||
m_pSprite->m_cCard = pCard[0]; // update internal card struct
|
||||
pCard[0]->m_pSprite = m_pSprite;
|
||||
pCard[0]->m_bIsBack = true;
|
||||
|
||||
Stack(pDC, pCard[0], i); // paint it on screen
|
||||
pCard[0] = pCard[0]->m_pNextCard; // Advance to next card
|
||||
i++;
|
||||
} // end while
|
||||
}
|
||||
|
||||
void CPaint::Refresh(CDC *pDC, CBoard *pBoard) {
|
||||
int i;
|
||||
int nCardPos; // card pos in stack
|
||||
CStack *pStack;
|
||||
CCard *pCard;
|
||||
CPoint cPos;
|
||||
|
||||
m_pSprite = (OSpr*) OSpr::GetSpriteChain();
|
||||
if (m_pSprite == nullptr) // any sprites to refresh?
|
||||
return; // no
|
||||
|
||||
OSpr::ClearBackgrounds();
|
||||
|
||||
pStack = pBoard->GetStack(fnd); // refresh foundation
|
||||
pCard = pStack->Bottom();
|
||||
nCardPos = 0;
|
||||
while (pCard != nullptr) {
|
||||
if (pCard->m_pSprite != nullptr) {
|
||||
pCard->m_pSprite->RefreshSprite(pDC);
|
||||
}
|
||||
pCard = pCard->m_pNextCard;
|
||||
nCardPos++;
|
||||
}
|
||||
|
||||
for (i = tab; i < stock; i++) { // refresh tableau
|
||||
pStack = pBoard->GetStack((loc) i);
|
||||
pCard = pStack->Bottom();
|
||||
nCardPos = 0;
|
||||
|
||||
while (pCard != nullptr) {
|
||||
if (pCard->m_pSprite != nullptr) {
|
||||
pCard->m_pSprite->RefreshSprite(pDC);
|
||||
}
|
||||
pCard = pCard->m_pNextCard;
|
||||
nCardPos++;
|
||||
} // end while
|
||||
} // end for
|
||||
|
||||
pStack = pBoard->GetStack(stock); // refresh stock top card only
|
||||
pCard = pStack->Bottom();
|
||||
nCardPos = 0;
|
||||
while (pCard != nullptr) {
|
||||
if (pCard->m_pSprite != nullptr) {
|
||||
pCard->m_pSprite->RefreshSprite(pDC);
|
||||
}
|
||||
pCard = pCard->m_pNextCard;
|
||||
nCardPos++;
|
||||
}
|
||||
|
||||
pStack = pBoard->GetStack(used); // refresh used stack
|
||||
pCard = pStack->Bottom();
|
||||
nCardPos = 0;
|
||||
while (pCard != nullptr) {
|
||||
if (pCard->m_pSprite != nullptr) {
|
||||
pCard->m_pSprite->RefreshSprite(pDC);
|
||||
}
|
||||
pCard = pCard->m_pNextCard;
|
||||
nCardPos++;
|
||||
}
|
||||
|
||||
(void)nCardPos; // avoid unused variable warning
|
||||
}
|
||||
|
||||
CCard *CPaint::IsOnCard(CPoint cPoint) {
|
||||
if ((m_pSprite = (OSpr *) m_pSprite->Touched(cPoint)) == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return m_pSprite->m_cCard->m_pStack->Top();
|
||||
}
|
||||
|
||||
void CPaint::MoveCard(CDC *pDC, CCard *pCard, CPoint point) {
|
||||
point.x -= pCard->m_pSprite->GetHotspot().x; // causes the point to appear in the
|
||||
point.y -= pCard->m_pSprite->GetHotspot().y; // center of the card.
|
||||
pCard->m_pSprite->PaintSprite(pDC, point);
|
||||
}
|
||||
|
||||
void CPaint::UpdateCard(CDC *pDC, CCard *pCard) {
|
||||
pCard->m_pSprite->PaintSprite(pDC, pCard->m_cOrigin); // paint card @ cur pos
|
||||
}
|
||||
|
||||
void CPaint::FlipCard(CDC *pDC, CCard *pCard) {
|
||||
/**********************************
|
||||
* Get rid of current card bitmap. *
|
||||
**********************************/
|
||||
pCard->m_pSprite->RefreshBackground(pDC); // ...repaint background
|
||||
pCard->m_pSprite->UnlinkSprite(); // unlink from refresh chain
|
||||
delete pCard->m_pSprite;
|
||||
|
||||
/******************************************************************
|
||||
* Reverse card. If it is a back, flip it forward, and vise versa. *
|
||||
******************************************************************/
|
||||
pCard->m_pSprite = new OSpr();
|
||||
if (pCard->m_bIsBack == true) {
|
||||
(*m_cCardSet[pCard->GetValue()]).DuplicateSprite(pDC, (CSprite*) pCard->m_pSprite);
|
||||
pCard->m_bIsBack = false;
|
||||
} else {
|
||||
(*m_cCardSet[m_nCardBack]).DuplicateSprite(pDC, (CSprite*) pCard->m_pSprite);
|
||||
pCard->m_bIsBack = true;
|
||||
}
|
||||
|
||||
pCard->m_pSprite->LinkSprite();
|
||||
pCard->m_pSprite->m_cCard = pCard; // update internal rep
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Stack
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Indents top card properly relative to it's current stack.
|
||||
* Assigns pCard->m_cOrigin to correct position.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
void CPaint::Stack(CDC *pDC, CCard *pCard, int nSize) {
|
||||
int i;
|
||||
|
||||
if (pCard == nullptr)
|
||||
return;
|
||||
|
||||
if (nSize == -1) { // funct overloaded?
|
||||
i = pCard->m_pStack->Size() - 1;// no, use stack size info
|
||||
} else {
|
||||
i = nSize; // yes, use info from param
|
||||
}
|
||||
|
||||
switch (pCard->m_pStack->GetID()) { // Update card visual coordinates
|
||||
case fnd:
|
||||
case stock:
|
||||
pCard->m_cOrigin = pCard->m_pStack->m_cRect.TopLeft();
|
||||
pCard->m_cOrigin.x += ((int) i / STACK_INDENT) * STACK_DX;
|
||||
pCard->m_cOrigin.y += ((int) i / STACK_INDENT) * STACK_DY;
|
||||
break;
|
||||
|
||||
case used:
|
||||
if (pCard->m_pStack->Bottom() == pCard) // bottom card?
|
||||
m_nUsedInd = 0; // reset stack offset counter
|
||||
|
||||
pCard->m_cOrigin = pCard->m_pStack->m_cRect.TopLeft();
|
||||
pCard->m_cOrigin.x += ((int) m_nUsedInd % USED_INDENT) * USED_DX;
|
||||
pCard->m_cOrigin.y += ((int) m_nUsedInd % USED_INDENT) * USED_DY;
|
||||
|
||||
m_nUsedInd++;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (pCard->m_pPrevCard != nullptr) { // card face req pos?
|
||||
if (pCard->m_pPrevCard->m_bIsBack == false) {
|
||||
pCard->m_cOrigin.x = pCard->m_pPrevCard->m_cOrigin.x + STACK_FACE_DX;
|
||||
pCard->m_cOrigin.y = pCard->m_pPrevCard->m_cOrigin.y + STACK_FACE_DY;
|
||||
break;
|
||||
} // end if
|
||||
}
|
||||
|
||||
//
|
||||
// Card back requires positioning
|
||||
//
|
||||
pCard->m_cOrigin = pCard->m_pStack->m_cRect.TopLeft();
|
||||
pCard->m_cOrigin.x += ((int) i / TAB_INDENT) * TAB_DX;
|
||||
pCard->m_cOrigin.y += ((int) i / TAB_INDENT) * TAB_DY;
|
||||
break;
|
||||
}
|
||||
|
||||
pCard->m_pSprite->PaintSprite(pDC, pCard->m_cOrigin);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* IsNewBack
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
bool CPaint::IsNewBack(int nBack) {
|
||||
if (m_nCardBack == nBack) { // any change?
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* ChangeBack
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
void CPaint::ChangeBack(CDC *pDC, CBoard *pBoard, int nBack) {
|
||||
int i;
|
||||
CStack *pStack;
|
||||
CCard *pCard;
|
||||
|
||||
if (m_nCardBack == nBack) { // any change?
|
||||
return; // no - just return
|
||||
} else {
|
||||
m_nCardBack = nBack;
|
||||
}
|
||||
|
||||
for (i = fnd; i <= used; i++) { // refresh tableau
|
||||
pStack = pBoard->GetStack((loc) i);
|
||||
pCard = pStack->Bottom();
|
||||
|
||||
while (pCard != nullptr) {
|
||||
if (pCard->m_bIsBack == false) {
|
||||
pCard = pCard->m_pNextCard;
|
||||
continue;
|
||||
}
|
||||
|
||||
pCard->m_pSprite->UnlinkSprite(); // unlink from refresh chain
|
||||
delete pCard->m_pSprite;
|
||||
|
||||
pCard->m_pSprite = new OSpr();
|
||||
(*m_cCardSet[m_nCardBack]).DuplicateSprite(pDC, (CSprite*) pCard->m_pSprite);
|
||||
pCard->m_pSprite->LinkSprite();
|
||||
pCard->m_pSprite->SetPosition(pCard->m_cOrigin);
|
||||
pCard->m_pSprite->m_cCard = pCard; // update internal rep
|
||||
|
||||
pCard = pCard->m_pNextCard;
|
||||
} // end while
|
||||
} // end for
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
121
engines/bagel/hodjnpodj/barbershop/paint.h
Normal file
121
engines/bagel/hodjnpodj/barbershop/paint.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_PAINT_H
|
||||
#define HODJNPODJ_BARBERSHOP_PAINT_H
|
||||
|
||||
#include "bagel/hodjnpodj/barbershop/deck.h"
|
||||
#include "bagel/hodjnpodj/barbershop/card.h"
|
||||
#include "bagel/hodjnpodj/barbershop/stack.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define STD_CARD_WTH 72 // standard card width (x-val)
|
||||
#define STD_CARD_HEI 97 // standard card height (y-val)
|
||||
#define STD_HALF_WTH 37
|
||||
#define STD_HALF_HEI 48
|
||||
|
||||
#define BITMAP_WTH 119
|
||||
#define BITMAP_HEI 84
|
||||
|
||||
#define FND_LEF 500 // Foundation rect
|
||||
#define FND_TOP 200
|
||||
#define FND_RIG (FND_LEF + BITMAP_WTH)
|
||||
#define FND_BOT (FND_TOP + BITMAP_HEI)
|
||||
|
||||
#define TAB_LEF 60 // Tableau rect
|
||||
#define TAB_TOP 300
|
||||
#define TAB_RIG (TAB_LEF + STD_CARD_WTH)
|
||||
#define TAB_BOT (TAB_TOP + STD_CARD_HEI)
|
||||
|
||||
#define TAB_OFFSET 110 // offset from one tab stack to next
|
||||
|
||||
#define TAB_INDENT 1 // # of cards before next card is shifted
|
||||
#define TAB_DX -2 // how much to shift card right/left
|
||||
#define TAB_DY 2 // how much shift up/down
|
||||
|
||||
#define STACK_INDENT 5 // # of cards before next card is shifted
|
||||
#define STACK_DX 0 // how much to shift card right/left
|
||||
#define STACK_DY -2 // how much shift up/down
|
||||
#define STACK_FACE_DX -7 // for Tableau face card shifting
|
||||
#define STACK_FACE_DY 15
|
||||
|
||||
#define STOC_LEF 110 // Stock stack rect
|
||||
#define STOC_TOP 200
|
||||
#define STOC_RIG (STOC_LEF + BITMAP_WTH)
|
||||
#define STOC_BOT (STOC_TOP + BITMAP_HEI)
|
||||
|
||||
#define USED_OFFSET BITMAP_WTH // Used stack offset from stock stack
|
||||
#define USED_INDENT 3 // # of cards before next card is shifted
|
||||
#define USED_DX 20 // how much to shift card right/left
|
||||
#define USED_DY 0 // how much shift up/down
|
||||
|
||||
#define DECK_RES_ID 100 // corresp to crypt.rc alphabet id's
|
||||
#define CARD_SET (DECK + 2) // 62 cards, 2 reverse sides
|
||||
#define CARD_BACK1 DECK // reverse side of card #1
|
||||
#define CARD_BACK2 DECK + 1 // reverse side of card #2
|
||||
|
||||
#define CARD_HOT_X 62 // Hotspot info for card positioning/moving
|
||||
#define CARD_HOT_Y 41
|
||||
|
||||
#define CARDS_PER_COL 8 // amount of cards in the column for of the deck bitmap
|
||||
#define CARDS_PER_ROW 8 // amount of cards in the row for of the deck bitmap
|
||||
|
||||
#define CARD_BACK1A_BMP "art\\card-bk1.bmp" // card back option #1
|
||||
#define CARD_BACK2A_BMP "art\\card-bk2.bmp" // card back option #2
|
||||
#define CARD_BACK1B_BMP "art\\card-bk3.bmp" // card back option #1
|
||||
#define CARD_BACK2B_BMP "art\\card-bk4.bmp" // card back option #2
|
||||
|
||||
class CPaint {
|
||||
private: // vars
|
||||
OSpr *m_cCardSet[CARD_SET] = {};
|
||||
|
||||
public: // func
|
||||
CPaint(CDC*);
|
||||
~CPaint();
|
||||
|
||||
void Board(CDC*, CBoard*);
|
||||
void Refresh(CDC*, CBoard*);
|
||||
CCard *IsOnCard(CPoint);
|
||||
void MoveCard(CDC*, CCard*, CPoint);
|
||||
void UpdateCard(CDC*, CCard*);
|
||||
void FlipCard(CDC*, CCard*);
|
||||
void Stack(CDC*, CCard*, int nSize = -1);
|
||||
bool IsNewBack(int);
|
||||
void ChangeBack(CDC*, CBoard*, int);
|
||||
|
||||
public: // vars
|
||||
OSpr *m_pSprite = nullptr;
|
||||
CRect m_cFound;
|
||||
CRect m_cTab[TAB_COUNT];
|
||||
CRect m_cStock;
|
||||
CRect m_cUsed;
|
||||
int m_nUsedInd = 0;
|
||||
int m_nCardBack = 0;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
61
engines/bagel/hodjnpodj/barbershop/resource.h
Normal file
61
engines/bagel/hodjnpodj/barbershop/resource.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_RESOURCE_H
|
||||
#define HODJNPODJ_BARBERSHOP_RESOURCE_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define HILITE_BORDER 3
|
||||
|
||||
#define INI_SECTION "Barbershop"
|
||||
#define INI_LETTERSSOLVED "LettersSolved"
|
||||
|
||||
#define LSLVD_DEFAULT 6
|
||||
#define MIN_LSLVD 0
|
||||
#define MAX_LSLVD 20
|
||||
|
||||
#define INI_TIME "Time"
|
||||
#define TIME_DEFAULT 180
|
||||
#define MIN_TIME 15
|
||||
#define MAX_TIME 601
|
||||
|
||||
#define INI_REC "Record"
|
||||
#define REC_DEFAULT 0
|
||||
#define CRYPT_RECS 200
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// App Studio generated include file.
|
||||
// Used by USERCFG.RC
|
||||
//
|
||||
#define IDD_RULES_DIALOG 900
|
||||
#define IDC_RULES_OKAY 900
|
||||
#define IDC_RULES_ARROWDN 901
|
||||
#define IDC_RULES_ARROWUP 902
|
||||
#define IDC_RULES_INVALID 903
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
132
engines/bagel/hodjnpodj/barbershop/stack.cpp
Normal file
132
engines/bagel/hodjnpodj/barbershop/stack.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/barbershop/stack.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
CStack::CStack(CRect cRect, int nID) {
|
||||
m_pTopCard = nullptr;
|
||||
m_pBottomCard = nullptr;
|
||||
m_nID = nID;
|
||||
m_nSize = 0;
|
||||
m_cRect = cRect;
|
||||
}
|
||||
|
||||
CStack::~CStack() {
|
||||
}
|
||||
|
||||
void CStack::Reset() {
|
||||
m_pTopCard = nullptr;
|
||||
m_pBottomCard = nullptr;
|
||||
m_nSize = 0;
|
||||
}
|
||||
|
||||
void CStack::Push(CCard *pCard) {
|
||||
if (pCard == nullptr)
|
||||
return;
|
||||
|
||||
/*********************************************************
|
||||
* Update card pointers aligning them with current stack. *
|
||||
*********************************************************/
|
||||
pCard->m_pPrevCard = m_pTopCard; // link new top prev to old top card
|
||||
pCard->m_pNextCard = nullptr; // new top next card now does not point anywhere
|
||||
|
||||
pCard->m_pStack = this; // reassign proper stack location
|
||||
|
||||
/*************************
|
||||
* Update stack pointers. *
|
||||
*************************/
|
||||
if (m_pTopCard != nullptr)
|
||||
m_pTopCard->m_pNextCard = pCard; // create forward chain for next card
|
||||
|
||||
m_pTopCard = pCard; // link old top card to new top
|
||||
|
||||
if (m_pBottomCard == nullptr)
|
||||
m_pBottomCard = pCard;
|
||||
|
||||
m_nSize++;
|
||||
}
|
||||
|
||||
CCard *CStack::Pop() {
|
||||
CCard *pReturnCard;
|
||||
|
||||
/**************************************************
|
||||
* Undo any links of current card to other stacks. *
|
||||
**************************************************/
|
||||
pReturnCard = m_pTopCard;
|
||||
|
||||
if (m_pTopCard == nullptr) {
|
||||
m_nSize = 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m_pTopCard->m_pPrevCard != nullptr) {
|
||||
m_pTopCard->m_pPrevCard->m_pNextCard = nullptr;
|
||||
m_pTopCard = m_pTopCard->m_pPrevCard;
|
||||
|
||||
if (m_pTopCard->m_pNextCard != nullptr)
|
||||
m_pTopCard->m_pNextCard->m_pPrevCard = m_pTopCard->m_pPrevCard; // make cur prev card point to prev of prev card :^) (if any)
|
||||
|
||||
m_nSize--;
|
||||
} else {
|
||||
m_pTopCard = nullptr;
|
||||
m_pBottomCard = nullptr;
|
||||
m_nSize = 0;
|
||||
}
|
||||
|
||||
return pReturnCard;
|
||||
}
|
||||
|
||||
void CStack::Unlink(CCard *pCard) {
|
||||
/**************************************************
|
||||
* Undo any links of current card to other stacks. *
|
||||
**************************************************/
|
||||
if (pCard->m_pNextCard != nullptr) {
|
||||
pCard->m_pNextCard->m_pPrevCard = pCard->m_pPrevCard; // make cur prev card point to prev of prev card :^) (if any)
|
||||
pCard->m_pNextCard = nullptr;
|
||||
}
|
||||
|
||||
if (pCard->m_pPrevCard != nullptr) {
|
||||
pCard->m_pPrevCard->m_pNextCard = pCard->m_pNextCard; // make cur of prev of next pointer point to next of the next (if any)
|
||||
this->m_pTopCard = pCard->m_pPrevCard; // Top of stack points to the prev card
|
||||
pCard->m_pPrevCard = nullptr; // clear the card "prev card" pointer
|
||||
} else {
|
||||
m_pTopCard = nullptr;
|
||||
m_pBottomCard = nullptr;
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* Card's stack pointer should not point anywhere. *
|
||||
**************************************************/
|
||||
pCard->m_pStack = nullptr; // clear card "stack" pointer
|
||||
}
|
||||
|
||||
int CStack::Size() {
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
75
engines/bagel/hodjnpodj/barbershop/stack.h
Normal file
75
engines/bagel/hodjnpodj/barbershop/stack.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_STACK_H
|
||||
#define HODJNPODJ_BARBERSHOP_STACK_H
|
||||
|
||||
#include "bagel/hodjnpodj/barbershop/card.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define STACKS 8
|
||||
|
||||
|
||||
class CStack {
|
||||
private: // vars
|
||||
int m_nID;
|
||||
CCard *m_pTopCard;
|
||||
CCard *m_pBottomCard;
|
||||
int m_nSize;
|
||||
|
||||
public: // functions
|
||||
|
||||
CStack(CRect, int nID);
|
||||
~CStack();
|
||||
|
||||
void Reset();
|
||||
void Unlink(CCard*);
|
||||
void Push(CCard*);
|
||||
CCard *Pop();
|
||||
CCard *Top() const {
|
||||
return m_pTopCard;
|
||||
}
|
||||
CCard *Bottom() const {
|
||||
return m_pBottomCard;
|
||||
}
|
||||
bool IsEmpty() const {
|
||||
return (bool)(m_pTopCard == nullptr);
|
||||
}
|
||||
int GetID() const {
|
||||
return m_nID;
|
||||
}
|
||||
bool IsTab() {
|
||||
return (bool)(m_nID >= tab && m_nID < stock);
|
||||
}
|
||||
int Size();
|
||||
|
||||
public:
|
||||
CRect m_cRect;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
132
engines/bagel/hodjnpodj/barbershop/stats.cpp
Normal file
132
engines/bagel/hodjnpodj/barbershop/stats.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/barbershop/stats.h"
|
||||
#include "bagel/hodjnpodj/barbershop/resource.h"
|
||||
#include "bagel/hodjnpodj/hodjnpodj.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
CStats::CStats() {
|
||||
m_pTime = nullptr;
|
||||
m_pScore = nullptr;
|
||||
|
||||
m_nLettersSolved = GetPrivateProfileInt(
|
||||
INI_SECTION,
|
||||
INI_LETTERSSOLVED,
|
||||
LSLVD_DEFAULT,
|
||||
INI_FILENAME
|
||||
);
|
||||
|
||||
if (m_nLettersSolved < MIN_LSLVD || m_nLettersSolved > MAX_LSLVD)
|
||||
m_nLettersSolved = LSLVD_DEFAULT;
|
||||
|
||||
m_nScore = 0;
|
||||
|
||||
m_nTime = GetPrivateProfileInt(
|
||||
INI_SECTION,
|
||||
INI_TIME,
|
||||
TIME_DEFAULT,
|
||||
INI_FILENAME
|
||||
);
|
||||
|
||||
|
||||
if (m_nTime < MIN_TIME || m_nTime > MAX_TIME)
|
||||
m_nTime = TIME_DEFAULT;
|
||||
|
||||
m_nCountDown = m_nTime;
|
||||
|
||||
m_nIsUsedGram = GetPrivateProfileInt(
|
||||
INI_SECTION,
|
||||
INI_REC,
|
||||
REC_DEFAULT,
|
||||
INI_FILENAME
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
CStats::~CStats() {
|
||||
if (m_pScore != nullptr) {
|
||||
delete m_pScore;
|
||||
m_pScore = nullptr;
|
||||
}
|
||||
|
||||
if (m_pTime != nullptr) {
|
||||
delete m_pTime;
|
||||
m_pTime = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CStats::ResetGame() {
|
||||
//char chResetUsedGram;
|
||||
int nID;
|
||||
//int i;
|
||||
|
||||
/*************************
|
||||
* Reset crytogram stats. *
|
||||
*************************/
|
||||
m_nCountDown = m_nTime;
|
||||
m_nScore = 0;
|
||||
|
||||
do { // Get random unused cryptogram
|
||||
nID = brand() % CRYPT_RECS;
|
||||
} while (m_nIsUsedGram == nID);
|
||||
|
||||
m_nIsUsedGram = nID; // Mark as used
|
||||
|
||||
WritePrivateProfileString(
|
||||
INI_SECTION,
|
||||
INI_REC,
|
||||
Common::String::format("%d", m_nIsUsedGram).c_str(),
|
||||
INI_FILENAME
|
||||
); // Save used list back
|
||||
|
||||
return nID;
|
||||
}
|
||||
|
||||
|
||||
void CStats::SaveStats(int nLttrsSlvd, int nTime) {
|
||||
m_nLettersSolved = nLttrsSlvd;
|
||||
m_nTime = nTime;
|
||||
|
||||
WritePrivateProfileString(
|
||||
INI_SECTION,
|
||||
INI_LETTERSSOLVED,
|
||||
Common::String::format("%d", m_nLettersSolved).c_str(),
|
||||
INI_FILENAME
|
||||
);
|
||||
|
||||
WritePrivateProfileString(
|
||||
INI_SECTION,
|
||||
INI_TIME,
|
||||
Common::String::format("%d", m_nTime).c_str(),
|
||||
INI_FILENAME
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
58
engines/bagel/hodjnpodj/barbershop/stats.h
Normal file
58
engines/bagel/hodjnpodj/barbershop/stats.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_STATS_H
|
||||
#define HODJNPODJ_BARBERSHOP_STATS_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define STATS_COLOR RGB(255,255,255)
|
||||
|
||||
#define SCORE_FACTOR 2
|
||||
#define SCORE_JACKPOT 100
|
||||
|
||||
class CStats {
|
||||
public:
|
||||
CStats();
|
||||
~CStats();
|
||||
|
||||
void SaveStats(int nLttrsSlvd, int nTime);
|
||||
int ResetGame();
|
||||
|
||||
CText *m_pScore;
|
||||
CText *m_pTime;
|
||||
|
||||
int m_nLettersSolved;
|
||||
int m_nScore;
|
||||
int m_nTime;
|
||||
int m_nCountDown;
|
||||
char m_nIsUsedGram;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
274
engines/bagel/hodjnpodj/barbershop/undo.cpp
Normal file
274
engines/bagel/hodjnpodj/barbershop/undo.cpp
Normal file
@@ -0,0 +1,274 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/barbershop/undo.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* [function name]
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
CUndo::CUndo() {
|
||||
m_cUndoRect = CRect(
|
||||
UNDO_LEF,
|
||||
UNDO_TOP,
|
||||
UNDO_RIG,
|
||||
UNDO_BOT
|
||||
);
|
||||
m_pStack = nullptr;
|
||||
m_pCard = nullptr;
|
||||
m_nStock = NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* [function name]
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
CUndo::~CUndo() {
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* [function name]
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
void CUndo::Record(CStack *pStack, CCard *pCard) {
|
||||
m_pStack = pStack;
|
||||
m_pCard = pCard;
|
||||
m_nStock = NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* [function name]
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
void CUndo::Record(int nCardsFlipped) {
|
||||
m_nStock = nCardsFlipped;
|
||||
|
||||
m_pStack = nullptr;
|
||||
m_pCard = nullptr;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Reset
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Resets undo parameters
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
void CUndo::Reset() {
|
||||
m_pStack = nullptr;
|
||||
m_pCard = nullptr;
|
||||
m_nStock = NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Undo
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Puts card back into original position.
|
||||
* Returns true if undo was possible, else false.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
bool CUndo::Undo(CDC *pDC, CBoard *pBoard, CPaint *pPaint) {
|
||||
CCard *pCard;
|
||||
CPoint cPos;
|
||||
int i;
|
||||
|
||||
if (m_nStock != NONE) { // undo stock card flip?
|
||||
for (i = 0; i < m_nStock; i++) {
|
||||
//
|
||||
// update interal representation
|
||||
//
|
||||
pCard = pBoard->GetStack((loc) used)->Pop();
|
||||
pBoard->GetStack((loc) stock)->Push(pCard);
|
||||
|
||||
//
|
||||
// update visual rep
|
||||
//
|
||||
pPaint->FlipCard(pDC, pCard);
|
||||
pPaint->Stack(pDC, pCard);
|
||||
pPaint->m_nUsedInd--;
|
||||
} // end for
|
||||
|
||||
Reset(); // clear undo
|
||||
return true;
|
||||
} // end if
|
||||
|
||||
if (m_pStack == nullptr) // basic card undo?
|
||||
return false; // No - nothing can be undone
|
||||
|
||||
|
||||
m_pCard->m_pStack->Pop(); // undo move in internal rep
|
||||
m_pStack->Push(m_pCard); // undo move in internal rep
|
||||
|
||||
if (m_pStack->GetID() == used) { // card in used stack?
|
||||
//
|
||||
// messy code to handle special visual used stacking order
|
||||
//
|
||||
if (m_pCard->m_pPrevCard == nullptr) {
|
||||
pPaint->m_nUsedInd = 0;
|
||||
} else {
|
||||
if (m_pCard->m_pPrevCard->m_cOrigin.x == m_pCard->m_pStack->m_cRect.TopLeft().x) {
|
||||
pPaint->m_nUsedInd = 1;
|
||||
} else if (m_pCard->m_pPrevCard->m_cOrigin.x == m_pCard->m_pStack->m_cRect.TopLeft().x + (1 * USED_DX)) {
|
||||
pPaint->m_nUsedInd = 2;
|
||||
} else {
|
||||
pPaint->m_nUsedInd = 0;
|
||||
} // end if
|
||||
} // end if
|
||||
|
||||
pPaint->Stack(pDC, m_pCard); // draw card apro stack
|
||||
pPaint->m_nUsedInd = 0;
|
||||
} else {
|
||||
pPaint->Stack(pDC, m_pCard); // draw card apro stack
|
||||
} // end if
|
||||
|
||||
Reset(); // clear undo
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
61
engines/bagel/hodjnpodj/barbershop/undo.h
Normal file
61
engines/bagel/hodjnpodj/barbershop/undo.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_UNDO_H
|
||||
#define HODJNPODJ_BARBERSHOP_UNDO_H
|
||||
|
||||
#include "bagel/hodjnpodj/barbershop/paint.h"
|
||||
#include "bagel/hodjnpodj/barbershop/board.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
constexpr int NONE = -1;
|
||||
|
||||
#define UNDO_LEF 432 // Undo hotspot rect
|
||||
#define UNDO_TOP 80
|
||||
#define UNDO_RIG (UNDO_LEF + 98)
|
||||
#define UNDO_BOT (UNDO_TOP + 94)
|
||||
|
||||
|
||||
class CUndo {
|
||||
public:
|
||||
CUndo();
|
||||
~CUndo();
|
||||
|
||||
void Record(CStack*, CCard*);
|
||||
void Record(int);
|
||||
void Reset();
|
||||
bool Undo(CDC*, CBoard*, CPaint*);
|
||||
|
||||
CRect m_cUndoRect;
|
||||
private:
|
||||
CStack *m_pStack;
|
||||
CCard *m_pCard;
|
||||
int m_nStock;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
232
engines/bagel/hodjnpodj/barbershop/usercfg.cpp
Normal file
232
engines/bagel/hodjnpodj/barbershop/usercfg.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/bitmaps.h"
|
||||
#include "bagel/hodjnpodj/barbershop/usercfg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/menures.h"
|
||||
#include "bagel/hodjnpodj/barbershop/paint.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define ID_RESET 104
|
||||
#define ID_LIMIT 105
|
||||
|
||||
#define PAGE_SIZE 10
|
||||
|
||||
// globals!!
|
||||
//
|
||||
//
|
||||
extern const char *INI_SECTION;
|
||||
extern CPalette *pGamePalette;
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
extern int g_nCardBack;
|
||||
|
||||
CUserCfgDlg::CUserCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, nID, ".\\ART\\SSCROLL.BMP") {
|
||||
m_cRectCardBack1 = CRect(CBCK_RECT1_LEFT - DELTA, CBCK_RECT1_TOP - DELTA, CBCK_RECT1_RIG + DELTA, CBCK_RECT1_BOT + DELTA);
|
||||
m_cRectCardBack2 = CRect(CBCK_RECT2_LEFT - DELTA, CBCK_RECT2_TOP - DELTA, CBCK_RECT2_RIG + DELTA, CBCK_RECT2_BOT + DELTA);
|
||||
m_nCardBack = g_nCardBack;
|
||||
DoModal();
|
||||
}
|
||||
|
||||
void CUserCfgDlg::DoDataExchange(CDataExchange *pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
bool CUserCfgDlg::OnInitDialog() {
|
||||
CDC *pDC = GetDC();
|
||||
CRect tmpRect;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
m_bSave = false;
|
||||
|
||||
if ((m_ctextBox = new CText) != nullptr) {
|
||||
bool bAssertCheck;
|
||||
|
||||
tmpRect.SetRect(TEXT_LEFT, TEXT_TOP, TEXT_RIG, TEXT_BOT);
|
||||
bAssertCheck = (*m_ctextBox).SetupText(pDC, pGamePalette, &tmpRect, JUSTIFY_CENTER);
|
||||
ASSERT(bAssertCheck); // initialize the text objext
|
||||
} // end if
|
||||
|
||||
if ((m_pOKButton = new CColorButton) != nullptr) { // build a color OK button
|
||||
(*m_pOKButton).SetPalette(pGamePalette); // set the palette to use
|
||||
(*m_pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
} // end if
|
||||
|
||||
ReleaseDC(pDC);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnPaint() {
|
||||
CDC *pDC = nullptr;
|
||||
char msg[64];
|
||||
bool bAssertCheck;
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
if (m_nCardBack == CARD_BACK1) { // card back painting
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK1B_BMP, CBCK_RECT1_LEFT, CBCK_RECT1_TOP, CBCK_RECT1_RIG - CBCK_RECT1_LEFT, CBCK_RECT1_BOT - CBCK_RECT1_TOP);
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK2A_BMP, CBCK_RECT2_LEFT, CBCK_RECT2_TOP, CBCK_RECT2_RIG - CBCK_RECT2_LEFT, CBCK_RECT2_BOT - CBCK_RECT2_TOP);
|
||||
} else {
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK1A_BMP, CBCK_RECT1_LEFT, CBCK_RECT1_TOP, CBCK_RECT1_RIG - CBCK_RECT1_LEFT, CBCK_RECT1_BOT - CBCK_RECT1_TOP);
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK2B_BMP, CBCK_RECT2_LEFT, CBCK_RECT2_TOP, CBCK_RECT2_RIG - CBCK_RECT2_LEFT, CBCK_RECT2_BOT - CBCK_RECT2_TOP);
|
||||
} // end if
|
||||
|
||||
Common::sprintf_s(msg, "Select a card back"); // top message
|
||||
bAssertCheck = (*m_ctextBox).DisplayString(pDC, msg, FONT_SIZE, FW_BOLD, RGBCOLOR_BLACK);
|
||||
ASSERT(bAssertCheck);
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnLButtonUp(unsigned int nFlags, CPoint point) {
|
||||
CDC *pDC = GetDC();
|
||||
|
||||
if (
|
||||
m_cRectCardBack1.PtInRect(point) == true &&
|
||||
m_nCardBack != CARD_BACK1
|
||||
) {
|
||||
// update visual image
|
||||
//
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK1B_BMP, CBCK_RECT1_LEFT, CBCK_RECT1_TOP, CBCK_RECT1_RIG - CBCK_RECT1_LEFT, CBCK_RECT1_BOT - CBCK_RECT1_TOP);
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK2A_BMP, CBCK_RECT2_LEFT, CBCK_RECT2_TOP, CBCK_RECT2_RIG - CBCK_RECT2_LEFT, CBCK_RECT2_BOT - CBCK_RECT2_TOP);
|
||||
|
||||
m_nCardBack = CARD_BACK1;
|
||||
} else if (
|
||||
m_cRectCardBack2.PtInRect(point) == true &&
|
||||
m_nCardBack != CARD_BACK2
|
||||
) {
|
||||
// update visual image
|
||||
//
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK1A_BMP, CBCK_RECT1_LEFT, CBCK_RECT1_TOP, CBCK_RECT1_RIG - CBCK_RECT1_LEFT, CBCK_RECT1_BOT - CBCK_RECT1_TOP);
|
||||
PaintMaskedDIB(pDC, pGamePalette, CARD_BACK2B_BMP, CBCK_RECT2_LEFT, CBCK_RECT2_TOP, CBCK_RECT2_RIG - CBCK_RECT2_LEFT, CBCK_RECT2_BOT - CBCK_RECT2_TOP);
|
||||
|
||||
m_nCardBack = CARD_BACK2;
|
||||
} // end if
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnOK() {
|
||||
ValidateRect(nullptr);
|
||||
g_nCardBack = m_nCardBack;
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnCancel() {
|
||||
ValidateRect(nullptr);
|
||||
EndDialog(IDCANCEL);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnClose() {
|
||||
ValidateRect(nullptr);
|
||||
if (m_pOKButton != nullptr) { // release button
|
||||
delete m_pOKButton;
|
||||
m_pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_ctextBox != nullptr) {
|
||||
delete m_ctextBox;
|
||||
m_ctextBox = nullptr;
|
||||
} // end if
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CUserCfgDlg, CBmpDialog)
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* MyFocusRect( CDC *pDC, CRect rect, int nDrawMode )
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Draws a rectangle which inverts the current pixels,
|
||||
* thereby delineating the current area of focus.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* CDC *pDC The Device context in which the FocusRect is to be drawn
|
||||
* CRect rect The CRect object holding the location of the FocusRect
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* pMyPen and pMyBrush, global pointers to the Pen and Brush used
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* none
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
void CUserCfgDlg::MyFocusRect(CDC *pDC, CRect rect, int nDrawMode, COLORREF rgbColor) {
|
||||
CBrush *pMyBrush = nullptr; // New Brush
|
||||
CBrush *pOldBrush = nullptr; // Pointer to old brush
|
||||
CPen *pMyPen = nullptr; // New Pen
|
||||
CPen *pOldPen = nullptr; // Pointer to old pen
|
||||
CPalette *pPalOld = nullptr; // Pointer to old palette
|
||||
int OldDrawMode; // Holder for old draw mode
|
||||
|
||||
pMyBrush = new CBrush(); // Construct new brush
|
||||
pMyPen = new CPen(); // Construct new pen
|
||||
|
||||
LOGBRUSH lb; // log brush type
|
||||
lb.lbStyle = BS_HOLLOW; // Don't fill in area
|
||||
pMyBrush->CreateBrushIndirect(&lb); // Create a new brush
|
||||
pMyPen->CreatePen(PS_INSIDEFRAME, DELTA, rgbColor); // Create a new pen
|
||||
|
||||
pPalOld = (*pDC).SelectPalette(pGamePalette, false); // Select in game palette
|
||||
(*pDC).RealizePalette(); // Use it
|
||||
|
||||
pOldPen = pDC->SelectObject(pMyPen); // Select the new pen & save old
|
||||
pOldBrush = pDC->SelectObject(pMyBrush); // Select the new brush & save old
|
||||
OldDrawMode = pDC->SetROP2(nDrawMode); // Set pen mode, saving old state
|
||||
|
||||
pDC->Rectangle(rect); // Draw the Rectangle to the DC
|
||||
|
||||
pDC->SelectObject(pOldPen); // Select the old pen
|
||||
pDC->SelectObject(pOldBrush); // Select the old brush
|
||||
pDC->SetROP2(OldDrawMode); // Set pen mode back to old state
|
||||
(*pDC).SelectPalette(pPalOld, false); // Select back the old palette
|
||||
|
||||
pMyBrush->DeleteObject();
|
||||
delete pMyBrush;
|
||||
|
||||
pMyPen->DeleteObject();
|
||||
delete pMyPen;
|
||||
}
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
93
engines/bagel/hodjnpodj/barbershop/usercfg.h
Normal file
93
engines/bagel/hodjnpodj/barbershop/usercfg.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BARBERSHOP_USERCFG_H
|
||||
#define HODJNPODJ_BARBERSHOP_USERCFG_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/barbershop/main.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Barbershop {
|
||||
|
||||
#define RGBCOLOR_DARKRED RGB(0, 128, 0)
|
||||
#define RGBCOLOR_BLACK RGB(0, 0, 0)
|
||||
#define RGBCOLOR_WHITE RGB(255, 255, 255)
|
||||
|
||||
#define FONT_SIZE 16 // CText object font size
|
||||
|
||||
// CText message
|
||||
#define TEXT_LEFT 20
|
||||
#define TEXT_TOP 25
|
||||
#define TEXT_RIG 220
|
||||
#define TEXT_BOT 46
|
||||
|
||||
// card back rect 1
|
||||
#define CBCK_RECT1_LEFT 40
|
||||
#define CBCK_RECT1_TOP 55
|
||||
#define CBCK_RECT1_RIG 110
|
||||
#define CBCK_RECT1_BOT 125
|
||||
|
||||
// card back rect 2
|
||||
#define CBCK_RECT2_LEFT 120
|
||||
#define CBCK_RECT2_TOP 55
|
||||
#define CBCK_RECT2_RIG 190
|
||||
#define CBCK_RECT2_BOT 125
|
||||
|
||||
#define DELTA 0
|
||||
|
||||
#define IDD_USERCFG 100
|
||||
|
||||
class CUserCfgDlg : public CBmpDialog {
|
||||
public:
|
||||
CUserCfgDlg(CWnd *pParent = nullptr, CPalette *pPalette = nullptr, unsigned int = IDD_USERCFG);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void DoDataExchange(CDataExchange *) override;
|
||||
virtual bool OnInitDialog() override;
|
||||
|
||||
void OnClose();
|
||||
void OnPaint();
|
||||
void OnLButtonUp(unsigned int, CPoint);
|
||||
void OnCancel() override;
|
||||
void OnOK() override;
|
||||
DECLARE_MESSAGE_MAP()
|
||||
void MyFocusRect(CDC*, CRect, int nDrawMode, COLORREF);
|
||||
|
||||
private:
|
||||
bool m_bSave = false; // True if should save theses values
|
||||
CRect m_cRectCardBack1;
|
||||
CRect m_cRectCardBack2;
|
||||
unsigned int m_nCardBack = 0;
|
||||
CColorButton *m_pOKButton = nullptr; // OKAY button on scroll
|
||||
CText *m_ctextBox = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Barbershop
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
3715
engines/bagel/hodjnpodj/battlefish/bfish.cpp
Normal file
3715
engines/bagel/hodjnpodj/battlefish/bfish.cpp
Normal file
File diff suppressed because it is too large
Load Diff
151
engines/bagel/hodjnpodj/battlefish/bfish.h
Normal file
151
engines/bagel/hodjnpodj/battlefish/bfish.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BATTLEFISH_BFISH_H
|
||||
#define HODJNPODJ_BATTLEFISH_BFISH_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/boflib/error.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
#define GRID_ROWS 8
|
||||
#define GRID_COLS 8
|
||||
#define MAX_FISH 4
|
||||
#define MAX_FISH_SIZE 2*3
|
||||
|
||||
#define MAX_TURNS MAX_FISH
|
||||
|
||||
typedef struct {
|
||||
POINT nLoc[MAX_FISH_SIZE + 1];
|
||||
byte life;
|
||||
} FISH;
|
||||
|
||||
class CBFishWindow : public CFrameWnd {
|
||||
public:
|
||||
CBFishWindow();
|
||||
void PlayGame();
|
||||
void PaintScreen();
|
||||
void LoadIniSettings();
|
||||
void SaveIniSettings();
|
||||
|
||||
protected:
|
||||
void FlushInputEvents();
|
||||
void GameReset();
|
||||
void GamePause();
|
||||
void GameResume();
|
||||
void HandleError(ERROR_CODE);
|
||||
void DeleteSprite(CSprite *);
|
||||
ERROR_CODE RepaintSpriteList(CDC *);
|
||||
ERROR_CODE LoadMasterSprites();
|
||||
void ReleaseMasterSprites();
|
||||
void PlaceUserFish();
|
||||
void PlaceEnemyFish();
|
||||
void RotateFish(int);
|
||||
void AssignFishToGrid(int);
|
||||
int GetEnemyGridIndex(CPoint);
|
||||
int GetUserGridIndex(CPoint);
|
||||
int GetFishIndex(CSprite *);
|
||||
bool OkToPlaceFish(int, CPoint, bool);
|
||||
void PlaceFish(int, CPoint);
|
||||
int IndexToId(int);
|
||||
int IdToIndex(int);
|
||||
CPoint SnapToGrid(CPoint);
|
||||
void UsersTurn(int);
|
||||
void ComputersTurn();
|
||||
int SelectRandomTarget();
|
||||
int SelectBurningTarget();
|
||||
int SelectBestFitTarget();
|
||||
int FindNeighborTarget(int, int);
|
||||
int FindTarget(int, int);
|
||||
int FindMatch(int, int);
|
||||
bool FishFits(int, int, int);
|
||||
int GetNeighbors(int, int);
|
||||
void CreatePlume(CPoint);
|
||||
void CreateHarpoon(CPoint);
|
||||
void SinkUserFish(int);
|
||||
void SinkEnemyFish(int);
|
||||
void PlaceTurnHarpoons();
|
||||
void RemoveTurnHarpoon();
|
||||
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
void OnSoundNotify(CSound *);
|
||||
void OnPaint();
|
||||
void OnMouseMove(unsigned int, CPoint);
|
||||
void OnRButtonDown(unsigned int, CPoint);
|
||||
void OnLButtonDown(unsigned int, CPoint);
|
||||
void OnLButtonUp(unsigned int, CPoint);
|
||||
void OnSysChar(unsigned int, unsigned int, unsigned int);
|
||||
void OnSysKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnActivate(unsigned int, CWnd *, bool) override;
|
||||
void OnClose();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
// Data Members
|
||||
//
|
||||
byte m_nUserGrid[GRID_ROWS][GRID_COLS] = {};
|
||||
byte m_nEnemyGrid[GRID_ROWS][GRID_COLS] = {};
|
||||
FISH m_aEnemyFishInfo[MAX_FISH] = {};
|
||||
FISH m_aUserFishInfo[MAX_FISH] = {};
|
||||
CRect m_rNewGameButton;
|
||||
CRect m_rEndPlacement;
|
||||
CPoint m_cLastPoint;
|
||||
CSprite *m_pHarpoons[MAX_TURNS] = {};
|
||||
CSprite *m_pFish[MAX_FISH] = {};
|
||||
CSprite *m_pEnemyFish[MAX_FISH] = {};
|
||||
CSprite *m_pMasterHit = nullptr;
|
||||
CSprite *m_pMasterMiss = nullptr;
|
||||
CSprite *m_pMasterHarpoon = nullptr;
|
||||
CSprite *m_pDragFish = nullptr;
|
||||
CSprite *m_pScrollSprite = nullptr;
|
||||
CSprite *m_pOctopus = nullptr;
|
||||
CPalette *m_pGamePalette = nullptr;
|
||||
CSound *m_pSoundTrack = nullptr;
|
||||
CText *m_pTxtClickHere = nullptr;
|
||||
int m_nEnemyFish = 0;
|
||||
int m_nUserFish = 0;
|
||||
int m_nTurns = 0;
|
||||
int m_nDifficultyLevel = 0;
|
||||
bool m_bGameActive = false;
|
||||
bool m_bPause = false;
|
||||
bool m_bUserEditMode = false;
|
||||
bool m_bMovingFish = false;
|
||||
bool m_bLastRotated = false;
|
||||
bool m_bStillCheck = false;
|
||||
bool m_bUsersTurn = false;
|
||||
bool m_bInMenu = false;
|
||||
};
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
98
engines/bagel/hodjnpodj/battlefish/init.cpp
Normal file
98
engines/bagel/hodjnpodj/battlefish/init.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/battlefish/bfish.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunBFish
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke poker
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
HWND FAR PASCAL RunBFish(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CBFishWindow *pMain;
|
||||
|
||||
pGameParams = lpGameInfo;
|
||||
|
||||
// invoke your game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMain = new CBFishWindow) != nullptr) {
|
||||
|
||||
pMain->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
pMain->UpdateWindow();
|
||||
|
||||
pMain->SetActiveWindow();
|
||||
|
||||
if (pGameParams->bPlayingMetagame)
|
||||
pMain->PlayGame();
|
||||
}
|
||||
|
||||
// these must be set in this function
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMain->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
33
engines/bagel/hodjnpodj/battlefish/init.h
Normal file
33
engines/bagel/hodjnpodj/battlefish/init.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
extern HWND FAR PASCAL RunBFish(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
407
engines/bagel/hodjnpodj/battlefish/usercfg.cpp
Normal file
407
engines/bagel/hodjnpodj/battlefish/usercfg.cpp
Normal file
@@ -0,0 +1,407 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/battlefish/usercfg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
#define ID_RESET 104
|
||||
#define ID_LIMIT 105
|
||||
|
||||
#define ID_PLAYER 106
|
||||
#define ID_COMPUTER 107
|
||||
|
||||
#define PAGE_SIZE 1
|
||||
|
||||
static const char *pszDiffLevel[DIFF_MAX + 1] = {
|
||||
"Wimpy",
|
||||
"Average",
|
||||
"Hefty"
|
||||
};
|
||||
|
||||
extern const char *INI_SECTION;
|
||||
|
||||
|
||||
CUserCfgDlg::CUserCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, nID, ".\\ART\\SSCROLL.BMP") {
|
||||
m_pOKButton = nullptr;
|
||||
m_pCancelButton = nullptr;
|
||||
m_pDefaultsButton = nullptr;
|
||||
m_pUserButton = nullptr;
|
||||
m_pCompButton = nullptr;
|
||||
DoModal();
|
||||
}
|
||||
|
||||
bool CUserCfgDlg::OnInitDialog() {
|
||||
CRect tmpRect;
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
m_pTxtLevel = nullptr;
|
||||
m_pTxtDifficulty = nullptr;
|
||||
|
||||
tmpRect.SetRect(22, 135, 122, 155);
|
||||
if ((m_pScrollBar = new CScrollBar) != nullptr) {
|
||||
m_pScrollBar->Create(WS_VISIBLE | WS_CHILD | SBS_HORZ | SBS_BOTTOMALIGN, tmpRect, this, ID_LIMIT);
|
||||
m_pScrollBar->SetScrollRange(DIFF_MIN, DIFF_MAX, true);
|
||||
}
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
tmpRect.SetRect(25, 111, 80, 131);
|
||||
if ((m_pTxtLevel = new CText) != nullptr) {
|
||||
m_pTxtLevel->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(81, 111, 146, 131);
|
||||
if ((m_pTxtDifficulty = new CText) != nullptr) {
|
||||
m_pTxtDifficulty->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(25, 20, 150, 40);
|
||||
if ((m_pTxtOrder = new CText) != nullptr) {
|
||||
m_pTxtOrder->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
if ((m_pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*m_pOKButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*m_pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*m_pCancelButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*m_pCancelButton).SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pDefaultsButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*m_pDefaultsButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*m_pDefaultsButton).SetControl(ID_RESET, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pUserButton = new CRadioButton) != nullptr) {
|
||||
tmpRect.SetRect(21, 32, 75, 45);
|
||||
//m_pUserButton->Create("Human", BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP | BS_OWNERDRAW, tmpRect, this, ID_PLAYER);
|
||||
m_pUserButton->SetPalette(m_pPalette);
|
||||
m_pUserButton->SetControl(ID_PLAYER, this);
|
||||
}
|
||||
|
||||
if ((m_pCompButton = new CRadioButton) != nullptr) {
|
||||
tmpRect.SetRect(21, 45, 75, 58);
|
||||
//m_pUserButton->Create("Computer", BS_AUTORADIOBUTTON | WS_TABSTOP | BS_OWNERDRAW, tmpRect, this, ID_COMPUTER);
|
||||
m_pCompButton->SetPalette(m_pPalette);
|
||||
m_pCompButton->SetControl(ID_COMPUTER, this);
|
||||
}
|
||||
|
||||
m_bSave = false;
|
||||
|
||||
LoadIniSettings();
|
||||
|
||||
PutDlgData();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::PutDlgData() {
|
||||
m_pScrollBar->SetScrollPos(m_nDifficultyLevel);
|
||||
|
||||
m_pUserButton->SetCheck(m_bUserGoesFirst);
|
||||
m_pCompButton->SetCheck(!m_bUserGoesFirst);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::GetDlgData() {
|
||||
m_nDifficultyLevel = m_pScrollBar->GetScrollPos();
|
||||
|
||||
m_bUserGoesFirst = false;
|
||||
if (m_pUserButton->GetCheck() == 1)
|
||||
m_bUserGoesFirst = true;
|
||||
}
|
||||
|
||||
|
||||
bool CUserCfgDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
//
|
||||
// respond to user
|
||||
//
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
|
||||
switch (wParam) {
|
||||
|
||||
case IDOK:
|
||||
m_bSave = true;
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
return false;
|
||||
|
||||
case IDCANCEL:
|
||||
ClearDialogImage();
|
||||
EndDialog(IDCANCEL);
|
||||
return false;
|
||||
|
||||
case ID_PLAYER:
|
||||
m_bUserGoesFirst = true;
|
||||
PutDlgData();
|
||||
break;
|
||||
|
||||
case ID_COMPUTER:
|
||||
m_bUserGoesFirst = false;
|
||||
PutDlgData();
|
||||
break;
|
||||
|
||||
/*
|
||||
* reset params to default
|
||||
*/
|
||||
case ID_RESET:
|
||||
|
||||
m_nDifficultyLevel = DIFF_DEF;
|
||||
m_bUserGoesFirst = TURN_DEF;
|
||||
|
||||
PutDlgData();
|
||||
DispLimit();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CBmpDialog::OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar *pScroll) {
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_LEFT:
|
||||
m_nDifficultyLevel = DIFF_MIN;
|
||||
break;
|
||||
|
||||
case SB_PAGELEFT:
|
||||
m_nDifficultyLevel -= PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
if (m_nDifficultyLevel > DIFF_MIN)
|
||||
m_nDifficultyLevel--;
|
||||
break;
|
||||
|
||||
case SB_RIGHT:
|
||||
m_nDifficultyLevel = DIFF_MAX;
|
||||
break;
|
||||
|
||||
case SB_PAGERIGHT:
|
||||
m_nDifficultyLevel += PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINERIGHT:
|
||||
if (m_nDifficultyLevel < DIFF_MAX)
|
||||
m_nDifficultyLevel++;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
m_nDifficultyLevel = nPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_nDifficultyLevel <= DIFF_MIN)
|
||||
m_nDifficultyLevel = DIFF_MIN;
|
||||
if (m_nDifficultyLevel > DIFF_MAX)
|
||||
m_nDifficultyLevel = DIFF_MAX;
|
||||
|
||||
// can't access a null pointer
|
||||
assert(pScroll != nullptr);
|
||||
|
||||
pScroll->SetScrollPos(m_nDifficultyLevel);
|
||||
|
||||
DispLimit();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* LoadIniSettings
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Loads this game's parameters from .INI file
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* None
|
||||
*
|
||||
****************************************************************/
|
||||
void CUserCfgDlg::LoadIniSettings() {
|
||||
int nVal;
|
||||
|
||||
// Get the Difficulty level (0..2)
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "DifficultyLevel", DIFF_DEF, INI_FILENAME);
|
||||
m_nDifficultyLevel = nVal;
|
||||
if (nVal < DIFF_MIN || nVal > DIFF_MAX)
|
||||
m_nDifficultyLevel = DIFF_DEF;
|
||||
|
||||
// Get the UserGoesFirst option setting
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "UserGoesFirst", TURN_DEF, INI_FILENAME);
|
||||
m_bUserGoesFirst = (nVal == 0 ? false : true);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::SaveIniSettings() {
|
||||
WritePrivateProfileString(INI_SECTION,
|
||||
"DifficultyLevel",
|
||||
Common::String::format("%d", m_nDifficultyLevel).c_str(),
|
||||
INI_FILENAME);
|
||||
|
||||
WritePrivateProfileString(INI_SECTION,
|
||||
"UserGoesFirst",
|
||||
Common::String::format("%d", m_bUserGoesFirst).c_str(),
|
||||
INI_FILENAME);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnPaint() {
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
m_pTxtLevel->DisplayString(pDC, "Difficulty:", 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
m_pTxtOrder->DisplayString(pDC, "Who goes first?", 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
DispLimit();
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnDestroy() {
|
||||
if (m_pOKButton != nullptr) { // release the button
|
||||
delete m_pOKButton;
|
||||
m_pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pCancelButton != nullptr) { // release the button
|
||||
delete m_pCancelButton;
|
||||
m_pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pDefaultsButton != nullptr) { // release the button
|
||||
delete m_pDefaultsButton;
|
||||
m_pDefaultsButton = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtDifficulty != nullptr);
|
||||
if (m_pTxtDifficulty != nullptr) {
|
||||
delete m_pTxtDifficulty;
|
||||
m_pTxtDifficulty = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtLevel != nullptr);
|
||||
if (m_pTxtLevel != nullptr) {
|
||||
delete m_pTxtLevel;
|
||||
m_pTxtLevel = nullptr;
|
||||
}
|
||||
|
||||
if (m_pTxtOrder != nullptr) {
|
||||
delete m_pTxtOrder;
|
||||
m_pTxtOrder = nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
// de-allocate the scroll bar
|
||||
//
|
||||
assert(m_pScrollBar != nullptr);
|
||||
if (m_pScrollBar != nullptr) {
|
||||
delete m_pScrollBar;
|
||||
m_pScrollBar = nullptr;
|
||||
}
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::ClearDialogImage() {
|
||||
if (m_bSave) {
|
||||
GetDlgData();
|
||||
SaveIniSettings();
|
||||
}
|
||||
|
||||
if (m_pCompButton != nullptr) {
|
||||
delete m_pCompButton;
|
||||
m_pCompButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pUserButton != nullptr) {
|
||||
delete m_pUserButton;
|
||||
m_pUserButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pOKButton != nullptr) { // release the button
|
||||
delete m_pOKButton;
|
||||
m_pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pCancelButton != nullptr) { // release the button
|
||||
delete m_pCancelButton;
|
||||
m_pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pDefaultsButton != nullptr) { // release the button
|
||||
delete m_pDefaultsButton;
|
||||
m_pDefaultsButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::DispLimit() {
|
||||
CDC *pDC;
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
m_pTxtDifficulty->DisplayString(pDC, pszDiffLevel[m_nDifficultyLevel], 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CUserCfgDlg, CBmpDialog)
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
80
engines/bagel/hodjnpodj/battlefish/usercfg.h
Normal file
80
engines/bagel/hodjnpodj/battlefish/usercfg.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BATTLEFISH_USERCFG_H
|
||||
#define HODJNPODJ_BATTLEFISH_USERCFG_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/boflib/misc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
#define IDD_USERCFG 100
|
||||
|
||||
#define DIFF_MIN 0
|
||||
#define DIFF_MAX 2
|
||||
#define DIFF_DEF 2
|
||||
|
||||
#define TURN_DEF false
|
||||
|
||||
class CUserCfgDlg : public CBmpDialog {
|
||||
public:
|
||||
CUserCfgDlg(CWnd *pParent = nullptr, CPalette *pPalette = nullptr, unsigned int = IDD_USERCFG);
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
virtual bool OnInitDialog() override;
|
||||
void PutDlgData();
|
||||
void GetDlgData();
|
||||
void DispLimit();
|
||||
void LoadIniSettings();
|
||||
void SaveIniSettings();
|
||||
|
||||
void OnHScroll(unsigned int, unsigned int, CScrollBar *);
|
||||
void OnDestroy();
|
||||
void OnPaint();
|
||||
void ClearDialogImage();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CColorButton *m_pOKButton = nullptr; // OKAY button on scroll
|
||||
CColorButton *m_pCancelButton = nullptr; // Cancel button on scroll
|
||||
CColorButton *m_pDefaultsButton = nullptr; // Defaults button on scroll
|
||||
CRadioButton *m_pUserButton = nullptr;
|
||||
CRadioButton *m_pCompButton = nullptr;
|
||||
CText *m_pTxtDifficulty = nullptr;
|
||||
CText *m_pTxtLevel = nullptr;
|
||||
CText *m_pTxtOrder = nullptr;
|
||||
CScrollBar *m_pScrollBar = nullptr;
|
||||
unsigned int m_nDifficultyLevel = 0; // Difficulty level for BattleFish
|
||||
bool m_bSave = false; // True if should save theses settings
|
||||
bool m_bUserGoesFirst = false; // true if Human player goes 1st
|
||||
};
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
1765
engines/bagel/hodjnpodj/beacon/beacon.cpp
Normal file
1765
engines/bagel/hodjnpodj/beacon/beacon.cpp
Normal file
File diff suppressed because it is too large
Load Diff
171
engines/bagel/hodjnpodj/beacon/beacon.h
Normal file
171
engines/bagel/hodjnpodj/beacon/beacon.h
Normal file
@@ -0,0 +1,171 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BEACON_BEACON_H
|
||||
#define HODJNPODJ_BEACON_BEACON_H
|
||||
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Beacon {
|
||||
|
||||
#define ABS(a) ( (a > 0) ? (a) : (-a) )
|
||||
|
||||
// Border info
|
||||
#define TOP_BORDER 24 //25
|
||||
#define BOTTOM_BORDER 16
|
||||
#define SIDE_BORDER 16
|
||||
|
||||
#define BEACON_TIMER 1
|
||||
#define MIN_SPEED 0
|
||||
#define MAX_SPEED 2
|
||||
#define SPEED_BASE 70
|
||||
#define SPEED_STEP 10
|
||||
|
||||
#define NUM_BEAMS 120
|
||||
#define CHANGE_BEAM 144
|
||||
#define START_ENTRY 55 // Starting entry of available palette slots
|
||||
#define BUTTON_ENTRY 176 // First entry of the Button palette slots
|
||||
|
||||
#define GRID_WIDTH 8 //5 // Number of pixels
|
||||
#define GRID_HEIGHT 8 //5
|
||||
|
||||
// Game playing area
|
||||
#define ART_WIDTH 488
|
||||
#define ART_HEIGHT 440
|
||||
|
||||
#define NUM_BUTTONS 16 // Number of buttons
|
||||
#define NUM_COLUMNS (ART_WIDTH / GRID_WIDTH)
|
||||
#define NUM_ROWS (ART_HEIGHT / GRID_HEIGHT)
|
||||
|
||||
// Lighthouse bitmap placement
|
||||
#define LTHOUSE_OFFSET_X 20
|
||||
#define LTHOUSE_OFFSET_Y 15
|
||||
#define LTHOUSE_WIDTH 50
|
||||
#define LTHOUSE_HEIGHT 70
|
||||
|
||||
// Start area
|
||||
#define START_OFFSET_X 36 // GRID_WIDTH * 4.5
|
||||
#define START_OFFSET_Y 28 // GRID_HEIGHT * 3.5
|
||||
#define START_WIDTH 72 // GRID_WIDTH * 9
|
||||
#define START_HEIGHT 88 // GRID_HEIGHT * 11
|
||||
|
||||
// Color Button placement
|
||||
#define BLOCK_SPACE_X 6
|
||||
#define BLOCK_SPACE_Y 6
|
||||
#define BLOCK_OFFSET_X (ART_WIDTH + SIDE_BORDER + BLOCK_SPACE_X)
|
||||
#define BLOCK_OFFSET_Y 74 // TOP_BORDER + 50
|
||||
#define BLOCK_WIDTH 50
|
||||
#define BLOCK_HEIGHT 40
|
||||
|
||||
#define SELECT_COLOR 0 // Always use Black for highlighting selected beacon color
|
||||
#define HILITE_BORDER 4 // The highlighting frame is three pixels wide
|
||||
#define XTRALITE_TRIM 42 // Color Index of lightest trim color
|
||||
#define LITE_TRIM 30 // Color Index of light trim color
|
||||
#define MEDIUM_TRIM 45 // Color Index of medium trim color
|
||||
#define DARK_TRIM 46 // Color Index of dark trim color
|
||||
|
||||
// Starting value defaults
|
||||
#define MAX_SWEEPS 300
|
||||
#define MIN_SWEEPS 5
|
||||
|
||||
// Sound files
|
||||
#define MID_SOUND ".\\sound\\bong.wav"
|
||||
#define PICK_SOUND ".\\sound\\pick.wav"
|
||||
#define LOSE_SOUND ".\\sound\\buzzer.wav"
|
||||
#define WIN_SOUND ".\\SOUND\\SOUNDWON.WAV"
|
||||
|
||||
#define GAME_THEME ".\\sound\\beacon.mid"
|
||||
#define RULES_WAV ".\\SOUND\\BEACON.WAV"
|
||||
#define RULES_TEXT "BEACON.TXT"
|
||||
|
||||
// Backdrop bitmaps
|
||||
#define MAINSCREEN ".\\ART\\BEACBRDR.BMP"
|
||||
#define BEAMSCREEN ".\\ART\\BEAMS3.BMP"
|
||||
|
||||
// Artwork data file constants
|
||||
#define DATA_FILE ".\\BEACON.DAT"
|
||||
#define MAX_FILE_LENGTH 20
|
||||
|
||||
// New Game button area
|
||||
#define NEWGAME_LOCATION_X 15
|
||||
#define NEWGAME_LOCATION_Y 0
|
||||
#define NEWGAME_WIDTH 217
|
||||
#define NEWGAME_HEIGHT 20
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CMainWindow:
|
||||
// See game.cpp for the code to the member functions and the message map.
|
||||
//
|
||||
class CMainWindow : public CFrameWnd {
|
||||
private:
|
||||
struct BLOCK {
|
||||
CRect rLocation;
|
||||
unsigned int nColorIndex;
|
||||
} colorBlock[NUM_BUTTONS];
|
||||
|
||||
void initStatics();
|
||||
|
||||
public:
|
||||
CMainWindow();
|
||||
void NewGame();
|
||||
void DrawBeams(CDC *pDC);
|
||||
void MoveBeam();
|
||||
void CheckUnderBeam();
|
||||
void SetBeamEntries(CDC *pDC);
|
||||
static void DrawPart(CDC *pDC, CPoint Src, CPoint Dst, int nWidth, int nHeight);
|
||||
static bool CompareColors(CDC *pDC, CPoint point);
|
||||
static bool UnderLighthouse(CPoint point);
|
||||
static bool InPictureSquare(CPoint point);
|
||||
static CPoint PointToGrid(CPoint point);
|
||||
bool LoadArtWork(CDC *pDC);
|
||||
|
||||
//added data members:
|
||||
private:
|
||||
void OnSoundNotify(CSound *pSound);
|
||||
|
||||
protected:
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
|
||||
//{{AFX_MSG( CMainWindow )
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnSysKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnTimer(uintptr nIDEvent);
|
||||
afx_msg void OnLButtonDown(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnClose();
|
||||
afx_msg LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace Beacon
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
45
engines/bagel/hodjnpodj/beacon/globals.h
Normal file
45
engines/bagel/hodjnpodj/beacon/globals.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BEACON_GLOBALS_H
|
||||
#define HODJNPODJ_BEACON_GLOBALS_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Beacon {
|
||||
|
||||
// Main Window positioning constants
|
||||
#define GAME_WIDTH 640
|
||||
#define GAME_HEIGHT 480
|
||||
|
||||
// Scroll button size and positioning information
|
||||
#define IDC_SCROLL 850
|
||||
|
||||
#define SCROLL_BUTTON_X 250
|
||||
#define SCROLL_BUTTON_Y 0
|
||||
#define SCROLL_BUTTON_DX 140
|
||||
#define SCROLL_BUTTON_DY 24
|
||||
|
||||
} // namespace Beacon
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
69
engines/bagel/hodjnpodj/beacon/init.cpp
Normal file
69
engines/bagel/hodjnpodj/beacon/init.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/beacon/beacon.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Beacon {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
|
||||
LPGAMESTRUCT pGameInfo;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
HWND FAR PASCAL RunBeac(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CMainWindow *pMain;
|
||||
|
||||
pGameInfo = lpGameInfo;
|
||||
|
||||
// invoke your game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMain = new CMainWindow()) != nullptr) {
|
||||
|
||||
pMain->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
pMain->UpdateWindow();
|
||||
|
||||
pMain->SetActiveWindow();
|
||||
}
|
||||
|
||||
// these must be set in this function
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMain->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace Beacon
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
65
engines/bagel/hodjnpodj/beacon/init.h
Normal file
65
engines/bagel/hodjnpodj/beacon/init.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BEACON_GAMEDLL_H
|
||||
#define HODJNPODJ_BEACON_GAMEDLL_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Beacon {
|
||||
|
||||
/**
|
||||
****************************************************************
|
||||
*
|
||||
* RunBeac
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke poker
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************
|
||||
*/
|
||||
extern HWND FAR PASCAL RunBeac(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
|
||||
|
||||
} // namespace Beacon
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
387
engines/bagel/hodjnpodj/beacon/optndlg.cpp
Normal file
387
engines/bagel/hodjnpodj/beacon/optndlg.cpp
Normal file
@@ -0,0 +1,387 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/beacon/globals.h"
|
||||
#include "bagel/hodjnpodj/beacon/resource.h"
|
||||
#include "bagel/hodjnpodj/beacon/beacon.h"
|
||||
#include "bagel/hodjnpodj/beacon/optndlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Beacon {
|
||||
|
||||
static CPalette *pSubOptionsPalette;
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
|
||||
static CCheckButton *pAutoButton = nullptr; // Framed check box
|
||||
static CCheckButton *pChangeButton = nullptr; // Framed check box
|
||||
|
||||
CText *m_pScoreText = nullptr;
|
||||
CText *m_pSweepsText = nullptr;
|
||||
CText *m_pSpeedText = nullptr;
|
||||
|
||||
int m_nSweepSettings[15] = {MIN_SWEEPS, 10, 15, 20, 30, 40, 50, 60, 80, 100, 120, 150, 200, 250, MAX_SWEEPS}; // 14 factors
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg dialog
|
||||
|
||||
|
||||
COptnDlg::COptnDlg(CWnd* pParent, CPalette* pPalette)
|
||||
: CBmpDialog(pParent, pPalette, IDD_SUBOPTIONS, ".\\ART\\SSCROLL.BMP") {
|
||||
//{{AFX_DATA_INIT(COptnDlg)
|
||||
m_bAutomatic = false;
|
||||
m_bChangeAtTwelve = false;
|
||||
m_nSweeps = 0;
|
||||
m_nSpeed = MIN_SPEED;
|
||||
nSweepSets = 15;
|
||||
pSubOptionsPalette = pPalette;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
COptnDlg::~COptnDlg() {
|
||||
if (m_pScoreText != nullptr)
|
||||
delete m_pScoreText;
|
||||
if (m_pSweepsText != nullptr)
|
||||
delete m_pSweepsText;
|
||||
if (m_pSpeedText != nullptr)
|
||||
delete m_pSpeedText;
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
void COptnDlg::DoDataExchange(CDataExchange* pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(COptnDlg)
|
||||
DDX_Control(pDX, IDC_NUMSWEEPS, m_ScrollSweeps);
|
||||
DDX_Control(pDX, IDC_SPEED, m_ScrollSpeed);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(COptnDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(COptnDlg)
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_CREATE()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_PAINT()
|
||||
ON_BN_CLICKED(IDC_AUTOMATIC, COptnDlg::OnAutomatic)
|
||||
ON_BN_CLICKED(IDC_CHANGE, COptnDlg::OnChangeAtTwelve)
|
||||
ON_WM_DESTROY()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg message handlers
|
||||
|
||||
int COptnDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) {
|
||||
if (CBmpDialog::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool COptnDlg::OnInitDialog() {
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
CDC *pDC;
|
||||
CRect statRect;
|
||||
int i;
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
// mSpeedTable[0] = "Leaky Rowboat";
|
||||
// mSpeedTable[1] = "Kayak";
|
||||
// mSpeedTable[2] = "Fishing Trawler";
|
||||
mSpeedTable[0] = "Rowboat";
|
||||
mSpeedTable[1] = "Dinghy";
|
||||
mSpeedTable[2] = "Hovercraft";
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 35, LEFT_SIDE + 185, 50);
|
||||
if ((m_pScoreText = new CText()) != nullptr) {
|
||||
(*m_pScoreText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 20, LEFT_SIDE + 185, 35);
|
||||
if ((m_pSweepsText = new CText()) != nullptr) {
|
||||
(*m_pSweepsText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
m_ScrollSweeps.SetScrollRange(0, nSweepSets - 1, 0);
|
||||
for (i = 0; i < (int)nSweepSets; i++) {
|
||||
if (m_nSweepSettings[i] == (int)m_nSweeps)
|
||||
m_ScrollSweeps.SetScrollPos(i, true);
|
||||
}
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 70, LEFT_SIDE + 115, 88);
|
||||
if ((m_pSpeedText = new CText()) != nullptr) {
|
||||
(*m_pSpeedText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
m_ScrollSpeed.SetScrollRange(MIN_SPEED, MAX_SPEED, 0);
|
||||
m_ScrollSpeed.SetScrollPos(m_nSpeed, true);
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pOKButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pCancelButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pCancelButton).SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pAutoButton = new CCheckButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pAutoButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pAutoButton).SetControl(IDC_AUTOMATIC, this); // tie to the dialog control
|
||||
}
|
||||
((CWnd *)this)->CheckDlgButton(IDC_AUTOMATIC, m_bAutomatic); // Set the Auto option box
|
||||
|
||||
if ((pChangeButton = new CCheckButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pChangeButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pChangeButton).SetControl(IDC_CHANGE, this); // tie to the dialog control
|
||||
}
|
||||
((CWnd *)this)->CheckDlgButton(IDC_CHANGE, m_bChangeAtTwelve); // Set the Auto option box
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
return true; // return true unless you set the focus to a control
|
||||
}
|
||||
|
||||
|
||||
bool COptnDlg::OnEraseBkgnd(CDC *pDC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void COptnDlg::OnDestroy() {
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
bool COptnDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
|
||||
switch (wParam) {
|
||||
|
||||
case IDC_AUTOMATIC:
|
||||
m_bAutomatic = !m_bAutomatic;
|
||||
((CWnd *)this)->CheckDlgButton(IDC_AUTOMATIC, m_bAutomatic);
|
||||
break;
|
||||
|
||||
case IDC_CHANGE:
|
||||
m_bChangeAtTwelve = !m_bChangeAtTwelve;
|
||||
((CWnd *)this)->CheckDlgButton(IDC_CHANGE, m_bChangeAtTwelve);
|
||||
break;
|
||||
|
||||
case IDOK:
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
} // end if
|
||||
|
||||
return true;
|
||||
|
||||
} // end OnCommand
|
||||
|
||||
|
||||
void COptnDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar) {
|
||||
int pMin,
|
||||
pMax;
|
||||
int OldPos = pScrollBar->GetScrollPos();
|
||||
int NewPos = OldPos;
|
||||
|
||||
pScrollBar->GetScrollRange(&pMin, &pMax);
|
||||
|
||||
switch (nSBCode) {
|
||||
case SB_LINERIGHT:
|
||||
NewPos++;
|
||||
break;
|
||||
case SB_PAGERIGHT:
|
||||
NewPos += NUM_BUTTONS;
|
||||
break;
|
||||
case SB_RIGHT:
|
||||
NewPos = pMax;
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
NewPos--;
|
||||
break;
|
||||
case SB_PAGELEFT:
|
||||
NewPos -= NUM_BUTTONS;
|
||||
break;
|
||||
case SB_LEFT:
|
||||
NewPos = pMin;
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
NewPos = nPos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (NewPos < pMin) NewPos = pMin;
|
||||
if (NewPos > pMax) NewPos = pMax;
|
||||
|
||||
if (NewPos != OldPos) { //To prevent "flicker"
|
||||
(*pScrollBar).SetScrollPos(NewPos, true); //...only update when
|
||||
} //...changed
|
||||
|
||||
UpdateScrollbars();
|
||||
|
||||
CDialog::OnHScroll(nSBCode, NewPos, pScrollBar);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* UpdateScrollbars
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Updates data adjusted with scrollbars
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* none
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* CScrollbar pScrollTime, pScrollColumns, pScrollRows
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* int m_nTime, m_nNumParts, m_nColumns, m_nRows
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
void COptnDlg::UpdateScrollbars() {
|
||||
unsigned int OldValue;
|
||||
CDC *pDC;
|
||||
char msg[64];
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
OldValue = m_nSweeps;
|
||||
m_nSweeps = m_nSweepSettings[m_ScrollSweeps.GetScrollPos()];
|
||||
if (OldValue != m_nSweeps) {
|
||||
if (m_nSweeps == MAX_SWEEPS)
|
||||
Common::sprintf_s(msg, "Number of Sweeps: Unlimited");
|
||||
else
|
||||
Common::sprintf_s(msg, "Number of Sweeps: %d", m_nSweeps);
|
||||
(*m_pSweepsText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
OldValue = m_nSpeed;
|
||||
m_nSpeed = m_ScrollSpeed.GetScrollPos();
|
||||
if (OldValue != m_nSpeed) {
|
||||
Common::sprintf_s(msg, "Speed: %s", mSpeedTable[m_nSpeed].c_str());
|
||||
(*m_pSpeedText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
|
||||
void COptnDlg::OnAutomatic() {
|
||||
m_bAutomatic = !m_bAutomatic;
|
||||
((CWnd *)this)->CheckDlgButton(IDC_AUTOMATIC, m_bAutomatic);
|
||||
}
|
||||
|
||||
void COptnDlg::OnChangeAtTwelve() {
|
||||
m_bChangeAtTwelve = !m_bChangeAtTwelve;
|
||||
((CWnd *)this)->CheckDlgButton(IDC_CHANGE, m_bChangeAtTwelve);
|
||||
}
|
||||
|
||||
void COptnDlg::OnOK() {
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
|
||||
void COptnDlg::OnCancel() {
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
}
|
||||
|
||||
void COptnDlg::OnPaint() {
|
||||
CDC *pDC;
|
||||
char msg[64];
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
Common::sprintf_s(msg, "(Effective on New Game)");
|
||||
(*m_pScoreText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
if (m_nSweeps == MAX_SWEEPS)
|
||||
Common::sprintf_s(msg, "Number of Sweeps: Unlimited");
|
||||
else
|
||||
Common::sprintf_s(msg, "Number of Sweeps: %d", m_nSweeps);
|
||||
(*m_pSweepsText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
Common::sprintf_s(msg, "Speed: %s", mSpeedTable[m_nSpeed].c_str());
|
||||
(*m_pSpeedText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
}
|
||||
|
||||
void COptnDlg::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (pAutoButton != nullptr) { // release the button
|
||||
delete pAutoButton;
|
||||
pAutoButton = nullptr;
|
||||
}
|
||||
|
||||
if (pChangeButton != nullptr) { // release the button
|
||||
delete pChangeButton;
|
||||
pChangeButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
} // namespace Beacon
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
86
engines/bagel/hodjnpodj/beacon/optndlg.h
Normal file
86
engines/bagel/hodjnpodj/beacon/optndlg.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BEACON_OPTNDLG_H
|
||||
#define HODJNPODJ_BEACON_OPTNDLG_H
|
||||
|
||||
#include "bagel/hodjnpodj/beacon/resource.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Beacon {
|
||||
|
||||
#define LEFT_SIDE 30
|
||||
#define OPTIONS_COLOR RGB(0, 0, 0) // Color of the stats info CText
|
||||
#define NUM_SPEEDS 3
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg dialog
|
||||
|
||||
class COptnDlg : public CBmpDialog {
|
||||
// Construction
|
||||
public:
|
||||
COptnDlg(CWnd* pParent = nullptr, CPalette *pPalette = nullptr); // standard constructor
|
||||
~COptnDlg(); // destructor
|
||||
void UpdateScrollbars();
|
||||
void ClearDialogImage();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(COptnDlg)
|
||||
enum { IDD = IDD_SUBOPTIONS };
|
||||
CScrollBar m_ScrollSweeps;
|
||||
CScrollBar m_ScrollSpeed;
|
||||
bool m_bAutomatic = false;
|
||||
bool m_bChangeAtTwelve = false;
|
||||
unsigned int m_nSweeps = 0;
|
||||
unsigned int m_nSpeed = 0;
|
||||
unsigned int nSweepSets = 0;
|
||||
CString mSpeedTable [NUM_SPEEDS];
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COptnDlg)
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
virtual bool OnInitDialog() override;
|
||||
afx_msg void OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar);
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
virtual void OnOK() override;
|
||||
virtual void OnCancel() override;
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnAutomatic();
|
||||
afx_msg void OnChangeAtTwelve();
|
||||
afx_msg void OnDestroy();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace Beacon
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
45
engines/bagel/hodjnpodj/beacon/resource.h
Normal file
45
engines/bagel/hodjnpodj/beacon/resource.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BATTLEFISH_USERCFG_H
|
||||
#define HODJNPODJ_BATTLEFISH_USERCFG_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
|
||||
#define IDD_SUBOPTIONS 115
|
||||
|
||||
#define IDB_BEACON_BMP 301
|
||||
|
||||
#define IDC_RULES 1002
|
||||
|
||||
#define IDC_NUMSWEEPS 1021
|
||||
#define IDC_SPEED 1023
|
||||
#define IDC_CHANGE 1024
|
||||
#define IDC_AUTOMATIC 1025
|
||||
|
||||
} // namespace Beacon
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
78
engines/bagel/hodjnpodj/console.cpp
Normal file
78
engines/bagel/hodjnpodj/console.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/console.h"
|
||||
#include "bagel/hodjnpodj/hodjnpodj.h"
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
Console::Console() : GUI::Debugger() {
|
||||
registerCmd("dumpres", WRAP_METHOD(Console, cmdDumpRes));
|
||||
}
|
||||
|
||||
Console::~Console() {
|
||||
}
|
||||
|
||||
bool Console::cmdDumpRes(int argc, const char **argv) {
|
||||
if (argc == 2) {
|
||||
int num = atoi(argv[1]);
|
||||
Common::String name = Common::String::format("#%d", num);
|
||||
HINSTANCE hInst = nullptr;
|
||||
uint dwBytes;
|
||||
HRSRC hRsc;
|
||||
HGLOBAL hGbl;
|
||||
byte *pData;
|
||||
|
||||
hRsc = FindResource(hInst, name.c_str(), RT_BITMAP);
|
||||
if (hRsc != nullptr) {
|
||||
dwBytes = (size_t)SizeofResource(hInst, hRsc);
|
||||
hGbl = LoadResource(hInst, hRsc);
|
||||
if ((dwBytes != 0) && (hGbl != nullptr)) {
|
||||
pData = (byte *)LockResource(hGbl);
|
||||
Common::MemoryReadStream rs(pData, dwBytes);
|
||||
Common::DumpFile df;
|
||||
if (df.open("dump.bin"))
|
||||
df.writeStream(&rs);
|
||||
|
||||
UnlockResource(hGbl);
|
||||
FreeResource(hGbl);
|
||||
|
||||
if (df.isOpen())
|
||||
debugPrintf("Created dump.bin\n");
|
||||
else
|
||||
debugPrintf("Could not create dump.bin\n");
|
||||
} else {
|
||||
debugPrintf("Could not find resource\n");
|
||||
}
|
||||
} else {
|
||||
debugPrintf("Could not find resource\n");
|
||||
}
|
||||
} else {
|
||||
debugPrintf("dumpres [num]\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
43
engines/bagel/hodjnpodj/console.h
Normal file
43
engines/bagel/hodjnpodj/console.h
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CONSOLE_H
|
||||
#define HODJNPODJ_CONSOLE_H
|
||||
|
||||
#include "gui/debugger.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
class Console : public GUI::Debugger {
|
||||
private:
|
||||
bool cmdDumpRes(int argc, const char **argv);
|
||||
|
||||
public:
|
||||
Console();
|
||||
~Console() override;
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
791
engines/bagel/hodjnpodj/crypt/crypt.cpp
Normal file
791
engines/bagel/hodjnpodj/crypt/crypt.cpp
Normal file
@@ -0,0 +1,791 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/hodjnpodj/crypt/globals.h"
|
||||
#include "bagel/hodjnpodj/crypt/crypt.h"
|
||||
#include "bagel/hodjnpodj/hodjnpodj.h"
|
||||
#include "bagel/metaengine.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* CCryptogram
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Initializes members.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* None
|
||||
*
|
||||
****************************************************************/
|
||||
CCryptogram::CCryptogram(CDC *pDC) {
|
||||
m_cRecordGram = new CCryptRecord();
|
||||
m_cPaintGram = new CPaintGram(pDC);
|
||||
m_cStats = new CStats();
|
||||
|
||||
/********************************************************
|
||||
* Solved switch is used to prevent further user updates *
|
||||
* after cryptogram is solved. *
|
||||
********************************************************/
|
||||
bIsGameOver = false; // Initialize solved switch
|
||||
|
||||
BagelMetaEngine::setKeybindingMode(KBMODE_MINIMAL);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* ~Cryptogram
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Destructor
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
CCryptogram::~CCryptogram() {
|
||||
if (m_cStats != nullptr)
|
||||
delete m_cStats;
|
||||
|
||||
if (m_cPaintGram != nullptr)
|
||||
delete m_cPaintGram;
|
||||
|
||||
if (m_cRecordGram != nullptr)
|
||||
delete m_cRecordGram;
|
||||
|
||||
BagelMetaEngine::setKeybindingMode(KBMODE_NORMAL);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* DrawGram
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* [Description of function]
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* [Show arguments]
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* [External data read]
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* [External data modified]
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* [Discuss return value]
|
||||
*
|
||||
****************************************************************/
|
||||
bool CCryptogram::DrawGram(CDC *pDC) {
|
||||
bIsGameOver = false;
|
||||
|
||||
if (m_cRecordGram->GetRecord(m_cStats->ResetGame()) == false) // Attempt to get the record
|
||||
return false;
|
||||
|
||||
m_cPaintGram->ClearGram(pDC);
|
||||
m_cPaintGram->PaintAlphabet(pDC);
|
||||
|
||||
CreateCryptMap(m_cStats->m_nLettersSolved);
|
||||
MarkSolvedLetters(pDC);
|
||||
|
||||
m_cPaintGram->InitGramPosition(m_cRecordGram);
|
||||
m_cPaintGram->PaintGram(pDC, m_chEncryptGram);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCryptogram::DrawSource(CDC *pDC) {
|
||||
m_cPaintGram->HiLiteOff(pDC);
|
||||
m_cPaintGram->PaintGram(pDC, m_cRecordGram->GetSource());
|
||||
}
|
||||
|
||||
void CCryptogram::MarkSolvedLetters(CDC *pDC) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ALPHABET; i++) { // flip thru Crypt Map
|
||||
if (m_nCryptMap[DECRYPT_MAP][i] == i) // Does letter rep itself?
|
||||
m_cPaintGram->RevealOn( // yes - Mark char as solved
|
||||
pDC,
|
||||
m_cPaintGram->IndexToChar(i)
|
||||
);
|
||||
} // end for
|
||||
}
|
||||
|
||||
void CCryptogram::SolveCryptogram(CDC *pDC) {
|
||||
int nReplaceCode;
|
||||
int nAlphaCode;
|
||||
int nGramCode;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ALPHABET; i++) { // flip thru Crypt Map
|
||||
if ((m_nCryptMap[DECRYPT_MAP][i] != i) && // Any chars rep another char?
|
||||
(m_nCryptMap[DECRYPT_MAP][i] != NOT_USED)) {
|
||||
|
||||
nAlphaCode = m_cPaintGram->IndexToChar(i); // Replace this char
|
||||
nGramCode = m_cPaintGram->IndexToChar(m_nCryptMap[DECRYPT_MAP][i]);
|
||||
|
||||
nReplaceCode = UpdateCryptMap(nGramCode, nAlphaCode); // Update internal rep
|
||||
if (nReplaceCode != NOT_USED) { // New char used in gram?
|
||||
m_cPaintGram->ReplaceLetter(pDC, m_cPaintGram->GetCharType(nAlphaCode), // Yes - swap w/temp char
|
||||
m_cPaintGram->SetLimboTypeOn(nReplaceCode)); // ...Temporarily set it's code to limbo
|
||||
|
||||
m_cPaintGram->ReplaceLetter(pDC, nGramCode, m_cPaintGram->GetCharType(nAlphaCode)); // swap old char with new char
|
||||
m_cPaintGram->ReplaceLetter(pDC, m_cPaintGram->SetLimboTypeOn(nReplaceCode), // Turn all limbo types off
|
||||
m_cPaintGram->SetLimboTypeOff(nReplaceCode));
|
||||
} else { // New char was not used in gram...
|
||||
m_cPaintGram->ReplaceLetter(pDC, nGramCode, m_cPaintGram->GetCharType(nAlphaCode)); // ...simply replace old with new.
|
||||
}
|
||||
|
||||
m_cPaintGram->UsedOff(pDC, nGramCode); // Turn used code off on old char since it's not being used anymore
|
||||
m_cPaintGram->UsedOn(pDC, nAlphaCode); // Turn used code on new char now appearing in cryptogram
|
||||
} // end if
|
||||
} // end for
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* HandleUserUpdate
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Processes user interaction with the displayed cryptogram.
|
||||
* Will modify both internal cryptogram representation by calling
|
||||
* appropriate CCryptogram members, and visual crytogram rep by
|
||||
* calling CPaintGram members.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* pDC - used for visual updating
|
||||
* cpointClicked - place where user clicked
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_cPaintGram member
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* modifies m_cPaintGram
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
bool CCryptogram::HandleUserUpdate(CDC *pDC, CPoint cpointClicked) {
|
||||
CSprite *pSprite;
|
||||
int nClickedCode;
|
||||
int nHiLiteCode;
|
||||
int nReplaceCode;
|
||||
int nAlphaCode;
|
||||
int nGramCode;
|
||||
|
||||
/*****************************
|
||||
* Cryptogram already solved? *
|
||||
*****************************/
|
||||
if (bIsGameOver == true) {
|
||||
//MessageBeep(-1); // No - exit
|
||||
return false;
|
||||
}
|
||||
|
||||
pSprite = m_cPaintGram->m_cDisplayLetters->Touched(cpointClicked);
|
||||
|
||||
/********************************
|
||||
* Clicked on letter anywhere? *
|
||||
********************************/
|
||||
if (pSprite == nullptr) {
|
||||
//MessageBeep(-1); // No - exit
|
||||
return false;
|
||||
}
|
||||
|
||||
/********************
|
||||
* Symbol hilited? *
|
||||
********************/
|
||||
nClickedCode = (*pSprite).GetTypeCode();
|
||||
if (m_cPaintGram->IsSymbolChar(nClickedCode) == true) {
|
||||
return false; // Yes - do not hilite symbols
|
||||
}
|
||||
|
||||
/********************
|
||||
* Anything hilited? *
|
||||
********************/
|
||||
if (m_cPaintGram->IsHiLiteOn() == false) {
|
||||
m_cPaintGram->HiLiteOn(pDC, nClickedCode); // No - hilite letter
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* Was the letter clicked same as the letter currenly hilited? *
|
||||
****************************************************************/
|
||||
if (m_cPaintGram->IsHiLiteType(nClickedCode) == true) {
|
||||
m_cPaintGram->HiLiteOff(pDC); // Yes - toggle hilite to off state
|
||||
return false;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Was the area clicked same as the area currenly hilited? *
|
||||
************************************************************/
|
||||
nHiLiteCode = m_cPaintGram->GetHiLiteType(pDC);
|
||||
ASSERT(nHiLiteCode);
|
||||
if (
|
||||
(m_cPaintGram->IsGramType(nClickedCode) &&
|
||||
m_cPaintGram->IsGramType(nHiLiteCode)) ||
|
||||
(m_cPaintGram->IsAlphabetType(nClickedCode) &&
|
||||
m_cPaintGram->IsAlphabetType(nHiLiteCode))
|
||||
) {
|
||||
m_cPaintGram->HiLiteOff(pDC); // Yes - turn hilite off
|
||||
m_cPaintGram->HiLiteOn(pDC, nClickedCode); // ...hilite new char
|
||||
return false; // out of here.
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* User wants to switch letters. *
|
||||
* Need to update internal cryptogram and visual reps. *
|
||||
************************************************************/
|
||||
if (m_cPaintGram->IsAlphabetType(nHiLiteCode) == true) { // Is the hilited char in the alphabet region?
|
||||
nAlphaCode = nHiLiteCode; // Yes - assign it the alpha code
|
||||
nGramCode = nClickedCode;
|
||||
} else {
|
||||
nAlphaCode = nClickedCode; // No - swap around clicked code
|
||||
nGramCode = nHiLiteCode;
|
||||
}
|
||||
|
||||
nReplaceCode = UpdateCryptMap(nGramCode, nAlphaCode); // Update internal rep
|
||||
if (nReplaceCode != NOT_USED) { // New char used in gram?
|
||||
/****************************************************************
|
||||
* These next lines introduces the "LimboType." From the fact *
|
||||
* that the new letter, "nAlphaCode," is already somewhere in *
|
||||
* the displayed cryptogram, two additional letters need *
|
||||
* replacing -- not just the old letter, "nGramCode," with the *
|
||||
* new. The following algorithm was used to resolve this: *
|
||||
* - The new char currently displayed needs to be replaced *
|
||||
* with another temp char, "nReplaced," which is the *
|
||||
* old char + LimboType. *
|
||||
* - Next all old chars are replaced with the new char. Note *
|
||||
* that the "old char + LimboType" will not be replaced with *
|
||||
* the new char. *
|
||||
* - Finally, set back temp char, "old + limbo," with old *
|
||||
* char. *
|
||||
* *
|
||||
* That's what the next three lines do respectively. *
|
||||
****************************************************************/
|
||||
m_cPaintGram->ReplaceLetter(pDC, m_cPaintGram->GetCharType(nAlphaCode), // Yes - swap w/temp char
|
||||
m_cPaintGram->SetLimboTypeOn(nReplaceCode)); // ...Temporarily set it's code to limbo
|
||||
|
||||
m_cPaintGram->ReplaceLetter(pDC, nGramCode, m_cPaintGram->GetCharType(nAlphaCode)); // swap old char with new char
|
||||
m_cPaintGram->ReplaceLetter(pDC, m_cPaintGram->SetLimboTypeOn(nReplaceCode), // Turn all limbo types off
|
||||
m_cPaintGram->SetLimboTypeOff(nReplaceCode));
|
||||
} else { // New char was not used in gram...
|
||||
m_cPaintGram->ReplaceLetter(pDC, nGramCode, m_cPaintGram->GetCharType(nAlphaCode)); // ...simply replace old with new.
|
||||
}
|
||||
|
||||
m_cPaintGram->HiLiteOff(pDC); // Turn hilite off
|
||||
m_cPaintGram->UsedOff(pDC, nGramCode); // Turn used code off on old char since it's not being used anymore
|
||||
m_cPaintGram->UsedOn(pDC, nAlphaCode); // Turn used code on new char now appearing in cryptogram
|
||||
|
||||
return IsSolved();
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* HandleUserUpdate
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Processes user interaction with the displayed cryptogram.
|
||||
* Will modify both internal cryptogram representation by calling
|
||||
* appropriate CCryptogram members, and visual crytogram rep by
|
||||
* calling CPaintGram members.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* pDC - used for visual updating
|
||||
* cpointClicked - place where user clicked
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_cPaintGram member
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* modifies m_cPaintGram
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
bool CCryptogram::HandleUserUpdate(CDC *pDC, unsigned int nChar) {
|
||||
char nNewChar = toupper(nChar);
|
||||
int nHiLiteCode;
|
||||
int nReplaceCode;
|
||||
int nAlphaCode;
|
||||
int nGramCode;
|
||||
|
||||
/*****************************
|
||||
* Cryptogram already solved? *
|
||||
*****************************/
|
||||
if (bIsGameOver == true) {
|
||||
//MessageBeep(-1); // No - exit
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* Is this a valid alphabetical letter? *
|
||||
****************************************/
|
||||
if (Common::isAlpha(nNewChar) == false) {
|
||||
MessageBeep(-1); // No - exit
|
||||
return false;
|
||||
}
|
||||
|
||||
/********************
|
||||
* Anything hilited? *
|
||||
********************/
|
||||
if (m_cPaintGram->IsHiLiteOn() == false) {
|
||||
m_cPaintGram->HiLiteOn(pDC, nNewChar); // Turn hilite on that spec char
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* Hilite in cryptogram region? *
|
||||
*******************************/
|
||||
nHiLiteCode = m_cPaintGram->GetHiLiteType(pDC);
|
||||
ASSERT(nHiLiteCode);
|
||||
if (m_cPaintGram->IsGramType(nHiLiteCode) == false) {
|
||||
MessageBeep(-1); // No - exit
|
||||
return false;
|
||||
}
|
||||
|
||||
/*************************************
|
||||
* Hilite same char as user typed in? *
|
||||
*************************************/
|
||||
if (nHiLiteCode == nNewChar) {
|
||||
m_cPaintGram->HiLiteOff(pDC); // Turn hilite off
|
||||
return false;
|
||||
}
|
||||
|
||||
nAlphaCode = nNewChar;
|
||||
nGramCode = nHiLiteCode;
|
||||
|
||||
/************************************************************
|
||||
* User wants to switch letters. *
|
||||
* Need to update internal cryptogram and visual reps. *
|
||||
************************************************************/
|
||||
|
||||
nReplaceCode = UpdateCryptMap(nGramCode, nAlphaCode); // Update internal rep
|
||||
if (nReplaceCode != NOT_USED) { // New char used in gram?
|
||||
/****************************************************************
|
||||
* These next lines introduces the "LimboType." From the fact *
|
||||
* that the new letter, "nAlphaCode," is already somewhere in *
|
||||
* the displayed cryptogram, two additional letters need *
|
||||
* replacing -- not just the old letter, "nGramCode," with the *
|
||||
* new. The following algorithm was used to resolve this: *
|
||||
* - The new char currently displayed needs to be replaced *
|
||||
* with another temp char, "nReplaced," which is the *
|
||||
* old char + LimboType. *
|
||||
* - Next all old chars are replaced with the new char. Note *
|
||||
* that the "old char + LimboType" will not be replaced with *
|
||||
* the new char. *
|
||||
* - Finally, set back temp char, "old + limbo," with old *
|
||||
* char. *
|
||||
* *
|
||||
* That's what the next three lines do respectively. *
|
||||
****************************************************************/
|
||||
m_cPaintGram->ReplaceLetter(pDC, m_cPaintGram->GetCharType(nAlphaCode), // Yes - swap w/temp char
|
||||
m_cPaintGram->SetLimboTypeOn(nReplaceCode)); // ...Temporarily set it's code to limbo
|
||||
|
||||
m_cPaintGram->ReplaceLetter(pDC, nGramCode, m_cPaintGram->GetCharType(nAlphaCode)); // swap old char with new char
|
||||
m_cPaintGram->ReplaceLetter(pDC, m_cPaintGram->SetLimboTypeOn(nReplaceCode), // Turn all limbo types off
|
||||
m_cPaintGram->SetLimboTypeOff(nReplaceCode));
|
||||
} else { // New char was not used in gram...
|
||||
m_cPaintGram->ReplaceLetter(pDC, nGramCode, m_cPaintGram->GetCharType(nAlphaCode)); // ...simply replace old with new.
|
||||
}
|
||||
|
||||
m_cPaintGram->HiLiteOff(pDC); // Turn hilite off
|
||||
m_cPaintGram->UsedOff(pDC, nGramCode); // Turn used code off on old char since it's not being used anymore
|
||||
m_cPaintGram->UsedOn(pDC, nAlphaCode); // Turn used code on new char now appearing in cryptogram
|
||||
|
||||
return IsSolved();
|
||||
}
|
||||
/*****************************************************************
|
||||
*
|
||||
* Encrypt
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Uses the Crypt Map to encode the phrase, as it originally
|
||||
* appears.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_cRecordGram - to obtain the original phrase.
|
||||
* m_nCryptMap - to encrypt phrase
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* m_chEncrptGram - updated according to structure of
|
||||
* m_nCryptMap.
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
void CCryptogram::Encrypt() {
|
||||
int i;
|
||||
|
||||
/*******************
|
||||
* Reset workbench. *
|
||||
*******************/
|
||||
Common::strcpy_s(m_chEncryptGram, m_cRecordGram->GetGram()); // Acquire copy of original
|
||||
|
||||
/*****************************************
|
||||
* Encrypt entire string using crypt map. *
|
||||
*****************************************/
|
||||
for (i = 0; m_chEncryptGram[i] != 0; i++) {
|
||||
if ((m_cPaintGram->IsAlphaChar(m_chEncryptGram[i]) == true) && // Is this a char?
|
||||
(m_nCryptMap[DECRYPT_MAP][m_cPaintGram->CharToIndex(m_chEncryptGram[i])] != NOT_USED) // and should this char be encrypted?
|
||||
) {
|
||||
m_chEncryptGram[i] = m_cPaintGram->IndexToChar(
|
||||
m_nCryptMap[DECRYPT_MAP][
|
||||
m_cPaintGram->CharToIndex(m_chEncryptGram[i])
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* CreateEncryptMap
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Creates an En-Cryption Map Key by randomally selecting
|
||||
* unique representations for each alphabetical letter.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* nLettersSolved - number of characters not encrypted
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_nCryptMap - Resets En-Cryption Map Key
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* m_nCryptMap - Complete En-Cryption Map Key with exactly
|
||||
* nLettersSolved chars mapped to themselves.
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
void CCryptogram::CreateCryptMap(int nLettersSolved) {
|
||||
int nEncryptCode; // encrypted value
|
||||
int nDecryptCode; // normal/decrypted value
|
||||
bool bIsUsed; // tells if encrypt-decrypt map was used
|
||||
int i, j; // index
|
||||
|
||||
/*******************
|
||||
* Reset workbench. *
|
||||
*******************/
|
||||
Common::strcpy_s(m_chEncryptGram, m_cRecordGram->GetGram()); // Acquire copy of original
|
||||
for (i = 0; i < ALPHABET; i++) { // Reset cryptmap
|
||||
m_nCryptMap[DECRYPT_MAP][i] = NOT_USED;
|
||||
m_nCryptMap[ENCRYPT_MAP][i] = NOT_USED;
|
||||
}
|
||||
|
||||
/****************************************************
|
||||
* Create encryption map based on letters in phrase. *
|
||||
****************************************************/
|
||||
for (i = 0; m_chEncryptGram[i] != 0; i++) {
|
||||
if (m_cPaintGram->IsAlphaChar(m_chEncryptGram[i]) == true) { // Is this a char?
|
||||
|
||||
nDecryptCode = m_cPaintGram->CharToIndex(m_chEncryptGram[i]);
|
||||
bIsUsed = (m_nCryptMap[DECRYPT_MAP][nDecryptCode] != NOT_USED);
|
||||
|
||||
if (bIsUsed == true) // Char already encrypted?
|
||||
continue; // Yes - loop to next char in text
|
||||
|
||||
/******************************
|
||||
* Find an unused encrypt map. *
|
||||
******************************/
|
||||
do {
|
||||
nEncryptCode = brand() % ALPHABET;
|
||||
bIsUsed = (m_nCryptMap[ENCRYPT_MAP][nEncryptCode] != NOT_USED);
|
||||
} while (bIsUsed == true || nEncryptCode == nDecryptCode); // find unused map
|
||||
|
||||
/**************************************
|
||||
* Record new encrypt/decrypt mapping. *
|
||||
**************************************/
|
||||
m_nCryptMap[DECRYPT_MAP][nDecryptCode] = nEncryptCode;
|
||||
m_nCryptMap[ENCRYPT_MAP][nEncryptCode] = nDecryptCode;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Decrypt letters solved given as function arg. *
|
||||
* To keep letters solved random (as opposed to decrypting A, B, and C *
|
||||
* in order) it seemed easier to change the map after it was fully *
|
||||
* encrypted, provided from above. *
|
||||
************************************************************************/
|
||||
for (i = 0; i < nLettersSolved ; i++) {
|
||||
|
||||
for (j = 0; j < ALPHABET; j++) { // Are there any letters left to decrypt?
|
||||
if (
|
||||
m_nCryptMap[DECRYPT_MAP][j] != NOT_USED && // in the quote and
|
||||
m_nCryptMap[DECRYPT_MAP][j] != j // not already solved
|
||||
) {
|
||||
bIsUsed = true; // Yes - so break
|
||||
break;
|
||||
} else
|
||||
bIsUsed = false; // No - not this letter, keep looking
|
||||
}
|
||||
|
||||
if (bIsUsed == false) // Any letters left to decrypt?
|
||||
break; // No - by pass loop.
|
||||
|
||||
do {
|
||||
nDecryptCode = brand() % ALPHABET; // find used char
|
||||
bIsUsed = (
|
||||
m_nCryptMap[DECRYPT_MAP][nDecryptCode] != NOT_USED && // in quote and
|
||||
m_nCryptMap[DECRYPT_MAP][nDecryptCode] != nDecryptCode // not already solved
|
||||
);
|
||||
} while (bIsUsed == false);
|
||||
|
||||
nEncryptCode = m_nCryptMap[DECRYPT_MAP][nDecryptCode]; // gets corres decoder
|
||||
|
||||
/********************************************************************
|
||||
* Need to know if the decrypted letter was used in the encryption *
|
||||
* map before. If it was, then another encryption letter needs to *
|
||||
* be used in it's place. *
|
||||
********************************************************************/
|
||||
bIsUsed = (m_nCryptMap[ENCRYPT_MAP][nDecryptCode] != NOT_USED);
|
||||
if (bIsUsed == true) { // Decrypted letter used before?
|
||||
m_nCryptMap[DECRYPT_MAP][m_nCryptMap[ENCRYPT_MAP][nDecryptCode]] = nEncryptCode; // Yes - Swap around encrypted chars
|
||||
m_nCryptMap[ENCRYPT_MAP][nEncryptCode] = m_nCryptMap[ENCRYPT_MAP][nDecryptCode];
|
||||
} else {
|
||||
m_nCryptMap[ENCRYPT_MAP][nEncryptCode] = NOT_USED; // No - Mark encryption map as unused
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* ENCRYPT_MAP is a reversed mirror of DECRYPT_MAP. I.e. if *
|
||||
* "A points to X" in the DECRYPT_MAP, then "X points to A" in the *
|
||||
* ENCRYPT_MAP. Specific reasons for assigning both sides of map *
|
||||
* to "nDecryptCode" are tricky...8-]. Think about it. *
|
||||
********************************************************************/
|
||||
m_nCryptMap[DECRYPT_MAP][nDecryptCode] = nDecryptCode; // Match Decrypt map
|
||||
m_nCryptMap[ENCRYPT_MAP][nDecryptCode] = nDecryptCode; // ...with Encrypt map
|
||||
}
|
||||
|
||||
Encrypt(); // Create the real thing...update internal rep.
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* UpdateGramChar
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Replaces old char, "nOldType," with new char, "nNewType," in
|
||||
* Crypt Map. Handles specific case when new char appears in
|
||||
* Crypt Map prior to replacement.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* nOldType - type code of old char
|
||||
* nNewType - type code of new char
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_nCryptMap - En-Cryption Map Key
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* m_nCryptMap - nOldType is remapped to nNewType
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* nReplaceCode - value of any additional character that may
|
||||
* need replacing.
|
||||
*
|
||||
****************************************************************/
|
||||
int CCryptogram::UpdateCryptMap(int nOldType, int nNewType) {
|
||||
int nOldIndex; // Crypt Map index equivalent of nOldType
|
||||
int nNewIndex; // index equivalent of nNewType
|
||||
int nEncryptCode; // old type
|
||||
int nDecryptCode; // decryption map corresponding to old type
|
||||
int nReplaceCode; // temporary old type
|
||||
|
||||
nOldIndex = m_cPaintGram->CharToIndex(m_cPaintGram->GetCharType(nOldType));
|
||||
nNewIndex = m_cPaintGram->CharToIndex(m_cPaintGram->GetCharType(nNewType));
|
||||
|
||||
nEncryptCode = nOldIndex;
|
||||
nDecryptCode = m_nCryptMap[ENCRYPT_MAP][nEncryptCode];
|
||||
nReplaceCode = NOT_USED;
|
||||
|
||||
/************************************************************************
|
||||
* Need to know if nNewType letter was used in the cryptogram *
|
||||
* before. This can occur in two different instances: another letter *
|
||||
* was encrypted into nNewType, or when nNewType just appears as a *
|
||||
* straight representation of itself. If either was case, then another *
|
||||
* letter needs to be used in it's place. *
|
||||
************************************************************************/
|
||||
if (m_nCryptMap[ENCRYPT_MAP][nNewIndex] != NOT_USED) { // New type used in encryption ma?
|
||||
m_nCryptMap[DECRYPT_MAP][m_nCryptMap[ENCRYPT_MAP][nNewIndex]] = nEncryptCode; // Swap around encrypted chars
|
||||
m_nCryptMap[ENCRYPT_MAP][nEncryptCode] = m_nCryptMap[ENCRYPT_MAP][nNewIndex];
|
||||
nReplaceCode = m_cPaintGram->IndexToChar(nEncryptCode);
|
||||
} else {
|
||||
m_nCryptMap[ENCRYPT_MAP][nEncryptCode] = NOT_USED;
|
||||
}
|
||||
|
||||
m_nCryptMap[DECRYPT_MAP][nDecryptCode] = nNewIndex; // Match Decrypt map
|
||||
m_nCryptMap[ENCRYPT_MAP][nNewIndex] = nDecryptCode; // ...with Encrypt map
|
||||
|
||||
Encrypt(); // Update internal rep
|
||||
return nReplaceCode; // return temporary value....
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* IsSolved
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Figures out if the cryptogram is solved, based on
|
||||
* state of "m_nCryptMap" -- the En-Cryption Map Key.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* void
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_nCryptMap - En-Cryption Map Key
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* nTotalSolved - number of correctly decrypted letters
|
||||
*
|
||||
****************************************************************/
|
||||
bool CCryptogram::IsSolved() {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ALPHABET; i++) { // flip thru Crypt Map
|
||||
if ((m_nCryptMap[DECRYPT_MAP][i] != i) && // Any chars rep another char?
|
||||
(m_nCryptMap[DECRYPT_MAP][i] != NOT_USED))
|
||||
return false; // Yes - cryptogram not solved
|
||||
}
|
||||
|
||||
bIsGameOver = true; // Mark cryptogram as solved
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* LettersSolved
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Figures out how many letters are properly decrypted, based on
|
||||
* state of "m_nCryptMap" -- the En-Cryption Map Key.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* void
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_nCryptMap - En-Cryption Map Key
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* nTotalSolved - number of correctly decrypted letters
|
||||
*
|
||||
****************************************************************/
|
||||
int CCryptogram::LettersSolved() {
|
||||
int i;
|
||||
int nTotalSolved = 0;
|
||||
|
||||
for (i = 0; i < ALPHABET; i++) { // flip thru Crypt Map
|
||||
if (m_nCryptMap[DECRYPT_MAP][i] == i) // Does letter rep itself?
|
||||
nTotalSolved++; // Yes - it is a solved letter
|
||||
}
|
||||
|
||||
return nTotalSolved;
|
||||
}
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
74
engines/bagel/hodjnpodj/crypt/crypt.h
Normal file
74
engines/bagel/hodjnpodj/crypt/crypt.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_CRYPT_H
|
||||
#define HODJNPODJ_CRYPT_CRYPT_H
|
||||
|
||||
#include "bagel/hodjnpodj/crypt/rec.h"
|
||||
#include "bagel/hodjnpodj/crypt/pnt_gram.h"
|
||||
#include "bagel/hodjnpodj/crypt/stats.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
#define SPLASHSPEC ".\\art\\crypt.BMP" // bitmap file for the splash screen
|
||||
|
||||
#define NOT_USED -1
|
||||
#define MAP 2
|
||||
#define DECRYPT_MAP 0
|
||||
#define ENCRYPT_MAP 1
|
||||
|
||||
class CCryptogram {
|
||||
private:
|
||||
CCryptRecord *m_cRecordGram = nullptr;
|
||||
int m_nCryptMap[MAP][ALPHABET] = {};
|
||||
|
||||
public:
|
||||
CCryptogram(CDC *pDC);
|
||||
~CCryptogram();
|
||||
|
||||
bool DrawGram(CDC *pDC);
|
||||
bool HandleUserUpdate(CDC *pDC, CPoint cpointClicked);
|
||||
bool HandleUserUpdate(CDC *pDC, unsigned int nChar);
|
||||
void Encrypt();
|
||||
void CreateCryptMap(int nLettersSolved);
|
||||
int UpdateCryptMap(int nOldType, int nNewType);
|
||||
bool IsSolved();
|
||||
int LettersSolved();
|
||||
void MarkSolvedLetters(CDC *pDC);
|
||||
void SolveCryptogram(CDC *pDC);
|
||||
void DrawSource(CDC *pDC);
|
||||
|
||||
char m_chEncryptGram[MAX_GRAM_LEN];
|
||||
CPaintGram *m_cPaintGram = nullptr;
|
||||
CStats *m_cStats = nullptr;
|
||||
bool bIsGameOver = false;
|
||||
};
|
||||
|
||||
// Globals!
|
||||
extern CPalette *pGamePalette;
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
51
engines/bagel/hodjnpodj/crypt/globals.h
Normal file
51
engines/bagel/hodjnpodj/crypt/globals.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_GLOBALS_H
|
||||
#define HODJNPODJ_CRYPT_GLOBALS_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
// Main Window positioning constants
|
||||
#define GAME_WIDTH 640
|
||||
#define GAME_HEIGHT 480
|
||||
|
||||
// Cryptogram info
|
||||
#define ALPHABET 26 // chars in English alphabet
|
||||
#define SYMBOLS 45 // chars + 9 symbols + 10 digits
|
||||
#define USED_SYMBOLS 26
|
||||
#define REVEAL_SYMBOLS 26
|
||||
|
||||
// Scroll button
|
||||
#define IDC_SCROLL 800
|
||||
|
||||
#define SCROLL_BUTTON_X 250
|
||||
#define SCROLL_BUTTON_Y 0
|
||||
#define SCROLL_BUTTON_DX 140
|
||||
#define SCROLL_BUTTON_DY 23
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
98
engines/bagel/hodjnpodj/crypt/init.cpp
Normal file
98
engines/bagel/hodjnpodj/crypt/init.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/rules.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/bitmaps.h"
|
||||
#include "bagel/hodjnpodj/crypt/main.h"
|
||||
#include "bagel/hodjnpodj/crypt/optn.h"
|
||||
#include "bagel/hodjnpodj/crypt/globals.h"
|
||||
#include "bagel/hodjnpodj/crypt/resource.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
|
||||
CMainWindow *pMainGameWnd = nullptr; // pointer to the poker's main window
|
||||
CPalette *pTestPalette = nullptr;
|
||||
HCURSOR hGameCursor;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunCrypt
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
HWND FAR PASCAL RunCrypt(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
// if the pointer has garbage in it, the clean it out
|
||||
if (pMainGameWnd != nullptr) {
|
||||
pMainGameWnd = nullptr;
|
||||
}
|
||||
|
||||
// create a my poker window and show it
|
||||
pMainGameWnd = new CMainWindow(hParentWnd, lpGameInfo);
|
||||
pMainGameWnd->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
pMainGameWnd->SplashScreen(); // Force immediate display to minimize repaint delay
|
||||
|
||||
pMainGameWnd->UpdateWindow();
|
||||
pMainGameWnd->SetActiveWindow();
|
||||
|
||||
// return the handle to this window
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMainGameWnd->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMainGameWnd->m_hWnd;
|
||||
}
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
37
engines/bagel/hodjnpodj/crypt/init.h
Normal file
37
engines/bagel/hodjnpodj/crypt/init.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_DLLINIT_H
|
||||
#define HODJNPODJ_CRYPT_DLLINIT_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
extern HWND FAR PASCAL RunCrypt(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
1371
engines/bagel/hodjnpodj/crypt/main.cpp
Normal file
1371
engines/bagel/hodjnpodj/crypt/main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
216
engines/bagel/hodjnpodj/crypt/main.h
Normal file
216
engines/bagel/hodjnpodj/crypt/main.h
Normal file
@@ -0,0 +1,216 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_MAIN_H
|
||||
#define HODJNPODJ_CRYPT_MAIN_H
|
||||
|
||||
#include "bagel/boflib/sound.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/crypt/crypt.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
#define NEW_GAME_LEFT 15
|
||||
#define NEW_GAME_TOP 2
|
||||
#define NEW_GAME_RIGHT 233
|
||||
#define NEW_GAME_BOTTOM 21
|
||||
|
||||
#define PAUSE_TIME 15000 // Pause for 15 seconds -- allows user to read quote
|
||||
|
||||
// Game theme song
|
||||
#define GAME_THEME ".\\sound\\crypt.mid"
|
||||
// Rules files
|
||||
#define RULES_TEXT "CRYPTRUL.TXT"
|
||||
#define RULES_WAV ".\\SOUND\\CRYPT.WAV"
|
||||
|
||||
///////////////////////////////////////////
|
||||
// EASTER EGG AND SOUND HOTSPOT DATA:
|
||||
//
|
||||
#define WAV_TIMEOUT ".\\SOUND\\BUZZER.WAV"
|
||||
#define WAV_WON ".\\SOUND\\SOUNDWON.WAV"
|
||||
#define WAV_URN1 ".\\SOUND\\OUTTHERE.WAV"
|
||||
#define WAV_URN2 ".\\SOUND\\SPOOKMUS.WAV"
|
||||
#define WAV_URN3 ".\\SOUND\\BUTFLIES.WAV"
|
||||
#define WAV_JOKE1 ".\\SOUND\\JOKE1.WAV"
|
||||
#define WAV_JOKE2 ".\\SOUND\\JOKE2.WAV"
|
||||
#define WAV_JOKE3 ".\\SOUND\\JOKE3.WAV"
|
||||
#define WAV_JOKE4 ".\\SOUND\\JOKE4.WAV"
|
||||
#define WAV_JOKE5 ".\\SOUND\\JOKE5.WAV"
|
||||
#define WAV_JOKE6 ".\\SOUND\\JOKE6.WAV"
|
||||
#define WAV_TORCH ".\\SOUND\\FIREENG.WAV"
|
||||
#define WAV_GRYPH ".\\SOUND\\GRYPHON.WAV"
|
||||
#define WAV_STEPS ".\\SOUND\\STAIRS.WAV"
|
||||
#define WAV_HOUR ".\\SOUND\\SANDTIME.WAV"
|
||||
|
||||
#define NUM_SKULL_SOUNDS 6
|
||||
|
||||
// Skull anim offsets
|
||||
#define SKULL_X 21 //15
|
||||
#define SKULL_Y 257 //245
|
||||
#define SKULL_DX 97
|
||||
#define SKULL_DY 135
|
||||
|
||||
// URN1 anim offsets
|
||||
#define URN1_X 98 //95
|
||||
#define URN1_Y 28 //22
|
||||
#define URN1_DX 42 //54
|
||||
#define URN1_DY 133 //48
|
||||
|
||||
// URN2 anim offsets
|
||||
#define URN2_X 204 //186
|
||||
#define URN2_Y 25 //24
|
||||
#define URN2_DX 94 //120
|
||||
#define URN2_DY 104 //106
|
||||
|
||||
// URN3 anim offsets
|
||||
#define URN3_X 361 //357
|
||||
#define URN3_Y 26 //23
|
||||
#define URN3_DX 72 //84
|
||||
#define URN3_DY 103 //108
|
||||
|
||||
// Anim cel count
|
||||
#define NUM_SKULL_CELS 20
|
||||
#define NUM_URN1_CELS 25
|
||||
#define NUM_URN2_CELS 22
|
||||
#define NUM_URN3_CELS 20
|
||||
|
||||
// Anim sleep times in millisecs
|
||||
#define SKULL_SLEEP 100
|
||||
#define JOKE1_SLEEP 130 // funny thing
|
||||
#define JOKE2_SLEEP 130 // pj's part A
|
||||
#define JOKE2B_SLEEP 120 // pj's part B
|
||||
#define JOKE3_SLEEP 120 // audience
|
||||
#define JOKE4_SLEEP 130 // brooklyn
|
||||
#define JOKE5_SLEEP 150 // philly
|
||||
#define JOKE6_SLEEP 40 // sock it to me
|
||||
#define URN1_SLEEP 150
|
||||
#define URN2_SLEEP 200
|
||||
#define URN3_SLEEP 125
|
||||
|
||||
// TORCH audio hotspot offsets
|
||||
|
||||
#define TORCH1_X 45
|
||||
#define TORCH1_Y 25
|
||||
#define TORCH2_X 170
|
||||
#define TORCH2_Y 40
|
||||
#define TORCH3_X 307
|
||||
#define TORCH3_Y 35
|
||||
#define TORCH4_X 450
|
||||
#define TORCH4_Y 40
|
||||
#define TORCH_DX 50
|
||||
#define TORCH_DY 80
|
||||
|
||||
// GRYPH audio hotspot offsets
|
||||
|
||||
#define GRYPH_X 208
|
||||
#define GRYPH_Y 130
|
||||
#define GRYPH_DX 240
|
||||
#define GRYPH_DY 45
|
||||
|
||||
// STEPS audio hotspot offsets
|
||||
|
||||
#define STEPS_X 568
|
||||
#define STEPS_Y 198
|
||||
#define STEPS_DX 42
|
||||
#define STEPS_DY 183
|
||||
|
||||
// HOUR audio hotspot offsets
|
||||
#define HOUR_X 473
|
||||
#define HOUR_Y 123
|
||||
#define HOUR_DX 40
|
||||
#define HOUR_DY 61
|
||||
|
||||
#define MAX_HOURS 10
|
||||
|
||||
|
||||
class CMainWindow : public CFrameWnd {
|
||||
public:
|
||||
CMainWindow(HWND, LPGAMESTRUCT);
|
||||
~CMainWindow();
|
||||
|
||||
void SplashScreen();
|
||||
static void FlushInputEvents();
|
||||
void DisplayStats(CDC*);
|
||||
void RefreshStats();
|
||||
void GameWin();
|
||||
void GameLose();
|
||||
|
||||
private:
|
||||
HWND m_hCallAppWnd = nullptr;
|
||||
LPGAMESTRUCT m_lpGameStruct = nullptr;
|
||||
CRect MainRect; // screen area spanned by the game window
|
||||
CRect m_cNewGame; // area spanned by new game rect
|
||||
CBmpButton *m_pScrollButton = nullptr; // scroll button
|
||||
bool m_bIgnoreScrollClick = false; // scroll button
|
||||
bool m_bIsFirstTimeHack = false;
|
||||
CSprite *m_pHourGlass = nullptr;
|
||||
|
||||
private:
|
||||
void OnSoundNotify(CSound *pSound);
|
||||
|
||||
protected:
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
|
||||
//{{AFX_MSG( CMainWindow )
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnLButtonDown(unsigned int, CPoint);
|
||||
afx_msg void OnLButtonUp(unsigned int, CPoint);
|
||||
afx_msg void OnLButtonDblClk(unsigned int, CPoint);
|
||||
afx_msg void OnMButtonDown(unsigned int, CPoint);
|
||||
afx_msg void OnMButtonUp(unsigned int, CPoint);
|
||||
afx_msg void OnMButtonDblClk(unsigned int, CPoint);
|
||||
afx_msg void OnRButtonDown(unsigned int, CPoint);
|
||||
afx_msg void OnRButtonUp(unsigned int, CPoint);
|
||||
afx_msg void OnRButtonDblClk(unsigned int, CPoint);
|
||||
afx_msg void OnMouseMove(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnSysChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnSysKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnTimer(uintptr nIDEvent);
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CTheApp:
|
||||
// See game.cpp for the code to the InitInstance member function.
|
||||
//
|
||||
class CTheApp : public CWinApp {
|
||||
public:
|
||||
bool InitInstance();
|
||||
int ExitInstance();
|
||||
};
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
362
engines/bagel/hodjnpodj/crypt/optn.cpp
Normal file
362
engines/bagel/hodjnpodj/crypt/optn.cpp
Normal file
@@ -0,0 +1,362 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/crypt/optn.h"
|
||||
#include "bagel/hodjnpodj/crypt/resource.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptn dialog
|
||||
|
||||
|
||||
COptn::COptn(
|
||||
CWnd* pParent /*=nullptr*/,
|
||||
CPalette *pPalette /*=nullptr*/,
|
||||
int nLttrsSlvd /*LSLVD_DEFAULT*/,
|
||||
int nTime /*TIME_DEFAULT*/
|
||||
)
|
||||
: CBmpDialog(pParent, pPalette, IDD_USER_OPTIONS, ".\\ART\\SSCROLL.BMP")
|
||||
|
||||
{
|
||||
//{{AFX_DATA_INIT(COptn)
|
||||
m_nTimeIndex[0] = 15;
|
||||
m_nTimeIndex[1] = 20;
|
||||
m_nTimeIndex[2] = 25;
|
||||
m_nTimeIndex[3] = 30;
|
||||
m_nTimeIndex[4] = 35;
|
||||
m_nTimeIndex[5] = 40;
|
||||
m_nTimeIndex[6] = 45;
|
||||
m_nTimeIndex[7] = 50;
|
||||
m_nTimeIndex[8] = 60;
|
||||
m_nTimeIndex[9] = 70;
|
||||
m_nTimeIndex[10] = 80;
|
||||
m_nTimeIndex[11] = 90;
|
||||
m_nTimeIndex[12] = 120;
|
||||
m_nTimeIndex[13] = 150;
|
||||
m_nTimeIndex[14] = 180;
|
||||
m_nTimeIndex[15] = 240;
|
||||
m_nTimeIndex[16] = 300;
|
||||
m_nTimeIndex[17] = 589;
|
||||
m_nTimeIndex[18] = 601;
|
||||
|
||||
pGamePalette = pPalette;
|
||||
|
||||
m_nTime = TimeToIndex(nTime);
|
||||
m_nLttrsSlvd = nLttrsSlvd;
|
||||
|
||||
m_pLttrsSlvd = nullptr;
|
||||
m_pTime = nullptr;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
COptn::~COptn() {
|
||||
if (m_pLttrsSlvd != nullptr) {
|
||||
delete m_pLttrsSlvd;
|
||||
m_pLttrsSlvd = nullptr;
|
||||
}
|
||||
|
||||
if (m_pTime != nullptr) {
|
||||
delete m_pTime;
|
||||
m_pLttrsSlvd = nullptr;
|
||||
}
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
int COptn::TimeToIndex(int nTime) {
|
||||
int nLow;
|
||||
|
||||
/***********************************
|
||||
* Seaches ordered array in n time. *
|
||||
***********************************/
|
||||
for (nLow = 0; nLow < TIME_TABLE ; nLow++) {
|
||||
if (m_nTimeIndex[nLow] == nTime)
|
||||
return (int)nLow;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void COptn::DoDataExchange(CDataExchange* pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(COptn)
|
||||
DDX_Control(pDX, IDC_LTTRSSLVD, m_LttrsSlvd);
|
||||
DDX_Control(pDX, IDC_TIME, m_Time);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(COptn, CDialog)
|
||||
//{{AFX_MSG_MAP(COptn)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_DESTROY()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptn message handlers
|
||||
|
||||
bool COptn::OnInitDialog() {
|
||||
CRect statsRect; // game stats displays
|
||||
int nStat_col_offset; // game stats placement
|
||||
int nStat_row_offset;
|
||||
int nStatWidth, nStatHeight;
|
||||
bool bAssertCheck;
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
m_chTime[0] = "15 Seconds";
|
||||
m_chTime[1] = "20 Seconds";
|
||||
m_chTime[2] = "25 Seconds";
|
||||
m_chTime[3] = "30 Seconds";
|
||||
m_chTime[4] = "35 Seconds";
|
||||
m_chTime[5] = "40 Seconds";
|
||||
m_chTime[6] = "45 Seconds";
|
||||
m_chTime[7] = "50 Seconds";
|
||||
m_chTime[8] = "60 Seconds";
|
||||
m_chTime[9] = "70 Seconds";
|
||||
m_chTime[10] = "80 Seconds";
|
||||
m_chTime[11] = "90 Seconds";
|
||||
m_chTime[12] = "120 Seconds";
|
||||
m_chTime[13] = "150 Seconds";
|
||||
m_chTime[14] = "3 Minutes";
|
||||
m_chTime[15] = "4 Minutes";
|
||||
m_chTime[16] = "5 Minutes";
|
||||
m_chTime[17] = "10 Minutes";
|
||||
m_chTime[18] = "None";
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
nStat_col_offset = STAT_BOX_COL; // setup the Letters Solved
|
||||
nStat_row_offset = STAT_BOX_ROW; // stat display box
|
||||
nStatWidth = STAT_BOX_WIDTH;
|
||||
nStatHeight = STAT_BOX_HEIGHT;
|
||||
statsRect.SetRect(
|
||||
nStat_col_offset,
|
||||
nStat_row_offset,
|
||||
nStat_col_offset + nStatWidth,
|
||||
nStat_row_offset + nStatHeight
|
||||
);
|
||||
|
||||
if ((m_pLttrsSlvd = new CText()) != nullptr) {
|
||||
bAssertCheck = (*m_pLttrsSlvd).SetupText(pDC, pGamePalette, &statsRect, JUSTIFY_LEFT);
|
||||
ASSERT(bAssertCheck); // initialize the text objext
|
||||
}
|
||||
m_LttrsSlvd.SetScrollRange(MIN_LTTRSSLVD, MAX_LTTRSSLVD, false); // setup Letters Solved defaults
|
||||
m_LttrsSlvd.SetScrollPos(m_nLttrsSlvd, true);
|
||||
|
||||
nStat_row_offset += BOX_ROW_OFFSET; // Time stat display box
|
||||
statsRect.SetRect(
|
||||
nStat_col_offset,
|
||||
nStat_row_offset,
|
||||
nStat_col_offset + nStatWidth,
|
||||
nStat_row_offset + nStatHeight
|
||||
);
|
||||
|
||||
if ((m_pTime = new CText()) != nullptr) {
|
||||
bAssertCheck = (*m_pTime).SetupText(pDC, pGamePalette, &statsRect, JUSTIFY_LEFT);
|
||||
ASSERT(bAssertCheck); // initialize the text objext
|
||||
}
|
||||
|
||||
m_Time.SetScrollRange(MIN_INDEX_TIME, MAX_INDEX_TIME, false); // Time scroll bar defaults
|
||||
m_Time.SetScrollPos(m_nTime, true);
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pOKButton).SetPalette(pGamePalette); // set the palette to use
|
||||
(*pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pCancelButton).SetPalette(pGamePalette); // set the palette to use
|
||||
(*pCancelButton).SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
return true; // return true unless you set the focus to a control
|
||||
}
|
||||
|
||||
void COptn::OnDestroy() {
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
void COptn::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar) {
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
CDC *pDC;
|
||||
bool bAssertCheck;
|
||||
char msg[64];
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_LTTRSSLVD) {
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_LINERIGHT:
|
||||
m_nLttrsSlvd++;
|
||||
break;
|
||||
|
||||
case SB_PAGERIGHT:
|
||||
m_nLttrsSlvd += (int) MAX_LTTRSSLVD / 5; // magic # 5 = five divisions
|
||||
break;
|
||||
|
||||
case SB_RIGHT:
|
||||
m_nLttrsSlvd = MAX_LTTRSSLVD;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
m_nLttrsSlvd--;
|
||||
break;
|
||||
|
||||
case SB_PAGELEFT:
|
||||
m_nLttrsSlvd -= (int) MAX_LTTRSSLVD / 5; // magic # 5 = five divisions
|
||||
break;
|
||||
|
||||
case SB_LEFT:
|
||||
m_nLttrsSlvd = MIN_LTTRSSLVD;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
m_nLttrsSlvd = (int) nPos;
|
||||
break;
|
||||
|
||||
} // end switch
|
||||
|
||||
if (m_nLttrsSlvd < MIN_LTTRSSLVD)
|
||||
m_nLttrsSlvd = MIN_LTTRSSLVD;
|
||||
if (m_nLttrsSlvd > MAX_LTTRSSLVD)
|
||||
m_nLttrsSlvd = MAX_LTTRSSLVD;
|
||||
|
||||
Common::sprintf_s(msg, "Letters Solved: %d", m_nLttrsSlvd);
|
||||
bAssertCheck = (*m_pLttrsSlvd).DisplayString(pDC, msg, FONT_SIZE, FW_BOLD, OPTIONS_COLOR);
|
||||
ASSERT(bAssertCheck);
|
||||
pScrollBar->SetScrollPos(m_nLttrsSlvd, true);
|
||||
|
||||
} else if (pScrollBar->GetDlgCtrlID() == IDC_TIME) {
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_LINERIGHT:
|
||||
m_nTime++;
|
||||
break;
|
||||
case SB_PAGERIGHT:
|
||||
m_nTime += MAX_INDEX_TIME / 5; // want 5 pagerights end to end
|
||||
break;
|
||||
case SB_RIGHT:
|
||||
m_nTime = MAX_INDEX_TIME;
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
m_nTime--;
|
||||
break;
|
||||
case SB_PAGELEFT:
|
||||
m_nTime -= MAX_INDEX_TIME / 5; // want 5 pagerights end to end
|
||||
break;
|
||||
case SB_LEFT:
|
||||
m_nTime = 0;
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
m_nTime = (int) nPos;
|
||||
break;
|
||||
} // end switch
|
||||
|
||||
if (m_nTime < MIN_INDEX_TIME)
|
||||
m_nTime = MIN_INDEX_TIME;
|
||||
if (m_nTime > MAX_INDEX_TIME)
|
||||
m_nTime = MAX_INDEX_TIME;
|
||||
|
||||
Common::sprintf_s(msg, "Time Limit: %s", m_chTime[m_nTime].c_str());
|
||||
|
||||
bAssertCheck = (*m_pTime).DisplayString(pDC, msg, FONT_SIZE, FW_BOLD, OPTIONS_COLOR);
|
||||
ASSERT(bAssertCheck); // paint the text
|
||||
|
||||
pScrollBar->SetScrollPos(m_nTime, true);
|
||||
} // end if
|
||||
|
||||
ReleaseDC(pDC);
|
||||
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
|
||||
}
|
||||
|
||||
|
||||
void COptn::OnPaint() {
|
||||
CDC *pDC;
|
||||
bool bAssertCheck;
|
||||
char msg[64];
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
// Do not call CDialog::OnPaint() for painting messages
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
Common::sprintf_s(msg, "Letters Solved: %d", m_nLttrsSlvd); // Display Letters Solved stats
|
||||
bAssertCheck = (*m_pLttrsSlvd).DisplayString(pDC, msg, FONT_SIZE, FW_BOLD, OPTIONS_COLOR);
|
||||
ASSERT(bAssertCheck);
|
||||
|
||||
Common::sprintf_s(msg, "Time: %s", m_chTime[m_nTime].c_str()); // Display Time stats
|
||||
bAssertCheck = (*m_pTime).DisplayString(pDC, msg, FONT_SIZE, FW_BOLD, OPTIONS_COLOR);
|
||||
ASSERT(bAssertCheck);
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
bool COptn::OnEraseBkgnd(CDC *pDC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void COptn::OnOK() {
|
||||
m_nTime = m_nTimeIndex[m_nTime];
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
// CDialog::OnOK();
|
||||
}
|
||||
|
||||
void COptn::OnCancel() {
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
}
|
||||
|
||||
void COptn::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
96
engines/bagel/hodjnpodj/crypt/optn.h
Normal file
96
engines/bagel/hodjnpodj/crypt/optn.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_OPTN_H
|
||||
#define HODJNPODJ_CRYPT_OPTN_H
|
||||
|
||||
#include "bagel/hodjnpodj/crypt/resource.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
#define MIN_LTTRSSLVD 0 // Preferences
|
||||
#define MAX_LTTRSSLVD 15
|
||||
|
||||
#define TIME_TABLE 19
|
||||
#define MIN_INDEX_TIME 0
|
||||
#define MAX_INDEX_TIME 18
|
||||
|
||||
#define OPTIONS_COLOR RGB(0, 0, 0) // Color of the stats info CText
|
||||
#define FONT_SIZE 16
|
||||
|
||||
#define STAT_BOX_COL 20
|
||||
#define STAT_BOX_ROW 20
|
||||
#define STAT_BOX_WIDTH 200
|
||||
#define STAT_BOX_HEIGHT 20
|
||||
|
||||
#define BOX_ROW_OFFSET 48
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptn dialog
|
||||
|
||||
class COptn : public CBmpDialog {
|
||||
private:
|
||||
CString m_chTime[TIME_TABLE];
|
||||
int m_nTimeIndex[TIME_TABLE] = {};
|
||||
CText *m_pLttrsSlvd = nullptr, *m_pTime = nullptr;
|
||||
CPalette *pGamePalette = nullptr;
|
||||
|
||||
int TimeToIndex(int nTime);
|
||||
|
||||
public:
|
||||
COptn(CWnd* pParent = nullptr, CPalette *pPalette = nullptr, int nLttrsSolvd = false, int nTime = false); // standard constructor
|
||||
~COptn();
|
||||
void ClearDialogImage();
|
||||
|
||||
int m_nLttrsSlvd = 0, m_nTime = 0;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(COptn)
|
||||
enum { IDD = IDD_USER_OPTIONS };
|
||||
CScrollBar m_LttrsSlvd;
|
||||
CScrollBar m_Time;
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COptn)
|
||||
virtual bool OnInitDialog() override;
|
||||
afx_msg void OnPaint();
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
afx_msg void OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar);
|
||||
virtual void OnOK() override;
|
||||
virtual void OnCancel() override;
|
||||
afx_msg void OnDestroy();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
1313
engines/bagel/hodjnpodj/crypt/pnt_gram.cpp
Normal file
1313
engines/bagel/hodjnpodj/crypt/pnt_gram.cpp
Normal file
File diff suppressed because it is too large
Load Diff
171
engines/bagel/hodjnpodj/crypt/pnt_gram.h
Normal file
171
engines/bagel/hodjnpodj/crypt/pnt_gram.h
Normal file
@@ -0,0 +1,171 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_PNT_GRAM_H
|
||||
#define HODJNPODJ_CRYPT_PNT_GRAM_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/hodjnpodj/crypt/globals.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
#define A 65 // ascii value of 'A'
|
||||
#define Z 90 // ascii value of 'Z'
|
||||
#define ALPHABET_BASE 0 // first index to char 'A' of bitmap array
|
||||
#define ASCII_OFFSET 65 // ascii value of 'A'
|
||||
|
||||
//#define ALPHA_RESOURCE_ID 100 // corresp to crypt.rc alphabet id's
|
||||
//#define USED_RESOURCE_ID 200 // corresp to crypt.rc alphabet id's
|
||||
#define ALPHA_ROW 0
|
||||
#define USED_ROW 1
|
||||
#define REVEAL_ROW 2
|
||||
#define ALPHA_RESOURCE_ID 100 // corresp to crypt.rc celtest.bmp id
|
||||
#define HILITE_RESOURCE_ID 300 // corresp to crypt.rc alphabet id's
|
||||
|
||||
#define STANDARD_SPACE_LENGTH 10 // lenth of ' ' space char
|
||||
#define STANDARD_CHAR_WIDTH 11 // width of larges char art bitmap
|
||||
#define STANDARD_CHAR_HEIGHT 9 // height of typical char art bitmap
|
||||
#define PUNCTUATION 9 // Number of punctuation symbols of non-standard width
|
||||
|
||||
#define ALPHA_TOP_COL 185 // alphabet pos coord
|
||||
#define ALPHA_TOP_ROW 225
|
||||
#define ALPHA_BOT_COL 472
|
||||
#define ALPHA_BOT_ROW 237
|
||||
|
||||
#define GRAM_TOP_COL 143 // cryptogram pos coord
|
||||
#define GRAM_TOP_ROW 253
|
||||
#define GRAM_BOT_COL 505
|
||||
#define GRAM_BOT_ROW 462
|
||||
|
||||
#define GRAM_LINE_SPACING 2 // space betw each line
|
||||
#define GRAM_LETTER_SPACING 0 // betw each letter
|
||||
#define GRAM_LEFT_MARGIN 15 // pixels indention
|
||||
#define GRAM_RIGHT_MARGIN 0
|
||||
|
||||
#define CHAR_TYPE 0x00FF // selects character
|
||||
#define GRAM_TYPE 0x0000 // part of cryptogram screen section
|
||||
#define ALPHA_TYPE 0x0100 // alphabet section
|
||||
#define HILITE_TYPE 0x0200 // high-light section
|
||||
#define USED_TYPE 0x0400 // indicates alphabet letter was used
|
||||
#define LIMBO_TYPE 0x0800 // indicates char is in purgatory
|
||||
#define REVEAL_TYPE 0x1000 // indicates an originally revealed letter
|
||||
|
||||
class CCryptRecord;
|
||||
|
||||
class CPaintGram {
|
||||
private: // functions
|
||||
inline int SetHiLiteTypeOn(int nTypeCode) {
|
||||
return nTypeCode | HILITE_TYPE;
|
||||
}
|
||||
inline int SetHiLiteTypeOff(int nTypeCode) {
|
||||
return nTypeCode & ~HILITE_TYPE;
|
||||
}
|
||||
inline int SetAlphaType(int nTypeCode) {
|
||||
return nTypeCode | ALPHA_TYPE;
|
||||
}
|
||||
inline int SetGramType(int nTypeCode) {
|
||||
return nTypeCode | GRAM_TYPE;
|
||||
}
|
||||
inline int SetUsedTypeOn(int nTypeCode) {
|
||||
return nTypeCode | USED_TYPE;
|
||||
}
|
||||
inline int SetUsedTypeOff(int nTypeCode) {
|
||||
return nTypeCode & ~USED_TYPE;
|
||||
}
|
||||
inline int SetRevealTypeOn(int nTypeCode) {
|
||||
return nTypeCode | REVEAL_TYPE;
|
||||
}
|
||||
inline int SetRevealTypeOff(int nTypeCode) {
|
||||
return nTypeCode & ~REVEAL_TYPE;
|
||||
}
|
||||
|
||||
private: // vars
|
||||
CSprite *m_cAlphabet[SYMBOLS] = {}; // Crypt construct objects
|
||||
CSprite *m_cUsedAlphabet[USED_SYMBOLS] = {};
|
||||
CSprite *m_cRevealAlphabet[REVEAL_SYMBOLS] = {};
|
||||
CSprite *m_cHiLite = nullptr;
|
||||
|
||||
CSize m_cPos;
|
||||
|
||||
CRect m_cGramRegion; // Cryptogram formatting params
|
||||
CRect m_cAlphaRegion;
|
||||
const int m_nGramLineSpacing;
|
||||
const int m_nGramLetterSpacing;
|
||||
const int m_nGramLeftMargin;
|
||||
const int m_nGramRightMargin;
|
||||
const int m_nStandardSpaceLength;
|
||||
const int m_nStandardCharHeight;
|
||||
const int m_nStandardCharWidth;
|
||||
|
||||
public:
|
||||
CPaintGram(CDC *pDC);
|
||||
~CPaintGram();
|
||||
|
||||
void InitGramPosition(CCryptRecord *pRec);
|
||||
int CenterGramVert(CCryptRecord *pRec);
|
||||
void PaintAlphabet(CDC *pDC);
|
||||
void PaintGram(CDC *pDC, const char *lpszCryptedGram);
|
||||
void PaintLine(CDC *pDC, const char *lpszCryptedGram, CSize cPos, int i);
|
||||
void ReplaceLetter(CDC *pDC, int nOldType, int nNewType);
|
||||
bool IsHiLiteOn();
|
||||
int GetHiLiteType(CDC *pDC);
|
||||
void HiLiteOff(CDC *pDC);
|
||||
void HiLiteOn(CDC *pDC, int nTypeCode);
|
||||
void UsedOff(CDC *pDC, int nTypeCode);
|
||||
void UsedOn(CDC *pDC, int nTypeCode);
|
||||
void RevealOn(CDC *pDC, int nTypeCode);
|
||||
void ClearGram(CDC *pDC);
|
||||
|
||||
bool IsHiLiteType(int nTypeCode);
|
||||
bool IsAlphabetType(int nTypeCode);
|
||||
bool IsGramType(int nTypeCode);
|
||||
bool IsUsedType(int nTypeCode);
|
||||
bool IsRevealType(int nTypeCode);
|
||||
bool IsAlphaChar(char chChar);
|
||||
bool IsSymbolChar(char chChar);
|
||||
|
||||
|
||||
char IndexToSymb(int nIndex);
|
||||
int SymbToIndex(char chChar);
|
||||
char IndexToChar(int nIndex);
|
||||
int CharToIndex(char chChar);
|
||||
|
||||
inline char GetCharType(int nTypeCode) {
|
||||
return (char)(nTypeCode & CHAR_TYPE);
|
||||
}
|
||||
inline int SetLimboTypeOn(int nTypeCode) {
|
||||
return nTypeCode | LIMBO_TYPE;
|
||||
}
|
||||
inline int SetLimboTypeOff(int nTypeCode) {
|
||||
return nTypeCode & ~LIMBO_TYPE;
|
||||
}
|
||||
|
||||
CSprite *m_cDisplayLetters = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
82
engines/bagel/hodjnpodj/crypt/rec.cpp
Normal file
82
engines/bagel/hodjnpodj/crypt/rec.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/lzss.h"
|
||||
#include "bagel/hodjnpodj/crypt/rec.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
bool CCryptRecord::GetRecord(int nID) {
|
||||
Common::SeekableReadStream *cryptFile;
|
||||
char chBuf;
|
||||
int i;
|
||||
|
||||
if ((cryptFile = makeLzssStream(CRYPT_TXT_FILE)) == nullptr)
|
||||
return false;
|
||||
|
||||
cryptFile->seek(nID * RECORD_LEN + 1);
|
||||
|
||||
for (i = 0; ; i++) { // Grab cryptogram
|
||||
if (i >= MAX_GRAM_LEN) {
|
||||
delete cryptFile;
|
||||
return false;
|
||||
}
|
||||
|
||||
chBuf = (char)cryptFile->readByte();
|
||||
if (chBuf == '\\') {
|
||||
chBuf = (char)cryptFile->readByte();
|
||||
} else if (chBuf == '\"') {
|
||||
m_lpszGram[i] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
m_lpszGram[i] = toupper(chBuf);
|
||||
}
|
||||
|
||||
// Advance past dilimiting comma and initial quote mark
|
||||
cryptFile->skip(2);
|
||||
|
||||
for (i = 0; ; i++) {
|
||||
// Grab source
|
||||
if (i >= MAX_SOURCE_LEN)
|
||||
return false;
|
||||
|
||||
chBuf = (char)cryptFile->readByte();
|
||||
if (chBuf == '\\') {
|
||||
chBuf = (char)cryptFile->readByte();
|
||||
} else if (chBuf == '\"') {
|
||||
m_lpszSource[i] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
m_lpszSource[i] = toupper(chBuf);
|
||||
}
|
||||
|
||||
delete cryptFile;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
64
engines/bagel/hodjnpodj/crypt/rec.h
Normal file
64
engines/bagel/hodjnpodj/crypt/rec.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_REC_H
|
||||
#define HODJNPODJ_CRYPT_REC_H
|
||||
|
||||
#include "common/file.h"
|
||||
//#include <lzexpand.h>
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
#define CRYPT_TXT_FILE "Crypt.lz"
|
||||
#define CRYPT_RECS (g_engine->isDemo() ? 8 : 200)
|
||||
|
||||
#define MAX_GRAM_LEN 512
|
||||
#define MAX_SOURCE_LEN 128
|
||||
#define RECORD_LEN 392
|
||||
|
||||
|
||||
class CCryptRecord {
|
||||
private:
|
||||
int m_nID = 0;
|
||||
char m_lpszGram[MAX_GRAM_LEN] = { 0 };
|
||||
char m_lpszSource[MAX_SOURCE_LEN] = { 0 };
|
||||
|
||||
public:
|
||||
bool GetRecord(int nID);
|
||||
|
||||
int GetID() const {
|
||||
return m_nID;
|
||||
};
|
||||
const char *GetGram() const {
|
||||
return m_lpszGram;
|
||||
};
|
||||
const char *GetSource() const {
|
||||
return m_lpszSource;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
42
engines/bagel/hodjnpodj/crypt/resource.h
Normal file
42
engines/bagel/hodjnpodj/crypt/resource.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_RESOURCE_H
|
||||
#define HODJNPODJ_CRYPT_RESOURCE_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// App Studio generated include file.
|
||||
// Used by CRYPT.RC
|
||||
//
|
||||
#define IDI_ICON 143
|
||||
#define IDD_USER_OPTIONS 865
|
||||
#define IDC_LTTRSSLVD 870
|
||||
#define IDC_TIME 875
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
132
engines/bagel/hodjnpodj/crypt/stats.cpp
Normal file
132
engines/bagel/hodjnpodj/crypt/stats.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/crypt/globals.h"
|
||||
#include "bagel/hodjnpodj/crypt/stats.h"
|
||||
#include "bagel/hodjnpodj/hodjnpodj.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
CStats::CStats() {
|
||||
m_pTime = nullptr;
|
||||
m_pScore = nullptr;
|
||||
|
||||
m_nLettersSolved = GetPrivateProfileInt(
|
||||
INI_SECTION,
|
||||
INI_LETTERSSOLVED,
|
||||
LSLVD_DEFAULT,
|
||||
INI_FNAME
|
||||
);
|
||||
|
||||
if (m_nLettersSolved < MIN_LSLVD || m_nLettersSolved > MAX_LSLVD)
|
||||
m_nLettersSolved = LSLVD_DEFAULT;
|
||||
|
||||
m_nScore = 0;
|
||||
|
||||
m_nTime = GetPrivateProfileInt(
|
||||
INI_SECTION,
|
||||
INI_TIME,
|
||||
TIME_DEFAULT,
|
||||
INI_FNAME
|
||||
);
|
||||
|
||||
|
||||
if (m_nTime < MIN_TIME || m_nTime > MAX_TIME)
|
||||
m_nTime = TIME_DEFAULT;
|
||||
|
||||
m_nCountDown = m_nTime;
|
||||
|
||||
m_nIsUsedGram = GetPrivateProfileInt(
|
||||
INI_SECTION,
|
||||
INI_REC,
|
||||
REC_DEFAULT,
|
||||
INI_FNAME
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
CStats::~CStats() {
|
||||
if (m_pScore != nullptr) {
|
||||
delete m_pScore;
|
||||
m_pScore = nullptr;
|
||||
}
|
||||
|
||||
if (m_pTime != nullptr) {
|
||||
delete m_pTime;
|
||||
m_pTime = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CStats::ResetGame() {
|
||||
//char chResetUsedGram;
|
||||
//char tmpBuf[5];
|
||||
int nID;
|
||||
//int i;
|
||||
|
||||
/*************************
|
||||
* Reset crytogram stats. *
|
||||
*************************/
|
||||
m_nCountDown = m_nTime;
|
||||
m_nScore = 0;
|
||||
|
||||
do { // Get random unused cryptogram
|
||||
nID = brand() % CRYPT_RECS;
|
||||
} while (m_nIsUsedGram == nID);
|
||||
|
||||
m_nIsUsedGram = nID; // Mark as used
|
||||
|
||||
WritePrivateProfileString(
|
||||
INI_SECTION,
|
||||
INI_REC,
|
||||
Common::String::format("%d", m_nIsUsedGram).c_str(),
|
||||
INI_FNAME
|
||||
); // Save used list back
|
||||
|
||||
return nID;
|
||||
}
|
||||
|
||||
|
||||
void CStats::SaveStats(int nLttrsSlvd, int nTime) {
|
||||
m_nLettersSolved = nLttrsSlvd;
|
||||
m_nTime = nTime;
|
||||
|
||||
WritePrivateProfileString(
|
||||
INI_SECTION,
|
||||
INI_LETTERSSOLVED,
|
||||
Common::String::format("%d", m_nLettersSolved).c_str(),
|
||||
INI_FNAME
|
||||
);
|
||||
|
||||
WritePrivateProfileString(
|
||||
INI_SECTION,
|
||||
INI_TIME,
|
||||
Common::String::format("%d", m_nTime).c_str(),
|
||||
INI_FNAME
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
91
engines/bagel/hodjnpodj/crypt/stats.h
Normal file
91
engines/bagel/hodjnpodj/crypt/stats.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_CRYPT_STATS_H
|
||||
#define HODJNPODJ_CRYPT_STATS_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/crypt/rec.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Crypt {
|
||||
|
||||
#define DECIMAL_BASE 10 // used in atoi() c function
|
||||
|
||||
#define TIME_LEFT_COL 44 // time left box
|
||||
#define TIME_LEFT_ROW 30
|
||||
#define TIME_RIGHT_COL 220
|
||||
#define TIME_RIGHT_ROW 52
|
||||
|
||||
#define SCORE_LEFT_COL 459 // score pos
|
||||
#define SCORE_LEFT_ROW 30
|
||||
#define SCORE_RIGHT_COL 574
|
||||
#define SCORE_RIGHT_ROW 52
|
||||
|
||||
#define MINUTE 60
|
||||
#define STATS_COLOR RGB(255,255,255)
|
||||
|
||||
#define INI_FNAME "boffo.ini"
|
||||
#define INI_SECTION "Cryptograms"
|
||||
|
||||
#define INI_LETTERSSOLVED "LettersSolved"
|
||||
#define LSLVD_DEFAULT 6
|
||||
#define MIN_LSLVD 0
|
||||
#define MAX_LSLVD 20
|
||||
|
||||
#define INI_TIME "Time"
|
||||
#define TIME_DEFAULT 180
|
||||
#define MIN_TIME 15
|
||||
#define MAX_TIME 601
|
||||
|
||||
#define INI_REC "Record"
|
||||
#define REC_DEFAULT 0
|
||||
|
||||
#define STAT_TIMER_ID 987 // wm_timer messages
|
||||
#define INTERVAL 1000 // one second intervals
|
||||
|
||||
#define SCORE_FACTOR 2
|
||||
#define SCORE_JACKPOT 100
|
||||
|
||||
class CStats {
|
||||
public:
|
||||
CStats();
|
||||
~CStats();
|
||||
|
||||
void SaveStats(int nLttrsSlvd, int nTime);
|
||||
int ResetGame();
|
||||
|
||||
CText *m_pScore;
|
||||
CText *m_pTime;
|
||||
|
||||
int m_nLettersSolved;
|
||||
int m_nScore;
|
||||
int m_nTime;
|
||||
int m_nCountDown;
|
||||
char m_nIsUsedGram;
|
||||
};
|
||||
|
||||
} // namespace Crypt
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
22
engines/bagel/hodjnpodj/crypt/stdafx.h
Normal file
22
engines/bagel/hodjnpodj/crypt/stdafx.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
1293
engines/bagel/hodjnpodj/dfa/dfa.cpp
Normal file
1293
engines/bagel/hodjnpodj/dfa/dfa.cpp
Normal file
File diff suppressed because it is too large
Load Diff
200
engines/bagel/hodjnpodj/dfa/dfa.h
Normal file
200
engines/bagel/hodjnpodj/dfa/dfa.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_DFA_DFA_H
|
||||
#define HODJNPODJ_DFA_DFA_H
|
||||
|
||||
#include "bagel/boflib/sound.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/dfa/globals.h"
|
||||
#include "bagel/hodjnpodj/dfa/resource.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h" // header for the options library
|
||||
#include "bagel/hodjnpodj/hnplibs/mainmenu.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/rules.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/bitmaps.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
// Button Identifier codes (BIDs)
|
||||
#define IDC_OPTION 100
|
||||
#define IDC_LETTERBUTTON 200 // to 480
|
||||
#define IDC_JUNK 999
|
||||
|
||||
// Border width & height
|
||||
#define SIDE_BORDER 16
|
||||
#define TOP_BORDER 20
|
||||
|
||||
// Rules File Identifiers
|
||||
#define RULESFILE "DFA.TXT"
|
||||
#define RULES_WAV ".\\SOUND\\DAMFUR.WAV"
|
||||
|
||||
// Sound files:
|
||||
#define GAME_THEME ".\\SOUND\\DAMFUR.MID"
|
||||
#define HIT_1_WAV ".\\SOUND\\OW1.WAV"
|
||||
#define HIT_2_WAV ".\\SOUND\\OW2.WAV"
|
||||
#define HIT_3_WAV ".\\SOUND\\OW3.WAV"
|
||||
#define HIT_4_WAV ".\\SOUND\\OW4.WAV"
|
||||
#define HIT_5_WAV ".\\SOUND\\OW5.WAV"
|
||||
#define HIT_6_WAV ".\\SOUND\\OW6.WAV"
|
||||
#define HIT_7_WAV ".\\SOUND\\OW7.WAV"
|
||||
#define HIT_8_WAV ".\\SOUND\\OW8.WAV"
|
||||
#define HIT_9_WAV ".\\SOUND\\OW9.WAV"
|
||||
#define HIT_10_WAV ".\\SOUND\\OW10.WAV"
|
||||
#define HIT_11_WAV ".\\SOUND\\OW11.WAV"
|
||||
#define MISS_1_WAV ".\\SOUND\\HAHA.WAV"
|
||||
#define MISS_2_WAV ".\\SOUND\\MISSED.WAV"
|
||||
#define MISS_3_WAV ".\\SOUND\\MISSEDME.WAV"
|
||||
#define TICK_WAV ".\\SOUND\\TICK.WAV"
|
||||
#define TIME_WAV ".\\SOUND\\BUZZER.WAV"
|
||||
#define LAKE_WAV ".\\SOUND\\LAKE.WAV"
|
||||
#define MOUNT_WAV ".\\SOUND\\YODEL.WAV"
|
||||
#define BEE_WAV ".\\SOUND\\BEE.WAV"
|
||||
#define WATCH_WAV ".\\SOUND\\CUCKOO.WAV"
|
||||
|
||||
#define NUM_HIT_SOUNDS 11 // Number of sounds available for a hit
|
||||
#define NUM_MISS_SOUNDS 3 // Number of sounds available for a missed hit
|
||||
#define NUM_BEAVERS 7 // Number of beavers to hit
|
||||
|
||||
// Audio EasterEgg area constants
|
||||
#define LAKE_X 178
|
||||
#define LAKE_Y 152
|
||||
#define LAKE_DX 283
|
||||
#define LAKE_DY 38
|
||||
|
||||
#define MOUNT_X 40
|
||||
#define MOUNT_Y 40
|
||||
#define MOUNT_DX 510
|
||||
#define MOUNT_DY 80
|
||||
|
||||
#define FLOWERS_X 540
|
||||
#define FLOWERS_Y 325
|
||||
#define FLOWERS_DX 82
|
||||
#define FLOWERS_DY 136
|
||||
|
||||
#define WATCH_X 437 // 436
|
||||
#define WATCH_Y 401 // 401
|
||||
#define WATCH_DX 70
|
||||
#define WATCH_DY 60
|
||||
|
||||
// Bitmap Identifiers
|
||||
#define OPTSCROLL "ART\\SSCROLL.BMP"
|
||||
#define BEAVER1 "ART\\BEAVER1.BMP"
|
||||
#define BEAVER2 "ART\\BEAVER2.BMP"
|
||||
#define BEAVER3 "ART\\BEAVER3.BMP"
|
||||
#define BEAVER4 "ART\\BEAVER4.BMP"
|
||||
#define BEAVER5 "ART\\BEAVER5.BMP"
|
||||
#define BEAVER6 "ART\\BEAVER6.BMP"
|
||||
#define BEAVER7 "ART\\BEAVER7.BMP"
|
||||
|
||||
// Button positioning constants
|
||||
#define OPTION_WIDTH 146
|
||||
#define OPTION_HEIGHT 23
|
||||
#define OPTION_LEFT 246
|
||||
#define OPTION_TOP 0
|
||||
|
||||
#define NUMBEROFCOLS 20
|
||||
#define NUMBEROFROWS 14
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CMainPackRatWindow:
|
||||
// See game.cpp for the code to the member functions and the message map.
|
||||
//
|
||||
|
||||
class CMainDFAWindow : public CFrameWnd {
|
||||
public:
|
||||
unsigned int m_nTimeForGame = 0;
|
||||
int m_nBeaverDuration = 0;
|
||||
|
||||
private:
|
||||
bool m_bPlaySounds = false; // bool for am I playing a certain # of rounds
|
||||
HWND m_hCallAppWnd = nullptr;
|
||||
LPGAMESTRUCT m_lpGameStruct = nullptr;
|
||||
bool m_bMouseCaptured = false;
|
||||
long m_lScore = 0;
|
||||
CRect MainRect; // screen area spanned by the game window
|
||||
CRect ArtRect; // screen area inside the border trim
|
||||
CRect OptionRect; // screen area spanned by the option button
|
||||
CRect rNewGame; // screen area spanned by the name plate
|
||||
CRect arBeaver[NUM_BEAVERS];
|
||||
|
||||
CString aHitFile[NUM_HIT_SOUNDS];
|
||||
CString aMissFile[NUM_MISS_SOUNDS];
|
||||
|
||||
public:
|
||||
CMainDFAWindow(HWND, LPGAMESTRUCT);
|
||||
|
||||
void SplashScreen();
|
||||
|
||||
static void ReleaseResources();
|
||||
static void FlushInputEvents();
|
||||
void MainLoop();
|
||||
void ResetGame();
|
||||
void ClearGrid();
|
||||
void LoadNewGrid(int = 1);
|
||||
void CreateNewGrid();
|
||||
|
||||
private:
|
||||
void OnSoundNotify(CSound *pSound);
|
||||
|
||||
protected:
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
bool LoadBeaverSounds();
|
||||
void ReleaseBeaverSounds();
|
||||
//
|
||||
// Sound as resource dudes:
|
||||
//
|
||||
char *m_pHitSound[NUM_HIT_SOUNDS] = {};
|
||||
HANDLE m_hHitRes[NUM_HIT_SOUNDS] = {};
|
||||
char *m_pMissSound[NUM_MISS_SOUNDS] = {};
|
||||
HANDLE m_hMissRes[NUM_MISS_SOUNDS] = {};
|
||||
|
||||
//{{AFX_MSG( CMainPackRatWindow )
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg void OnTimer(uintptr);
|
||||
afx_msg void OnRButtonDown(unsigned int, CPoint);
|
||||
afx_msg void OnLButtonDown(unsigned int, CPoint);
|
||||
afx_msg void OnLButtonUp(unsigned int, CPoint);
|
||||
afx_msg void OnMouseMove(unsigned int, CPoint);
|
||||
afx_msg void OnSysKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
afx_msg void OnKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
afx_msg bool OnEraseBkgnd(CDC *);
|
||||
afx_msg void OnActivate(unsigned int nState, CWnd *pWndOther, bool bMinimized) override;
|
||||
afx_msg LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
90
engines/bagel/hodjnpodj/dfa/dialogs.h
Normal file
90
engines/bagel/hodjnpodj/dfa/dialogs.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_DFA_DIALOGS_H
|
||||
#define HODJNPODJ_DFA_DIALOGS_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/dfa/dfa.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////// Options Specific to Word Search
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
class CDFAOptDlg : public CBmpDialog {
|
||||
private:
|
||||
int m_nGameTime = 0;
|
||||
int m_nBeaverTime = 0;
|
||||
CRect rDisplayGTime;
|
||||
CRect rDisplayBTime;
|
||||
|
||||
public:
|
||||
CDFAOptDlg(CWnd* pParent = nullptr, CPalette *pPalette = nullptr, unsigned int = IDD_MINIOPTIONS_DIALOG);
|
||||
void SetInitialOptions(int = 8, int = 1); // Sets the private members
|
||||
void ClearDialogImage();
|
||||
bool OnInitDialog() override;
|
||||
|
||||
protected:
|
||||
//{{AFX_MSG(COptions)
|
||||
virtual void OnCancel() override;
|
||||
virtual void OnOK() override;
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
afx_msg void OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar);
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnDestroy();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////// Pack Rat Message Box
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
class CMsgDlg : public CBmpDialog {
|
||||
private:
|
||||
int m_nWhichMsg;
|
||||
long m_lScore;
|
||||
|
||||
public:
|
||||
CMsgDlg(CWnd* pParent = nullptr, CPalette *pPalette = nullptr, unsigned int = IDD_MESSAGEBOX);
|
||||
void SetInitialOptions(int, long); // Sets the private members
|
||||
void ClearDialogImage();
|
||||
bool OnInitDialog() override;
|
||||
|
||||
protected:
|
||||
//{{AFX_MSG(COptions)
|
||||
virtual void OnCancel() override;
|
||||
virtual void OnOK() override;
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnDestroy();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
57
engines/bagel/hodjnpodj/dfa/errors.h
Normal file
57
engines/bagel/hodjnpodj/dfa/errors.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_DFA_ERRORS_H
|
||||
#define HODJNPODJ_DFA_ERRORS_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
//
|
||||
// error reporting codes
|
||||
//
|
||||
typedef unsigned char ERROR_CODE;
|
||||
#define ERR_NONE 0 // no error
|
||||
#define ERR_MEMORY 1 // not enough memory
|
||||
#define ERR_FOPEN 2 // error opening a file
|
||||
#define ERR_FCLOSE 3 // error closing a file
|
||||
#define ERR_FREAD 4 // error reading a file
|
||||
#define ERR_FWRITE 5 // error writing a file
|
||||
#define ERR_FSEEK 6 // error seeking a file
|
||||
#define ERR_FDEL 7 // error deleting a file
|
||||
#define ERR_FFIND 8 // could not find file
|
||||
#define ERR_FTYPE 9 // invalid file type
|
||||
#define ERR_PATH 10 // invalid path or filename
|
||||
#define ERR_DISK 11 // unrecoverable disk error
|
||||
#define ERR_UNKNOWN 12 // unknown error
|
||||
|
||||
#define ERR_FUTURE1 13 // future use
|
||||
#define ERR_FUTURE2 14 //
|
||||
#define ERR_FUTURE3 15 //
|
||||
#define ERR_FUTURE4 16 //
|
||||
#define ERR_FUTURE5 17 // future use
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
42
engines/bagel/hodjnpodj/dfa/globals.h
Normal file
42
engines/bagel/hodjnpodj/dfa/globals.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_DFA_GLOBALS_H
|
||||
#define HODJNPODJ_DFA_GLOBALS_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
// Main Window positioning constants
|
||||
#define GAME_WIDTH 640
|
||||
#define GAME_HEIGHT 480
|
||||
|
||||
#define VK_H 72
|
||||
#define VK_J 74
|
||||
#define VK_K 75
|
||||
#define VK_L 76
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
89
engines/bagel/hodjnpodj/dfa/init.cpp
Normal file
89
engines/bagel/hodjnpodj/dfa/init.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/dfa/resource.h"
|
||||
#include "bagel/hodjnpodj/dfa/dfa.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
|
||||
CMainDFAWindow *pMainGameWnd = nullptr; // pointer to the poker's main window
|
||||
CPalette *pTestPalette = nullptr;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunDFA
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
HWND FAR PASCAL RunDFA(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
|
||||
// if the pointer has garbage in it, the clean it out
|
||||
if (pMainGameWnd != nullptr) {
|
||||
pMainGameWnd = nullptr;
|
||||
}
|
||||
|
||||
// create a my poker window and show it
|
||||
pMainGameWnd = new CMainDFAWindow(hParentWnd, lpGameInfo);
|
||||
pMainGameWnd->ShowWindow(SW_SHOWNORMAL);
|
||||
pMainGameWnd->UpdateWindow();
|
||||
pMainGameWnd->SetActiveWindow();
|
||||
|
||||
// return the handle to this window
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMainGameWnd->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
if (!lpGameInfo->bPlayingMetagame)
|
||||
MFC::PostMessage(pMainGameWnd->m_hWnd, WM_COMMAND, IDC_OPTION, BN_CLICKED);
|
||||
|
||||
return pMainGameWnd->m_hWnd;
|
||||
}
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
37
engines/bagel/hodjnpodj/dfa/init.h
Normal file
37
engines/bagel/hodjnpodj/dfa/init.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_DFA_DLLINIT_H
|
||||
#define HODJNPODJ_DFA_DLLINIT_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
HWND FAR PASCAL RunDFA(HWND, LPGAMESTRUCT);
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
262
engines/bagel/hodjnpodj/dfa/msgdlg.cpp
Normal file
262
engines/bagel/hodjnpodj/dfa/msgdlg.cpp
Normal file
@@ -0,0 +1,262 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/dfa/resource.h"
|
||||
#include "bagel/hodjnpodj/dfa/dialogs.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
static CPalette *pPackRatOptPalette;
|
||||
|
||||
CColorButton *pMsgOKButton = nullptr;
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* CMsgDlg
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Constructor sends the input to the CBmpDialog constructor and
|
||||
* the intializes the private members
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* Those needed to contruct a CBmpDialog dialog: pParent,pPalette, nID
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* private member m_nCurrenLEVEL
|
||||
* globals rectDisplayAmount and pSeLEVELPalette
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
CMsgDlg::CMsgDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, nID, ".\\ART\\SSCROLL.BMP") {
|
||||
pPackRatOptPalette = pPalette;
|
||||
m_nWhichMsg = 1;
|
||||
m_lScore = 0L;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnCommand
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Process the "Set" and "Cancel" buttons
|
||||
*
|
||||
* This function is called when a WM_COMMAND message is issued,
|
||||
* typically in order to process control related activities.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* wParam identifier for the button to be processed
|
||||
* lParam type of message to be processed
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
bool CMsgDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
// What ever button is clicked, end the dialog and send the ID of the button
|
||||
// clicked as the return from the dialog
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
switch (wParam) {
|
||||
case IDOK:
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return CDialog::OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
void CMsgDlg::OnCancel() {
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
return;
|
||||
}
|
||||
|
||||
void CMsgDlg::OnOK() {
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
return;
|
||||
}
|
||||
|
||||
void CMsgDlg::ClearDialogImage() {
|
||||
|
||||
if (pMsgOKButton != nullptr) {
|
||||
delete pMsgOKButton;
|
||||
pMsgOKButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
|
||||
return;
|
||||
}
|
||||
/*****************************************************************
|
||||
*
|
||||
* SetInitialOptions
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This sets the privates to the inputted values
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* lCurrenLEVEL = the current amount the user has
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_nCurrenLEVEL = (int)min( AMOUNTMAX, lCurrenLEVEL)
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
*
|
||||
****************************************************************/
|
||||
void CMsgDlg::SetInitialOptions(int nWhichMsg, long lScore) {
|
||||
m_nWhichMsg = nWhichMsg;
|
||||
m_lScore = lScore;
|
||||
return;
|
||||
}
|
||||
|
||||
bool CMsgDlg::OnInitDialog() {
|
||||
bool bSuccess;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
pMsgOKButton = new CColorButton();
|
||||
ASSERT(pMsgOKButton != nullptr);
|
||||
pMsgOKButton->SetPalette(pPackRatOptPalette);
|
||||
bSuccess = pMsgOKButton->SetControl(IDOK, this);
|
||||
ASSERT(bSuccess);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnPaint
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Repaint the screen whenever needed; e.g. when uncovered by an
|
||||
* overlapping window, when maximized from an icon, and when it the
|
||||
* window is initially created.
|
||||
*
|
||||
* This uses the CBmpDialog Paint as its base, and displays the current
|
||||
* amount chosen from the scrollbar
|
||||
*
|
||||
* This routine is called whenever Windows sends a WM_PAINT message.
|
||||
* Note that creating a CPaintDC automatically does a BeginPaint and
|
||||
* an EndPaint call is done when it is destroyed at the end of this
|
||||
* function. CPaintDC's constructor needs the window (this).
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CMsgDlg::OnPaint() {
|
||||
// call CBmpDialog onpaint, to paint the background
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
CDC *pDC = GetDC();
|
||||
// CText(CDC *pDC, CPalette *pPalette, CRect *pRect, int nJustify = JUSTIFY_CENTER);
|
||||
// bool DisplayString(CDC *pDC, const char* pszText, const int nSize, const int nWeight, const COLORREF crColor = CTEXT_COLOR);
|
||||
|
||||
CRect rRect1(16, 40, 200, 50);
|
||||
CRect rRect2(16, 60, 200, 80);
|
||||
CRect rRect3(16, 84, 200, 104);
|
||||
CText txtLine1(pDC, pPackRatOptPalette, &rRect1);
|
||||
CText txtLine2(pDC, pPackRatOptPalette, &rRect2);
|
||||
CText txtLine3(pDC, pPackRatOptPalette, &rRect3);
|
||||
char cDisplay[30];
|
||||
|
||||
switch (m_nWhichMsg) {
|
||||
case 1:
|
||||
Common::sprintf_s(cDisplay, "Score: %li", m_lScore);
|
||||
// txtLine1.DisplayString( pDC, "", 21, FW_BOLD );
|
||||
txtLine2.DisplayString(pDC, "Game over.", 21, FW_BOLD);
|
||||
txtLine3.DisplayString(pDC, cDisplay, 21, FW_BOLD);
|
||||
break;
|
||||
}
|
||||
ReleaseDC(pDC);
|
||||
return;
|
||||
}
|
||||
|
||||
void CMsgDlg::OnDestroy() {
|
||||
// send a message to the calling app to tell it the user has quit the game
|
||||
if (pMsgOKButton != nullptr) {
|
||||
delete pMsgOKButton;
|
||||
pMsgOKButton = nullptr;
|
||||
}
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
// Message Map
|
||||
BEGIN_MESSAGE_MAP(CMsgDlg, CBmpDialog)
|
||||
//{{AFX_MSG_MAP( CMainPokerWindow )
|
||||
ON_WM_PAINT()
|
||||
ON_WM_DESTROY()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
487
engines/bagel/hodjnpodj/dfa/optdlg.cpp
Normal file
487
engines/bagel/hodjnpodj/dfa/optdlg.cpp
Normal file
@@ -0,0 +1,487 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/dfa/resource.h"
|
||||
#include "bagel/hodjnpodj/dfa/dialogs.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
constexpr int GAMETIMEMAX = 5;
|
||||
constexpr int GAMETIMEMIN = 1;
|
||||
constexpr int GAMESTEP = 1;
|
||||
|
||||
constexpr int BEAVERTIMEMAX = 4;
|
||||
constexpr int BEAVERTIMEMIN = 1;
|
||||
constexpr int BEAVERSTEP = 1;
|
||||
|
||||
static CPalette *pPackRatOptPalette;
|
||||
CText *ptxtGTime;
|
||||
CText *ptxtBTime;
|
||||
|
||||
CColorButton *pDFAOKButton = nullptr;
|
||||
CColorButton *pDFACancelButton = nullptr;
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* CDFAOptDlg
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Constructor sends the input to the CBmpDialog constructor and
|
||||
* the intializes the private members
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* Those needed to contruct a CBmpDialog dialog: pParent,pPalette, nID
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* private member m_nCurrenLEVEL
|
||||
* globals rectDisplayAmount and pSeLEVELPalette
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
CDFAOptDlg::CDFAOptDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, nID, ".\\ART\\SSCROLL.BMP"),
|
||||
rDisplayGTime(43, 85, 174, 98),
|
||||
rDisplayBTime(43, 35, 174, 48) {
|
||||
CDC *pDC = GetDC();
|
||||
|
||||
pPackRatOptPalette = pPalette;
|
||||
|
||||
ptxtGTime = new CText(pDC, pPackRatOptPalette, &rDisplayGTime, JUSTIFY_CENTER);
|
||||
ptxtBTime = new CText(pDC, pPackRatOptPalette, &rDisplayBTime, JUSTIFY_CENTER);
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnCommand
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Process the "Set" and "Cancel" buttons
|
||||
*
|
||||
* This function is called when a WM_COMMAND message is issued,
|
||||
* typically in order to process control related activities.
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* wParam identifier for the button to be processed
|
||||
* lParam type of message to be processed
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
bool CDFAOptDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
// What ever button is clicked, end the dialog and send the ID of the button
|
||||
// clicked as the return from the dialog
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
switch (wParam) {
|
||||
case IDC_MINI_OK:
|
||||
// calculate current level from
|
||||
ClearDialogImage();
|
||||
EndDialog(m_nGameTime + (m_nBeaverTime * 1000));
|
||||
return 1;
|
||||
case IDC_MINI_CANCEL:
|
||||
ClearDialogImage();
|
||||
EndDialog(-1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return CDialog::OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
void CDFAOptDlg::OnCancel() {
|
||||
ClearDialogImage();
|
||||
EndDialog(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
void CDFAOptDlg::OnOK() {
|
||||
if (pDFAOKButton->GetState() & 0x0008)
|
||||
SendMessage(WM_COMMAND, IDC_MINI_OK, BN_CLICKED);
|
||||
else
|
||||
SendMessage(WM_COMMAND, IDC_MINI_CANCEL, BN_CLICKED);
|
||||
return;
|
||||
}
|
||||
|
||||
void CDFAOptDlg::ClearDialogImage() {
|
||||
|
||||
if (pDFAOKButton != nullptr) {
|
||||
delete pDFAOKButton;
|
||||
pDFAOKButton = nullptr;
|
||||
}
|
||||
if (pDFACancelButton != nullptr) {
|
||||
delete pDFACancelButton;
|
||||
pDFACancelButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
|
||||
return;
|
||||
}
|
||||
/*****************************************************************
|
||||
*
|
||||
* SetInitialOptions
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This sets the privates to the inputted values
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* lCurrenLEVEL = the current amount the user has
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* m_nCurrenLEVEL = (int)min( AMOUNTMAX, lCurrenLEVEL)
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
*
|
||||
****************************************************************/
|
||||
void CDFAOptDlg::SetInitialOptions(int nGTime, int nBTime) {
|
||||
m_nGameTime = nGTime / 15; // get a value of 0 to 4
|
||||
m_nBeaverTime = nBTime;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool CDFAOptDlg::OnInitDialog() {
|
||||
bool bSuccess;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
pDFAOKButton = new CColorButton();
|
||||
ASSERT(pDFAOKButton != nullptr);
|
||||
pDFAOKButton->SetPalette(pPackRatOptPalette);
|
||||
bSuccess = pDFAOKButton->SetControl(IDC_MINI_OK, this);
|
||||
ASSERT(bSuccess);
|
||||
|
||||
pDFACancelButton = new CColorButton();
|
||||
ASSERT(pDFACancelButton != nullptr);
|
||||
pDFACancelButton->SetPalette(pPackRatOptPalette);
|
||||
bSuccess = pDFACancelButton->SetControl(IDC_MINI_CANCEL, this);
|
||||
ASSERT(bSuccess);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnPaint
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Repaint the screen whenever needed; e.g. when uncovered by an
|
||||
* overlapping window, when maximized from an icon, and when it the
|
||||
* window is initially created.
|
||||
*
|
||||
* This uses the CBmpDialog Paint as its base, and displays the current
|
||||
* amount chosen from the scrollbar
|
||||
*
|
||||
* This routine is called whenever Windows sends a WM_PAINT message.
|
||||
* Note that creating a CPaintDC automatically does a BeginPaint and
|
||||
* an EndPaint call is done when it is destroyed at the end of this
|
||||
* function. CPaintDC's constructor needs the window (this).
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CDFAOptDlg::OnPaint() {
|
||||
CDC *pDC;
|
||||
CString strBTime = "Beaver Time (Secs) :";
|
||||
CString strGTime = "Game Time (Secs) :";
|
||||
int nOldBkMode;
|
||||
|
||||
CScrollBar *pBTime = nullptr;
|
||||
CScrollBar *pGTime = nullptr;
|
||||
|
||||
char cGDisplay[12];
|
||||
char cBDisplay[12];
|
||||
|
||||
// call CBmpDialog onpaint, to paint the background
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
// now paint in my text with a transparent background
|
||||
nOldBkMode = pDC->SetBkMode(TRANSPARENT);
|
||||
pDC->TextOut(43, 24, strBTime);
|
||||
pDC->TextOut(43, 69, strGTime);
|
||||
pDC->SetBkMode(nOldBkMode);
|
||||
|
||||
switch (m_nGameTime) {
|
||||
case 1:
|
||||
Common::sprintf_s(cGDisplay, "15");
|
||||
break;
|
||||
case 2:
|
||||
Common::sprintf_s(cGDisplay, "30");
|
||||
break;
|
||||
case 3:
|
||||
Common::sprintf_s(cGDisplay, "45");
|
||||
break;
|
||||
case 4:
|
||||
Common::sprintf_s(cGDisplay, "60");
|
||||
break;
|
||||
default:
|
||||
Common::sprintf_s(cGDisplay, "Unlimited");
|
||||
break;
|
||||
}
|
||||
ptxtGTime->DisplayString(pDC, cGDisplay, 14, FW_BOLD, RGB(0, 0, 0));
|
||||
|
||||
pGTime = (CScrollBar *)GetDlgItem(IDC_GAMETIME);
|
||||
pGTime->SetScrollRange(GAMETIMEMIN, GAMETIMEMAX, true);
|
||||
if (m_nGameTime == 0)
|
||||
pGTime->SetScrollPos(GAMETIMEMAX, true);
|
||||
else
|
||||
pGTime->SetScrollPos(m_nGameTime, true);
|
||||
|
||||
|
||||
switch (m_nBeaverTime) {
|
||||
case 1:
|
||||
Common::sprintf_s(cBDisplay, ".5");
|
||||
break;
|
||||
case 2:
|
||||
Common::sprintf_s(cBDisplay, "1");
|
||||
break;
|
||||
case 3:
|
||||
Common::sprintf_s(cBDisplay, "1.5");
|
||||
break;
|
||||
default:
|
||||
Common::sprintf_s(cBDisplay, "2");
|
||||
break;
|
||||
}
|
||||
ptxtBTime->DisplayString(pDC, cBDisplay, 14, FW_BOLD, RGB(0, 0, 0));
|
||||
|
||||
pBTime = (CScrollBar *)GetDlgItem(IDC_BEAVERDUR);
|
||||
pBTime->SetScrollRange(BEAVERTIMEMIN, BEAVERTIMEMAX, true);
|
||||
pBTime->SetScrollPos(m_nBeaverTime, true);
|
||||
|
||||
pGTime = nullptr;
|
||||
pBTime = nullptr;
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* OnHScroll
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the functionality of the scroll bar
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
void CDFAOptDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar) {
|
||||
int oldAmnt = 0;
|
||||
int newAmnt = 0;
|
||||
CDC *pDC;
|
||||
char cGDisplay[12];
|
||||
char cBDisplay[12];
|
||||
|
||||
// first set the range of the scoll bar
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_GAMETIME)
|
||||
pScrollBar->SetScrollRange(GAMETIMEMIN, GAMETIMEMAX, true);
|
||||
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_BEAVERDUR)
|
||||
pScrollBar->SetScrollRange(BEAVERTIMEMIN, BEAVERTIMEMAX, true);
|
||||
|
||||
// get the scroll bar's current position, i.e. the current amount set
|
||||
oldAmnt = pScrollBar->GetScrollPos();
|
||||
newAmnt = oldAmnt;
|
||||
|
||||
// switching off of what the scroll bar wants to do, act accordingly.
|
||||
switch (nSBCode) {
|
||||
case SB_LINELEFT:
|
||||
case SB_PAGELEFT:
|
||||
case SB_LEFT:
|
||||
newAmnt --;
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_BEAVERDUR) {
|
||||
if (newAmnt < BEAVERTIMEMIN)
|
||||
newAmnt = BEAVERTIMEMIN;
|
||||
} else {
|
||||
newAmnt = MAX<int>(newAmnt, GAMETIMEMIN);
|
||||
}
|
||||
break;
|
||||
case SB_LINERIGHT:
|
||||
case SB_PAGERIGHT:
|
||||
case SB_RIGHT:
|
||||
newAmnt ++;
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_BEAVERDUR) {
|
||||
if (newAmnt > BEAVERTIMEMAX)
|
||||
newAmnt = BEAVERTIMEMAX;
|
||||
} else {
|
||||
if (newAmnt > GAMETIMEMAX)
|
||||
newAmnt = GAMETIMEMAX;
|
||||
}
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
newAmnt = nPos;
|
||||
break;
|
||||
}
|
||||
|
||||
// set the scroll bar to the new position
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_GAMETIME)
|
||||
m_nGameTime = newAmnt;
|
||||
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_BEAVERDUR)
|
||||
m_nBeaverTime = newAmnt;
|
||||
|
||||
pScrollBar->SetScrollPos(newAmnt, true);
|
||||
|
||||
// set the current amount to the new amount just set
|
||||
// and paint this new amount onto the screen
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_GAMETIME) {
|
||||
switch (m_nGameTime) {
|
||||
case 1:
|
||||
Common::sprintf_s(cGDisplay, "15");
|
||||
break;
|
||||
case 2:
|
||||
Common::sprintf_s(cGDisplay, "30");
|
||||
break;
|
||||
case 3:
|
||||
Common::sprintf_s(cGDisplay, "45");
|
||||
break;
|
||||
case 4:
|
||||
Common::sprintf_s(cGDisplay, "60");
|
||||
break;
|
||||
default:
|
||||
Common::sprintf_s(cGDisplay, "Unlimited");
|
||||
break;
|
||||
}
|
||||
ptxtGTime->DisplayString(pDC, cGDisplay, 14, FW_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
if (pScrollBar->GetDlgCtrlID() == IDC_BEAVERDUR) {
|
||||
switch (m_nBeaverTime) {
|
||||
case 1:
|
||||
Common::sprintf_s(cBDisplay, ".5");
|
||||
break;
|
||||
case 2:
|
||||
Common::sprintf_s(cBDisplay, "1");
|
||||
break;
|
||||
case 3:
|
||||
Common::sprintf_s(cBDisplay, "1.5");
|
||||
break;
|
||||
default:
|
||||
Common::sprintf_s(cBDisplay, "2");
|
||||
break;
|
||||
}
|
||||
ptxtBTime->DisplayString(pDC, cBDisplay, 14, FW_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
ReleaseDC(pDC);
|
||||
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
|
||||
}
|
||||
|
||||
bool CDFAOptDlg::OnEraseBkgnd(CDC *pDC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDFAOptDlg::OnDestroy() {
|
||||
// send a message to the calling app to tell it the user has quit the game
|
||||
if (pDFAOKButton != nullptr) {
|
||||
delete pDFAOKButton;
|
||||
pDFAOKButton = nullptr;
|
||||
}
|
||||
if (pDFACancelButton != nullptr) {
|
||||
delete pDFACancelButton;
|
||||
pDFACancelButton = nullptr;
|
||||
}
|
||||
|
||||
delete ptxtBTime;
|
||||
delete ptxtGTime;
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
// Message Map
|
||||
BEGIN_MESSAGE_MAP(CDFAOptDlg, CBmpDialog)
|
||||
//{{AFX_MSG_MAP( CMainPokerWindow )
|
||||
ON_WM_PAINT()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_ERASEBKGND()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
48
engines/bagel/hodjnpodj/dfa/resource.h
Normal file
48
engines/bagel/hodjnpodj/dfa/resource.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_DFA_RESOURCE_H
|
||||
#define HODJNPODJ_DFA_RESOURCE_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace DFA {
|
||||
|
||||
#define IDI_DFA 2
|
||||
#define IDC_OPTIONS 202
|
||||
#define IDC_RULES 230
|
||||
#define IDC_CANCEL 250
|
||||
#define IDC_QUIT 251
|
||||
|
||||
#define IDB_PODJRIGHT 330
|
||||
#define IDD_MESSAGEBOX 333
|
||||
|
||||
#define IDD_MINIOPTIONS_DIALOG 500
|
||||
#define IDC_MINI_CANCEL 501
|
||||
#define IDC_MINI_OK 502
|
||||
#define IDC_GAMETIME 504
|
||||
#define IDC_BEAVERDUR 505
|
||||
|
||||
} // namespace DFA
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
2890
engines/bagel/hodjnpodj/fuge/fuge.cpp
Normal file
2890
engines/bagel/hodjnpodj/fuge/fuge.cpp
Normal file
File diff suppressed because it is too large
Load Diff
153
engines/bagel/hodjnpodj/fuge/fuge.h
Normal file
153
engines/bagel/hodjnpodj/fuge/fuge.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_FUGE_FUGE_H
|
||||
#define HODJNPODJ_FUGE_FUGE_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/boflib/error.h"
|
||||
#include "bagel/hodjnpodj/libs/vector.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Fuge {
|
||||
|
||||
#define N_ROWS 6
|
||||
#define BRICKS_PER_ROW 16
|
||||
#define N_BRICKS (N_ROWS*BRICKS_PER_ROW)
|
||||
|
||||
class CFugeWindow : public CFrameWnd {
|
||||
public:
|
||||
CFugeWindow();
|
||||
void PlayGame();
|
||||
void PaintScreen();
|
||||
void LoadIniSettings();
|
||||
|
||||
protected:
|
||||
void initMembers();
|
||||
void initStatics();
|
||||
void GameReset();
|
||||
void GamePause();
|
||||
void GameResume();
|
||||
void HandleError(ERROR_CODE);
|
||||
void RealignVectors();
|
||||
ERROR_CODE LoadMasterSprites();
|
||||
void ReleaseMasterSprites();
|
||||
ERROR_CODE LoadMasterSounds();
|
||||
void ReleaseMasterSounds();
|
||||
ERROR_CODE LoadNewPaddle(int);
|
||||
void InitializeJoystick();
|
||||
void RepaintSpriteList(CDC *);
|
||||
void PaintBricks(CDC *);
|
||||
void StartBall();
|
||||
void EndBall();
|
||||
void PaintBall();
|
||||
void LaunchBall();
|
||||
void StartPaddle();
|
||||
void EndPaddle();
|
||||
void PaintPaddle(bool);
|
||||
CVector BallOnPaddle();
|
||||
void StartBricks();
|
||||
void EndBricks();
|
||||
void EraseBrick(CDC *, int);
|
||||
void LoseBall();
|
||||
void BallvsPaddle();
|
||||
void BallvsBrick(double);
|
||||
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
long OnJoyStick(unsigned int, long);
|
||||
void OnPaint();
|
||||
void OnTimer(uintptr);
|
||||
void OnMouseMove(unsigned int, CPoint);
|
||||
void OnRButtonUp(unsigned int, CPoint);
|
||||
void OnLButtonDown(unsigned int, CPoint);
|
||||
void OnSysChar(unsigned int, unsigned int, unsigned int);
|
||||
void OnSysKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnActivate(unsigned int, CWnd *, bool) override;
|
||||
LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
void OnSoundNotify(CSound *);
|
||||
void OnClose();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
bool m_bBrickVisible[N_BRICKS] = {};
|
||||
CPoint m_ptOrigin;
|
||||
CRect m_rNewGameButton;
|
||||
CRect m_rBlackHole;
|
||||
CVector m_vBallVector;
|
||||
CVector m_ptBallLocation;
|
||||
CPalette *m_pGamePalette = nullptr;
|
||||
CBmpButton *m_pScrollButton = nullptr;
|
||||
CSprite *m_pBall = nullptr;
|
||||
CSprite *m_pPaddle = nullptr;
|
||||
CSound *m_pSoundTrack = nullptr;
|
||||
|
||||
char * m_pBrickSound = nullptr;
|
||||
char * m_pWallSound = nullptr;
|
||||
char * m_pPaddleSound = nullptr;
|
||||
char * m_pExtraLifeSound = nullptr;
|
||||
HANDLE m_hBrickRes = nullptr;
|
||||
HANDLE m_hWallRes = nullptr;
|
||||
HANDLE m_hPaddleRes = nullptr;
|
||||
HANDLE m_hExtraLifeRes = nullptr;
|
||||
|
||||
int m_nInitNumBalls = 0;
|
||||
int m_nInitStartLevel = 0;
|
||||
int m_nInitBallSpeed = 0;
|
||||
int m_nInitPaddleSize = 0;
|
||||
int m_nGForceFactor = 0;
|
||||
|
||||
double m_fTurboBoost = 0;
|
||||
long m_lScore = 0;
|
||||
long m_lExtraLifeScore = 0;
|
||||
long m_nJoyOrgX = 0;
|
||||
long m_nJoyOrgY = 0;
|
||||
int m_nBricks = 0;
|
||||
int m_nBalls = 0;
|
||||
int m_nBallSpeed = 0;
|
||||
int m_nNumRows = 0;
|
||||
int m_nPaddleCelIndex = 0;
|
||||
int m_nOldSize = -1;
|
||||
|
||||
bool m_bMovingPaddle = false;
|
||||
bool m_bGameActive = false;
|
||||
bool m_bPause = false;
|
||||
bool m_bIgnoreScrollClick = false;
|
||||
bool m_bPaddleHit = false;
|
||||
bool m_bOutterWall = false;
|
||||
bool m_bJoyActive = false;
|
||||
bool m_bBallOnPaddle = false;
|
||||
|
||||
CVector gvCenter;
|
||||
};
|
||||
|
||||
} // namespace Fuge
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
100
engines/bagel/hodjnpodj/fuge/init.cpp
Normal file
100
engines/bagel/hodjnpodj/fuge/init.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/fuge/fuge.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Fuge {
|
||||
|
||||
HWND FAR PASCAL RunFuge(HWND, LPGAMESTRUCT);
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunFuge
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke poker
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
//extern "C"
|
||||
HWND FAR PASCAL RunFuge(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CFugeWindow *pMain;
|
||||
|
||||
pGameParams = lpGameInfo;
|
||||
|
||||
// invoke your game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMain = new CFugeWindow) != nullptr) {
|
||||
|
||||
pMain->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
pMain->UpdateWindow();
|
||||
|
||||
pMain->SetActiveWindow();
|
||||
|
||||
// these are used by Rules
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
if (pGameParams->bPlayingMetagame)
|
||||
pMain->PlayGame();
|
||||
}
|
||||
|
||||
return pMain->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace Fuge
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
37
engines/bagel/hodjnpodj/fuge/init.h
Normal file
37
engines/bagel/hodjnpodj/fuge/init.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_FUGE_RESOURCE_H
|
||||
#define HODJNPODJ_FUGE_RESOURCE_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Fuge {
|
||||
|
||||
extern HWND FAR PASCAL RunFuge(HWND, LPGAMESTRUCT);
|
||||
|
||||
} // namespace Fuge
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
59
engines/bagel/hodjnpodj/fuge/resource.h
Normal file
59
engines/bagel/hodjnpodj/fuge/resource.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_FUGE_RESOURCE_H
|
||||
#define HODJNPODJ_FUGE_RESOURCE_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Fuge {
|
||||
|
||||
#define IDI_POKER 2
|
||||
#define IDB_MAP 248
|
||||
#define IDI_ICON1 249
|
||||
#define IDI_CESDEMO 249
|
||||
#define IDD_MAIN_SCROLL 250
|
||||
#define IDD_META_SETUP 251
|
||||
#define IDC_PLAY_META 1022
|
||||
#define IDC_RESTORE_GAME 1023
|
||||
#define IDC_PLAY 1023
|
||||
#define IDC_PLAY_MINI 1024
|
||||
#define IDC_CANCEL_PLAY 1024
|
||||
#define IDC_GRAND_TOUR 1025
|
||||
#define IDC_HODJ_SKILL_HARD 1025
|
||||
#define IDC_RESTART_MOVIE 1026
|
||||
#define IDC_HODJ_SKILL_MEDIUM 1026
|
||||
#define IDC_HODJ_SKILL_EASY 1027
|
||||
#define IDC_QUIT_GAME 1028
|
||||
#define IDC_PODJ_SKILL_EASY 1028
|
||||
#define IDC_PODJ_SKILL_MEDIUM 1029
|
||||
#define IDC_PODJ_SKILL_HARD 1030
|
||||
#define IDC_GAMETIME_LONG 1031
|
||||
#define IDC_GAMETIME_MEDIUM 1032
|
||||
#define IDC_GAMETIME_SHORT 1033
|
||||
#define IDC_PODJ_COMPUTER 1034
|
||||
#define IDC_PODJ_HUMAN 1035
|
||||
|
||||
} // namespace Fuge
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
523
engines/bagel/hodjnpodj/fuge/usercfg.cpp
Normal file
523
engines/bagel/hodjnpodj/fuge/usercfg.cpp
Normal file
@@ -0,0 +1,523 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/menures.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/fuge/usercfg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Fuge {
|
||||
|
||||
#define ID_RESET 104
|
||||
|
||||
#define ID_SCROLL1 105
|
||||
#define ID_SCROLL2 106
|
||||
#define ID_SCROLL3 107
|
||||
#define ID_SCROLL4 108
|
||||
|
||||
#define ID_WALLS 109
|
||||
|
||||
#define PAGE_SIZE 2
|
||||
|
||||
extern const char *INI_SECTION;
|
||||
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
|
||||
static CColorButton *pDefaultsButton = nullptr; // Defaults button on scroll
|
||||
|
||||
|
||||
CUserCfgDlg::CUserCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, nID, ".\\ART\\SSCROLL.BMP") {
|
||||
// Inits
|
||||
//
|
||||
m_pScrollBar1 = nullptr;
|
||||
m_pScrollBar2 = nullptr;
|
||||
m_pScrollBar3 = nullptr;
|
||||
m_pScrollBar4 = nullptr;
|
||||
m_pTxtNumBalls = nullptr;
|
||||
m_pTxtStartLevel = nullptr;
|
||||
m_pTxtBallSpeed = nullptr;
|
||||
m_pTxtPaddleSize = nullptr;
|
||||
|
||||
DoModal();
|
||||
}
|
||||
|
||||
void CUserCfgDlg::DoDataExchange(CDataExchange *pDX) {
|
||||
CBmpDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::PutDlgData() {
|
||||
m_pScrollBar1->SetScrollPos(m_nNumBalls);
|
||||
m_pScrollBar2->SetScrollPos(m_nStartLevel);
|
||||
m_pScrollBar3->SetScrollPos(m_nBallSpeed);
|
||||
m_pScrollBar4->SetScrollPos(m_nPaddleSize);
|
||||
|
||||
m_pWallButton->SetCheck(m_bOutterWall);
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::GetDlgData() {
|
||||
m_nNumBalls = m_pScrollBar1->GetScrollPos();
|
||||
m_nStartLevel = m_pScrollBar2->GetScrollPos();
|
||||
m_nBallSpeed = m_pScrollBar3->GetScrollPos();
|
||||
m_nPaddleSize = m_pScrollBar4->GetScrollPos();
|
||||
|
||||
m_bOutterWall = false;
|
||||
if (m_pWallButton->GetCheck() == 1) {
|
||||
m_bOutterWall = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CUserCfgDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
/*
|
||||
* respond to user
|
||||
*/
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
|
||||
switch (wParam) {
|
||||
|
||||
case IDOK:
|
||||
m_bSave = true;
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
return false;
|
||||
|
||||
case IDCANCEL:
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
return false;
|
||||
|
||||
/*
|
||||
* reset params to default
|
||||
*/
|
||||
case ID_RESET:
|
||||
|
||||
m_nNumBalls = BALLS_DEF;
|
||||
m_nStartLevel = LEVEL_DEF;
|
||||
m_nBallSpeed = SPEED_DEF;
|
||||
m_nPaddleSize = PSIZE_DEF;
|
||||
m_bOutterWall = false;
|
||||
|
||||
PutDlgData();
|
||||
|
||||
UpdateOptions();
|
||||
break;
|
||||
|
||||
case ID_WALLS:
|
||||
m_bOutterWall = !m_bOutterWall;
|
||||
PutDlgData();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CBmpDialog::OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar *pScroll) {
|
||||
char buf[40];
|
||||
int nMin, nMax, nVal;
|
||||
CDC *pDC;
|
||||
|
||||
// can't access a null pointer
|
||||
assert(pScroll != nullptr);
|
||||
|
||||
if (pScroll == m_pScrollBar1) {
|
||||
|
||||
nMin = BALLS_MIN;
|
||||
nMax = BALLS_MAX;
|
||||
nVal = m_nNumBalls;
|
||||
|
||||
} else if (pScroll == m_pScrollBar2) {
|
||||
|
||||
nMin = LEVEL_MIN;
|
||||
nMax = LEVEL_MAX;
|
||||
nVal = m_nStartLevel;
|
||||
|
||||
} else if (pScroll == m_pScrollBar3) {
|
||||
|
||||
nMin = SPEED_MIN;
|
||||
nMax = SPEED_MAX;
|
||||
nVal = m_nBallSpeed;
|
||||
|
||||
} else {
|
||||
assert(pScroll == m_pScrollBar4);
|
||||
|
||||
nMin = PSIZE_MIN;
|
||||
nMax = PSIZE_MAX;
|
||||
nVal = m_nPaddleSize;
|
||||
}
|
||||
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_LEFT:
|
||||
nVal = nMin;
|
||||
break;
|
||||
|
||||
case SB_PAGELEFT:
|
||||
nVal -= PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
if (nVal > nMin)
|
||||
nVal--;
|
||||
break;
|
||||
|
||||
case SB_RIGHT:
|
||||
nVal = nMax;
|
||||
break;
|
||||
|
||||
case SB_PAGERIGHT:
|
||||
nVal += PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINERIGHT:
|
||||
if (nVal < nMax)
|
||||
nVal++;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
nVal = nPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (nVal < nMin)
|
||||
nVal = nMin;
|
||||
if (nVal > nMax)
|
||||
nVal = nMax;
|
||||
|
||||
pScroll->SetScrollPos(nVal);
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
if (pScroll == m_pScrollBar1) {
|
||||
|
||||
m_nNumBalls = nVal;
|
||||
if (m_pTxtNumBalls != nullptr) {
|
||||
Common::sprintf_s(buf, "Number of Balls: %d", m_nNumBalls);
|
||||
m_pTxtNumBalls->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
} else if (pScroll == m_pScrollBar2) {
|
||||
|
||||
m_nStartLevel = nVal;
|
||||
if (m_pTxtStartLevel != nullptr) {
|
||||
Common::sprintf_s(buf, "Starting Level: %d", m_nStartLevel);
|
||||
m_pTxtStartLevel->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
} else if (pScroll == m_pScrollBar3) {
|
||||
|
||||
m_nBallSpeed = nVal;
|
||||
if (m_pTxtBallSpeed != nullptr) {
|
||||
Common::sprintf_s(buf, "Ball Speed: %d", m_nBallSpeed);
|
||||
m_pTxtBallSpeed->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
} else if (pScroll == m_pScrollBar4) {
|
||||
|
||||
m_nPaddleSize = nVal;
|
||||
if (m_pTxtPaddleSize != nullptr) {
|
||||
Common::sprintf_s(buf, "Paddle Size: %d", m_nPaddleSize);
|
||||
m_pTxtPaddleSize->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CUserCfgDlg::OnInitDialog() {
|
||||
CRect tmpRect;
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
tmpRect.SetRect(22, 22, 135, 35);
|
||||
if ((m_pTxtNumBalls = new CText) != nullptr) {
|
||||
m_pTxtNumBalls->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(22, 35, 92, 53);
|
||||
if ((m_pScrollBar1 = new CScrollBar) != nullptr) {
|
||||
m_pScrollBar1->Create(WS_VISIBLE | WS_CHILD | SBS_HORZ | SBS_BOTTOMALIGN, tmpRect, this, ID_SCROLL1);
|
||||
m_pScrollBar1->SetScrollRange(BALLS_MIN, BALLS_MAX, true);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(22, 57, 135, 70);
|
||||
if ((m_pTxtStartLevel = new CText) != nullptr) {
|
||||
m_pTxtStartLevel->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(22, 70, 92, 88);
|
||||
if ((m_pScrollBar2 = new CScrollBar) != nullptr) {
|
||||
m_pScrollBar2->Create(WS_VISIBLE | WS_CHILD | SBS_HORZ | SBS_BOTTOMALIGN, tmpRect, this, ID_SCROLL2);
|
||||
m_pScrollBar2->SetScrollRange(LEVEL_MIN, LEVEL_MAX, true);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(22, 92, 135, 105);
|
||||
if ((m_pTxtBallSpeed = new CText) != nullptr) {
|
||||
m_pTxtBallSpeed->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(22, 105, 92, 123);
|
||||
if ((m_pScrollBar3 = new CScrollBar) != nullptr) {
|
||||
m_pScrollBar3->Create(WS_VISIBLE | WS_CHILD | SBS_HORZ | SBS_BOTTOMALIGN, tmpRect, this, ID_SCROLL3);
|
||||
m_pScrollBar3->SetScrollRange(SPEED_MIN, SPEED_MAX, true);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(22, 127, 110, 140);
|
||||
if ((m_pTxtPaddleSize = new CText) != nullptr) {
|
||||
m_pTxtPaddleSize->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(22, 140, 92, 158);
|
||||
if ((m_pScrollBar4 = new CScrollBar) != nullptr) {
|
||||
m_pScrollBar4->Create(WS_VISIBLE | WS_CHILD | SBS_HORZ | SBS_BOTTOMALIGN, tmpRect, this, ID_SCROLL4);
|
||||
m_pScrollBar4->SetScrollRange(PSIZE_MIN, PSIZE_MAX, true);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
pOKButton->SetPalette(m_pPalette); // set the palette to use
|
||||
pOKButton->SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
pCancelButton->SetPalette(m_pPalette); // set the palette to use
|
||||
pCancelButton->SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pDefaultsButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
pDefaultsButton->SetPalette(m_pPalette); // set the palette to use
|
||||
pDefaultsButton->SetControl(ID_RESET, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pWallButton = new CCheckButton) != nullptr) {
|
||||
m_pWallButton->SetPalette(m_pPalette);
|
||||
m_pWallButton->SetControl(ID_WALLS, this);
|
||||
}
|
||||
|
||||
m_bSave = false;
|
||||
|
||||
LoadIniSettings();
|
||||
|
||||
PutDlgData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnPaint() {
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
UpdateOptions();
|
||||
}
|
||||
|
||||
void CUserCfgDlg::UpdateOptions() {
|
||||
char buf[40];
|
||||
CDC *pDC;
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
if (m_pTxtNumBalls != nullptr) {
|
||||
Common::sprintf_s(buf, "Number of Balls: %d", m_nNumBalls);
|
||||
m_pTxtNumBalls->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
if (m_pTxtStartLevel != nullptr) {
|
||||
Common::sprintf_s(buf, "Starting Level: %d", m_nStartLevel);
|
||||
m_pTxtStartLevel->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
if (m_pTxtBallSpeed != nullptr) {
|
||||
Common::sprintf_s(buf, "Ball Speed: %d", m_nBallSpeed);
|
||||
m_pTxtBallSpeed->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
if (m_pTxtPaddleSize != nullptr) {
|
||||
Common::sprintf_s(buf, "Paddle Size: %d", m_nPaddleSize);
|
||||
m_pTxtPaddleSize->DisplayString(pDC, buf, 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
}
|
||||
|
||||
bool CUserCfgDlg::OnEraseBkgnd(CDC *) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::OnClose() {
|
||||
if (m_bSave) {
|
||||
|
||||
SaveIniSettings();
|
||||
}
|
||||
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (pDefaultsButton != nullptr) { // release the button
|
||||
delete pDefaultsButton;
|
||||
pDefaultsButton = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtPaddleSize != nullptr);
|
||||
if (m_pTxtPaddleSize != nullptr) {
|
||||
delete m_pTxtPaddleSize;
|
||||
m_pTxtPaddleSize = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtBallSpeed != nullptr);
|
||||
if (m_pTxtBallSpeed != nullptr) {
|
||||
delete m_pTxtBallSpeed;
|
||||
m_pTxtBallSpeed = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtStartLevel != nullptr);
|
||||
if (m_pTxtStartLevel != nullptr) {
|
||||
delete m_pTxtStartLevel;
|
||||
m_pTxtStartLevel = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtNumBalls != nullptr);
|
||||
if (m_pTxtNumBalls != nullptr) {
|
||||
delete m_pTxtNumBalls;
|
||||
m_pTxtNumBalls = nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
// de-allocate the scroll bars
|
||||
//
|
||||
assert(m_pScrollBar4 != nullptr);
|
||||
if (m_pScrollBar4 != nullptr) {
|
||||
delete m_pScrollBar4;
|
||||
m_pScrollBar4 = nullptr;
|
||||
}
|
||||
assert(m_pScrollBar3 != nullptr);
|
||||
if (m_pScrollBar3 != nullptr) {
|
||||
delete m_pScrollBar3;
|
||||
m_pScrollBar3 = nullptr;
|
||||
}
|
||||
assert(m_pScrollBar2 != nullptr);
|
||||
if (m_pScrollBar2 != nullptr) {
|
||||
delete m_pScrollBar2;
|
||||
m_pScrollBar2 = nullptr;
|
||||
}
|
||||
assert(m_pScrollBar1 != nullptr);
|
||||
if (m_pScrollBar1 != nullptr) {
|
||||
delete m_pScrollBar1;
|
||||
m_pScrollBar1 = nullptr;
|
||||
}
|
||||
|
||||
if (m_pWallButton != nullptr) {
|
||||
delete m_pWallButton;
|
||||
m_pWallButton = nullptr;
|
||||
}
|
||||
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (pDefaultsButton != nullptr) { // release the button
|
||||
delete pDefaultsButton;
|
||||
pDefaultsButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::LoadIniSettings() {
|
||||
m_nNumBalls = GetPrivateProfileInt(INI_SECTION, "NumberOfBalls", BALLS_DEF, INI_FILENAME);
|
||||
if ((m_nNumBalls < BALLS_MIN) || (m_nNumBalls > BALLS_MAX))
|
||||
m_nNumBalls = BALLS_DEF;
|
||||
|
||||
m_nStartLevel = GetPrivateProfileInt(INI_SECTION, "StartingLevel", LEVEL_DEF, INI_FILENAME);
|
||||
if ((m_nStartLevel < LEVEL_MIN) || (m_nStartLevel > LEVEL_MAX))
|
||||
m_nStartLevel = LEVEL_DEF;
|
||||
|
||||
m_nBallSpeed = GetPrivateProfileInt(INI_SECTION, "BallSpeed", SPEED_DEF, INI_FILENAME);
|
||||
if ((m_nBallSpeed < SPEED_MIN) || (m_nBallSpeed > SPEED_MAX))
|
||||
m_nBallSpeed = SPEED_DEF;
|
||||
|
||||
m_nPaddleSize = GetPrivateProfileInt(INI_SECTION, "PaddleSize", PSIZE_DEF, INI_FILENAME);
|
||||
if ((m_nPaddleSize < PSIZE_MIN) || (m_nPaddleSize > PSIZE_MAX))
|
||||
m_nPaddleSize = PSIZE_DEF;
|
||||
|
||||
int outerWall = GetPrivateProfileInt(INI_SECTION, "OutterWall", 0, INI_FILENAME);
|
||||
m_bOutterWall = outerWall != 0;
|
||||
}
|
||||
|
||||
void CUserCfgDlg::SaveIniSettings() {
|
||||
WritePrivateProfileString(INI_SECTION, "NumberOfBalls", Common::String::format("%d", m_nNumBalls).c_str(), INI_FILENAME);
|
||||
WritePrivateProfileString(INI_SECTION, "StartingLevel", Common::String::format("%d", m_nStartLevel).c_str(), INI_FILENAME);
|
||||
WritePrivateProfileString(INI_SECTION, "BallSpeed", Common::String::format("%d", m_nBallSpeed).c_str(), INI_FILENAME);
|
||||
WritePrivateProfileString(INI_SECTION, "PaddleSize", Common::String::format("%d", m_nPaddleSize).c_str(), INI_FILENAME);
|
||||
WritePrivateProfileString(INI_SECTION, "OutterWall", Common::String::format("%d", m_bOutterWall ? 1 : 0).c_str(), INI_FILENAME);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CUserCfgDlg, CBmpDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace Fuge
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
101
engines/bagel/hodjnpodj/fuge/usercfg.h
Normal file
101
engines/bagel/hodjnpodj/fuge/usercfg.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_FUGE_USERCFG_H
|
||||
#define HODJNPODJ_FUGE_USERCFG_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Fuge {
|
||||
|
||||
#define IDD_USERCFG 100
|
||||
|
||||
#define BALLS_MIN 1
|
||||
#define BALLS_DEF 5
|
||||
#define BALLS_MAX 5
|
||||
|
||||
#define LEVEL_MIN 1
|
||||
#define LEVEL_DEF 6
|
||||
#define LEVEL_MAX 6
|
||||
|
||||
#define SPEED_MIN 1
|
||||
#define SPEED_DEF 6
|
||||
#define SPEED_MAX 10
|
||||
|
||||
#define PSIZE_MIN 0
|
||||
#define PSIZE_DEF 2
|
||||
#define PSIZE_MAX 2
|
||||
|
||||
#define GFORCE_MIN 0
|
||||
#define GFORCE_DEF 0
|
||||
#define GFORCE_MAX 20
|
||||
|
||||
class CUserCfgDlg : public CBmpDialog {
|
||||
public:
|
||||
CUserCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void DoDataExchange(CDataExchange *) override;
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
virtual bool OnInitDialog() override;
|
||||
void PutDlgData();
|
||||
void GetDlgData();
|
||||
void LoadIniSettings();
|
||||
void SaveIniSettings();
|
||||
void UpdateOptions();
|
||||
void ClearDialogImage();
|
||||
|
||||
afx_msg bool OnEraseBkgnd(CDC *);
|
||||
void OnHScroll(unsigned int, unsigned int, CScrollBar *);
|
||||
void OnClose();
|
||||
void OnDestroy();
|
||||
void OnPaint();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CText *m_pTxtNumBalls = nullptr;
|
||||
CText *m_pTxtStartLevel = nullptr;
|
||||
CText *m_pTxtBallSpeed = nullptr;
|
||||
CText *m_pTxtPaddleSize = nullptr;
|
||||
CScrollBar *m_pScrollBar1 = nullptr;
|
||||
CScrollBar *m_pScrollBar2 = nullptr;
|
||||
CScrollBar *m_pScrollBar3 = nullptr;
|
||||
CScrollBar *m_pScrollBar4 = nullptr;
|
||||
CCheckButton *m_pWallButton = nullptr;
|
||||
|
||||
int m_nNumBalls = 0;
|
||||
int m_nStartLevel = 0;
|
||||
int m_nBallSpeed = 0;
|
||||
int m_nPaddleSize = 0;
|
||||
bool m_bOutterWall = false;
|
||||
|
||||
bool m_bSave = false; // True if should save theses values
|
||||
};
|
||||
|
||||
} // namespace Fuge
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
1263
engines/bagel/hodjnpodj/garfunkle/garfunkle.cpp
Normal file
1263
engines/bagel/hodjnpodj/garfunkle/garfunkle.cpp
Normal file
File diff suppressed because it is too large
Load Diff
241
engines/bagel/hodjnpodj/garfunkle/garfunkle.h
Normal file
241
engines/bagel/hodjnpodj/garfunkle/garfunkle.h
Normal file
@@ -0,0 +1,241 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_GARFUNKLE_GARFUNKLE_H
|
||||
#define HODJNPODJ_GARFUNKLE_GARFUNKLE_H
|
||||
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Garkfunkle {
|
||||
|
||||
#define PLAY_FACTOR 150 // Multiply MilliSeconds by SpeedFactor for tenths of Seconds
|
||||
#define ANIM_SLEEP 200 // Milliseconds
|
||||
|
||||
// Button Identifier codes (BIDs)
|
||||
#define IDC_A 100
|
||||
#define IDC_B 101
|
||||
#define IDC_C 102
|
||||
#define IDC_D 103
|
||||
#define IDC_E 104
|
||||
#define IDC_F 105
|
||||
#define IDC_START 106
|
||||
|
||||
// Win condition values
|
||||
#define LOW_WIN 8 // Minimum number of notes in completed
|
||||
#define MEDIUM_WIN 10 //...sequence required to receive info
|
||||
#define HIGH_WIN 12 //...when playing from the metagame
|
||||
|
||||
// Backdrop bitmaps
|
||||
#define MAINSCREEN ".\\ART\\GARFEMPT.BMP"
|
||||
#define RIBBON ".\\ART\\RIBBON.BMP"
|
||||
|
||||
#define RIBBON_X 139
|
||||
#define RIBBON_Y 332
|
||||
|
||||
#define SIGN_COLOR RGB( 0, 0, 0 ) // Color of the sign text
|
||||
#define SIGN_LOCATION_X 117
|
||||
#define SIGN_LOCATION_Y 310
|
||||
#define SIGN_WIDTH 33
|
||||
#define SIGN_HEIGHT 30
|
||||
|
||||
#define VIOLIN_LOCATION_X 199
|
||||
#define VIOLIN_LOCATION_Y 210
|
||||
#define VIOLIN_WIDTH 57
|
||||
#define VIOLIN_HEIGHT 96
|
||||
|
||||
#define CELLO_LOCATION_X 257
|
||||
#define CELLO_LOCATION_Y 206
|
||||
#define CELLO_WIDTH 63
|
||||
#define CELLO_HEIGHT 101
|
||||
|
||||
#define DRUM_LOCATION_X 321
|
||||
#define DRUM_LOCATION_Y 208
|
||||
#define DRUM_WIDTH 57
|
||||
#define DRUM_HEIGHT 92
|
||||
|
||||
#define SAX_LOCATION_X 380
|
||||
#define SAX_LOCATION_Y 208
|
||||
#define SAX_WIDTH 55
|
||||
#define SAX_HEIGHT 99
|
||||
|
||||
#define HARP_LOCATION_X 141
|
||||
#define HARP_LOCATION_Y 194
|
||||
#define HARP_WIDTH 56
|
||||
#define HARP_HEIGHT 107
|
||||
|
||||
#define CLARINET_LOCATION_X 444
|
||||
#define CLARINET_LOCATION_Y 180
|
||||
#define CLARINET_WIDTH 46
|
||||
#define CLARINET_HEIGHT 127
|
||||
|
||||
#define NEWGAME_LOCATION_X 15
|
||||
#define NEWGAME_LOCATION_Y 0
|
||||
#define NEWGAME_WIDTH 217
|
||||
#define NEWGAME_HEIGHT 20
|
||||
|
||||
#define SIGN_LOCATION_X 117
|
||||
#define SIGN_LOCATION_Y 310
|
||||
#define SIGN_WIDTH 33
|
||||
#define SIGN_HEIGHT 30
|
||||
|
||||
#define WOODRIGHT_LOCATION_X 460
|
||||
#define WOODRIGHT_LOCATION_Y 25
|
||||
#define WOODRIGHT_WIDTH 164
|
||||
#define WOODRIGHT_HEIGHT 137
|
||||
|
||||
#define WOODLEFT_LOCATION_X 17
|
||||
#define WOODLEFT_LOCATION_Y 25
|
||||
#define WOODLEFT_WIDTH 137
|
||||
#define WOODLEFT_HEIGHT 148
|
||||
|
||||
#define BENCH_LOCATION_X 17
|
||||
#define BENCH_LOCATION_Y 404
|
||||
#define BENCH_WIDTH 610
|
||||
#define BENCH_HEIGHT 62
|
||||
|
||||
// Simon Button constants
|
||||
#define MIN_BUTTONS 3
|
||||
#define MAX_BUTTONS 6
|
||||
#define MAX_SEQUENCE 25
|
||||
|
||||
// Playback speed constants
|
||||
#define MIN_SPEED 0
|
||||
#define MAX_SPEED 11
|
||||
#define NUM_SPEEDS 12
|
||||
#define SLOW_DOWN 1 // take off this amount from time between notes on playback
|
||||
|
||||
#define PLAYER_TIMER 3 // can't wait forever for a note!
|
||||
#define ANIM_TIMER 4 // time to change frames
|
||||
#define TIME_LIMIT 10000 // 10 seconds for player response
|
||||
#define PAUSE_TIME 50 // in milliseconds, so = 1/2 sec
|
||||
#define INCREMENT_RATE 5 // rate by which speed is increased
|
||||
|
||||
#define RULES_TEXT "GARFUNK.TXT" // rules file
|
||||
|
||||
#define WIN_SOUND ".\\SOUND\\FANFARE1.WAV"
|
||||
#define WRONG_SOUND ".\\SOUND\\SOSORRY.WAV"
|
||||
#define SLOW_SOUND ".\\SOUND\\ALARM.WAV"
|
||||
#define SIGN_1_SOUND ".\\SOUND\\SIGN1.WAV"
|
||||
#define SIGN_2_SOUND ".\\SOUND\\SIGN2.WAV"
|
||||
#define SIGN_3_SOUND ".\\SOUND\\SIGN3.WAV"
|
||||
#define SIGN_4_SOUND ".\\SOUND\\SIGN4.WAV"
|
||||
#define SIGN_5_SOUND ".\\SOUND\\SIGN5.WAV"
|
||||
#define BENCH_SOUND ".\\SOUND\\MYSEAT.WAV"
|
||||
#define TREES_SOUND ".\\SOUND\\TIMBER.WAV"
|
||||
#define RULES_SOUND ".\\SOUND\\GARFUNK.WAV"
|
||||
|
||||
#define NUM_SIGN_SOUNDS 5
|
||||
|
||||
#define VIOLIN_SOUND ".\\SOUND\\viol2.mid"
|
||||
#define CELLO_SOUND ".\\SOUND\\cello2.mid"
|
||||
#define DRUM_SOUND ".\\SOUND\\DRUM2.MID" //drum.mid" //DRUM.WAV"
|
||||
#define SAX_SOUND ".\\SOUND\\sax2.mid"
|
||||
#define HARP_SOUND ".\\SOUND\\harp2.mid"
|
||||
#define CLARINET_SOUND ".\\SOUND\\clar2.mid"
|
||||
|
||||
#define VIOLIN_ANIM ".\\ART\\violin2.bmp"
|
||||
#define CELLO_ANIM ".\\ART\\cello2.bmp"
|
||||
#define DRUM_ANIM ".\\ART\\drums2.bmp"
|
||||
#define SAX_ANIM ".\\ART\\sax2.bmp"
|
||||
#define HARP_ANIM ".\\ART\\harp2.bmp"
|
||||
#define CLARINET_ANIM ".\\ART\\clari2.bmp"
|
||||
|
||||
#define VIOLIN_CELS 14
|
||||
#define CELLO_CELS 16
|
||||
#define DRUM_CELS 20
|
||||
#define SAX_CELS 14
|
||||
#define HARP_CELS 17
|
||||
#define CLARINET_CELS 18
|
||||
|
||||
#define VIOLIN_OFFSET_X 2
|
||||
#define CELLO_OFFSET_X 4
|
||||
#define DRUM_OFFSET_X 0
|
||||
#define SAX_OFFSET_X 2
|
||||
#define HARP_OFFSET_X 2
|
||||
#define CLARINET_OFFSET_X 5
|
||||
|
||||
#define VIOLIN_OFFSET_Y 16
|
||||
#define CELLO_OFFSET_Y 5
|
||||
#define DRUM_OFFSET_Y 3
|
||||
#define SAX_OFFSET_Y 4
|
||||
#define HARP_OFFSET_Y 0
|
||||
#define CLARINET_OFFSET_Y 4
|
||||
|
||||
//bool wait_awhile(int);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CMainWindow:
|
||||
// See game.cpp for the code to the member functions and the message map.
|
||||
//
|
||||
class CMainWindow : public CFrameWnd {
|
||||
public:
|
||||
CMainWindow();
|
||||
bool GetNewSequence(const char* pszFileName);
|
||||
bool GetNewSequence(int nLength);
|
||||
void ActivateButtons(unsigned int nNumActive, bool bState);
|
||||
void PlayBackSeries(int nNumNotes);
|
||||
void NewGame();
|
||||
void StartAnimation();
|
||||
void StopAnimation();
|
||||
bool wait_awhile(int nHundSecs);
|
||||
|
||||
//added data members:
|
||||
void SplashScreen();
|
||||
|
||||
private:
|
||||
void initStatics();
|
||||
void OnSoundNotify(CSound *pSound);
|
||||
|
||||
CRect rectMusic[MAX_BUTTONS]; // Musician locations
|
||||
|
||||
protected:
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
void OnDestroy();
|
||||
|
||||
//{{AFX_MSG( CMainWindow )
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnSysChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnSysKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
// afx_msg void OnKeyUp(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
|
||||
afx_msg void OnTimer(uintptr nIDEvent);
|
||||
afx_msg void OnLButtonDown(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnRButtonDown(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnActivate(unsigned int, CWnd*, bool) override;
|
||||
afx_msg void OnClose();
|
||||
afx_msg LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace Garfunkle
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
96
engines/bagel/hodjnpodj/garfunkle/init.cpp
Normal file
96
engines/bagel/hodjnpodj/garfunkle/init.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/garfunkle/garfunkle.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Garkfunkle {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
|
||||
LPGAMESTRUCT pGameInfo;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunGarf
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke poker
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
HWND FAR PASCAL RunGarf(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CMainWindow *pMain;
|
||||
|
||||
pGameInfo = lpGameInfo;
|
||||
|
||||
// invoke your game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMain = new CMainWindow) != nullptr) {
|
||||
|
||||
// pMain->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
// pMain->UpdateWindow();
|
||||
|
||||
pMain->SetActiveWindow();
|
||||
}
|
||||
|
||||
// these must be set in this function
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMain->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace Garfunkle
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
35
engines/bagel/hodjnpodj/garfunkle/init.h
Normal file
35
engines/bagel/hodjnpodj/garfunkle/init.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_GARFUNKLE_GAMEDLL_H
|
||||
#define HODJNPODJ_GARFUNKLE_GAMEDLL_H
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Garkfunkle {
|
||||
|
||||
extern HWND FAR PASCAL RunGarf(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
|
||||
|
||||
} // namespace Garfunkle
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
161
engines/bagel/hodjnpodj/garfunkle/note.cpp
Normal file
161
engines/bagel/hodjnpodj/garfunkle/note.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/garfunkle/note.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Garkfunkle {
|
||||
|
||||
CNote *CNote::m_pNoteHead = nullptr; // pointer to list of linked notes
|
||||
CNote *CNote::m_pNoteTail = nullptr; // pointer to tail of list of linked notes
|
||||
|
||||
IMPLEMENT_DYNCREATE(CNote, CObject)
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* CNote()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Constructor for note class.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
CNote::CNote() {
|
||||
m_nValue = 1;
|
||||
m_pNext = nullptr; // it is not yet in the sprite chain and
|
||||
m_pPrev = nullptr; // ... thus has no links to other sprites
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* ~CNote()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Destructor for note class.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
CNote::~CNote() {
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* SetValue()
|
||||
*
|
||||
* Parameters:
|
||||
* int nValue value which identifies the button associated with the note
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Identify the button to be played at this point in the sequence
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void CNote::SetValue(int nValue) {
|
||||
m_nValue = nValue; // identify the button to be played
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* LinkNote()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Link this note into the list by placing it at the
|
||||
* the tail of the list
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void CNote::LinkNote() {
|
||||
m_pNext = nullptr; // link note onto tail of list
|
||||
m_pPrev = m_pNoteTail; //... by pointing it back at the current
|
||||
//... tail, making it the tail, and
|
||||
if (m_pNoteTail) //... pointing it at nullptr (the list terminator)
|
||||
(*m_pNoteTail).m_pNext = this;
|
||||
else
|
||||
m_pNoteHead = this;
|
||||
m_pNoteTail = this;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* UnLinkNote()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Remove this sprite from the sprite chain and point its
|
||||
* neighbors at each other to fill the gap
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void CNote::UnLinkNote() {
|
||||
if (m_pPrev) // disconnect us from the note chain
|
||||
(*m_pPrev).m_pNext = m_pNext; // ... by pointing the one before us, and
|
||||
else // ... the one after us, at each other
|
||||
m_pNoteHead = m_pNext; // special case the instances where the
|
||||
// ... note to be removed is the first
|
||||
if (m_pNext) // ... or the last in the list, update
|
||||
(*m_pNext).m_pPrev = m_pPrev; // ... the head of chain pointer
|
||||
else
|
||||
m_pNoteTail = m_pPrev;
|
||||
|
||||
m_pNext = m_pPrev = nullptr;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* FlushNoteList()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Remove all notes from the chain and delete them via
|
||||
* the standard destructor
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void CNote::FlushNoteList() {
|
||||
CNote *pNote;
|
||||
|
||||
while ((pNote = CNote::GetNoteHead())) {
|
||||
(*pNote).UnLinkNote();
|
||||
delete pNote;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Garfunkle
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
75
engines/bagel/hodjnpodj/garfunkle/note.h
Normal file
75
engines/bagel/hodjnpodj/garfunkle/note.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_GARFUNKLE_NOTE_H
|
||||
#define HODJNPODJ_GARFUNKLE_NOTE_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/dibapi.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Garkfunkle {
|
||||
|
||||
class CNote : public CObject {
|
||||
DECLARE_DYNCREATE(CNote)
|
||||
|
||||
// Constructors
|
||||
public:
|
||||
CNote(); // use "new" operator to create notes, then SetValue
|
||||
|
||||
// Destructors
|
||||
public:
|
||||
~CNote();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
void SetValue(int nValue);
|
||||
int GetValue() const {
|
||||
return m_nValue;
|
||||
}
|
||||
void LinkNote();
|
||||
void UnLinkNote();
|
||||
CNote *GetNextNote() const {
|
||||
return m_pNext;
|
||||
}
|
||||
CNote *GetPrevNote() const {
|
||||
return m_pPrev;
|
||||
}
|
||||
|
||||
static CNote *GetNoteHead() {
|
||||
return m_pNoteHead;
|
||||
}
|
||||
static void FlushNoteList();
|
||||
|
||||
private:
|
||||
int m_nValue = 0;
|
||||
CNote *m_pNext = nullptr; // pointer to next note in chain
|
||||
CNote *m_pPrev = nullptr; // pointer to previous note in chain
|
||||
|
||||
static CNote *m_pNoteHead; // pointer to linked chain of notes
|
||||
static CNote *m_pNoteTail; // pointer to tail of list of notes
|
||||
};
|
||||
|
||||
} // namespace Garfunkle
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
355
engines/bagel/hodjnpodj/garfunkle/optndlg.cpp
Normal file
355
engines/bagel/hodjnpodj/garfunkle/optndlg.cpp
Normal file
@@ -0,0 +1,355 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/garfunkle/resource.h"
|
||||
#include "bagel/hodjnpodj/garfunkle/garfunkle.h"
|
||||
#include "bagel/hodjnpodj/garfunkle/optndlg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Garkfunkle {
|
||||
|
||||
static CPalette *pSubOptionsPalette;
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
|
||||
static CRadioButton *pGameButton = nullptr;
|
||||
static CRadioButton *pMusicButton = nullptr;
|
||||
|
||||
CText *m_pButtonsText = nullptr;
|
||||
CText *m_pSpeedText = nullptr;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg dialog
|
||||
|
||||
|
||||
COptnDlg::COptnDlg(CWnd* pParent, CPalette* pPalette)
|
||||
: CBmpDialog(pParent, pPalette, IDD_SUBOPTIONS, ".\\ART\\SSCROLL.BMP") {
|
||||
//{{AFX_DATA_INIT(COptnDlg)
|
||||
m_nSpeed = MIN_SPEED;
|
||||
m_nNumButtons = MAX_BUTTONS;
|
||||
m_bPlayGame = true;
|
||||
pSubOptionsPalette = pPalette;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
COptnDlg::~COptnDlg() {
|
||||
if (m_pButtonsText != nullptr)
|
||||
delete m_pButtonsText;
|
||||
if (m_pSpeedText != nullptr)
|
||||
delete m_pSpeedText;
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
void COptnDlg::DoDataExchange(CDataExchange* pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(COptnDlg)
|
||||
DDX_Control(pDX, IDC_NUMBUTTONS, m_ScrollButtons);
|
||||
DDX_Control(pDX, IDC_SPEED, m_ScrollSpeed);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(COptnDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(COptnDlg)
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_CREATE()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_DESTROY()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg message handlers
|
||||
|
||||
int COptnDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) {
|
||||
if (CBmpDialog::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool COptnDlg::OnInitDialog() {
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
CDC *pDC;
|
||||
CRect statRect;
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
mSpeedTable[0] = "Way Largo";
|
||||
mSpeedTable[1] = "Largo";
|
||||
mSpeedTable[2] = "Adagio";
|
||||
mSpeedTable[3] = "Andante";
|
||||
mSpeedTable[4] = "Andantino";
|
||||
mSpeedTable[5] = "Moderato";
|
||||
mSpeedTable[6] = "Allegretto";
|
||||
mSpeedTable[7] = "Allegro";
|
||||
mSpeedTable[8] = "Vivace";
|
||||
mSpeedTable[9] = "Presto";
|
||||
mSpeedTable[10] = "Prestissimo";
|
||||
mSpeedTable[11] = "Way Prestissimo";
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 26, LEFT_SIDE + 175, 41);
|
||||
if ((m_pButtonsText = new CText()) != nullptr) {
|
||||
(*m_pButtonsText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
m_ScrollButtons.SetScrollRange(MIN_BUTTONS, MAX_BUTTONS, 0);
|
||||
m_ScrollButtons.SetScrollPos(m_nNumButtons, true);
|
||||
|
||||
statRect.SetRect(LEFT_SIDE, 65, LEFT_SIDE + 175, 80);
|
||||
if ((m_pSpeedText = new CText()) != nullptr) {
|
||||
(*m_pSpeedText).SetupText(pDC, pSubOptionsPalette, &statRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
m_ScrollSpeed.SetScrollRange(MIN_SPEED, MAX_SPEED, 0);
|
||||
m_ScrollSpeed.SetScrollPos(m_nSpeed, true);
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pOKButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pCancelButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pCancelButton).SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pGameButton = new CRadioButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pGameButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pGameButton).SetControl(IDC_PLAYGAME, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
|
||||
if ((pMusicButton = new CRadioButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pMusicButton).SetPalette(pSubOptionsPalette); // set the palette to use
|
||||
(*pMusicButton).SetControl(IDC_PLAYMUSIC, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
return true; // return true unless you set the focus to a control
|
||||
}
|
||||
|
||||
void COptnDlg::OnDestroy() {
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
bool COptnDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
|
||||
switch (wParam) {
|
||||
|
||||
case IDC_PLAYGAME:
|
||||
m_bPlayGame = true;
|
||||
(*pGameButton).SetCheck(m_bPlayGame);
|
||||
(*pMusicButton).SetCheck(!m_bPlayGame);
|
||||
break;
|
||||
|
||||
case IDC_PLAYMUSIC:
|
||||
m_bPlayGame = false;
|
||||
(*pGameButton).SetCheck(m_bPlayGame);
|
||||
(*pMusicButton).SetCheck(!m_bPlayGame);
|
||||
break;
|
||||
|
||||
case IDOK:
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
} // end if
|
||||
|
||||
return true;
|
||||
|
||||
} // end OnCommand
|
||||
|
||||
|
||||
bool COptnDlg::OnEraseBkgnd(CDC *pDC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void COptnDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar) {
|
||||
int pMin,
|
||||
pMax;
|
||||
int OldPos = pScrollBar->GetScrollPos();
|
||||
int NewPos = OldPos;
|
||||
|
||||
pScrollBar->GetScrollRange(&pMin, &pMax);
|
||||
|
||||
switch (nSBCode) {
|
||||
case SB_LINERIGHT:
|
||||
case SB_PAGERIGHT:
|
||||
NewPos++;
|
||||
break;
|
||||
case SB_RIGHT:
|
||||
NewPos = pMax;
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
case SB_PAGELEFT:
|
||||
NewPos--;
|
||||
break;
|
||||
case SB_LEFT:
|
||||
NewPos = pMin;
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
NewPos = nPos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (NewPos < pMin) NewPos = pMin;
|
||||
if (NewPos > pMax) NewPos = pMax;
|
||||
|
||||
if (NewPos != OldPos) { //To prevent "flicker"
|
||||
(*pScrollBar).SetScrollPos(NewPos, true); //...only update when
|
||||
} //...changed
|
||||
|
||||
UpdateScrollbars();
|
||||
|
||||
CDialog::OnHScroll(nSBCode, NewPos, pScrollBar);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* UpdateScrollbars
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Updates data adjusted with scrollbars
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* none
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* CScrollbar pScrollTime, pScrollColumns, pScrollRows
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* int m_nTime, m_nNumParts, m_nColumns, m_nRows
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* void
|
||||
*
|
||||
****************************************************************/
|
||||
void COptnDlg::UpdateScrollbars() {
|
||||
int OldValue;
|
||||
CDC *pDC;
|
||||
char msg[64];
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
OldValue = m_nNumButtons;
|
||||
m_nNumButtons = m_ScrollButtons.GetScrollPos();
|
||||
if (OldValue != m_nNumButtons) {
|
||||
Common::sprintf_s(msg, "Number of Musicians: %d", m_nNumButtons);
|
||||
(*m_pButtonsText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
OldValue = m_nSpeed;
|
||||
m_nSpeed = m_ScrollSpeed.GetScrollPos();
|
||||
if (OldValue != m_nSpeed) {
|
||||
Common::sprintf_s(msg, "Speed: %s", mSpeedTable[m_nSpeed].c_str());
|
||||
(*m_pSpeedText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
void COptnDlg::OnOK() {
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
|
||||
void COptnDlg::OnCancel() {
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
}
|
||||
|
||||
void COptnDlg::OnPaint() {
|
||||
CDC *pDC;
|
||||
char msg[64];
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
Common::sprintf_s(msg, "Number of Musicians: %d", m_nNumButtons);
|
||||
(*m_pButtonsText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
Common::sprintf_s(msg, "Speed: %s", mSpeedTable[m_nSpeed].c_str());
|
||||
(*m_pSpeedText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
|
||||
|
||||
(*pGameButton).SetCheck(m_bPlayGame);
|
||||
(*pMusicButton).SetCheck(!m_bPlayGame);
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
}
|
||||
|
||||
void COptnDlg::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (pGameButton != nullptr) { // release the button
|
||||
delete pGameButton;
|
||||
pGameButton = nullptr;
|
||||
}
|
||||
|
||||
if (pMusicButton != nullptr) { // release the button
|
||||
delete pMusicButton;
|
||||
pMusicButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
} // namespace Garfunkle
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
82
engines/bagel/hodjnpodj/garfunkle/optndlg.h
Normal file
82
engines/bagel/hodjnpodj/garfunkle/optndlg.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_GARFUNKLE_OPTNDLG_H
|
||||
#define HODJNPODJ_GARFUNKLE_OPTNDLG_H
|
||||
|
||||
#include "bagel/hodjnpodj/garfunkle/resource.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Garkfunkle {
|
||||
|
||||
#define LEFT_SIDE 26
|
||||
#define OPTIONS_COLOR RGB(0, 0, 0) // Color of the stats info CText
|
||||
#define NUM_SPEEDS 12
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptnDlg dialog
|
||||
|
||||
class COptnDlg : public CBmpDialog {
|
||||
// Construction
|
||||
public:
|
||||
COptnDlg(CWnd* pParent = nullptr, CPalette *pPalette = nullptr); // standard constructor
|
||||
~COptnDlg(); // destructor
|
||||
void UpdateScrollbars();
|
||||
void ClearDialogImage();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(COptnDlg)
|
||||
enum { IDD = IDD_SUBOPTIONS };
|
||||
CScrollBar m_ScrollButtons;
|
||||
CScrollBar m_ScrollSpeed;
|
||||
bool m_bPlayGame;
|
||||
int m_nNumButtons;
|
||||
int m_nSpeed;
|
||||
CString mSpeedTable [NUM_SPEEDS];
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COptnDlg)
|
||||
virtual bool OnInitDialog() override;
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
afx_msg void OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar);
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
virtual void OnOK() override;
|
||||
virtual void OnCancel() override;
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnDestroy();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace Garfunkle
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user