mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +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:
@@ -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
|
||||
Reference in New Issue
Block a user