forked from Mirrors/openclonk
objects: Remove context menus
parent
3c7f17c1aa
commit
fbb96b2fb3
|
@ -92,7 +92,6 @@ IDS_COMM_BUILD=Bauen
|
|||
IDS_COMM_BUY=Kaufen
|
||||
IDS_COMM_CALL=Objektaufruf
|
||||
IDS_COMM_CONSTRUCT=Konstruktion
|
||||
IDS_COMM_CONTEXT=Kontext
|
||||
IDS_COMM_DIG=Graben
|
||||
IDS_COMM_DROP=Ablegen
|
||||
IDS_COMM_ENERGY=Energieversorgung
|
||||
|
@ -663,8 +662,6 @@ IDS_MENU_ATTACKNOT=nicht
|
|||
IDS_MENU_ATTACKSELF=Wir greifen uns selbst nicht an.
|
||||
IDS_MENU_BUY=%s kaufen
|
||||
IDS_MENU_CLONKNAMES_DESC=Zeigt Clonk-Namen über gegnerischen Clonks an.
|
||||
IDS_MENU_CONSTRUCT=Bauauftrag: %s
|
||||
IDS_MENU_CONTEXTSUBCLONKDESC=Öffnet ein Untermenü mit Befehlen für diesen Clonk.
|
||||
IDS_MENU_CPATTACK=Angriff
|
||||
IDS_MENU_CPATTACKINFO=Festlegen, welche Spieler von den eigenen Clonks angegriffen werden sollen.
|
||||
IDS_MENU_CPGOALS=Spielziele
|
||||
|
|
|
@ -92,7 +92,6 @@ IDS_COMM_BUILD=Build
|
|||
IDS_COMM_BUY=Buy
|
||||
IDS_COMM_CALL=Object call
|
||||
IDS_COMM_CONSTRUCT=Construction
|
||||
IDS_COMM_CONTEXT=Context
|
||||
IDS_COMM_DIG=Digging
|
||||
IDS_COMM_DROP=Drop
|
||||
IDS_COMM_ENERGY=Power supply
|
||||
|
@ -662,8 +661,6 @@ IDS_MENU_ATTACKNOT=not
|
|||
IDS_MENU_ATTACKSELF=We don't attack ourselves.
|
||||
IDS_MENU_BUY=Buy %s
|
||||
IDS_MENU_CLONKNAMES_DESC=Displays clonk names above enemy clonks.
|
||||
IDS_MENU_CONSTRUCT=Construction: %s
|
||||
IDS_MENU_CONTEXTSUBCLONKDESC=Opens a sub menu with command options for this clonk.
|
||||
IDS_MENU_CPATTACK=Attack
|
||||
IDS_MENU_CPATTACKINFO=Order your clonks to attack other players.
|
||||
IDS_MENU_CPGOALS=Goals
|
||||
|
|
|
@ -72,7 +72,6 @@ const char *CommandName(int32_t iCommand)
|
|||
case C4CMD_PushTo: return "PushTo";
|
||||
case C4CMD_Transfer: return "Transfer";
|
||||
case C4CMD_Attack: return "Attack";
|
||||
case C4CMD_Context: return "Context";
|
||||
case C4CMD_Buy: return "Buy";
|
||||
case C4CMD_Sell: return "Sell";
|
||||
case C4CMD_Acquire: return "Acquire";
|
||||
|
@ -107,7 +106,6 @@ const char* CommandNameID(int32_t iCommand)
|
|||
case C4CMD_PushTo: return "IDS_COMM_PUSHTO";
|
||||
case C4CMD_Transfer: return "IDS_COMM_TRANSFER";
|
||||
case C4CMD_Attack: return "IDS_COMM_ATTACK";
|
||||
case C4CMD_Context: return "IDS_COMM_CONTEXT";
|
||||
case C4CMD_Buy: return "IDS_COMM_BUY";
|
||||
case C4CMD_Sell: return "IDS_COMM_SELL";
|
||||
case C4CMD_Acquire: return "IDS_COMM_ACQUIRE";
|
||||
|
@ -908,22 +906,6 @@ void C4Command::Wait()
|
|||
if (cObj->GetProcedure()==DFA_DIG) ObjectComStop(cObj);
|
||||
}
|
||||
|
||||
void C4Command::Context()
|
||||
{
|
||||
// Not context object specified (in Target2): fail
|
||||
if (!Target2) { Finish(); return; }
|
||||
// Open context menu for target
|
||||
cObj->ActivateMenu(C4MN_Context,0,0,0,Target2);
|
||||
if (Tx._getInt()!=0 && Ty!=0)
|
||||
if (cObj->Menu)
|
||||
{
|
||||
cObj->Menu->SetAlignment(C4MN_Align_Free);
|
||||
cObj->Menu->SetLocation(Tx._getInt(),Ty);
|
||||
}
|
||||
// Done
|
||||
Finish(true);
|
||||
}
|
||||
|
||||
bool C4Command::GetTryEnter()
|
||||
{
|
||||
// Target contained and container has RejectContents: fail
|
||||
|
@ -1352,7 +1334,6 @@ void C4Command::Execute()
|
|||
case C4CMD_PushTo: PushTo(); break;
|
||||
case C4CMD_Transfer: Transfer(); break;
|
||||
case C4CMD_Attack: Attack(); break;
|
||||
case C4CMD_Context: Context(); break;
|
||||
case C4CMD_Buy: Buy(); break;
|
||||
case C4CMD_Sell: Sell(); break;
|
||||
case C4CMD_Acquire: Acquire(); break;
|
||||
|
@ -1957,7 +1938,6 @@ int32_t C4Command::GetExpGain()
|
|||
case C4CMD_Activate:
|
||||
case C4CMD_PushTo:
|
||||
case C4CMD_Dig:
|
||||
case C4CMD_Context:
|
||||
case C4CMD_Buy:
|
||||
case C4CMD_Sell:
|
||||
case C4CMD_Take:
|
||||
|
|
|
@ -47,7 +47,6 @@ enum C4CMD
|
|||
C4CMD_PushTo,
|
||||
C4CMD_Transfer,
|
||||
C4CMD_Attack,
|
||||
C4CMD_Context,
|
||||
C4CMD_Buy,
|
||||
C4CMD_Sell,
|
||||
C4CMD_Acquire,
|
||||
|
@ -133,7 +132,6 @@ protected:
|
|||
void Dig();
|
||||
void Activate();
|
||||
void PushTo();
|
||||
void Context();
|
||||
int32_t CallFailed();
|
||||
bool JumpControl();
|
||||
bool FlightControl();
|
||||
|
|
|
@ -294,7 +294,6 @@ void C4Def::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(NoSell, "NoSell", 0 ));
|
||||
pComp->Value(mkNamingAdapt(NoGet, "NoGet", 0 ));
|
||||
pComp->Value(mkNamingAdapt(NoTransferZones, "NoTransferZones", 0 ));
|
||||
pComp->Value(mkNamingAdapt(AutoContextMenu, "AutoContextMenu", 0 ));
|
||||
pComp->Value(mkNamingAdapt(NeededGfxMode, "NeededGfxMode", 0 ));
|
||||
|
||||
const StdBitfieldEntry<int32_t> AllowPictureStackModes[] =
|
||||
|
|
|
@ -174,7 +174,6 @@ public:
|
|||
int32_t NeededGfxMode; // if set, the def will only be loaded in given gfx mode
|
||||
int32_t RotatedEntrance; // 0 entrance not rotateable, 1 entrance always, 2-360 entrance within this rotation
|
||||
int32_t NoTransferZones;
|
||||
int32_t AutoContextMenu; // automatically open context menu for this object
|
||||
int32_t AllowPictureStack; // allow stacking of multiple items in menus even if some attributes do not match. APS_*-values
|
||||
public:
|
||||
void DefaultDefCore();
|
||||
|
|
|
@ -56,7 +56,6 @@ void C4PlayerInfoCore::Default(C4RankSystem *pRanks)
|
|||
PrefPosition=0;
|
||||
PrefMouse=1;
|
||||
OldPrefControlStyle = 0;
|
||||
PrefAutoContextMenu = 0;
|
||||
OldPrefAutoContextMenu = 0;
|
||||
PrefControl.Clear();
|
||||
ExtraData.Reset();
|
||||
|
@ -152,7 +151,6 @@ void C4PlayerInfoCore::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(PrefColorDw, "ColorDw", 0xffu));
|
||||
pComp->Value(mkNamingAdapt(PrefColor2Dw, "AlternateColorDw", 0u));
|
||||
pComp->Value(mkNamingAdapt(PrefPosition, "Position", 0));
|
||||
pComp->Value(mkNamingAdapt(PrefAutoContextMenu, "AutoContextMenu2", 0)); // temp solution - to be removed
|
||||
pComp->Value(mkNamingAdapt(PrefMouse, "Mouse", 1));
|
||||
pComp->Value(mkNamingAdapt(OldPrefControl, "Control", C4P_Control_Keyboard2));
|
||||
pComp->Value(mkNamingAdapt(OldPrefControlStyle, "AutoStopControl", 0));
|
||||
|
|
|
@ -107,7 +107,6 @@ public:
|
|||
int32_t PrefColor;
|
||||
uint32_t PrefColorDw, PrefColor2Dw;
|
||||
int32_t PrefPosition;
|
||||
int32_t PrefAutoContextMenu; // enable automatically opened context menus in structures
|
||||
// Old control method - loaded for backwards compatilibity if PrefControl is unassigned
|
||||
// and stored back so you can use the same player file for CR and OC
|
||||
int32_t OldPrefControl;
|
||||
|
|
|
@ -1684,7 +1684,7 @@ bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
|
|||
//CloseMenu(true);
|
||||
if (Menu && Menu->IsActive()) if (!Menu->TryClose(true, false)) return false;
|
||||
// Create menu
|
||||
if (!Menu) Menu = new C4ObjectMenu; else Menu->ClearItems(true);
|
||||
if (!Menu) Menu = new C4ObjectMenu; else Menu->ClearItems();
|
||||
// Open menu
|
||||
switch (iMenu)
|
||||
{
|
||||
|
@ -1746,27 +1746,6 @@ bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
|
|||
// Success
|
||||
return true;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4MN_Context:
|
||||
{
|
||||
// Target by parameter
|
||||
if (!pTarget) break;
|
||||
|
||||
// Create symbol & init menu
|
||||
pPlayer=::Players.Get(pTarget->Owner);
|
||||
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
|
||||
pTarget->Def->Draw(fctSymbol,false,pTarget->Color, pTarget);
|
||||
Menu->Init(fctSymbol,pTarget->GetName(),this,C4MN_Extra_None,0,iMenu,C4MN_Style_Context);
|
||||
|
||||
Menu->SetPermanent(!!iMenuData);
|
||||
Menu->SetRefillObject(pTarget);
|
||||
|
||||
// Preselect
|
||||
Menu->SetSelection(iMenuSelect, false, true);
|
||||
Menu->SetPosition(iMenuPosition);
|
||||
}
|
||||
// Success
|
||||
return true;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4MN_Info:
|
||||
// Target by parameter
|
||||
if (!pTarget) break;
|
||||
|
@ -1802,28 +1781,6 @@ bool C4Object::CloseMenu(bool fForce)
|
|||
return true;
|
||||
}
|
||||
|
||||
void C4Object::AutoContextMenu(int32_t iMenuSelect)
|
||||
{
|
||||
// Auto Context Menu - the "new structure menus"
|
||||
// No command set and no menu open
|
||||
if (!Command && !(Menu && Menu->IsActive()))
|
||||
// In a container with AutoContextMenu
|
||||
if (Contained && Contained->Def->AutoContextMenu)
|
||||
// Crew members only
|
||||
if (OCF & OCF_CrewMember)
|
||||
{
|
||||
// Player has AutoContextMenus enabled
|
||||
C4Player* pPlayer = ::Players.Get(Controller);
|
||||
if (pPlayer && pPlayer->PrefAutoContextMenu)
|
||||
{
|
||||
// Open context menu for structure
|
||||
ActivateMenu(C4MN_Context, iMenuSelect, 1, 0, Contained);
|
||||
// Closing the menu exits the building (all selected clonks)
|
||||
Menu->SetCloseCommand("PlayerObjectCommand(GetOwner(), \"Exit\") && ExecuteCommand()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BYTE C4Object::GetArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt)
|
||||
{
|
||||
if (!Status || !Def) return 0;
|
||||
|
|
|
@ -281,7 +281,6 @@ public:
|
|||
void GetOCFForPos(int32_t ctx, int32_t cty, DWORD &ocf);
|
||||
bool CloseMenu(bool fForce);
|
||||
bool ActivateMenu(int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=NULL);
|
||||
void AutoContextMenu(int32_t iMenuSelect);
|
||||
int32_t ContactCheck(int32_t atx, int32_t aty);
|
||||
bool Contact(int32_t cnat);
|
||||
void TargetBounds(C4Real &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi);
|
||||
|
|
|
@ -233,98 +233,6 @@ bool C4ObjectMenu::DoRefillInternal(bool &rfRefilled)
|
|||
}
|
||||
break;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4MN_Context:
|
||||
{
|
||||
// Clear items
|
||||
ClearItems();
|
||||
if (!(pTarget = RefillObject)) return false;
|
||||
if (!Object) return false;
|
||||
|
||||
// Put - if target is a container...
|
||||
if (pTarget->OCF & OCF_Container)
|
||||
// ...and we have something to put...
|
||||
if (Object->Contents.GetObject(0))
|
||||
// ...and if we are in that container
|
||||
if ((pTarget == Object->Contained)
|
||||
// ...or if we are grabbing the container and it has grab-put enabled
|
||||
|| ((Object->GetProcedure() == DFA_PUSH) && (Object->Action.Target == pTarget) && (pTarget->Def->GrabPutGet & C4D_Grab_Put)))
|
||||
{
|
||||
// Primary command: put first inventory item (all selected clonks)
|
||||
sprintf(szCommand, "PlayerObjectCommand(%d, \"Put\", Object(%d), 0, 0) && ExecuteCommand()", Object->Owner, pTarget->Number);
|
||||
// Secondary command: put all inventory items (all selected clonks)
|
||||
szCommand2[0] = 0;
|
||||
if ((Object->Contents.ObjectCount() > 1) || (::Players.Get(Object->Owner)->GetSelectedCrewCount() > 1))
|
||||
sprintf(szCommand2, "PlayerObjectCommand(%d, \"Put\", Object(%d), 1000, 0) && ExecuteCommand()", Object->Owner, pTarget->Number); // Workaround: specifying a really high put count here; will be adjusted later by C4Menu::ObjectCommand...
|
||||
// Create symbol
|
||||
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
|
||||
fctTarget = fctSymbol.GetFraction(85, 85, C4FCT_Right, C4FCT_Top);
|
||||
Object->Contents.GetObject(0)->DrawPicture(fctTarget);
|
||||
fctTarget = fctSymbol.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom);
|
||||
::GraphicsResource.fctHand.Draw(fctTarget, true, 0);
|
||||
// Add menu item
|
||||
Add(LoadResStr("IDS_CON_PUT2"), fctSymbol, szCommand, C4MN_Item_NoCount, NULL, NULL, C4ID::None, szCommand2);
|
||||
// Preserve symbol
|
||||
fctSymbol.Default();
|
||||
}
|
||||
|
||||
// Contents - if target is a container...
|
||||
if (pTarget->OCF & OCF_Container)
|
||||
// ...and if we are in that container
|
||||
if ((pTarget == Object->Contained)
|
||||
// ...or if we are grabbing the container and it has grab-get enabled
|
||||
|| ((Object->GetProcedure() == DFA_PUSH) && (Object->Action.Target == pTarget) && (pTarget->Def->GrabPutGet & C4D_Grab_Get))
|
||||
// ...or if the container is owned by us or a friendly player - this is for remote mouse-button-clicks
|
||||
|| (ValidPlr(pTarget->Owner) && !Hostile(pTarget->Owner,Object->Owner)))
|
||||
{
|
||||
sprintf(szCommand,"SetCommand(\"Get\",Object(%d),0,0,nil,2)&&ExecuteCommand()",pTarget->Number);
|
||||
fctSymbol.Create(C4SymbolSize,C4SymbolSize); pTarget->DrawPicture(fctSymbol);
|
||||
Add(LoadResStr("IDS_CON_CONTENTS"),fctSymbol,szCommand);
|
||||
fctSymbol.Default();
|
||||
}
|
||||
|
||||
// Scripted context functions
|
||||
AddContextFunctions(pTarget);
|
||||
|
||||
// Show needed material (if construction site)
|
||||
if (pTarget->OCF & OCF_Construct && Object->r==0 && (Game.Rules & C4RULE_ConstructionNeedsMaterial))
|
||||
{
|
||||
sprintf(szCommand, "Object(%d)->PlayerMessage(GetOwner(), Object(%d)->GetNeededMatStr())", pTarget->Number, pTarget->Number);
|
||||
fctSymbol.Create(16,16); GfxR->fctConstruction.Draw(fctSymbol,true);
|
||||
Add(LoadResStr("IDS_CON_BUILDINFO"),fctSymbol,szCommand);
|
||||
fctSymbol.Default();
|
||||
}
|
||||
|
||||
/* no GetDesc() anymore
|
||||
// Target info (if desc available)
|
||||
if (pTarget->Def->GetDesc() && *pTarget->Def->GetDesc())
|
||||
{
|
||||
// Symbol
|
||||
fctSymbol.Create(16,16);
|
||||
fctTarget = fctSymbol.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom);
|
||||
pTarget->DrawPicture(fctTarget);
|
||||
C4Facet fctTarget = fctSymbol.GetFraction(85, 85, C4FCT_Right, C4FCT_Top);
|
||||
GfxR->fctOKCancel.Draw(fctTarget, true, 0, 1);
|
||||
// Command
|
||||
sprintf(szCommand,"ShowInfo(Object(%d))",pTarget->Number);
|
||||
// Add item
|
||||
Add(LoadResStr("IDS_CON_INFO"),fctSymbol,szCommand);
|
||||
fctSymbol.Default();
|
||||
}
|
||||
*/
|
||||
|
||||
// Exit (if self contained in target container)
|
||||
if (pTarget->OCF & OCF_Container)
|
||||
if (pTarget == Object->Contained)
|
||||
{
|
||||
sprintf(szCommand, "PlayerObjectCommand(GetOwner(), \"Exit\") && ExecuteCommand()"); // Exit all selected clonks...
|
||||
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
|
||||
::GraphicsResource.fctExit.Draw(fctSymbol);
|
||||
Add(LoadResStr("IDS_COMM_EXIT"), fctSymbol, szCommand);
|
||||
fctSymbol.Default();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
default:
|
||||
// Not an internal menu
|
||||
return true;
|
||||
|
@ -393,11 +301,6 @@ int32_t C4ObjectMenu::GetControllingPlayer()
|
|||
|
||||
bool C4ObjectMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
|
||||
{
|
||||
// backup parameters to local stack because menu callback may delete this
|
||||
bool l_Permanent = !!Permanent;
|
||||
C4Object *l_Object = Object;
|
||||
int32_t l_LastSelection = LastSelection;
|
||||
|
||||
switch (eCallbackType)
|
||||
{
|
||||
case CB_Object:
|
||||
|
@ -415,176 +318,5 @@ bool C4ObjectMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
|
|||
break;
|
||||
}
|
||||
|
||||
if ((!l_Permanent || fIsCloseCommand) && l_Object) l_Object->AutoContextMenu(l_LastSelection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t C4ObjectMenu::AddContextFunctions(C4Object *pTarget, bool fCountOnly)
|
||||
{
|
||||
int32_t iFunction, iResult = 0;
|
||||
C4AulScriptFunc *pFunction,*pFunction2;
|
||||
C4Object *cObj; C4ObjectLink *clnk;
|
||||
const char *strDescText;
|
||||
char szCommand[256+1];
|
||||
C4Def *pDef;
|
||||
C4IDList ListItems;
|
||||
C4Facet fctTarget;
|
||||
C4FacetSurface fctSymbol;
|
||||
|
||||
// ActionContext functions of target's action target (for first target only, because otherwise strange stuff can happen with outdated Target2s...)
|
||||
if (pTarget->GetAction())
|
||||
if ((cObj = pTarget->Action.Target))
|
||||
for (iFunction=0; (pFunction=cObj->Def->Script.GetSFunc(iFunction, "ActionContext")); iFunction++)
|
||||
if (!pFunction->OverloadedBy)
|
||||
if (!pFunction->Condition || !!pFunction->Condition->Exec(cObj, &C4AulParSet(C4VObj(Object), C4VID(pFunction->idImage), C4VObj(pTarget))))
|
||||
{
|
||||
if (!fCountOnly)
|
||||
{
|
||||
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this,Object(%d))",cObj->Number,pFunction->Name,pTarget->Number);
|
||||
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
|
||||
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
|
||||
iResult++;
|
||||
}
|
||||
else
|
||||
iResult++;
|
||||
}
|
||||
|
||||
// Effect context functions of target's effects
|
||||
for (C4Effect *pEff = pTarget->pEffects; pEff; pEff = pEff->pNext)
|
||||
if (pEff->IsActive())
|
||||
{
|
||||
C4AulScript *pEffScript = pEff->GetCallbackScript();
|
||||
StdStrBuf sPattern; sPattern.Format(PSF_FxCustom, pEff->Name, "Context");
|
||||
if (pEffScript)
|
||||
for (iFunction=0; (pFunction=pEffScript->GetSFunc(iFunction, sPattern.getData())); iFunction++)
|
||||
if (!pFunction->OverloadedBy)
|
||||
if (!pFunction->Condition || !!pFunction->Condition->Exec(pEff->CommandTarget, &C4AulParSet(C4VObj(pTarget), C4VInt(pEff->iNumber), C4VObj(Object), C4VID(pFunction->idImage))))
|
||||
{
|
||||
if (!fCountOnly)
|
||||
{
|
||||
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",Object(%d),%d,Object(%d),%s)",pEff->CommandTarget->Number,pFunction->Name,pTarget->Number,(int)pEff->iNumber,Object->Number,pFunction->idImage.ToString());
|
||||
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
|
||||
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
|
||||
fctSymbol.Default();
|
||||
iResult++;
|
||||
}
|
||||
else
|
||||
iResult++;
|
||||
}
|
||||
}
|
||||
|
||||
// Script context functions of any objects attached to target (search global list, because attachment objects might be moved just about anywhere...)
|
||||
for (clnk=::Objects.First; clnk && (cObj=clnk->Obj); clnk=clnk->Next)
|
||||
if (cObj->Status && cObj->Action.Target == pTarget)
|
||||
{
|
||||
C4PropList* pActionDef = cObj->GetAction();
|
||||
if (pActionDef)
|
||||
if (pActionDef->GetPropertyP(P_Procedure) == DFA_ATTACH)
|
||||
for (iFunction=0; (pFunction=cObj->Def->Script.GetSFunc(iFunction, "AttachContext")); iFunction++)
|
||||
if (!pFunction->OverloadedBy)
|
||||
if (!pFunction->Condition || !! pFunction->Condition->Exec(cObj, &C4AulParSet(C4VObj(Object), C4VID(pFunction->idImage), C4VObj(pTarget))))
|
||||
{
|
||||
if (!fCountOnly)
|
||||
{
|
||||
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this,Object(%d))",cObj->Number,pFunction->Name,pTarget->Number);
|
||||
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
|
||||
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
|
||||
fctSymbol.Default();
|
||||
iResult++;
|
||||
}
|
||||
else
|
||||
iResult++;
|
||||
}
|
||||
}
|
||||
|
||||
// 'Activate' and 'ControlDigDouble' script functions of target
|
||||
const char *func, *funcs[] = { "Activate", "ControlDigDouble", 0 };
|
||||
for (int i = 0; (func = funcs[i]); i++)
|
||||
// 'Activate' function only if in clonk's inventory; 'ControlDigDouble' function only if pushed by clonk
|
||||
if ((SEqual(func, "Activate") && (pTarget->Contained == Object)) || (SEqual(func, "ControlDigDouble") && (Object->GetProcedure() == DFA_PUSH) && (Object->Action.Target == pTarget)))
|
||||
// Find function
|
||||
if ((pFunction = pTarget->Def->Script.GetSFunc(func)))
|
||||
// Find function not overloaded
|
||||
if (!pFunction->OverloadedBy)
|
||||
// Function condition valid
|
||||
if (!pFunction->Condition || !!pFunction->Condition->Exec(pTarget, &C4AulParSet(C4VObj(Object), C4VID(pFunction->idImage))))
|
||||
{
|
||||
// Get function text
|
||||
strDescText = pFunction->DescText.getData() ? pFunction->DescText.getData() : pTarget->GetName();
|
||||
// Check if there is a scripted context function doing exactly the same
|
||||
bool fDouble = false;
|
||||
for (iFunction = 0; (pFunction2 = pTarget->Def->Script.GetSFunc(iFunction, "Context")); iFunction++)
|
||||
if (!pFunction2->OverloadedBy)
|
||||
if (!pFunction2->Condition || !!pFunction2->Condition->Exec(pTarget, &C4AulParSet(C4VObj(Object), C4VID(pFunction2->idImage))))
|
||||
if (SEqual(strDescText, pFunction2->DescText.getData()))
|
||||
fDouble = true;
|
||||
// If so, skip this function to prevent duplicate entries
|
||||
if (fDouble) continue;
|
||||
// Count this function
|
||||
iResult++;
|
||||
// Count only: don't actually add
|
||||
if (fCountOnly) continue;
|
||||
// Command
|
||||
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this)",pTarget->Number,pFunction->Name);
|
||||
// Symbol
|
||||
fctSymbol.Create(16,16);
|
||||
if ((pDef = C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
|
||||
else pTarget->DrawPicture(fctSymbol);
|
||||
// Add menu item
|
||||
Add(strDescText, fctSymbol, szCommand, C4MN_Item_NoCount, NULL, pFunction->DescLong.getData());
|
||||
// Preserve symbol
|
||||
fctSymbol.Default();
|
||||
}
|
||||
|
||||
// Script context functions of target
|
||||
if (!(pTarget->OCF & OCF_CrewMember) || (pTarget->Owner==Object->Owner)) // Crew member: only allow if owned by ourself
|
||||
if (!(pTarget->Category & C4D_Living) || pTarget->GetAlive()) // No dead livings
|
||||
for (iFunction=0; (pFunction=pTarget->Def->Script.GetSFunc(iFunction, "Context")); iFunction++)
|
||||
if (!pFunction->OverloadedBy)
|
||||
if (!pFunction->Condition || !! pFunction->Condition->Exec(pTarget, &C4AulParSet(C4VObj(Object), C4VID(pFunction->idImage))))
|
||||
{
|
||||
if (!fCountOnly)
|
||||
{
|
||||
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this)",pTarget->Number,pFunction->Name);
|
||||
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
|
||||
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
|
||||
fctSymbol.Default();
|
||||
iResult++;
|
||||
}
|
||||
else
|
||||
iResult++;
|
||||
}
|
||||
|
||||
// Context functions of the menu clonk itself (if not same as target)
|
||||
if (Object != pTarget)
|
||||
// Only if clonk is inside or grabbing or containing target (this excludes remote mouse-right-click context menus)
|
||||
if ((Object->Contained == pTarget) || ((Object->GetProcedure() == DFA_PUSH) && (Object->Action.Target == pTarget)) || (pTarget->Contained == Object))
|
||||
// No dead livings
|
||||
if (!(Object->Category & C4D_Living) || Object->GetAlive())
|
||||
{
|
||||
// Context menu for a building or grabbed vehicle: move the clonk functions into a submenu if more than two functions
|
||||
int32_t iSubMenuThreshold = 2;
|
||||
// Context menu for an inventory item: no threshold, always display clonk functions directly with target object functions
|
||||
if (pTarget->Contained == Object) iSubMenuThreshold = -1;
|
||||
// First count the available entries
|
||||
int32_t iFunctions = AddContextFunctions(Object, true);
|
||||
// Less than threshold or no threshold: display directly
|
||||
if ((iFunctions <= iSubMenuThreshold) || (iSubMenuThreshold == -1))
|
||||
iResult += AddContextFunctions(Object);
|
||||
// Above threshold: create sub-menu entry for the clonk
|
||||
else if (!fCountOnly)
|
||||
{
|
||||
sprintf(szCommand, "SetCommand(\"Context\",nil,0,0,this)&&ExecuteCommand()");
|
||||
fctSymbol.Create(16,16); Object->Def->Draw(fctSymbol, false, Object->Color);
|
||||
Add(Object->Def->GetName(), fctSymbol, szCommand, C4MN_Item_NoCount, NULL, LoadResStr("IDS_MENU_CONTEXTSUBCLONKDESC"));
|
||||
fctSymbol.Default();
|
||||
iResult++;
|
||||
}
|
||||
else
|
||||
iResult++;
|
||||
}
|
||||
|
||||
// Done
|
||||
return iResult;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ enum
|
|||
/*C4MN_Magic = 10, obsolete, now reserved*/
|
||||
/*C4MN_Main = 12, now defined in C4MainMenu*/
|
||||
C4MN_Get = 13,
|
||||
C4MN_Context = 14,
|
||||
/*C4MN_Context = 14, obsolete, now reserved*/
|
||||
C4MN_Info = 15,
|
||||
/*C4MN_TeamSelection= 16, now defined in C4MainMenu */
|
||||
/*C4MN_TeamSwitch = 17, now defined in C4MainMenu */
|
||||
|
@ -86,9 +86,6 @@ protected:
|
|||
virtual void OnUserEnter(int32_t Player, int32_t iIndex, bool fRight);
|
||||
virtual void OnUserClose();
|
||||
virtual int32_t GetControllingPlayer();
|
||||
|
||||
private:
|
||||
int32_t AddContextFunctions(C4Object *pTarget, bool fCountOnly = false);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -195,8 +195,6 @@ void C4Player::Execute()
|
|||
UpdateView();
|
||||
ExecuteControl();
|
||||
Menu.Execute();
|
||||
if (Cursor)
|
||||
Cursor->AutoContextMenu(-1);
|
||||
|
||||
// decay of dead viewtargets
|
||||
C4ObjectLink *pLnkNext = FoWViewObjs.First, *pLnk;
|
||||
|
|
|
@ -1190,7 +1190,7 @@ static bool FnCreateMenu(C4AulObjectContext *cthr, C4ID iSymbol, C4Object *pComm
|
|||
|
||||
// Clear any old menu, init new menu
|
||||
if (!cthr->Obj->CloseMenu(false)) return false;
|
||||
if (!cthr->Obj->Menu) cthr->Obj->Menu = new C4ObjectMenu; else cthr->Obj->Menu->ClearItems(true);
|
||||
if (!cthr->Obj->Menu) cthr->Obj->Menu = new C4ObjectMenu; else cthr->Obj->Menu->ClearItems();
|
||||
cthr->Obj->Menu->Init(fctSymbol,FnStringPar(szCaption),pCommandObj,iExtra,iExtraData,(idMenuID ? idMenuID : iSymbol).GetHandle(),iStyle,true);
|
||||
|
||||
// Set permanent
|
||||
|
@ -4105,7 +4105,7 @@ static bool FnClearMenuItems(C4AulObjectContext *ctx)
|
|||
// check menu
|
||||
if (!ctx->Obj->Menu) return false;
|
||||
// clear the items
|
||||
ctx->Obj->Menu->ClearItems(true);
|
||||
ctx->Obj->Menu->ClearItems();
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -252,7 +252,6 @@ C4Menu::C4Menu() : C4GUI::Dialog(100, 100, NULL, true) // will be re-adjusted la
|
|||
// initially invisible: Will be made visible at first drawing by viewport
|
||||
// when the location will be inialized
|
||||
SetVisibility(false);
|
||||
LastSelection = -1;
|
||||
}
|
||||
|
||||
void C4Menu::Default()
|
||||
|
@ -839,9 +838,6 @@ void C4Menu::DrawElement(C4TargetFacet &cgo)
|
|||
DrawFrame(cgoExtra.Surface, cgoExtra.X-1, cgoExtra.Y-1, cgoExtra.Wdt+1, cgoExtra.Hgt+1);
|
||||
}
|
||||
|
||||
// live max magic
|
||||
int32_t iUseExtraData = ExtraData;
|
||||
|
||||
// Draw specified extra
|
||||
switch (Extra)
|
||||
{
|
||||
|
@ -851,8 +847,6 @@ void C4Menu::DrawElement(C4TargetFacet &cgo)
|
|||
case C4MN_Extra_Value:
|
||||
{
|
||||
if (pDef) ::GraphicsResource.fctWealth.DrawValue(cgoExtra,iValue,0,0,C4FCT_Right);
|
||||
// Flag parent object's owner's wealth display
|
||||
C4Player *pParentPlr = ::Players.Get(GetControllingPlayer());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -904,18 +898,11 @@ bool C4Menu::RefillInternal()
|
|||
return true;
|
||||
}
|
||||
|
||||
void C4Menu::ClearItems(bool fResetSelection)
|
||||
void C4Menu::ClearItems()
|
||||
{
|
||||
C4MenuItem *pItem;
|
||||
while ((pItem = GetItem(0))) delete pItem;
|
||||
ItemCount=0;
|
||||
if (fResetSelection)
|
||||
{
|
||||
// Remember selection for nested menus
|
||||
LastSelection = Selection;
|
||||
SetSelection(-1, true, false);
|
||||
LocationSet=false;
|
||||
}
|
||||
UpdateScrollBar();
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,6 @@ protected:
|
|||
int32_t Lines; // async
|
||||
int32_t Alignment;
|
||||
int32_t VisibleCount;
|
||||
int32_t LastSelection; // used by AutoContextMenus
|
||||
StdStrBuf CloseCommand; // script command that will be executed on menu close
|
||||
char Caption[C4MaxTitle+1];
|
||||
C4FacetSurface Symbol;
|
||||
|
@ -193,7 +192,7 @@ public:
|
|||
int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=NULL,
|
||||
const char *szInfoCaption=NULL,
|
||||
C4ID idID=C4ID::None, const char *szCommand2=NULL, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true);
|
||||
void ClearItems(bool fResetSelection=false);
|
||||
void ClearItems();
|
||||
void ResetLocation() { LocationSet = false; }
|
||||
bool SetLocation(int32_t iX, int32_t iY); // set location relative to user viewport
|
||||
bool SetTextProgress(int32_t iToProgress, bool fAdd); // enable/disable progressive text display and set starting pos
|
||||
|
|
Loading…
Reference in New Issue