Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QoL changes for mapeditor selection window #383

Merged
merged 3 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Editor/editscreen.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "builddefines.h"
#include "builddefines.h"

#ifdef JA2EDITOR

Expand Down Expand Up @@ -2954,6 +2954,23 @@ UINT32 WaitForSelectionWindowResponse( void )
}
}

// Mousewheel scroll
if (_WheelValue > 0)
{
while (_WheelValue--)
{
ScrollSelWinUp();
}
}
else
{
while (_WheelValue++)
{
ScrollSelWinDown();
}
}
_WheelValue = 0;

if ( DoWindowSelection( ) )
{
fSelectionWindow = FALSE;
Expand Down
96 changes: 60 additions & 36 deletions Editor/selectwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ extern BOOLEAN fDontUseRandom;

extern UINT16 GenericButtonFillColors[40];

struct SelectionWindow
{
SGPRect window;
SGPPoint displayAreaStart; // Area where selectable items are drawn
SGPPoint displayAreaEnd;
SGPPoint spacing; // For displayed items
};

SelectionWindow gSelection;

BOOLEAN gfRenderSquareArea = FALSE;
INT16 iStartClickX,iStartClickY;
INT16 iEndClickX,iEndClickY;
Expand All @@ -40,7 +50,6 @@ INT32 iSelectWin,iCancelWin,iScrollUp,iScrollDown,iOkWin;
BOOLEAN fAllDone=FALSE;
BOOLEAN fButtonsPresent=FALSE;

SGPPoint SelWinSpacing, SelWinStartPoint, SelWinEndPoint;

//These definitions help define the start and end of the various wall indices.
//This needs to be maintained if the walls change.
Expand Down Expand Up @@ -172,6 +181,30 @@ UINT16 SelWinHilightFillColor = 0x23BA; //blue, formerly 0x000d a kind of mediu
//
void CreateJA2SelectionWindow( INT16 sWhat )
{
auto selectWinWidth = 600;
const auto selectWinHeight = SCREEN_HEIGHT - 120; // From top edge to taskbar
if (iResolution > _800x600)
{
selectWinWidth = 900;
}
auto tlX = 0;
auto tlY = 0;
auto brX = tlX + selectWinWidth;
auto brY = tlY + selectWinHeight;
gSelection.window.iLeft = tlX;
gSelection.window.iTop = tlY;
gSelection.window.iRight = brX;
gSelection.window.iBottom = brY;
gSelection.displayAreaStart.iX = tlX + 1;
gSelection.displayAreaStart.iY = tlY + 15;
gSelection.displayAreaEnd.iX = brX - 1;
gSelection.displayAreaEnd.iY= brY - 1;
gSelection.spacing.iX = 2;
gSelection.spacing.iY = 2;

iTopWinCutOff = gSelection.displayAreaStart.iY;
iBotWinCutOff = gSelection.displayAreaEnd.iY;

DisplaySpec *pDSpec;
UINT16 usNSpecs;

Expand All @@ -185,51 +218,40 @@ void CreateJA2SelectionWindow( INT16 sWhat )
iButtonIcons[ SEL_WIN_DOWN_ICON ] = LoadGenericButtonIcon( "EDITOR//lgDownArrow.sti" );
iButtonIcons[ SEL_WIN_OK_ICON ] = LoadGenericButtonIcon( "EDITOR//checkmark.sti" );

iSelectWin = CreateHotSpot(0, 0, 600, 360, MSYS_PRIORITY_HIGH,

iSelectWin = CreateHotSpot(0, 0, selectWinWidth, selectWinHeight, MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, SelWinClkCallback);

iOkWin = CreateIconButton((INT16)iButtonIcons[SEL_WIN_OK_ICON], 0,
BUTTON_USE_DEFAULT, 600, 0,
BUTTON_USE_DEFAULT, selectWinWidth, 0,
40, 40, BUTTON_TOGGLE,
MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, OkClkCallback);
SetButtonFastHelpText(iOkWin,pDisplaySelectionWindowButtonText[0]);

iCancelWin = CreateIconButton((INT16)iButtonIcons[SEL_WIN_CANCEL_ICON], 0,
BUTTON_USE_DEFAULT, 600, 40,
BUTTON_USE_DEFAULT, selectWinWidth, 40,
40, 40, BUTTON_TOGGLE,
MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, CnclClkCallback);
SetButtonFastHelpText(iCancelWin,pDisplaySelectionWindowButtonText[1]);

iScrollUp = CreateIconButton((INT16)iButtonIcons[SEL_WIN_UP_ICON], 0,
BUTTON_USE_DEFAULT, 600, 80,
BUTTON_USE_DEFAULT, selectWinWidth, 80,
40, 160, BUTTON_NO_TOGGLE,
MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, UpClkCallback);
SetButtonFastHelpText(iScrollUp,pDisplaySelectionWindowButtonText[2]);

iScrollDown = CreateIconButton((INT16)iButtonIcons[SEL_WIN_DOWN_ICON], 0,
BUTTON_USE_DEFAULT, 600, 240,
BUTTON_USE_DEFAULT, selectWinWidth, 240,
40, 160, BUTTON_NO_TOGGLE,
MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, DwnClkCallback);
SetButtonFastHelpText(iScrollDown,pDisplaySelectionWindowButtonText[3]);

fButtonsPresent = TRUE;

SelWinSpacing.iX = 2;
SelWinSpacing.iY = 2;

SelWinStartPoint.iX = 1;
SelWinStartPoint.iY = 15;

iTopWinCutOff = 15;

SelWinEndPoint.iX = 599;
SelWinEndPoint.iY = 359;

iBotWinCutOff = 359;

switch( sWhat )
{
Expand Down Expand Up @@ -347,8 +369,8 @@ void CreateJA2SelectionWindow( INT16 sWhat )
return;
}

BuildDisplayWindow( pDSpec, usNSpecs, &pDispList, &SelWinStartPoint, &SelWinEndPoint,
&SelWinSpacing, CLEAR_BACKGROUND);
BuildDisplayWindow( pDSpec, usNSpecs, &pDispList, &gSelection.displayAreaStart , &gSelection.displayAreaEnd,
&gSelection.spacing, CLEAR_BACKGROUND);
}


Expand Down Expand Up @@ -849,28 +871,30 @@ void RenderSelectionWindow( void )
return;

ColorFillVideoSurfaceArea(FRAME_BUFFER,
0, 0, 600, 400,
GenericButtonFillColors[0]);
gSelection.window.iLeft, gSelection.window.iTop, gSelection.window.iRight, gSelection.window.iBottom,
GenericButtonFillColors[0]
);
DrawSelections( );
MarkButtonsDirty();
RenderButtons( );

// Draw selection rectangle
if ( gfRenderSquareArea )
{
button = ButtonList[iSelectWin];
if ( button == NULL )
return;

if ( (abs( iStartClickX - button->Area.MouseXPos ) > 9) ||
(abs( iStartClickY - (button->Area.MouseYPos + iTopWinCutOff - (INT16)SelWinStartPoint.iY)) > 9) )
(abs( iStartClickY - (button->Area.MouseYPos + iTopWinCutOff - (INT16)gSelection.displayAreaStart.iY)) > 9) )
{
// iSX = (INT32)iStartClickX;
// iEX = (INT32)button->Area.MouseXPos;
// iSY = (INT32)iStartClickY;
// iEY = (INT32)(button->Area.MouseYPos + iTopWinCutOff - (INT16)SelWinStartPoint.iY);

iSX = iStartClickX;
iSY = iStartClickY - iTopWinCutOff + SelWinStartPoint.iY;
iSY = iStartClickY - iTopWinCutOff + gSelection.displayAreaStart.iY;
iEX = gusMouseXPos;
iEY = gusMouseYPos;

Expand All @@ -889,10 +913,10 @@ void RenderSelectionWindow( void )
iEY ^= iSY;
}

iEX = min( iEX, 600 );
iSY = max( SelWinStartPoint.iY, iSY );
iEY = min( 359, iEY );
iEY = max( SelWinStartPoint.iY, iEY );
iEX = min( gSelection.displayAreaEnd.iX, iEX);
iSY = max( gSelection.displayAreaStart.iY, iSY );
iEY = min( gSelection.displayAreaEnd.iY, iEY );
iEY = max( gSelection.displayAreaStart.iY, iEY );

usFillColor = Get16BPPColor(FROMRGB(255, usFillGreen, 0));
usFillGreen += usDir;
Expand Down Expand Up @@ -928,7 +952,7 @@ void SelWinClkCallback( GUI_BUTTON *button, INT32 reason )
return;

iClickX = button->Area.MouseXPos;
iClickY = button->Area.MouseYPos + iTopWinCutOff - (INT16)SelWinStartPoint.iY;
iClickY = button->Area.MouseYPos + iTopWinCutOff - (INT16)gSelection.displayAreaStart.iY;

if (reason & MSYS_CALLBACK_REASON_LBUTTON_DWN)
{
Expand Down Expand Up @@ -1035,9 +1059,9 @@ void DisplaySelectionWindowGraphicalInformation()
UINT16 y;
//Determine if there is a valid picture at cursor position.
//iRelX = gusMouseXPos;
//iRelY = gusMouseYPos + iTopWinCutOff - (INT16)SelWinStartPoint.iY;
//iRelY = gusMouseYPos + iTopWinCutOff - (INT16)gSelection.displayAreaStart.iY;

y = gusMouseYPos + iTopWinCutOff - (UINT16)SelWinStartPoint.iY;
y = gusMouseYPos + iTopWinCutOff - (UINT16)gSelection.displayAreaStart.iY;
pNode = pDispList;
fDone = FALSE;
while( (pNode != NULL) && !fDone )
Expand Down Expand Up @@ -1470,10 +1494,10 @@ void DrawSelections( void )
{
SGPRect ClipRect, NewRect;

NewRect.iLeft = SelWinStartPoint.iX;
NewRect.iTop = SelWinStartPoint.iY;
NewRect.iRight = SelWinEndPoint.iX;
NewRect.iBottom = SelWinEndPoint.iY;
NewRect.iLeft = gSelection.displayAreaStart.iX;
NewRect.iTop = gSelection.displayAreaStart.iY;
NewRect.iRight = gSelection.displayAreaEnd.iX;
NewRect.iBottom = gSelection.displayAreaEnd.iY;

GetClippingRect(&ClipRect);
SetClippingRect(&NewRect);
Expand All @@ -1483,7 +1507,7 @@ void DrawSelections( void )
SetObjectShade( gvoLargeFontType1, 0 );
// SetObjectShade( gvoLargeFont, 0 );

DisplayWindowFunc( pDispList, iTopWinCutOff, iBotWinCutOff, &SelWinStartPoint, CLEAR_BACKGROUND );
DisplayWindowFunc( pDispList, iTopWinCutOff, iBotWinCutOff, &gSelection.displayAreaStart, CLEAR_BACKGROUND );

SetObjectShade( gvoLargeFontType1, 4 );

Expand Down
Loading