46
46
uAction::uAction(uAction *&anchor,const char* name,
49
:tListItem<uAction>(anchor),type(t),priority(priority_),internalName(name){
49
:tListItem<uAction>(anchor),tooltip_(NULL),type(t),priority(priority_),internalName(name){
50
50
globalID = localID = su_allActionsLen++;
52
52
tASSERT(localID < uMAX_ACTIONS);
71
71
const tOutput& help,
74
:tListItem<uAction>(anchor),type(t),priority(priority_),internalName(name), description(desc), helpText(help){
74
:tListItem<uAction>(anchor),tooltip_(NULL),type(t),priority(priority_),internalName(name), description(desc), helpText(help){
75
75
globalID = localID = su_allActionsLen++;
77
77
tASSERT(localID < uMAX_ACTIONS);
1448
1452
bool uBindPlayer::DoActivate(REAL x){
1449
1454
if (ePlayer==0)
1450
return GlobalAct(act,x);
1455
ret = GlobalAct(act,x);
1452
return uPlayerPrototype::PlayerConfig(ePlayer-1)->Act(act,x);
1457
ret = uPlayerPrototype::PlayerConfig(ePlayer-1)->Act(act,x);
1459
if( ret && act && act->GetTooltip() && x > 0 )
1461
act->GetTooltip()->Count(ePlayer);
1510
1522
static uActionGlobalFunc mu(&mess_up,&messup_func);
1511
1523
static uActionGlobalFunc md(&mess_down,&messdown_func);
1512
1524
static uActionGlobalFunc me(&mess_end,&messend_func);
1530
uActionTooltip::uActionTooltip( uAction & action, int numHelp, VETOFUNC * veto )
1531
: tConfItemBase(action.internalName + "_TOOLTIP"), action_( action ), veto_(veto)
1533
help_ = tString("$input_") + action.internalName + "_tooltip";
1536
// initialize array holding the number of help attempts to give left
1537
for( int i = uMAX_PLAYERS; i >= 0; --i )
1539
activationsLeft_[i] = 0; // numHelp;
1542
action.tooltip_ = this;
1545
uActionTooltip::~uActionTooltip()
1547
if( action_.tooltip_ == this )
1548
action_.tooltip_ = NULL;
1552
bool uActionTooltip::Help( int player )
1554
// find most needed tooltip
1555
uActionTooltip * mostWanted = NULL;
1557
// keys bound to the action of the tooltip that needs help
1561
// run through binds
1562
for ( uInputs::const_iterator i = su_inputs.begin(); i != su_inputs.end(); ++i )
1564
uBind * bind = (*i)->GetBind();
1565
if( !bind ||!bind->CheckPlayer(player) )
1567
uAction * action = bind->act;
1570
uActionTooltip * tooltip = action->GetTooltip();
1571
if( !tooltip || ( tooltip->veto_ && (*tooltip->veto_)(player) ) )
1576
int activationsLeft = tooltip->activationsLeft_[player];
1577
if( activationsLeft > 0 &&
1578
( !mostWanted || mostWanted->activationsLeft_[player] < activationsLeft ) )
1580
mostWanted = tooltip;
1585
// build up key list
1586
if( mostWanted == tooltip )
1588
if ( maps.Len() > 1 )
1592
if ( last.Len() > 1 )
1596
last = tString("<") + (*i)->Name() + ">";
1602
if( last.Len() > 1 )
1604
if( maps.Len() > 1 )
1605
maps << " " << tOutput("$input_or") << " " << last;
1610
con.CenterDisplay(tString(tOutput(mostWanted->help_, maps)));
1617
void uActionTooltip::Count( int player )
1619
if ( activationsLeft_[player] > 0 )
1621
activationsLeft_[player]--;
1626
void uActionTooltip::WriteVal(std::ostream & s )
1628
for( int i = 0; i <= uMAX_PLAYERS; ++i )
1630
s << activationsLeft_[i] << " ";
1634
void uActionTooltip::ReadVal(std::istream & s )
1636
for( int i = 0; i <= uMAX_PLAYERS; ++i )
1638
s >> activationsLeft_[i];