Initial commit
This commit is contained in:
3715
engines/bagel/hodjnpodj/battlefish/bfish.cpp
Normal file
3715
engines/bagel/hodjnpodj/battlefish/bfish.cpp
Normal file
File diff suppressed because it is too large
Load Diff
151
engines/bagel/hodjnpodj/battlefish/bfish.h
Normal file
151
engines/bagel/hodjnpodj/battlefish/bfish.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BATTLEFISH_BFISH_H
|
||||
#define HODJNPODJ_BATTLEFISH_BFISH_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/stdinc.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/sprite.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/boflib/error.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
#define GRID_ROWS 8
|
||||
#define GRID_COLS 8
|
||||
#define MAX_FISH 4
|
||||
#define MAX_FISH_SIZE 2*3
|
||||
|
||||
#define MAX_TURNS MAX_FISH
|
||||
|
||||
typedef struct {
|
||||
POINT nLoc[MAX_FISH_SIZE + 1];
|
||||
byte life;
|
||||
} FISH;
|
||||
|
||||
class CBFishWindow : public CFrameWnd {
|
||||
public:
|
||||
CBFishWindow();
|
||||
void PlayGame();
|
||||
void PaintScreen();
|
||||
void LoadIniSettings();
|
||||
void SaveIniSettings();
|
||||
|
||||
protected:
|
||||
void FlushInputEvents();
|
||||
void GameReset();
|
||||
void GamePause();
|
||||
void GameResume();
|
||||
void HandleError(ERROR_CODE);
|
||||
void DeleteSprite(CSprite *);
|
||||
ERROR_CODE RepaintSpriteList(CDC *);
|
||||
ERROR_CODE LoadMasterSprites();
|
||||
void ReleaseMasterSprites();
|
||||
void PlaceUserFish();
|
||||
void PlaceEnemyFish();
|
||||
void RotateFish(int);
|
||||
void AssignFishToGrid(int);
|
||||
int GetEnemyGridIndex(CPoint);
|
||||
int GetUserGridIndex(CPoint);
|
||||
int GetFishIndex(CSprite *);
|
||||
bool OkToPlaceFish(int, CPoint, bool);
|
||||
void PlaceFish(int, CPoint);
|
||||
int IndexToId(int);
|
||||
int IdToIndex(int);
|
||||
CPoint SnapToGrid(CPoint);
|
||||
void UsersTurn(int);
|
||||
void ComputersTurn();
|
||||
int SelectRandomTarget();
|
||||
int SelectBurningTarget();
|
||||
int SelectBestFitTarget();
|
||||
int FindNeighborTarget(int, int);
|
||||
int FindTarget(int, int);
|
||||
int FindMatch(int, int);
|
||||
bool FishFits(int, int, int);
|
||||
int GetNeighbors(int, int);
|
||||
void CreatePlume(CPoint);
|
||||
void CreateHarpoon(CPoint);
|
||||
void SinkUserFish(int);
|
||||
void SinkEnemyFish(int);
|
||||
void PlaceTurnHarpoons();
|
||||
void RemoveTurnHarpoon();
|
||||
|
||||
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
|
||||
LRESULT OnMCINotify(WPARAM, LPARAM);
|
||||
LRESULT OnMMIONotify(WPARAM, LPARAM);
|
||||
void OnSoundNotify(CSound *);
|
||||
void OnPaint();
|
||||
void OnMouseMove(unsigned int, CPoint);
|
||||
void OnRButtonDown(unsigned int, CPoint);
|
||||
void OnLButtonDown(unsigned int, CPoint);
|
||||
void OnLButtonUp(unsigned int, CPoint);
|
||||
void OnSysChar(unsigned int, unsigned int, unsigned int);
|
||||
void OnSysKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnKeyDown(unsigned int, unsigned int, unsigned int);
|
||||
void OnActivate(unsigned int, CWnd *, bool) override;
|
||||
void OnClose();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
// Data Members
|
||||
//
|
||||
byte m_nUserGrid[GRID_ROWS][GRID_COLS] = {};
|
||||
byte m_nEnemyGrid[GRID_ROWS][GRID_COLS] = {};
|
||||
FISH m_aEnemyFishInfo[MAX_FISH] = {};
|
||||
FISH m_aUserFishInfo[MAX_FISH] = {};
|
||||
CRect m_rNewGameButton;
|
||||
CRect m_rEndPlacement;
|
||||
CPoint m_cLastPoint;
|
||||
CSprite *m_pHarpoons[MAX_TURNS] = {};
|
||||
CSprite *m_pFish[MAX_FISH] = {};
|
||||
CSprite *m_pEnemyFish[MAX_FISH] = {};
|
||||
CSprite *m_pMasterHit = nullptr;
|
||||
CSprite *m_pMasterMiss = nullptr;
|
||||
CSprite *m_pMasterHarpoon = nullptr;
|
||||
CSprite *m_pDragFish = nullptr;
|
||||
CSprite *m_pScrollSprite = nullptr;
|
||||
CSprite *m_pOctopus = nullptr;
|
||||
CPalette *m_pGamePalette = nullptr;
|
||||
CSound *m_pSoundTrack = nullptr;
|
||||
CText *m_pTxtClickHere = nullptr;
|
||||
int m_nEnemyFish = 0;
|
||||
int m_nUserFish = 0;
|
||||
int m_nTurns = 0;
|
||||
int m_nDifficultyLevel = 0;
|
||||
bool m_bGameActive = false;
|
||||
bool m_bPause = false;
|
||||
bool m_bUserEditMode = false;
|
||||
bool m_bMovingFish = false;
|
||||
bool m_bLastRotated = false;
|
||||
bool m_bStillCheck = false;
|
||||
bool m_bUsersTurn = false;
|
||||
bool m_bInMenu = false;
|
||||
};
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
98
engines/bagel/hodjnpodj/battlefish/init.cpp
Normal file
98
engines/bagel/hodjnpodj/battlefish/init.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
#include "bagel/hodjnpodj/battlefish/bfish.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
HINSTANCE hDLLInst;
|
||||
HINSTANCE hExeInst;
|
||||
extern LPGAMESTRUCT pGameParams;
|
||||
|
||||
// global the pointer to the your game's main window
|
||||
HWND ghParentWnd;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public C interface
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* RunBFish
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* This is the API function for the DLL. It is what the calling app
|
||||
* calls to invoke poker
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* hParentWnd, lpGameInfo
|
||||
*
|
||||
* IMPLICIT INPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* IMPLICIT OUTPUT PARAMETERS:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* n/a
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
HWND FAR PASCAL RunBFish(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
|
||||
CBFishWindow *pMain;
|
||||
|
||||
pGameParams = lpGameInfo;
|
||||
|
||||
// invoke your game here by creating a pGame for your main window
|
||||
// look at the InitInstance for your game for this
|
||||
|
||||
ghParentWnd = hParentWnd;
|
||||
|
||||
if ((pMain = new CBFishWindow) != nullptr) {
|
||||
|
||||
pMain->ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
pMain->UpdateWindow();
|
||||
|
||||
pMain->SetActiveWindow();
|
||||
|
||||
if (pGameParams->bPlayingMetagame)
|
||||
pMain->PlayGame();
|
||||
}
|
||||
|
||||
// these must be set in this function
|
||||
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
|
||||
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
|
||||
|
||||
return pMain->m_hWnd; // return the m_hWnd of your main game window
|
||||
}
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
33
engines/bagel/hodjnpodj/battlefish/init.h
Normal file
33
engines/bagel/hodjnpodj/battlefish/init.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
extern HWND FAR PASCAL RunBFish(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
407
engines/bagel/hodjnpodj/battlefish/usercfg.cpp
Normal file
407
engines/bagel/hodjnpodj/battlefish/usercfg.cpp
Normal file
@@ -0,0 +1,407 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/globals.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/text.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/hodjnpodj/battlefish/usercfg.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
#define ID_RESET 104
|
||||
#define ID_LIMIT 105
|
||||
|
||||
#define ID_PLAYER 106
|
||||
#define ID_COMPUTER 107
|
||||
|
||||
#define PAGE_SIZE 1
|
||||
|
||||
static const char *pszDiffLevel[DIFF_MAX + 1] = {
|
||||
"Wimpy",
|
||||
"Average",
|
||||
"Hefty"
|
||||
};
|
||||
|
||||
extern const char *INI_SECTION;
|
||||
|
||||
|
||||
CUserCfgDlg::CUserCfgDlg(CWnd *pParent, CPalette *pPalette, unsigned int nID)
|
||||
: CBmpDialog(pParent, pPalette, nID, ".\\ART\\SSCROLL.BMP") {
|
||||
m_pOKButton = nullptr;
|
||||
m_pCancelButton = nullptr;
|
||||
m_pDefaultsButton = nullptr;
|
||||
m_pUserButton = nullptr;
|
||||
m_pCompButton = nullptr;
|
||||
DoModal();
|
||||
}
|
||||
|
||||
bool CUserCfgDlg::OnInitDialog() {
|
||||
CRect tmpRect;
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnInitDialog();
|
||||
|
||||
m_pTxtLevel = nullptr;
|
||||
m_pTxtDifficulty = nullptr;
|
||||
|
||||
tmpRect.SetRect(22, 135, 122, 155);
|
||||
if ((m_pScrollBar = new CScrollBar) != nullptr) {
|
||||
m_pScrollBar->Create(WS_VISIBLE | WS_CHILD | SBS_HORZ | SBS_BOTTOMALIGN, tmpRect, this, ID_LIMIT);
|
||||
m_pScrollBar->SetScrollRange(DIFF_MIN, DIFF_MAX, true);
|
||||
}
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
tmpRect.SetRect(25, 111, 80, 131);
|
||||
if ((m_pTxtLevel = new CText) != nullptr) {
|
||||
m_pTxtLevel->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(81, 111, 146, 131);
|
||||
if ((m_pTxtDifficulty = new CText) != nullptr) {
|
||||
m_pTxtDifficulty->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
tmpRect.SetRect(25, 20, 150, 40);
|
||||
if ((m_pTxtOrder = new CText) != nullptr) {
|
||||
m_pTxtOrder->SetupText(pDC, m_pPalette, &tmpRect, JUSTIFY_LEFT);
|
||||
}
|
||||
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
if ((m_pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*m_pOKButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*m_pOKButton).SetControl(IDOK, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*m_pCancelButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*m_pCancelButton).SetControl(IDCANCEL, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pDefaultsButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
|
||||
(*m_pDefaultsButton).SetPalette(m_pPalette); // set the palette to use
|
||||
(*m_pDefaultsButton).SetControl(ID_RESET, this); // tie to the dialog control
|
||||
}
|
||||
|
||||
if ((m_pUserButton = new CRadioButton) != nullptr) {
|
||||
tmpRect.SetRect(21, 32, 75, 45);
|
||||
//m_pUserButton->Create("Human", BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP | BS_OWNERDRAW, tmpRect, this, ID_PLAYER);
|
||||
m_pUserButton->SetPalette(m_pPalette);
|
||||
m_pUserButton->SetControl(ID_PLAYER, this);
|
||||
}
|
||||
|
||||
if ((m_pCompButton = new CRadioButton) != nullptr) {
|
||||
tmpRect.SetRect(21, 45, 75, 58);
|
||||
//m_pUserButton->Create("Computer", BS_AUTORADIOBUTTON | WS_TABSTOP | BS_OWNERDRAW, tmpRect, this, ID_COMPUTER);
|
||||
m_pCompButton->SetPalette(m_pPalette);
|
||||
m_pCompButton->SetControl(ID_COMPUTER, this);
|
||||
}
|
||||
|
||||
m_bSave = false;
|
||||
|
||||
LoadIniSettings();
|
||||
|
||||
PutDlgData();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::PutDlgData() {
|
||||
m_pScrollBar->SetScrollPos(m_nDifficultyLevel);
|
||||
|
||||
m_pUserButton->SetCheck(m_bUserGoesFirst);
|
||||
m_pCompButton->SetCheck(!m_bUserGoesFirst);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::GetDlgData() {
|
||||
m_nDifficultyLevel = m_pScrollBar->GetScrollPos();
|
||||
|
||||
m_bUserGoesFirst = false;
|
||||
if (m_pUserButton->GetCheck() == 1)
|
||||
m_bUserGoesFirst = true;
|
||||
}
|
||||
|
||||
|
||||
bool CUserCfgDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
|
||||
//
|
||||
// respond to user
|
||||
//
|
||||
if (HIWORD(lParam) == BN_CLICKED) {
|
||||
|
||||
switch (wParam) {
|
||||
|
||||
case IDOK:
|
||||
m_bSave = true;
|
||||
ClearDialogImage();
|
||||
EndDialog(IDOK);
|
||||
return false;
|
||||
|
||||
case IDCANCEL:
|
||||
ClearDialogImage();
|
||||
EndDialog(IDCANCEL);
|
||||
return false;
|
||||
|
||||
case ID_PLAYER:
|
||||
m_bUserGoesFirst = true;
|
||||
PutDlgData();
|
||||
break;
|
||||
|
||||
case ID_COMPUTER:
|
||||
m_bUserGoesFirst = false;
|
||||
PutDlgData();
|
||||
break;
|
||||
|
||||
/*
|
||||
* reset params to default
|
||||
*/
|
||||
case ID_RESET:
|
||||
|
||||
m_nDifficultyLevel = DIFF_DEF;
|
||||
m_bUserGoesFirst = TURN_DEF;
|
||||
|
||||
PutDlgData();
|
||||
DispLimit();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CBmpDialog::OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar *pScroll) {
|
||||
switch (nSBCode) {
|
||||
|
||||
case SB_LEFT:
|
||||
m_nDifficultyLevel = DIFF_MIN;
|
||||
break;
|
||||
|
||||
case SB_PAGELEFT:
|
||||
m_nDifficultyLevel -= PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINELEFT:
|
||||
if (m_nDifficultyLevel > DIFF_MIN)
|
||||
m_nDifficultyLevel--;
|
||||
break;
|
||||
|
||||
case SB_RIGHT:
|
||||
m_nDifficultyLevel = DIFF_MAX;
|
||||
break;
|
||||
|
||||
case SB_PAGERIGHT:
|
||||
m_nDifficultyLevel += PAGE_SIZE;
|
||||
break;
|
||||
|
||||
case SB_LINERIGHT:
|
||||
if (m_nDifficultyLevel < DIFF_MAX)
|
||||
m_nDifficultyLevel++;
|
||||
break;
|
||||
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
m_nDifficultyLevel = nPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_nDifficultyLevel <= DIFF_MIN)
|
||||
m_nDifficultyLevel = DIFF_MIN;
|
||||
if (m_nDifficultyLevel > DIFF_MAX)
|
||||
m_nDifficultyLevel = DIFF_MAX;
|
||||
|
||||
// can't access a null pointer
|
||||
assert(pScroll != nullptr);
|
||||
|
||||
pScroll->SetScrollPos(m_nDifficultyLevel);
|
||||
|
||||
DispLimit();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* LoadIniSettings
|
||||
*
|
||||
* FUNCTIONAL DESCRIPTION:
|
||||
*
|
||||
* Loads this game's parameters from .INI file
|
||||
*
|
||||
* FORMAL PARAMETERS:
|
||||
*
|
||||
* None
|
||||
*
|
||||
* RETURN VALUE:
|
||||
*
|
||||
* None
|
||||
*
|
||||
****************************************************************/
|
||||
void CUserCfgDlg::LoadIniSettings() {
|
||||
int nVal;
|
||||
|
||||
// Get the Difficulty level (0..2)
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "DifficultyLevel", DIFF_DEF, INI_FILENAME);
|
||||
m_nDifficultyLevel = nVal;
|
||||
if (nVal < DIFF_MIN || nVal > DIFF_MAX)
|
||||
m_nDifficultyLevel = DIFF_DEF;
|
||||
|
||||
// Get the UserGoesFirst option setting
|
||||
//
|
||||
nVal = GetPrivateProfileInt(INI_SECTION, "UserGoesFirst", TURN_DEF, INI_FILENAME);
|
||||
m_bUserGoesFirst = (nVal == 0 ? false : true);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::SaveIniSettings() {
|
||||
WritePrivateProfileString(INI_SECTION,
|
||||
"DifficultyLevel",
|
||||
Common::String::format("%d", m_nDifficultyLevel).c_str(),
|
||||
INI_FILENAME);
|
||||
|
||||
WritePrivateProfileString(INI_SECTION,
|
||||
"UserGoesFirst",
|
||||
Common::String::format("%d", m_bUserGoesFirst).c_str(),
|
||||
INI_FILENAME);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnPaint() {
|
||||
CDC *pDC;
|
||||
|
||||
CBmpDialog::OnPaint();
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
m_pTxtLevel->DisplayString(pDC, "Difficulty:", 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
m_pTxtOrder->DisplayString(pDC, "Who goes first?", 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
|
||||
DispLimit();
|
||||
}
|
||||
|
||||
void CUserCfgDlg::OnDestroy() {
|
||||
if (m_pOKButton != nullptr) { // release the button
|
||||
delete m_pOKButton;
|
||||
m_pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pCancelButton != nullptr) { // release the button
|
||||
delete m_pCancelButton;
|
||||
m_pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pDefaultsButton != nullptr) { // release the button
|
||||
delete m_pDefaultsButton;
|
||||
m_pDefaultsButton = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtDifficulty != nullptr);
|
||||
if (m_pTxtDifficulty != nullptr) {
|
||||
delete m_pTxtDifficulty;
|
||||
m_pTxtDifficulty = nullptr;
|
||||
}
|
||||
|
||||
assert(m_pTxtLevel != nullptr);
|
||||
if (m_pTxtLevel != nullptr) {
|
||||
delete m_pTxtLevel;
|
||||
m_pTxtLevel = nullptr;
|
||||
}
|
||||
|
||||
if (m_pTxtOrder != nullptr) {
|
||||
delete m_pTxtOrder;
|
||||
m_pTxtOrder = nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
// de-allocate the scroll bar
|
||||
//
|
||||
assert(m_pScrollBar != nullptr);
|
||||
if (m_pScrollBar != nullptr) {
|
||||
delete m_pScrollBar;
|
||||
m_pScrollBar = nullptr;
|
||||
}
|
||||
|
||||
CBmpDialog::OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
void CUserCfgDlg::ClearDialogImage() {
|
||||
if (m_bSave) {
|
||||
GetDlgData();
|
||||
SaveIniSettings();
|
||||
}
|
||||
|
||||
if (m_pCompButton != nullptr) {
|
||||
delete m_pCompButton;
|
||||
m_pCompButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pUserButton != nullptr) {
|
||||
delete m_pUserButton;
|
||||
m_pUserButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pOKButton != nullptr) { // release the button
|
||||
delete m_pOKButton;
|
||||
m_pOKButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pCancelButton != nullptr) { // release the button
|
||||
delete m_pCancelButton;
|
||||
m_pCancelButton = nullptr;
|
||||
}
|
||||
|
||||
if (m_pDefaultsButton != nullptr) { // release the button
|
||||
delete m_pDefaultsButton;
|
||||
m_pDefaultsButton = nullptr;
|
||||
}
|
||||
|
||||
ValidateRect(nullptr);
|
||||
}
|
||||
|
||||
void CUserCfgDlg::DispLimit() {
|
||||
CDC *pDC;
|
||||
|
||||
if ((pDC = GetDC()) != nullptr) {
|
||||
|
||||
m_pTxtDifficulty->DisplayString(pDC, pszDiffLevel[m_nDifficultyLevel], 14, TEXT_BOLD, RGB(0, 0, 0));
|
||||
ReleaseDC(pDC);
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CUserCfgDlg, CBmpDialog)
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
80
engines/bagel/hodjnpodj/battlefish/usercfg.h
Normal file
80
engines/bagel/hodjnpodj/battlefish/usercfg.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BATTLEFISH_USERCFG_H
|
||||
#define HODJNPODJ_BATTLEFISH_USERCFG_H
|
||||
|
||||
#include "bagel/afxwin.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
|
||||
#include "bagel/hodjnpodj/hnplibs/button.h"
|
||||
#include "bagel/boflib/misc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Battlefish {
|
||||
|
||||
#define IDD_USERCFG 100
|
||||
|
||||
#define DIFF_MIN 0
|
||||
#define DIFF_MAX 2
|
||||
#define DIFF_DEF 2
|
||||
|
||||
#define TURN_DEF false
|
||||
|
||||
class CUserCfgDlg : public CBmpDialog {
|
||||
public:
|
||||
CUserCfgDlg(CWnd *pParent = nullptr, CPalette *pPalette = nullptr, unsigned int = IDD_USERCFG);
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool OnCommand(WPARAM, LPARAM) override;
|
||||
virtual bool OnInitDialog() override;
|
||||
void PutDlgData();
|
||||
void GetDlgData();
|
||||
void DispLimit();
|
||||
void LoadIniSettings();
|
||||
void SaveIniSettings();
|
||||
|
||||
void OnHScroll(unsigned int, unsigned int, CScrollBar *);
|
||||
void OnDestroy();
|
||||
void OnPaint();
|
||||
void ClearDialogImage();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CColorButton *m_pOKButton = nullptr; // OKAY button on scroll
|
||||
CColorButton *m_pCancelButton = nullptr; // Cancel button on scroll
|
||||
CColorButton *m_pDefaultsButton = nullptr; // Defaults button on scroll
|
||||
CRadioButton *m_pUserButton = nullptr;
|
||||
CRadioButton *m_pCompButton = nullptr;
|
||||
CText *m_pTxtDifficulty = nullptr;
|
||||
CText *m_pTxtLevel = nullptr;
|
||||
CText *m_pTxtOrder = nullptr;
|
||||
CScrollBar *m_pScrollBar = nullptr;
|
||||
unsigned int m_nDifficultyLevel = 0; // Difficulty level for BattleFish
|
||||
bool m_bSave = false; // True if should save theses settings
|
||||
bool m_bUserGoesFirst = false; // true if Human player goes 1st
|
||||
};
|
||||
|
||||
} // namespace Battlefish
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user