Fix high score banner entry

This commit is contained in:
elasota
2020-02-05 00:22:55 -05:00
parent 60e0912a7b
commit 7b8052174f
4 changed files with 36 additions and 35 deletions

View File

@@ -457,7 +457,7 @@ void SetDialogNumToStr (Dialog *theDialog, short item, long theNumber)
Rect itemRect; Rect itemRect;
ControlHandle itemHandle; ControlHandle itemHandle;
short itemType; short itemType;
NumToString(theNumber, theString); NumToString(theNumber, theString);
PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget(); PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget();
widget->SetString(theString); widget->SetString(theString);

View File

@@ -46,7 +46,7 @@ void UpdateNameDialog (Dialog *);
Boolean NameFilter (Dialog *, EventRecord *, short *); Boolean NameFilter (Dialog *, EventRecord *, short *);
void GetHighScoreName (short); void GetHighScoreName (short);
void UpdateBannerDialog (Dialog *); void UpdateBannerDialog (Dialog *);
Boolean BannerFilter (Dialog *, EventRecord *, short *); int16_t BannerFilter(Dialog *dialog, const TimeTaggedVOSEvent &evt);
void GetHighScoreBanner (void); void GetHighScoreBanner (void);
Boolean OpenHighScoresFile (const VFileSpec &spec, PortabilityLayer::IOStream *&outStream); Boolean OpenHighScoresFile (const VFileSpec &spec, PortabilityLayer::IOStream *&outStream);
@@ -535,7 +535,6 @@ void UpdateBannerDialog (Dialog *theDialog)
{ {
short nChars; short nChars;
DrawDialog(theDialog);
DrawDefaultButton(theDialog); DrawDefaultButton(theDialog);
nChars = GetDialogStringLen(theDialog, kHighBannerItem); nChars = GetDialogStringLen(theDialog, kHighBannerItem);
@@ -545,7 +544,7 @@ void UpdateBannerDialog (Dialog *theDialog)
//-------------------------------------------------------------- BannerFilter //-------------------------------------------------------------- BannerFilter
// Dialog filter for the "Enter Message" dialog. // Dialog filter for the "Enter Message" dialog.
Boolean BannerFilter (Dialog *dial, EventRecord *event, short *item) int16_t BannerFilter(Dialog *dial, const TimeTaggedVOSEvent &evt)
{ {
short nChars; short nChars;
@@ -555,44 +554,36 @@ Boolean BannerFilter (Dialog *dial, EventRecord *event, short *item)
SetDialogNumToStr(dial, kBannerScoreNCharsItem, (long)nChars); SetDialogNumToStr(dial, kBannerScoreNCharsItem, (long)nChars);
keyStroke = false; keyStroke = false;
} }
switch (event->what) if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
{ {
const GpKeyboardInputEvent &kbEvent = evt.m_vosEvent.m_event.m_keyboardInputEvent;
case keyDown:
keyStroke = true; if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDownChar || kbEvent.m_eventType == GpKeyboardInputEventTypes::kAutoChar)
switch (event->message)
{ {
PlayPrioritySound(kTypingSound, kTypingPriority);
return -1; // Don't capture, need this to forward to the editbox
}
else if (kbEvent.m_eventType == GpKeyboardInputEventTypes::kDown)
{
const intptr_t keyCode = PackVOSKeyCode(kbEvent);
switch (keyCode)
{
case PL_KEY_SPECIAL(kEnter): case PL_KEY_SPECIAL(kEnter):
case PL_KEY_NUMPAD_SPECIAL(kEnter): case PL_KEY_NUMPAD_SPECIAL(kEnter):
PlayPrioritySound(kCarriageSound, kCarriagePriority); PlayPrioritySound(kCarriageSound, kCarriagePriority);
FlashDialogButton(dial, kOkayButton); FlashDialogButton(dial, kOkayButton);
*item = kOkayButton; return kOkayButton;
return(true);
break;
case PL_KEY_SPECIAL(kTab): case PL_KEY_SPECIAL(kTab):
SelectDialogItemText(dial, kHighBannerItem, 0, 1024); SelectDialogItemText(dial, kHighBannerItem, 0, 1024);
return(false); return -1;
break; }
default:
PlayPrioritySound(kTypingSound, kTypingPriority);
return(false);
} }
break;
case updateEvt:
UpdateBannerDialog(dial);
EndUpdate(dial->GetWindow());
event->what = nullEvent;
return(false);
break;
default:
return(false);
break;
} }
return -1;
} }
//-------------------------------------------------------------- GetHighScoreBanner //-------------------------------------------------------------- GetHighScoreBanner
@@ -612,10 +603,12 @@ void GetHighScoreBanner (void)
SetDialogString(theDial, kHighBannerItem, highBanner); SetDialogString(theDial, kHighBannerItem, highBanner);
SelectDialogItemText(theDial, kHighBannerItem, 0, 1024); SelectDialogItemText(theDial, kHighBannerItem, 0, 1024);
leaving = false; leaving = false;
UpdateBannerDialog(theDial);
while (!leaving) while (!leaving)
{ {
ModalDialog(BannerFilter, &item); item = theDial->ExecuteModal(BannerFilter);
if (item == kOkayButton) if (item == kOkayButton)
{ {
@@ -624,6 +617,8 @@ void GetHighScoreBanner (void)
leaving = true; leaving = true;
} }
} }
theDial->Destroy();
} }
//-------------------------------------------------------------- OpenHighScoresFile //-------------------------------------------------------------- OpenHighScoresFile

View File

@@ -384,6 +384,9 @@ void DoOptionsMenu (short theItem)
switch (theItem) switch (theItem)
{ {
case iEditor: case iEditor:
if (IsRoomEditorDisabled())
break;
#ifdef COMPILEDEMO #ifdef COMPILEDEMO
DoNotInDemo(); DoNotInDemo();
#else #else

View File

@@ -31,6 +31,9 @@ namespace PortabilityLayer
void LabelWidget::DrawControl(DrawSurface *surface) void LabelWidget::DrawControl(DrawSurface *surface)
{ {
surface->SetForeColor(StdColors::White());
surface->FillRect(m_rect);
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold); surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
surface->SetForeColor(StdColors::Black()); surface->SetForeColor(StdColors::Black());