~vitty/armagetronad/trunk-armagetronad-breakpad

« back to all changes in this revision

Viewing changes to src/ui/uInput.cpp

  • Committer: z-man
  • Date: 2010-08-06 07:05:46 UTC
  • Revision ID: svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Ftrunk%2Farmagetronad:9426
Merging branch 0.2.8 from revision 9356 to 9425:
 ------------------------------------------------------------------------
 r9424 | bazaarmagetron | 2010-06-28 17:45:41 +0200 (Mon, 28 Jun 2010) | 2 lines
 
 Manuel Moos: Improving readability of console and in-game menu by fading the background to black with an alpha quad.
 
 ------------------------------------------------------------------------
 r9423 | bazaarmagetron | 2010-06-25 16:03:21 +0200 (Fri, 25 Jun 2010) | 2 lines
 
 Manuel Moos: Finishing passing of configuration directory from last merge.
 
 ------------------------------------------------------------------------
 r9422 | bazaarmagetron | 2010-06-25 16:02:48 +0200 (Fri, 25 Jun 2010) | 5 lines
 
 author: Manuel Moos
 Merging own changes from earlier:
  - Added passing down of $CONFIG directory in serverstarter scripts.
  - Hovering over color menu items no longer breaks debug recording playback fast forward.
 
 ------------------------------------------------------------------------
 r9421 | bazaarmagetron | 2010-06-24 01:04:25 +0200 (Thu, 24 Jun 2010) | 2 lines
 
 Manuel Moos: Merging own forgotten changes.
 
 ------------------------------------------------------------------------
 r9420 | bazaarmagetron | 2010-06-07 15:19:04 +0200 (Mon, 07 Jun 2010) | 2 lines
 
 Manuel Moos: Avoiding player list read overflow. How did this go unnoticed for so long?
 
 ------------------------------------------------------------------------
 r9419 | bazaarmagetron | 2010-05-27 13:36:19 +0200 (Thu, 27 May 2010) | 2 lines
 
 Manuel Moos: Fixing aspect ratio calculations. In all practical cases, ensuring vertical fov did not happen; in those where something happened (really, really high screens), it overcompensated and distorted the image.
 
 ------------------------------------------------------------------------
 r9418 | bazaarmagetron | 2010-05-26 15:04:31 +0200 (Wed, 26 May 2010) | 2 lines
 
 Manuel Moos: Taking ownership of ALL network objects formerly belonging to a deleted user.
 
 ------------------------------------------------------------------------
 r9417 | bazaarmagetron | 2010-05-26 15:03:55 +0200 (Wed, 26 May 2010) | 2 lines
 
 Manuel Moos: Clearing send queue on new user login. Fixes one instance of odd authentication dialogs popping up.
 
 ------------------------------------------------------------------------
 r9416 | bazaarmagetron | 2010-05-26 15:03:19 +0200 (Wed, 26 May 2010) | 2 lines
 
 Manuel Moos: Simplified default login procedure for @forums accounts.
 
 ------------------------------------------------------------------------
 r9415 | bazaarmagetron | 2010-04-25 23:27:21 +0200 (Sun, 25 Apr 2010) | 2 lines
 
 Manuel Moos: Updated to current version from gnu.org. Address change, formatting, and LGPL is now the lesser GNU License.
 
 ------------------------------------------------------------------------
 r9414 | bazaarmagetron | 2010-04-25 23:26:49 +0200 (Sun, 25 Apr 2010) | 2 lines
 
 Manuel Moos: Using OUR version of COPYING.
 
 ------------------------------------------------------------------------
 r9413 | bazaarmagetron | 2010-04-22 12:33:03 +0200 (Thu, 22 Apr 2010) | 2 lines
 
 Manuel Moos: Avoiding reloading of title screen when textures are reloaded and it isn't actually getting displayed.
 
 ------------------------------------------------------------------------
 r9412 | bazaarmagetron | 2010-04-19 20:02:56 +0200 (Mon, 19 Apr 2010) | 1 line
 
 Luke Dashjr: replace references to guru3.sytes.net with working URIs at forums.armagetronad.net
 ------------------------------------------------------------------------
 r9408 | bazaarmagetron | 2010-04-17 19:02:43 +0200 (Sat, 17 Apr 2010) | 1 line
 
 Luke Dashjr: main is not a valid hack for AC_CHECK_LIB... use valid values
 ------------------------------------------------------------------------
 r9400 | bazaarmagetron | 2010-03-19 23:41:45 +0100 (Fri, 19 Mar 2010) | 1 line
 
 Luke Dashjr: png_sig_cmp is in both libpng12 and libpng14, where as png_check_sig is only libpng12 --ssuominen
 ------------------------------------------------------------------------
 r9377 | bazaarmagetron | 2010-02-22 20:39:56 +0100 (Mon, 22 Feb 2010) | 1 line
 
 Manuel Moos: partial portugese translation
 ------------------------------------------------------------------------
 r9375 | bazaarmagetron | 2010-02-21 01:16:35 +0100 (Sun, 21 Feb 2010) | 2 lines
 
 Manuel Moos: More typo fixes.
 
 ------------------------------------------------------------------------
 r9368 | bazaarmagetron | 2010-02-20 18:08:58 +0100 (Sat, 20 Feb 2010) | 2 lines
 
 Manuel Moos: Rebranding support for configure error messages.
 
 ------------------------------------------------------------------------
 r9367 | bazaarmagetron | 2010-02-20 18:08:00 +0100 (Sat, 20 Feb 2010) | 2 lines
 
 Manuel Moos: Merging start menu branch.
 
 ------------------------------------------------------------------------
 r9366 | bazaarmagetron | 2010-02-20 18:06:37 +0100 (Sat, 20 Feb 2010) | 2 lines
 
 Manuel Moos: Merging tooltip branch.
 
 ------------------------------------------------------------------------
 r9365 | bazaarmagetron | 2010-02-20 18:04:54 +0100 (Sat, 20 Feb 2010) | 2 lines
 
 Manuel Moos: Merging luke's spelling fix branch.
 
 ------------------------------------------------------------------------
 r9364 | bazaarmagetron | 2010-02-19 19:25:59 +0100 (Fri, 19 Feb 2010) | 2 lines
 
 Manuel Moos: "Winner..." message only shown if there is a non-zero win score. Yeah, we don't care if it's negative.
 
 ------------------------------------------------------------------------

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
uAction::uAction(uAction *&anchor,const char* name,
47
47
                 int priority_,
48
48
                 uInputType t)
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++;
51
51
 
52
52
    tASSERT(localID < uMAX_ACTIONS);
71
71
                 const tOutput& help,
72
72
                 int priority_,
73
73
                 uInputType t)
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++;
76
76
 
77
77
    tASSERT(localID < uMAX_ACTIONS);
1304
1304
    // transform events
1305
1305
    bool ret = false;
1306
1306
 
 
1307
    // there is nearly allways a mouse motion tEvent:
 
1308
    int xrel=e.motion.xrel;
 
1309
    int yrel=-e.motion.yrel;
 
1310
 
1307
1311
    std::vector< uTransformEventInfo > events;
1308
1312
    su_TransformEvent( e, events );
1309
1313
 
1446
1450
}
1447
1451
 
1448
1452
bool uBindPlayer::DoActivate(REAL x){
 
1453
    bool ret = false;
1449
1454
    if (ePlayer==0)
1450
 
        return  GlobalAct(act,x);
 
1455
        ret = GlobalAct(act,x);
1451
1456
    else
1452
 
        return uPlayerPrototype::PlayerConfig(ePlayer-1)->Act(act,x);
 
1457
        ret = uPlayerPrototype::PlayerConfig(ePlayer-1)->Act(act,x);
 
1458
 
 
1459
    if( ret && act && act->GetTooltip() && x > 0 )
 
1460
    {
 
1461
        act->GetTooltip()->Count(ePlayer);
 
1462
    }
 
1463
    
 
1464
    return ret;
1453
1465
}
1454
1466
 
1455
1467
 
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);
 
1525
 
 
1526
// ********
 
1527
// tooltips
 
1528
// ********
 
1529
 
 
1530
uActionTooltip::uActionTooltip( uAction & action, int numHelp, VETOFUNC * veto )
 
1531
: tConfItemBase(action.internalName + "_TOOLTIP"), action_( action ), veto_(veto)
 
1532
{
 
1533
    help_ = tString("$input_") + action.internalName + "_tooltip";
 
1534
    tToLower( help_ );
 
1535
 
 
1536
    // initialize array holding the number of help attempts to give left
 
1537
    for( int i = uMAX_PLAYERS; i >= 0; --i )
 
1538
    {
 
1539
        activationsLeft_[i] = 0; // numHelp;
 
1540
    }
 
1541
 
 
1542
    action.tooltip_ = this;
 
1543
}
 
1544
 
 
1545
uActionTooltip::~uActionTooltip()
 
1546
{
 
1547
    if( action_.tooltip_ == this )
 
1548
        action_.tooltip_ = NULL;
 
1549
        
 
1550
}
 
1551
 
 
1552
bool uActionTooltip::Help( int player )
 
1553
{
 
1554
    // find most needed tooltip
 
1555
    uActionTooltip * mostWanted = NULL;
 
1556
 
 
1557
    // keys bound to the action of the tooltip that needs help
 
1558
    tString maps;
 
1559
    tString last;
 
1560
 
 
1561
    // run through binds
 
1562
    for ( uInputs::const_iterator i = su_inputs.begin(); i != su_inputs.end(); ++i )
 
1563
    {
 
1564
        uBind * bind = (*i)->GetBind();
 
1565
        if( !bind ||!bind->CheckPlayer(player) )
 
1566
            continue;
 
1567
        uAction * action = bind->act;
 
1568
        if( !action )
 
1569
            continue;
 
1570
        uActionTooltip * tooltip = action->GetTooltip();
 
1571
        if( !tooltip || ( tooltip->veto_ && (*tooltip->veto_)(player) ) )
 
1572
        {
 
1573
            continue;
 
1574
        }
 
1575
        
 
1576
        int activationsLeft = tooltip->activationsLeft_[player];
 
1577
        if( activationsLeft > 0 && 
 
1578
            ( !mostWanted || mostWanted->activationsLeft_[player] < activationsLeft ) )
 
1579
        {
 
1580
            mostWanted = tooltip;
 
1581
            maps = "";
 
1582
            last = "";
 
1583
        }
 
1584
 
 
1585
        // build up key list
 
1586
        if( mostWanted == tooltip )
 
1587
        {
 
1588
            if ( maps.Len() > 1 )
 
1589
            {
 
1590
                maps << ", ";
 
1591
            }
 
1592
            if ( last.Len() > 1 )
 
1593
            {
 
1594
                maps << last;
 
1595
            }
 
1596
            last = tString("<") + (*i)->Name() + ">";
 
1597
        }
 
1598
    }
 
1599
 
 
1600
    if( mostWanted )
 
1601
    {
 
1602
        if( last.Len() > 1 )
 
1603
        {
 
1604
            if( maps.Len() > 1 )
 
1605
                maps << " " << tOutput("$input_or") << " " << last;
 
1606
            else
 
1607
                maps = last;
 
1608
        }
 
1609
 
 
1610
        con.CenterDisplay(tString(tOutput(mostWanted->help_, maps)));
 
1611
 
 
1612
        return true;
 
1613
    }
 
1614
    return false;
 
1615
}
 
1616
 
 
1617
void uActionTooltip::Count( int player )
 
1618
{
 
1619
    if ( activationsLeft_[player] > 0 )
 
1620
    {
 
1621
        activationsLeft_[player]--;
 
1622
        Help(player);
 
1623
    }
 
1624
}
 
1625
 
 
1626
void uActionTooltip::WriteVal(std::ostream & s )
 
1627
{
 
1628
    for( int i = 0; i <= uMAX_PLAYERS; ++i )
 
1629
    {
 
1630
        s << activationsLeft_[i] << " ";
 
1631
    }
 
1632
}
 
1633
 
 
1634
void uActionTooltip::ReadVal(std::istream & s )
 
1635
{
 
1636
    for( int i = 0; i <= uMAX_PLAYERS; ++i )
 
1637
    {
 
1638
        s >> activationsLeft_[i];
 
1639
    }
 
1640
}