Files
source/Editor/messagebox.cpp
T
00fb898600 Delete builddefines.h
Nothing was left in it but the include of profiler.h, and 132 translation units
were including it for that alone. Fifteen files were leaning on profiler.h to
drag in <set>, <vector> and <ostream> for them; those now include what they use.

This is the commit that moves line numbers. Removing an include line shifts
__LINE__ by one for everything below it, and __LINE__ is an immediate operand in
every Assert() and DebugMsg() call, so the four game executables differ from
their predecessors by roughly a thousand 32-bit constants each. Every one of
those is accounted for: each is a single immediate that moved by -1 where the
builddefines.h include went away, or +1 where a <set>/<vector> include was
added. Nothing else in .text, .rdata or .data moves, no object file's section
sizes change, and symbolize_crash and Ja2Export stay bit-identical.

The one non-immediate difference is that the 24 Editor translation units of the
non-editor apps stop emitting __Avx2WmemEnabledWeakValue, a 4-byte weak COMDAT
they only ever instantiated through profiler.h's <vector>. It is a UCRT weak
default that other translation units still provide.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 01:07:26 -03:00

162 lines
4.2 KiB
C++

#ifdef JA2EDITOR
#include "vobject.h"
#include "video.h"
#include "Font.h"
#include "Font Control.h"
#include "messagebox.h"
#include "input.h"
#include "english.h"
//internal variables.
INT32 iMsgBoxNum;
INT32 iMsgBoxOkImg, iMsgBoxCancelImg;
INT32 iMsgBoxBgrnd,iMsgBoxOk,iMsgBoxCancel;
SGPRect MsgBoxRect;
BOOLEAN gfMessageBoxResult = FALSE;
UINT8 gubMessageBoxStatus = MESSAGEBOX_NONE;
void MsgBoxOkClkCallback( GUI_BUTTON *butn, INT32 reason );
void MsgBoxCnclClkCallback( GUI_BUTTON *butn, INT32 reason );
void CreateMessageBox( STR16 wzString )
{
INT16 sPixLen;
INT16 sStartX, sStartY;
sPixLen = StringPixLength ( wzString, (UINT16)gpLargeFontType1 ) + 10;
if ( sPixLen > iScreenWidthOffset + 600 )
sPixLen = iScreenWidthOffset + 600;
sStartX = (SCREEN_WIDTH - sPixLen) / 2;
sStartY = ((SCREEN_HEIGHT - 96) / 2);
gfMessageBoxResult = FALSE;
// Fake button for background w/ text
iMsgBoxBgrnd = CreateTextButton( wzString, (UINT16)gpLargeFontType1,
FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT, sStartX, sStartY,
sPixLen, 96, BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST - 2,
BUTTON_NO_CALLBACK, BUTTON_NO_CALLBACK);
DisableButton( iMsgBoxBgrnd );
SpecifyDisabledButtonStyle( iMsgBoxBgrnd, DISABLED_STYLE_NONE );
iMsgBoxOkImg = LoadButtonImage("EDITOR//ok.sti",0,1,2,3,4);
iMsgBoxCancelImg = LoadButtonImage("EDITOR//cancel.sti",0,1,2,3,4);
iMsgBoxOk = QuickCreateButton(iMsgBoxOkImg, (INT16)(sStartX + (sPixLen/2) - 35), (INT16)(sStartY + 58),
BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST - 1,
BUTTON_NO_CALLBACK, (GUI_CALLBACK)MsgBoxOkClkCallback);
iMsgBoxCancel = QuickCreateButton(iMsgBoxCancelImg, (INT16)(sStartX + (sPixLen/2) + 5), (INT16)(sStartY + 58),
BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST - 1,
BUTTON_NO_CALLBACK, (GUI_CALLBACK)MsgBoxCnclClkCallback);
MsgBoxRect.iLeft = sStartX;
MsgBoxRect.iTop = sStartY;
MsgBoxRect.iRight = sStartX + sPixLen;
MsgBoxRect.iBottom = sStartY + 96;
RestrictMouseCursor( &MsgBoxRect );
gubMessageBoxStatus = MESSAGEBOX_WAIT;
}
BOOLEAN MessageBoxHandled()
{
InputAtom DummyEvent;
while (DequeueSpecificEvent(&DummyEvent, KEY_DOWN|KEY_UP|KEY_REPEAT))
{
if ( DummyEvent.usEvent == KEY_DOWN )
{
switch( DummyEvent.usParam )
{
case ENTER:
case 'y':
case 'Y':
gubMessageBoxStatus = MESSAGEBOX_DONE;
gfMessageBoxResult = TRUE;
break;
case ESC:
case 'n':
case 'N':
gubMessageBoxStatus = MESSAGEBOX_DONE;
gfMessageBoxResult = FALSE;
break;
}
}
}
if( gubMessageBoxStatus == MESSAGEBOX_DONE )
{
while( DequeueEvent( &DummyEvent ) )
continue;
}
MarkButtonsDirty();
RenderButtons( );
// InvalidateScreen( );
// ExecuteBaseDirtyRectQueue();
EndFrameBufferRender( );
return gubMessageBoxStatus == MESSAGEBOX_DONE;
}
void RemoveMessageBox( )
{
FreeMouseCursor( FALSE );
RemoveButton( iMsgBoxCancel );
RemoveButton( iMsgBoxOk );
RemoveButton( iMsgBoxBgrnd );
UnloadButtonImage( iMsgBoxOkImg );
UnloadButtonImage( iMsgBoxCancelImg );
gubMessageBoxStatus = MESSAGEBOX_NONE;
}
//----------------------------------------------------------------------------------------------
// Quick Message Box button callback functions.
//----------------------------------------------------------------------------------------------
void MsgBoxOkClkCallback( GUI_BUTTON *butn, INT32 reason )
{
if ( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN)
{
butn->uiFlags |= BUTTON_CLICKED_ON;
}
else if ( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
gubMessageBoxStatus = MESSAGEBOX_DONE;
gfMessageBoxResult = TRUE;
}
}
void MsgBoxCnclClkCallback( GUI_BUTTON *butn, INT32 reason )
{
if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
butn->uiFlags |= BUTTON_CLICKED_ON;
}
else if ( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
gubMessageBoxStatus = MESSAGEBOX_DONE;
gfMessageBoxResult = FALSE;
}
}
//----------------------------------------------------------------------------------------------
// End of the quick message box callback functions
//----------------------------------------------------------------------------------------------
#endif