Example #1
0
void		_HYSequencePane::ProcessContextualPopUp (long l, long t)
{	
	if (messageRecipient)
		messageRecipient->ProcessEvent (generateContextPopUpEvent(GetID(),l,t));
}	
Example #2
0
GameWorld::GameWorld()
: m_fStartFrame(0)
, m_bDoubleTouch(false)
, m_iTouchCnt(0)
{
    //로그 찍을 것인가?
    LogMgr->SetLog(true);
    
    //카메라 레이어 초기화
    m_pCameraLayer = Layer::create();
    addChild(m_pCameraLayer, 0);
    
    //UI 레이어 초기화
    m_pUILayer = Layer::create();
    addChild(m_pUILayer, 1);
    
    //맵 생성
    m_pMap = new GameMap();
    m_pMap->LoadMap(TILE_WIDTH_NUM,TILE_HEIGHT_NUM);
    m_pCameraLayer->addChild(m_pMap);
    
    //저글링 생성
    for(int i=0;i<12;i++){
        auto pZergling = new Zergling(this,0,(DIVIDE_NODE ? 20615+i : 5110+i));
        pZergling->setColor(Color3B(255,0,0));
        pZergling->setCascadeColorEnabled(true);
        m_pCameraLayer->addChild(pZergling);
        m_Units[pZergling->GetID()] = pZergling;
    }
    
    for(int i=0;i<20;i++){
        auto pZergling = new Zergling(this,1,(DIVIDE_NODE ? 20817 + i: 5213 + i));
        m_pCameraLayer->addChild(pZergling);
        m_Units[pZergling->GetID()] = pZergling;
    }
    
    //선택 DrawNode 생성
    m_pSelectDrawNode = DrawNode::create();
    m_pSelectDrawNode->setVisible(false);
    m_pCameraLayer->addChild(m_pSelectDrawNode);
    
    
    //카메라 설정 : 맵 크기 (64*256, 64*256)
    CameraMgr->SetScreen(6400, 3200 - 32);
    
    //네트워크 매니저 초기화
    NetMgr->SetGameWorld(this);
    NetMgr->SetupWhatPlayerFlag();
    
    LogMgr->Log("This is %d Computer",NetMgr->GetPlayerFlag());

    //디버그용
    m_pDebugLabel = Label::createWithTTF("","fonts/arial.ttf",24);
    m_pDebugLabel->setAnchorPoint(Vec2(0,0));
    m_pDebugLabel->setPosition(0,120);
    addChild(m_pDebugLabel);

    
    //Scene setting
    GameClient::GetInstance().currentScene = GAME_SCENE_NOW;

    
    //타일 스캔
    {
        auto pDrawNode = DrawNode::create();
//        for(int i=0;i<=720;i++){
//            for(int j=0;j<1280;j++){
//                if(m_pMap->GetTileIndexFromPosition(Vec2(j,i)) == 17){
//                    pDrawNode->drawDot(Vec2(j,i), 1, Color4F(1,1,1,1));
//                }
//            }
//        }
        pDrawNode->setTag(5);
        addChild(pDrawNode);
    }
    
    //초기화
    Init();
    
    for(int i=0;i<12;i++){
        m_TouchedUnits.push_back(m_Units[i]);
    }
    
}
Example #3
0
void CGUIWindowFullScreen::FrameMove()
{
    if (g_application.GetPlaySpeed() != 1)
        g_infoManager.SetDisplayAfterSeek();
    if (m_bShowCurrentTime)
        g_infoManager.SetDisplayAfterSeek();

    if (!g_application.m_pPlayer) return;

    if( g_application.m_pPlayer->IsCaching() )
    {
        g_infoManager.SetDisplayAfterSeek(0); //Make sure these stuff aren't visible now
    }

    //------------------------
    m_showCodec.Update();
    if (m_showCodec)
    {
        // show audio codec info
        CStdString strAudio, strVideo, strGeneral;
        g_application.m_pPlayer->GetAudioInfo(strAudio);
        {
            CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1);
            msg.SetLabel(strAudio);
            OnMessage(msg);
        }
        // show video codec info
        g_application.m_pPlayer->GetVideoInfo(strVideo);
        {
            CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2);
            msg.SetLabel(strVideo);
            OnMessage(msg);
        }
        // show general info
        g_application.m_pPlayer->GetGeneralInfo(strGeneral);
        {
            CStdString strGeneralFPS;
#ifdef __APPLE__
            // We show CPU usage for the entire process, as it's arguably more useful.
            double dCPU = m_resourceCounter.GetCPUUsage();
            CStdString strCores;
            strCores.Format("cpu:%.0f%%", dCPU);
#else
            CStdString strCores = g_cpuInfo.GetCoresUsageString();
#endif
            int    missedvblanks;
            int    refreshrate;
            double clockspeed;
            CStdString strClock;

            if (g_VideoReferenceClock.GetClockInfo(missedvblanks, clockspeed, refreshrate))
                strClock.Format("S( refresh:%i missed:%i speed:%+.3f%% %s )"
                                , refreshrate
                                , missedvblanks
                                , clockspeed - 100.0
                                , g_renderManager.GetVSyncState().c_str());

            strGeneralFPS.Format("%s\nW( fps:%02.2f %s ) %s"
                                 , strGeneral.c_str()
                                 , g_infoManager.GetFPS()
                                 , strCores.c_str(), strClock.c_str() );

            CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3);
            msg.SetLabel(strGeneralFPS);
            OnMessage(msg);
        }
    }
    //----------------------
    // ViewMode Information
    //----------------------
    if (m_bShowViewModeInfo && XbmcThreads::SystemClockMillis() - m_dwShowViewModeTimeout > 2500)
    {
        m_bShowViewModeInfo = false;
    }
    if (m_bShowViewModeInfo)
    {
        {
            // get the "View Mode" string
            CStdString strTitle = g_localizeStrings.Get(629);
            CStdString strMode = g_localizeStrings.Get(630 + g_settings.m_currentVideoSettings.m_ViewMode);
            CStdString strInfo;
            strInfo.Format("%s : %s", strTitle.c_str(), strMode.c_str());
            CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1);
            msg.SetLabel(strInfo);
            OnMessage(msg);
        }
        // show sizing information
        CRect SrcRect, DestRect;
        float fAR;
        g_application.m_pPlayer->GetVideoRect(SrcRect, DestRect);
        g_application.m_pPlayer->GetVideoAspectRatio(fAR);
        {
            CStdString strSizing;
            strSizing.Format(g_localizeStrings.Get(245),
                             (int)SrcRect.Width(), (int)SrcRect.Height(),
                             (int)DestRect.Width(), (int)DestRect.Height(),
                             g_settings.m_fZoomAmount, fAR*g_settings.m_fPixelRatio,
                             g_settings.m_fPixelRatio, g_settings.m_fVerticalShift);
            CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2);
            msg.SetLabel(strSizing);
            OnMessage(msg);
        }
        // show resolution information
        int iResolution = g_graphicsContext.GetVideoResolution();
        {
            CStdString strStatus;
            if (g_Windowing.IsFullScreen())
                strStatus.Format("%s %ix%i@%.2fHz - %s",
                                 g_localizeStrings.Get(13287), g_settings.m_ResInfo[iResolution].iWidth,
                                 g_settings.m_ResInfo[iResolution].iHeight, g_settings.m_ResInfo[iResolution].fRefreshRate,
                                 g_localizeStrings.Get(244));
            else
                strStatus.Format("%s %ix%i - %s",
                                 g_localizeStrings.Get(13287), g_settings.m_ResInfo[iResolution].iWidth,
                                 g_settings.m_ResInfo[iResolution].iHeight, g_localizeStrings.Get(242));

            CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW3);
            msg.SetLabel(strStatus);
            OnMessage(msg);
        }
    }

    if (m_timeCodeShow && m_timeCodePosition != 0)
    {
        if ( (XbmcThreads::SystemClockMillis() - m_timeCodeTimeout) >= 2500)
        {
            m_timeCodeShow = false;
            m_timeCodePosition = 0;
        }
        CStdString strDispTime = "00:00:00";

        CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1);

        for (int pos = 7, i = m_timeCodePosition; pos >= 0 && i > 0; pos--)
        {
            if (strDispTime[pos] != ':')
            {
                i -= 1;
                strDispTime[pos] = (char)m_timeCodeStamp[i] + '0';
            }
        }

        strDispTime += "/" + g_infoManager.GetDuration(TIME_FORMAT_HH_MM_SS) + " [" + g_infoManager.GetCurrentPlayTime(TIME_FORMAT_HH_MM_SS) + "]"; // duration [ time ]
        msg.SetLabel(strDispTime);
        OnMessage(msg);
    }

    if (m_showCodec || m_bShowViewModeInfo)
    {
        SET_CONTROL_VISIBLE(LABEL_ROW1);
        SET_CONTROL_VISIBLE(LABEL_ROW2);
        SET_CONTROL_VISIBLE(LABEL_ROW3);
        SET_CONTROL_VISIBLE(BLUE_BAR);
    }
    else if (m_timeCodeShow)
    {
        SET_CONTROL_VISIBLE(LABEL_ROW1);
        SET_CONTROL_HIDDEN(LABEL_ROW2);
        SET_CONTROL_HIDDEN(LABEL_ROW3);
        SET_CONTROL_VISIBLE(BLUE_BAR);
    }
    else
    {
        SET_CONTROL_HIDDEN(LABEL_ROW1);
        SET_CONTROL_HIDDEN(LABEL_ROW2);
        SET_CONTROL_HIDDEN(LABEL_ROW3);
        SET_CONTROL_HIDDEN(BLUE_BAR);
    }
}
Example #4
0
wxObject *wxAuiToolBarXmlHandler::DoCreateResource()
{
    wxAuiToolBar* toolbar=NULL;

    if (m_class == _T("tool"))
    {
        wxCHECK_MSG(m_toolbar, NULL, _("Incorrect syntax of XRC resource: tool not within a toolbar!"));

        wxSize bitmapSize = m_toolbar->GetToolBitmapSize();

        if (GetPosition() != wxDefaultPosition)
        {
            m_toolbar->AddTool(GetID(),
                               GetCenteredBitmap(_T("bitmap"), wxART_OTHER, wxSize(16,16)),
                               NULL, //GetCenteredBitmap(_T("bitmap2"), wxART_TOOLBAR, bitmapSize),
                               GetBool(_T("toggle")),
                               NULL,
                               GetText(_T("tooltip")),
                               GetText(_T("longhelp")));

           if (GetBool(_T("disabled")))
           {
               m_toolbar->Realize();
               m_toolbar->EnableTool(GetID(),false);
           }
        }
        else
        {
            wxItemKind kind = wxITEM_NORMAL;
            if (GetBool(_T("radio")))
                kind = wxITEM_RADIO;
            if (GetBool(_T("toggle")))
            {
                wxASSERT_MSG( kind == wxITEM_NORMAL,
                              _("can't have both toggleable and radion button at once") );
                kind = wxITEM_CHECK;
            }

            m_toolbar->AddTool(GetID(),
                               GetText(_T("label")),
                               GetCenteredBitmap(_T("bitmap"), wxART_OTHER, bitmapSize),
                               GetCenteredBitmap(_T("bitmap2"), wxART_OTHER, bitmapSize),
                               kind,
                               GetText(_T("tooltip")),
                               GetText(_T("longhelp")));

           if (GetBool(_T("disabled")))
           {
               m_toolbar->Realize();
               m_toolbar->EnableTool(GetID(),false);
           }
        }
        return m_toolbar; // must return non-NULL
    }

    else if (m_class == _T("overflow_tool"))
    {
        wxCHECK_MSG(m_toolbar, NULL, _("Incorrect syntax of XRC resource: tool not within a toolbar!"));

        wxSize bitmapSize = m_toolbar->GetToolBitmapSize();

        wxItemKind kind = wxITEM_NORMAL;
        if (GetBool(_T("radio")))
                kind = wxITEM_RADIO;
        if (GetBool(_T("toggle")))
        {
                wxASSERT_MSG( kind == wxITEM_NORMAL,
                              _("can't have both toggleable and radion button at once") );
                kind = wxITEM_CHECK;
        }
        if (GetBool(_T("separator")))
            kind = wxITEM_SEPARATOR;

        m_toolbar->AddOverflowTool(GetID(),
                               GetText(_T("label")),
                               GetCenteredBitmap(_T("bitmap"), wxART_OTHER, bitmapSize),
                               GetText(_T("longhelp")),
                               kind,
                               GetBool(_T("prepend"),0)   );

        if (GetBool(_T("disabled")))
        {
               m_toolbar->Realize();
               m_toolbar->EnableTool(GetID(),false);
        }

        return m_toolbar; // must return non-NULL
    }

    else if (m_class == _T("separator"))
    {
        wxCHECK_MSG(m_toolbar, NULL, _("Incorrect syntax of XRC resource: separator not within a toolbar!"));
        m_toolbar->AddSeparator();
        return m_toolbar; // must return non-NULL
    }

    else /*<object class="wxAuiToolBar">*/
    {
        toolbar=(wxAuiToolBar*)m_instance;
        if(!toolbar && (m_class == _T("wxToolBarAddOn")))
        {
           toolbar = new wxAuiToolBar(m_parentAsWindow, -1, wxDefaultPosition, wxDefaultSize);
           m_instance = (wxObject *)toolbar;
        }

            long style = GetStyle(_T("style"), -1);
            if (style!=-1)
                toolbar->SetWindowStyle(style);

            style = GetStyle(_T("add_style"), -1);
            if (style!=-1)
                toolbar->SetWindowStyle(toolbar->GetWindowStyle() | style);

            style = GetStyle(_T("remove_style"), -1);
            if (style!=-1)
                toolbar->SetWindowStyle(toolbar->GetWindowStyle() & ~style);

            wxSize bmpsize = GetSize(_T("bitmapsize"));
            // First find the generic bitmap size
            if (!(bmpsize == wxDefaultSize))
                toolbar->SetToolBitmapSize(bmpsize);
            else
            {
                // if no generic size then find the platform dependent size
                #ifdef __WXMSW__
                    bmpsize = GetSize(_T("bitmapsize_win"));
                #endif
                #ifdef __WXMAC__
                    bmpsize = GetSize(_T("bitmapsize_mac"));
                #endif
                #ifdef __WXGTK__
                    bmpsize = GetSize(_T("bitmapsize_unix"));
                #endif

                if (!(bmpsize == wxDefaultSize))
                    toolbar->SetToolBitmapSize(bmpsize);
            }

            wxSize margins = GetSize(_T("margins"));
            if (!(margins == wxDefaultSize))
                toolbar->SetMargins(margins.x, margins.y);
            long packing = GetLong(_T("packing"), -1);
            if (packing != -1)
                toolbar->SetToolPacking(packing);
            long separation = GetLong(_T("separation"), -1);
            if (separation != -1)
                toolbar->SetToolSeparation(separation);

        wxXmlNode *children_node = GetParamNode(_T("object"));
        if (!children_node)
           children_node = GetParamNode(_T("object_ref"));

        if (children_node == NULL) return toolbar;

        m_isInside = TRUE;
        m_toolbar = toolbar;

        wxXmlNode *n = children_node;

        while (n)
        {
            if ((n->GetType() == wxXML_ELEMENT_NODE) &&
                (n->GetName() == _T("object") || n->GetName() == _T("object_ref")))
            {
                wxObject *created = CreateResFromNode(n, toolbar, NULL);
                wxControl *control = wxDynamicCast(created, wxControl);
                if (!IsOfClass(n, _T("tool")) &&
                    !IsOfClass(n, _T("separator")) &&
                    control != NULL &&
                    control != toolbar)
                {
                    //Manager::Get()->GetLogManager()->DebugLog(F(_T("control=%p, parent=%p, toolbar=%p"), control, control->GetParent(), toolbar));
                    toolbar->AddControl(control);
                }
            }
            n = n->GetNext();
        }
        toolbar->Realize();
        m_isInside = FALSE;
        m_toolbar = NULL;
        m_isAddon=false;
        return toolbar;
    }
}
bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
	int32 base = 0;
	int32 size = 4;
	uchar* buffer;
	ServerPacket* pack = 0;
	while ((recvbuf_used - base) >= size)
	{
		buffer = &recvbuf[base];
		memcpy(&size, &buffer[2], 2);
		if (size >= MaxTCPReceiveBuffferSize)
		{
#if TCPN_DEBUG_Memory >= 1
			std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
#endif
			if (errbuf)
			{
				snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
			}
			return false;
		}
		if ((recvbuf_used - base) >= size)
		{
			// ok, we got enough data to make this packet!
			pack = new ServerPacket;
			memcpy(&pack->opcode, &buffer[0], 2);
			pack->size = size - 4;
			// TODO: Checksum or size check or something similar
			/* if ()
			{
				// Data stream corruption, get the hell outta here!
				delete pack;
				return false;
			}*/
			if (pack->size > 0)
			{
				pack->pBuffer = new uchar[pack->size];
				memcpy(pack->pBuffer, &buffer[4], pack->size);
			}
			if (pack->opcode == 0)
			{
				// keepalive, no need to process
				safe_delete(pack);
			}
			else
			{
#if TCPN_LOG_PACKETS >= 1
				if (pack && pack->opcode != 0)
				{
					struct in_addr	in;
					in.s_addr = GetrIP();
					CoutTimestamp(true);
					std::cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
					if (pack->size >= 32)
					{
						DumpPacket(pack->pBuffer, 32);
					}
					else
					{
						DumpPacket(pack);
					}
#endif
#if TCPN_LOG_PACKETS >= 3
					DumpPacket(pack);
#endif
				}
#endif
				OutQueuePush(pack);
			}
			base += size;
			size = 4;
		}
	}
	if (base != 0)
	{
		if (base >= recvbuf_used)
		{
			safe_delete_array(recvbuf);
		}
		else
		{
			uchar* tmpbuf = new uchar[recvbuf_size - base];
			memcpy(tmpbuf, &recvbuf[base], recvbuf_used - base);
			safe_delete_array(recvbuf);
			recvbuf = tmpbuf;
			recvbuf_used -= base;
			recvbuf_size -= base;
		}
	}
	return true;
}
Example #6
0
void ZModule::Active(bool bActive)	// (비)활성화 시킨다
{
	m_pContainer->ActiveModule(GetID(),bActive);
}
Example #7
0
void CGUIDialogMediaFilter::OnSettingChanged(const CSetting *setting)
{
  CGUIDialogSettingsManualBase::OnSettingChanged(setting);

  std::map<std::string, Filter>::iterator it = m_filters.find(setting->GetId());
  if (it == m_filters.end())
    return;
  
  bool remove = false;
  Filter& filter = it->second;
 
  if (filter.controlType == "edit")
  {
    std::string value = setting->ToString();
    if (!value.empty())
    {
      if (filter.rule == NULL)
        filter.rule = AddRule(filter.field, filter.ruleOperator);
      filter.rule->m_parameter.clear();
      filter.rule->m_parameter.push_back(value);
    }
    else
      remove = true;
  }
  else if (filter.controlType == "toggle")
  {
    int choice = static_cast<const CSettingInt*>(setting)->GetValue();
    if (choice > CHECK_ALL)
    {
      CDatabaseQueryRule::SEARCH_OPERATOR ruleOperator = choice == CHECK_YES ? CDatabaseQueryRule::OPERATOR_TRUE : CDatabaseQueryRule::OPERATOR_FALSE;
      if (filter.rule == NULL)
        filter.rule = AddRule(filter.field, ruleOperator);
      else
        filter.rule->m_operator = ruleOperator;
    }
    else
      remove = true;
  }
  else if (filter.controlType == "list")
  {
    std::vector<CVariant> values = CSettingUtils::GetList(static_cast<const CSettingList*>(setting));
    if (!values.empty())
    {
      if (filter.rule == NULL)
        filter.rule = AddRule(filter.field, filter.ruleOperator);

      filter.rule->m_parameter.clear();
      for (std::vector<CVariant>::const_iterator itValue = values.begin(); itValue != values.end(); ++itValue)
        filter.rule->m_parameter.push_back(itValue->asString());
    }
    else
      remove = true;
  }
  else if (filter.controlType == "range")
  {
    const CSettingList *settingList = static_cast<const CSettingList*>(setting);
    std::vector<CVariant> values = CSettingUtils::GetList(settingList);
    if (values.size() != 2)
      return;

    std::string strValueLower, strValueUpper;

    const CSetting *definition = settingList->GetDefinition();
    if (definition->GetType() == SettingTypeInteger)
    {
      const CSettingInt *definitionInt = static_cast<const CSettingInt*>(definition);
      int valueLower = static_cast<int>(values.at(0).asInteger());
      int valueUpper = static_cast<int>(values.at(1).asInteger());

      if (valueLower > definitionInt->GetMinimum() ||
          valueUpper < definitionInt->GetMaximum())
      {
        if (filter.controlFormat == "date")
        {
          strValueLower = CDateTime(static_cast<time_t>(valueLower)).GetAsDBDate();
          strValueUpper = CDateTime(static_cast<time_t>(valueUpper)).GetAsDBDate();
        }
        else
        {
          strValueLower = values.at(0).asString();
          strValueUpper = values.at(1).asString();
        }
      }
    }
    else if (definition->GetType() == SettingTypeNumber)
    {
      const CSettingNumber *definitionNumber = static_cast<const CSettingNumber*>(definition);
      float valueLower = values.at(0).asFloat();
      float valueUpper = values.at(1).asFloat();

      if (valueLower > definitionNumber->GetMinimum() ||
          valueUpper < definitionNumber->GetMaximum())
      {
        strValueLower = values.at(0).asString();
        strValueUpper = values.at(1).asString();
      }
    }
    else
      return;

    if (!strValueLower.empty() && !strValueUpper.empty())
    {
      // prepare the filter rule
      if (filter.rule == NULL)
        filter.rule = AddRule(filter.field, filter.ruleOperator);
      filter.rule->m_parameter.clear();

      filter.rule->m_parameter.push_back(strValueLower);
      filter.rule->m_parameter.push_back(strValueUpper);
    }
    else
      remove = true;
  }
  else
    return;

  // we need to remove the existing rule for the title
  if (remove && filter.rule != NULL)
  {
    DeleteRule(filter.field);
    filter.rule = NULL;
  }

  CGUIMessage msg(GUI_MSG_REFRESH_LIST, GetID(), 0);
  g_windowManager.SendThreadMessage(msg, WINDOW_DIALOG_MEDIA_FILTER);
}
int CGUIDialogSmartPlaylistEditor::GetSelectedItem()
{
  CGUIMessage message(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_RULE_LIST);
  OnMessage(message);
  return message.GetParam1();
}
Example #9
0
void
HdSurfaceShader::Sync()
{
    HD_TRACE_FUNCTION();
    HD_MALLOC_TAG_FUNCTION();
 
    // _delegate might be null in certain conditions including when
    // Hydra is using a fallback surface shader
    if (not _delegate) {
        return;  
    }

    SdfPath const& id = GetID();
    HdSceneDelegate* delegate = GetDelegate();
    HdResourceRegistry *resourceRegistry = &HdResourceRegistry::GetInstance();
    HdChangeTracker& changeTracker = 
                                delegate->GetRenderIndex().GetChangeTracker();
    HdChangeTracker::DirtyBits bits = changeTracker.GetShaderDirtyBits(id);

    if(bits & HdChangeTracker::DirtySurfaceShader) {
        _fragmentSource = delegate->GetSurfaceShaderSource(id);
        _geometrySource = delegate->GetDisplacementShaderSource(id);

        // XXX Forcing collections to be dirty to reload everything
        //     Something more efficient can be done here
        changeTracker.MarkAllCollectionsDirty();
    }

    if(bits & HdChangeTracker::DirtyParams) {
        HdBufferSourceVector sources;
        TextureDescriptorVector textures;
        _params = delegate->GetSurfaceShaderParams(id);
        TF_FOR_ALL(paramIt, _params) {
            if (paramIt->IsPrimvar()) {
                // skip -- maybe not necessary, but more memory efficient
                continue;
            } else if (paramIt->IsFallback()) {
                HdBufferSourceSharedPtr source(new HdVtBufferSource(
                                                   paramIt->GetName(),
                   delegate->GetSurfaceShaderParamValue(id, paramIt->GetName())));
                sources.push_back(source);
            } else if (paramIt->IsTexture()) {
                bool bindless = HdRenderContextCaps::GetInstance()
                                                        .bindlessTextureEnabled;
                // register bindless handle

                HdTextureResource::ID texID =
                    delegate->GetTextureResourceID(paramIt->GetConnection());

                HdTextureResourceSharedPtr texResource;
                {
                    HdInstance<HdTextureResource::ID, HdTextureResourceSharedPtr> texInstance;

                    std::unique_lock<std::mutex> regLock =
                        resourceRegistry->RegisterTextureResource(texID, &texInstance);

                    if (not TF_VERIFY(not texInstance.IsFirstInstance(), "%s",
                                      paramIt->GetConnection().GetText())) {
                        continue;
                    }

                    texResource = texInstance.GetValue();
                    if (not TF_VERIFY(texResource)) {
                        continue;
                    }
                }

                TextureDescriptor tex;
                tex.name = paramIt->GetName();

                if (texResource->IsPtex()) {
                    tex.type = TextureDescriptor::TEXTURE_PTEX_TEXEL;
                    tex.handle = bindless ? texResource->GetTexelsTextureHandle()
                                          : texResource->GetTexelsTextureId();
                    textures.push_back(tex);

                    if (bindless) {
                        HdBufferSourceSharedPtr source(new Hd_BindlessSamplerBufferSource(
                                                           tex.name,
                                                           GL_SAMPLER_2D_ARRAY,
                                                           tex.handle));
                        sources.push_back(source);
                    }

                    // layout

                    tex.name = TfToken(std::string(paramIt->GetName().GetText()) + "_layout");
                    tex.type = TextureDescriptor::TEXTURE_PTEX_LAYOUT;
                    tex.handle = bindless ? texResource->GetLayoutTextureHandle()
                                          : texResource->GetLayoutTextureId();
                    textures.push_back(tex);

                    if (bindless) {
                        HdBufferSourceSharedPtr source(new Hd_BindlessSamplerBufferSource(
                                                           tex.name,
                                                           GL_INT_SAMPLER_BUFFER,
                                                           tex.handle));
                        sources.push_back(source);
                    }

                } else {
                    tex.type = TextureDescriptor::TEXTURE_2D;
                    tex.handle = bindless ? texResource->GetTexelsTextureHandle()
                                          : texResource->GetTexelsTextureId();
                    tex.sampler =  texResource->GetTexelsSamplerId();
                    textures.push_back(tex);

                    if (bindless) {
                        HdBufferSourceSharedPtr source(new Hd_BindlessSamplerBufferSource(
                                                           tex.name,
                                                           GL_SAMPLER_2D,
                                                           tex.handle));
                        sources.push_back(source);
                    }
                }
            }
        }

        _textureDescriptors = textures;

        // return before allocation if it's empty.                                   
        if (sources.empty())                                                         
            return;

        // Allocate a new uniform buffer if not exists.
        if (not _paramArray) {
            // establish a buffer range
            HdBufferSpecVector bufferSpecs;
            TF_FOR_ALL(srcIt, sources) {
                (*srcIt)->AddBufferSpecs(&bufferSpecs);
            }
Example #10
0
wxObject * MaxSplitterWindowXmlHandler::DoCreateResource()
{
    XRC_MAKE_INSTANCE(splitter, MaxSplitterWindow);

    splitter->Create(m_parentAsWindow,
                     GetID(),
                     GetPosition(), GetSize(),
                     GetStyle(wxT("style"), wxSP_3D),
                     GetName());

    splitter->MaxBind(_wx_wxsplitterwindow_wxSplitterWindow__xrcNew(splitter));

    SetupWindow(splitter);

    long sashpos = GetLong(wxT("sashpos"), 0);
    long minpanesize = GetLong(wxT("minsize"), -1);
    float gravity = GetFloat(wxT("gravity"), 0.0);
    if (minpanesize != -1)
        splitter->SetMinimumPaneSize(minpanesize);
    if (gravity != 0.0)
        splitter->SetSashGravity(gravity);

    wxWindow *win1 = NULL, *win2 = NULL;
    wxXmlNode *n = m_node->GetChildren();
    while (n)
    {
        if ((n->GetType() == wxXML_ELEMENT_NODE) &&
                (n->GetName() == wxT("object") ||
                 n->GetName() == wxT("object_ref")))
        {
            wxObject *created = CreateResFromNode(n, splitter, NULL);
            wxWindow *win = wxDynamicCast(created, wxWindow);
            if (win1 == NULL)
            {
                win1 = win;
            }
            else
            {
                win2 = win;
                break;
            }
        }
        n = n->GetNext();
    }

    if (win1 == NULL)
        wxLogError(wxT("wxSplitterWindow node must contain at least one window."));

    bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical"));
    if (win1 && win2)
    {
        if (horizontal)
            splitter->SplitHorizontally(win1, win2, sashpos);
        else
            splitter->SplitVertically(win1, win2, sashpos);
    }
    else
    {
        splitter->Initialize(win1);
    }

    return splitter;

}
void CGUIDialogSmartPlaylistEditor::UpdateButtons()
{
  CONTROL_ENABLE(CONTROL_OK); // always enabled since we can have no rules -> match everything (as we do with default partymode playlists)
  
  // if there's no rule available, add a dummy one the user can edit
  if (m_playlist.m_ruleCombination.m_rules.size() <= 0)
    m_playlist.m_ruleCombination.AddRule(CSmartPlaylistRule());

  // name
  if (m_mode == "partyvideo" || m_mode == "partymusic")
  {
    SET_CONTROL_LABEL2(CONTROL_NAME, g_localizeStrings.Get(16035));
    CONTROL_DISABLE(CONTROL_NAME);
  }
  else
    SET_CONTROL_LABEL2(CONTROL_NAME, m_playlist.m_playlistName);
  
  UpdateRuleControlButtons();

  CONTROL_ENABLE_ON_CONDITION(CONTROL_MATCH, m_playlist.m_ruleCombination.m_rules.size() > 1);

  int currentItem = GetSelectedItem();
  CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RULE_LIST);
  OnMessage(msgReset);
  m_ruleLabels->Clear();
  for (unsigned int i = 0; i < m_playlist.m_ruleCombination.m_rules.size(); i++)
  {
    CFileItemPtr item(new CFileItem("", false));
    if (m_playlist.m_ruleCombination.m_rules[i]->m_field == FieldNone)
      item->SetLabel(g_localizeStrings.Get(21423));
    else
      item->SetLabel(std::static_pointer_cast<CSmartPlaylistRule>(m_playlist.m_ruleCombination.m_rules[i])->GetLocalizedRule());
    m_ruleLabels->Add(item);
  }
  CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_RULE_LIST, 0, 0, m_ruleLabels);
  OnMessage(msg);
  SendMessage(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_RULE_LIST, currentItem);

  if (m_playlist.m_orderDirection != SortOrderDescending)
  {
    CONTROL_SELECT(CONTROL_ORDER_DIRECTION);
  }
  else
  {
    CONTROL_DESELECT(CONTROL_ORDER_DIRECTION);
  }

  // sort out the order fields
  std::vector< std::pair<std::string, int> > labels;
  std::vector<SortBy> orders = CSmartPlaylistRule::GetOrders(m_playlist.GetType());
  for (unsigned int i = 0; i < orders.size(); i++)
    labels.push_back(make_pair(g_localizeStrings.Get(SortUtils::GetSortLabel(orders[i])), orders[i]));
  SET_CONTROL_LABELS(CONTROL_ORDER_FIELD, m_playlist.m_orderField, &labels);

  // setup groups
  labels.clear();
  std::vector<Field> groups = CSmartPlaylistRule::GetGroups(m_playlist.GetType());
  Field currentGroup = CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str());
  for (unsigned int i = 0; i < groups.size(); i++)
    labels.push_back(make_pair(CSmartPlaylistRule::GetLocalizedGroup(groups[i]), groups[i]));
  SET_CONTROL_LABELS(CONTROL_GROUP_BY, currentGroup, &labels);

  if (m_playlist.IsGroupMixed())
    CONTROL_SELECT(CONTROL_GROUP_MIXED);
  else
    CONTROL_DESELECT(CONTROL_GROUP_MIXED);

  // disable the group controls if there's no group
  // or only one group which can't be mixed
  if (groups.size() == 0 ||
     (groups.size() == 1 && !CSmartPlaylistRule::CanGroupMix(groups[0])))
  {
    CONTROL_DISABLE(CONTROL_GROUP_BY);
    CONTROL_DISABLE(CONTROL_GROUP_MIXED);
  }
  else
  {
    CONTROL_ENABLE(CONTROL_GROUP_BY);
    CONTROL_ENABLE_ON_CONDITION(CONTROL_GROUP_MIXED, CSmartPlaylistRule::CanGroupMix(currentGroup));
  }
}
wxObject *wxStatusBarXmlHandler::DoCreateResource()
{
    XRC_MAKE_INSTANCE(statbar, wxStatusBar)

    statbar->Create(m_parentAsWindow,
                    GetID(),
                    GetStyle(),
                    GetName());

    int fields = GetLong(wxT("fields"), 1);
    wxString widths = GetParamValue(wxT("widths"));
    wxString styles = GetParamValue(wxT("styles"));

    if (fields > 1 && !widths.IsEmpty())
    {
        int *width = new int[fields];

        for (int i = 0; i < fields; ++i)
        {
            width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
            if(widths.Find(wxT(',')))
                widths.Remove(0, widths.Find(wxT(',')) + 1);
        }
        statbar->SetFieldsCount(fields, width);
        delete[] width;
    }
    else
        statbar->SetFieldsCount(fields);

    if (!styles.empty())
    {
        int *style = new int[fields];
        for (int i = 0; i < fields; ++i)
        {
            style[i] = wxSB_NORMAL;

            wxString first = styles.BeforeFirst(wxT(','));
            if (first == wxT("wxSB_NORMAL"))
                style[i] = wxSB_NORMAL;
            else if (first == wxT("wxSB_FLAT"))
                style[i] = wxSB_FLAT;
            else if (first == wxT("wxSB_RAISED"))
                style[i] = wxSB_RAISED;
            else if (!first.empty())
            {
                ReportParamError
                (
                    "styles",
                    wxString::Format
                    (
                        "unknown status bar field style \"%s\"",
                        first
                    )
                );
            }

            if(styles.Find(wxT(',')))
                styles.Remove(0, styles.Find(wxT(',')) + 1);
        }
        statbar->SetStatusStyles(fields, style);
        delete [] style;
    }

    CreateChildren(statbar);

    if (m_parentAsWindow)
    {
        wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
        if (parentFrame)
            parentFrame->SetStatusBar(statbar);
    }

    return statbar;
}
Example #13
0
wxObject *wxChoicebookXmlHandler::DoCreateResource()
{
    if (m_class == wxT("choicebookpage"))
    {
        wxXmlNode *n = GetParamNode(wxT("object"));

        if ( !n )
            n = GetParamNode(wxT("object_ref"));

        if (n)
        {
            bool old_ins = m_isInside;
            m_isInside = false;
            wxObject *item = CreateResFromNode(n, m_choicebook, NULL);
            m_isInside = old_ins;
            wxWindow *wnd = wxDynamicCast(item, wxWindow);

            if (wnd)
            {
                m_choicebook->AddPage(wnd, GetText(wxT("label")),
                                           GetBool(wxT("selected")));
                if ( HasParam(wxT("bitmap")) )
                {
                    wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
                    wxImageList *imgList = m_choicebook->GetImageList();
                    if ( imgList == NULL )
                    {
                        imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
                        m_choicebook->AssignImageList( imgList );
                    }
                    int imgIndex = imgList->Add(bmp);
                    m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, imgIndex );
                }
                else if ( HasParam(wxT("image")) )
                {
                    if ( m_choicebook->GetImageList() )
                    {
                        m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1,
                                                   GetLong(wxT("image")) );
                    }
                    else // image without image list?
                    {
                        ReportError(n, "image can only be used in conjunction "
                                       "with imagelist");
                    }
                }
            }
            else
            {
                ReportError(n, "choicebookpage child must be a window");
            }
            return wnd;
        }
        else
        {
            ReportError("choicebookpage must have a window child");
            return NULL;
        }
    }

    else
    {
        XRC_MAKE_INSTANCE(nb, wxChoicebook)

        nb->Create(m_parentAsWindow,
                   GetID(),
                   GetPosition(), GetSize(),
                   GetStyle(wxT("style")),
                   GetName());

        wxImageList *imagelist = GetImageList();
        if ( imagelist )
            nb->AssignImageList(imagelist);

        wxChoicebook *old_par = m_choicebook;
        m_choicebook = nb;
        bool old_ins = m_isInside;
        m_isInside = true;
        CreateChildren(m_choicebook, true/*only this handler*/);
        m_isInside = old_ins;
        m_choicebook = old_par;

        return nb;
    }
}
void CGUIControlGroupList::AddControl(CGUIControl *control, int position /*= -1*/)
{
  // NOTE: We override control navigation here, but we don't override the <onleft> etc. builtins
  //       if specified.
  if (position < 0 || position > (int)m_children.size()) // add at the end
    position = (int)m_children.size();

  if (control)
  { // set the navigation of items so that they form a list
    int beforeID = (m_orientation == VERTICAL) ? GetControlIdUp() : GetControlIdLeft();
    int afterID = (m_orientation == VERTICAL) ? GetControlIdDown() : GetControlIdRight();
    if (m_children.size())
    {
      // we're inserting at the given position, so grab the items above and below and alter
      // their navigation accordingly
      CGUIControl *before = NULL;
      CGUIControl *after = NULL;
      if (position == 0)
      { // inserting at the beginning
        after = m_children[0];
        if (afterID == GetID()) // we're wrapping around bottom->top, so we have to update the last item
          before = m_children[m_children.size() - 1];
        if (beforeID == GetID())   // we're wrapping around top->bottom
          beforeID = m_children[m_children.size() - 1]->GetID();
        afterID = after->GetID();
      }
      else if (position == (int)m_children.size())
      { // inserting at the end
        before = m_children[m_children.size() - 1];
        if (beforeID == GetID())   // we're wrapping around top->bottom, so we have to update the first item
          after = m_children[0];
        if (afterID == GetID()) // we're wrapping around bottom->top
          afterID = m_children[0]->GetID();
        beforeID = before->GetID();
      }
      else
      { // inserting somewhere in the middle
        before = m_children[position - 1];
        after = m_children[position];
        beforeID = before->GetID();
        afterID = after->GetID();
      }
      if (m_orientation == VERTICAL)
      {
        if (before) // update the DOWN action to point to us
          before->SetNavigation(before->GetControlIdUp(), control->GetID(), GetControlIdLeft(), GetControlIdRight(), GetControlIdBack());
        if (after) // update the UP action to point to us
          after->SetNavigation(control->GetID(), after->GetControlIdDown(), GetControlIdLeft(), GetControlIdRight(), GetControlIdBack());
      }
      else
      {
        if (before) // update the RIGHT action to point to us
          before->SetNavigation(GetControlIdUp(), GetControlIdDown(), before->GetControlIdLeft(), control->GetID(), GetControlIdBack());
        if (after) // update the LEFT action to point to us
          after->SetNavigation(GetControlIdUp(), GetControlIdDown(), control->GetID(), after->GetControlIdRight(), GetControlIdBack());
      }
    }
    // now the control's nav
    CGUIAction empty;
    if (m_orientation == VERTICAL)
    {
      control->SetNavigation(beforeID, afterID, GetControlIdLeft(), GetControlIdRight(), GetControlIdBack());
      control->SetNavigationActions(empty, empty, m_actionLeft, m_actionRight, empty, false);
    }
    else
    {
      control->SetNavigation(GetControlIdUp(), GetControlIdDown(), beforeID, afterID, GetControlIdBack());
      control->SetNavigationActions(m_actionUp, m_actionDown, empty, empty, empty, false);
    }

    if (!m_useControlPositions)
      control->SetPosition(0,0);
    CGUIControlGroup::AddControl(control, position);
    m_totalSize = GetTotalSize();
  }
}
Example #15
0
int CGUIDialogFavourites::GetSelectedItem()
{
  CGUIMessage message(GUI_MSG_ITEM_SELECTED, GetID(), FAVOURITES_LIST);
  OnMessage(message);
  return message.GetParam1();
}
Example #16
0
// This is a NPC implementation of damage system (incomplete)
bool NPC::ApplyDamage(Damage &d) {
    _log(ITEM__TRACE, "%u: Applying %.1f total damage from %u", GetID(), d.GetTotal(), d.source->GetID());

    double total_damage = 0;
    bool killed = false;
    int random_damage = 0;
    double random_damage_mult = 1.0;

    //apply resistances...
    //damageResistance?

    //Shield:
    double available_shield = m_shieldCharge;
    Damage shield_damage = d.MultiplyDup(
        m_self->GetAttribute(AttrShieldKineticDamageResonance).get_float(),
        m_self->GetAttribute(AttrShieldThermalDamageResonance).get_float(),
        m_self->GetAttribute(AttrShieldEmDamageResonance).get_float(),
        m_self->GetAttribute(AttrShieldExplosiveDamageResonance).get_float()
    );
    //other:
    //emDamageResistanceBonus
    //explosiveDamageResistanceBonus
    //kineticDamageResistanceBonus
    //thermalDamageResistanceBonus
    //



    //TODO: deal with seepage from shield into armor.
     //shieldUniformity
    //uniformity (chance of seeping through to armor)

    /*
     * Here we calculates the uniformity thing.
     * I think this must be calculated based on
     * the type of damage -> resistance basis.
    *
    double shield_uniformity = available_shield / m_self->shieldCapacity();
    if( shield_uniformity < ( 1.0  - m_self->shieldUniformity() ) )
    {
        /*
         * As far i can see mostly npc/entities have a
         * chance of transpassing when the shield is below 25%
        /
    }
    */

    // Make a random value to use in msg's and attack multiplier
    random_damage = static_cast<int32>(MakeRandomInt(0, 5));
    random_damage_mult = (double)(random_damage / 10.0);

    // Not sure about this, but with this we get some random hits... :)
    //total_shield_damage += total_shield_damage * random_damage_mult;
    shield_damage.SumWithMultFactor( random_damage_mult );
    double total_shield_damage = shield_damage.GetTotal();

    if(total_shield_damage <= available_shield)
    {
        //we can take all this damage with our shield...
        double new_charge = m_shieldCharge - total_shield_damage;

        m_shieldCharge = new_charge;
        total_damage += total_shield_damage;
        _log(ITEM__TRACE, "%s(%u): Applying entire %.1f damage to shields. New charge: %.1f", GetName(), GetID(), total_shield_damage, new_charge);
    }
    else
    {
        //first determine how much we can actually apply to
        //the shield, the rest goes further down.
        double consumed_shield_ratio = available_shield / shield_damage.GetTotal();
        d *= 1.0 - consumed_shield_ratio;
        if(available_shield > 0) {
            total_damage += available_shield;

            _log(ITEM__TRACE, "%s(%us): Shield depleated with %.1f damage. %.1f damage remains.", GetName(), GetID(), available_shield, d.GetTotal());

            //set shield to 0, it is fully depleated.
            m_shieldCharge = 0;
        }

        //Armor:
        double available_armor = m_self->GetAttribute(AttrArmorHP).get_float() - m_armorDamage;
        Damage armor_damage = d.MultiplyDup(
            m_self->GetAttribute(AttrArmorKineticDamageResonance).get_float(),
            m_self->GetAttribute(AttrArmorThermalDamageResonance).get_float(),
            m_self->GetAttribute(AttrArmorEmDamageResonance).get_float(),
            m_self->GetAttribute(AttrArmorExplosiveDamageResonance).get_float()
        );
        //other:
        //activeEmResistanceBonus
        //activeExplosiveResistanceBonus
        //activeThermicResistanceBonus
        //activeKineticResistanceBonus
        //passiveEmDamageResistanceBonus
        //passiveExplosiveDamageResistanceBonus
        //passiveKineticDamageResistanceBonus
        //passiveThermicDamageResistanceBonus

        //TODO: figure out how much passes through to structure/modules.
        //armorUniformity

        // Not sure about this, but with this we get some random hits... :)
        //total_armor_damage += total_armor_damage * random_damage_mult;
        armor_damage.SumWithMultFactor( random_damage_mult );
        double total_armor_damage = armor_damage.GetTotal();

        if(total_armor_damage <= available_armor)
        {
            //we can take all this damage with our armor...
            double new_damage = m_armorDamage + total_armor_damage;
            m_armorDamage = new_damage;

            total_damage += total_armor_damage;
            _log(ITEM__TRACE, "%s(%u): Applying entire %.1f damage to armor. New armor damage: %.1f", GetName(), GetID(), total_armor_damage, new_damage);
        }
        else
        {
            //first determine how much we can actually apply to
            //the armor, the rest goes further down.
            double consumed_armor_ratio = available_armor / armor_damage.GetTotal();
            d *= 1.0 - consumed_armor_ratio;

            if(available_armor > 0)
            {
                total_damage += available_armor;

                _log(ITEM__TRACE, "%s(%u): Armor depleated with %.1f damage. %.1f damage remains.", GetName(), GetID(), available_armor, d.GetTotal());

                //all armor has been penetrated.
                m_armorDamage = m_self->GetAttribute(AttrArmorHP).get_float();
            }


            //Hull/Structure:

            //The base hp and damage attributes represent structure.
            double available_hull = m_self->GetAttribute(AttrHp).get_float() - m_hullDamage;
            Damage hull_damage = d.MultiplyDup(
                m_self->GetAttribute(AttrHullKineticDamageResonance).get_float(),
                m_self->GetAttribute(AttrHullThermalDamageResonance).get_float(),
                m_self->GetAttribute(AttrHullEmDamageResonance).get_float(),
                m_self->GetAttribute(AttrHullExplosiveDamageResonance).get_float()
            );
            //other:
            //passiveEmDamageResonanceMultiplier
            //passiveThermalDamageResonanceMultiplier
            //passiveKineticDamageResonanceMultiplier
            //passiveExplosiveDamageResonanceMultiplier
            //activeEmDamageResonance
            //activeThermalDamageResonance
            //activeKineticDamageResonance
            //activeExplosiveDamageResonance
            //structureUniformity

            // Not sure about this, but with this we get some random hits... :)
            //total_hull_damage += total_hull_damage * random_damage_mult;
            hull_damage.SumWithMultFactor( random_damage_mult );
            double total_hull_damage = hull_damage.GetTotal();
            total_damage += total_hull_damage;

            if(total_hull_damage < available_hull)
            {

                //we can take all this damage with our hull...
                double new_damage = m_hullDamage + total_hull_damage;
                m_hullDamage = new_damage;
                _log(ITEM__TRACE, "%s(%u): Applying entire %.1f damage to structure. New structure damage: %.1f", GetName(), GetID(), total_hull_damage, new_damage);
            }
            else
            {
                //dead....
                _log(ITEM__TRACE, "%s(%u): %.1f damage has depleated our structure. Time to explode.", GetName(), GetID(), total_hull_damage);
                killed = true;
                //m_hullDamage = m_self->hp();
                m_hullDamage = m_self->GetAttribute(AttrHp).get_float();
            }

            //TODO: deal with damaging modules. no idea the mechanics on this.
        }
    }

    //if( total_damage <= 0.0 )
    //    return(killed);

    PyTuple *up;

    //Notifications to ourself:
    Notify_OnEffectHit noeh;
    noeh.itemID = d.source->GetID();
    noeh.effectID = d.effect;
    noeh.targetID = GetID();
    noeh.damage = total_damage;

    up = noeh.Encode();
    QueueDestinyEvent(&up);
    PySafeDecRef( up );

    //NOTE: could send out the RD version of this message instead of the R version, which
    //includes "weapon" and "owner" instead of "source".
    Notify_OnDamageMessage_Self ondam;
    //ondam.messageID = "AttackHit2R";    //TODO: randomize/select this somehow.
    ondam.messageID = DamageMessageIDs_Self[random_damage];
    ondam.damage = total_damage;
    ondam.source = d.source->GetID();
    ondam.splash = "";
    up = ondam.Encode();
    QueueDestinyEvent(&up);
    PySafeDecRef( up );

    //Notifications to others:
    //I am not sure what the correct scope of this broadcast
    //should be. For now, it goes to anybody targeting us.
    if(targets.IsTargetedBySomething()) {
        up = noeh.Encode();
        targets.QueueTBDestinyEvent(&up);
        PySafeDecRef( up );

        Notify_OnDamageMessage_Other ondamo;
        //ondamo.messageID = "AttackHit3";        //TODO: select this based on the severity of the hit...
        ondamo.messageID = DamageMessageIDs_Other[random_damage];
        ondamo.format_type = fmtMapping_itemTypeName;
        ondamo.weaponType = d.weapon->typeID();
        ondamo.damage = total_damage;
        ondamo.target = GetID();
        ondamo.splash = "";

        up = ondamo.Encode();
        targets.QueueTBDestinyEvent(&up);
        PySafeDecRef( up );
    }

    if(killed == true)
    {
        Killed(d);
    }
    else
    {
        _SendDamageStateChanged();
    }

    return(killed);

}
Example #17
0
//if itemlist is null, just send wear changes
void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charges, uint8 minlevel, uint8 maxlevel, bool equipit, bool wearchange) {
	if(item2 == nullptr)
		return;

	//make sure we are doing something...
	if(!itemlist && !wearchange)
		return;

	ServerLootItem_Struct* item = new ServerLootItem_Struct;
#if EQDEBUG>=11
		LogFile->write(EQEMuLog::Debug, "Adding drop to npc: %s, Item: %i", GetName(), item2->ID);
#endif

	EQApplicationPacket* outapp = nullptr;
	WearChange_Struct* wc = nullptr;
	if(wearchange) {
		outapp = new EQApplicationPacket(OP_WearChange, sizeof(WearChange_Struct));
		wc = (WearChange_Struct*)outapp->pBuffer;
		wc->spawn_id = GetID();
		wc->material=0;
	}

	item->item_id = item2->ID;
	item->charges = charges;
	item->aug1 = 0;
	item->aug2 = 0;
	item->aug3 = 0;
	item->aug4 = 0;
	item->aug5 = 0;
	item->minlevel = minlevel;
	item->maxlevel = maxlevel;
	if (equipit) {
		uint8 eslot = 0xFF;
		char newid[20];
		const Item_Struct* compitem = nullptr;
		bool found = false; // track if we found an empty slot we fit into
		int32 foundslot = -1; // for multi-slot items

		// Equip rules are as follows:
		// If the item has the NoPet flag set it will not be equipped.
		// An empty slot takes priority. The first empty one that an item can
		// fit into will be the one picked for the item.
		// AC is the primary choice for which item gets picked for a slot.
		// If AC is identical HP is considered next.
		// If an item can fit into multiple slots we'll pick the last one where
		// it is an improvement.

		if (!item2->NoPet) {
			for (int i=0; !found && i<MAX_WORN_INVENTORY; i++) {
				uint32 slots = (1 << i);
				if (item2->Slots & slots) {
					if(equipment[i])
					{
						compitem = database.GetItem(equipment[i]);
						if (item2->AC > compitem->AC ||
							(item2->AC == compitem->AC && item2->HP > compitem->HP))
						{
							// item would be an upgrade
							// check if we're multi-slot, if yes then we have to keep
							// looking in case any of the other slots we can fit into are empty.
							if (item2->Slots != slots) {
								foundslot = i;
							}
							else {
								equipment[i] = item2->ID;
								foundslot = i;
								found = true;
							}
						} // end if ac
					}
					else
					{
						equipment[i] = item2->ID;
						foundslot = i;
						found = true;
					}
				} // end if (slots)
			} // end for
		} // end if NoPet

		// Possible slot was found but not selected. Pick it now.
		if (!found && foundslot >= 0) {
			equipment[foundslot] = item2->ID;
			found = true;
		}

		// @merth: IDFile size has been increased, this needs to change
		uint16 emat;
		if(item2->Material <= 0
			|| item2->Slots & (1 << SLOT_PRIMARY | 1 << SLOT_SECONDARY)) {
			memset(newid, 0, sizeof(newid));
			for(int i=0;i<7;i++){
				if (!isalpha(item2->IDFile[i])){
					strn0cpy(newid, &item2->IDFile[i],6);
					i=8;
				}
			}

			emat = atoi(newid);
		} else {
			emat = item2->Material;
		}

		if (foundslot == SLOT_PRIMARY) {
			if (item2->Proc.Effect != 0)
				CastToMob()->AddProcToWeapon(item2->Proc.Effect, true);

			eslot = MaterialPrimary;
		}
		else if (foundslot == SLOT_SECONDARY
			&& (GetOwner() != nullptr || (GetLevel() >= 13 && MakeRandomInt(0,99) < NPC_DW_CHANCE) || (item2->Damage==0)) &&
			(item2->ItemType == ItemType1HSlash || item2->ItemType == ItemType1HBlunt || item2->ItemType == ItemTypeShield ||
			item2->ItemType == ItemType1HPiercing))
		{
			if (item2->Proc.Effect!=0)
				CastToMob()->AddProcToWeapon(item2->Proc.Effect, true);

			eslot = MaterialSecondary;
		}
		else if (foundslot == SLOT_HEAD) {
			eslot = MaterialHead;
		}
		else if (foundslot == SLOT_CHEST) {
			eslot = MaterialChest;
		}
		else if (foundslot == SLOT_ARMS) {
			eslot = MaterialArms;
		}
		else if (foundslot == SLOT_BRACER01 || foundslot == SLOT_BRACER02) {
			eslot = MaterialWrist;
		}
		else if (foundslot == SLOT_HANDS) {
			eslot = MaterialHands;
		}
		else if (foundslot == SLOT_LEGS) {
			eslot = MaterialLegs;
		}
		else if (foundslot == SLOT_FEET) {
			eslot = MaterialFeet;
		}

		/*
		what was this about???

		if (((npc->GetRace()==127) && (npc->CastToMob()->GetOwnerID()!=0)) && (item2->Slots==24576) || (item2->Slots==8192) || (item2->Slots==16384)){
			npc->d_meele_texture2=atoi(newid);
			wc->wear_slot_id=8;
			if (item2->Material >0)
				wc->material=item2->Material;
			else
				wc->material=atoi(newid);
			npc->AC+=item2->AC;
			npc->STR+=item2->STR;
			npc->INT+=item2->INT;
		}
		*/

		//if we found an open slot it goes in...
		if(eslot != 0xFF) {
			if(wearchange) {
				wc->wear_slot_id = eslot;
				wc->material = emat;
			}

		}
		if (found) {
			CalcBonuses(); // This is less than ideal for bulk adding of items
		}
		item->equipSlot = item2->Slots;
	}

	if(itemlist != nullptr)
		itemlist->push_back(item);
	else
		safe_delete(item);

	if(wearchange && outapp) {
		entity_list.QueueClients(this, outapp);
		safe_delete(outapp);
	}
}
Example #18
0
bool CGUIEditControl::OnAction(const CAction &action)
{
  ValidateCursor();

  if (m_inputType != INPUT_TYPE_READONLY)
  {
    if (action.GetID() == ACTION_BACKSPACE)
    {
      // backspace
      if (m_cursorPos)
      {
        if (!ClearMD5())
          m_text2.erase(--m_cursorPos, 1);
        UpdateText();
      }
      return true;
    }
    else if (action.GetID() == ACTION_MOVE_LEFT ||
             action.GetID() == ACTION_CURSOR_LEFT)
    {
      if (m_cursorPos > 0)
      {
        m_cursorPos--;
        UpdateText(false);
        return true;
      }
    }
    else if (action.GetID() == ACTION_MOVE_RIGHT ||
             action.GetID() == ACTION_CURSOR_RIGHT)
    {
      if ((unsigned int) m_cursorPos < m_text2.size())
      {
        m_cursorPos++;
        UpdateText(false);
        return true;
      }
    }
    else if (action.GetID() == ACTION_PASTE)
    {
      ClearMD5();
      OnPasteClipboard();
      return true;
    }
    else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII && m_edit.empty())
    {
      // input from the keyboard (vkey, not ascii)
      BYTE b = action.GetID() & 0xFF;
      if (b == XBMCVK_HOME)
      {
        m_cursorPos = 0;
        UpdateText(false);
        return true;
      }
      else if (b == XBMCVK_END)
      {
        m_cursorPos = m_text2.length();
        UpdateText(false);
        return true;
      }
      if (b == XBMCVK_LEFT && m_cursorPos > 0)
      {
        m_cursorPos--;
        UpdateText(false);
        return true;
      }
      if (b == XBMCVK_RIGHT && m_cursorPos < m_text2.length())
      {
        m_cursorPos++;
        UpdateText(false);
        return true;
      }
      if (b == XBMCVK_DELETE)
      {
        if (m_cursorPos < m_text2.length())
        {
          if (!ClearMD5())
            m_text2.erase(m_cursorPos, 1);
          UpdateText();
          return true;
        }
      }
      if (b == XBMCVK_BACK)
      {
        if (m_cursorPos > 0)
        {
          if (!ClearMD5())
            m_text2.erase(--m_cursorPos, 1);
          UpdateText();
        }
        return true;
      }
      else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER)
      {
        // enter - send click message, but otherwise ignore
        SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1);
        return true;
      }
      else if (b == XBMCVK_ESCAPE)
      { // escape - fallthrough to default action
        return CGUIButtonControl::OnAction(action);
      }
    }
    else if (action.GetID() >= KEY_ASCII)
    {
      // input from the keyboard
      int ch = action.GetUnicode();
      // ignore non-printing characters
      if ( !((0 <= ch && ch < 0x8) || (0xE <= ch && ch < 0x1B) || (0x1C <= ch && ch < 0x20)) )
      {
      switch (ch)
      {
      case 9:  // tab, ignore
      case 11: // Non-printing character, ignore
      case 12: // Non-printing character, ignore
        break;
      case 10:
      case 13:
        {
          // enter - send click message, but otherwise ignore
          SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1);
          return true;
        }
      case 27:
        { // escape - fallthrough to default action
          return CGUIButtonControl::OnAction(action);
        }
      case 8:
        {
          // backspace
          if (m_cursorPos)
          {
            if (!ClearMD5())
              m_text2.erase(--m_cursorPos, 1);
          }
          break;
        }
      case 127:
        { // delete
          if (m_cursorPos < m_text2.length())
          {
            if (!ClearMD5())
              m_text2.erase(m_cursorPos, 1);
          }
        break;
        }
      default:
        {
          if (!g_Windowing.IsTextInputEnabled())
          {
            ClearMD5();
            m_edit.clear();
            m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.GetUnicode());
          }
          break;
        }
      }
      UpdateText();
      return true;
      }
    }
    else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
    { // input from the remote
      ClearMD5();
      m_edit.clear();
      OnSMSCharacter(action.GetID() - REMOTE_0);
      return true;
    }
    else if (action.GetID() == ACTION_INPUT_TEXT)
    {
      m_edit.clear();
      std::wstring str;
      g_charsetConverter.utf8ToW(action.GetText(), str);
      m_text2.insert(m_cursorPos, str);
      m_cursorPos += str.size();
      UpdateText();
      return true;
    }
  }
  return CGUIButtonControl::OnAction(action);
}
Example #19
0
//__________________________________________________________________
void        _HYPullDown::SendSelectionChange (void)
{
    if (messageRecipient) {
        messageRecipient->ProcessEvent (generateMenuSelChangeEvent (GetID(),GetSelection()));
    }
}
Example #20
0
bool CGUIWindowLoginScreen::OnMessage(CGUIMessage& message)
{
  switch ( message.GetMessage() )
  {
  case GUI_MSG_WINDOW_DEINIT:
    {
      m_viewControl.Reset();
      m_vecItems->Clear();
    }
    break;

  case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      if (iControl == CONTROL_BIG_LIST)
      {
        int iAction = message.GetParam1();

        // iItem is checked for validity inside these routines
        if (iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK)
        {
          int iItem = m_viewControl.GetSelectedItem();
          bool bResult = OnPopupMenu(m_viewControl.GetSelectedItem());
          if (bResult)
          {
            Update();
            CGUIMessage msg(GUI_MSG_ITEM_SELECT,GetID(),CONTROL_BIG_LIST,iItem);
            OnMessage(msg);
          }

          return bResult;
        }
        else if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK)
        {
          int iItem = m_viewControl.GetSelectedItem();
          bool bCanceled;
          bool bOkay = g_passwordManager.IsProfileLockUnlocked(iItem, bCanceled);

          if (bOkay)
          {
            LoadProfile(iItem);
          }
          else
          {
            if (!bCanceled && iItem != 0)
              CGUIDialogOK::ShowAndGetInput(20068,20117,20022,20022);
          }
        }
      }
    }
    break;
    case GUI_MSG_SETFOCUS:
    {
      if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != message.GetControlId())
      {
        m_viewControl.SetFocused();
        return true;
      }
    }
    default:
    break;

  }

  return CGUIWindow::OnMessage(message);
}
Example #21
0
wxObject *wxToolBarAddOnXmlHandler::DoCreateResource()
{
    wxToolBar* toolbar=NULL;

    if (m_class == _T("tool"))
    {
        wxCHECK_MSG(m_toolbar, NULL, _("Incorrect syntax of XRC resource: tool not within a toolbar!"));

        wxSize bitmapSize = m_toolbar->GetToolBitmapSize();

        if (GetPosition() != wxDefaultPosition)
        {
            m_toolbar->AddTool(GetID(),
            #if wxCHECK_VERSION(2, 9, 0)
                               wxEmptyString,
            #endif
                               GetCenteredBitmap(_T("bitmap"), wxART_TOOLBAR, bitmapSize),
                               GetCenteredBitmap(_T("bitmap2"), wxART_TOOLBAR, bitmapSize),
            #if !wxCHECK_VERSION(2, 9, 0)
                               GetBool(_T("toggle")),
                               GetPosition().x,
                               GetPosition().y,
                               NULL,
            #else
                               wxITEM_NORMAL,
            #endif
                               GetText(_T("tooltip")),
                               GetText(_T("longhelp")));
           if (GetBool(_T("disabled")))
           {
               m_toolbar->Realize();
               m_toolbar->EnableTool(GetID(),false);
           }
        }
        else
        {
            wxItemKind kind = wxITEM_NORMAL;
            if (GetBool(_T("radio")))
                kind = wxITEM_RADIO;
            if (GetBool(_T("toggle")))
            {
                wxASSERT_MSG( kind == wxITEM_NORMAL,
                              _("can't have both toggleable and radion button at once") );
                kind = wxITEM_CHECK;
            }
            m_toolbar->AddTool(GetID(),
                               GetText(_T("label")),
                               GetCenteredBitmap(_T("bitmap"), wxART_TOOLBAR, bitmapSize),
                               GetCenteredBitmap(_T("bitmap2"), wxART_TOOLBAR, bitmapSize),
                               kind,
                               GetText(_T("tooltip")),
                               GetText(_T("longhelp")));

           if (GetBool(_T("disabled")))
           {
               m_toolbar->Realize();
               m_toolbar->EnableTool(GetID(),false);
           }
        }
        return m_toolbar; // must return non-NULL
    }

    else if (m_class == _T("separator"))
    {
        wxCHECK_MSG(m_toolbar, NULL, _("Incorrect syntax of XRC resource: separator not within a toolbar!"));
        m_toolbar->AddSeparator();
        return m_toolbar; // must return non-NULL
    }

    else /*<object class="wxToolBar">*/
    {
        m_isAddon=(m_class == _T("wxToolBarAddOn"));
        if(m_isAddon)
        { // special case: Only add items to toolbar
          toolbar=(wxToolBar*)m_instance;
          // XRC_MAKE_INSTANCE(toolbar, wxToolBar);
        }
        else
        {
            int style = GetStyle(_T("style"), wxNO_BORDER | wxTB_HORIZONTAL);
            #ifdef __WXMSW__
            if (!(style & wxNO_BORDER)) style |= wxNO_BORDER;
            #endif

            XRC_MAKE_INSTANCE(toolbar, wxToolBar)

            toolbar->Create(m_parentAsWindow,
                             GetID(),
                             GetPosition(),
                             GetSize(),
                             style,
                             GetName());
            wxSize bmpsize = GetSize(_T("bitmapsize"));
            if (!(bmpsize == wxDefaultSize))
                toolbar->SetToolBitmapSize(bmpsize);
            wxSize margins = GetSize(_T("margins"));
            if (!(margins == wxDefaultSize))
                toolbar->SetMargins(margins.x, margins.y);
            long packing = GetLong(_T("packing"), -1);
            if (packing != -1)
                toolbar->SetToolPacking(packing);
            long separation = GetLong(_T("separation"), -1);
            if (separation != -1)
                toolbar->SetToolSeparation(separation);

            prepend.Clear();
            append.Clear();
        }

        wxXmlNode *children_node = GetParamNode(_T("object"));
        if (!children_node)
           children_node = GetParamNode(_T("object_ref"));

        if (children_node == NULL) return toolbar;

        m_isInside = TRUE;
        m_toolbar = toolbar;

        wxXmlNode *n = children_node;

        while (n)
        {
            if ((n->GetType() == wxXML_ELEMENT_NODE) &&
                (n->GetName() == _T("object") || n->GetName() == _T("object_ref")))
            {
                wxObject *created = CreateResFromNode(n, toolbar, NULL);
                wxControl *control = wxDynamicCast(created, wxControl);
                if (!IsOfClass(n, _T("tool")) &&
                    !IsOfClass(n, _T("separator")) &&
                    control != NULL &&
                    control != toolbar)
                {
                    //Manager::Get()->GetLogManager()->DebugLog(F(_T("control=%p, parent=%p, toolbar=%p"), control, control->GetParent(), toolbar));
                    toolbar->AddControl(control);
                }
            }
            n = n->GetNext();
        }

        toolbar->Realize();

        toolbar->SetCustomOverflowItems( prepend, append);

        m_isInside = FALSE;
        m_toolbar = NULL;

        if(!m_isAddon)
        {
            if (m_parentAsWindow && !GetBool(_T("dontattachtoframe")))
            {
                wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
                if (parentFrame)
                    parentFrame->SetToolBar(toolbar);
            }
        }
        m_isAddon=false;
        return toolbar;
    }
}
Example #22
0
SDL2DRenderManager::SDL2DRenderManager( LogTools& logger )
    : logger_( logger )
{
    logger_.OOLOG( FILE_INFOS ) << OOSTREAM( LOG_MESSAGE, "SDL 2D: creation of a render manager (id:" << GetID() << ")" );
}
bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf)
{
	if (errbuf)
	{
		errbuf[0] = 0;
	}
	int32 base = 0;
	int32 size = 7;
	uchar* buffer;
	ServerPacket* pack = 0;
	while ((recvbuf_used - base) >= size)
	{
		EmuTCPNetPacket_Struct* tnps = (EmuTCPNetPacket_Struct*) &recvbuf[base];
		buffer = tnps->buffer;
		size = tnps->size;
		if (size >= MaxTCPReceiveBuffferSize)
		{
#if TCPN_DEBUG_Memory >= 1
			std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
			DumpPacket(&recvbuf[base], 16);
#endif
			if (errbuf)
			{
				snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
			}
			return false;
		}
		if ((recvbuf_used - base) >= size)
		{
			// ok, we got enough data to make this packet!
			pack = new ServerPacket;
			pack->size = size - sizeof(EmuTCPNetPacket_Struct);
			// read headers
			pack->opcode = tnps->opcode;
			if (tnps->flags.compressed)
			{
				pack->compressed = true;
				pack->InflatedSize = *((int32*)buffer);
				pack->size -= 4;
				buffer += 4;
			}
			if (tnps->flags.destination)
			{
				pack->destination = *((int32*)buffer);
				pack->size -= 4;
				buffer += 4;
			}
			// end read headers
			if (pack->size > 0)
			{
				if (tnps->flags.compressed)
				{
					// Lets decompress the packet here
					pack->compressed = false;
					pack->pBuffer = new uchar[pack->InflatedSize];
					pack->size = InflatePacket(buffer, pack->size, pack->pBuffer, pack->InflatedSize);
				}
				else
				{
					pack->pBuffer = new uchar[pack->size];
					memcpy(pack->pBuffer, buffer, pack->size);
				}
			}
			if (pack->opcode == 0)
			{
				if (pack->size)
				{
#if TCPN_DEBUG >= 2
						std::cout << "Received TCP Network layer packet" << std::endl;
#endif
					ProcessNetworkLayerPacket(pack);
				}
#if TCPN_DEBUG >= 5
				else
				{
					std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
				}
#endif
				// keepalive, no need to process
				safe_delete(pack);
			}
			else
			{
#if TCPN_LOG_PACKETS >= 1
				if (pack && pack->opcode != 0)
				{
					struct in_addr	in;
					in.s_addr = GetrIP();
					CoutTimestamp(true);
					std::cout << ": Logging incoming TCP packet. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
					if (pack->size >= 32)
					{
						DumpPacket(pack->pBuffer, 32);
					}
					else
					{
						DumpPacket(pack);
					}
#endif
#if TCPN_LOG_PACKETS >= 3
					DumpPacket(pack);
#endif
				}
#endif
				if (RelayServer && Server && pack->destination)
				{
					EmuTCPConnection* con = Server->FindConnection(pack->destination);
					if (!con)
					{
#if TCPN_DEBUG >= 1
							std::cout << "Error relaying packet: con = 0" << std::endl;
#endif
						safe_delete(pack);
					}
					else
					{
						con->OutQueuePush(pack);
					}
				}
				else
				{
					OutQueuePush(pack);
				}
			}
			base += size;
			size = 7;
		}
	}
	if (base != 0)
	{
		if (base >= recvbuf_used)
		{
			safe_delete_array(recvbuf);
		}
		else
		{
			uchar* tmpbuf = new uchar[recvbuf_size - base];
			memcpy(tmpbuf, &recvbuf[base], recvbuf_used - base);
			safe_delete_array(recvbuf);
			recvbuf = tmpbuf;
			recvbuf_used -= base;
			recvbuf_size -= base;
		}
	}
	return true;
}
Example #24
0
void CDisplayPlane::UpdateCurrentNode(const TIME64 &vsyncTime)
{

    if(m_currentNode.isValid && m_currentNode.info.nfields > 0)
    {
        m_currentNode.info.nfields--;
        if(m_currentNode.info.nfields != 0)
            return;
    }

    if(m_currentNode.isValid)
    {
        if(!m_pendingNode.isValid)
        {
            // Nothing is going to be displayed next, so deal with either
            // keeping the current node on display or shuting down the plane
            if(m_isPaused || (m_currentNode.info.ulFlags & STM_PLANE_PRESENTATION_PERSISTENT))
            {
                // It is up to the specific updateHW implementation to make sure
                // the node keeps on displaying.
                return;
            }

            DEBUGF2(2,("CDisplayPlane::UpdateCurrentNode plane = %d disabling plane, no more nodes\n",GetID()));

            this->DisableHW();
            // Thats it, we have shut down so we are no longer active and should
            // not get any more updateHW calls until another node is queued.
            m_isActive = false;
            m_ulStatus &= ~STM_PLANE_STATUS_ACTIVE;
        }

        /*
         * We can now say the current node has completed and is no
         * longer on display, but it may still be referenced.
         */
        if(m_previousNode.isValid)
        {
            if(m_previousNode.info.pCompletedCallback)
            {
                m_previousNode.info.stats.vsyncTime = vsyncTime;
                m_previousNode.info.stats.ulStatus |= m_ulStatus;
                m_previousNode.info.pCompletedCallback(m_previousNode.info.pUserData,
                                                       &m_previousNode.info.stats);
            }

            DEBUGF2(3,("%s plane = %d releasing previous node\n",
                       __PRETTY_FUNCTION__, GetID()));

            this->ReleaseNode(m_previousNode);
            m_previousNode.isValid = false;
        }

        if(m_isActive && m_keepHistoricBufferForDeinterlacing)
        {
            m_previousNode = m_currentNode;
        }
        else
        {
            /*
             * Either in the non-deinterlacing case or the case of the last
             * node in a stream and the HW has just been shutdown, just release
             * the current node instead of moving it to a "previous" state.
             */
            if(m_currentNode.info.pCompletedCallback)
            {
                m_currentNode.info.stats.vsyncTime = vsyncTime;
                m_currentNode.info.stats.ulStatus |= m_ulStatus;
                m_currentNode.info.pCompletedCallback(m_currentNode.info.pUserData,
                                                      &m_currentNode.info.stats);
            }

            this->ReleaseNode(m_currentNode);
            m_currentNode.isValid = false;
        }
    }

    if(m_pendingNode.isValid)
    {
        m_currentNode = m_pendingNode;

        if(m_isPaused)
        {
          /*
           * If the plane has just been paused, then set the display fields to
           * zero. When the plane gets resumed the next queued buffer will
           * display on the next valid field. This prevents the buffer sticking
           * on the display for several frames when in very slow motion.
           */
          m_currentNode.info.nfields = 0;
        }

        m_pendingNode.isValid = false;

        // We can now say that this node is on the display
        if(m_currentNode.info.pDisplayCallback)
        {
            m_currentNode.info.stats.ulStatus |= STM_PLANE_STATUS_BUF_DISPLAYED;
            m_currentNode.info.pDisplayCallback(m_currentNode.info.pUserData, vsyncTime);
        }
    }
}
Example #25
0
// 鼠标移动事件处理
BOOL CControlBase::OnMouseMove(UINT nFlags, CPoint point)
{
	if(!m_bIsVisible || !m_bRresponse) return false;
	
	OnMousePointChange(point);

	BOOL bRresponse = false;
	if(m_pControl)
	{
		if((m_pControl->PtInRect(point) && m_pControl->OnCheckMouseResponse(nFlags, point)) || m_bMouseDown)
		{
			if(m_pControl->OnMouseMove(nFlags, point))
			{
				return true;
			}
			return false;
		}
	}

	CControlBase * pOldControl = m_pControl;
	m_pControl =  NULL;

	if(!m_strTooltip.IsEmpty() && PtInRect(point) && OnCheckMouseResponse(nFlags, point))
	{
		// 如果当前控件有Tooltip,则添加一个Tooltip
		CDlgBase* pDlg = GetParentDialog();
		if(pDlg && (pDlg->GetTooltipCtrlID() != GetID()))
		{
			pDlg->SetTooltip(this, m_strTooltip, m_rc);
			pDlg->SetTooltipCtrlID(GetID());
		}
	}

	bRresponse = OnControlMouseMove(nFlags, point);

	if(!m_bMouseDown)
	{
		for (size_t i = 0; i < m_vecControl.size(); i++)
		{
			CControlBase * pControlBase = m_vecControl.at(i);
			if (pControlBase)
			{
				if(pControlBase->OnMouseMove(nFlags, point))
				{
					if(pControlBase->PtInRect(point))
					{
						m_pControl = pControlBase;
					}
					bRresponse = true;
				}
			}
		}


		if (pOldControl)
		{
			bRresponse = true;
		}

		if (m_pControl)
		{
			bRresponse = true;
		}
	}

	return bRresponse;
}
Example #26
0
cGameCell::cGameCell( cFile& file, int num ) :
	m_index( num )
{
	queue<string> tokQueue;

	SetID( MakeID( c_cellSegment, num ) );
	MsgDaemon()->RegObject( GetID(), this );

	string tok;
	do
	{
		file.TokenizeNextNCLine( &tokQueue, '#' );

		tok = nextTok( tokQueue );

		if( tok == "CELL_START" )
		{
			// do nothing
		}

		else if( tok == "CELL_END" )
		{
			break;
		}

		else if( tok == "PT" )
		{
			point3 pt;

			// Read in the point
			tok = nextTok( tokQueue );
			pt.x = atof( tok.c_str() );

			tok = nextTok( tokQueue );
			pt.y = atof( tok.c_str() );

			tok = nextTok( tokQueue );
			pt.z = atof( tok.c_str() );

			// Append it to the list
			m_ptList.push_back( pt );
		}

		else if( tok == "FACE" )
		{
			tok = nextTok( tokQueue );

			int nInd = atoi( tok.c_str() );

			// Create the polygon structure to fill
			sPolygon currPoly;
			currPoly.m_nVerts = nInd;

			/**
			 * The next line is the indices.
			 */
			file.TokenizeNextNCLine( &tokQueue, '#' );

			// Fill in the indices
			for( int i=0; i< nInd; i++ )
			{
				tok = nextTok( tokQueue );
				currPoly.m_vList[i].m_ind = atoi( tok.c_str() );
			}

			// Now we can build the plane.

			currPoly.m_plane = plane3( 
				m_ptList[currPoly.m_vList[0].m_ind],
				m_ptList[currPoly.m_vList[1].m_ind],
				m_ptList[currPoly.m_vList[2].m_ind] );

			/**
			 * Next line is the colors
			 */
			file.TokenizeNextNCLine( &tokQueue, '#' );

			// Fill in the colors
			for( i=0; i< nInd; i++ )
			{
				tok = nextTok( tokQueue );
				sscanf( tok.c_str(), "%x", &currPoly.m_vList[i].m_col );
			}

			/**
			 * Final line is the texture info.
			 */
			file.TokenizeNextNCLine( &tokQueue, '#' );

			point3 m, n, p;

			// First token says whether to auto generate textures
			// Or explicitly read them.
			tok = nextTok( tokQueue );

			if( tok == "AUTO" )
			{
				// Automatically generate the texture vectors
				p = (m_ptList[currPoly.m_vList[0].m_ind]);

				tok = nextTok( tokQueue );
				currPoly.m_texID = atoi( tok.c_str() );

				tok = nextTok( tokQueue );
				float mScale = atof( tok.c_str() );

				tok = nextTok( tokQueue );
				float nScale = atof( tok.c_str() );

				// Run tests to figure out which way the plane faces
				if( point3::i == currPoly.m_plane.n || -1*point3::i == currPoly.m_plane.n )
				{
					// plane points in the +/-x direction
					m.Assign(0,0,1);
					n.Assign(0,1,0);
				}
				else if( point3::j == currPoly.m_plane.n || -1*point3::j == currPoly.m_plane.n )
				{
					// plane points in the +/-y direction
					m.Assign(0,0,1);
					n.Assign(1,0,0);
				}
				else if( point3::k == currPoly.m_plane.n || -1*point3::k == currPoly.m_plane.n )
				{
					// plane points in the +/-z direction
					m.Assign(1,0,0);
					n.Assign(0,1,0);
				}

				// No easy guess... just estimate using the first two points as one vector
				// and the cross as the other.
				else
				{
					m = m_ptList[currPoly.m_vList[1].m_ind] - m_ptList[currPoly.m_vList[0].m_ind];
					m.Normalize();
					n = m ^ currPoly.m_plane.n;
				}

				// scale the vectors by the provided scaling values.
				m *= mScale;
				n *= nScale;
			}
			else if( tok == "EXP" )
			{
				// Explicit tex-gen.  texture ID and then 9 floats (p,m,n).
				tok = nextTok( tokQueue );
				currPoly.m_texID = atoi( tok.c_str() );

				// P
				tok = nextTok( tokQueue );
				p.x = atof( tok.c_str() );

				tok = nextTok( tokQueue );
				p.y = atof( tok.c_str() );

				tok = nextTok( tokQueue );
				p.z = atof( tok.c_str() );

				// M
				tok = nextTok( tokQueue );
				m.x = atof( tok.c_str() );

				tok = nextTok( tokQueue );
				m.y = atof( tok.c_str() );

				tok = nextTok( tokQueue );
				m.z = atof( tok.c_str() );

				// N
				tok = nextTok( tokQueue );
				n.x = atof( tok.c_str() );

				tok = nextTok( tokQueue );
				n.y = atof( tok.c_str() );

				tok = nextTok( tokQueue );
				n.z = atof( tok.c_str() );

			}
			else throw cGameError( "Bad texture gen token" );

			float mMag = m.Mag();
			m /= mMag;

			float nMag = n.Mag();
			n /= nMag;

			// We have the n,m,p vectors; let's generate the coordinates.
			for( i=0; i<nInd; i++ )
			{
				point3 pt = m_ptList[currPoly.m_vList[i].m_ind] - p;

				float u = (pt * m);
				float v = (pt * n);

				currPoly.m_vList[i].m_u = u / mMag;
				currPoly.m_vList[i].m_v = v / nMag;
			}

			// Add the poly
			m_polyList.push_back( currPoly );

		}
		else if( 0 == tok.compare( "PORTAL" ) )
		{
			tok = nextTok( tokQueue );
			int other = atoi( tok.c_str() );

			tok = nextTok( tokQueue );
			int nInd = atoi( tok.c_str() );

			// Create the polygon structure to fill
			sPortal currPortal;
			currPortal.m_nVerts = nInd;

			// first # in the file is 1, here is 0
			currPortal.m_other = MakeID( c_cellSegment, other - 1);

			// Fill in the indices
			for( int i=0; i< nInd; i++ )
			{
				tok = nextTok( tokQueue );

				currPortal.m_vList[i].m_ind = atoi( tok.c_str() );
			}

			currPortal.m_plane = plane3( 
				m_ptList[currPortal.m_vList[0].m_ind],
				m_ptList[currPortal.m_vList[1].m_ind],
				m_ptList[currPortal.m_vList[2].m_ind] );

			// build the edge planes for this portal
			currPortal.CalcEdgePlanes( this );

			// Add the poly
			m_portalList.push_back( currPortal );
		}

	} while( 1 );
}
Example #27
0
void CGUIPythonWindowDialog::OnDeinitWindow(int nextWindowID)
{
  g_windowManager.RemoveDialog(GetID());
  CGUIWindow::OnDeinitWindow(nextWindowID);
  g_windowManager.Delete(GetID());
}
Example #28
0
void CGUIDialogFavourites::UpdateList()
{
  int currentItem = GetSelectedItem();
  CGUIMessage message(GUI_MSG_LABEL_BIND, GetID(), FAVOURITES_LIST, currentItem >= 0 ? currentItem : 0, 0, m_favourites);
  OnMessage(message);
}
Example #29
0
  data[0] = propid & 0x7F;                                  // data[0] = APPPPPP
                                                            // data[1] = 0000000

  if(cmd == Barrett::SET){                                  // this is a 'SET'
    data[0] |= 0x80;                                        // data[0] = 1PPPPPP
    
    // fill the rest of the bytes with the property value
    for(size_t i=2; i<6; i++){
      data[i] = (osaCANBusFrame::Data)( propval & 0xFF);     // data[i] = values
      propval >>= 8;
    }
    length = 6; // packed 6 bytes 
  }
  
  // create a new CAN frame
  canframe = osaCANBusFrame( osaPuck::CANID( GetID() ), data, length );

  return osaPuck::ESUCCESS;
}

// this unpacks a frame originating from the puck and destined to the host
// this is a bit backwards, because this methods is usually called from the 
// perspective of the host. Therefore, this is akin to asking a puck to unpack
// a message that it sent...whatever
osaPuck::Errno osaPuck::UnpackCANFrame(const osaCANBusFrame& canframe,
				       Barrett::ID& propid,
				       Barrett::Value& propval ){

  // get the data and the data length
  const osaCANBusFrame::Data* data = canframe.GetData();
  osaCANBusFrame::DataLength length = canframe.GetLength();
Example #30
0
void		_HYSequencePane::SendSelectionChange (bool vert)
{	
	if (messageRecipient)
		messageRecipient->ProcessEvent (generateMenuSelChangeEvent(GetID(),vert));
}