void MapMaintener::pauseMapCallback( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
{
	menu_handler.setVisible(h_start, true);
	menu_handler.setVisible(h_pause, false);
	menu_handler.setVisible(h_stop, true);
	menu_handler.reApply( *server);
  server->applyChanges();
	mappingActive = false;
}
void modeCb( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
{

    menu_handler.setCheckState( h_mode_last, MenuHandler::UNCHECKED );
    h_mode_last = feedback->menu_entry_id;
    std::string namesss=feedback->control_name;
    ROS_INFO("Name: %s", namesss.c_str());
    ROS_INFO("last %i", h_mode_last);
    menu_handler.setCheckState( h_mode_last, MenuHandler::CHECKED );
    menu_handler.reApply( *server );
    server->applyChanges();

}
Exemplo n.º 3
0
void MenuManager::menuSelected( WMenuItem * item )
//------------------------------------------------
{
    const SubMenuInfo * info;
    MenuHandler *       handler;

    info = (const SubMenuInfo *) item->tagPtr();
    MIMenuID id( info->mainId, info->subId );

    if( _receivers->find( id, handler ) ) {
        if( handler != NULL ) {
            handler->menuSelected( id );
        }
    }
}
void DroneRvizDisplay::initMenu(int i)
{

    std::ostringstream s;

    s << "Drone " << i;

    h_mode_last = menu_handler.insert( sub_menu_handle, s.str(), &modeCb );
    menu_handler.setCheckState( h_mode_last, MenuHandler::UNCHECKED );
    h_mode_last = 2;
    menu_handler.setCheckState( h_mode_last, MenuHandler::CHECKED );  //try
    //

    ROS_INFO("INIT");
    //obstacles.ns="zero";


}
// Marker callback
void MapMaintener::update_tf(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
{
	//InteractiveMarker int_marker;
	//server->get("object_menu", int_marker);

	if(mapPointCloud.features.cols() == 0)
	{	
		nav_msgs::Odometry odom;
		odom.pose.pose = feedback->pose;
		publishLock.lock();
		TObjectToMap = 	PointMatcher_ros::odomMsgToEigenMatrix<float>(odom);
		publishLock.unlock();
		
		//int_marker.description = "Move to the zone of interest";
		menu_handler.reApply( *server);
		server->applyChanges();
	}
	else
	{
		//int_marker.description = "Reset the map to apply change";
		menu_handler.reApply( *server);
		server->applyChanges();
	}
}
Exemplo n.º 6
0
    StartingMenuScreen::StartingMenuScreen(MenuHandler& menu) : Parent(menu)
    {
        auto renderer = FARender::Renderer::get();
        mFocus42.reset(new FARender::AnimationPlayer());
        mFocus42->playAnimation(renderer->loadImage("ui_art/focus42.pcx&trans=0,255,0&vanim=42"),
                                FAWorld::World::getTicksInPeriod("0.06"),
                                FARender::AnimationPlayer::AnimationType::Looped);
        mSmLogo = menu.createSmLogo();

        auto drawItem = [&](const char* text, const struct nk_rect& rect) {
            return [=](nk_context* ctx, bool isActive) {
                nk_layout_space_push(ctx, rect);
                menuText(ctx, text, MenuFontColor::gold, 42, NK_TEXT_ALIGN_CENTERED);
                auto ret = DrawFunctionResult::noAction;
                if (nk_widget_is_mouse_click_down_inactive(ctx, NK_BUTTON_LEFT))
                {
                    ret = DrawFunctionResult::executeAction;
                }
                if (isActive)
                {
                    auto frame = mFocus42->getCurrentFrame();
                    auto frameRect = nk_rect(0, 0, frame.first->getWidth(), frame.first->getHeight());
                    nk_layout_space_push(ctx, alignRect(frameRect, rect, halign_t::left, valign_t::center));
                    nk_image(ctx, frame.first->getNkImage(frame.second));
                    nk_layout_space_push(ctx, alignRect(frameRect, rect, halign_t::right, valign_t::center));
                    nk_image(ctx, frame.first->getNkImage(frame.second));
                }
                return ret;
            };
        };
        mMenuItems.push_back({drawItem("Single Player", {65, 192, 510, 42}), [this]() {
                                  mMenuHandler.setActiveScreen<SelectHeroMenuScreen>();
                                  return ActionResult::stopDrawing;
                              }});
        mMenuItems.push_back({drawItem("Multi Player", {65, 235, 510, 42}), []() { return ActionResult::continueDrawing; }});
        mMenuItems.push_back({drawItem("Replay Intro", {65, 277, 510, 42}), []() { return ActionResult::continueDrawing; }});
        mMenuItems.push_back({drawItem("Show Credits", {65, 320, 510, 42}), []() { return ActionResult::continueDrawing; }});
        mRejectAction = [this]() {
            mMenuHandler.engine().stop();
            return ActionResult::stopDrawing;
        };
        mMenuItems.push_back({drawItem("Exit Diablo", {65, 363, 510, 42}), mRejectAction});
    }
Exemplo n.º 7
0
GameSequence *IntroSequence::doTick(ALLEGRO_BITMAP *screen_buffer,
                                    bool key_pressed[ALLEGRO_KEY_MAX],
                                    bool key_down[ALLEGRO_KEY_MAX],
                                    bool *exit_game, double dt) {
  iZoom = (iZoom - iZoomSpeed);
  if (iZoom < 1.0) {
    iZoom = 1;
    isRunning = false;
  }

  clear_bitmap(iDoublebuffer);
  DrawZoomedLogoInCenter(mini, maxi);
  // draw 2 horizontal lines
  hline(iDoublebuffer, 0, 0, width, al_map_rgb(255, 255, 255));
  hline(iDoublebuffer, 0, IntroSequence::maxi - IntroSequence::mini - 1, width,
        al_map_rgb(255, 255, 255));

  // blit to the screen
  blit(iDoublebuffer, screen_buffer, 0, 0, 0, mini, width, maxi - mini);

  if (key_pressed[ALLEGRO_KEY_ESCAPE] && canQuickExit) {
    quickExit = true;
    isRunning = false;
  }

  if (joystick_action_timer.is_running())
    joystick_action_timer.tick();

  bool startgame = false;
  bool exit = false;
  bool reload = false;

  if (!quickExit && !isRunning) {
    black = al_map_rgb(0, 0, 0);
    red = al_map_rgb(255, 0, 0);
    lightred = al_map_rgb(255, 75, 75);

    handle_key_presses(key_pressed, &reload, &startgame, &exit);

    char layout_str[1000];
    auto font = GameManager::font;

    MenuHandler mh;

    mh.reset();
    mh.selected_idx = menuselected;
    mh.maxi = maxi;
    mh.width = width;
    mh.max_visible_lines = 25;

    mh.addline("Start game");
    mh.addline("Options:", false, 15);

    snprintf(menutext, sizeof(menutext), "   Players - %d   ", playerschoice);
    mh.addline(menutext);

    snprintf(menutext, sizeof(menutext), "   Level - %d   ", levelchoice + 1);
    mh.addline(menutext);

    snprintf(menutext, sizeof(menutext), "   Lives - %d   ", liveschoice);
    mh.addline(menutext);

    snprintf(menutext, sizeof(menutext), "   Use DCA - %s   ",
             ((dcachoice) ? "yes" : "no"));
    mh.addline(menutext);

    snprintf(menutext, sizeof(menutext), "   Wall Collision - %s   ",
             ((wallchoice) ? "yes" : "no"));
    mh.addline(menutext);

    mh.addline("Controls:", false, 15);

    snprintf(menutext, sizeof(menutext), "   Player 1 - %s",
             get_control_id_as_string(playercontrols[0]));
    mh.addline(menutext);

    snprintf(menutext, sizeof(menutext), "   Player 2 - %s",
             get_control_id_as_string(playercontrols[1]));
    mh.addline(menutext);

    snprintf(menutext, sizeof(menutext), "   Player 3 - %s",
             get_control_id_as_string(playercontrols[2]));
    mh.addline(menutext);

    snprintf(menutext, sizeof(menutext), "   Player 4 - %s",
             get_control_id_as_string(playercontrols[3]));
    mh.addline(menutext);

    mh.addline("Controller layouts:", false, 15);
    
    menu_joy_kbd_idx = 10;
  
    menu_kbd_layout1_idx = 0;
    menu_kbd_layout2_idx = 0;
    menu_kbd_layout3_idx = 0;
    menu_kbd_layout4_idx = 0;
    menu_kbd_layout_end = 0;
  
    menu_joy_layout1_idx = 0;
    menu_joy_layout2_idx = 0;
    menu_joy_layout3_idx = 0;
    menu_joy_layout4_idx = 0;
    menu_joy_layout_end = 0;
    
    if (GameManager::num_joysticks_loaded > 0) {
      for (int i = 0; i < GameManager::num_joysticks_loaded; i++) {
        switch (i) {
          case 0:
            menu_joy_layout1_idx = menu_joy_kbd_idx;
            break;
          case 1:
            menu_joy_layout2_idx = menu_joy_kbd_idx;
            break;
          case 2:
            menu_joy_layout3_idx = menu_joy_kbd_idx;
            break;
          case 3:
            menu_joy_layout4_idx = menu_joy_kbd_idx;
            break;
        }
        snprintf(menutext, sizeof(menutext), "   Joystick %d %s", (i + 1), al_get_joystick_name(GameManager::joysticks[i]->joy));
        mh.addline(menutext, false, 10);
        snprintf(menutext, sizeof(menutext), "      Left   - %s",
                 button_to_str(mapping_joy::btn_sets[i][0]));
        mh.addline(menutext);
        snprintf(menutext, sizeof(menutext), "      Right  - %s",
                 button_to_str(mapping_joy::btn_sets[i][1]));
        mh.addline(menutext);
        snprintf(menutext, sizeof(menutext), "      Thrust - %s",
                 button_to_str(mapping_joy::btn_sets[i][2]));
        mh.addline(menutext);
        snprintf(menutext, sizeof(menutext), "      Shield - %s",
                 button_to_str(mapping_joy::btn_sets[i][3]));
        mh.addline(menutext);
        snprintf(menutext, sizeof(menutext), "      Fire   - %s",
                 button_to_str(mapping_joy::btn_sets[i][4]));
        mh.addline(menutext);
        menu_joy_kbd_idx = menu_joy_kbd_idx + 5;
        menu_joy_layout_end = menu_joy_kbd_idx;
      }
    }

    for (int i = 0; i < 4; i++) {
      switch (i) {
        case 0:
          menu_kbd_layout1_idx = menu_joy_kbd_idx;
          break;
        case 1:
          menu_kbd_layout2_idx = menu_joy_kbd_idx;
          break;
        case 2:
          menu_kbd_layout3_idx = menu_joy_kbd_idx;
          break;
        case 3:
          menu_kbd_layout4_idx = menu_joy_kbd_idx;
          break;
      }
      
      snprintf(menutext, sizeof(menutext), "   Keyboard %d", (i + 1));
      mh.addline(menutext, false, 10);
      snprintf(menutext, sizeof(menutext), "      Left   - %s",
               key_to_str(mapping_key::key_sets[i][0]));
      mh.addline(menutext);
      snprintf(menutext, sizeof(menutext), "      Right  - %s",
               key_to_str(mapping_key::key_sets[i][1]));
      mh.addline(menutext);
      snprintf(menutext, sizeof(menutext), "      Thrust - %s",
               key_to_str(mapping_key::key_sets[i][2]));
      mh.addline(menutext);
      snprintf(menutext, sizeof(menutext), "      Shield - %s",
               key_to_str(mapping_key::key_sets[i][3]));
      mh.addline(menutext);
      snprintf(menutext, sizeof(menutext), "      Fire   - %s",
               key_to_str(mapping_key::key_sets[i][4]));
      mh.addline(menutext);
      menu_joy_kbd_idx = menu_joy_kbd_idx + 5;
      menu_kbd_layout_end = menu_joy_kbd_idx;
    }

    snprintf(menutext, sizeof(menutext), "Resolution (%ix%i):   ", width,
             height);
    mh.addline(menutext, false, 15);

    menu_resolution_idx = menu_joy_kbd_idx;
    menu_exit_idx = menu_resolution_idx + 1;
    menuitems = menu_exit_idx + 1;

    if (width == GameManager::native_width &&
        height == GameManager::native_height)
      snprintf(menutext, sizeof(menutext), "   Switch to Low - 1024x768   ");
    else
      snprintf(menutext, sizeof(menutext), "   Switch to Native - %ix%i   ",
               GameManager::native_width, GameManager::native_height);
    mh.addline(menutext);

    mh.addline("Exit", true, 15);

    mh.draw(screen_buffer, font);
  }

  *exit_game = exit;

  GameSequence *seq = nullptr;
  if (startgame) {
    iZoom = iZoomMax;
    seq = new BattleSequence(this, playerschoice, playerschoice, liveschoice,
                             levelchoice, dcachoice, wallchoice, width, height,
                             playercontrols);
  } else if (reload)
    seq = new IntroSequence(NULL, 10.0, 0.5, playerschoice, levelchoice,
                            liveschoice, dcachoice, wallchoice);
  else
    seq = ReturnScreen();

  return seq;
}
void DroneRvizDisplay::MenuHandlerApply()
{

    menu_handler.apply(*server, "GRF");

}
#include "RvizInteractiveMarkerDisplay.h"

using namespace visualization_msgs;
using namespace interactive_markers;

//Menu Initialize
MenuHandler menu_handler;
MenuHandler::EntryHandle h_first_entry;
MenuHandler::EntryHandle h_mode_last=2;
MenuHandler::EntryHandle sub_menu_handle = menu_handler.insert( "Drone Selection" );

//Server Initialize
boost::shared_ptr<interactive_markers::InteractiveMarkerServer> server;

//Marker objects
visualization_msgs::Marker obstacles;
visualization_msgs::Marker walls;
visualization_msgs::Marker line_strip;
visualization_msgs::Marker point;

//Initialize Markers
int ini = 0;
int iniMP = 0;
int iniO = 0;


//-------------------------Create Markers(Box / Sphere)------------------------------------------------//


Marker makeBox( InteractiveMarker &msg )
{