当前位置: 首页>>代码示例>>C++>>正文


C++ Element::GetInnerRML方法代码示例

本文整理汇总了C++中rocket::core::Element::GetInnerRML方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::GetInnerRML方法的具体用法?C++ Element::GetInnerRML怎么用?C++ Element::GetInnerRML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rocket::core::Element的用法示例。


在下文中一共展示了Element::GetInnerRML方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_mouseup

/// \brief Event listener callback for "mouseup" events generated by libRocket.
///
/// \param ev     The object containing event info.
/// \param store  The UIDataViewList widget to use.
/// \param db     The cards database to use for comparison against model
///               (table) data.
/// \param model  The data source model to use.
/// \param player_hand  The mock player hand object to use for holding card
///                     data, such as totals on number of cards of a type.
void on_mouseup(  Rocket::Core::Event& ev,
                  UIDataViewList* store,
                  const std::shared_ptr<CardCollection> db,
                  std::shared_ptr<CardsPageDataSource> model,
                  std::map<int,Card>& player_hand )
{
  EXPECT_TRUE( store != nullptr );
  EXPECT_TRUE( db != nullptr );
  EXPECT_TRUE( model != nullptr );

  // ID of card selection
  int selection = 0;
  Rocket::Core::Element* target = ev.GetTargetElement();

  if( ev == "mouseup" )
  {
    Rocket::Core::Input::KeyIdentifier button =
      (Rocket::Core::Input::KeyIdentifier) ev.GetParameter<int>("button", 3);

    EXPECT_TRUE( model->per_page() == model->GetNumRows("cards") );
    EXPECT_EQ( 57, model->num_rows() );

    if( target ) {

      Card card = model->lookup_by_name( target->GetInnerRML().CString() );
      selection = card.id();

      if( target->GetTagName() == "card" && button == 0 ) // Left click
      {
        // Card selection logic; player hand receives a card
        //
        // 1. Decrease available card count by one
        // 2. Sync the cards model to reflect modified card count (-1)
        // 3. Update player hand w/ a copy of the reference card
        if( card.num() > 0 )
        {
          card.set_num( card.num() - 1 );
          model->insert_card(selection, card);
          player_hand[card.id()] = card;
        }

      } // end if button == 0
      else if( target->GetTagName() == "card" && button == 1 )  // Right click
      {
        // Compare the selected card from the current model with the game
        // database; we rely on the game database to be the "safe" -- read-only.
        Card ref_card = db->lookup_by_id(selection);

        // Card selection logic; player hand removes a card
        //
        // 1. Increase available card count by one
        // 2. Sync the cards model to reflect modified card count (+1)
        // 3. Remove the card from the player's hand
        if( card.num() < ref_card.num() )
        {
          card.set_num( card.num() + 1 );
          model->insert_card(selection, card);
          player_hand.erase( card.id() );
        }
      } // end if button == 1

      NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, "Card ID:", selection );
      NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, "Card name:", target->GetInnerRML().CString() );

    } // end if target

  } // end if click
} // end func on_mouseup
开发者ID:i8degrees,项目名称:nomlib,代码行数:77,代码来源:libRocketDataGridTest.cpp


注:本文中的rocket::core::Element::GetInnerRML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。