Collision Math Toy
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
CDialogBox Class Reference

The dialog box class. More...

#include <DialogBox.h>

Inheritance diagram for CDialogBox:
CCommon

Public Member Functions

void Initialize (CObjectManager *)
 Initialize the dialog box class. More...
 
void Update ()
 Update the dialog box at 1-second intervals. More...
 
void UpdateLaunchCount ()
 Update the launch count. More...
 

Static Public Member Functions

static BOOL CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM)
 Dialog box procedure. More...
 

Static Private Member Functions

static int GetEditBox (int)
 Get number from an edit box. More...
 
static void SetEditBox (int, int)
 Set an edit box. More...
 
static void InitEditBoxes (HWND)
 Initialize edit boxes. More...
 
static void SetCheckbox (HWND, int, bool)
 Set check box. More...
 
static void InitCheckBoxes (HWND)
 Initialize check boxes. More...
 
static void InitRadioButtons (HWND)
 Initialize radio buttons. More...
 
static void InitSpinControls (HWND)
 Initialize all spin controls. More...
 
static void InitSpinControl (HWND, int, int, int)
 Init a spin control. More...
 
static LRESULT GetSliderValue (HWND, int, LPARAM)
 Get value from slider. More...
 

Static Private Attributes

static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static LParticleEngine2D * m_pFrontParticleEngine = nullptr
 Pointer to front particle engine.

 
static LParticleEngine2D * m_pBackParticleEngine = nullptr
 Pointer to front particle engine.
 
static bool m_bShowTrack = false
 Show trail of breadcrumbs.
 
static bool m_bShowReticles = false
 Show reticle at hit point.
 
static bool m_bShowImpacts = false
 Draw dots at collision points.
 
static bool m_bShowArrows = false
 Draw arrows for velocity vectors.
 
static bool m_bShowTangents = false
 Draw arrows for tangents.
 
static bool m_bShowSectors = false
 Draw arc sentinels and normals.
 
static bool m_bShowAABBs = false
 Draw shape AABBs.
 
static bool m_bShowLights = false
 Light up shapes on collision.
 
static bool m_bRotate = false
 Rotate kinematic shapes.
 
static bool m_bLaunch = false
 Launch a ball.
 
static bool m_bMute = false
 Mute the sound.
 
static float m_fNextBallScale = 0.5f
 Scale factor for ball size.
 
static int m_nMIterationsInit = 4
 Initial number of motion iterations.
 
static int m_nCIterationsInit = 6
 Initial number of collision iterations.
 
static int m_nMIterations = CCommon::m_nMIterationsInit
 Current number of motion iterations.
 
static int m_nCIterations = CCommon::m_nCIterationsInit
 Current number of collision iterations.
 
static bool m_bUseQuadTree = false
 Whether to use a quadtree.
 
static HWND m_hDlg = nullptr
 Control dialog box handle.
 
static float m_fLoad = 0.0f
 Processor load.
 
static float m_fLaunchSpeed = 1000.0f
 Speed at which the next ball will be launched.
 
static int m_nDesiredLaunchCnt = 1
 Number of balls to launch at next multilaunch.
 
static int m_nLaunched = 0
 Number of balls launched in current multilaunch.
 
static bool m_bMultiLaunch = false
 Whether launching multiple balls.
 
static int m_nBallsLaunched = 0
 Number of balls in play.
 
static float m_fFrequency = 60.0f*m_nMIterations
 Frequency, number of physics iterations per second.
 

Detailed Description

This class encapsulates all of the nasty, ugly, crufty Windows API code needed for the care and feeding of a dialog box. Don't bother to look at it unless you are really motivated to learn how it works. Unfortunately, Windows message passing needs a C-style message handler, which we have to fake in C++ by making it a static function (CDialogBox::DlgProc). That means that we have to make all of the functions it calls and member variables that they collectively access static too. That means that we have to make a static version of theobject manager pointer m_pObjectManager inherited from CCommon. Awkward.

Member Function Documentation

◆ DlgProc()

BOOL CALLBACK CDialogBox::DlgProc ( HWND  hDlg,
UINT  iMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

The Dialog Procedure processes messages from the controls on the dialog box, including radio buttons, check buttons, and edit boxes. This one's a monster, boys and girls, over 170 lines of straight-line code.

Parameters
hDlgHandle to the dialog box.
iMsgWM code for the message.
wParamWparam.
lParamlParam.
Returns
TRUE if the user quits.

if

◆ GetEditBox()

int CDialogBox::GetEditBox ( int  item)
staticprivate

Get integer value from an edit box, if something goes wrong then zero is returned, for better or for worse.

Parameters
itemId of an edit box.
Returns
Value from that edit box, 0 if there was an error.

◆ GetSliderValue()

LRESULT CDialogBox::GetSliderValue ( HWND  hDlg,
int  slider,
LPARAM  lParam 
)
staticprivate

If the LPARAM value matches the handles of a slider, then get the slider's value.

Parameters
hDlgHandle to the dialog box.
sliderSlider index.
lParamLPARAM value from message.
Returns
Value of slider if it matches the LPARAM, 0 otherwise.

◆ InitCheckBoxes()

void CDialogBox::InitCheckBoxes ( HWND  hDlg)
staticprivate

Set check boxes to initial values.

Parameters
hDlgHandle to the dialog box.

◆ InitEditBoxes()

void CDialogBox::InitEditBoxes ( HWND  hDlg)
staticprivate

Set edit boxes to initial values.

Parameters
hDlgHandle to the dialog box.

◆ Initialize()

void CDialogBox::Initialize ( CObjectManager p)

Initialize the dialog box.

Parameters
pPointer to the object manager.

◆ InitRadioButtons()

void CDialogBox::InitRadioButtons ( HWND  hDlg)
staticprivate

Set radio buttons to initial values.

Parameters
hDlgHandle to the dialog box.

◆ InitSpinControl()

void CDialogBox::InitSpinControl ( HWND  hDlg,
int  n,
int  lo,
int  hi 
)
staticprivate

Set the range for a spin control.

Parameters
hDlgHandle to the dialog box.
nSpin control.
loBottom of range.
hiTop of range.

◆ InitSpinControls()

void CDialogBox::InitSpinControls ( HWND  hDlg)
staticprivate

Set the range of all spin controls.

Parameters
hDlgHandle to the dialog box.

◆ SetCheckbox()

void CDialogBox::SetCheckbox ( HWND  hDlg,
int  n,
bool  b 
)
staticprivate

Set the checkbox state, checked or unchecked.

Parameters
hDlgHandle to the dialog box.
nCheck box.
btrue to check the checkbox.

◆ SetEditBox()

void CDialogBox::SetEditBox ( int  item,
int  n 
)
staticprivate

Set an edit box to a comma-separated integer value.

Parameters
itemId of an edit box.
nNumber to put into the edit box.

◆ Update()

void CDialogBox::Update ( )

Update the edit boxes contained in the dialog box with interesting values only after a second has elapsed. Intended to be called from CGame's ProcessFrame function.

◆ UpdateLaunchCount()

void CDialogBox::UpdateLaunchCount ( )

Immediately set the launch count edit box without waiting for the next update cycle.