Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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