Changeset 51:bc776d590040 in xplra


Ignore:
Timestamp:
02/16/13 10:31:37 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 3 'hg:/home/ivaradi/xplane/hg/xplra' '/'>, 'public')
Message:

Added scrolling the message if needed

Location:
src/plugin/src/xplra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/plugin/src/xplra/MessageWindow.cc

    r50 r51  
    7979    maxMessageLength(0),
    8080    showForced(false),
     81    showTime(0.0),
    8182    hideTime(0.0),
    8283    clickedX(-1),
     
    146147    float d = getNewMessage(displayedMessage);
    147148    if (d>0.0) {
     149        showTime = now;
    148150        hideTime = now + d;
    149151    }
     
    156158        XPLMDrawTranslucentDarkBox(left, top, right, bottom);
    157159        if (hideTime!=0.0) {
    158 
    159             string dm(displayedMessage, 0, maxMessageLength);
     160            size_t offset = 0;
     161            if  (displayedMessage.size()>maxMessageLength &&
     162                 now > (showTime + scrollTimeout) )
     163            {
     164                offset = (now - showTime - scrollTimeout) /
     165                    scrollInterval;
     166                offset = min(offset,
     167                             displayedMessage.size() - maxMessageLength);
     168            }
     169
     170            string dm(displayedMessage, offset, maxMessageLength);
    160171
    161172            XPLMDrawString(colour,
  • src/plugin/src/xplra/MessageWindow.h

    r50 r51  
    9494    static const int baseLineSize = 2;
    9595
     96    /**
     97     * The amount of time in seconds after which the message is
     98     * started to be scrolled, if it should be scrolled.
     99     */
     100    static const float scrollTimeout = 1.0;
     101
     102    /**
     103     * The amount of time in seconds between each character step.
     104     */
     105    static const float scrollInterval = 0.1;
     106
    96107private:
    97108    /**
     
    143154     * The maximal message length.
    144155     */
    145     int maxMessageLength;
     156    size_t maxMessageLength;
    146157
    147158    /**
     
    154165     */
    155166    std::string displayedMessage;
     167
     168    /**
     169     * The time the current message was shown.
     170     */
     171    float showTime;
    156172
    157173    /**
Note: See TracChangeset for help on using the changeset viewer.