mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
- New Feature: Quick attachment selection (by The_Bob)
o The popup will list attachments available for the given slot on the current weapon. Ones not in sector inventory will be greyed out. o It should show up after clicking on an empty attachment slot, provided these criteria are met: --> we are on the mapscreen --> the sector inventory is open --> the selected merc is in this sector --> there is no combat in this sector git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4620 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -5502,6 +5502,10 @@ UINT32 MapScreenHandle(void)
|
||||
UpdatePausedStatesDueToTimeCompression( );
|
||||
|
||||
// is there a description to be displayed?
|
||||
// BOB : if we're displaying the attachment popup, don't redraw the IDB
|
||||
if (giActiveAttachmentPopup > -1)
|
||||
gItemDescAttachmentPopups[giActiveAttachmentPopup]->show();
|
||||
else
|
||||
RenderItemDescriptionBox( );
|
||||
|
||||
// render clock
|
||||
|
||||
@@ -76,8 +76,11 @@
|
||||
#include "Map Screen Interface Map.h"
|
||||
#include "Interface Enhanced.h"
|
||||
#include "InterfaceItemImages.h"
|
||||
#include "Auto Resolve.h"
|
||||
#include "popup_callback.h"
|
||||
// BOB : quick attachment popup
|
||||
#include "popup_class.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SANDRO - all "APBPConstants[AP_PICKUP_ITEM]" were replaced by GetBasicAPsToPickupItem()
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -280,6 +283,16 @@ BOOLEAN fItemDescDelete = FALSE;
|
||||
MOUSE_REGION gItemDescAttachmentRegions[MAX_ATTACHMENTS];
|
||||
MOUSE_REGION gProsAndConsRegions[2];
|
||||
|
||||
// BOB : quick attachment popups
|
||||
BOOLEAN gItemDescAttachmentPopupsInitialized = FALSE;
|
||||
|
||||
POPUP* gItemDescAttachmentPopups[MAX_ATTACHMENTS];
|
||||
INT32 giActiveAttachmentPopup = -1;
|
||||
|
||||
POPUP* gEquipPopups[NUM_INV_SLOTS];
|
||||
INT32 giActiveEquipPopup = -1;
|
||||
|
||||
|
||||
void BtnMoneyButtonCallback(GUI_BUTTON *btn,INT32 reason);
|
||||
UINT32 guiMoneyButtonBtn[OLD_MAX_ATTACHMENTS_101];
|
||||
INT32 guiMoneyButtonImage;
|
||||
@@ -510,6 +523,65 @@ INV_DESC_REGIONS gItemDescAdvRegions[NUM_UDB_ADV_LINES][4]; // Advanced data reg
|
||||
|
||||
INV_DESC_REGIONS gODBItemDescRegions[4][8]; // Four regions of eight sub-regions each.
|
||||
|
||||
// ------------------- Attachment popup callbacks
|
||||
|
||||
// BOB : globals for telling attachment popups _where_ should the attachment go
|
||||
UINT8 gubPopupStatusIndex;
|
||||
UINT32 guiPopupItemPos;
|
||||
void popupCallbackItem(INT16 itemId){
|
||||
|
||||
|
||||
for(UINT16 i = 0; i < pInventoryPoolList.size(); i++){
|
||||
if( pInventoryPoolList[i].object.usItem == itemId ) {
|
||||
|
||||
gpItemPointer = &pInventoryPoolList[i].object; // pick up the object (or stack)
|
||||
DoAttachment((UINT8)gubPopupStatusIndex, guiPopupItemPos); // try to attach it
|
||||
gpItemPointer = NULL; // and drop it
|
||||
|
||||
gItemDescAttachmentPopups[giActiveAttachmentPopup]->hide();
|
||||
RenderItemDescriptionBox();
|
||||
giActiveAttachmentPopup = -1;
|
||||
|
||||
//UpdateAttachmentTooltips(gpItemDescObject, gubItemDescStatusIndex);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool popupCallbackItemInSector(INT16 itemId){
|
||||
for(UINT16 i = 0; i < pInventoryPoolList.size(); i++)
|
||||
if( pInventoryPoolList[i].object.usItem == itemId ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void hideAttachmentPopup(){
|
||||
giActiveAttachmentPopup = -1;
|
||||
|
||||
if (giInvDescTabButton[0] != giItemDescAmmoButton)
|
||||
ShowButton(giItemDescAmmoButton);
|
||||
}
|
||||
|
||||
void hideOtherAttachmentPopups(UINT32 cnt){
|
||||
|
||||
// if there's a bullet icon, hide it. It tends to overlap my popup boxes
|
||||
if (giInvDescTabButton[0] != giItemDescAmmoButton)
|
||||
HideButton(giItemDescAmmoButton);
|
||||
|
||||
RenderItemDescriptionBox(); // also, redraw the IDB to clean up helptext
|
||||
|
||||
if( cnt > MAX_ATTACHMENTS ) return;
|
||||
|
||||
for(UINT32 i = 0; i < cnt; i++){
|
||||
if (gItemDescAttachmentPopups[i] != NULL)
|
||||
gItemDescAttachmentPopups[i]->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOLEAN AttemptToAddSubstring( STR16 zDest, STR16 zTemp, UINT32 * puiStringLength, UINT32 uiPixLimit )
|
||||
{
|
||||
UINT32 uiRequiredStringLength, uiTempStringLength;
|
||||
@@ -3592,6 +3664,7 @@ BOOLEAN InternalInitItemDescriptionBox( OBJECTTYPE *pObject, INT16 sX, INT16 sY,
|
||||
}
|
||||
|
||||
//CHRISL: This function is designed to recreate the attachment tooltips
|
||||
extern BOOLEAN CanPlayerUseSectorInventory( SOLDIERTYPE *pSelectedSoldier );
|
||||
void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
||||
{
|
||||
UINT32 slotCount = 0;
|
||||
@@ -3609,11 +3682,19 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
||||
std::vector<UINT16> usAttachmentSlotIndexVector = GetItemSlots(pObject);
|
||||
|
||||
//start by deleting the currently defined regions if they exist
|
||||
//BOB : also, clean up the popup boxes (in case they're still around)
|
||||
// and init them to NULL in case they contain garbage
|
||||
for (INT32 cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
|
||||
{
|
||||
if( gItemDescAttachmentRegions[cnt].IDNumber != 0 )
|
||||
MSYS_RemoveRegion( &gItemDescAttachmentRegions[cnt]);
|
||||
|
||||
if( gItemDescAttachmentPopupsInitialized && gItemDescAttachmentPopups[cnt] != NULL ){
|
||||
delete(gItemDescAttachmentPopups[cnt]);
|
||||
}
|
||||
gItemDescAttachmentPopups[cnt] = NULL;
|
||||
}
|
||||
gItemDescAttachmentPopupsInitialized = TRUE;
|
||||
|
||||
//now, create new regions
|
||||
for (slotCount = 0; ;++slotCount )
|
||||
@@ -3711,6 +3792,47 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOLEAN showAttachmentPopups = FALSE;
|
||||
|
||||
if( guiCurrentItemDescriptionScreen == MAP_SCREEN
|
||||
&& fShowMapInventoryPool
|
||||
&& ( (Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ].sSectorX == sSelMapX )
|
||||
&& ( Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ].sSectorY == sSelMapY )
|
||||
&& ( Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ].bSectorZ == iCurrentMapSectorZ )
|
||||
)
|
||||
&& CanPlayerUseSectorInventory( &Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ] )
|
||||
)
|
||||
{
|
||||
showAttachmentPopups = TRUE;
|
||||
}
|
||||
|
||||
// create quick attachment popup boxes here
|
||||
if (showAttachmentPopups)
|
||||
{
|
||||
gItemDescAttachmentPopups[slotCount] = new POPUP("Attachment list"); // init attachment popup for this slot
|
||||
|
||||
UINT8 thisPopupsPositionType;
|
||||
if ( gsInvDescX + gItemDescAttachmentsXY[slotCount].sX < 170 && gsInvDescY + gItemDescAttachmentsXY[slotCount].sY < 180 ){
|
||||
thisPopupsPositionType = POPUP_POSITION_TOP_LEFT;
|
||||
} else if ( gsInvDescX + gItemDescAttachmentsXY[slotCount].sX > 170 && gsInvDescY + gItemDescAttachmentsXY[slotCount].sY < 180 ){
|
||||
thisPopupsPositionType = POPUP_POSITION_TOP_RIGHT;
|
||||
} else if ( gsInvDescX + gItemDescAttachmentsXY[slotCount].sX > 170 && gsInvDescY + gItemDescAttachmentsXY[slotCount].sY > 180 ){
|
||||
thisPopupsPositionType = POPUP_POSITION_BOTTOM_RIGHT;
|
||||
} else if ( gsInvDescX + gItemDescAttachmentsXY[slotCount].sX < 170 && gsInvDescY + gItemDescAttachmentsXY[slotCount].sY > 180 ){
|
||||
thisPopupsPositionType = POPUP_POSITION_BOTTOM_LEFT;
|
||||
} else {
|
||||
thisPopupsPositionType = POPUP_POSITION_TOP_LEFT;
|
||||
}
|
||||
|
||||
gItemDescAttachmentPopups[slotCount]->setPosition( (gsInvDescX + gItemDescAttachmentsXY[slotCount].sX) + 12 ,
|
||||
/* Put it near the current slot */ (gsInvDescY + gItemDescAttachmentsXY[slotCount].sY) + 32 ,
|
||||
thisPopupsPositionType );
|
||||
|
||||
// the show callback should redraw the description box (in case we had any helptext and close other attachment popups)
|
||||
gItemDescAttachmentPopups[slotCount]->setCallback( POPUP_CALLBACK_SHOW, new popupCallbackFunction<void,UINT32>( &hideOtherAttachmentPopups, usAttachmentSlotIndexVector.size() ) );
|
||||
// the hide callback tells the program we're no longer displaying an attachment callback
|
||||
gItemDescAttachmentPopups[slotCount]->setCallback( POPUP_CALLBACK_HIDE, new popupCallbackFunction<void,void>( &hideAttachmentPopup ) );
|
||||
}
|
||||
for(UINT16 loop = 0; loop < attachList.size(); loop++){
|
||||
usAttachment = attachList[loop];
|
||||
// If the attachment is not hidden
|
||||
@@ -3728,6 +3850,36 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
||||
swprintf( attachStr2, L"\n%s", Item[ usAttachment ].szItemName );
|
||||
wcscat( attachStr3, attachStr2);
|
||||
}
|
||||
|
||||
if (showAttachmentPopups)
|
||||
{ // add the current attachment to the popup assigned to this attachment slot
|
||||
POPUP_OPTION * o = new POPUP_OPTION( &std::wstring( Item[ usAttachment ].szItemName ),
|
||||
new popupCallbackFunction<void,UINT16>(&popupCallbackItem,usAttachment));
|
||||
// set an availiability callback to gray out any compatible attachments not found in this sector
|
||||
o->setAvail( new popupCallbackFunction<bool,UINT16>(&popupCallbackItemInSector,usAttachment) );
|
||||
|
||||
if (loop == 11 && attachList.size() > 11){ // if there's too much stuff to list, we create a subpopup for the rest
|
||||
gItemDescAttachmentPopups[slotCount]->addSubMenuOption( &std::wstring(L"More...") );
|
||||
POPUP_SUB_POPUP_OPTION * tmp = gItemDescAttachmentPopups[slotCount]->getSubPopupOption(0);
|
||||
|
||||
// positioning sub popups is handled through the option that holds them
|
||||
tmp->setPopupPosition( (gsInvDescX + gItemDescAttachmentsXY[slotCount].sX),
|
||||
(gsInvDescY + gItemDescAttachmentsXY[slotCount].sY) + 32 ,
|
||||
POPUP_POSITION_TOP_RIGHT); // put it to the right of the main box
|
||||
|
||||
// hide the other box too
|
||||
// note that we're working with the sub popup options's sub-popup here, not the option itself
|
||||
tmp->subPopup->setCallback( POPUP_CALLBACK_HIDE, new popupCallbackFunction<void,UINT32>( &hideOtherAttachmentPopups, usAttachmentSlotIndexVector.size() ) );
|
||||
|
||||
// finally add the option
|
||||
tmp->subPopup->addOption(*o);
|
||||
|
||||
} else if (loop > 11){ // add surplus options to the subpopup
|
||||
gItemDescAttachmentPopups[slotCount]->getSubPopupOption(0)->subPopup->addOption(*o);
|
||||
} else { // options 0-11 go into the main popup
|
||||
gItemDescAttachmentPopups[slotCount]->addOption(*o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4159,7 +4311,22 @@ void ItemDescAttachmentsCallback( MOUSE_REGION * pRegion, INT32 iReason )
|
||||
UpdateItemHatches();
|
||||
|
||||
}
|
||||
|
||||
// BOB : show the quick attachment popup
|
||||
} else if( guiCurrentItemDescriptionScreen == MAP_SCREEN // if we're in the map screen
|
||||
&& fShowMapInventoryPool // and are viweing the sector inventory
|
||||
&& !pAttachment->exists() // and the clicked attachment slot is empty
|
||||
&& gItemDescAttachmentPopupsInitialized && gItemDescAttachmentPopups[uiItemPos] != 0 ) { // and the popup exists
|
||||
|
||||
// the popup slot that is going to be displayed
|
||||
giActiveAttachmentPopup = uiItemPos;
|
||||
// which slot was this ? No better (simple) way to let the callbacks know.
|
||||
gubPopupStatusIndex = (UINT8)ubStatusIndex;
|
||||
guiPopupItemPos = uiItemPos;
|
||||
|
||||
return; // and leave before UpdateAttachmentTooltips overwrites the popup
|
||||
}
|
||||
|
||||
if(gpItemDescObject != NULL)
|
||||
{
|
||||
InitDescStatCoords(gpItemDescObject);
|
||||
@@ -5655,7 +5822,15 @@ void DeleteItemDescriptionBox( )
|
||||
for ( cnt = 0; cnt < (INT32)(*gpItemDescObject)[0]->attachments.size(); cnt++ )
|
||||
{
|
||||
MSYS_RemoveRegion( &gItemDescAttachmentRegions[cnt]);
|
||||
|
||||
//BOB : also, clean up the popup boxes
|
||||
if( gItemDescAttachmentPopupsInitialized && gItemDescAttachmentPopups[cnt] != NULL ){
|
||||
delete(gItemDescAttachmentPopups[cnt]);
|
||||
gItemDescAttachmentPopups[cnt] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
giActiveAttachmentPopup = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "items.h"
|
||||
#include "Handle Items.h"
|
||||
#include "popup_class.h"
|
||||
|
||||
// DEFINES FOR ITEM SLOT SIZES IN PIXELS
|
||||
#define BIG_INV_SLOT_WIDTH 61
|
||||
@@ -304,4 +305,15 @@ INT16 CycleItems( INT16 usOldItem );
|
||||
|
||||
BOOLEAN InitializeStealItemPickupMenu( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, ITEM_POOL *pItemPool, UINT8 ubCount);
|
||||
|
||||
// BOB : quick attachment selection popups
|
||||
extern POPUP* gItemDescAttachmentPopups[MAX_ATTACHMENTS]; // popup list for attachment slots
|
||||
extern INT32 giActiveAttachmentPopup; // the attachment popup to display in mapscreen
|
||||
|
||||
// BOB : quick equip popups
|
||||
extern POPUP* gEquipPopups[NUM_INV_SLOTS]; // popup list for attachment slots
|
||||
extern INT32 giActiveEquipPopup; // the attachment popup to display in mapscreen
|
||||
|
||||
// BOB : duh...
|
||||
void DoAttachment( UINT8 subObject, INT32 iItemPos );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -454,6 +454,14 @@
|
||||
RelativePath=".\Music Control.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\popup_callback.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\popup_class.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PopUpBox.h"
|
||||
>
|
||||
@@ -680,6 +688,10 @@
|
||||
RelativePath=".\Music Control.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\popup_class.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PopUpBox.cpp"
|
||||
>
|
||||
|
||||
@@ -458,6 +458,14 @@
|
||||
RelativePath="Music Control.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\popup_callback.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\popup_class.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PopUpBox.h"
|
||||
>
|
||||
@@ -682,6 +690,10 @@
|
||||
RelativePath="Music Control.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\popup_class.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PopUpBox.cpp"
|
||||
>
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
<ClInclude Include="Multilingual Text Code Generator.h" />
|
||||
<ClInclude Include="Music Control.h" />
|
||||
<ClInclude Include="PopUpBox.h" />
|
||||
<ClInclude Include="popup_callback.h" />
|
||||
<ClInclude Include="popup_class.h" />
|
||||
<ClInclude Include="Quantize Wrap.h" />
|
||||
<ClInclude Include="Quantize.h" />
|
||||
<ClInclude Include="Slider.h" />
|
||||
@@ -92,6 +94,7 @@
|
||||
<ClCompile Include="Multilingual Text Code Generator.cpp" />
|
||||
<ClCompile Include="Music Control.cpp" />
|
||||
<ClCompile Include="PopUpBox.cpp" />
|
||||
<ClCompile Include="popup_class.cpp" />
|
||||
<ClCompile Include="Quantize Wrap.cpp" />
|
||||
<ClCompile Include="Quantize.cpp" />
|
||||
<ClCompile Include="Slider.cpp" />
|
||||
|
||||
@@ -147,6 +147,8 @@
|
||||
<ClInclude Include="Cinematics Bink.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="popup_callback.h" />
|
||||
<ClInclude Include="popup_class.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="_ChineseText.cpp">
|
||||
@@ -317,5 +319,6 @@
|
||||
<ClCompile Include="Cinematics Bink.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="popup_class.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,171 @@
|
||||
#ifndef POPUP_CALLBACK_CLASS
|
||||
#define POPUP_CALLBACK_CLASS
|
||||
|
||||
class popupCallback;
|
||||
|
||||
template <typename R, typename P1> class popupCallbackFunction;
|
||||
|
||||
class popupCallback{
|
||||
public:
|
||||
popupCallback(void){}
|
||||
~popupCallback(void){}
|
||||
|
||||
virtual void bind(void* newFun) = 0;
|
||||
virtual bool call(void) = 0;
|
||||
};
|
||||
|
||||
template <typename R, typename P1>
|
||||
class popupCallbackFunction : public popupCallback{
|
||||
protected:
|
||||
R (*fun)(P1);
|
||||
P1 param_1;
|
||||
public:
|
||||
popupCallbackFunction(void);
|
||||
popupCallbackFunction(void * newFun, P1 param);
|
||||
virtual void bind(void * newFun);
|
||||
virtual bool call(void);
|
||||
};
|
||||
|
||||
template<typename R,typename P1>
|
||||
popupCallbackFunction<R,P1>::popupCallbackFunction(void){
|
||||
this->fun = 0;
|
||||
this->param_1 = P1();
|
||||
};
|
||||
|
||||
template<typename R,typename P1>
|
||||
popupCallbackFunction<R,P1>::popupCallbackFunction(void * newFun, P1 param){
|
||||
this->fun = static_cast< R(*)(P1)>(newFun);
|
||||
this->param_1 = param;
|
||||
};
|
||||
|
||||
template<typename R,typename P1>
|
||||
void popupCallbackFunction<R,P1>::bind(void * newFun){
|
||||
this->fun = static_cast< R(*)(P1)>(newFun);
|
||||
};
|
||||
|
||||
template<typename R,typename P1>
|
||||
bool popupCallbackFunction<R,P1>::call(void){
|
||||
return (bool)(this->fun)(this->param_1);
|
||||
}
|
||||
|
||||
// no return type, one parameter
|
||||
template <typename P1>
|
||||
class popupCallbackFunction<void, typename P1> : public popupCallback{
|
||||
protected:
|
||||
void (*fun)(P1);
|
||||
P1 param_1;
|
||||
public:
|
||||
popupCallbackFunction(void);
|
||||
popupCallbackFunction(void * newFun, P1 param);
|
||||
virtual void bind(void * newFun);
|
||||
virtual bool call(void);
|
||||
};
|
||||
|
||||
template<typename P1>
|
||||
popupCallbackFunction<void,P1>::popupCallbackFunction(void){
|
||||
this->fun = 0;
|
||||
this->param_1 = P1();
|
||||
};
|
||||
|
||||
template<typename P1>
|
||||
popupCallbackFunction<void,P1>::popupCallbackFunction(void * newFun, P1 param){
|
||||
this->fun = static_cast< void(*)(P1)>(newFun);
|
||||
this->param_1 = param;
|
||||
};
|
||||
|
||||
template<typename P1>
|
||||
void popupCallbackFunction<void,P1>::bind(void * newFun){
|
||||
this->fun = static_cast< void(*)(P1)>(newFun);
|
||||
};
|
||||
|
||||
|
||||
template<typename P1>
|
||||
bool popupCallbackFunction<void,P1>::call(void){
|
||||
try {
|
||||
(this->fun)(this->param_1);
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns something, no parameter
|
||||
template <typename R>
|
||||
class popupCallbackFunction<typename R, void> : public popupCallback{
|
||||
protected:
|
||||
R (*fun)(void);
|
||||
public:
|
||||
popupCallbackFunction(void);
|
||||
popupCallbackFunction(void * newFun);
|
||||
virtual void bind(void * newFun);
|
||||
virtual bool call(void);
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
popupCallbackFunction<R,void>::popupCallbackFunction(void){
|
||||
this->fun = 0;
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
popupCallbackFunction<R,void>::popupCallbackFunction(void * newFun){
|
||||
this->fun = static_cast< R(*)(void)>(newFun);
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
void popupCallbackFunction<R,void>::bind(void * newFun){
|
||||
this->fun = static_cast< R(*)(void)>(newFun);
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
bool popupCallbackFunction<R,void>::call(void){
|
||||
return (bool)(this->fun)();
|
||||
}
|
||||
|
||||
|
||||
//template<>
|
||||
//bool popupCallbackFunction<bool,void>::call(void){
|
||||
// return (this->fun)();
|
||||
//}
|
||||
|
||||
// no parameters/return types
|
||||
template <>
|
||||
class popupCallbackFunction<void, void> : public popupCallback{
|
||||
protected:
|
||||
void (*fun)(void);
|
||||
public:
|
||||
popupCallbackFunction(void){
|
||||
this->fun = 0;
|
||||
};
|
||||
popupCallbackFunction(void * newFun){
|
||||
this->fun = static_cast< void(*)(void)>(newFun);
|
||||
};
|
||||
virtual void bind(void * newFun){
|
||||
this->fun = static_cast< void(*)(void)>(newFun);
|
||||
};
|
||||
virtual bool call(void){
|
||||
try {
|
||||
(this->fun)();
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
class popupCallbackLua : public popupCallback{
|
||||
protected:
|
||||
CHAR16 * functionName;
|
||||
public:
|
||||
popupCallbackLua(void);
|
||||
popupCallbackLua(CHAR16 * newFunctionName){
|
||||
this->functionName = newFunctionName;
|
||||
};
|
||||
virtual void bind(void * newFun){
|
||||
this->functionName = static_cast< CHAR16* >(newFun);
|
||||
};
|
||||
virtual bool call(void){
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,283 @@
|
||||
#ifndef POPUP_CLASS
|
||||
#define POPUP_CLASS
|
||||
|
||||
#include <vector>
|
||||
#include "popup_callback.h"
|
||||
|
||||
#define MAX_POPUPS 8
|
||||
#define POPUP_MAX_SUB_POPUPS 2
|
||||
#define POPUP_MAX_OPTIONS 32
|
||||
#define MAX_REGIONS_IN_INDEX MAX_POPUPS*POPUP_MAX_OPTIONS*POPUP_MAX_SUB_POPUPS
|
||||
|
||||
#define REGION_SUB_POPUP 1
|
||||
#define REGION_OPTION 0
|
||||
|
||||
#ifdef MSYS_PRIORITY_VERY_HIGH
|
||||
#define POPUP_SCREEN_MASK_PRIORITY (MSYS_PRIORITY_VERY_HIGH + 10) // MSYS priority for popup screen mask
|
||||
#define POPUP_OPTION_PRIORITY (MSYS_PRIORITY_VERY_HIGH + 12) // MSYS priority for popup options
|
||||
#else // compatibility with 1.13 versions without the VERY_HIGH priority defined
|
||||
#define POPUP_SCREEN_MASK_PRIORITY MSYS_PRIORITY_HIGHEST
|
||||
#define POPUP_OPTION_PRIORITY MSYS_PRIORITY_HIGHEST
|
||||
#endif
|
||||
|
||||
#define POPUP_CALLBACK_INIT 1 // called at the end of init
|
||||
#define POPUP_CALLBACK_END 2 // called after cleanup
|
||||
#define POPUP_CALLBACK_SHOW 3 // called before showing
|
||||
#define POPUP_CALLBACK_HIDE 4 // called after hiding
|
||||
|
||||
#define POPUP_POSITION_TOP_LEFT 1 // default positioning rule when setting position
|
||||
#define POPUP_POSITION_TOP_RIGHT 2 // user defined point (position) is the top right corner of the popup
|
||||
#define POPUP_POSITION_BOTTOM_RIGHT 3 // user defined point (position) is the bottom right corner of the popup
|
||||
#define POPUP_POSITION_BOTTOM_LEFT 4 // user defined point (position) is the bottom left corner of the popup
|
||||
|
||||
#define POPUP_POSITION_RELATIVE 0 // only used for sub-popups, left corner is relative to parent popup's point of origin
|
||||
|
||||
class POPUP_OPTION;
|
||||
class POPUP_SUB_POPUP_OPTION;
|
||||
class POPUP;
|
||||
|
||||
typedef void (POPUP::*POPUP_CALLBACK)(MOUSE_REGION *, INT32);
|
||||
|
||||
typedef struct {
|
||||
UINT16 regionId;
|
||||
UINT32 classId;
|
||||
} PopupIndex ;
|
||||
|
||||
extern std::vector<typename PopupIndex> gPopupRegionIndex;
|
||||
extern std::vector<POPUP*> gPopupIndex;
|
||||
|
||||
extern UINT32 gPopupRegionIndexCounter;
|
||||
extern UINT32 gPopupIndexCounter;
|
||||
|
||||
PopupIndex * findMouseRegionInIndex(UINT16 regionId);
|
||||
BOOLEAN registerPopupRegion(UINT16 rID, UINT32 cID);
|
||||
BOOLEAN unregisterPopupRegion(UINT16 regionId);
|
||||
void rebuildPopupRegionIndex(void);
|
||||
void popupMaskCallback(MOUSE_REGION *pRegion, INT32 iReason);
|
||||
void popupMouseMoveCallback(MOUSE_REGION *pRegion, INT32 iReason);
|
||||
void popupMouseClickCallback(MOUSE_REGION *pRegion, INT32 iReason);
|
||||
|
||||
POPUP * findPopupInIndex( UINT32 cID );
|
||||
void rebuildPopupIndex(void);
|
||||
void reinitPopupIndex(void);
|
||||
void initPopupIndex(void);
|
||||
|
||||
class POPUP_OPTION
|
||||
{
|
||||
public:
|
||||
POPUP_OPTION::POPUP_OPTION(void); // default constructor
|
||||
POPUP_OPTION(std::wstring* name, popupCallback* newFunction); // constructor
|
||||
~POPUP_OPTION(); // destructor
|
||||
// setup
|
||||
BOOLEAN setName(WCHAR* name);
|
||||
BOOLEAN setAction(popupCallback*fun);
|
||||
BOOLEAN setAvail(popupCallback *fun);
|
||||
BOOLEAN setHover(popupCallback *fun);
|
||||
|
||||
BOOLEAN run();
|
||||
BOOLEAN forceRun();
|
||||
|
||||
BOOLEAN runHoverCallback(MOUSE_REGION * pRegion);
|
||||
BOOLEAN checkAvailability();
|
||||
|
||||
BOOLEAN HoverFunctionSet(){ return (this->hover != 0); };
|
||||
BOOLEAN AvailabilityFunctionSet(){ return (this->avail != 0); };
|
||||
|
||||
std::wstring name;
|
||||
std::wstring hint;
|
||||
// protected:
|
||||
popupCallback * action;
|
||||
popupCallback * avail;
|
||||
popupCallback * hover;
|
||||
};
|
||||
|
||||
|
||||
class POPUP_SUB_POPUP_OPTION : public POPUP_OPTION
|
||||
{
|
||||
public:
|
||||
// constructor/destructor
|
||||
POPUP_SUB_POPUP_OPTION(void);
|
||||
POPUP_SUB_POPUP_OPTION(std::wstring* name);
|
||||
POPUP_SUB_POPUP_OPTION(std::wstring* newName, const POPUP * parent);
|
||||
~POPUP_SUB_POPUP_OPTION();
|
||||
|
||||
void showPopup();
|
||||
void hidePopup();
|
||||
|
||||
BOOLEAN run();
|
||||
|
||||
void initSubPopup();
|
||||
void destroySubPopup();
|
||||
void positionSubPopup();
|
||||
|
||||
BOOLEAN setPopupPosition(UINT16 x, UINT16 y, UINT8 positioningRule = POPUP_POSITION_RELATIVE );
|
||||
|
||||
BOOLEAN customPositionSet;
|
||||
INT32 customX;
|
||||
INT32 customY;
|
||||
UINT8 customRule;
|
||||
|
||||
POPUP * subPopup;
|
||||
const POPUP * parent;
|
||||
};
|
||||
|
||||
|
||||
class POPUP
|
||||
{
|
||||
/////////////////////////
|
||||
// public functions
|
||||
public:
|
||||
POPUP(void); // constructor
|
||||
POPUP(CHAR* name); // constructor
|
||||
~POPUP(void); // destructor
|
||||
// setup
|
||||
POPUP_OPTION * addOption(std::wstring * name, popupCallback * action);
|
||||
/*INT16 findFreeOptionIndex();*/
|
||||
BOOLEAN addOption(POPUP_OPTION &option);
|
||||
POPUP_OPTION * getOption(UINT16 n);
|
||||
|
||||
BOOLEAN delOption(CHAR* name); // Another index to through and clean, aargh
|
||||
BOOLEAN delOption(UINT8 optIndex);
|
||||
|
||||
POPUP* addSubMenuOption(std::wstring * name);
|
||||
/*INT16 findFreeSubMenuOptionIndex();*/
|
||||
POPUP_SUB_POPUP_OPTION * getSubPopupOption(UINT8 n);
|
||||
|
||||
BOOLEAN setPosition(UINT16 x, UINT16 y, UINT8 positioningRule = POPUP_POSITION_TOP_LEFT );
|
||||
BOOLEAN setSize(UINT16 x, UINT16 y );
|
||||
// usage
|
||||
BOOLEAN show(void);
|
||||
BOOLEAN hide(void);
|
||||
BOOLEAN toggle(void);
|
||||
BOOLEAN refresh(void);
|
||||
BOOLEAN forceDraw(void);
|
||||
BOOLEAN callOption(int optIndex);
|
||||
|
||||
INT32 getBoxId(){
|
||||
return this->boxId;
|
||||
}
|
||||
|
||||
BOOLEAN setCallback(UINT8 type, popupCallback * callback);
|
||||
BOOLEAN isCallbackSet(UINT8 type);
|
||||
|
||||
/////////////////////////
|
||||
// public variables
|
||||
public:
|
||||
CHAR name[32];
|
||||
SGPPoint Position;
|
||||
SGPRect Dimensions;
|
||||
UINT32 id;
|
||||
static UINT32 nextid ;
|
||||
UINT8 optionCount;
|
||||
UINT8 subPopupOptionCount;
|
||||
|
||||
/////////////////////////
|
||||
// private functions
|
||||
private:
|
||||
|
||||
void setInitialValues(void);
|
||||
BOOLEAN addToIndex( void );
|
||||
BOOLEAN removeFromIndex( void );
|
||||
|
||||
// Box init functions
|
||||
BOOLEAN CreateDestroyPopUpBoxes(void);
|
||||
BOOLEAN CreatePopUpBoxes(void);
|
||||
BOOLEAN DestroyPopUpBoxes(void);
|
||||
|
||||
BOOLEAN CreateBox( void );
|
||||
void AddOptionStrings();
|
||||
void AddSubPopupStrings();
|
||||
|
||||
void RebuildBox( void );
|
||||
|
||||
// Screen mask
|
||||
void CreateDestroyScreenMask( void );
|
||||
void CreateScreenMask( void );
|
||||
void DestroyScreenMask( void );
|
||||
|
||||
// Mouse regions
|
||||
void CreateDestroyMouseRegions( void );
|
||||
void CreateMouseRegions( void );
|
||||
void DestroyMouseRegions( void );
|
||||
void AdjustMouseRegions( void );
|
||||
|
||||
void RepositionMouseRegions( void );
|
||||
public:
|
||||
// MSYS Callbacks
|
||||
void MenuMvtCallBack(MOUSE_REGION * pRegion, INT32 iReason );
|
||||
void MenuBtnCallBack( MOUSE_REGION * pRegion, INT32 iReason );
|
||||
void ScreenMaskBtnCallback(MOUSE_REGION * pRegion, INT32 iReason );
|
||||
private:
|
||||
// These are mostly used in the map screen
|
||||
void UpdateMapScreenPosition(void);
|
||||
void DetermineWhichLMenusCanBeShown( void );
|
||||
|
||||
// Misc utility functions
|
||||
void HandleShadingOfLines( void );
|
||||
void PositionCursorForBox( void );
|
||||
void CheckAndUpdateTacticalPopUpPositions( void );
|
||||
void DetermineBoxPositions( void );
|
||||
void UpdateTextProperties( void );
|
||||
|
||||
// external flag access functiona
|
||||
BOOLEAN MapScreenBottomDirty(void);
|
||||
BOOLEAN CharacterInfoPanelDirty(void);
|
||||
BOOLEAN TeamPanelDirty(void);
|
||||
BOOLEAN RenderPBInterface(void);
|
||||
|
||||
void setMapScreenBottomDirty(BOOLEAN);
|
||||
void setCharacterInfoPanelDirty(BOOLEAN);
|
||||
void setTeamPanelDirty(BOOLEAN);
|
||||
void setRenderPBInterface(BOOLEAN);
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// private variables
|
||||
private:
|
||||
BOOLEAN PopupVisible;
|
||||
|
||||
popupCallback * initCallback;
|
||||
popupCallback * EndCallback;
|
||||
popupCallback * ShowCallback;
|
||||
popupCallback * HideCallback;
|
||||
|
||||
///////////////////////
|
||||
// Popup box vars
|
||||
/////////////////
|
||||
|
||||
BOOLEAN FirstClickInScreenMask;
|
||||
BOOLEAN BoxPersist;
|
||||
INT16 BoxesX, BoxesY;
|
||||
|
||||
// Textures
|
||||
|
||||
static UINT32 uiPOPUPBORDERS;
|
||||
static UINT32 uiPOPUPTEX;
|
||||
|
||||
// PopUp Box Handles
|
||||
INT32 boxId;
|
||||
|
||||
// which corner of the popup should be aligned with the supplied coordinates ?
|
||||
UINT8 positioningRule;
|
||||
|
||||
|
||||
// the x,y position of the pop up in tactical
|
||||
public:
|
||||
INT16 X, Y;
|
||||
|
||||
// assignment menu mouse regions
|
||||
|
||||
MOUSE_REGION MenuRegion[ POPUP_MAX_OPTIONS ];
|
||||
MOUSE_REGION ScreenMaskRegion;
|
||||
private:
|
||||
// Box position and size
|
||||
SGPPoint OrigPosition;
|
||||
|
||||
// Options
|
||||
std::vector<POPUP_OPTION *> options;
|
||||
|
||||
// Subpopups
|
||||
std::vector<POPUP_SUB_POPUP_OPTION *> subPopupOptions;
|
||||
|
||||
};
|
||||
#endif
|
||||
+1
-1
@@ -145,7 +145,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Winmm.lib .\Multiplayer\raknet\RakNetLibStatic.lib ws2_32.lib DbgHelp.lib"
|
||||
OutputFile="$(OutDir)\JA2_CH_Release_4552.exe"
|
||||
OutputFile="$(OutDir)\JA2_EN_Release.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
GenerateMapFile="true"
|
||||
|
||||
Reference in New Issue
Block a user