void CollisionSystem::IncorporateEntity(std::shared_ptr<Entity> eaterEntity,
    std::shared_ptr<Entity> eatableEntity)
{
    LOG_D("[CollisionSystem] Entity " << eaterEntity->GetId()
        << " is incorporating entity " << eatableEntity->GetId());

    auto spriteComponent = std::static_pointer_cast<SpriteComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(
            eatableEntity, "SpriteComponent"));
    auto complexityComponent = std::static_pointer_cast<ComplexityComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(eaterEntity, "ComplexityComponent"));

    auto maxComplexity = complexityComponent->GetMaxComplexity();
    auto complexity = complexityComponent->GetComplexity();

    if (complexity < maxComplexity)
    {
        complexity += 1;

        Vector position;
        position.SetPolar(50, 2*M_PI*complexity/maxComplexity);
        
        complexityComponent->SetComplexity(complexity);
        spriteComponent->SetPosition(position);
        Engine::GetInstance().AddComponent(spriteComponent, eaterEntity);

        DestroyEntity(eatableEntity);
    }
}
void CollisionSystem::CollideBodies(std::shared_ptr<Entity> entity1,
    std::shared_ptr<Entity> entity2)
{
    LOG_D("[CollisionSystem] Colliding entities: " << entity1->GetId() << " and " << entity2->GetId());

    auto particleComponent1 = std::static_pointer_cast<ParticleComponent>(Engine::GetInstance().GetSingleComponentOfClass(entity1, "ParticleComponent"));
    auto particleComponent2 = std::static_pointer_cast<ParticleComponent>(Engine::GetInstance().GetSingleComponentOfClass(entity2, "ParticleComponent"));
    auto colliderComponent1 = std::static_pointer_cast<ColliderComponent>(Engine::GetInstance().GetSingleComponentOfClass(entity1, "ColliderComponent"));
    auto colliderComponent2 = std::static_pointer_cast<ColliderComponent>(Engine::GetInstance().GetSingleComponentOfClass(entity2, "ColliderComponent"));
    float radius1 = colliderComponent1->GetRadius();
    float radius2 = colliderComponent2->GetRadius();
    Vector position1 = particleComponent1->GetPosition();
    Vector position2 = particleComponent2->GetPosition();
    float distance = position1.CalculateDistance(position2);
    float difference = radius1 + radius2 - distance;

    Vector direction = position2 - position1;
    direction.Normalize();

    // Applying force contrary to the collision direction. This force should
    // depend on the energy of the collision
    float forceMag = 100;
    Vector force1 = direction*(-forceMag);
    Vector force2 = direction*(forceMag);

    particleComponent1->SetForce(force1);
    particleComponent2->SetForce(force2);
    
    // Avoiding overlapping
    position1 += direction*(-difference/2);
    position2 += direction*(difference/2);

    particleComponent1->SetPosition(position1);
    particleComponent2->SetPosition(position2);
}
 touchmind::VISITOR_RESULT operator()(std::shared_ptr<touchmind::model::node::NodeModel> node) {
   D2D1_RECT_F layoutRect = D2D1::RectF(node->GetX() + m_insets.left, node->GetY() + m_insets.top,
                                        node->GetX() + node->GetWidth() - m_insets.right,
                                        node->GetY() + node->GetHeight() - m_insets.bottom);
   if (m_nodeIdToView.count(node->GetId()) != 0) {
     std::shared_ptr<touchmind::view::node::BaseNodeView> &nodeView = m_nodeIdToView[node->GetId()];
     nodeView->SetHandled();
     auto editControlIndex = m_nodeViewManager->GetEditControlIndexFromNodeId(node->GetId());
     std::shared_ptr<touchmind::control::DWriteEditControl> editControl
         = m_pEditControlManager->GetEditControl(editControlIndex);
     if (editControl != nullptr) {
       editControl->SetLayoutRect(layoutRect);
     }
   } else {
     touchmind::control::EDIT_CONTROL_INDEX editControlIndex;
     HRESULT hr = m_nodeViewManager->_CreateEditControl(layoutRect, node->GetText(), &editControlIndex);
     if (SUCCEEDED(hr)) {
       auto nodeView = touchmind::view::node::NodeViewFactory::Create(node);
       nodeView->SetNodeViewManager(m_nodeViewManager);
       nodeView->SetEditControlManager(m_pEditControlManager);
       nodeView->SetEditControlIndex(editControlIndex);
       nodeView->SetHandled();
       m_nodeIdToView.insert({node->GetId(), nodeView});
     } else {
       LOG(SEVERITY_LEVEL_WARN) << L"Failed to create an edit control";
     }
   }
   return touchmind::VISITOR_RESULT_CONTINUE;
 }
Example #4
0
    touchmind::VISITOR_RESULT operator()(std::shared_ptr<touchmind::model::node::NodeModel> node) {
        HRESULT hr = S_OK;

        m_pXPSPrint->_PrintNode(node);
        if (FAILED(hr)) {
            LOG(SEVERITY_LEVEL_WARN) << L"_PrintNodeBody failed at node(" << node->GetId() << L", hr = " << hr;
            return touchmind::VISITOR_RESULT_STOP;
        }

        XpsDWriteTextRenderer* pTextRenderer = m_pXPSPrint->GetTextRenderer();
        touchmind::view::node::NodeViewManager *pNodeViewManager = m_pXPSPrint->GetNodeViewManager();
        control::DWriteEditControlManager *pEditControlManager = m_pXPSPrint->GetEditControlManager();

        control::EDIT_CONTROL_INDEX editControlIndex = pNodeViewManager->GetEditControlIndexFromNodeId(node->GetId());
        std::shared_ptr<control::DWriteEditControl> pEditControl = pEditControlManager->GetEditControl(editControlIndex);
        if (pEditControl != nullptr) {
            IDWriteTextLayout* pTextLayout = pEditControl->GetTextLayout();
            if (pTextLayout != nullptr) {
                pTextLayout->Draw(nullptr,
                                  pTextRenderer,
                                  node->GetX() + m_pXPSPrint->GetConfiguration()->GetInsets().left,
                                  node->GetY() + m_pXPSPrint->GetConfiguration()->GetInsets().top);
            } else {
                LOG(SEVERITY_LEVEL_WARN) << L"TextLayout is null";
            }
        } else {
            LOG(SEVERITY_LEVEL_WARN) << L"Could not found EditControl for Node(" << node->GetId() << L")";
        }
        return touchmind::VISITOR_RESULT_CONTINUE;
    }
Example #5
0
void CPVRSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  if (setting == nullptr)
    return;

  CSingleLock lock(m_critSection);
  m_settings[setting->GetId()] = SettingPtr(setting->Clone(setting->GetId()));
}
Example #6
0
bool CTestManager::AddScale(std::shared_ptr<PsiScale> scale)
{
	if (!scale)
		return false;

	if (_scales.find(scale->GetId()) != _scales.end())
		return false;

	_scales.insert(make_pair(scale->GetId(), scale));

	return true;
}
void touchmind::view::node::NodeViewManager::DrawPath(touchmind::Context *pContext, ID2D1RenderTarget *pRenderTarget,
                                                      std::shared_ptr<model::node::NodeModel> node) {
  if (m_nodeIdToPathView.count(node->GetId()) == 0) {
    auto pathView = touchmind::view::path::PathViewFactory::Create(node);
    m_nodeIdToPathView.insert({node->GetId(), pathView});
    pathView->SetConfiguration(m_pConfiguration);
    pathView->SetNodeViewManager(this);
    pathView->SetNodeModel(node);
  }
  auto pathView = m_nodeIdToPathView[node->GetId()];
  pathView->Draw(pContext, pRenderTarget);
  pathView->SetHandled();
}
Example #8
0
void CAddonSystemSettings::OnSettingAction(std::shared_ptr<const CSetting> setting)
{
  if (setting->GetId() == CSettings::SETTING_ADDONS_MANAGE_DEPENDENCIES)
  {
    std::vector<std::string> params{"addons://dependencies/", "return"};
    CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_ADDON_BROWSER, params);
  }
  else if (setting->GetId() == CSettings::SETTING_ADDONS_SHOW_RUNNING)
  {
    std::vector<std::string> params{"addons://running/", "return"};
    CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_ADDON_BROWSER, params);
  }
}
 touchmind::VISITOR_RESULT operator()(std::shared_ptr<touchmind::model::node::NodeModel> node) {
   if (m_nodeIdToView.count(node->GetId()) != 0) {
     auto &nodeView = m_nodeIdToView[node->GetId()];
     if (nodeView->IsCompatible(node)) {
       nodeView->SetHandled();
     } else {
       auto editControlIndex = nodeView->GetEditControlIndex();
       m_nodeIdToView.erase(node->GetId());
       CreateNewView(node, editControlIndex);
     }
   } else {
     CreateNewView(node);
   }
   return touchmind::VISITOR_RESULT_CONTINUE;
 }
void CGUIDialogSubtitleSettings::OnSettingAction(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
    return;

  CGUIDialogSettingsManualBase::OnSettingAction(setting);

  const std::string &settingId = setting->GetId();
  if (settingId == SETTING_SUBTITLE_BROWSER)
  {
    std::string strPath = BrowseForSubtitle();
    if (!strPath.empty())
    {
      g_application.GetAppPlayer().AddSubtitle(strPath);
      Close();
    }
  }
  else if (settingId == SETTING_SUBTITLE_SEARCH)
  {
    auto dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSubtitles>(WINDOW_DIALOG_SUBTITLES);
    if (dialog)
    {
      dialog->Open();
      m_subtitleStreamSetting->UpdateDynamicOptions();
    }
  }
  else if (settingId == SETTING_MAKE_DEFAULT)
    Save();
}
void CGUIDialogCMSSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
    return;

  CGUIDialogSettingsManualBase::OnSettingChanged(setting);

  const std::string &settingId = setting->GetId();
  if (settingId == SETTING_VIDEO_CMSENABLE)
    CServiceBroker::GetSettings().SetBool(SETTING_VIDEO_CMSENABLE, (std::static_pointer_cast<const CSettingBool>(setting)->GetValue()));
  else if (settingId == SETTING_VIDEO_CMSMODE)
    CServiceBroker::GetSettings().SetInt(SETTING_VIDEO_CMSMODE, static_cast<int>(std::static_pointer_cast<const CSettingInt>(setting)->GetValue()));
  else if (settingId == SETTING_VIDEO_CMS3DLUT)
    CServiceBroker::GetSettings().SetString(SETTING_VIDEO_CMS3DLUT, static_cast<std::string>(std::static_pointer_cast<const CSettingString>(setting)->GetValue()));
  else if (settingId == SETTING_VIDEO_CMSWHITEPOINT)
    CServiceBroker::GetSettings().SetInt(SETTING_VIDEO_CMSWHITEPOINT, static_cast<int>(std::static_pointer_cast<const CSettingInt>(setting)->GetValue()));
  else if (settingId == SETTING_VIDEO_CMSPRIMARIES)
    CServiceBroker::GetSettings().SetInt(SETTING_VIDEO_CMSPRIMARIES, static_cast<int>(std::static_pointer_cast<const CSettingInt>(setting)->GetValue()));
  else if (settingId == SETTING_VIDEO_CMSGAMMAMODE)
    CServiceBroker::GetSettings().SetInt(SETTING_VIDEO_CMSGAMMAMODE, static_cast<int>(std::static_pointer_cast<const CSettingInt>(setting)->GetValue()));
  else if (settingId == SETTING_VIDEO_CMSGAMMA)
    CServiceBroker::GetSettings().SetInt(SETTING_VIDEO_CMSGAMMA, static_cast<float>(std::static_pointer_cast<const CSettingNumber>(setting)->GetValue())*100);
  else if (settingId == SETTING_VIDEO_CMSLUTSIZE)
    CServiceBroker::GetSettings().SetInt(SETTING_VIDEO_CMSLUTSIZE, static_cast<int>(std::static_pointer_cast<const CSettingInt>(setting)->GetValue()));
}
Example #12
0
void CDiscSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
#if (BLURAY_VERSION >= BLURAY_VERSION_CODE(1,0,1))
  if (setting == NULL)
    return;

  const std::string &settingId = setting->GetId();

  if (settingId == CSettings::SETTING_DISC_PLAYBACK)
  {
    int mode = std::static_pointer_cast<const CSettingInt>(setting)->GetValue();
    if (mode == BD_PLAYBACK_DISC_MENU)
    {
      bool bdjWorking = false;
      BLURAY* bd = bd_init();
      const BLURAY_DISC_INFO* info = bd_get_disc_info(bd);

      if (!info->libjvm_detected)
        CLog::Log(LOGDEBUG, "DiscSettings - Could not load the java vm.");
      else if (!info->bdj_handled)
        CLog::Log(LOGDEBUG, "DiscSettings - Could not load the libbluray.jar.");
      else
        bdjWorking = true;

      bd_close(bd);

      if (!bdjWorking)
        HELPERS::ShowOKDialogText(CVariant{ 29803 }, CVariant{ 29804 });
    }
  }
#endif
}
Example #13
0
void CPVRChannelGroup::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
    return;

  //! @todo while pvr manager is starting up do accept setting changes.
  if(!CServiceBroker::GetPVRManager().IsStarted())
  {
    CLog::Log(LOGWARNING, "CPVRChannelGroup setting change ignored while PVRManager is starting\n");
    return;
  }

  const std::string &settingId = setting->GetId();
  if (settingId == CSettings::SETTING_PVRMANAGER_BACKENDCHANNELORDER || settingId == CSettings::SETTING_PVRMANAGER_USEBACKENDCHANNELNUMBERS)
  {
    CSingleLock lock(m_critSection);
    bool bUsingBackendChannelOrder   = CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRMANAGER_BACKENDCHANNELORDER);
    bool bUsingBackendChannelNumbers = CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRMANAGER_USEBACKENDCHANNELNUMBERS);
    bool bChannelNumbersChanged      = m_bUsingBackendChannelNumbers != bUsingBackendChannelNumbers;
    bool bChannelOrderChanged        = m_bUsingBackendChannelOrder != bUsingBackendChannelOrder;

    m_bUsingBackendChannelOrder   = bUsingBackendChannelOrder;
    m_bUsingBackendChannelNumbers = bUsingBackendChannelNumbers;

    /* check whether this channel group has to be renumbered */
    if (bChannelOrderChanged || bChannelNumbersChanged)
    {
      CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - renumbering group '%s' to use the backend channel order and/or numbers",
          __FUNCTION__, m_strGroupName.c_str());
      SortAndRenumber();
      Persist();
    }
  }
}
Example #14
0
void CNetworkServices::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
    return;

  const std::string &settingId = setting->GetId();
#ifdef HAS_WEB_SERVER
  if (settingId == CSettings::SETTING_SERVICES_WEBSERVERUSERNAME ||
      settingId == CSettings::SETTING_SERVICES_WEBSERVERPASSWORD)
  {
    m_webserver.SetCredentials(CServiceBroker::GetSettings().GetString(CSettings::SETTING_SERVICES_WEBSERVERUSERNAME),
                               CServiceBroker::GetSettings().GetString(CSettings::SETTING_SERVICES_WEBSERVERPASSWORD));
  }
  else
#endif // HAS_WEB_SERVER
  if (settingId == CSettings::SETTING_SMB_WINSSERVER ||
      settingId == CSettings::SETTING_SMB_WORKGROUP ||
      settingId == CSettings::SETTING_SMB_MAXPROTOCOL)
  {
    // okey we really don't need to restart, only deinit samba, but that could be damn hard if something is playing
    //! @todo - General way of handling setting changes that require restart
    if (HELPERS::ShowYesNoDialogText(CVariant{14038}, CVariant{14039}) == DialogResponse::YES)
    {
      CServiceBroker::GetSettings().Save();
      CApplicationMessenger::GetInstance().PostMsg(TMSG_RESTARTAPP);
    }
  }
}
void CGUIDialogLibExportSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  if (!setting)
    return;

  CGUIDialogSettingsManualBase::OnSettingChanged(setting);

  const std::string &settingId = setting->GetId();

  if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_FILETYPE)
  {
    m_settings.SetExportType(std::static_pointer_cast<const CSettingInt>(setting)->GetValue());
    SetupView();
    SetFocus(CSettings::SETTING_MUSICLIBRARY_EXPORT_FILETYPE);
  }
  else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER)
  {
    m_settings.m_strPath = std::static_pointer_cast<const CSettingString>(setting)->GetValue();
    UpdateButtons();
  }
  else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE)
    m_settings.m_overwrite = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_ITEMS)
    m_settings.SetItemsToExport(GetExportItemsFromSetting(setting));
  else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_ARTWORK)
  {
    m_settings.m_artwork = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
    ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, m_settings.m_artwork);
  }
  else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_UNSCRAPED)
    m_settings.m_unscraped = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO)
    m_settings.m_skipnfo = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
}
Example #16
0
void CDisplaySettings::OnSettingAction(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
    return;

  const std::string &settingId = setting->GetId();
  if (settingId == "videoscreen.cms3dlut")
  {
    std::string path = std::static_pointer_cast<const CSettingString>(setting)->GetValue();
    VECSOURCES shares;
    g_mediaManager.GetLocalDrives(shares);
    if (CGUIDialogFileBrowser::ShowAndGetFile(shares, ".3dlut", g_localizeStrings.Get(36580), path))
    {
      std::static_pointer_cast<CSettingString>(std::const_pointer_cast<CSetting>(setting))->SetValue(path);
    }
  }
  else if (settingId == "videoscreen.displayprofile")
  {
    std::string path = std::static_pointer_cast<const CSettingString>(setting)->GetValue();
    VECSOURCES shares;
    g_mediaManager.GetLocalDrives(shares);
    if (CGUIDialogFileBrowser::ShowAndGetFile(shares, ".icc|.icm", g_localizeStrings.Get(36581), path))
    {
      std::static_pointer_cast<CSettingString>(std::const_pointer_cast<CSetting>(setting))->SetValue(path);
    }
  }
}
Example #17
0
void CGUIDialogLockSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
    return;

  CGUIDialogSettingsManualBase::OnSettingChanged(setting);

  const std::string &settingId = setting->GetId();
  if (settingId == SETTING_USERNAME)
    m_user = std::static_pointer_cast<const CSettingString>(setting)->GetValue();
  else if (settingId == SETTING_PASSWORD)
    m_locks.code = std::static_pointer_cast<const CSettingString>(setting)->GetValue();
  else if (settingId == SETTING_PASSWORD_REMEMBER)
    *m_saveUserDetails = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == SETTING_LOCK_MUSIC)
    m_locks.music = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == SETTING_LOCK_VIDEOS)
    m_locks.video = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == SETTING_LOCK_PICTURES)
    m_locks.pictures = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == SETTING_LOCK_PROGRAMS)
    m_locks.programs = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == SETTING_LOCK_FILEMANAGER)
    m_locks.files = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();
  else if (settingId == SETTING_LOCK_SETTINGS)
    m_locks.settings = static_cast<LOCK_LEVEL::SETTINGS_LOCK>(std::static_pointer_cast<const CSettingInt>(setting)->GetValue());
  else if (settingId == SETTING_LOCK_ADDONMANAGER)
    m_locks.addonManager = std::static_pointer_cast<const CSettingBool>(setting)->GetValue();

  m_changed = true;
}
Example #18
0
void CDiscSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
#ifdef TARGET_WINDOWS
  if (setting == NULL)
    return;

  const std::string &settingId = setting->GetId();

  if (settingId == CSettings::SETTING_DISC_PLAYBACK)
  {
    int mode = std::static_pointer_cast<const CSettingInt>(setting)->GetValue();
    if (mode == BD_PLAYBACK_DISC_MENU)
    {
      BLURAY* bd = m_dll->bd_init();
      const BLURAY_DISC_INFO* info = m_dll->bd_get_disc_info(bd);
      if (!info->bdj_handled)
      {
        if (!info->libjvm_detected)
        {
          CLog::Log(LOGDEBUG, "DiscSettings - Could not load the java vm.");
          CGUIDialogOK::ShowAndGetInput(CVariant{ 29803 }, CVariant{ 29804 });
        }
        CLog::Log(LOGDEBUG, "DiscSettings - Could not load the libbluray.jar.");
      }
      m_dll->bd_close(bd);
    }
  }
#endif
}
void CGUIDialogPVRTimerSettings::OnSettingAction(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
  {
    CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::OnSettingAction - No setting");
    return;
  }

  CGUIDialogSettingsManualBase::OnSettingAction(setting);

  const std::string &settingId = setting->GetId();
  if (settingId == SETTING_TMR_BEGIN)
  {
    SYSTEMTIME timerStartTime;
    m_startLocalTime.GetAsSystemTime(timerStartTime);
    if (CGUIDialogNumeric::ShowAndGetTime(timerStartTime, g_localizeStrings.Get(14066)))
    {
      SetTimeFromSystemTime(m_startLocalTime, timerStartTime);
      m_timerStartTimeStr = m_startLocalTime.GetAsLocalizedTime("", false);
      SetButtonLabels();
    }
  }
  else if (settingId == SETTING_TMR_END)
  {
    SYSTEMTIME timerEndTime;
    m_endLocalTime.GetAsSystemTime(timerEndTime);
    if (CGUIDialogNumeric::ShowAndGetTime(timerEndTime, g_localizeStrings.Get(14066)))
    {
      SetTimeFromSystemTime(m_endLocalTime, timerEndTime);
      m_timerEndTimeStr = m_endLocalTime.GetAsLocalizedTime("", false);
      SetButtonLabels();
    }
  }
}
Example #20
0
void touchmind::win::CanvasPanel::ExpandLayoutRect(const std::shared_ptr<touchmind::model::node::NodeModel> &node,
        FLOAT dx, FLOAT dy) {
    auto editControlIndex = m_pNodeViewManager->GetEditControlIndexFromNodeId(node->GetId());
    std::shared_ptr<control::DWriteEditControl> editControl = m_pEditControlManager->GetEditControl(editControlIndex);
    editControl->ExpandLayoutRect(dx, dy);
    node->IncrementRepaintRequiredCounter();
    Invalidate();
}
bool CollisionSystem::ReproduceEntities(std::shared_ptr<Entity> entity1,
    std::shared_ptr<Entity> entity2)
{
    auto reproductionComponent1 = std::static_pointer_cast<ReproductionComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(entity1,
            "ReproductionComponent"));

    auto reproductionComponent2 = std::static_pointer_cast<ReproductionComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(entity2,
            "ReproductionComponent"));

    auto particleComponent1 = std::static_pointer_cast<ParticleComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(entity1,
            "ParticleComponent"));
    auto particleComponent2 = std::static_pointer_cast<ParticleComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(entity2,
            "ParticleComponent"));

    auto position1 = particleComponent1->GetPosition();
    auto position2 = particleComponent2->GetPosition();

    if (position1.CalculateDistance(position2) >= CFG_GETF("REPRODUCTION_DISTANCE_MAX"))
        return true;

    auto enabled1 = reproductionComponent1->GetEnabled();
    auto enabled2 = reproductionComponent2->GetEnabled();

    auto reproduced1 = reproductionComponent1->GetReproduced();
    auto reproduced2 = reproductionComponent2->GetReproduced();

    auto type1 = reproductionComponent1->GetType();
    auto type2 = reproductionComponent2->GetType();

    if (enabled1 && enabled2 && !reproduced1 && !reproduced2 && type1 == type2)
    {
        LOG_D("[CollisionSystem] Reproducing entities " << entity1->GetId()
            << " and " << entity2->GetId());
        EntityFactory::CreateCell(particleComponent1->GetPosition() + Vector(50, 50));
        reproductionComponent1->SetReproduced(true);
        reproductionComponent2->SetReproduced(true);
        return true;
    }

    return false;
}
 void CreateNewView(std::shared_ptr<touchmind::model::node::NodeModel> node,
                    touchmind::control::EDIT_CONTROL_INDEX editControlIndex) {
   auto nodeView = touchmind::view::node::NodeViewFactory::Create(node);
   nodeView->SetNodeViewManager(m_nodeViewManager);
   nodeView->SetEditControlManager(m_pEditControlManager);
   nodeView->SetEditControlIndex(editControlIndex);
   nodeView->SetHandled();
   m_nodeIdToView.insert({node->GetId(), nodeView});
 }
Example #23
0
void CGUIPassword::OnSettingAction(std::shared_ptr<const CSetting> setting)
{
  if (setting == NULL)
    return;

  const std::string &settingId = setting->GetId();
  if (settingId == CSettings::SETTING_MASTERLOCK_LOCKCODE)
    SetMasterLockMode();
}
Example #24
0
//******************************************************************************
// VideoCodec
//******************************************************************************
bool CDVDVideoCodec::IsSettingVisible(const std::string &condition, const std::string &value, std::shared_ptr<const CSetting> setting, void *data)
{
  if (setting == NULL || value.empty())
    return false;

  const std::string &settingId = setting->GetId();

  if (settingId == CSettings::SETTING_VIDEOPLAYER_USEVDPAU)
  {
    auto hwaccels = CDVDFactoryCodec::GetHWAccels();
    for (auto &id : hwaccels)
    {
      if (id == "vdpau")
        return true;
    }
    return false;
  }
  else if (settingId == CSettings::SETTING_VIDEOPLAYER_USEVAAPI)
  {
    auto hwaccels = CDVDFactoryCodec::GetHWAccels();
    for (auto &id : hwaccels)
    {
      if (id == "vaapi")
        return true;
    }
    return false;
  }

  // check if we are running on nvidia hardware
  std::string gpuvendor = g_Windowing.GetRenderVendor();
  std::transform(gpuvendor.begin(), gpuvendor.end(), gpuvendor.begin(), ::tolower);
  bool isNvidia = (gpuvendor.compare(0, 6, "nvidia") == 0);
  bool isIntel = (gpuvendor.compare(0, 5, "intel") == 0);

  // nvidia does only need mpeg-4 setting
  if (isNvidia)
  {
    if (settingId == CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4)
      return true;

    return false; // will also hide intel settings on nvidia hardware
  }
  else if (isIntel) // intel needs vc1, mpeg-2 and mpeg4 setting
  {
    if (settingId == CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4)
      return true;
    if (settingId == CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1)
      return true;
    if (settingId == CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG2)
      return true;

    return false; // this will also hide nvidia settings on intel hardware
  }
  // if we don't know the hardware we are running on e.g. amd oss vdpau 
  // or fglrx with xvba-driver we show everything
  return true;
}
Example #25
0
bool CSettingsOperations::SerializeISetting(std::shared_ptr<const ISetting> setting, CVariant &obj)
{
  if (setting == NULL)
    return false;

  obj["id"] = setting->GetId();

  return true;
}
Example #26
0
void CProfilesManager::OnSettingAction(std::shared_ptr<const CSetting> setting)
{
  if (setting == nullptr)
    return;

  const std::string& settingId = setting->GetId();
  if (settingId == CSettings::SETTING_EVENTLOG_SHOW)
    GetEventLog().ShowFullEventLog();
}
Example #27
0
void CInputManager::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  if (setting == nullptr)
    return;

  const std::string &settingId = setting->GetId();
  if (settingId == CSettings::SETTING_INPUT_ENABLEMOUSE)
    m_Mouse.SetEnabled(std::dynamic_pointer_cast<const CSettingBool>(setting)->GetValue());
}
TemplateDescriptor::TemplateDescriptor(std::shared_ptr<rmscore::core::
                                                       ProtectionPolicy>policy)
  : m_id(policy->GetId())
  , m_name(policy->GetName())
  , m_description(policy->GetDescription())
{
  if (policy->IsAdhoc()) {
    throw exceptions::RMSInvalidArgumentException("Invalid policy");
  }
}
Example #29
0
 bool SceneManager::Update(const std::shared_ptr<Entity> & entity)
 {
     auto search = m_nodes.find(entity->GetId());
     if (search != m_nodes.end())
     {
         this->UpdateRenderData(search->second);
         return true;
     }
     return false;
 }
Example #30
0
void CAddonSystemSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting)
{
  using namespace KODI::MESSAGING::HELPERS;

  if (setting->GetId() == CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES
    && CServiceBroker::GetSettings().GetBool(CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES)
    && ShowYesNoDialogText(19098, 36618) != DialogResponse::YES)
  {
    CServiceBroker::GetSettings().SetBool(CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES, false);
  }
}