Partial editbox support for high scores

This commit is contained in:
elasota
2020-02-16 20:55:47 -05:00
parent bd2e27978e
commit 8f4ac13919
18 changed files with 523 additions and 80 deletions

View File

@@ -27,7 +27,7 @@
static void HiLiteOkayButton (DrawSurface *surface);
static void UnHiLiteOkayButton (DrawSurface *surface);
static void UpdateMainPict (Dialog *);
static int16_t AboutFilter(Dialog *, const TimeTaggedVOSEvent &evt);
static int16_t AboutFilter(Dialog *, const TimeTaggedVOSEvent *evt);
static Point okayButtLowerV, okayButtUpperV;
@@ -176,17 +176,20 @@ static bool PointIsInDiagonalOkayButton(const Point &pt)
//-------------------------------------------------------------- AboutFilter
// Dialog filter for the About dialog.
static int16_t AboutFilter(Dialog *dialog, const TimeTaggedVOSEvent &evt)
static int16_t AboutFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt)
{
bool handledIt = false;
int16_t hit = -1;
if (!evt)
return -1;
Window *window = dialog->GetWindow();
DrawSurface *surface = window->GetDrawSurface();
if (evt.IsKeyDownEvent())
if (evt->IsKeyDownEvent())
{
switch (PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent))
switch (PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent))
{
case PL_KEY_SPECIAL(kEnter):
case PL_KEY_NUMPAD_SPECIAL(kEnter):
@@ -202,9 +205,9 @@ static int16_t AboutFilter(Dialog *dialog, const TimeTaggedVOSEvent &evt)
break;
}
}
else if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput)
else if (evt->m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput)
{
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
const GpMouseInputEvent &mouseEvt = evt->m_vosEvent.m_event.m_mouseInputEvent;
const Point mousePt = window->MouseToLocal(mouseEvt);
if (mouseEvt.m_eventType == GpMouseEventTypes::kDown)

View File

@@ -169,7 +169,7 @@ void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent
const bool optionDown = keyStates.IsSet(PL_KEY_EITHER_SPECIAL(kAlt));
if ((commandDown) && (!optionDown))
DoMenuChoice(MenuKey(static_cast<int>(theChar)));
DoMenuChoice(MenuKey(theChar));
else
{
switch (theChar)

View File

@@ -43,10 +43,10 @@ namespace PortabilityLayer
void DrawHighScores (DrawSurface *);
void UpdateNameDialog (Dialog *);
Boolean NameFilter (Dialog *, EventRecord *, short *);
int16_t NameFilter (Dialog *dial, const TimeTaggedVOSEvent *evt);
void GetHighScoreName (short);
void UpdateBannerDialog (Dialog *);
int16_t BannerFilter(Dialog *dialog, const TimeTaggedVOSEvent &evt);
int16_t BannerFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt);
void GetHighScoreBanner (void);
Boolean OpenHighScoresFile (const VFileSpec &spec, PortabilityLayer::IOStream *&outStream);
@@ -446,7 +446,7 @@ void UpdateNameDialog (Dialog *theDialog)
//-------------------------------------------------------------- NameFilter
// Dialog filter for the "Enter High Score Name" dialog.
int16_t NameFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t NameFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
{
short nChars;
@@ -457,13 +457,17 @@ int16_t NameFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
keyStroke = false;
}
if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
if (!evt)
return -1;
if (evt->m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
{
const GpKeyboardInputEvent &kbEvent = evt.m_vosEvent.m_event.m_keyboardInputEvent;
const GpKeyboardInputEvent &kbEvent = evt->m_vosEvent.m_event.m_keyboardInputEvent;
if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDownChar || kbEvent.m_eventType == GpKeyboardInputEventTypes::kAutoChar)
{
PlayPrioritySound(kTypingSound, kTypingPriority);
keyStroke = true;
return -1; // Don't capture, need this to forward to the editbox
}
else if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDown)
@@ -544,7 +548,7 @@ void UpdateBannerDialog (Dialog *theDialog)
//-------------------------------------------------------------- BannerFilter
// Dialog filter for the "Enter Message" dialog.
int16_t BannerFilter(Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t BannerFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
{
short nChars;
@@ -555,13 +559,17 @@ int16_t BannerFilter(Dialog *dial, const TimeTaggedVOSEvent &evt)
keyStroke = false;
}
if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
if (!evt)
return -1;
if (evt->m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
{
const GpKeyboardInputEvent &kbEvent = evt.m_vosEvent.m_event.m_keyboardInputEvent;
const GpKeyboardInputEvent &kbEvent = evt->m_vosEvent.m_event.m_keyboardInputEvent;
if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDownChar || kbEvent.m_eventType == GpKeyboardInputEventTypes::kAutoChar)
{
PlayPrioritySound(kTypingSound, kTypingPriority);
keyStroke = true;
return -1; // Don't capture, need this to forward to the editbox
}
else if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDown)

View File

@@ -44,7 +44,7 @@
void UpdateLoadDialog (Dialog *);
void PageUpHouses (Dialog *);
void PageDownHouses (Dialog *);
int16_t LoadFilter (Dialog *, const TimeTaggedVOSEvent &);
int16_t LoadFilter (Dialog *, const TimeTaggedVOSEvent *);
void SortHouseList (void);
void DoDirSearch (void);
@@ -201,13 +201,16 @@ void PageDownHouses (Dialog *theDial)
//-------------------------------------------------------------- LoadFilter
#ifndef COMPILEDEMO
int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
{
short screenCount, i, wasIndex;
if (evt.IsKeyDownEvent())
if (!evt)
return -1;
if (evt->IsKeyDownEvent())
{
const intptr_t keyCode = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
const intptr_t keyCode = PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent);
switch (keyCode)
{
case PL_KEY_SPECIAL(kEnter):
@@ -316,20 +319,20 @@ int16_t LoadFilter(Dialog *dial, const TimeTaggedVOSEvent &evt)
return -1;
}
}
else if (evt.IsLMouseDownEvent())
else if (evt->IsLMouseDownEvent())
{
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
const GpMouseInputEvent &mouseEvt = evt->m_vosEvent.m_event.m_mouseInputEvent;
lastWhenClick = evt.m_timestamp - lastWhenClick;
lastWhenClick = evt->m_timestamp - lastWhenClick;
lastWhereClick -= Point::Create(mouseEvt.m_x, mouseEvt.m_y);
return -1;
}
else if (evt.IsLMouseUpEvent())
else if (evt->IsLMouseUpEvent())
{
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
const GpMouseInputEvent &mouseEvt = evt->m_vosEvent.m_event.m_mouseInputEvent;
lastWhenClick = evt.m_timestamp;
lastWhenClick = evt->m_timestamp;
lastWhereClick = Point::Create(mouseEvt.m_x, mouseEvt.m_y);
return -1;

View File

@@ -64,27 +64,27 @@
void SetBrainsToDefaults (Dialog *);
void UpdateSettingsBrains (Dialog *);
int16_t BrainsFilter (Dialog *, const TimeTaggedVOSEvent &);
int16_t BrainsFilter (Dialog *, const TimeTaggedVOSEvent *);
void DoBrainsPrefs (void);
void SetControlsToDefaults (Dialog *);
void UpdateControlKeyName (Dialog *);
void UpdateSettingsControl (Dialog *);
int16_t ControlFilter (Dialog *, const TimeTaggedVOSEvent &);
int16_t ControlFilter (Dialog *, const TimeTaggedVOSEvent *);
void DoControlPrefs (void);
void SoundDefaults (Dialog *);
void UpdateSettingsSound (Dialog *);
void HandleSoundMusicChange (short, Boolean);
int16_t SoundFilter(Dialog *, const TimeTaggedVOSEvent &);
int16_t SoundFilter(Dialog *, const TimeTaggedVOSEvent *);
void DoSoundPrefs (void);
void DisplayDefaults (void);
void FrameDisplayIcon (Dialog *, const PortabilityLayer::RGBAColor &color);
void DisplayUpdate (Dialog *);
int16_t DisplayFilter(Dialog *dialog, const TimeTaggedVOSEvent &);
int16_t DisplayFilter(Dialog *dialog, const TimeTaggedVOSEvent *);
void DoDisplayPrefs (void);
void SetAllDefaults (void);
void FlashSettingsButton (DrawSurface *, short);
void UpdateSettingsMain (Dialog *);
int16_t PrefsFilter(Dialog *dialog, const TimeTaggedVOSEvent &evt);
int16_t PrefsFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt);
void BitchAboutChanges (void);
@@ -145,11 +145,14 @@ void UpdateSettingsBrains (Dialog *theDialog)
//-------------------------------------------------------------- BrainsFilter
int16_t BrainsFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t BrainsFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
{
if (evt.IsKeyDownEvent())
if (!evt)
return -1;
if (evt->IsKeyDownEvent())
{
intptr_t keyCode = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
intptr_t keyCode = PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent);
switch (keyCode)
{
@@ -186,6 +189,19 @@ int16_t BrainsFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
}
}
if (evt->m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
{
const GpKeyboardInputEvent &keyEvent = evt->m_vosEvent.m_event.m_keyboardInputEvent;
if (keyEvent.m_keyIDSubset == GpKeyIDSubsets::kUnicode)
return 0;
if (keyEvent.m_keyIDSubset == GpKeyIDSubsets::kASCII)
{
char asciiChar = (keyEvent.m_key.m_asciiChar);
if (asciiChar < '0' || asciiChar > '9')
return 0;
}
}
return -1;
}
@@ -220,6 +236,8 @@ void DoBrainsPrefs (void)
UpdateSettingsBrains(prefDlg);
prefDlg->GetWindow()->FocusWidget(prefDlg->GetItems()[kMaxFilesItem - 1].GetWidget());
while (!leaving)
{
itemHit = prefDlg->ExecuteModal(BrainsFilter);
@@ -353,18 +371,21 @@ void UpdateSettingsControl (Dialog *theDialog)
//-------------------------------------------------------------- ControlFilter
int16_t ControlFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t ControlFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
{
intptr_t wasKeyMap;
if (evt.IsKeyDownEvent())
if (!evt)
return -1;
if (evt->IsKeyDownEvent())
{
GpKeyIDSubset_t subset = evt.m_vosEvent.m_event.m_keyboardInputEvent.m_keyIDSubset;
GpKeyIDSubset_t subset = evt->m_vosEvent.m_event.m_keyboardInputEvent.m_keyIDSubset;
// Ignore Unicode (for now) and gamepad buttons
if (subset == GpKeyIDSubsets::kASCII || subset == GpKeyIDSubsets::kSpecial || subset == GpKeyIDSubsets::kNumPadNumber || subset == GpKeyIDSubsets::kNumPadSpecial || subset == GpKeyIDSubsets::kFKey)
{
wasKeyMap = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
wasKeyMap = PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent);
switch (whichCtrl)
{
@@ -626,13 +647,16 @@ void HandleSoundMusicChange (short newVolume, Boolean sayIt)
//-------------------------------------------------------------- SoundFilter
int16_t SoundFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t SoundFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
{
short newVolume;
if (evt.IsKeyDownEvent())
if (!evt)
return -1;
if (evt->IsKeyDownEvent())
{
intptr_t keyCode = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
intptr_t keyCode = PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent);
switch (keyCode)
{
@@ -885,11 +909,14 @@ void DisplayUpdate (Dialog *theDialog)
//-------------------------------------------------------------- DisplayFilter
int16_t DisplayFilter(Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t DisplayFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
{
if (evt.IsKeyDownEvent())
if (!evt)
return -1;
if (evt->IsKeyDownEvent())
{
switch (PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent))
switch (PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent))
{
case PL_KEY_SPECIAL(kEnter):
case PL_KEY_NUMPAD_SPECIAL(kEnter):
@@ -1194,14 +1221,17 @@ void UpdateSettingsMain (Dialog *theDialog)
//-------------------------------------------------------------- PrefsFilter
int16_t PrefsFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
int16_t PrefsFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
{
short i;
Boolean foundHit;
if (evt.IsKeyDownEvent())
if (!evt)
return -1;
if (evt->IsKeyDownEvent())
{
intptr_t packedKey = PackVOSKeyCode(evt.m_vosEvent.m_event.m_keyboardInputEvent);
intptr_t packedKey = PackVOSKeyCode(evt->m_vosEvent.m_event.m_keyboardInputEvent);
switch (packedKey)
{
@@ -1226,10 +1256,10 @@ int16_t PrefsFilter (Dialog *dial, const TimeTaggedVOSEvent &evt)
return -1;
}
}
else if (evt.IsLMouseDownEvent())
else if (evt->IsLMouseDownEvent())
{
const Window *window = dial->GetWindow();
const GpMouseInputEvent &mouseEvent = evt.m_vosEvent.m_event.m_mouseInputEvent;
const GpMouseInputEvent &mouseEvent = evt->m_vosEvent.m_event.m_mouseInputEvent;
const Point testPt = Point::Create(mouseEvent.m_x - window->m_wmX, mouseEvent.m_y - window->m_wmY);