Changeset 42:719f590e4878 in xplra


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

Added initial support for the menu

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

Legend:

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

    r38 r42  
    7373
    7474MessageWindow::MessageWindow() :
     75    showForced(false),
    7576    hideTime(0.0),
    7677    duration(0.0)
     
    104105//------------------------------------------------------------------------------
    105106
     107void MessageWindow::show()
     108{
     109    showForced = true;
     110    XPLMSetWindowIsVisible(windowID, 1);
     111}
     112
     113//------------------------------------------------------------------------------
     114
     115void MessageWindow::hide()
     116{
     117    showForced = false;
     118}
     119
     120//------------------------------------------------------------------------------
     121
    106122void MessageWindow::drawWindow()
    107123{
     
    115131    }
    116132
    117     if (now>=hideTime) {
     133    if (now>=hideTime) hideTime = 0.0;
     134
     135    if (hideTime==0.0 && !showForced) {
    118136        XPLMSetWindowIsVisible(windowID, 0);
    119137    } else {
    120138        XPLMDrawTranslucentDarkBox(left, top, right, bottom);
    121         XPLMDrawString(colour, left + 25, top - 15,
    122                        const_cast<char*>(displayedMessage.c_str()), 0,
    123                        xplmFont_Basic);
     139        if (hideTime!=0.0) {
     140            XPLMDrawString(colour, left + 25, top - 15,
     141                           const_cast<char*>(displayedMessage.c_str()), 0,
     142                           xplmFont_Basic);
     143        }
    124144    }
    125145}
  • src/plugin/src/xplra/MessageWindow.h

    r38 r42  
    105105
    106106    /**
     107     * Indicate if the message window should be shown
     108     */
     109    bool showForced;
     110
     111    /**
    107112     * The currently displayed message.
    108113     */
     
    144149     */
    145150    ~MessageWindow();
     151
     152    /**
     153     * Force showing the message window.
     154     */
     155    void show();
     156
     157    /**
     158     * Hide the message window if it does not have to display an
     159     * actual message.
     160     */
     161    void hide();
    146162
    147163private:
  • src/plugin/src/xplra/plugin.cc

    r38 r42  
    3939#include <XPLMUtilities.h>
    4040#include <XPLMProcessing.h>
     41#include <XPLMMenus.h>
    4142
    4243#include <cstdio>
     
    6667 */
    6768static ListenThread* listenThread = 0;
     69
     70/**
     71 * The ID of the menu of the plugin.
     72 */
     73static XPLMMenuID menuID = 0;
     74
     75/**
     76 * The index of the show message area menu item.
     77 */
     78static int showMessageAreaIndex = 0;
     79
     80//------------------------------------------------------------------------------
     81
     82static void menuHandler(void* /*menuRef*/, void* /*itemRef*/)
     83{
     84    // Util::debug("hu.varadiistvan.xplra menuHandler called\n");
     85    XPLMMenuCheck checked = xplm_Menu_NoCheck;
     86    XPLMCheckMenuItemState(menuID, showMessageAreaIndex, &checked);
     87    if (checked==xplm_Menu_Unchecked) {
     88        XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Checked);
     89        messageWindow->show();
     90    } else if (checked==xplm_Menu_Checked) {
     91        XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Unchecked);
     92        messageWindow->hide();
     93    }
     94}
    6895
    6996//------------------------------------------------------------------------------
     
    96123    XPLMHostApplicationID hostID = 0;
    97124    XPLMGetVersions(&xplaneVersion, &xplmVersion, &hostID);
     125
     126    int menuIndex = XPLMAppendMenuItem(XPLMFindPluginsMenu(),
     127                                       "Remote Access", NULL, 1);
     128    menuID = XPLMCreateMenu("Remote Access", XPLMFindPluginsMenu(), menuIndex,
     129                            &menuHandler, 0);
     130    showMessageAreaIndex = XPLMAppendMenuItem(menuID, "Show message area",
     131                                              0, 1);
     132    XPLMCheckMenuItem(menuID, showMessageAreaIndex, xplm_Menu_Unchecked);
    98133
    99134    messageWindow = new MessageWindow();
Note: See TracChangeset for help on using the changeset viewer.