Initial commit
This commit is contained in:
348
engines/bagel/hodjnpodj/hnplibs/audiocfg.cpp
Normal file
348
engines/bagel/hodjnpodj/hnplibs/audiocfg.cpp
Normal file
@@ -0,0 +1,348 @@
|
||||
/* 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/audiocfg.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/menures.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define ID_SCROLL1 105
|
||||
#define ID_MUSIC 109
|
||||
#define ID_SOUND 110
|
||||
|
||||
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
|
||||
|
||||
|
||||
CAudioCfgDlg::CAudioCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, IDD_AUDIOCFG, ".\\ART\\SSCROLL.BMP") {
|
||||
m_pScrollBar1 = nullptr;
|
||||
|
||||
DoModal();
|
||||
}
|
||||
|
||||
void CAudioCfgDlg::DoDataExchange(CDataExchange *pDX) {
|
||||
CBmpDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
void CAudioCfgDlg::PutDlgData() {
|
||||
m_pScrollBar1->SetScrollPos(m_nVolume);
|
||||
|
||||
m_pMusicButton->SetCheck(m_bMusic);
|
||||
m_pSoundButton->SetCheck(m_bSound);
|
||||
}
|
||||
|
||||
|
||||
void CAudioCfgDlg::GetDlgData() {
|
||||
m_nVolume = m_pScrollBar1->GetScrollPos();
|
||||
|
||||
m_bMusic = false;
|
||||
if (m_pMusicButton->GetCheck() == 1) {
|
||||
m_bMusic = true;
|
||||
}
|
||||
|
||||
m_bSound = false;
|
||||
if (m_pSoundButton->GetCheck() == 1) {
|
||||
m_bSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CAudioCfgDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
/*
|
||||
* respond to audio
|
||||
*/
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
|
||||
switch (wParam) {
|
||||
|
||||
case IDOK:
|
||||
SaveIniSettings();
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
return false;
|
||||
|
||||
case IDCANCEL:
|
||||
PostMessage(WM_CLOSE, 0, 0);
|
||||
return false;
|
||||
|
||||
case ID_MUSIC:
|
||||
m_bMusic = !m_bMusic;
|
||||
PutDlgData();
|
||||
break;
|
||||
|
||||
case ID_SOUND:
|
||||
m_bSound = !m_bSound;
|
||||
PutDlgData();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CBmpDialog::OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
void CAudioCfgDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar *pScroll) {
|
||||
int nMin = 0, nMax = 0, nVal = 0;
|
||||
|
||||
if (pScroll == m_pScrollBar1) {
|
||||
|
||||
nMin = LEVEL_MIN;
|
||||
nMax = LEVEL_MAX;
|
||||
nVal = m_nVolume;
|
||||
}
|
||||
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_LEFT:
|
||||
nVal = nMin;
|
||||
break;
|
||||
|
||||
case SB_PAGELEFT:
|
||||
nVal -= PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
if (nVal > nMin)
|
||||
nVal--;
|
||||
break;
|
||||
|
||||
case SB_RIGHT:
|
||||
nVal = nMax;
|
||||
break;
|
||||
|
||||
case SB_PAGERIGHT:
|
||||
nVal += PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINERIGHT:
|
||||
if (nVal < nMax)
|
||||
nVal++;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
nVal = nPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (nVal < nMin)
|
||||
nVal = nMin;
|
||||
if (nVal > nMax)
|
||||
nVal = nMax;
|
||||
|
||||
pScroll->SetScrollPos(nVal);
|
||||
|
||||
if (pScroll == m_pScrollBar1) {
|
||||
m_nVolume = nVal;
|
||||
UpdateOptions();
|
||||
} else
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
bool CAudioCfgDlg::OnInitDialog() {
|
||||
CRect tmpRect;
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
tmpRect.SetRect(54, 85, 168, 98);
|
||||
if ((m_pTxtVolume = new CText) != nullptr) {
|
||||
m_pTxtVolume->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(54, 100, 168, 118);
|
||||
if ((m_pScrollBar1 = new CScrollBar) != nullptr) {
|
||||
m_pScrollBar1->Create(WS_VISIBLE | WS_CHILD | SBS_HORZ | SBS_BOTTOMALIGN, tmpRect, this, ID_SCROLL1);
|
||||
m_pScrollBar1->SetScrollRange(LEVEL_MIN, LEVEL_MAX, true);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
pOKButton->SetPalette(m_pPalette); // set the palette to use
|
||||
pOKButton->SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
pCancelButton->SetPalette(m_pPalette); // set the palette to use
|
||||
pCancelButton->SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pMusicButton = new CCheckButton) != nullptr) {
|
||||
m_pMusicButton->SetPalette(m_pPalette);
|
||||
m_pMusicButton->SetControl(ID_MUSIC, this);
|
||||
if (!CSound::MidiAvailable())
|
||||
m_pMusicButton->EnableWindow(false);
|
||||
}
|
||||
|
||||
if ((m_pSoundButton = new CCheckButton) != nullptr) {
|
||||
m_pSoundButton->SetPalette(m_pPalette);
|
||||
m_pSoundButton->SetControl(ID_SOUND, this);
|
||||
if (!CSound::SoundAvailable())
|
||||
m_pSoundButton->EnableWindow(false);
|
||||
}
|
||||
|
||||
LoadIniSettings();
|
||||
|
||||
PutDlgData();
|
||||
|
||||
if (!CSound::SoundVolumeAvailable() && !CSound::MidiVolumeAvailable())
|
||||
m_pScrollBar1->EnableWindow(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CAudioCfgDlg::OnPaint() {
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
UpdateOptions();
|
||||
}
|
||||
|
||||
|
||||
void CAudioCfgDlg::UpdateOptions() {
|
||||
char buf[40];
|
||||
CDC *pDC;
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
if (m_pTxtVolume != nullptr) {
|
||||
if (CSound::SoundVolumeAvailable() || CSound::MidiVolumeAvailable())
|
||||
Common::sprintf_s(buf, "Volume: %d", m_nVolume);
|
||||
else
|
||||
Common::strcpy_s(buf, "Volume control not available");
|
||||
m_pTxtVolume->DisplayString(pDC, buf, 13, TEXT_NORMAL, RGB(0, 0, 0));
|
||||
}
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CAudioCfgDlg::OnEraseBkgnd(CDC *) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CAudioCfgDlg::OnClose() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pTxtVolume != nullptr) {
|
||||
delete m_pTxtVolume;
|
||||
m_pTxtVolume = nullptr;
|
||||
}
|
||||
|
||||
if (m_pScrollBar1 != nullptr) {
|
||||
delete m_pScrollBar1;
|
||||
m_pScrollBar1 = nullptr;
|
||||
}
|
||||
|
||||
if (m_pMusicButton != nullptr) {
|
||||
delete m_pMusicButton;
|
||||
m_pMusicButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pSoundButton != nullptr) {
|
||||
delete m_pSoundButton;
|
||||
m_pSoundButton = nullptr;
|
||||
}
|
||||
|
||||
ClearDialogImage();
|
||||
EndDialog(0);
|
||||
}
|
||||
|
||||
void CAudioCfgDlg::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (pCancelButton != nullptr) { // release the button
|
||||
delete pCancelButton;
|
||||
pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
|
||||
void CAudioCfgDlg::LoadIniSettings() {
|
||||
int nMidiVolume, nWaveVolume;
|
||||
|
||||
m_bMusic = GetPrivateProfileInt("Meta", "Music", true, "HODJPODJ.INI");
|
||||
m_bSound = GetPrivateProfileInt("Meta", "SoundEffects", true, "HODJPODJ.INI");
|
||||
|
||||
nMidiVolume = GetPrivateProfileInt("Meta", "MidiVolume", LEVEL_DEF, "HODJPODJ.INI");
|
||||
nWaveVolume = GetPrivateProfileInt("Meta", "WaveVolume", LEVEL_DEF, "HODJPODJ.INI");
|
||||
|
||||
if (nWaveVolume > nMidiVolume)
|
||||
m_nVolume = nWaveVolume;
|
||||
else
|
||||
m_nVolume = nMidiVolume;
|
||||
|
||||
if ((m_nVolume < LEVEL_MIN) || (m_nVolume > LEVEL_MAX))
|
||||
m_nVolume = LEVEL_DEF;
|
||||
|
||||
CSound::setVolume(m_nVolume, m_nVolume);
|
||||
}
|
||||
|
||||
void CAudioCfgDlg::SaveIniSettings() {
|
||||
WritePrivateProfileString("Meta", "Music", Common::String::format("%d", m_bMusic ? 1 : 0).c_str(), "HODJPODJ.INI");
|
||||
WritePrivateProfileString("Meta", "SoundEffects", Common::String::format("%d", m_bSound ? 1 : 0).c_str(), "HODJPODJ.INI");
|
||||
WritePrivateProfileString("Meta", "WaveVolume", Common::String::format("%d", m_nVolume).c_str(), "HODJPODJ.INI");
|
||||
WritePrivateProfileString("Meta", "MidiVolume", Common::String::format("%d", m_nVolume).c_str(), "HODJPODJ.INI");
|
||||
|
||||
CSound::setVolume(m_nVolume, m_nVolume);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAudioCfgDlg, CBmpDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
76
engines/bagel/hodjnpodj/hnplibs/audiocfg.h
Normal file
76
engines/bagel/hodjnpodj/hnplibs/audiocfg.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* 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_HNPLIBS_AUDIOCFG_H
|
||||
#define HODJNPODJ_HNPLIBS_AUDIOCFG_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define PAGE_SIZE 2
|
||||
#define LEVEL_MIN 1
|
||||
#define LEVEL_DEF ((VOLUME_INDEX_MAX * 3) >> 2)
|
||||
#define LEVEL_MAX VOLUME_INDEX_MAX
|
||||
|
||||
class CAudioCfgDlg : public CBmpDialog {
|
||||
public:
|
||||
CAudioCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void DoDataExchange(CDataExchange *) override;
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
virtual bool OnInitDialog() override;
|
||||
void PutDlgData();
|
||||
void GetDlgData();
|
||||
void LoadIniSettings();
|
||||
void SaveIniSettings();
|
||||
void UpdateOptions();
|
||||
void ClearDialogImage();
|
||||
|
||||
afx_msg bool OnEraseBkgnd(CDC *);
|
||||
void OnHScroll(unsigned int, unsigned int, CScrollBar *);
|
||||
void OnClose();
|
||||
void OnDestroy();
|
||||
void OnPaint();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CScrollBar *m_pScrollBar1 = nullptr;
|
||||
CCheckButton *m_pMusicButton = nullptr;
|
||||
CCheckButton *m_pSoundButton = nullptr;
|
||||
|
||||
CText *m_pTxtVolume = nullptr;
|
||||
|
||||
int m_nVolume = 0;
|
||||
bool m_bMusic = false;
|
||||
bool m_bSound = false;
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
1248
engines/bagel/hodjnpodj/hnplibs/bitmaps.cpp
Normal file
1248
engines/bagel/hodjnpodj/hnplibs/bitmaps.cpp
Normal file
File diff suppressed because it is too large
Load Diff
103
engines/bagel/hodjnpodj/hnplibs/bitmaps.h
Normal file
103
engines/bagel/hodjnpodj/hnplibs/bitmaps.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* 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_HNPLIBS_BITMAPS_H
|
||||
#define HODJNPODJ_HNPLIBS_BITMAPS_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/boflib/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
/**
|
||||
* Return a rectangular area of the screen in a CBitmap object.
|
||||
* @param pDC Pointer to device context to be used for display
|
||||
* @param pPalette Pointer to color palette to be used for the bitmap
|
||||
* @param x,y Upper left hand corner of bitmap to fetch
|
||||
* @param dx,dy Size of rectangular area to retrive
|
||||
* @return Pointer to bitmap object or nullptr
|
||||
*/
|
||||
extern CBitmap *FetchScreenBitmap(CDC *pDC, CPalette *pPalette, const int x, const int y, const int dx, const int dy);
|
||||
|
||||
/**
|
||||
* Loads a bitmap file
|
||||
* @param pDC Pointer to device context to be used for display
|
||||
* @param pPalette Address of pointer where to store palette from the DIB
|
||||
* @param pszPathName Pointer to path string for disk based DIB file
|
||||
* @return Pointer to bitmap object or nullptr
|
||||
*/
|
||||
extern CBitmap *FetchBitmap(CDC *pDC, CPalette **pPalette, const char *pszPathName);
|
||||
|
||||
/**
|
||||
* Loads a bitmap from a string named resource
|
||||
* @param pDC Pointer to device context to be used for display
|
||||
* @param pPalette Address of pointer where to store palette from the DIB
|
||||
* @param pszName Resource string name
|
||||
* @return Pointer to bitmap object or nullptr
|
||||
*/
|
||||
extern CBitmap *FetchResourceBitmap(CDC *pDC, CPalette **pPalette, const char *pszName);
|
||||
|
||||
/**
|
||||
* Loads a bitmap from a numeric Id resource
|
||||
* @param pDC Pointer to device context to be used for display
|
||||
* @param pPalette Address of pointer where to store palette from the DIB
|
||||
* @param nResID Resource Id
|
||||
* @return Pointer to bitmap object or nullptr
|
||||
*/
|
||||
extern CBitmap *FetchResourceBitmap(CDC *pDC, CPalette **pPalette, const int nResID);
|
||||
|
||||
/**
|
||||
* Creates a bitmap from a section of another bitmap
|
||||
* @param pDC Pointer to device context to be used for display
|
||||
* @param pBase Pointer to source bitmap for extraction
|
||||
* @param pPalette Pointer to color palette to be used for the bitmap
|
||||
* @param x,y Upper left hand corner of bitmap to fetch
|
||||
* @param dx,dy Size of rectangular area to retrive
|
||||
* @return Pointer to bitmap object or nullptr
|
||||
*/
|
||||
extern CBitmap *ExtractBitmap(CDC *pDC, CBitmap *pBitmap, CPalette *pPalette, const int x, const int y, const int dx, const int dy);
|
||||
|
||||
bool PaintBitmap(CDC *pDC, CPalette *pPalette, CBitmap *pBitmap, const int x = 0, const int y = 0, const int dx = 0, const int dy = 0);
|
||||
bool PaintBitmap(CDC *pDC, CPalette *pPalette, const char *pszName, const int x = 0, const int y = 0, const int dx = 0, const int dy = 0);
|
||||
|
||||
bool PaintMaskedBitmap(CDC *pDC, CPalette *pPalette, CBitmap *pBitmap, const int x = 0, const int y = 0, const int dx = 0, const int dy = 0);
|
||||
|
||||
bool PaintMaskedDIB(CDC *pDC, CPalette *pPalette, const char *pszName, const int x = 0, const int y = 0, const int dx = 0, const int dy = 0);
|
||||
bool PaintMaskedDIB(CDC *pDC, CPalette *pPalette, CDibDoc *pDIB, const int x = 0, const int y = 0, const int dx = 0, const int dy = 0);
|
||||
bool PaintMaskedResource(CDC *pDC, CPalette *pPalette, const int resId, const int x = 0, const int y = 0, const int dx = 0, const int dy = 0);
|
||||
bool PaintMaskedResource(CDC *pDC, CPalette *pPalette, const char *pszPathName, const int x = 0, const int y = 0, const int dx = 0, const int dy = 0);
|
||||
|
||||
bool PaintBlockEffect(CDC *pDC, CBitmap *pBitmap, CPalette *pPalette, int nBlockSize);
|
||||
bool PaintBlockEffect(CDC *pDC, CDibDoc *pDIB, CPalette *pPalette, int nBlockSize);
|
||||
bool PaintBlockEffect(CDC *pDC, COLORREF rgbColor, CPalette *pPalette, int nBlockSize, int nX, int nY, int nWidth, int nHeight);
|
||||
|
||||
bool BltBitmap(CDC *pDC, CPalette *pPalette, CBitmap *pBitmap, CRect *pSrcRect, CRect *pDstRect, uint32 nMode);
|
||||
bool BltMaskedBitmap(CDC *pDC, CPalette *pPalette, CBitmap *pBitmap, CRect *pSrcRect, const int x, const int y);
|
||||
|
||||
CSize GetBitmapSize(CBitmap *pBitmap);
|
||||
CPalette *GetPalette(CDC *pDC, const char *pszBmpName);
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
1717
engines/bagel/hodjnpodj/hnplibs/button.cpp
Normal file
1717
engines/bagel/hodjnpodj/hnplibs/button.cpp
Normal file
File diff suppressed because it is too large
Load Diff
263
engines/bagel/hodjnpodj/hnplibs/button.h
Normal file
263
engines/bagel/hodjnpodj/hnplibs/button.h
Normal file
@@ -0,0 +1,263 @@
|
||||
/* 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_HNPLIBS_BUTTON_H
|
||||
#define HODJNPODJ_HNPLIBS_BUTTON_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/bitmaps.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define BUTTON_EDGE_WIDTH 3
|
||||
#define FOCUS_RECT_DX 2
|
||||
#define FOCUS_RECT_DY 1
|
||||
#define SELECTED_TEXT_DX 1
|
||||
#define SELECTED_TEXT_DY 1
|
||||
#define CHECK_BOX_SIZE 13
|
||||
#define CHECK_BOX_DX 4
|
||||
#define CHECK_TEXT_DX 22
|
||||
#define RADIO_BOX_SIZE 13
|
||||
#define RADIO_BOX_DX 4
|
||||
#define RADIO_TEXT_DX 22
|
||||
|
||||
#define RGB_BUTTON_FACE PALETTERGB(199,167,139) // PALETTERGB(207,159,115)
|
||||
#define RGB_BUTTON_HIGHLIGHT PALETTERGB(223,199,175)
|
||||
#define RGB_BUTTON_SHADOW PALETTERGB(155,123,95)
|
||||
#define RGB_BUTTON_TEXT PALETTERGB(51,31,19) // PALETTERGB(83,59,1)
|
||||
#define RGB_BUTTON_TEXT_DISABLE PALETTERGB(155,139,123)
|
||||
#define RGB_BUTTON_OUTLINE PALETTERGB(83,59,51) // PALETTERGB(83,59,1)
|
||||
|
||||
#define RGB_CHECK_FACE PALETTERGB(199,167,139) // PALETTERGB(207,159,115)
|
||||
#define RGB_CHECK_CONTROL PALETTERGB(99,15,7)
|
||||
#define RGB_CHECK_TEXT PALETTERGB(51,31,19) // PALETTERGB(83,59,1)
|
||||
#define RGB_CHECK_TEXT_DISABLE PALETTERGB(155,139,123)
|
||||
#define RGB_CHECK_OUTLINE PALETTERGB(83,59,51) // PALETTERGB(207,159,115)
|
||||
|
||||
#define RGB_RADIO_FACE PALETTERGB(199,167,139) // PALETTERGB(207,159,115)
|
||||
#define RGB_RADIO_CONTROL PALETTERGB(99,15,7)
|
||||
#define RGB_RADIO_TEXT PALETTERGB(51,31,19) // PALETTERGB(83,59,1)
|
||||
#define RGB_RADIO_TEXT_DISABLE PALETTERGB(155,139,123)
|
||||
#define RGB_RADIO_OUTLINE PALETTERGB(83,59,51) // PALETTERGB(207,159,115)
|
||||
|
||||
|
||||
class CBmpButton : public CBitmapButton {
|
||||
DECLARE_DYNCREATE(CBmpButton)
|
||||
|
||||
// Constructors
|
||||
public:
|
||||
CBmpButton(); // use "new" operator to create buttons, then LoadButton
|
||||
|
||||
// Destructors
|
||||
public:
|
||||
~CBmpButton();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
bool SetControl(unsigned int nID, CWnd * pParent);
|
||||
bool AutoLoad(unsigned int nID, CWnd * pParent);
|
||||
|
||||
bool LoadBitmaps(CPalette *pPalette, CBitmap *pBase, CBitmap *pSelected, CBitmap *pFocus, CBitmap *pDisabled);
|
||||
bool LoadBitmaps(const char *lpszBase, const char *lpszSelected = nullptr, const char *lpszFocus = nullptr, const char *lpszDisabled = nullptr);
|
||||
bool LoadBitmaps(const int nBase, const int nSelected = 0, const int nFocus = 0, const int nDisabled = 0);
|
||||
bool LoadBmpBitmaps(const char *lpszBase, const char *lpszSelected = nullptr, const char *lpszFocus = nullptr, const char *lpszDisabled = nullptr);
|
||||
|
||||
private:
|
||||
CPalette *m_pPalette;
|
||||
//bool m_bSharedPalette;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Given inaccuracies in the ScummVM dialog template
|
||||
* system, the co-ordinates determined for buttons
|
||||
* may be slightly too small for the bitmaps we load.
|
||||
* If so, we need to increase the bounds to accommodate.
|
||||
*/
|
||||
void ensureSize();
|
||||
|
||||
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) override;
|
||||
|
||||
//{{AFX_MSG( CBmpButton )
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMaskedButton : public CBmpButton {
|
||||
DECLARE_DYNCREATE(CMaskedButton)
|
||||
|
||||
// Constructors
|
||||
public:
|
||||
CMaskedButton(); // use "new" operator to create buttons, then LoadButton
|
||||
|
||||
// Destructors
|
||||
public:
|
||||
~CMaskedButton();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
|
||||
private:
|
||||
CPalette *m_pPalette;
|
||||
CBitmap *m_pBackground;
|
||||
|
||||
private:
|
||||
|
||||
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) override;
|
||||
|
||||
//{{AFX_MSG( CMaskedButton )
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CColorButton : public CButton {
|
||||
DECLARE_DYNCREATE(CColorButton)
|
||||
|
||||
// Constructors
|
||||
public:
|
||||
CColorButton(); // use "new" operator to create buttons, then LoadButton
|
||||
|
||||
// Destructors
|
||||
public:
|
||||
~CColorButton();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
bool SetControl(unsigned int nID, CWnd * pParent);
|
||||
void SetPalette(CPalette *pPalette);
|
||||
void SetColors(CPalette *pPalette, COLORREF cFace, COLORREF cHighlight, COLORREF cShadow, COLORREF cText, COLORREF cTextDisabled, COLORREF cOutline);
|
||||
|
||||
private:
|
||||
CPalette *m_pPalette;
|
||||
COLORREF m_cButtonFace;
|
||||
COLORREF m_cButtonHighlight;
|
||||
COLORREF m_cButtonShadow;
|
||||
COLORREF m_cButtonText;
|
||||
COLORREF m_cButtonTextDisabled;
|
||||
COLORREF m_cButtonOutline;
|
||||
|
||||
private:
|
||||
|
||||
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) override;
|
||||
|
||||
//{{AFX_MSG( CColorButton )
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CCheckButton : public CButton {
|
||||
DECLARE_DYNCREATE(CCheckButton)
|
||||
|
||||
// Constructors
|
||||
public:
|
||||
CCheckButton(); // use "new" operator to create buttons, then LoadButton
|
||||
|
||||
// Destructors
|
||||
public:
|
||||
~CCheckButton();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
bool SetControl(unsigned int nID, CWnd * pParent);
|
||||
void SetPalette(CPalette *pPalette);
|
||||
void SetColors(CPalette *pPalette, COLORREF cFace, COLORREF cControl, COLORREF cText, COLORREF cTextDisabled, COLORREF cOutline);
|
||||
|
||||
private:
|
||||
bool m_bCheckState;
|
||||
CPalette *m_pPalette;
|
||||
COLORREF m_cButtonFace;
|
||||
COLORREF m_cButtonControl;
|
||||
COLORREF m_cButtonText;
|
||||
COLORREF m_cButtonTextDisabled;
|
||||
COLORREF m_cButtonOutline;
|
||||
|
||||
private:
|
||||
|
||||
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) override;
|
||||
|
||||
//{{AFX_MSG( CCheckButton )
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
afx_msg LRESULT OnSetCheck(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnGetCheck(WPARAM, LPARAM);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CRadioButton : public CButton {
|
||||
DECLARE_DYNCREATE(CRadioButton)
|
||||
|
||||
// Constructors
|
||||
public:
|
||||
CRadioButton(); // use "new" operator to create buttons, then LoadButton
|
||||
|
||||
// Destructors
|
||||
public:
|
||||
~CRadioButton();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
bool SetControl(unsigned int nID, CWnd * pParent);
|
||||
void SetPalette(CPalette *pPalette);
|
||||
void SetColors(CPalette *pPalette, COLORREF cFace, COLORREF cControl, COLORREF cText, COLORREF cTextDisabled, COLORREF cOutline);
|
||||
|
||||
private:
|
||||
bool m_bCheckState;
|
||||
CPalette *m_pPalette;
|
||||
COLORREF m_cButtonFace;
|
||||
COLORREF m_cButtonControl;
|
||||
COLORREF m_cButtonText;
|
||||
COLORREF m_cButtonTextDisabled;
|
||||
COLORREF m_cButtonOutline;
|
||||
|
||||
private:
|
||||
|
||||
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) override;
|
||||
|
||||
//{{AFX_MSG( CRadioButton )
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
afx_msg LRESULT OnSetCheck(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnGetCheck(WPARAM, LPARAM);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
278
engines/bagel/hodjnpodj/hnplibs/cbofdlg.cpp
Normal file
278
engines/bagel/hodjnpodj/hnplibs/cbofdlg.cpp
Normal file
@@ -0,0 +1,278 @@
|
||||
/* 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/bitmaps.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
CBmpDialog::CBmpDialog(CWnd *pParent, CPalette *pPalette, int nID, const char *pFileName, const int dx, const int dy, bool bSaveBackground)
|
||||
: CDialog(nID, pParent) {
|
||||
// can't access null pointers
|
||||
//
|
||||
assert(pParent != nullptr);
|
||||
assert(pPalette != nullptr);
|
||||
assert(pFileName != nullptr);
|
||||
|
||||
// Inits
|
||||
//
|
||||
m_pDlgBackground = nullptr;
|
||||
m_pParentWnd = pParent;
|
||||
m_pPalette = pPalette;
|
||||
m_pBmpFileName = pFileName;
|
||||
m_nDx = dx;
|
||||
m_nDy = dy;
|
||||
m_bSaveBackground = bSaveBackground;
|
||||
|
||||
//{{AFX_DATA_INIT(CBmpDialog)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
CBmpDialog::CBmpDialog(CWnd *pParent, CPalette *pPalette, int nID, int nBmpID, const int dx, const int dy, bool bSaveBackground)
|
||||
: CDialog(nID, pParent) {
|
||||
// can't access null pointers
|
||||
//
|
||||
assert(pParent != nullptr);
|
||||
assert(pPalette != nullptr);
|
||||
|
||||
// Inits
|
||||
//
|
||||
m_pDlgBackground = nullptr;
|
||||
m_pBmpFileName = nullptr;
|
||||
m_pParentWnd = pParent;
|
||||
m_pPalette = pPalette;
|
||||
m_nBmpID = nBmpID;
|
||||
m_nDx = dx;
|
||||
m_nDy = dy;
|
||||
m_bSaveBackground = bSaveBackground;
|
||||
|
||||
//{{AFX_DATA_INIT(CBmpDialog)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::DoDataExchange(CDataExchange *pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CBmpDialog)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::EndDialog(int nResult) {
|
||||
if (m_pDlgBackground != nullptr) {
|
||||
RefreshBackground();
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
CDialog::EndDialog(nResult);
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::OnDestroy() {
|
||||
bool bUpdateNeeded;
|
||||
|
||||
//
|
||||
// delete the bitmap created with FetchScreenBitmap
|
||||
//
|
||||
if (m_pDlgBackground != nullptr) {
|
||||
m_pDlgBackground->DeleteObject();
|
||||
delete m_pDlgBackground;
|
||||
m_pDlgBackground = nullptr;
|
||||
|
||||
bUpdateNeeded = (*m_pParentWnd).GetUpdateRect(nullptr, false);
|
||||
if (bUpdateNeeded)
|
||||
(*m_pParentWnd).ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
CDialog::OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
bool CBmpDialog::OnInitDialog() {
|
||||
CRect cDlgRect, cWindRect;
|
||||
int iDlgWidth, iDlgHeight; // size of dialog box
|
||||
CDC *pDC;
|
||||
CBitmap *pBitmap;
|
||||
CSize cSize;
|
||||
|
||||
CDialog::OnInitDialog(); // do basic dialog initialization
|
||||
|
||||
// get the button's position and size
|
||||
|
||||
(*m_pParentWnd).GetWindowRect(&cWindRect); // get pos/size of parent
|
||||
((CWnd *)this)->GetWindowRect(&cDlgRect); // get pos/size of dialog
|
||||
|
||||
pDC = GetDC();
|
||||
assert(pDC != nullptr);
|
||||
|
||||
if (m_pBmpFileName == nullptr) // try to fetch the bitmap
|
||||
pBitmap = FetchResourceBitmap(pDC, nullptr, m_nBmpID);
|
||||
else
|
||||
pBitmap = FetchBitmap(pDC, nullptr, m_pBmpFileName);
|
||||
if (pBitmap == nullptr) { // no luck, so use what we know
|
||||
iDlgWidth = cDlgRect.right - cDlgRect.left; // dlg box width
|
||||
iDlgHeight = cDlgRect.bottom - cDlgRect.top; // dlg box height
|
||||
} else {
|
||||
cSize = GetBitmapSize(pBitmap); // actual width and height from bitmap
|
||||
iDlgWidth = cSize.cx;
|
||||
iDlgHeight = cSize.cy;
|
||||
delete pBitmap;
|
||||
}
|
||||
|
||||
// modify code below to center dialog box based on GAME_WIDTH and GAME_HEIGHT
|
||||
// center the dialog box on the screen
|
||||
|
||||
if (m_nDx == -1) { // no horizontal location, so center
|
||||
//...the dialog box horizontally
|
||||
cDlgRect.left = cWindRect.left + (cWindRect.right - cWindRect.left - iDlgWidth) / 2;
|
||||
} else { // want it in a specific horiz.loc.
|
||||
cDlgRect.left = cWindRect.left + m_nDx;
|
||||
}
|
||||
cDlgRect.right = cDlgRect.left + iDlgWidth; // set the right side
|
||||
|
||||
if (m_nDy == -1) { // no vertical location, so center
|
||||
//...the dialog box vertically
|
||||
cDlgRect.top = cWindRect.top + (cWindRect.bottom - cWindRect.top - iDlgHeight) / 2;
|
||||
} else { // want it in a specific vertical loc.
|
||||
cDlgRect.top = cWindRect.top + m_nDy;
|
||||
}
|
||||
cDlgRect.bottom = cDlgRect.top + iDlgHeight;
|
||||
|
||||
MoveWindow(&cDlgRect, false); // position window, don't repaint
|
||||
|
||||
// if we are saving the background
|
||||
//
|
||||
if (m_bSaveBackground) {
|
||||
// save a copy of the background
|
||||
m_pDlgBackground = FetchScreenBitmap(pDC, m_pPalette, 0, 0, iDlgWidth, iDlgHeight);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
return true; // return true unless focused on a control
|
||||
}
|
||||
|
||||
|
||||
bool CBmpDialog::OnEraseBkgnd(CDC *pDC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::RefreshBackground(CDC *pDC) {
|
||||
CDC *pMyDC;
|
||||
|
||||
// paint back the background
|
||||
//
|
||||
if (m_pDlgBackground != nullptr) {
|
||||
if (pDC == nullptr) {
|
||||
if ((pMyDC = GetDC()) != nullptr) {
|
||||
PaintBitmap(pMyDC, m_pPalette, m_pDlgBackground, 0, 0);
|
||||
ReleaseDC(pMyDC);
|
||||
}
|
||||
} else
|
||||
PaintBitmap(pDC, m_pPalette, m_pDlgBackground, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::OnPaint() {
|
||||
InvalidateRect(nullptr, false);
|
||||
|
||||
CPaintDC dc(this); // device context for painting
|
||||
CPalette *pPalOld = nullptr;
|
||||
bool bSuccess;
|
||||
|
||||
if (m_pPalette != nullptr) {
|
||||
pPalOld = dc.SelectPalette(m_pPalette, false);
|
||||
dc.RealizePalette();
|
||||
}
|
||||
|
||||
// repaint the background behind the dialog
|
||||
//
|
||||
RefreshBackground(&dc);
|
||||
|
||||
if (m_pDlgBackground != nullptr) {
|
||||
bSuccess = PaintBitmap(&dc, m_pPalette, m_pDlgBackground, 0, 0);
|
||||
assert(bSuccess);
|
||||
}
|
||||
|
||||
// paint the dialog (uses bitmap instead of standard windows dialog)
|
||||
//
|
||||
if (m_pBmpFileName != nullptr) {
|
||||
bSuccess = PaintMaskedDIB(&dc, m_pPalette, m_pBmpFileName, 0, 0);
|
||||
} else {
|
||||
bSuccess = PaintMaskedResource(&dc, m_pPalette, m_nBmpID, 0, 0);
|
||||
}
|
||||
|
||||
assert(bSuccess);
|
||||
|
||||
if (m_pPalette != nullptr)
|
||||
dc.SelectPalette(pPalOld, false);
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::OnShowWindow(bool bShow, unsigned int nStatus) {
|
||||
CDialog::OnShowWindow(bShow, nStatus);
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::OnSize(unsigned int nType, int cx, int cy) {
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
}
|
||||
|
||||
|
||||
int CBmpDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) {
|
||||
if (CDialog::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::OnLButtonDown(unsigned int nFlags, CPoint point) {
|
||||
CDialog::OnLButtonDown(nFlags, point);
|
||||
}
|
||||
|
||||
|
||||
void CBmpDialog::OnMouseMove(unsigned int nFlags, CPoint point) {
|
||||
CDialog::OnMouseMove(nFlags, point);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CBmpDialog, CDialog)
|
||||
//{{AFX_MSG_MAP(CBmpDialog)
|
||||
ON_WM_CREATE()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_SHOWWINDOW()
|
||||
ON_WM_SIZE()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_NCMOUSEMOVE()
|
||||
ON_WM_DESTROY()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
76
engines/bagel/hodjnpodj/hnplibs/cbofdlg.h
Normal file
76
engines/bagel/hodjnpodj/hnplibs/cbofdlg.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* 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_HNPLIBS_CBOFDLG_H
|
||||
#define HODJNPODJ_HNPLIBS_CBOFDLG_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
class CBmpDialog : public CDialog {
|
||||
public:
|
||||
// Construction
|
||||
CBmpDialog(CWnd *, CPalette *, int, const char *, const int dx = -1, const int dy = -1, bool bSaveBackground = true);
|
||||
CBmpDialog(CWnd *, CPalette *, int, int, const int dx = -1, const int dy = -1, bool bSaveBackground = true);
|
||||
|
||||
void RefreshBackground(CDC *pDC = nullptr);
|
||||
|
||||
private:
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CBmpDialog)
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
protected:
|
||||
// Implementation
|
||||
void EndDialog(int);
|
||||
void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CBmpDialog)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
bool OnInitDialog() override;
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg void OnShowWindow(bool bShow, unsigned int nStatus);
|
||||
afx_msg void OnSize(unsigned int nType, int cx, int cy);
|
||||
afx_msg void OnMouseMove(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnLButtonDown(unsigned int nFlags, CPoint point);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CBitmap *m_pDlgBackground = nullptr;
|
||||
CPalette *m_pPalette = nullptr;
|
||||
const char *m_pBmpFileName = nullptr;
|
||||
int m_nBmpID = 0;
|
||||
int m_nDx = 0;
|
||||
int m_nDy = 0;
|
||||
bool m_bSaveBackground = false;
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
191
engines/bagel/hodjnpodj/hnplibs/cmessbox.cpp
Normal file
191
engines/bagel/hodjnpodj/hnplibs/cmessbox.cpp
Normal file
@@ -0,0 +1,191 @@
|
||||
/* 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/cmessbox.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/menures.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cmessbox.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
|
||||
|
||||
CMessageBox::CMessageBox(CWnd* pParent, CPalette *pPalette, const char *msg1, const char *msg2, const int dx, const int dy)
|
||||
: CBmpDialog(pParent, pPalette, IDD_GAMEOVER, ".\\ART\\SSCROLL.BMP", dx, dy) {
|
||||
// Initialize all members
|
||||
//
|
||||
m_pPalette = pPalette;
|
||||
m_pMessage1 = msg1;
|
||||
m_pMessage2 = msg2;
|
||||
|
||||
m_cTextMessage1 = nullptr;
|
||||
m_cTextMessage2 = nullptr;
|
||||
|
||||
DoModal();
|
||||
|
||||
//{{AFX_DATA_INIT(CMessageBox)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CMessageBox::ClearDialogImage() {
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
void CMessageBox::OnDestroy() {
|
||||
if (m_cTextMessage1 != nullptr) {
|
||||
delete m_cTextMessage1;
|
||||
m_cTextMessage1 = nullptr;
|
||||
}
|
||||
|
||||
if (m_cTextMessage2 != nullptr) {
|
||||
delete m_cTextMessage2;
|
||||
m_cTextMessage2 = nullptr;
|
||||
}
|
||||
|
||||
if (pOKButton != nullptr) { // release the button
|
||||
delete pOKButton;
|
||||
pOKButton = nullptr;
|
||||
}
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
void CMessageBox::DoDataExchange(CDataExchange* pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CMessageBox)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMessageBox, CDialog)
|
||||
//{{AFX_MSG_MAP(CMessageBox)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_DESTROY()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMessageBox message handlers
|
||||
|
||||
bool CMessageBox::OnInitDialog() {
|
||||
CRect statsRect; // game stats displays
|
||||
int nStat_col_offset; // game stats placement
|
||||
int nStat_row_offset;
|
||||
int nStatWidth, nStatHeight;
|
||||
bool bAssertCheck;
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
|
||||
pDC = GetDC();
|
||||
// setup the Starting Villages stat display box
|
||||
nStat_col_offset = MESSAGE_COL;
|
||||
nStat_row_offset = MESSAGE_ROW;
|
||||
nStatWidth = MESSAGE_WIDTH;
|
||||
nStatHeight = MESSAGE_HEIGHT;
|
||||
statsRect.SetRect(
|
||||
nStat_col_offset,
|
||||
nStat_row_offset,
|
||||
nStat_col_offset + nStatWidth,
|
||||
nStat_row_offset + nStatHeight
|
||||
);
|
||||
|
||||
if ((m_cTextMessage1 = new CText()) != nullptr) {
|
||||
bAssertCheck = (*m_cTextMessage1).SetupText(pDC, m_pPalette, &statsRect, JUSTIFY_CENTER);
|
||||
ASSERT(bAssertCheck); // initialize the text objext
|
||||
}
|
||||
|
||||
nStat_row_offset += MESSAGE2_ROW_OFFSET;
|
||||
statsRect.SetRect(
|
||||
nStat_col_offset,
|
||||
nStat_row_offset,
|
||||
nStat_col_offset + nStatWidth,
|
||||
nStat_row_offset + nStatHeight
|
||||
);
|
||||
|
||||
if ((m_cTextMessage2 = new CText()) != nullptr) {
|
||||
bAssertCheck = (*m_cTextMessage2).SetupText(pDC, m_pPalette, &statsRect, JUSTIFY_CENTER);
|
||||
ASSERT(bAssertCheck); // initialize the text objext
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
|
||||
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*pOKButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
return true; // return true unless you set the focus to a control
|
||||
}
|
||||
|
||||
void CMessageBox::OnPaint() {
|
||||
// TODO: Add your message handler code here
|
||||
CDC *pDC;
|
||||
bool bAssertCheck;
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
// Do not call CDialog::OnPaint() for painting messages
|
||||
|
||||
pDC = GetDC();
|
||||
|
||||
if (m_pMessage1 != nullptr) {
|
||||
bAssertCheck = (*m_cTextMessage1).DisplayString(pDC, m_pMessage1, 21, FW_BOLD, TEXT_COLOR);
|
||||
ASSERT(bAssertCheck);
|
||||
}
|
||||
|
||||
if (m_pMessage2 != nullptr) {
|
||||
bAssertCheck = (*m_cTextMessage2).DisplayString(pDC, m_pMessage2, 21, FW_BOLD, TEXT_COLOR);
|
||||
ASSERT(bAssertCheck);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
void CMessageBox::OnOK() {
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
|
||||
void CMessageBox::OnCancel() {
|
||||
ClearDialogImage();
|
||||
EndDialog(IDCANCEL);
|
||||
}
|
||||
|
||||
bool CMessageBox::OnEraseBkgnd(CDC *pDC) {
|
||||
// Prevents refreshing of background
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
81
engines/bagel/hodjnpodj/hnplibs/cmessbox.h
Normal file
81
engines/bagel/hodjnpodj/hnplibs/cmessbox.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* 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_HNPLIBS_CMESSBOX_H
|
||||
#define HODJNPODJ_HNPLIBS_CMESSBOX_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define TEXT_COLOR RGB(0, 0, 0) // displayed text color
|
||||
|
||||
#define MESSAGE_COL 16 // first message box positioning
|
||||
#define MESSAGE_ROW 60
|
||||
|
||||
#define MESSAGE_WIDTH 186 // standard message box dims
|
||||
#define MESSAGE_HEIGHT 20
|
||||
|
||||
#define MESSAGE2_ROW_OFFSET ( MESSAGE_HEIGHT + 4 ) // Row offset from first
|
||||
// message box
|
||||
|
||||
#define IDD_GAMEOVER 201
|
||||
|
||||
class CMessageBox : public CBmpDialog {
|
||||
private:
|
||||
CText *m_cTextMessage1, *m_cTextMessage2;
|
||||
const char *m_pMessage1, *m_pMessage2;
|
||||
|
||||
public:
|
||||
// standard constructor
|
||||
CMessageBox(CWnd *pParent, CPalette *pPalette, const char *msg1, const char *msg2 = nullptr, const int dx = -1, const int dy = -1);
|
||||
|
||||
void ClearDialogImage();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CMessageBox)
|
||||
enum { IDD = IDD_GAMEOVER };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
protected:
|
||||
// Implementation
|
||||
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CMessageBox)
|
||||
afx_msg void OnPaint();
|
||||
virtual void OnOK() override;
|
||||
virtual void OnCancel() override;
|
||||
virtual bool OnInitDialog() override;
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
419
engines/bagel/hodjnpodj/hnplibs/dibapi.cpp
Normal file
419
engines/bagel/hodjnpodj/hnplibs/dibapi.cpp
Normal file
@@ -0,0 +1,419 @@
|
||||
/* 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 "graphics/palette.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibapi.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
static BITMAPINFOHEADER getDIBInfoHeader(HDIB hDib) {
|
||||
BITMAPINFOHEADER h;
|
||||
h.biSize = 40;
|
||||
h.biWidth = hDib->w;
|
||||
h.biHeight = hDib->h;
|
||||
h.biPlanes = 1;
|
||||
h.biBitCount = 8;
|
||||
h.biCompression = BI_RGB;
|
||||
h.biSizeImage = 0;
|
||||
h.biXPelsPerMeter = 0;
|
||||
h.biYPelsPerMeter = 0;
|
||||
h.biClrUsed = !hDib->hasPalette() ? 0 :
|
||||
hDib->grabPalette()->size();
|
||||
h.biClrImportant = 0;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
static BITMAPINFO *getDIBInfo(HDIB hDib) {
|
||||
BITMAPINFO *h = (BITMAPINFO *)malloc(
|
||||
sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
||||
|
||||
h->bmiHeader = getDIBInfoHeader(hDib);
|
||||
|
||||
const Graphics::Palette *pal = hDib->grabPalette();
|
||||
for (uint i = 0; i < h->bmiHeader.biClrUsed; ++i) {
|
||||
auto &col = h->bmiColors[i];
|
||||
pal->get(i, col.rgbRed, col.rgbGreen, col.rgbBlue);
|
||||
col.rgbReserved = 0;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* PaintDIB()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* HDC hDC - DC to do output to
|
||||
*
|
||||
* LPRECT lpDCRect - rectangle on DC to do output to
|
||||
*
|
||||
* HDIB hDIB - handle to global memory with a DIB spec
|
||||
* in it followed by the DIB bits
|
||||
*
|
||||
* LPRECT lpDIBRect - rectangle of DIB to output into lpDCRect
|
||||
*
|
||||
* CPalette* pPal - pointer to CPalette containing DIB's palette
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* bool - true if DIB was drawn, false otherwise
|
||||
*
|
||||
* Description:
|
||||
* Painting routine for a DIB. Calls StretchDIBits() or
|
||||
* SetDIBitsToDevice() to paint the DIB. The DIB is
|
||||
* output to the specified DC, at the coordinates given
|
||||
* in lpDCRect. The area of the DIB to be output is
|
||||
* given by lpDIBRect.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
bool PaintDIB(HDC hDC, LPRECT lpDCRect, HDIB hDIB,
|
||||
LPRECT lpDIBRect, CPalette *pPal) {
|
||||
bool bSuccess = false; // Success/fail flag
|
||||
HPALETTE hPal = nullptr; // Our DIB's palette
|
||||
HPALETTE hOldPal = nullptr; // Previous palette
|
||||
HPALETTE hOldPal2 = nullptr; // Previous palette
|
||||
HBITMAP hBitmap, hBitmapOld;
|
||||
HDC hdcMem; // memory device context
|
||||
int nDevCaps;
|
||||
|
||||
// Check for valid DIB handle
|
||||
if (hDIB == nullptr)
|
||||
return false;
|
||||
|
||||
// Get the palette, then select it into DC
|
||||
if (pPal != nullptr) {
|
||||
hPal = (HPALETTE)pPal->m_hObject;
|
||||
|
||||
// Select as foreground and realize it
|
||||
hOldPal = SelectPalette(hDC, hPal, false);
|
||||
RealizePalette(hDC);
|
||||
}
|
||||
|
||||
nDevCaps = GetDeviceCaps(hDC, RASTERCAPS);
|
||||
if (!(nDevCaps & RC_STRETCHDIB)) {
|
||||
hBitmap = DIBtoBitmap(hDC, nullptr, hDIB);
|
||||
if (hBitmap) {
|
||||
hdcMem = CreateCompatibleDC(hDC);
|
||||
if (hdcMem) {
|
||||
hOldPal2 = SelectPalette(hdcMem, hPal, false);
|
||||
RealizePalette(hdcMem);
|
||||
hBitmapOld = SelectBitmap(hdcMem, hBitmap);
|
||||
if ((RECTWIDTH(lpDCRect) == RECTWIDTH(lpDIBRect)) &&
|
||||
(RECTHEIGHT(lpDCRect) == RECTHEIGHT(lpDIBRect)))
|
||||
bSuccess = BitBlt(hDC, lpDCRect->left, lpDCRect->top,
|
||||
RECTWIDTH(lpDIBRect),
|
||||
RECTHEIGHT(lpDIBRect),
|
||||
hdcMem, lpDIBRect->left, lpDIBRect->top, SRCCOPY);
|
||||
else if (nDevCaps & RC_STRETCHBLT)
|
||||
bSuccess = StretchBlt(hDC, lpDCRect->left, lpDCRect->top, RECTWIDTH(lpDCRect), RECTHEIGHT(lpDCRect),
|
||||
hdcMem, lpDIBRect->left, lpDIBRect->top, RECTWIDTH(lpDIBRect), RECTHEIGHT(lpDIBRect),
|
||||
SRCCOPY);
|
||||
else
|
||||
bSuccess = false;
|
||||
SelectBitmap(hdcMem, hBitmapOld);
|
||||
SelectPalette(hdcMem, hOldPal2, false);
|
||||
DeleteDC(hdcMem);
|
||||
}
|
||||
}
|
||||
|
||||
if (hBitmap != nullptr)
|
||||
DeleteBitmap(hBitmap);
|
||||
if (pPal != nullptr)
|
||||
SelectPalette(hDC, hOldPal, false);
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
error("TODO: Populate binfo and enable below if this is ever needed");
|
||||
#if 0
|
||||
BITMAPINFO bInfo;
|
||||
|
||||
// Lock down the DIB, and get a pointer to it
|
||||
Graphics::ManagedSurface *surf = (Graphics::ManagedSurface *)hDIB;
|
||||
void *lpDIBBits = surf->getPixels();
|
||||
|
||||
// Make sure to use the stretching mode best for color pictures
|
||||
SetStretchBltMode(hDC, COLORONCOLOR);
|
||||
|
||||
bSuccess = StretchDIBits(hDC, // hDC
|
||||
lpDCRect->left, // DestX
|
||||
lpDCRect->top, // DestY
|
||||
RECTWIDTH(lpDCRect), // nDestWidth
|
||||
RECTHEIGHT(lpDCRect), // nDestHeight
|
||||
lpDIBRect->left, // SrcX
|
||||
lpDIBRect->top, // SrcY
|
||||
RECTWIDTH(lpDIBRect), // wSrcWidth
|
||||
RECTHEIGHT(lpDIBRect), // wSrcHeight
|
||||
lpDIBBits, // lpBits
|
||||
&bInfo, // lpBitsInfo
|
||||
DIB_RGB_COLORS, // wUsage
|
||||
SRCCOPY); // dwROP
|
||||
|
||||
if (pPal != nullptr)
|
||||
SelectPalette(hDC, hOldPal, false);
|
||||
|
||||
return bSuccess;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CreateDIBPalette(HDIB hDIB, CPalette *pPal) {
|
||||
uint16 wNumColors;
|
||||
bool bResult = false;
|
||||
|
||||
// If handle to DIB is invalid, return false
|
||||
if (hDIB == nullptr)
|
||||
return false;
|
||||
|
||||
// Get the number of colors in the DIB
|
||||
wNumColors = DIBNumColors(hDIB);
|
||||
|
||||
if (wNumColors != 0) {
|
||||
const Graphics::Palette *pal = hDIB->grabPalette();
|
||||
bResult = pPal->SetPaletteEntries(*pal);
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
CPalette *DuplicatePalette(CPalette *pOrigPal) {
|
||||
CPalette *pPal;
|
||||
LPLOGPALETTE lpPal; // pointer to a logical palette
|
||||
HANDLE hLogPal; // handle to a logical palette
|
||||
uint16 wNumColors; // number of colors in color table
|
||||
bool bResult;
|
||||
|
||||
wNumColors = pOrigPal->GetPaletteEntries(0, 0, nullptr);
|
||||
if (wNumColors == 0)
|
||||
return nullptr;
|
||||
|
||||
/* allocate memory block for logical palette */
|
||||
hLogPal = GlobalAlloc(GPTR, sizeof(LOGPALETTE)
|
||||
+ sizeof(PALETTEENTRY)
|
||||
* wNumColors);
|
||||
assert(hLogPal);
|
||||
|
||||
lpPal = (LPLOGPALETTE) GlobalLock((HGLOBAL)hLogPal);
|
||||
|
||||
/* set version and number of palette entries */
|
||||
lpPal->palVersion = PALVERSION;
|
||||
lpPal->palNumEntries = (uint16)wNumColors;
|
||||
|
||||
(*pOrigPal).GetPaletteEntries(0, wNumColors - 1, &lpPal->palPalEntry[0]);
|
||||
|
||||
/* create the palette and get handle to it */
|
||||
|
||||
pPal = new CPalette();
|
||||
bResult = pPal->CreatePalette(lpPal);
|
||||
if (!bResult) {
|
||||
delete pPal;
|
||||
pPal = nullptr;
|
||||
}
|
||||
|
||||
GlobalUnlock((HGLOBAL)hLogPal);
|
||||
GlobalFree((HGLOBAL)hLogPal);
|
||||
|
||||
return pPal;
|
||||
}
|
||||
|
||||
char *FindDIBBits(HDIB hDIB) {
|
||||
return (char *)hDIB->getPixels();
|
||||
}
|
||||
|
||||
uint32 DIBWidth(HDIB hDIB) {
|
||||
return hDIB->w;
|
||||
}
|
||||
|
||||
uint32 DIBHeight(HDIB hDIB) {
|
||||
return hDIB->h;
|
||||
}
|
||||
|
||||
uint16 PaletteSize(HDIB hDIB) {
|
||||
const Graphics::Palette *pal = hDIB->grabPalette();
|
||||
return pal->size() * 3;
|
||||
}
|
||||
|
||||
uint16 DIBNumColors(HDIB lpDIB) {
|
||||
const Graphics::Palette *pal = lpDIB->grabPalette();
|
||||
return pal->size();
|
||||
}
|
||||
|
||||
CBitmap *ConvertDIB(CDC *pDC, HDIB hDIB, CPalette *pPal) {
|
||||
HPALETTE hPal = nullptr; // Our DIB's palette
|
||||
HPALETTE hOldPal = nullptr; // Previous palette
|
||||
HDC hDC;
|
||||
HBITMAP hBitmap = nullptr;
|
||||
CBitmap *pBitmap = nullptr;
|
||||
|
||||
hDC = (*pDC).m_hDC;
|
||||
|
||||
// Get the palette, then select it into DC
|
||||
if (pPal != nullptr) {
|
||||
hPal = (HPALETTE)pPal->m_hObject;
|
||||
|
||||
// Select as foreground and realize it
|
||||
hOldPal = SelectPalette(hDC, hPal, false);
|
||||
RealizePalette(hDC);
|
||||
}
|
||||
|
||||
// Convert the bit buffer to a bitmap
|
||||
hBitmap = DIBtoBitmap(hDC, nullptr, hDIB);
|
||||
|
||||
if (hBitmap != nullptr) {
|
||||
pBitmap = new CBitmap();
|
||||
if (pBitmap != nullptr)
|
||||
(*pBitmap).Attach(hBitmap);
|
||||
}
|
||||
|
||||
/* Reselect old palette */
|
||||
if (pPal != nullptr)
|
||||
SelectPalette(hDC, hOldPal, false);
|
||||
|
||||
return pBitmap;
|
||||
}
|
||||
|
||||
HBITMAP DIBtoBitmap(HDC hDC, HPALETTE hPalette, HDIB hDib) {
|
||||
BITMAPINFO *info = getDIBInfo(hDib);
|
||||
void *lpbihBits = FindDIBBits(hDib);
|
||||
HBITMAP hBitmap = CreateDIBitmap(hDC,
|
||||
&info->bmiHeader,
|
||||
CBM_INIT,
|
||||
lpbihBits,
|
||||
info,
|
||||
DIB_RGB_COLORS);
|
||||
assert(hBitmap);
|
||||
|
||||
free(info);
|
||||
return hBitmap;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Function: InitBitmapInfoHeader
|
||||
//
|
||||
// Purpose: Does a "standard" initialization of a BITMAPINFOHEADER,
|
||||
// given the Width, Height, and Bits per Pixel for the
|
||||
// DIB.
|
||||
//
|
||||
// By standard, I mean that all the relevant fields are set
|
||||
// to the specified values. biSizeImage is computed, the
|
||||
// biCompression field is set to "no compression," and all
|
||||
// other fields are 0.
|
||||
//
|
||||
// Note that DIBs only allow BitsPixel values of 1, 4, 8, or
|
||||
// 24. This routine makes sure that one of these values is
|
||||
// used (whichever is most appropriate for the specified
|
||||
// nBPP).
|
||||
//
|
||||
// Parms: lpBmInfoHdr == Far pointer to a BITMAPINFOHEADER structure
|
||||
// to be filled in.
|
||||
// dwWidth == Width of DIB (not in Win 3.0 & 3.1, high
|
||||
// word MUST be 0).
|
||||
// dwHeight == Height of DIB (not in Win 3.0 & 3.1, high
|
||||
// word MUST be 0).
|
||||
// nBPP == Bits per Pixel for the DIB.
|
||||
//
|
||||
// History: Date Reason
|
||||
// 11/07/91 Created
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void WINAPI InitBitmapInfoHeader(LPBITMAPINFOHEADER lpBmInfoHdr,
|
||||
uint32 dwWidth,
|
||||
uint32 dwHeight,
|
||||
int nBPP) {
|
||||
memset(lpBmInfoHdr, 0, sizeof(BITMAPINFOHEADER));
|
||||
|
||||
lpBmInfoHdr->biSize = sizeof(BITMAPINFOHEADER);
|
||||
lpBmInfoHdr->biWidth = dwWidth;
|
||||
lpBmInfoHdr->biHeight = dwHeight;
|
||||
lpBmInfoHdr->biPlanes = 1;
|
||||
|
||||
if (nBPP <= 1)
|
||||
nBPP = 1;
|
||||
else if (nBPP <= 4)
|
||||
nBPP = 4;
|
||||
else if (nBPP <= 8)
|
||||
nBPP = 8;
|
||||
else
|
||||
nBPP = 24;
|
||||
|
||||
lpBmInfoHdr->biBitCount = nBPP;
|
||||
lpBmInfoHdr->biSizeImage = WIDTHBYTES(dwWidth * nBPP) * dwHeight;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Clipboard support
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Function: CopyHandle (from SDK DibView sample clipbrd.c)
|
||||
//
|
||||
// Purpose: Makes a copy of the given global memory block. Returns
|
||||
// a handle to the new memory block (nullptr on error).
|
||||
//
|
||||
// Routine stolen verbatim out of ShowDIB.
|
||||
//
|
||||
// Parms: h == Handle to global memory to duplicate.
|
||||
//
|
||||
// Returns: Handle to new global memory block.
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
HANDLE WINAPI CopyHandle(HANDLE h) {
|
||||
byte *lpCopy;
|
||||
byte *lp;
|
||||
HANDLE hCopy;
|
||||
uint32 dwLen;
|
||||
|
||||
if (h == nullptr)
|
||||
return nullptr;
|
||||
|
||||
dwLen = GlobalSize((HGLOBAL)h);
|
||||
|
||||
if ((hCopy = (HANDLE) GlobalAlloc(GHND, dwLen)) != nullptr) {
|
||||
lpCopy = (byte *) GlobalLock((HGLOBAL)hCopy);
|
||||
lp = (byte *) GlobalLock((HGLOBAL)h);
|
||||
|
||||
while (dwLen--)
|
||||
*lpCopy++ = *lp++;
|
||||
|
||||
GlobalUnlock((HGLOBAL)hCopy);
|
||||
GlobalUnlock((HGLOBAL)h);
|
||||
}
|
||||
|
||||
return hCopy;
|
||||
}
|
||||
|
||||
|
||||
void WINAPI ShowMemoryInfo(const char *chMessage, const char *chTitle) {
|
||||
// No implementation
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
151
engines/bagel/hodjnpodj/hnplibs/dibapi.h
Normal file
151
engines/bagel/hodjnpodj/hnplibs/dibapi.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_HNPLIBS_DIBAPI_H
|
||||
#define HODJNPODJ_HNPLIBS_DIBAPI_H
|
||||
|
||||
#include "graphics/managed_surface.h"
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
/* Handle to a DIB */
|
||||
typedef Graphics::ManagedSurface *HDIB;
|
||||
|
||||
/* DIB constants */
|
||||
#define PALVERSION 0x300
|
||||
|
||||
/* DIB Macros*/
|
||||
#define IS_WIN30_DIB(lpbi) ( true )
|
||||
|
||||
#define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left)
|
||||
#define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top)
|
||||
#define DeleteBitmap(hbm) DeleteObject((HGDIOBJ)(HBITMAP)(hbm))
|
||||
#define SelectBitmap(hdc, hbm) ((HBITMAP)SelectObject((hdc),(HGDIOBJ)(HBITMAP)(hbm)))
|
||||
|
||||
// WIDTHBYTES performs uint32-aligning of DIB scanlines. The "bits"
|
||||
// parameter is the bit count for the scanline (biWidth * biBitCount),
|
||||
// and this macro returns the number of uint32-aligned bytes needed
|
||||
// to hold those bits.
|
||||
|
||||
#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
|
||||
|
||||
/* Function prototypes */
|
||||
bool PaintDIB(HDC, LPRECT, HDIB, LPRECT, CPalette *pPal);
|
||||
|
||||
|
||||
/**
|
||||
* This function creates a palette from a DIB by allocating memory for the
|
||||
* logical palette, reading and storing the colors from the DIB's color table
|
||||
* into the logical palette, creating a palette from this logical palette,
|
||||
* and then returning the palette's handle. This allows the DIB to be
|
||||
* displayed using the best possible colors (important for DIBs with 256 or
|
||||
* more colors).
|
||||
* @param hDIB Specifies the DIB
|
||||
* @return Specifies the palette
|
||||
*/
|
||||
extern bool CreateDIBPalette(HDIB hDIB, CPalette *cPal);
|
||||
|
||||
/**
|
||||
* This function calculates the address of the DIB's bits and returns a
|
||||
* pointer to the DIB bits.
|
||||
* @param hDIB Pointer to packed-DIB memory block
|
||||
* @return Pointer to the DIB bits
|
||||
*/
|
||||
extern char *FindDIBBits(HDIB lpbi);
|
||||
|
||||
/**
|
||||
* This function gets the width of the bitmap.
|
||||
* @param lpbi Bitmap pointer
|
||||
* @return Width
|
||||
*/
|
||||
extern uint32 DIBWidth(HDIB lpDIB);
|
||||
|
||||
/**
|
||||
* This function gets the height of the bitmap.
|
||||
* @param lpbi Bitmap pointer
|
||||
* @return Height
|
||||
*/
|
||||
extern uint32 DIBHeight(HDIB lpDIB);
|
||||
|
||||
/**
|
||||
* Gets the size required to store the DIB's palette
|
||||
* @param lpbi Pointer to packed-DIB memory block
|
||||
* @return Size of the color palette of the DIB
|
||||
*/
|
||||
extern uint16 PaletteSize(HDIB lpDIB);
|
||||
|
||||
/**
|
||||
* Gets the number of colors in the palette
|
||||
* @param lpbi Pointer to packed-DIB memory block
|
||||
* @return Number of the palette colors.
|
||||
*/
|
||||
extern uint16 DIBNumColors(HDIB lpDIB);
|
||||
|
||||
HANDLE CopyHandle(HANDLE h);
|
||||
|
||||
/**
|
||||
* Convert a device-independent bitmap (DIB) to a device-dependent
|
||||
* bitmap (DDB). The DIB must be packed; i.e. same as a .BMP file.
|
||||
* @return A handle to the DDB (HBITMAP). If an error occurs, the return
|
||||
* value will be nullptr.
|
||||
*/
|
||||
extern HBITMAP DIBtoBitmap(HDC hDC, HPALETTE hPal, HDIB hDib);
|
||||
|
||||
/**
|
||||
* Convert a device-independent bitmap (DIB) to a device-dependent
|
||||
* bitmap (DDB), with the desired color palette mapped to the context.
|
||||
* The DIB must be packed; i.e. same as a .BMP file.
|
||||
* @return A handle to the Bitmap (CBitmap *). If an error occurs, the return
|
||||
* value will be nullptr.
|
||||
*/
|
||||
extern CBitmap *ConvertDIB(CDC *pDC, HDIB hDIB, CPalette *pPal);
|
||||
|
||||
/**
|
||||
* Reads in the specified DIB file into a global chunk of memory.
|
||||
* @param file Bitmap file to read
|
||||
* @return A handle to a dib (hDIB) if successful.
|
||||
* nullptr if an error occurs.
|
||||
*/
|
||||
extern HDIB ReadDIBFile(CFile &file);
|
||||
|
||||
/**
|
||||
* Reads in the specified DIB from a resource entry.
|
||||
* @param pszPathName Resource name
|
||||
* @return A handle to a dib (hDIB) if successful.
|
||||
* nullptr if an error occurs.
|
||||
*/
|
||||
extern HDIB ReadDIBResource(const char *pszPathName);
|
||||
|
||||
void InitBitmapInfoHeader(LPBITMAPINFOHEADER lpBmInfoHdr,
|
||||
uint32 dwWidth,
|
||||
uint32 dwHeight,
|
||||
int nBPP);
|
||||
|
||||
void ShowMemoryInfo(const char *chMessage, const char *chTitle);
|
||||
|
||||
CPalette *DuplicatePalette(CPalette *pPal);
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
204
engines/bagel/hodjnpodj/hnplibs/dibdoc.cpp
Normal file
204
engines/bagel/hodjnpodj/hnplibs/dibdoc.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
/* 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"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDibDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CDibDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDibDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CDibDoc)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDibDoc construction/destruction
|
||||
|
||||
CDibDoc::CDibDoc() {
|
||||
m_hDIB = nullptr;
|
||||
m_palDIB = nullptr;
|
||||
m_sizeDoc = CSize(1, 1); // dummy value to make CScrollView happy
|
||||
}
|
||||
|
||||
CDibDoc::~CDibDoc() {
|
||||
delete m_hDIB;
|
||||
|
||||
if (m_palDIB != nullptr) {
|
||||
(*m_palDIB).DeleteObject();
|
||||
delete m_palDIB;
|
||||
}
|
||||
}
|
||||
|
||||
void CDibDoc::InitDIBData() {
|
||||
if (m_palDIB != nullptr) {
|
||||
delete m_palDIB;
|
||||
m_palDIB = nullptr;
|
||||
}
|
||||
if (m_hDIB == nullptr) {
|
||||
return;
|
||||
}
|
||||
// Set up document size
|
||||
if (DIBWidth(m_hDIB) > INT_MAX || DIBHeight(m_hDIB) > INT_MAX) {
|
||||
delete m_hDIB;
|
||||
m_hDIB = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
m_sizeDoc = CSize((int)DIBWidth(m_hDIB), (int)DIBHeight(m_hDIB));
|
||||
|
||||
// Create copy of palette
|
||||
m_palDIB = new CPalette;
|
||||
if (m_palDIB == nullptr) {
|
||||
// we must be really low on memory
|
||||
GlobalFree((HGLOBAL)m_hDIB);
|
||||
m_hDIB = nullptr;
|
||||
ShowMemoryInfo("Unable to create artwork palette", "Internal Problem");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CreateDIBPalette(m_hDIB, m_palDIB)) {
|
||||
// DIB may not have a palette
|
||||
delete m_palDIB;
|
||||
m_palDIB = nullptr;
|
||||
ShowMemoryInfo("Unable to create artwork palette", "Internal Problem");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CDibDoc::OpenResourceDocument(const int nResID) {
|
||||
char chResID[8];
|
||||
|
||||
DeleteContents();
|
||||
|
||||
Common::sprintf_s(chResID, "#%d", nResID);
|
||||
m_hDIB = ReadDIBResource(chResID);
|
||||
if (m_hDIB != nullptr)
|
||||
InitDIBData();
|
||||
|
||||
if (m_hDIB == nullptr) {
|
||||
char buf[128];
|
||||
|
||||
Common::sprintf_s(buf, "Unable to load artwork resource: %s", chResID);
|
||||
ShowMemoryInfo(buf, "Internal Problem");
|
||||
return false;
|
||||
}
|
||||
SetPathName(chResID);
|
||||
SetModifiedFlag(false); // start off with unmodified
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CDibDoc::OpenResourceDocument(const char *pszPathName) {
|
||||
DeleteContents();
|
||||
|
||||
m_hDIB = ReadDIBResource(pszPathName);
|
||||
if (m_hDIB != nullptr)
|
||||
InitDIBData();
|
||||
|
||||
if (m_hDIB == nullptr) {
|
||||
char buf[128];
|
||||
|
||||
Common::sprintf_s(buf, "Unable to load artwork file: %s", pszPathName);
|
||||
ShowMemoryInfo(buf, "Internal Problem");
|
||||
return false;
|
||||
}
|
||||
SetPathName(" ");
|
||||
SetModifiedFlag(false); // start off with unmodified
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CPalette *CDibDoc::DetachPalette() {
|
||||
CPalette *pMyPalette;
|
||||
|
||||
pMyPalette = m_palDIB;
|
||||
m_palDIB = nullptr;
|
||||
return pMyPalette;
|
||||
}
|
||||
|
||||
|
||||
bool CDibDoc::OpenDocument(const char *pszPathName) {
|
||||
CFile file;
|
||||
CFileException fe;
|
||||
|
||||
if (!file.Open(pszPathName, CFile::modeRead | CFile::shareDenyWrite, &fe)) {
|
||||
error("Unable to open artwork file: %s", pszPathName);
|
||||
return false;
|
||||
}
|
||||
|
||||
DeleteContents();
|
||||
// BeginWaitCursor();
|
||||
|
||||
// replace calls to Serialize with ReadDIBFile function
|
||||
TRY {
|
||||
m_hDIB = ReadDIBFile(file);
|
||||
|
||||
if (m_hDIB == nullptr)
|
||||
error("Unable to load artwork file: %s", pszPathName);
|
||||
}
|
||||
CATCH(CFileException, eLoad) {
|
||||
file.Abort(); // will not throw an exception
|
||||
// EndWaitCursor();
|
||||
ReportSaveLoadException(pszPathName, eLoad,
|
||||
false, AFX_IDP_FAILED_TO_OPEN_DOC);
|
||||
m_hDIB = nullptr;
|
||||
return false;
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
InitDIBData();
|
||||
// EndWaitCursor();
|
||||
|
||||
if (m_hDIB == nullptr) {
|
||||
char buf[128];
|
||||
|
||||
Common::sprintf_s(buf, "Unable to load artwork file: %s", pszPathName);
|
||||
ShowMemoryInfo(buf, "Internal Problem");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetPathName(pszPathName);
|
||||
SetModifiedFlag(false); // start off with unmodified
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CDibDoc::SaveDocument(const char *pszPathName) {
|
||||
// No implementation
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDibDoc::ReplaceHDIB(HDIB hDIB) {
|
||||
if (m_hDIB != nullptr) {
|
||||
GlobalFree((HGLOBAL)m_hDIB);
|
||||
}
|
||||
m_hDIB = hDIB;
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
74
engines/bagel/hodjnpodj/hnplibs/dibdoc.h
Normal file
74
engines/bagel/hodjnpodj/hnplibs/dibdoc.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_HNPLIBS_DIBDOC_H
|
||||
#define HODJNPODJ_HNPLIBS_DIBDOC_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/dibapi.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
class CDibDoc : public CDocument {
|
||||
DECLARE_DYNCREATE(CDibDoc)
|
||||
friend class CSprite;
|
||||
|
||||
public:
|
||||
CDibDoc();
|
||||
|
||||
// Attributes
|
||||
HDIB GetHDIB() const {
|
||||
return m_hDIB;
|
||||
}
|
||||
CPalette *GetDocPalette() const {
|
||||
return m_palDIB;
|
||||
}
|
||||
CPalette *DetachPalette();
|
||||
CSize GetDocSize() const {
|
||||
return m_sizeDoc;
|
||||
}
|
||||
|
||||
// Operations
|
||||
void ReplaceHDIB(HDIB hDIB);
|
||||
void InitDIBData();
|
||||
|
||||
// Implementation
|
||||
virtual ~CDibDoc();
|
||||
virtual bool SaveDocument(const char* pszPathName);
|
||||
virtual bool OpenDocument(const char* pszPathName);
|
||||
virtual bool OpenResourceDocument(const int nResID);
|
||||
virtual bool OpenResourceDocument(const char* pszPathName);
|
||||
|
||||
private:
|
||||
HDIB m_hDIB = nullptr;
|
||||
CPalette *m_palDIB = nullptr;
|
||||
CSize m_sizeDoc;
|
||||
|
||||
protected:
|
||||
//{{AFX_MSG(CDibDoc)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
90
engines/bagel/hodjnpodj/hnplibs/dibfile.cpp
Normal file
90
engines/bagel/hodjnpodj/hnplibs/dibfile.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/memstream.h"
|
||||
#include "image/bmp.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibapi.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
HDIB ReadDIBFile(CFile &file) {
|
||||
Image::BitmapDecoder decoder;
|
||||
if (!decoder.loadStream(file))
|
||||
return nullptr;
|
||||
|
||||
Graphics::ManagedSurface *surf =
|
||||
new Graphics::ManagedSurface();
|
||||
surf->copyFrom(*decoder.getSurface());
|
||||
|
||||
if (decoder.hasPalette()) {
|
||||
// WORKAROUND: dfa/art/mallet.bmp has 257 palette entries.
|
||||
// Other bitmaps may likewise.
|
||||
const Graphics::Palette &pal = decoder.getPalette();
|
||||
surf->setPalette(pal.data(), 0, MIN<int>(pal.size(), 256));
|
||||
}
|
||||
|
||||
return surf;
|
||||
}
|
||||
|
||||
HDIB ReadDIBResource(const char *pszName) {
|
||||
Image::BitmapDecoder decoder;
|
||||
HINSTANCE hInst = nullptr;
|
||||
uint dwBytes;
|
||||
HRSRC hRsc;
|
||||
HGLOBAL hGbl;
|
||||
byte *pData;
|
||||
|
||||
hRsc = FindResource(hInst, pszName, RT_BITMAP);
|
||||
if (hRsc != nullptr) {
|
||||
dwBytes = (size_t)SizeofResource(hInst, hRsc);
|
||||
hGbl = LoadResource(hInst, hRsc);
|
||||
if ((dwBytes != 0) &&
|
||||
(hGbl != nullptr)) {
|
||||
pData = (byte *)LockResource(hGbl);
|
||||
Common::MemoryReadStream rs(pData, dwBytes);
|
||||
|
||||
bool success = decoder.loadStream(rs);
|
||||
|
||||
UnlockResource(hGbl);
|
||||
FreeResource(hGbl);
|
||||
|
||||
if (success) {
|
||||
Graphics::ManagedSurface *surf =
|
||||
new Graphics::ManagedSurface();
|
||||
surf->copyFrom(*decoder.getSurface());
|
||||
|
||||
if (decoder.hasPalette()) {
|
||||
const Graphics::Palette &pal = decoder.getPalette();
|
||||
surf->setPalette(pal.data(), 0, pal.size());
|
||||
}
|
||||
|
||||
return surf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
59
engines/bagel/hodjnpodj/hnplibs/gamedll.h
Normal file
59
engines/bagel/hodjnpodj/hnplibs/gamedll.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_HNPLIBS_GAMEDLL_H
|
||||
#define HODJNPODJ_HNPLIBS_GAMEDLL_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define PATHSPECSIZE 256
|
||||
|
||||
#define NOPLAY -1
|
||||
#define SKILLLEVEL_LOW 0
|
||||
#define SKILLLEVEL_MEDIUM 1
|
||||
#define SKILLLEVEL_HIGH 2
|
||||
|
||||
#define INSTALL_NONE 0
|
||||
#define INSTALL_MINIMAL 1
|
||||
#define INSTALL_BASIC 2
|
||||
#define INSTALL_EXTRA 3
|
||||
#define INSTALL_FULL 4
|
||||
|
||||
|
||||
struct GAMESTRUCT {
|
||||
long lCrowns = 0;
|
||||
long lScore = 0;
|
||||
int nSkillLevel = 0;
|
||||
bool bSoundEffectsEnabled = false;
|
||||
bool bMusicEnabled = false;
|
||||
bool bPlayingMetagame = false;
|
||||
bool bPlayingHodj = false;
|
||||
};
|
||||
|
||||
typedef GAMESTRUCT FAR *LPGAMESTRUCT;
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
97
engines/bagel/hodjnpodj/hnplibs/lzss.cpp
Normal file
97
engines/bagel/hodjnpodj/hnplibs/lzss.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/* 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 "common/file.h"
|
||||
#include "common/memstream.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/lzss.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
Common::SeekableReadStream *makeLzssStream(const Common::Path &filename) {
|
||||
Common::File file;
|
||||
if (!file.open(filename))
|
||||
return nullptr;
|
||||
|
||||
// First part of the signature
|
||||
if (file.readUint32BE() != MKTAG('S', 'Z', 'D', 'D'))
|
||||
return nullptr;
|
||||
|
||||
// Second part of the signature
|
||||
if (file.readUint32BE() != 0x88F02733)
|
||||
return nullptr;
|
||||
|
||||
// Compression mode must be 'A'
|
||||
if (file.readByte() != 'A')
|
||||
return nullptr;
|
||||
|
||||
file.readByte(); // file name character change
|
||||
uint32 unpackedLength = file.readUint32LE();
|
||||
|
||||
byte *window = new byte[0x1000]();
|
||||
int pos = 0x1000 - 16;
|
||||
|
||||
byte *unpackedData = (byte *)malloc(unpackedLength);
|
||||
assert(unpackedData);
|
||||
byte *dataPos = unpackedData;
|
||||
|
||||
uint32 remaining = unpackedLength;
|
||||
|
||||
// Apply simple LZSS decompression
|
||||
for (;;) {
|
||||
byte controlByte = file.readByte();
|
||||
|
||||
if (remaining == 0 || file.eos())
|
||||
break;
|
||||
|
||||
for (byte i = 0; i < 8; i++) {
|
||||
if (controlByte & (1 << i)) {
|
||||
*dataPos++ = window[pos++] = file.readByte();
|
||||
pos &= 0xFFF;
|
||||
if (--remaining == 0)
|
||||
break;
|
||||
} else {
|
||||
int matchPos = file.readByte();
|
||||
int matchLen = file.readByte();
|
||||
matchPos |= (matchLen & 0xF0) << 4;
|
||||
matchLen = (matchLen & 0xF) + 3;
|
||||
if ((uint32)matchLen > remaining)
|
||||
matchLen = remaining;
|
||||
remaining -= matchLen;
|
||||
|
||||
while (matchLen--) {
|
||||
*dataPos++ = window[pos++] = window[matchPos++];
|
||||
pos &= 0xFFF;
|
||||
matchPos &= 0xFFF;
|
||||
}
|
||||
|
||||
if (remaining == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] window;
|
||||
return new Common::MemoryReadStream(unpackedData, unpackedLength);
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
36
engines/bagel/hodjnpodj/hnplibs/lzss.h
Normal file
36
engines/bagel/hodjnpodj/hnplibs/lzss.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* 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_HNPLIBS_LZSS_H
|
||||
#define HODJNPODJ_HNPLIBS_LZSS_H
|
||||
|
||||
#include "common/path.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
extern Common::SeekableReadStream *makeLzssStream(const Common::Path &filename);
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
344
engines/bagel/hodjnpodj/hnplibs/mainmenu.cpp
Normal file
344
engines/bagel/hodjnpodj/hnplibs/mainmenu.cpp
Normal file
@@ -0,0 +1,344 @@
|
||||
/* 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/dibapi.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/mainmenu.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/audiocfg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/bitmaps.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/rules.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hodjnpodj.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainMenu, CBmpDialog)
|
||||
//{{AFX_MSG_MAP(CMainMenu)
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_DESTROY()
|
||||
ON_BN_CLICKED(IDC_OPTIONS_RULES, CMainMenu::OnClickedRules)
|
||||
ON_BN_CLICKED(IDC_OPTIONS_NEWGAME, CMainMenu::OnClickedNewgame)
|
||||
ON_BN_CLICKED(IDC_OPTIONS_OPTIONS, CMainMenu::OnClickedOptions)
|
||||
ON_BN_CLICKED(IDC_OPTIONS_AUDIO, CMainMenu::OnClickedAudio)
|
||||
ON_BN_CLICKED(IDC_OPTIONS_RETURN, CMainMenu::OnClickedReturn)
|
||||
ON_BN_CLICKED(IDC_OPTIONS_QUIT, CMainMenu::OnClickedQuit)
|
||||
ON_BN_CLICKED(IDC_OPTIONS_HYPE, CMainMenu::OnClickedHype)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
CMainMenu::CMainMenu(CWnd *pParent, CPalette *pPalette,
|
||||
unsigned int nFlags, FPFUNC pOptionsFunc, const char *pRulesFileName,
|
||||
const char *pWavFileName, LPGAMESTRUCT pGameParams)
|
||||
: CBmpDialog(pParent, pPalette, IDD_OPTIONS_DIALOG, ".\\ART\\OSCROLL.BMP") {
|
||||
// Can't access null pointers
|
||||
assert(pParent != nullptr);
|
||||
assert(pPalette != nullptr);
|
||||
assert(pRulesFileName != nullptr);
|
||||
|
||||
// Inits
|
||||
_rulesFilename = pRulesFileName;
|
||||
_wavFilename = pWavFileName;
|
||||
_flags = nFlags;
|
||||
_gameParams = pGameParams;
|
||||
|
||||
if (!(_flags & NO_OPTIONS)) {
|
||||
assert(pOptionsFunc != nullptr);
|
||||
}
|
||||
_optionsFunction = pOptionsFunc;
|
||||
|
||||
//{{AFX_DATA_INIT(CMainMenu)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CMainMenu::DoDataExchange(CDataExchange* pDX) {
|
||||
CBmpDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CMainMenu)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
void CMainMenu::clearButtons() {
|
||||
delete _rulesButton;
|
||||
_rulesButton = nullptr;
|
||||
|
||||
delete _newGameButton;
|
||||
_newGameButton = nullptr;
|
||||
|
||||
delete _optionsButton;
|
||||
_optionsButton = nullptr;
|
||||
|
||||
delete _audioButton;
|
||||
_audioButton = nullptr;
|
||||
|
||||
delete _returnButton;
|
||||
_returnButton = nullptr;
|
||||
|
||||
delete _quitButton;
|
||||
_quitButton = nullptr;
|
||||
|
||||
delete _hypeButton;
|
||||
_hypeButton = nullptr;
|
||||
}
|
||||
|
||||
void CMainMenu::ClearDialogImage() {
|
||||
clearButtons();
|
||||
|
||||
if (m_pDlgBackground != nullptr)
|
||||
InvalidateRect(nullptr, false);
|
||||
}
|
||||
|
||||
void CMainMenu::OnDestroy() {
|
||||
CBmpDialog::OnDestroy();
|
||||
|
||||
clearButtons();
|
||||
}
|
||||
|
||||
bool CMainMenu::OnInitDialog() {
|
||||
CWnd *pWndTemp;
|
||||
|
||||
CBmpDialog::OnInitDialog(); // do basic dialog initialization
|
||||
|
||||
// Set up replacement color buttons
|
||||
_rulesButton = new CColorButton();
|
||||
_rulesButton->SetPalette(m_pPalette);
|
||||
_rulesButton->SetControl(IDC_OPTIONS_RULES, this);
|
||||
|
||||
_newGameButton = new CColorButton();
|
||||
_newGameButton->SetPalette(m_pPalette);
|
||||
_newGameButton->SetControl(IDC_OPTIONS_NEWGAME, this);
|
||||
|
||||
_optionsButton = new CColorButton();
|
||||
_optionsButton->SetPalette(m_pPalette);
|
||||
_optionsButton->SetControl(IDC_OPTIONS_OPTIONS, this);
|
||||
|
||||
_audioButton = new CColorButton();
|
||||
_audioButton->SetPalette(m_pPalette);
|
||||
_audioButton->SetControl(IDC_OPTIONS_AUDIO, this);
|
||||
|
||||
_returnButton = new CColorButton();
|
||||
_returnButton->SetPalette(m_pPalette);
|
||||
_returnButton->SetControl(IDC_OPTIONS_RETURN, this);
|
||||
|
||||
_quitButton = new CColorButton();
|
||||
_quitButton->SetPalette(m_pPalette);
|
||||
_quitButton->SetControl(IDC_OPTIONS_QUIT, this);
|
||||
|
||||
// Add the Hype Button if running the Maze O' Doom demo
|
||||
if (g_engine->isMazeODoomDemo()) {
|
||||
CRect optionsRect, audioRect;
|
||||
_optionsButton->GetWindowRect(&optionsRect);
|
||||
_audioButton->GetWindowRect(&audioRect);
|
||||
CRect hypeRect(optionsRect.right + 5, optionsRect.top,
|
||||
optionsRect.right + 50, audioRect.bottom);
|
||||
|
||||
_hypeButton = new CColorButton();
|
||||
_hypeButton->Create("?", BS_OWNERDRAW | WS_CHILD | WS_VISIBLE,
|
||||
hypeRect, this, IDC_OPTIONS_HYPE);
|
||||
_hypeButton->SetPalette(m_pPalette);
|
||||
|
||||
_hypeFont.CreateFont(24, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, OUT_RASTER_PRECIS, 0, PROOF_QUALITY, FF_ROMAN, "MS Sans Serif");
|
||||
_hypeButton->SetFont(&_hypeFont);
|
||||
}
|
||||
|
||||
// Disable the Rules button if told to do so
|
||||
if (_flags & NO_RULES) {
|
||||
pWndTemp = GetDlgItem(IDC_OPTIONS_RULES);
|
||||
assert(pWndTemp != nullptr);
|
||||
if (pWndTemp != nullptr)
|
||||
pWndTemp->EnableWindow(false);
|
||||
}
|
||||
|
||||
// Disable the NewGame button if told to do so
|
||||
if (_flags & NO_NEWGAME) {
|
||||
pWndTemp = GetDlgItem(IDC_OPTIONS_NEWGAME);
|
||||
assert(pWndTemp != nullptr);
|
||||
if (pWndTemp != nullptr)
|
||||
pWndTemp->EnableWindow(false);
|
||||
}
|
||||
|
||||
// Disable the Options button if told to do so
|
||||
if (_flags & NO_OPTIONS) {
|
||||
pWndTemp = GetDlgItem(IDC_OPTIONS_OPTIONS);
|
||||
assert(pWndTemp != nullptr);
|
||||
if (pWndTemp != nullptr)
|
||||
pWndTemp->EnableWindow(false);
|
||||
}
|
||||
|
||||
// Disable the Audio button if told to do so
|
||||
if (_flags & NO_AUDIO) {
|
||||
pWndTemp = GetDlgItem(IDC_OPTIONS_AUDIO);
|
||||
assert(pWndTemp != nullptr);
|
||||
if (pWndTemp != nullptr)
|
||||
pWndTemp->EnableWindow(false);
|
||||
}
|
||||
|
||||
// Disable the Return button if told to do so
|
||||
if (_flags & NO_RETURN) {
|
||||
pWndTemp = GetDlgItem(IDC_OPTIONS_RETURN);
|
||||
assert(pWndTemp != nullptr);
|
||||
if (pWndTemp != nullptr)
|
||||
pWndTemp->EnableWindow(false);
|
||||
}
|
||||
|
||||
// Disable the Return button if told to do so
|
||||
if (_flags & NO_QUIT) {
|
||||
pWndTemp = GetDlgItem(IDC_OPTIONS_QUIT);
|
||||
assert(pWndTemp != nullptr);
|
||||
if (pWndTemp != nullptr)
|
||||
pWndTemp->EnableWindow(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CMainMenu::OnEraseBkgnd(CDC *pDC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CMainMenu::OnPaint() {
|
||||
CBmpDialog::OnPaint();
|
||||
}
|
||||
|
||||
|
||||
void CMainMenu::OnClickedRules() {
|
||||
CWnd *pControl;
|
||||
|
||||
// Load the rules
|
||||
CRules RulesDlg(this, _rulesFilename, m_pPalette, _wavFilename);
|
||||
|
||||
// Display the rules
|
||||
RulesDlg.DoModal();
|
||||
|
||||
SetDefID(IDC_OPTIONS_OPTIONS);
|
||||
if (_flags & NO_RETURN) {
|
||||
SetDefID(IDC_OPTIONS_NEWGAME);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_NEWGAME);
|
||||
} else {
|
||||
SetDefID(IDC_OPTIONS_RETURN);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_RETURN);
|
||||
}
|
||||
|
||||
GotoDlgCtrl(pControl);
|
||||
}
|
||||
|
||||
void CMainMenu::OnClickedHype() {
|
||||
CWnd *pControl;
|
||||
|
||||
// Load the hype
|
||||
CRules hypeDlg(this, "hype.txt", m_pPalette, nullptr);
|
||||
|
||||
// Display the dialog
|
||||
hypeDlg.DoModal();
|
||||
|
||||
SetDefID(IDC_OPTIONS_OPTIONS);
|
||||
if (_flags & NO_RETURN) {
|
||||
SetDefID(IDC_OPTIONS_NEWGAME);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_NEWGAME);
|
||||
} else {
|
||||
SetDefID(IDC_OPTIONS_RETURN);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_RETURN);
|
||||
}
|
||||
|
||||
GotoDlgCtrl(pControl);
|
||||
}
|
||||
|
||||
void CMainMenu::OnClickedNewgame() {
|
||||
// User has chosen to start a new game
|
||||
ClearDialogImage();
|
||||
EndDialog(IDC_OPTIONS_NEWGAME);
|
||||
}
|
||||
|
||||
void CMainMenu::OnClickedOptions() {
|
||||
CWnd *pControl;
|
||||
|
||||
SetDefID(IDC_OPTIONS_RULES);
|
||||
if (_flags & NO_RETURN) {
|
||||
SetDefID(IDC_OPTIONS_NEWGAME);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_NEWGAME);
|
||||
} else {
|
||||
SetDefID(IDC_OPTIONS_RETURN);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_RETURN);
|
||||
}
|
||||
GotoDlgCtrl(pControl);
|
||||
|
||||
// Call the user defined sub-options (we are the parent)
|
||||
if (_optionsFunction != nullptr)
|
||||
(_optionsFunction)(this);
|
||||
}
|
||||
|
||||
void CMainMenu::OnClickedAudio() {
|
||||
CWnd *pControl;
|
||||
|
||||
SetDefID(IDC_OPTIONS_RULES);
|
||||
if (_flags & NO_RETURN) {
|
||||
SetDefID(IDC_OPTIONS_NEWGAME);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_NEWGAME);
|
||||
} else {
|
||||
SetDefID(IDC_OPTIONS_RETURN);
|
||||
pControl = GetDlgItem(IDC_OPTIONS_RETURN);
|
||||
}
|
||||
|
||||
GotoDlgCtrl(pControl);
|
||||
|
||||
CAudioCfgDlg dlgAudioCfg(this, m_pPalette, IDD_AUDIOCFG);
|
||||
|
||||
if (_gameParams != nullptr) {
|
||||
_gameParams->bMusicEnabled = GetPrivateProfileInt("Meta", "Music", true, "HODJPODJ.INI");
|
||||
_gameParams->bSoundEffectsEnabled = GetPrivateProfileInt("Meta", "SoundEffects", true, "HODJPODJ.INI");
|
||||
}
|
||||
}
|
||||
|
||||
void CMainMenu::OnOK() {
|
||||
// Don't do anything
|
||||
}
|
||||
|
||||
void CMainMenu::OnCancel() {
|
||||
// User is returning to Mini-game (only if Continue is not disabled)
|
||||
if (!(_flags & NO_RETURN)) {
|
||||
ClearDialogImage();
|
||||
EndDialog(IDC_OPTIONS_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
void CMainMenu::OnClickedReturn() {
|
||||
// User is returning to Mini-game
|
||||
ClearDialogImage();
|
||||
EndDialog(IDC_OPTIONS_RETURN);
|
||||
}
|
||||
|
||||
void CMainMenu::OnClickedQuit() {
|
||||
// User hit the Quit Button
|
||||
ClearDialogImage();
|
||||
EndDialog(IDC_OPTIONS_QUIT);
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
103
engines/bagel/hodjnpodj/hnplibs/mainmenu.h
Normal file
103
engines/bagel/hodjnpodj/hnplibs/mainmenu.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* 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_HNPLIBS_MAINMENU_H
|
||||
#define HODJNPODJ_HNPLIBS_MAINMENU_H
|
||||
|
||||
#include "bagel/mfc/afxwin.h"
|
||||
#include "bagel/mfc/afxext.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/menures.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
typedef void (CALLBACK *FPFUNC)(CWnd *);
|
||||
|
||||
#define NO_RULES 0x0001
|
||||
#define NO_NEWGAME 0x0002
|
||||
#define NO_OPTIONS 0x0004
|
||||
#define NO_RETURN 0x0008
|
||||
#define NO_QUIT 0x0010
|
||||
#define NO_AUDIO 0x0020
|
||||
|
||||
class CMainMenu : public CBmpDialog {
|
||||
public:
|
||||
CMainMenu(CWnd *, CPalette *, unsigned int, FPFUNC,
|
||||
const char *, const char *pWavFileName = nullptr,
|
||||
LPGAMESTRUCT pGameParams = nullptr);
|
||||
void ClearDialogImage();
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CMainMenu)
|
||||
virtual bool OnInitDialog() override;
|
||||
virtual void OnOK() override;
|
||||
virtual void OnCancel() override;
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg void OnClickedRules() ;
|
||||
afx_msg void OnClickedNewgame() ;
|
||||
afx_msg void OnClickedOptions() ;
|
||||
afx_msg void OnClickedAudio() ;
|
||||
afx_msg void OnClickedReturn();
|
||||
afx_msg void OnClickedQuit();
|
||||
afx_msg void OnClickedHype();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
FPFUNC _optionsFunction = nullptr;
|
||||
const char *_rulesFilename = nullptr;
|
||||
const char *_wavFilename = nullptr;
|
||||
uint _flags = 0;
|
||||
LPGAMESTRUCT _gameParams = nullptr;
|
||||
|
||||
private:
|
||||
CColorButton *_hypeButton = nullptr;
|
||||
CColorButton *_rulesButton = nullptr;
|
||||
CColorButton *_newGameButton = nullptr;
|
||||
CColorButton *_optionsButton = nullptr;
|
||||
CColorButton *_audioButton = nullptr;
|
||||
CColorButton *_returnButton = nullptr;
|
||||
CColorButton *_quitButton = nullptr;
|
||||
CFont _hypeFont;
|
||||
|
||||
//{{AFX_DATA(CMainMenu)
|
||||
enum {
|
||||
IDD = IDD_OPTIONS_DIALOG
|
||||
};
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
void clearButtons();
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
50
engines/bagel/hodjnpodj/hnplibs/menures.h
Normal file
50
engines/bagel/hodjnpodj/hnplibs/menures.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* 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 BAGEL_MFC_GLOBAL_MENURES_H
|
||||
#define BAGEL_MFC_GLOBAL_MENURES_H
|
||||
|
||||
#define IDC_OPTIONS_ARROWUP 503
|
||||
#define IDC_OPTIONS_ARROWDN 504
|
||||
|
||||
#define ID_OPTIONS_CODES 450
|
||||
|
||||
// obsolete
|
||||
//#define IDR_BITMAP_SCROLL 451
|
||||
|
||||
#define IDR_OPTION_SCROLL 452
|
||||
#define IDD_OPTIONS_DIALOG 453
|
||||
|
||||
#define IDC_OPTIONS_RETURN 454
|
||||
#define IDC_OPTIONS_QUIT 455
|
||||
#define IDC_OPTIONS_RULES 456
|
||||
#define IDC_OPTIONS_NEWGAME 457
|
||||
#define IDC_OPTIONS_OPTIONS 458
|
||||
#define IDC_OPTIONS_AUDIO 459
|
||||
#define IDC_OPTIONS_HYPE 999
|
||||
|
||||
#define IDB_SCROLBTN 460
|
||||
#define SCROLLUP 461
|
||||
#define SCROLLDOWN 462
|
||||
|
||||
#define IDD_AUDIOCFG 463
|
||||
|
||||
#endif
|
||||
1444
engines/bagel/hodjnpodj/hnplibs/rules.cpp
Normal file
1444
engines/bagel/hodjnpodj/hnplibs/rules.cpp
Normal file
File diff suppressed because it is too large
Load Diff
114
engines/bagel/hodjnpodj/hnplibs/rules.h
Normal file
114
engines/bagel/hodjnpodj/hnplibs/rules.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_HNPLIBS_RULES_H
|
||||
#define HODJNPODJ_HNPLIBS_RULES_H
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#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
|
||||
|
||||
|
||||
class CRules : public CDialog {
|
||||
// Construction
|
||||
public:
|
||||
CRules(CWnd *pParent = nullptr, const char *pszPathName = nullptr,
|
||||
CPalette *pPalette = nullptr, const char *pszSoundPath = nullptr);
|
||||
|
||||
void UpdateScroll(int nPage);
|
||||
void ClearDialogImage();
|
||||
void RefreshBackground();
|
||||
|
||||
private:
|
||||
|
||||
bool SetupKeyboardHook();
|
||||
void RemoveKeyboardHook();
|
||||
|
||||
static CDibDoc *LoadScrollDIB(const char *pSpec, CRect *pRect);
|
||||
static bool PaintScrollDIB(CDC *pDC, CDibDoc *pDibDoc);
|
||||
static CBitmap *CreateScrollBitmap(CDC *pDC, CDibDoc *pDibDoc, CPalette *pPalette);
|
||||
static CDC *SetupMask(CDC *pDC, CDC *pBitmapDC, CBitmap *pMask, CBitmap * &pMaskOld, CRect *pRect);
|
||||
static CDC *SetupCompatibleContext(CDC *pDC, CBitmap *pBitmap, CBitmap * &pBitmapOld, CPalette *pPalette, CPalette * &pPalOld);
|
||||
static void ReleaseCompatibleContext(CDC * &pDC, CBitmap * &pBitmap, CBitmap *pBitmapOld, CPalette *pPalOld);
|
||||
|
||||
bool CreateWorkAreas(CDC *pDC);
|
||||
void UnfurlScroll(CDC *pDC);
|
||||
void UpdateMore(CDC *pDC);
|
||||
void WritePage(CDC *pDC, int nPage);
|
||||
void ShowWaitCursor();
|
||||
void DoWaitCursor(int nCode) override {
|
||||
CDialog::DoWaitCursor(nCode);
|
||||
}
|
||||
void DoArrowCursor();
|
||||
void Sleep(clock_t wait);
|
||||
|
||||
private:
|
||||
bool m_bKeyboardHook = false; // whether keyboard hook present
|
||||
CRect OkayRect; // rectangle bounding the OKAY button
|
||||
CRect ScrollRect, // x/y (left/right) and dx/dy (right/bottom) for the scroll window
|
||||
ScrollTopRect, // rectangle bounding the scroll top section
|
||||
ScrollBotRect, // rectangle bounding the scroll bottom section
|
||||
ScrollMidRect; // rectangle bounding the scroll middle section
|
||||
|
||||
CRect ScrollTopCurlRect, // current location of top curl for mouse clicks
|
||||
ScrollBotCurlRect; // current location of bottom curl for mouse clicks
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CRules)
|
||||
enum { IDD = IDD_RULES_DIALOG };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CRules)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
virtual bool OnInitDialog() override;
|
||||
afx_msg bool OnEraseBkgnd(CDC *pDC);
|
||||
virtual void OnOK() override;
|
||||
virtual void OnCancel() override;
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnShowWindow(bool bShow, unsigned int nStatus);
|
||||
afx_msg void OnSize(unsigned int nType, int cx, int cy);
|
||||
afx_msg void OnMouseMove(unsigned int nFlags, CPoint point);
|
||||
afx_msg bool OnSetCursor(CWnd *pWnd, unsigned int nHitTest, unsigned int message);
|
||||
afx_msg void OnLButtonDown(unsigned int nFlags, CPoint point);
|
||||
afx_msg void OnActivate(unsigned int nState, CWnd *pWndOther, bool bMinimized) override;
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
3182
engines/bagel/hodjnpodj/hnplibs/sprite.cpp
Normal file
3182
engines/bagel/hodjnpodj/hnplibs/sprite.cpp
Normal file
File diff suppressed because it is too large
Load Diff
346
engines/bagel/hodjnpodj/hnplibs/sprite.h
Normal file
346
engines/bagel/hodjnpodj/hnplibs/sprite.h
Normal file
@@ -0,0 +1,346 @@
|
||||
/* 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_HNPLIBS_SPRITE_H
|
||||
#define HODJNPODJ_HNPLIBS_SPRITE_H
|
||||
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
enum {
|
||||
COLOR_WHITE = RGB(255, 255, 255)
|
||||
};
|
||||
|
||||
#define SPRITE_TOPMOST 0
|
||||
#define SPRITE_FOREGROUND 64
|
||||
#define SPRITE_MIDDLE 128
|
||||
#define SPRITE_BACKGROUND 192
|
||||
#define SPRITE_HINDMOST 255
|
||||
|
||||
class CSprite : public CObject {
|
||||
DECLARE_DYNCREATE(CSprite)
|
||||
|
||||
public:
|
||||
CSprite(); // use "new" operator to create sprites, then LoadSprite
|
||||
~CSprite();
|
||||
|
||||
CSprite *DuplicateSprite(CDC *pDC);
|
||||
bool DuplicateSprite(CDC *pDC, CSprite *pSprite);
|
||||
|
||||
bool LoadSprite(CDC *pDC, const char* pszPathName);
|
||||
bool LoadSprite(CBitmap *pBitmap, CPalette *pPalette = nullptr);
|
||||
bool LoadResourceSprite(CDC *pDC, const int resId);
|
||||
bool LoadResourceSprite(CDC *pDC, const char* pszName);
|
||||
|
||||
bool LoadCels(CDC *pDC, const char* pszPathName, const int nCels);
|
||||
bool LoadCels(CBitmap *pBitmap, const int nCels, CPalette *pPalette = nullptr);
|
||||
bool LoadResourceCels(CDC *pDC, const int resId, const int nCels);
|
||||
bool LoadResourceCels(CDC *pDC, const char* pszName, const int nCels);
|
||||
|
||||
bool SetPalette(CPalette *pPalette);
|
||||
bool SharePalette(CPalette *pPalette);
|
||||
bool GetShared() {
|
||||
return (m_bSharedPalette);
|
||||
}
|
||||
|
||||
bool PaintSprite(CDC *pDC, const int x, const int y);
|
||||
bool PaintSprite(CDC *pDC, CPoint point) {
|
||||
return (PaintSprite(pDC, point.x, point.y));
|
||||
}
|
||||
|
||||
bool SetupCels(const int nCels);
|
||||
void SetCel(const int nCelID);
|
||||
void UpdateCel() {
|
||||
SetCel(m_nCelID + 1);
|
||||
}
|
||||
|
||||
bool CropImage(CDC *pDC, CRect *pRect);
|
||||
|
||||
bool RefreshSprite(CDC *pDC) {
|
||||
return (PaintSprite(pDC, m_cPosition.x, m_cPosition.y));
|
||||
}
|
||||
bool RefreshBackground(CDC *pDC);
|
||||
|
||||
bool EraseSprite(CDC *pDC);
|
||||
|
||||
void ClearBackground();
|
||||
|
||||
CSprite *Interception(CDC *pDC) {
|
||||
return (Interception(pDC, m_pSpriteChain));
|
||||
}
|
||||
CSprite *Interception(CDC *pDC, CSprite * pTestSprite);
|
||||
CSprite *Interception(CRect *newRect) {
|
||||
return (Interception(newRect, m_pSpriteChain));
|
||||
}
|
||||
CSprite *Interception(CRect *newRect, CSprite * pSprite);
|
||||
bool TestInterception(CDC *pDC, CSprite * pSprite, CPoint *pPoint = nullptr);
|
||||
|
||||
bool GetVisible() {
|
||||
return (m_bVisible);
|
||||
}
|
||||
|
||||
void SetIntercepts(bool bValue) {
|
||||
m_bIntercepts = bValue;
|
||||
}
|
||||
bool GetIntercepts() {
|
||||
return (m_bIntercepts);
|
||||
}
|
||||
|
||||
void SetPosition(int x, int y);
|
||||
void SetPosition(CPoint point) {
|
||||
SetPosition(point.x, point.y);
|
||||
}
|
||||
CPoint GetPosition() const {
|
||||
return (m_cPosition);
|
||||
}
|
||||
|
||||
void SetDelta(int x, int y) {
|
||||
m_cMovementDelta.x = x;
|
||||
m_cMovementDelta.y = y;
|
||||
}
|
||||
CPoint GetDelta() {
|
||||
return (m_cMovementDelta);
|
||||
}
|
||||
|
||||
void SetHotspot(int x, int y) {
|
||||
m_cHotspot.x = x;
|
||||
m_cHotspot.y = y;
|
||||
}
|
||||
CPoint GetHotspot() {
|
||||
return (m_cHotspot);
|
||||
}
|
||||
|
||||
CSize GetSize() {
|
||||
return (m_cSize);
|
||||
}
|
||||
|
||||
CRect GetRect() {
|
||||
return (m_cRect);
|
||||
}
|
||||
CRect GetArea() { // obsolete - use GetRect
|
||||
return (m_cRect);
|
||||
}
|
||||
|
||||
void SetMasked(bool bValue) {
|
||||
m_bMasked = bValue;
|
||||
}
|
||||
bool GetMasked() {
|
||||
return (m_bMasked);
|
||||
}
|
||||
|
||||
void SetMobile(bool bValue) {
|
||||
m_bMobile = bValue;
|
||||
}
|
||||
bool GetMobile() {
|
||||
return (m_bMobile);
|
||||
}
|
||||
|
||||
void SetOptimizeSpeed(bool bValue) {
|
||||
m_bRetainContexts = false & bValue;
|
||||
}
|
||||
bool GetOptimizeSpeed() {
|
||||
return (m_bRetainContexts);
|
||||
}
|
||||
|
||||
void SetTypeCode(int nValue) {
|
||||
m_nType = nValue;
|
||||
}
|
||||
int GetTypeCode() {
|
||||
return (m_nType);
|
||||
}
|
||||
|
||||
void SetData(CObject *pData) {
|
||||
m_pData = pData;
|
||||
}
|
||||
CObject *GetData() {
|
||||
return (m_pData);
|
||||
}
|
||||
|
||||
int GetId() {
|
||||
return (m_nId);
|
||||
}
|
||||
|
||||
void SetZOrder(int nValue) {
|
||||
m_nZOrder = nValue;
|
||||
m_nZPosition = nValue;
|
||||
}
|
||||
int GetZOrder() {
|
||||
return (m_nZOrder);
|
||||
}
|
||||
int GetZPosition() {
|
||||
return (m_nZPosition);
|
||||
}
|
||||
|
||||
int GetCelCount() {
|
||||
return (m_nCelCount);
|
||||
}
|
||||
int GetCelIndex() {
|
||||
return (m_nCelID);
|
||||
}
|
||||
|
||||
void SetAnimated(bool bAnimated) {
|
||||
m_bAnimated = bAnimated;
|
||||
}
|
||||
bool GetAnimated() {
|
||||
return (m_bAnimated);
|
||||
}
|
||||
|
||||
void SetRetainBackground(bool bValue);
|
||||
bool GetRetainBackground() {
|
||||
return (m_bRetainBackground);
|
||||
}
|
||||
|
||||
bool IsLinked() {
|
||||
return (m_bLinked);
|
||||
}
|
||||
void LinkSprite();
|
||||
void UnlinkSprite();
|
||||
CSprite *GetNextSprite() {
|
||||
return (m_pNext);
|
||||
}
|
||||
CSprite *GetPrevSprite() {
|
||||
return (m_pPrev);
|
||||
}
|
||||
|
||||
bool Touching(CPoint myPoint);
|
||||
|
||||
static CSprite *Touched(CPoint myPoint) {
|
||||
return (Touched(myPoint, m_pSpriteChain));
|
||||
}
|
||||
static CSprite *Touched(CPoint myPoint, CSprite *pSprite);
|
||||
static bool InterceptOccurred() {
|
||||
return (m_bTouchedSprite);
|
||||
}
|
||||
static CSprite *GetInterception() {
|
||||
return (m_pTouchedSprite);
|
||||
}
|
||||
|
||||
static CSprite *GetSpriteChain() {
|
||||
return (m_pSpriteChain);
|
||||
}
|
||||
static bool EraseSprites(CDC *pDC);
|
||||
static void ClearBackgrounds();
|
||||
static void FlushSpriteChain();
|
||||
|
||||
static bool HaveBackdrop() {
|
||||
return (m_bHaveBackdrop);
|
||||
}
|
||||
static CDC *GetBackdropDC(CDC *pDC);
|
||||
static void ReleaseBackdropDC();
|
||||
static bool SetBackdrop(CDC *pDC, CPalette *pPalette, CBitmap *pBitmap);
|
||||
static void ClearBackdrop();
|
||||
static bool RefreshBackdrop(CDC *pDC, CPalette *pPalette);
|
||||
|
||||
private:
|
||||
bool UpdateSprite(CDC *pDC);
|
||||
|
||||
bool SaveBackground(CDC *pDC);
|
||||
|
||||
bool CreateBackground(CDC *pDC);
|
||||
bool CreateMask(CDC *pDC);
|
||||
|
||||
bool SetupImage(CDC *pDC);
|
||||
bool SetupBackground(CDC *pDC);
|
||||
bool SetupMask(CDC *pDC);
|
||||
|
||||
bool CreateImageContext(CDC *pDC);
|
||||
bool CreateBackgroundContext(CDC *pDC);
|
||||
bool CreateMaskContext(CDC *pDC);
|
||||
|
||||
void ReleaseImageContext();
|
||||
void ReleaseBackgroundContext();
|
||||
void ReleaseMaskContext();
|
||||
|
||||
void ClearImage();
|
||||
void ClearMask();
|
||||
void ClearPalette();
|
||||
|
||||
bool SpritesOverlap(CDC *pDC, CSprite *pSprite, CPoint *pPoint = nullptr);
|
||||
|
||||
bool DoSpritePainting(CDC *pDC, CPoint cPoint);
|
||||
bool DoOptimizedPainting(CDC *pDC, CRect *pDst);
|
||||
bool DoOverlapPainting(CDC *pDC, CRect *myRect);
|
||||
bool ReconstructBackground(CDC *pDC, CRect *myRect);
|
||||
|
||||
private:
|
||||
CDC *m_pImageDC; // offscreen bitmap device context for image
|
||||
CBitmap *m_pImage; // bitmap for the sprite
|
||||
CBitmap *m_pImageOld; // previous bitmap mapped in the DC
|
||||
CDC *m_pMaskDC; // offscreen bitmap device context for mask
|
||||
CBitmap *m_pMask; // bitmap for the sprite's mask
|
||||
CBitmap *m_pMaskOld; // previous bitmap mapped in the DC
|
||||
CDC *m_pBackgroundDC; // offscreen bitmap device context for background
|
||||
CBitmap *m_pBackground; // bitmap for the sprite's background
|
||||
CBitmap *m_pBackgroundOld; // previous bitmap mapped in the DC
|
||||
CPalette *m_pPalette; // color palette for the sprite
|
||||
CPalette *m_pPalImageOld; // previous palette mapped to image DC
|
||||
CPalette *m_pPalBackOld; // previous palette mapped to background DC
|
||||
CPoint m_cPosition; // upper left corner of sprite on display
|
||||
CPoint m_cMovementDelta; // dx/dy increments for sprite movement
|
||||
CPoint m_cHotspot; // logical hotspot; e.g. for cursors
|
||||
CSize m_cSize; // dx/dy size of the sprite bitmap
|
||||
CRect m_cRect; // bounding rectangle on display
|
||||
CRect m_cImageRect; // bounding rectangle within image bitmap
|
||||
bool m_bVisible; // sprite has an image to be painted
|
||||
bool m_bIntercepts; // sprite can be detected by interception
|
||||
bool m_bSharedPalette; // palette is shared and not deleteable
|
||||
bool m_bMasked; // sprite is to be masked (ignore white)
|
||||
bool m_bMobile; // sprite is mobile or stationary
|
||||
bool m_bOverlaps; // sprite covers other sprites
|
||||
bool m_bPaintOverlap; // whether to paint sprite for overlaps
|
||||
bool m_bRetainBackground;// retain background for screen updates
|
||||
bool m_bRetainContexts; // retain device contexts across calls
|
||||
bool m_bDuplicated; // shares bitmaps with some other sprite
|
||||
bool m_bOverlapTest; // used for positional testing
|
||||
bool m_bPositioned; // whether sprite has been positioned yet
|
||||
bool m_bAnimated; // whether cel advance occurs when painting
|
||||
bool m_bLinked; // whether sprite is linked into the chain
|
||||
int m_nId; // unique sprite identifier
|
||||
int m_nType; // user defined information
|
||||
CObject *m_pData; // user defined data pointer
|
||||
int m_nZOrder; // foreground / background order
|
||||
int m_nZPosition; // foreground / background placement
|
||||
int m_nCelID; // index of current cel image
|
||||
int m_nCelCount; // number of cels in the animation strip
|
||||
CSprite *m_pNext; // pointer to next sprite in master chain
|
||||
CSprite *m_pPrev; // pointer to previous sprite in master chain
|
||||
CSprite *m_pZNext; // pointer to next sprite in z chain
|
||||
CSprite *m_pZPrev; // pointer to previous sprite in z chain
|
||||
|
||||
static int m_nIndex; // generator of sprite identifiers
|
||||
static CSprite *m_pSpriteChain; // pointer to linked chain of sprites
|
||||
static bool m_bTouchedSprite; // set when sprite painting intercepts another
|
||||
static CSprite *m_pTouchedSprite; // sprite touched during painting operation
|
||||
static bool m_bHaveBackdrop; // whether we have a backdrop bitmap
|
||||
static CDC *m_pBackdropDC; // context used for backdrop artwork
|
||||
static CBitmap *m_pBackdrop; // pointer to backdrop bitmap for background
|
||||
static CBitmap *m_pBackdropOld; // bitmap previously mapped to backdrop context
|
||||
static CPalette *m_pBackdropPalette;// palette mapped to backdrop context
|
||||
static CPalette *m_pBackdropPalOld; // palette previously mapped to backdrop context
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
23
engines/bagel/hodjnpodj/hnplibs/stdafx.h
Normal file
23
engines/bagel/hodjnpodj/hnplibs/stdafx.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* 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"
|
||||
//
|
||||
85
engines/bagel/hodjnpodj/hnplibs/stdinc.h
Normal file
85
engines/bagel/hodjnpodj/hnplibs/stdinc.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* 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_HNPLIBS_STDINC_H
|
||||
#define HODJNPODJ_HNPLIBS_STDINC_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "common/algorithm.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define BOF_DEBUG 1
|
||||
|
||||
/*
|
||||
* Math Function Macros
|
||||
*/
|
||||
#define isodd(x) ((x)&1) /* Returns 1 if number is odd */
|
||||
#define iseven(x) !((x)&1) /* Returns 1 if number is even */
|
||||
#ifndef min
|
||||
#define min(x,y) (x<y?x:y) /* returns the min of x and y */
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x,y) (x>y?x:y) /* returns the max of x and y */
|
||||
#endif
|
||||
#ifndef abs
|
||||
#define abs(x) ((x)<0?-(x):(x)) /* returns the absolute value of x */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* normal types
|
||||
*/
|
||||
#define CDECL
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
|
||||
enum {
|
||||
YES = 1,
|
||||
NO = 0
|
||||
};
|
||||
|
||||
#ifndef MAX_FNAME
|
||||
#define MAX_FNAME 256
|
||||
#endif
|
||||
|
||||
#define MAX_DIRPATH 256
|
||||
|
||||
#define Assert(f) assert(f)
|
||||
#define TRACE(s) debug(9, "%s", (s))
|
||||
|
||||
#define WF_80x87 1024
|
||||
#define WF_CPU186 128
|
||||
#define WF_CPU286 2
|
||||
#define WF_CPU386 4
|
||||
#define WF_CPU486 8
|
||||
#define WF_STANDARD 16
|
||||
#define WF_ENHANCED 32
|
||||
|
||||
inline unsigned int GetWinFlags() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
538
engines/bagel/hodjnpodj/hnplibs/text.cpp
Normal file
538
engines/bagel/hodjnpodj/hnplibs/text.cpp
Normal file
@@ -0,0 +1,538 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
int CText::m_nTabStop = 20; // tabstops every 20 pixels
|
||||
bool CText::m_bFontLoaded = false; // no font initially loaded
|
||||
|
||||
|
||||
IMPLEMENT_DYNCREATE(CText, CObject)
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* CText()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Constructor for text class. Initialize all fields.
|
||||
* SetupText must be called next to build the primary
|
||||
* data objects and work areas.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
CText::CText() {
|
||||
InitializeFields(); // initialize stuff
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* CText()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* CDC *pDC device context where the text will be displayed
|
||||
* CPalette *pPalette palette to associate with the device context
|
||||
* CRect *pRect rectangular area encompassed by the text object
|
||||
* int nJustify alignment of text in the rectangle
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Constructor for text class. Initialize all fields,
|
||||
* and then build primary data objects and work areas.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
CText::CText(CDC *pDC, CPalette *pPalette, CRect *pRect, int nJustify) {
|
||||
InitializeFields(); // initialize stuff
|
||||
SetupText(pDC, pPalette, pRect, nJustify); // build the work areas
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* ~CText()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Destructor for text class. Tears down all objects created
|
||||
* for use by the text object; e.g. device contexts, bitmaps,
|
||||
* and palettes.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
CText::~CText() {
|
||||
ReleaseContexts();
|
||||
|
||||
if (m_pWork != nullptr) {
|
||||
(*m_pWork).DeleteObject();
|
||||
delete m_pWork;
|
||||
}
|
||||
if (m_pBackground != nullptr) {
|
||||
(*m_pBackground).DeleteObject();
|
||||
delete m_pBackground;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* InitializeFields
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: Initializes key fields to zero or nullptr states.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void CText::InitializeFields() {
|
||||
m_pBackgroundDC = nullptr;
|
||||
m_pBackground = nullptr;
|
||||
m_pBackgroundOld = nullptr;
|
||||
|
||||
m_pWorkDC = nullptr;
|
||||
m_pWork = nullptr;
|
||||
m_pWorkOld = nullptr;
|
||||
|
||||
m_pPalette = nullptr;
|
||||
m_pPalBackOld = nullptr;
|
||||
m_pPalWorkOld = nullptr;
|
||||
|
||||
m_cPosition = CPoint(0, 0);
|
||||
m_cSize = CSize(0, 0);
|
||||
m_cRect.SetRect(0, 0, 0, 0);
|
||||
|
||||
m_cShadowColor = RGB(0, 0, 0);
|
||||
m_nShadow_DX = 0;
|
||||
m_nShadow_DY = 0;
|
||||
|
||||
m_bBounded = true;
|
||||
m_bHaveBackground = false;
|
||||
m_nJustify = JUSTIFY_LEFT;
|
||||
|
||||
m_pFont = nullptr;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* SetupText()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* CDC *pDC device context where the text will be displayed
|
||||
* CPalette *pPalette palette to associate with the device context
|
||||
* CRect *pRect rectangular area encompassed by the text object
|
||||
* int nJustify alignment of text in the rectangle
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* bool success/failure condition
|
||||
*
|
||||
* Description: build primary data objects and work areas; text
|
||||
* will be displayed centered within the defined
|
||||
* rectangular area, hence it is up to the caller to
|
||||
* ensure that the text fits (excess is cropped).
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
bool CText::SetupText(CDC *pDC, CPalette *pPalette, CRect *pRect, int nJustify) {
|
||||
CPalette *pPalOld = nullptr;
|
||||
|
||||
m_bBounded = true; // set for bounded area painting
|
||||
m_pPalette = pPalette;
|
||||
m_nJustify = nJustify;
|
||||
|
||||
if (m_pPalette != nullptr) {
|
||||
pPalOld = (*pDC).SelectPalette(m_pPalette, false);
|
||||
(*pDC).RealizePalette();
|
||||
}
|
||||
|
||||
if (!m_bFontLoaded) { // load the font if we have not
|
||||
m_bFontLoaded = true; // ... done so already
|
||||
AddFontResource("msserif.fon");
|
||||
}
|
||||
|
||||
m_cRect = *pRect; // setup the fields for location
|
||||
m_cSize.cx = m_cRect.right - m_cRect.left; // ... and size of the text area
|
||||
m_cSize.cy = m_cRect.bottom - m_cRect.top;
|
||||
|
||||
m_pWork = new CBitmap(); // create a bitmap to serve as our
|
||||
if ((m_pWork == nullptr) || // ... work area as we output text
|
||||
!(*m_pWork).CreateCompatibleBitmap(pDC, m_cSize.cx, m_cSize.cy))
|
||||
return false;
|
||||
|
||||
m_pBackground = new CBitmap(); // create a bitmap to hold the
|
||||
if ((m_pBackground == nullptr) || // ... background we overwrite
|
||||
!(*m_pBackground).CreateCompatibleBitmap(pDC, m_cSize.cx, m_cSize.cy))
|
||||
return false;
|
||||
|
||||
if (m_pPalette != nullptr)
|
||||
(*pDC).SelectPalette(pPalOld, false);
|
||||
|
||||
return true; // return status
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* RestoreBackground()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* CDC *pDC device context where the text was displayed
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* bool success/failure condition
|
||||
*
|
||||
* Description: repaint the background art, thereby erasing the text.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
bool CText::RestoreBackground(CDC *pDC) {
|
||||
bool bSuccess = false;
|
||||
CPalette *pPalOld = nullptr;
|
||||
|
||||
if (m_pPalette != nullptr) {
|
||||
pPalOld = (*pDC).SelectPalette(m_pPalette, false);
|
||||
(*pDC).RealizePalette();
|
||||
}
|
||||
|
||||
if ((m_pBackground != nullptr) &&
|
||||
SetupContexts(pDC)) {
|
||||
bSuccess = (*pDC).BitBlt( // simply splat the background art
|
||||
m_cRect.left, // ... back where it came from
|
||||
m_cRect.top,
|
||||
m_cSize.cx,
|
||||
m_cSize.cy,
|
||||
m_pBackgroundDC,
|
||||
0,
|
||||
0,
|
||||
SRCCOPY);
|
||||
ReleaseContexts();
|
||||
}
|
||||
|
||||
if (m_pPalette != nullptr)
|
||||
(*pDC).SelectPalette(pPalOld, false);
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* DisplayString()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* CDC *pDC device context where the text was displayed
|
||||
* char *pszText point to text string to be displayed
|
||||
* int nSize point size of the text to be used
|
||||
* int nWeight weighting of the font (FW_ identifier)
|
||||
* COLORREF crColor color that the text will be
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* bool success/failure condition
|
||||
*
|
||||
* Description: display a text string, formatted in the text object area.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
bool CText::DisplayString(CDC *pDC, const char *pszText, const int nSize, const int nWeight, const COLORREF crColor) {
|
||||
bool bSuccess;
|
||||
|
||||
m_cTextColor = crColor;
|
||||
bSuccess = DisplayText(pDC, pszText, nSize, nWeight, false);
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* DisplayShadowedString()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* CDC *pDC evice context where the text was displayed
|
||||
* char *pszText point to text string to be displayed
|
||||
* int nSize point size of the text to be used
|
||||
* int nWeight weighting of the font (FW_ identifier)
|
||||
* COLORREF crColor color that the text will be
|
||||
* COLORREF crShadow color that the text's shadow will be
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* bool success/failure condition
|
||||
*
|
||||
* Description: display a shadowed text string, formatted in the text object area.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
bool CText::DisplayShadowedString(CDC *pDC, const char *pszText, const int nSize, const int nWeight, const COLORREF crColor, const COLORREF crShadow, const int nDX, const int nDY) {
|
||||
bool bSuccess;
|
||||
|
||||
m_cTextColor = crColor;
|
||||
m_cShadowColor = crShadow;
|
||||
m_nShadow_DX = nDX;
|
||||
m_nShadow_DY = nDY;
|
||||
bSuccess = DisplayText(pDC, pszText, nSize, nWeight, true);
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* DisplayText()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* CDC *pDC evice context where the text was displayed
|
||||
* char *pszText point to text string to be displayed
|
||||
* int nSize point size of the text to be used
|
||||
* int nWeight weighting of the font (FW_ identifier)
|
||||
* bool bShadowed whether the text is shadowed
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* bool success/failure condition
|
||||
*
|
||||
* Description: display a text string, formatted in the text object area.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
bool CText::DisplayText(CDC *pDC, const char *pszText, const int nSize, const int nWeight, const bool bShadowed) {
|
||||
CFont *pFontOld = nullptr; // font that was mapped to the context
|
||||
CSize textInfo; // font info about the text to be displayed
|
||||
TEXTMETRIC fontMetrics; // info about the font itself
|
||||
CRect unionRect;
|
||||
CRect newRect;
|
||||
CPalette *pPalOld = nullptr;
|
||||
|
||||
if (m_pPalette != nullptr) {
|
||||
pPalOld = (*pDC).SelectPalette(m_pPalette, false);
|
||||
(*pDC).RealizePalette();
|
||||
}
|
||||
|
||||
if (!SetupContexts(pDC)) // setup the device contexts and map in
|
||||
return false; // ... the various bitmaps
|
||||
|
||||
if (!m_bHaveBackground) {
|
||||
(*m_pBackgroundDC).BitBlt( // grab what the background looks like
|
||||
0, // ... putting it in the work area
|
||||
0,
|
||||
m_cSize.cx,
|
||||
m_cSize.cy,
|
||||
pDC,
|
||||
m_cRect.left,
|
||||
m_cRect.top,
|
||||
SRCCOPY);
|
||||
m_bHaveBackground = true;
|
||||
}
|
||||
|
||||
// Create an instance of the specified font
|
||||
m_pFont = new CFont();
|
||||
(*m_pFont).CreateFont(nSize, 0, 0, 0, nWeight,
|
||||
0, 0, 0, 0, OUT_RASTER_PRECIS, 0,
|
||||
PROOF_QUALITY, FF_ROMAN, "MS Sans Serif");
|
||||
|
||||
pFontOld = (*m_pWorkDC).SelectObject(m_pFont); // select it into our context
|
||||
(*m_pWorkDC).GetTextMetrics(&fontMetrics); // get some info about the font
|
||||
(*m_pWorkDC).SetBkMode(TRANSPARENT); // make the text overlay transparently
|
||||
|
||||
textInfo = (*m_pWorkDC).GetTextExtent(pszText, strlen(pszText)); // get the area spanned by the text
|
||||
|
||||
(*m_pWorkDC).BitBlt( // copy the saved background to the work area
|
||||
0,
|
||||
0,
|
||||
m_cSize.cx,
|
||||
m_cSize.cy,
|
||||
m_pBackgroundDC,
|
||||
0,
|
||||
0,
|
||||
SRCCOPY);
|
||||
|
||||
m_cPosition.y = (m_cSize.cy - textInfo.cy) >> 1;
|
||||
switch (m_nJustify) {
|
||||
case JUSTIFY_CENTER:
|
||||
m_cPosition.x = (m_cSize.cx - textInfo.cx) >> 1;
|
||||
break;
|
||||
case JUSTIFY_LEFT:
|
||||
m_cPosition.x = 0;
|
||||
break;
|
||||
case JUSTIFY_RIGHT:
|
||||
m_cPosition.x = m_cSize.cx - textInfo.cx;
|
||||
}
|
||||
|
||||
m_cPosition.x = MAX<int>(m_cPosition.x, 0);
|
||||
m_cPosition.y = MAX<int>(m_cPosition.y, 0);
|
||||
|
||||
if (bShadowed) {
|
||||
(*m_pWorkDC).SetTextColor(m_cShadowColor); // set the color of the shadow
|
||||
(*m_pWorkDC).TabbedTextOut( // zap the shadow to the work area
|
||||
m_cPosition.x + m_nShadow_DX,
|
||||
m_cPosition.y + m_nShadow_DY,
|
||||
(const char *)pszText,
|
||||
strlen(pszText),
|
||||
1, &m_nTabStop, 0);
|
||||
}
|
||||
|
||||
(*m_pWorkDC).SetTextColor(m_cTextColor); // set the color of the text
|
||||
(*m_pWorkDC).TabbedTextOut( // zap the text to the work area
|
||||
m_cPosition.x,
|
||||
m_cPosition.y,
|
||||
(const char *)pszText,
|
||||
strlen(pszText),
|
||||
1, &m_nTabStop, 0);
|
||||
|
||||
(*m_pWorkDC).SelectObject(pFontOld); // map out the font
|
||||
|
||||
delete m_pFont; // release the font instance
|
||||
m_pFont = nullptr;
|
||||
|
||||
(*pDC).BitBlt( // copy the result to the destination context
|
||||
m_cRect.left,
|
||||
m_cRect.top,
|
||||
m_cSize.cx,
|
||||
m_cSize.cy,
|
||||
m_pWorkDC,
|
||||
0,
|
||||
0,
|
||||
SRCCOPY);
|
||||
|
||||
ReleaseContexts();
|
||||
|
||||
if (m_pPalette != nullptr)
|
||||
(*pDC).SelectPalette(pPalOld, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* SetupContexts()
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* CDC *pDC device context where the text is displayed
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* bool success/failure condition
|
||||
*
|
||||
* Description: create compatible device contexts for the background
|
||||
* and work areas, and map in their bitmaps.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
bool CText::SetupContexts(CDC *pDC) {
|
||||
if (m_pWorkDC == nullptr) {
|
||||
m_pWorkDC = new CDC();
|
||||
if ((m_pWorkDC == nullptr) ||
|
||||
!(*m_pWorkDC).CreateCompatibleDC(pDC))
|
||||
return false;
|
||||
if (m_pPalette != nullptr) {
|
||||
m_pPalWorkOld = (*m_pWorkDC).SelectPalette(m_pPalette, false);
|
||||
(*m_pWorkDC).RealizePalette();
|
||||
}
|
||||
m_pWorkOld = (*m_pWorkDC).SelectObject(m_pWork);
|
||||
if (m_pWorkOld == nullptr)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_pBackgroundDC == nullptr) {
|
||||
m_pBackgroundDC = new CDC();
|
||||
if ((m_pBackgroundDC == nullptr) ||
|
||||
!(*m_pBackgroundDC).CreateCompatibleDC(pDC))
|
||||
return false;
|
||||
if (m_pPalette != nullptr) {
|
||||
m_pPalBackOld = (*m_pBackgroundDC).SelectPalette(m_pPalette, false);
|
||||
(*m_pBackgroundDC).RealizePalette();
|
||||
}
|
||||
m_pBackgroundOld = (*m_pBackgroundDC).SelectObject(m_pBackground);
|
||||
if (m_pBackgroundOld == nullptr)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* ReleaseContexts()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: none
|
||||
*
|
||||
* Description: release all device contexts after mapping out palettes
|
||||
* and bitmaps.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void CText::ReleaseContexts() {
|
||||
if (m_pWorkOld != nullptr) {
|
||||
(*m_pWorkDC).SelectObject(m_pWorkOld);
|
||||
m_pWorkOld = nullptr;
|
||||
}
|
||||
if (m_pBackgroundOld != nullptr) {
|
||||
(*m_pBackgroundDC).SelectObject(m_pBackgroundOld);
|
||||
m_pBackgroundOld = nullptr;
|
||||
}
|
||||
|
||||
if (m_pPalWorkOld != nullptr) {
|
||||
(*m_pWorkDC).SelectPalette(m_pPalWorkOld, false);
|
||||
m_pPalWorkOld = nullptr;
|
||||
}
|
||||
if (m_pPalBackOld != nullptr) {
|
||||
(*m_pBackgroundDC).SelectPalette(m_pPalBackOld, false);
|
||||
m_pPalBackOld = nullptr;
|
||||
}
|
||||
|
||||
if (m_pWorkDC != nullptr) {
|
||||
(*m_pWorkDC).DeleteDC();
|
||||
delete m_pWorkDC;
|
||||
m_pWorkDC = nullptr;
|
||||
}
|
||||
if (m_pBackgroundDC != nullptr) {
|
||||
(*m_pBackgroundDC).DeleteDC();
|
||||
delete m_pBackgroundDC;
|
||||
m_pBackgroundDC = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
110
engines/bagel/hodjnpodj/hnplibs/text.h
Normal file
110
engines/bagel/hodjnpodj/hnplibs/text.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/* 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_HNPLIBS_TEXT_H
|
||||
#define HODJNPODJ_HNPLIBS_TEXT_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
// text color and offset definitions
|
||||
|
||||
#define CTEXT_COLOR RGB(0,0,0)
|
||||
#define CTEXT_SHADOW_COLOR RGB(0,0,0)
|
||||
#define CTEXT_SHADOW_DX 2
|
||||
#define CTEXT_SHADOW_DY 2
|
||||
|
||||
// text justification definitions
|
||||
enum {
|
||||
JUSTIFY_CENTER = 0,
|
||||
JUSTIFY_LEFT = 1,
|
||||
JUSTIFY_RIGHT = 2
|
||||
};
|
||||
|
||||
// text weight definitions
|
||||
|
||||
#define TEXT_DONTCARE 0
|
||||
#define TEXT_THIN FW_THIN
|
||||
#define TEXT_EXTRALIGHT FW_EXTRALIGHT
|
||||
#define TEXT_ULTRALIGHT FW_ULTRALIGHT
|
||||
#define TEXT_LIGHT FW_LIGHT
|
||||
#define TEXT_NORMAL FW_NORMAL
|
||||
#define TEXT_REGULAR FW_REGULAR
|
||||
#define TEXT_MEDIUM FW_MEDIUM
|
||||
#define TEXT_SEMIBOLD FW_SEMIBOLD
|
||||
#define TEXT_DEMIBOLD FW_DEMIBOLD
|
||||
#define TEXT_BOLD FW_BOLD
|
||||
#define TEXT_EXTRABOLD FW_EXTRABOLD
|
||||
#define TEXT_ULTRABOLD FW_ULTRABOLD
|
||||
#define TEXT_BLACK FW_BLACK
|
||||
#define TEXT_HEAVY FW_HEAVY
|
||||
|
||||
class CText : public CObject {
|
||||
DECLARE_DYNCREATE(CText)
|
||||
|
||||
public:
|
||||
CText();
|
||||
CText(CDC *pDC, CPalette *pPalette, CRect *pRect, int nJustify = JUSTIFY_CENTER);
|
||||
~CText();
|
||||
|
||||
bool SetupText(CDC *pDC, CPalette * pPalette, CRect *pRect, int nJustify = JUSTIFY_CENTER);
|
||||
bool RestoreBackground(CDC *pDC);
|
||||
bool DisplayString(CDC *pDC, const char* pszText, const int nSize, const int nWeight, const COLORREF crColor = CTEXT_COLOR);
|
||||
bool DisplayShadowedString(CDC *pDC, const char* pszText, const int nSize, const int nWeight, const COLORREF crColor, const COLORREF crShadow = CTEXT_SHADOW_COLOR, const int DX = CTEXT_SHADOW_DX, const int DY = CTEXT_SHADOW_DY);
|
||||
|
||||
private:
|
||||
void InitializeFields();
|
||||
bool SetupContexts(CDC *pDC);
|
||||
void ReleaseContexts();
|
||||
bool DisplayText(CDC *pDC, const char* pszText, const int nSize, const int nWeight, const bool bShadowed);
|
||||
|
||||
private:
|
||||
CDC *m_pBackgroundDC = nullptr; // offscreen bitmap device context for background
|
||||
CBitmap *m_pBackground = nullptr; // bitmap for the text's background
|
||||
CBitmap *m_pBackgroundOld = nullptr; // previous bitmap mapped in the DC
|
||||
CDC *m_pWorkDC = nullptr; // offscreen bitmap device context for work area
|
||||
CBitmap *m_pWork = nullptr; // bitmap for the work area
|
||||
CBitmap *m_pWorkOld = nullptr; // previous bitmap mapped in the DC
|
||||
CPalette *m_pPalette = nullptr; // color palette for the text
|
||||
CPalette *m_pPalBackOld = nullptr; // previous palette mapped to background DC
|
||||
CPalette *m_pPalWorkOld = nullptr; // previous palette mapped to work area DC
|
||||
CPoint m_cPosition; // upper left corner of text displayed
|
||||
CSize m_cSize; // dx/dy size of the text bitmap
|
||||
CRect m_cRect; // bounding rectangle of text area
|
||||
CFont *m_pFont = nullptr; // font to use for the text
|
||||
int m_nJustify = 0; // positioning within the rectangle
|
||||
bool m_bBounded = false; // bounded versus free-form text output
|
||||
bool m_bHaveBackground = false; // whether the background has been saved
|
||||
COLORREF m_cTextColor = 0; // color to use for the text itself
|
||||
COLORREF m_cShadowColor = 0; // color to use for the text's shadow
|
||||
int m_nShadow_DX = 0; // horizontal offset for shadow
|
||||
int m_nShadow_DY = 0; // vertical offset for shadow
|
||||
|
||||
static int m_nTabStop; // tabstop table
|
||||
static bool m_bFontLoaded; // font loaded flag
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user