forked from Mirrors/openclonk
Remove the menu functionality from the Construct Command in favour of script
parent
c14ca10f89
commit
e252d91efa
|
@ -1573,11 +1573,10 @@ void C4Command::Construct()
|
|||
Finish(false, FormatString(LoadResStr("IDS_TEXT_CANTBUILD"), cObj->GetName()).getData());
|
||||
return;
|
||||
}
|
||||
// No target type to construct: open menu & done
|
||||
// No target type to construct: fail
|
||||
if (!Data)
|
||||
{
|
||||
cObj->ActivateMenu(C4MN_Construction);
|
||||
Finish(true); return;
|
||||
Finish(false); return;
|
||||
}
|
||||
|
||||
// Determine move-to range
|
||||
|
|
|
@ -1888,6 +1888,28 @@ bool C4Object::CreateContentsByList(C4IDList &idlist)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void DrawMenuSymbol(int32_t iMenu, C4Facet &cgo, int32_t iOwner)
|
||||
{
|
||||
C4Facet ccgo;
|
||||
|
||||
DWORD dwColor=0;
|
||||
if (ValidPlr(iOwner)) dwColor=::Players.Get(iOwner)->ColorDw;
|
||||
|
||||
switch (iMenu)
|
||||
{
|
||||
case C4MN_Buy:
|
||||
::GraphicsResource.fctFlagClr.DrawClr(ccgo = cgo.GetFraction(75, 75), true, dwColor);
|
||||
::GraphicsResource.fctWealth.Draw(ccgo = cgo.GetFraction(100, 50, C4FCT_Left, C4FCT_Bottom));
|
||||
::GraphicsResource.fctArrow.Draw(ccgo = cgo.GetFraction(70, 70, C4FCT_Right, C4FCT_Center), false, 0);
|
||||
break;
|
||||
case C4MN_Sell:
|
||||
::GraphicsResource.fctFlagClr.DrawClr(ccgo = cgo.GetFraction(75, 75), true, dwColor);
|
||||
::GraphicsResource.fctWealth.Draw(ccgo = cgo.GetFraction(100, 50, C4FCT_Left, C4FCT_Bottom));
|
||||
::GraphicsResource.fctArrow.Draw(ccgo = cgo.GetFraction(70, 70, C4FCT_Right, C4FCT_Center), false, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
|
||||
int32_t iMenuData, int32_t iMenuPosition,
|
||||
C4Object *pTarget)
|
||||
|
@ -1930,7 +1952,7 @@ bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
|
|||
// Create symbol
|
||||
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
|
||||
//pTarget->Def->Draw(fctSymbol,false,pTarget->Color,pTarget);
|
||||
DrawMenuSymbol(C4MN_Buy, fctSymbol, pTarget->Owner, pTarget);
|
||||
DrawMenuSymbol(C4MN_Buy, fctSymbol, pTarget->Owner);
|
||||
// Init menu
|
||||
Menu->Init(fctSymbol,LoadResStr("IDS_PLR_NOBUY"),this,C4MN_Extra_Value,0,iMenu);
|
||||
Menu->SetPermanent(true);
|
||||
|
@ -1944,7 +1966,7 @@ bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
|
|||
// Create symbol & init
|
||||
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
|
||||
//pTarget->Def->Draw(fctSymbol,false,pTarget->Color,pTarget);
|
||||
DrawMenuSymbol(C4MN_Sell, fctSymbol, pTarget->Owner, pTarget);
|
||||
DrawMenuSymbol(C4MN_Sell, fctSymbol, pTarget->Owner);
|
||||
sprintf(szCaption,LoadResStr("IDS_OBJ_EMPTY"),pTarget->GetName());
|
||||
Menu->Init(fctSymbol,szCaption,this,C4MN_Extra_Value,0,iMenu);
|
||||
Menu->SetPermanent(true);
|
||||
|
@ -1988,33 +2010,6 @@ bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
|
|||
}
|
||||
// Success
|
||||
return true;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4MN_Construction:
|
||||
// Check valid player
|
||||
if (!(pPlayer = ::Players.Get(Owner))) break;
|
||||
// Create symbol
|
||||
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
|
||||
DrawMenuSymbol(C4MN_Construction,fctSymbol,-1,NULL);
|
||||
// Init menu
|
||||
Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_PLR_NOBKNOW"),pPlayer->GetName()).getData(),
|
||||
this,C4MN_Extra_Components,0,iMenu);
|
||||
// Add player's structure build knowledge
|
||||
for (cnt=0; (pDef=C4Id2Def(pPlayer->Knowledge.GetID(::Definitions,C4D_Structure,cnt,&iCount))); cnt++)
|
||||
{
|
||||
// Caption
|
||||
sprintf(szCaption,LoadResStr("IDS_MENU_CONSTRUCT"),pDef->GetName());
|
||||
// Picture
|
||||
fctSymbol.Set(pDef->Graphics.GetBitmap(),pDef->PictureRect.x,pDef->PictureRect.y,pDef->PictureRect.Wdt,pDef->PictureRect.Hgt);
|
||||
// Command
|
||||
sprintf(szCommand,"SetCommand(\"Construct\",nil,0,0,nil,%s)",pDef->id.ToString());
|
||||
// Add menu item
|
||||
Menu->AddRefSym(szCaption,fctSymbol,szCommand,C4MN_Item_NoCount,NULL,"",pDef->id);
|
||||
}
|
||||
// Preselect
|
||||
Menu->SetSelection(iMenuSelect, false, true);
|
||||
Menu->SetPosition(iMenuPosition);
|
||||
// Success
|
||||
return true;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4MN_Info:
|
||||
// Target by parameter
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
enum
|
||||
{
|
||||
C4MN_None = 0,
|
||||
C4MN_Construction = 1,
|
||||
/*C4MN_Construction = 1, obsolete, now reserved */
|
||||
/*C4MN_Bridge = 2, obsolete, now reserved */
|
||||
C4MN_Take = 3,
|
||||
C4MN_Buy = 4,
|
||||
|
|
|
@ -46,48 +46,6 @@ const int32_t C4MN_DefInfoWdt = 270, // default width of info windows
|
|||
|
||||
const int32_t C4MN_InfoCaption_Delay = 90;
|
||||
|
||||
/* Obsolete helper function still used by CreateMenu(iSymbol) */
|
||||
|
||||
#include <C4ObjectMenu.h> // only needed for menu symbol constants below
|
||||
|
||||
void DrawMenuSymbol(int32_t iMenu, C4Facet &cgo, int32_t iOwner, C4Object *cObj)
|
||||
{
|
||||
C4Facet ccgo;
|
||||
|
||||
DWORD dwColor=0;
|
||||
if (ValidPlr(iOwner)) dwColor=::Players.Get(iOwner)->ColorDw;
|
||||
|
||||
switch (iMenu)
|
||||
{
|
||||
case C4MN_Construction:
|
||||
{
|
||||
C4Def *pDef;
|
||||
if ((pDef=C4Id2Def(C4ID("CXCN"))))
|
||||
pDef->Draw(cgo);
|
||||
else if ((pDef=C4Id2Def(C4ID("WKS1"))))
|
||||
pDef->Draw(cgo);
|
||||
}
|
||||
break;
|
||||
case C4MN_Buy:
|
||||
::GraphicsResource.fctFlagClr.DrawClr(ccgo = cgo.GetFraction(75, 75), true, dwColor);
|
||||
::GraphicsResource.fctWealth.Draw(ccgo = cgo.GetFraction(100, 50, C4FCT_Left, C4FCT_Bottom));
|
||||
::GraphicsResource.fctArrow.Draw(ccgo = cgo.GetFraction(70, 70, C4FCT_Right, C4FCT_Center), false, 0);
|
||||
break;
|
||||
case C4MN_Sell:
|
||||
::GraphicsResource.fctFlagClr.DrawClr(ccgo = cgo.GetFraction(75, 75), true, dwColor);
|
||||
::GraphicsResource.fctWealth.Draw(ccgo = cgo.GetFraction(100, 50, C4FCT_Left, C4FCT_Bottom));
|
||||
::GraphicsResource.fctArrow.Draw(ccgo = cgo.GetFraction(70, 70, C4FCT_Right, C4FCT_Center), false, 1);
|
||||
break;
|
||||
/*case C4MN_Main:
|
||||
::GraphicsResource.fctFlagClr.DrawClr(cgo,true,dwColor);
|
||||
ccgo.Set(cgo.Surface,cgo.X,cgo.Y+cgo.Hgt/2,cgo.Wdt,cgo.Hgt/2);
|
||||
::GraphicsResource.fctCrewClr.DrawClr(ccgo,true,dwColor);
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// C4MenuItem
|
||||
|
||||
|
|
|
@ -74,8 +74,6 @@ enum
|
|||
C4MN_AdjustPosition = 1<<31
|
||||
};
|
||||
|
||||
void DrawMenuSymbol(int32_t iMenu, C4Facet &cgo, int32_t iOwner, C4Object *cObj);
|
||||
|
||||
class C4MenuItem : public C4GUI::Element
|
||||
{
|
||||
friend class C4Menu;
|
||||
|
|
|
@ -897,7 +897,7 @@ void C4ViewportList::RecalculateViewports()
|
|||
SortViewportsByPlayerControl();
|
||||
|
||||
// Viewport area
|
||||
int32_t iBorderTop = 0, iBorderBottom = 0;
|
||||
int32_t iBorderTop = 0;
|
||||
if (Config.Graphics.UpperBoard)
|
||||
iBorderTop = C4UpperBoardHeight;
|
||||
ViewportArea.Set(FullScreen.pSurface,0,iBorderTop, C4GUI::GetScreenWdt(), C4GUI::GetScreenHgt()-iBorderTop);
|
||||
|
|
Loading…
Reference in New Issue