コード例 #1
0
void CPVRChannelNumberInputHandler::AppendChannelNumberCharacter(char cCharacter)
{
  if (cCharacter != CPVRChannelNumber::SEPARATOR && (cCharacter < '0' || cCharacter > '9'))
    return;

  CSingleLock lock(m_mutex);

  if (cCharacter == CPVRChannelNumber::SEPARATOR)
  {
    // no leading separator
    if (m_inputBuffer.empty())
      return;

    // max one separator
    if (m_inputBuffer.find(CPVRChannelNumber::SEPARATOR) != std::string::npos)
      return;
  }

  if (m_inputBuffer.size() == static_cast<size_t>(m_iMaxDigits))
  {
    m_inputBuffer.erase(m_inputBuffer.begin());
    m_label = m_inputBuffer;
  }
  else if (m_inputBuffer.empty())
  {
    m_sortedChannelNumbers.clear();
    GetChannelNumbers(m_sortedChannelNumbers);

    std::sort(m_sortedChannelNumbers.begin(), m_sortedChannelNumbers.end());
  }

  m_inputBuffer.append(&cCharacter, 1);
  m_label = m_inputBuffer;

  for (auto it = m_sortedChannelNumbers.begin(); it != m_sortedChannelNumbers.end();)
  {
    const std::string channel = *it;
    ++it;

    if (StringUtils::StartsWith(channel, m_inputBuffer))
    {
      if (it != m_sortedChannelNumbers.end() && StringUtils::StartsWith(*it, m_inputBuffer))
      {
        // there are alternative numbers; wait for more input
        break;
      }

      // no alternatives; complete the number and fire immediately
      m_inputBuffer = channel;
      m_label = m_inputBuffer;
      ExecuteAction();
      return;
    }
  }

  if (!m_timer.IsRunning())
    m_timer.Start(m_iDelay);
  else
    m_timer.Restart();
}
コード例 #2
0
bool mitk::EventStateMachine::HandleEvent(InteractionEvent* event, DataNode* dataNode)
{
  if (!FilterEvents(event, dataNode))
  {
    return false;
  }
  // check if the current state holds a transition that works with the given event.
  StateMachineTransition::Pointer transition = m_CurrentState->GetTransition(event->GetNameOfClass(), MapToEventVariant(event));

  if (transition.IsNotNull())
  {
    // iterate over all actions in this transition and execute them
    ActionVectorType actions = transition->GetActions();
    bool success = false;
    for (ActionVectorType::iterator it = actions.begin(); it != actions.end(); ++it)
    {

      success |= ExecuteAction(*it, event); // treat an event as handled if at least one of the actions is executed successfully
    }
    if (success || actions.empty())  // an empty action list is always successful
    {
      // perform state change
      m_CurrentState = transition->GetNextState();
      //MITK_INFO<< "StateChange: " << m_CurrentState->GetName();
    }
    return success;
  }
  else
  {
    return false; // no transition found that matches event
  }
}
コード例 #3
0
int CreateServiceSettingsAction::ExecuteAction(const Argz* az, const ServiceTaskSettings* baseSettings) {  
  CString serviceCommand;
  CString logFile;
  {    
    int ret = ServiceAction().GenerateServiceCommandLine(az, serviceCommand, logFile);
    if (ret != 0) return ret;
  }

  if (logFile.GetLength() > 0) {
    LOG.LogInfoFormat(L"Service log file is set to: %s", logFile);
  }
  
  SimpleCreateServiceSettings settings(baseSettings, serviceCommand);

  if (az->HasArgument(L"/runAsSystem")) {
    settings.setRunAsSystem(true);
    LOG.LogInfo(L"Installing service unser LOCAL_SYSTEM account");
  } else {
    int ret = ParseUserSettings(az, &settings);
    if (ret != 0) return ret;
    LOG.LogInfoFormat(L"Installing service under %s (domain=%s) account", settings.getUserName(), settings.getDomain());
  }

  settings.setAutostart(az->GetBooleanArgument(L"autostart", true) && az->GetBooleanArgument(KEY_AUTORUN, true));

  return ExecuteAction(az, &settings, baseSettings);  
}
コード例 #4
0
LRESULT
CDialogWindow::OnCommand(UINT msg, WPARAM wp, LPARAM lp)
{
	LRESULT result;

	if (lp != 0)	// получено уведомление от дочернего элемента
	{
		CBaseWindow *pCtrl = CBaseWindow::GetObjectPtr((HWND)lp);	// получаем дочерний элемент
		if (pCtrl)
		{
			int aindex = pCtrl->GetActionIndex(HIWORD(wp));		// получаем от дочернего элемента сохраненный индекс действия
			result = ExecuteAction(aindex,msg,wp,lp);	// выполняем требуемое действие
		}
		else
		{
			result = OnMessageDefault(msg,wp,lp);
		}
	}
	else
	{
		result = OnMessageDefault(msg,wp,lp);
	}

	return result;
}
コード例 #5
0
ファイル: Scene.cpp プロジェクト: DCubix/1.4.0
//It's not equal with MFC function.
CVoid CScene::SetClipIndex( CInt index, CBool loopAnimation )
{
	m_currentClipIndex = index;
	if( m_currentClipIndex == m_numClips)
		m_currentClipIndex = m_numClips - 1;
	if( m_currentClipIndex < 0 )
		m_currentClipIndex = 0;
	if( loopAnimation )
	{
		for( CInt index = 0; index < m_numClips; index++ )
		{
			if( m_currentClipIndex != index ) 
			{
				ClearCycle( index, 1.0f ); //1.0 second
			}
			else
			{
				BlendCycle( index, 1.0f, 1.0f );
			}
		}
	}
	else
	{
		ExecuteAction( m_currentClipIndex, m_animationClips[m_currentClipIndex]->GetDuration() * 0.1f, m_animationClips[m_currentClipIndex]->GetDuration() * 0.1f);
	}
}
コード例 #6
0
ファイル: app.c プロジェクト: FanHongchuang/Tina
/*
*********************************************************************************************************
*                                            App_DanceTask()
*
* Description : 机器人舞蹈管理任务
*
* Argument(s) : pdata.
*
* Return(s)   : none.
*
*********************************************************************************************************
*/
static void App_DanceTask(void *pdata)
{
	FRESULT result;
 	char ContentOfTheLine[6] = {0};
	
	uint32_t action = 0;
	uint32_t action_delay  = 0;
	
	INT8U err;

	while(1)
	{	
		OSSemPend(DanceSem,0,&err);
		
		/*##-1- 打开表情配置文件 */
		result = f_open(&CfgFile, "0:/dance/apple.txt", FA_OPEN_EXISTING | FA_READ);

		/*##-2- 逐行读取表情配置文件内容 */	
			do
			{
				
				f_gets(ContentOfTheLine,6,&CfgFile);
//				f_lseek(&CfgFile, f_tell(&CfgFile) + 2);
				sscanf((const char *)ContentOfTheLine, "%u %u" ,&action, &action_delay);
				
				ExecuteAction(action);
				OSTimeDlyHMSM(0,0,action_delay,10);
				ExecuteAction(127);
				
				
				if(f_eof(&CfgFile) != 0) //若文件读完,则将移动指针到文件头
				{
					//文件读完的时候,也就是舞蹈跳完的时候,跳出循环
					break;
					
				}

				
			}while(1);
			
		/*##-3- 关闭表情配置文件 */
			f_close(&CfgFile);
			
			OSTimeDlyHMSM(0,0,0,10);
		
	}
}
コード例 #7
0
ファイル: dlg_search.cpp プロジェクト: alfateam123/taiga
LRESULT SearchDialog::OnNotify(int idCtrl, LPNMHDR pnmh) {
  // ListView control
  if (idCtrl == IDC_LIST_SEARCH) {
    switch (pnmh->code) {
      // Column click
      case LVN_COLUMNCLICK: {
        LPNMLISTVIEW lplv = (LPNMLISTVIEW)pnmh;
        int order = 1;
        if (lplv->iSubItem == list_.GetSortColumn())
          order = list_.GetSortOrder() * -1;
        switch (lplv->iSubItem) {
          // Episode
          case 2:
            list_.Sort(lplv->iSubItem, order, ui::kListSortNumber, ui::ListViewCompareProc);
            break;
          // Season
          case 4:
            list_.Sort(lplv->iSubItem, order, ui::kListSortDateStart, ui::ListViewCompareProc);
            break;
          // Other columns
          default:
            list_.Sort(lplv->iSubItem, order, ui::kListSortDefault, ui::ListViewCompareProc);
            break;
        }
        break;
      }

      // Double click
      case NM_DBLCLK: {
        if (list_.GetSelectedCount() > 0) {
          LPNMITEMACTIVATE lpnmitem = reinterpret_cast<LPNMITEMACTIVATE>(pnmh);
          if (lpnmitem->iItem == -1)
            break;
          LPARAM lParam = list_.GetItemParam(lpnmitem->iItem);
          if (lParam)
            ShowDlgAnimeInfo(lParam);
        }
        break;
      }

      // Right click
      case NM_RCLICK: {
        LPNMITEMACTIVATE lpnmitem = reinterpret_cast<LPNMITEMACTIVATE>(pnmh);
        if (lpnmitem->iItem == -1)
          break;
        LPARAM lParam = list_.GetItemParam(lpnmitem->iItem);
        auto anime_item = AnimeDatabase.FindItem(static_cast<int>(lParam));
        ui::Menus.UpdateSearchList(!anime_item->IsInList());
        ExecuteAction(ui::Menus.Show(pnmh->hwndFrom, 0, 0, L"SearchList"), 0, lParam);
        break;
      }
    }
  }

  return 0;
}
コード例 #8
0
ファイル: threaded_worker.cpp プロジェクト: aka2006/RapidSVN
  /**
   * thread execution starts here
   */
  virtual void *
  Entry()
  {
    while (!TestDestroy())
    {
      ExecuteAction();

      Sleep(10);
    }
    return 0;
  }
コード例 #9
0
bool CPVRChannelNumberInputHandler::CheckInputAndExecuteAction()
{
  const CPVRChannelNumber channelNumber = GetChannelNumber();
  if (channelNumber.IsValid())
  {
    // we have a valid channel number; execute the associated action now.
    ExecuteAction();
    return true;
  }
  return false;
}
コード例 #10
0
ファイル: dlg_anime_info.cpp プロジェクト: Greathood/taiga
LRESULT AnimeDialog::OnNotify(int idCtrl, LPNMHDR pnmh) {
  switch (idCtrl) {
    case IDC_LINK_NOWPLAYING: {
      switch (pnmh->code) {
        // Link click
        case NM_CLICK: {
          PNMLINK pNMLink = reinterpret_cast<PNMLINK>(pnmh);
          wstring action = pNMLink->item.szUrl;
          if (IsEqual(pNMLink->item.szID, L"menu")) {
            action = UI.Menus.Show(m_hWindow, 0, 0, pNMLink->item.szUrl);
          } else if (IsEqual(pNMLink->item.szID, L"search")) {
            action = L"SearchAnime(" + CurrentEpisode.title + L")";
          } else if (IsEqual(pNMLink->item.szUrl, L"score")) {
            action = L"";
            CurrentEpisode.anime_id = ToInt(pNMLink->item.szID);
            auto anime_item = AnimeDatabase.FindItem(CurrentEpisode.anime_id);
            if (anime_item) {
              anime_item->AddtoUserList();
              auto synonyms = anime_item->GetUserSynonyms();
              synonyms.push_back(CurrentEpisode.title);
              anime_item->SetUserSynonyms(synonyms);
              Meow.UpdateCleanTitles(anime_item->GetId());
              Settings.Save();
              anime_item->StartWatching(CurrentEpisode);
              MainDialog.ChangeStatus();
            }
          }
          ExecuteAction(action, 0, GetCurrentId());
          return TRUE;
        }

        // Custom draw
        case NM_CUSTOMDRAW: {
          return CDRF_DODEFAULT;
        }
      }
      break;
    }

    case IDC_TAB_ANIME: {
      switch (pnmh->code) {
        // Tab select
        case TCN_SELCHANGE: {
          SetCurrentPage(tab_.GetCurrentlySelected() + 1);
          break;
        }
      }
      break;
    }
  }
  
  return 0;
}
コード例 #11
0
ファイル: ajs_cps.c プロジェクト: dengcj0/QCA4010
static AJSVC_ServiceStatus CPSMessageHandler(AJ_BusAttachment* bus, AJ_Message* msg, AJ_Status* msgStatus)
{
    AJ_Status status = AJ_OK;
    AJSVC_ServiceStatus handled = AJSVC_SERVICE_STATUS_HANDLED;
    AJ_MemberType mt;
    uint8_t isRoot;
    const char* member;

    if (!objectList || (LST_INDEX(msg->msgId) != AJCPS_OBJECT_LIST_INDEX)) {
        return AJSVC_SERVICE_STATUS_NOT_HANDLED;
    }
    AJ_InfoPrintf(("CPSMessageHandler %s::%s.%s\n", msg->objPath, msg->iface, msg->member));
    mt = AJ_GetMemberType(msg->msgId, &member, NULL);
    if (mt != AJ_METHOD_MEMBER) {
        return AJSVC_SERVICE_STATUS_NOT_HANDLED;
    }
    isRoot = InvolvesRootWidget(msg->msgId);
    if (strcmp(msg->member, "Get") == 0) {
        status = AJ_BusPropGet(msg, isRoot ? AJCPS_GetRootProperty : AJCPS_GetWidgetProperty, NULL);
    } else if (strcmp(msg->member, "Set") == 0) {
        status = SetWidgetProp(msg);
    } else if (strcmp(msg->member, "GetAll") == 0) {
        if (isRoot) {
            status = AJCPS_GetAllRootProperties(msg, msg->msgId);
        } else {
            status = AJCPS_GetAllWidgetProperties(msg, msg->msgId);
        }
    } else if (strcmp(msg->member, "Exec") == 0) {
        status = ExecuteAction(msg, 0, NULL);
    } else if ((strncmp(msg->member, "Action", 6) == 0) && !msg->member[7]) {
        status = ExecuteAction(msg, msg->member[6] - '0', NULL);
    } else if (strcmp(msg->member, "GetURL") == 0) {
        status = AJCPS_SendRootUrl(msg, msg->msgId);
    } else {
        handled = AJSVC_SERVICE_STATUS_NOT_HANDLED;
    }
    *msgStatus = status;
    return handled;
}
コード例 #12
0
ファイル: FFL_Notify.cpp プロジェクト: abbro-ca/pdfium
FX_BOOL	CFFL_Notify::ExecuteActionTree(CPDF_AAction::AActionType eAAT,CPDF_Action & action, FX_BOOL& bExit)
{
	if (!ExecuteAction(eAAT,action,bExit)) return FALSE;
	if (bExit) return TRUE;

	for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++)
	{
		CPDF_Action subaction = action.GetSubAction(i);
		if (!ExecuteActionTree(eAAT,subaction,bExit)) return FALSE;
		if (bExit) break;
	}

	return TRUE;
}
コード例 #13
0
ファイル: taiga.cpp プロジェクト: Greathood/taiga
BOOL Taiga::InitInstance() {
  // Check another instance
  if (CheckInstance(L"Taiga-33d5a63c-de90-432f-9a8b-f6f733dab258", L"TaigaMainW"))
    return FALSE;
  g_hInstance = GetInstanceHandle();

  // Initialize
  InitCommonControls(ICC_STANDARD_CLASSES);
  OleInitialize(NULL);

  // Initialize logger
#ifdef _DEBUG
  Logger.SetOutputPath(AddTrailingSlash(GetCurrentDirectory()) + L"Taiga_debug.log");
  Logger.SetSeverityLevel(LevelDebug);
#else
  Logger.SetOutputPath(AddTrailingSlash(GetPathOnly(GetModulePath())) + L"Taiga.log");
  Logger.SetSeverityLevel(LevelWarning);
#endif

  // Load data
  LoadData();

  // Create API windows
  Skype.Create();
  TaigaApi.Create();

  if (Settings.Program.StartUp.check_new_version) {
    // Create update dialog
    ExecuteAction(L"CheckUpdates");
  } else {
    // Create main dialog
    ExecuteAction(L"MainDialog");
  }

  return TRUE;
}
コード例 #14
0
ファイル: dlg_main_controls.cpp プロジェクト: erengy/taiga
void MainDialog::ToolbarWithMenu::ShowMenu() {
  button_index = toolbar->GetHotItem();

  TBBUTTON tbb;
  toolbar->GetButton(button_index, tbb);
  toolbar->PressButton(tbb.idCommand, TRUE);

  // Calculate point
  RECT rect;
  toolbar->SendMessage(TB_GETITEMRECT, button_index, reinterpret_cast<LPARAM>(&rect));
  POINT pt = {rect.left, rect.bottom};
  ClientToScreen(toolbar->GetWindowHandle(), &pt);

  // Hook
  if (hook)
    UnhookWindowsHookEx(hook);
  hook = SetWindowsHookEx(WH_MSGFILTER, &HookProc, NULL, GetCurrentThreadId());

  // Display menu
  ui::Menus.UpdateAll();
  std::wstring action;
  HWND hwnd = DlgMain.GetWindowHandle();
  #define SHOWUIMENU(id, name) \
    case id: action = ui::Menus.Show(hwnd, pt.x, pt.y, name); break;
  switch (tbb.idCommand) {
    SHOWUIMENU(100, L"File");
    SHOWUIMENU(101, L"Services");
    SHOWUIMENU(102, L"Tools");
    SHOWUIMENU(103, L"View");
    SHOWUIMENU(104, L"Help");
    SHOWUIMENU(kToolbarButtonFolders, L"Folders");
    SHOWUIMENU(kToolbarButtonTools, L"ExternalLinks");
  }
  #undef SHOWUIMENU

  // Unhook
  if (hook) {
    UnhookWindowsHookEx(hook);
    hook = nullptr;
  }

  toolbar->PressButton(tbb.idCommand, FALSE);
  if (button_index > -1)
    toolbar->SetHotItem(-1);

  if (!action.empty())
    ExecuteAction(action);
}
コード例 #15
0
ファイル: dlg_torrent.cpp プロジェクト: Greathood/taiga
BOOL TorrentDialog::OnCommand(WPARAM wParam, LPARAM lParam) {
  Feed* feed = Aggregator.Get(FEED_CATEGORY_LINK);
  if (!feed) return 0;
  
  // Toolbar
  switch (LOWORD(wParam)) {
    // Check new torrents
    case 100: {
      MainDialog.edit.SetText(L"");
      feed->Check(Settings.RSS.Torrent.source);
      /**
      #ifdef _DEBUG
      feed->Load();
      feed->ExamineData();
      RefreshList();
      #endif
      /**/
      return TRUE;
    }
    // Download marked torrents
    case 101: {
      feed->Download(-1);
      return TRUE;
    }
    // Discard marked torrents
    case 102: {
      for (int i = 0; i < list_.GetItemCount(); i++) {
        if (list_.GetCheckState(i) == TRUE) {
          FeedItem* feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(i));
          if (feed_item) {
            feed_item->state = FEEDITEM_DISCARDED_NORMAL;
            list_.SetCheckState(i, FALSE);
            Aggregator.file_archive.push_back(feed_item->title);
          }
        }
      }
      return TRUE;
    }
    // Settings
    case 103: {
      ExecuteAction(L"Settings", SECTION_TORRENTS, PAGE_TORRENTS_DISCOVERY);
      return TRUE;
    }
  }

  return FALSE;
}
コード例 #16
0
BOOL KGatewayDataProcess::ProGameLogin(S3PDBConVBC* pConn, const IBYTE* lpData, const DWORD dwDataSize)
{
	BOOL bRet = FALSE;
	if (NULL != lpData && dwDataSize == sizeof(KAccountUser))
	{
		KAccountUser* pAccInfo = (KAccountUser*)(lpData);
		if (pAccInfo->Version == ACCOUNT_CURRENT_VERSION &&
			pAccInfo->Type == AccountUser)
		{
			KAccountUserReturn aReturn;
			aReturn.Size = sizeof(KAccountUserReturn);
			aReturn.Type = AccountUserReturn;
			aReturn.Operate = pAccInfo->Operate;
			memcpy(aReturn.Account, pAccInfo->Account, LOGIN_USER_ACCOUNT_MAX_LEN);
			aReturn.nReturn = S3PAccount::FreezeAccount(pConn, pAccInfo->Account);

			S3PDBSocketPool* pSocket = S3PDBSocketPool::Instance();

			char* szDetail = NULL;
			in_addr ar;
			ar.s_addr = m_Address;
			if (aReturn.nReturn == ACTION_SUCCESS)
			{
				bRet = TRUE;
				char szS[200];
				sprintf(szS, "GlobalExecute(\"dw KickOutAccount([[%s]])\")", pAccInfo->Account);
				ExecuteAction(szS);//踢人
				gTrace("Account(%s) is KickOff!", pAccInfo->Account);
				szDetail = " Success !";
			}
			else
			{
				szDetail = " Failed !";
			}

			gTrace("Gateway %s(%s): User %s Freeze Account%s", m_ServerName.c_str(), inet_ntoa(ar), pAccInfo->Account, szDetail);
			
			pSocket->CustomSend(m_nClientID, s2c_gamelogin, &aReturn);
		}
		else
			gTrace("Protocol %d data is error", c2s_gamelogin);
	}
	else
		gTrace("Protocol %d data is error", c2s_gamelogin);
	return bRet;
}
コード例 #17
0
logical cClassCodeInit :: SetupInitCode ( )
{
  PropertyHandle  *prophdl = GetPropertyHandle();    
  PropertyHandle  *fcti_ph = prophdl->GetParentProperty();
  logical          term    = NO;
BEGINSEQ
  ExecuteAction("StoreEntry",ACT_Function);
  fcti_ph->Save();
  if ( prophdl->NoWrite() )                          ERROR
  
  fcti_ph->ExecuteInstanceAction("SetupInitCode","NO");

RECOVER
  term = YES;
ENDSEQ
  return(term);
}
コード例 #18
0
bool mitk::EventStateMachine::HandleEvent(InteractionEvent* event, DataNode* dataNode)
{
  if (!m_IsActive)
    return false;

  if (!FilterEvents(event, dataNode))
  {
    return false;
  }

  // Get the transition that can be executed
  mitk::StateMachineTransition::Pointer transition = GetExecutableTransition( event );

  // check if the current state holds a transition that works with the given event.
  if ( transition.IsNotNull() )
  {
    // all conditions are fulfilled so we can continue with the actions
    m_CurrentState = transition->GetNextState();

    // iterate over all actions in this transition and execute them
    ActionVectorType actions = transition->GetActions();
    for (ActionVectorType::iterator it = actions.begin(); it != actions.end(); ++it)
    {
      try
      {
        ExecuteAction(*it, event);
      }
      catch( const std::exception& e )
      {
        MITK_ERROR << "Unhandled excaption caught in ExecuteAction(): " << e.what();
        return false;
      }
      catch( ... )
      {
        MITK_ERROR << "Unhandled excaption caught in ExecuteAction()";
        return false;
      }
    }

    return true;
  }
  return false;
}
コード例 #19
0
ファイル: dlg_search.cpp プロジェクト: Hydro8182/taiga
void SearchDialog::OnContextMenu(HWND hwnd, POINT pt) {
  if (hwnd == list_.GetWindowHandle()) {
    if (list_.GetSelectedCount() > 0) {
      if (pt.x == -1 || pt.y == -1)
        GetPopupMenuPositionForSelectedListItem(list_, pt);
      auto anime_id = GetAnimeIdFromSelectedListItem(list_);
      auto anime_ids = GetAnimeIdsFromSelectedListItems(list_);
      bool is_in_list = true;
      for (const auto& anime_id : anime_ids) {
        auto anime_item = AnimeDatabase.FindItem(anime_id);
        if (anime_item && !anime_item->IsInList()) {
          is_in_list = false;
          break;
        }
      }
      ui::Menus.UpdateSearchList(!is_in_list);
      auto action = ui::Menus.Show(DlgMain.GetWindowHandle(), pt.x, pt.y, L"SearchList");
      ExecuteAction(action, TRUE, StartsWith(action, L"AddToList") ?
                    reinterpret_cast<LPARAM>(&anime_ids) : anime_id);
    }
  }
}
コード例 #20
0
ファイル: Scene.cpp プロジェクト: DCubix/1.4.0
CVoid CScene::SetClipIndex( CInt index, CBool loopAnimation )
{
	if (g_selectedName != -1)
	{
		if (m_numClips == 0)
			return;
		m_currentClipIndex = index;
		if (m_currentClipIndex == m_numClips - 1)
			ex_pBtnNextAnim->EnableWindow(FALSE);
		else if (m_numClips > 1)
			ex_pBtnNextAnim->EnableWindow(TRUE);

		if (m_currentClipIndex == 0)
			ex_pBtnPrevAnim->EnableWindow(FALSE);
		else if (m_numClips > 1)
			ex_pBtnPrevAnim->EnableWindow(TRUE);

		if (loopAnimation)
		{
			for (CInt index = 0; index < m_numClips; index++)
			{
				if (m_currentClipIndex != index)
				{
					ClearCycle(index, 1.0f); //1.0 second
				}
				else
				{
					BlendCycle(index, 1.0f, 1.0f);
				}
			}
		}
		else
		{
			ExecuteAction(m_currentClipIndex, m_animationClips[m_currentClipIndex]->GetDuration() * 0.1f, m_animationClips[m_currentClipIndex]->GetDuration() * 0.1f);
		}

		PrintInfo("\nAnimation '" + (CString)m_animationClips[m_currentClipIndex]->GetName() + "' activated");
	}
}
コード例 #21
0
int8 cTableEditor :: DoBeforeDrop ( )
{
  char                    executed      = NO;
  PropertyHandle        * attr_ph       = NULL;
  PropertyHandle        * field_ph      = NULL;
  PropertyHandle        * parent        = NULL;
  char                  * prop_path;
  NString                 field_opts    = "";
  char                  * field_name    = NULL;
  CTX_Control           * field_context = NULL;
BEGINSEQ
  PropertyHandle    *drop_ph    = GetDropPropertyHandle();
  char              *drop_txt   = GetDropText();
  DPoint             drop_pos   = GetDropPosition();
  int                drop_index = GetDropIndex();
  logical            is_local   = IsLocalDrop();

  if ( is_local )                                    ERROR
  
  field_opts += drop_txt;
  field_opts += ",";
  field_opts += drop_index;
  
  prop_path = GetPropertyHandle()->GetPropertyPath();
  parent    = GetPropertyHandle()->GetParentProperty();
  if ( !strcmp(prop_path,"ADK_StyleAction.columns") )
    parent->ExecuteInstanceAction("AddColumn", field_opts);
  else if ( !strcmp(prop_path,"ADK_StyleAction.regions") )
    parent->ExecuteInstanceAction("AddRegion", field_opts);
  executed = YES;

  ExecuteAction("Refresh", ACT_Function);
RECOVER
  return CTX_Control::DoBeforeDrop();
ENDSEQ
  return(executed);
}
コード例 #22
0
BOOL KGatewayDataProcess::ProAutoTime(S3PDBConVBC* pConn)
{
	BOOL bRet = FALSE;
	DWORD dwMin = 0;
	dwMin = 1800;	//默认30分钟
	char szMessage[128];
	if (dwMin > 0)
	{
		AccountTimeList TimeList;
		if (S3PAccount::GetAccountsTime(pConn, m_nGameID, dwMin, TimeList) == ACTION_SUCCESS)
		{
			AccountTimeList::iterator i = TimeList.begin();
			while (i != TimeList.end())
			{
				if (i->nTime == 0)		//踢人
				{
					char szS[200];
					sprintf(szS, "GlobalExecute(\"dw KickOutAccount([[%s]])\")", i->Account);
					ExecuteAction(szS);//踢人
					gTrace("Account(%s) is KickOff!", i->Account);
				}
				else	//催促充值
				{
					int nLen = 0;
					if (i->nTime >= 60)
						nLen = sprintf(szMessage, "您在游戏中还可以停留%d分钟, 请赶快充值!", i->nTime / 60);
					else
						nLen = sprintf(szMessage, "您在游戏中还可以停留%d秒, 请赶快充值!", i->nTime);
					SendSystemInfo(m_nClientID, i->Account, "GM", szMessage, nLen);
				}
				i++;
			}
			bRet = TRUE;
		}
	}
	return bRet;
}
コード例 #23
0
ファイル: Realtime.cpp プロジェクト: RadekSimkanic/JA2-1.13
void RTHandleAI( SOLDIERTYPE * pSoldier )
{
#ifdef AI_PROFILING
	INT32 iLoop;
#endif

	if ((pSoldier->aiData.bAction != AI_ACTION_NONE) && pSoldier->aiData.bActionInProgress)
	{
		// if action should remain in progress
		if (ActionInProgress(pSoldier))
		{
			#ifdef DEBUGBUSY
				AINumMessage("Busy with action, skipping guy#",pSoldier->ubID);
			#endif
			// let it continue
			return;
		}
	}

	// Flugente: prisoners of war don't do anything
	if ( pSoldier->usSoldierFlagMask & SOLDIER_POW )
		return;

	// if man has nothing to do
	if (pSoldier->aiData.bAction == AI_ACTION_NONE)
	{
		if (pSoldier->aiData.bNextAction == AI_ACTION_NONE)
		{
			// make sure this flag is turned off (it already should be!)
			pSoldier->aiData.bActionInProgress = FALSE;

			// truly nothing to do!
			RefreshAI( pSoldier );
		}

		// Since we're NEVER going to "continue" along an old path at this point,
		// then it would be nice place to reinitialize "pathStored" flag for
		// insurance purposes.
		//
		// The "pathStored" variable controls whether it's necessary to call
		// findNewPath() after you've called NewDest(). Since the AI calls
		// findNewPath() itself, a speed gain can be obtained by avoiding
		// redundancy.
		//
		// The "normal" way for pathStored to be reset is inside
		// SetNewCourse() [which gets called after NewDest()].
		//
		// The only reason we would NEED to reinitialize it here is if I've
		// incorrectly set pathStored to TRUE in a process that doesn't end up
		// calling NewDest()
		pSoldier->pathing.bPathStored = FALSE;

		// decide on the next action
#ifdef AI_PROFILING
		for (iLoop = 0; iLoop < 1000; iLoop++)
#endif
		{
			if (pSoldier->aiData.bNextAction != AI_ACTION_NONE)
			{
				if ( pSoldier->aiData.bNextAction == AI_ACTION_END_COWER_AND_MOVE )
				{
					if ( pSoldier->flags.uiStatusFlags & SOLDIER_COWERING )
					{
						pSoldier->aiData.bAction = AI_ACTION_STOP_COWERING;
						pSoldier->aiData.usActionData = ANIM_STAND;
					}
					else if ( gAnimControl[ pSoldier->usAnimState ].ubEndHeight < ANIM_STAND )
					{
						// stand up!
						pSoldier->aiData.bAction = AI_ACTION_CHANGE_STANCE;
						pSoldier->aiData.usActionData = ANIM_STAND;
					}
					else
					{
						pSoldier->aiData.bAction = AI_ACTION_NONE;
					}
					if ( pSoldier->sGridNo == pSoldier->aiData.usNextActionData )
					{
						// no need to walk after this
						pSoldier->aiData.bNextAction = AI_ACTION_NONE;
						pSoldier->aiData.usNextActionData = NOWHERE;
					}
					else
					{
						pSoldier->aiData.bNextAction = AI_ACTION_WALK;
						// leave next-action-data as is since that's where we want to go
					}
				}
				else
				{
					// do the next thing we have to do...
					pSoldier->aiData.bAction = pSoldier->aiData.bNextAction;
					pSoldier->aiData.usActionData = pSoldier->aiData.usNextActionData;
					pSoldier->bTargetLevel = pSoldier->aiData.bNextTargetLevel;
					pSoldier->aiData.bNextAction = AI_ACTION_NONE;
					pSoldier->aiData.usNextActionData = 0;
					pSoldier->aiData.bNextTargetLevel = 0;
				}
				if (pSoldier->aiData.bAction == AI_ACTION_PICKUP_ITEM)
				{
					// the item pool index was stored in the special data field
					pSoldier->aiData.uiPendingActionData1 = pSoldier->iNextActionSpecialData;
				}
			}			
			else if (!TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
			{
				if ( ACTING_ON_SCHEDULE( pSoldier ) )
				{
					pSoldier->aiData.bAction = AI_ACTION_SCHEDULE_MOVE;
				}
				else
				{
					pSoldier->aiData.bAction = AI_ACTION_WALK;
				}
				pSoldier->aiData.usActionData = pSoldier->sAbsoluteFinalDestination;
			}
			else
			{
				if (!(gTacticalStatus.uiFlags & ENGAGED_IN_CONV))
				{
                    if(!pSoldier->ai_masterplan_) // if the Soldier has no plan, create one
                    {
                        if(pSoldier->bAIIndex == 0) // not yet initialized, use bTeam+1 as default
                            pSoldier->bAIIndex = pSoldier->bTeam + 1;
                        AI::tactical::AIInputData ai_input;
                        AI::tactical::PlanFactoryLibrary* plan_lib(AI::tactical::PlanFactoryLibrary::instance());
                        pSoldier->ai_masterplan_ = plan_lib->create_plan(pSoldier->bAIIndex, pSoldier, ai_input);
                    }
                    AI::tactical::PlanInputData plan_input(false, gTacticalStatus);
                    pSoldier->ai_masterplan_->execute(plan_input);
				}
			}
		}
		// if he chose to continue doing nothing
		if (pSoldier->aiData.bAction == AI_ACTION_NONE)
		{
			#ifdef RECORDNET
				fprintf(NetDebugFile,"\tMOVED BECOMING TRUE: Chose to do nothing, guynum %d\n",pSoldier->ubID);
			#endif

			// do a standard wait before doing anything else!
			pSoldier->aiData.bAction = AI_ACTION_WAIT;
			//if (PTR_CIVILIAN && pSoldier->aiData.bAlertStatus != STATUS_BLACK)
			if ( PTR_CIV_OR_MILITIA && !(pSoldier->ubCivilianGroup == KINGPIN_CIV_GROUP ) )
			{
				pSoldier->aiData.usActionData = (UINT16) REALTIME_CIV_AI_DELAY;
			}
			else if ( CREATURE_OR_BLOODCAT( pSoldier ) && !( pSoldier->aiData.bHunting ) )
			{
				pSoldier->aiData.usActionData = (UINT16) REALTIME_CREATURE_AI_DELAY;
			}
			else
			{
				pSoldier->aiData.usActionData = (UINT16) REALTIME_AI_DELAY;
				if ( pSoldier->ubCivilianGroup == KINGPIN_CIV_GROUP )
				{
					//DBrot: More Rooms
					//UINT8		ubRoom;
					UINT16 usRoom;

					if ( InARoom( pSoldier->sGridNo, &usRoom ) && IN_BROTHEL( usRoom ) )
					{
						pSoldier->aiData.usActionData /= 3;
					}

				}
			}
		}
		else if (pSoldier->aiData.bAction == AI_ACTION_ABSOLUTELY_NONE)
		{
			pSoldier->aiData.bAction = AI_ACTION_NONE;
		}

	}

	// to get here, we MUST have an action selected, but not in progress...
	NPCDoesAct(pSoldier);

	// perform the chosen action
	pSoldier->aiData.bActionInProgress = ExecuteAction(pSoldier); // if started, mark us as busy
}
コード例 #24
0
ファイル: dlg_torrent.cpp プロジェクト: zilog80/taiga
LRESULT TorrentDialog::OnNotify(int idCtrl, LPNMHDR pnmh) {
  Feed* feed = Aggregator.Get(kFeedCategoryLink);
  if (!feed)
    return 0;

  // ListView control
  if (idCtrl == IDC_LIST_TORRENT) {
    switch (pnmh->code) {
      // Column click
      case LVN_COLUMNCLICK: {
        LPNMLISTVIEW lplv = (LPNMLISTVIEW)pnmh;
        int order = 1;
        if (lplv->iSubItem == list_.GetSortColumn()) order = list_.GetSortOrder() * -1;
        switch (lplv->iSubItem) {
          // Episode
          case 1:
            list_.Sort(lplv->iSubItem, order, ui::kListSortNumber, ui::ListViewCompareProc);
            break;
          // File size
          case 3:
            list_.Sort(lplv->iSubItem, order, ui::kListSortFileSize, ui::ListViewCompareProc);
            break;
          // Other columns
          default:
            list_.Sort(lplv->iSubItem, order, ui::kListSortDefault, ui::ListViewCompareProc);
            break;
        }
        break;
      }

      // Check/uncheck
      case LVN_ITEMCHANGED: {
        if (!list_.IsVisible()) break;
        LPNMLISTVIEW pnmv = reinterpret_cast<LPNMLISTVIEW>(pnmh);
        if (pnmv->uOldState != 0 && (pnmv->uNewState == 0x1000 || pnmv->uNewState == 0x2000)) {
          int checked_count = 0;
          for (int i = 0; i < list_.GetItemCount(); i++) {
            if (list_.GetCheckState(i)) checked_count++;
          }
          if (checked_count == 1) {
            DlgMain.ChangeStatus(L"Marked 1 torrent.");
          } else {
            DlgMain.ChangeStatus(L"Marked " + ToWstr(checked_count) + L" torrents.");
          }
          FeedItem* feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(pnmv->iItem));
          if (feed_item) {
            bool checked = list_.GetCheckState(pnmv->iItem) == TRUE;
            feed_item->state = checked ? kFeedItemSelected : kFeedItemDiscardedNormal;
          }
        }
        break;
      }

      // Double click
      case NM_DBLCLK: {
        if (list_.GetSelectedCount() > 0) {
          LPNMITEMACTIVATE lpnmitem = reinterpret_cast<LPNMITEMACTIVATE>(pnmh);
          if (lpnmitem->iItem == -1) break;
          FeedItem* feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(lpnmitem->iItem));
          if (feed_item)
            feed->Download(feed_item->index);
        }
        break;
      }

      // Right click
      case NM_RCLICK: {
        LPNMITEMACTIVATE lpnmitem = reinterpret_cast<LPNMITEMACTIVATE>(pnmh);
        if (lpnmitem->iItem == -1) break;
        FeedItem* feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(lpnmitem->iItem));
        if (feed_item) {
          std::wstring answer = ui::Menus.Show(GetWindowHandle(), 0, 0, L"TorrentListRightClick");
          if (answer == L"DownloadTorrent") {
            feed->Download(feed_item->index);
          } else if (answer == L"Info") {
            auto anime_id = feed_item->episode_data.anime_id;
            if (anime_id) {
              ShowDlgAnimeInfo(anime_id);
            } else {
              ExecuteAction(L"SearchAnime(" + feed_item->episode_data.title + L")");
            }
          } else if (answer == L"DiscardTorrent") {
            feed_item->state = kFeedItemDiscardedNormal;
            list_.SetCheckState(lpnmitem->iItem, FALSE);
            Aggregator.file_archive.push_back(feed_item->title);
          } else if (answer == L"DiscardTorrents") {
            auto anime_item = AnimeDatabase.FindItem(feed_item->episode_data.anime_id);
            if (anime_item) {
              for (int i = 0; i < list_.GetItemCount(); i++) {
                feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(i));
                if (feed_item && feed_item->episode_data.anime_id == anime_item->GetId()) {
                  feed_item->state = kFeedItemDiscardedNormal;
                  list_.SetCheckState(i, FALSE);
                }
              }
              Aggregator.filter_manager.AddFilter(
                  kFeedFilterActionDiscard, kFeedFilterMatchAll, kFeedFilterOptionDefault,
                  true, L"Discard \"" + anime_item->GetTitle() + L"\"");
              Aggregator.filter_manager.filters.back().AddCondition(
                  kFeedFilterElement_Meta_Id, kFeedFilterOperator_Equals,
                  ToWstr(anime_item->GetId()));
            }
          } else if (answer == L"SelectFansub") {
            int anime_id = feed_item->episode_data.anime_id;
            std::wstring group_name = feed_item->episode_data.group;
            if (anime::IsValidId(anime_id) && !group_name.empty()) {
              for (int i = 0; i < list_.GetItemCount(); i++) {
                feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(i));
                if (feed_item && !IsEqual(feed_item->episode_data.group, group_name)) {
                  feed_item->state = kFeedItemDiscardedNormal;
                  list_.SetCheckState(i, FALSE);
                }
              }
              anime::SetFansubFilter(anime_id, group_name);
            }
          } else if (answer == L"MoreTorrents") {
            Search(Settings[taiga::kTorrent_Discovery_SearchUrl], feed_item->episode_data.title);
          } else if (answer == L"SearchService") {
            ExecuteAction(L"SearchAnime(" + feed_item->episode_data.title + L")");
          }
        }
        break;
      }

      // Custom draw
      case NM_CUSTOMDRAW: {
        LPNMLVCUSTOMDRAW pCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pnmh);
        switch (pCD->nmcd.dwDrawStage) {
          case CDDS_PREPAINT:
            return CDRF_NOTIFYITEMDRAW;
          case CDDS_ITEMPREPAINT:
            return CDRF_NOTIFYSUBITEMDRAW;
          case CDDS_PREERASE:
          case CDDS_ITEMPREERASE:
            return CDRF_NOTIFYPOSTERASE;

          case CDDS_ITEMPREPAINT | CDDS_SUBITEM: {
            // Alternate background color
            if ((pCD->nmcd.dwItemSpec % 2) && !list_.IsGroupViewEnabled())
              pCD->clrTextBk = ChangeColorBrightness(GetSysColor(COLOR_WINDOW), -0.03f);
            FeedItem* feed_item = reinterpret_cast<FeedItem*>(pCD->nmcd.lItemlParam);
            if (feed_item) {
              if (Taiga.debug_mode) {
                // Change background color
                switch (feed_item->state) {
                  case kFeedItemDiscardedNormal:
                  case kFeedItemDiscardedInactive:
                  case kFeedItemDiscardedHidden:
                    pCD->clrTextBk = ui::kColorLightRed;
                    break;
                  case kFeedItemSelected:
                    pCD->clrTextBk = ui::kColorLightGreen;
                    break;
                  default:
                    pCD->clrTextBk = GetSysColor(COLOR_WINDOW);
                    break;
                }
              }
              // Change text color
              if (feed_item->state == kFeedItemDiscardedInactive) {
                pCD->clrText = GetSysColor(COLOR_GRAYTEXT);
              } else if (feed_item->episode_data.new_episode) {
                pCD->clrText = GetSysColor(pCD->iSubItem == 1 ? COLOR_HIGHLIGHT : COLOR_WINDOWTEXT);
              }
            }
            return CDRF_NOTIFYPOSTPAINT;
          }
        }
      }
    }
  }

  return 0;
}
コード例 #25
0
bool mitk::StateMachine::HandleEvent(StateEvent const* stateEvent)
{
  if (stateEvent == NULL)
    return false;

  if (m_CurrentStateVector.empty())
  {
    STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachine not initialized!\n";
    return false;//m_CurrentStateVector needs to be initialized!
  }

  if (m_TimeStep >= m_CurrentStateVector.size())
  {
    STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachine not initialized for this time step!\n";
    return false;
  }

  if (m_CurrentStateVector[m_TimeStep].IsNull())
  {
    STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachine not initialized with the right temporal information!\n";
    return false;//m_CurrentState needs to be initialized!
  }

  //get the Transition from m_CurrentState which waits for this EventId
  const Transition *tempTransition = m_CurrentStateVector[m_TimeStep]->GetTransition(stateEvent->GetId());
  if (tempTransition == NULL) //no transition in this state for that EventId
  {
    return false;
  }

  //get next State
  State *tempNextState = tempTransition->GetNextState();
  if (tempNextState == NULL) //wrong built up statemachine!
  {
    STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachinePattern not defined correctly!\n";
    return false;
  }

  //and ActionId to execute later on
  if ( m_CurrentStateVector[m_TimeStep]->GetId() != tempNextState->GetId() )//statechange only if there is a real statechange
  {
    if ( m_UndoEnabled )  //write to UndoMechanism if Undo is enabled
    {
      //UNDO for this statechange; since we directly change the state, we don't need the do-Operation in case m_UndoEnables == false
      StateTransitionOperation* doOp = new StateTransitionOperation(OpSTATECHANGE, tempNextState, m_TimeStep);
      StateTransitionOperation* undoOp = new StateTransitionOperation(OpSTATECHANGE, m_CurrentStateVector[m_TimeStep], m_TimeStep);
      OperationEvent *operationEvent = new OperationEvent(((mitk::OperationActor*)(this)), doOp, undoOp);
      m_UndoController->SetOperationEvent(operationEvent);
    }

    STATEMACHINE_DEBUG("StateChange")<<this->GetType()<<" from " << m_CurrentStateVector[m_TimeStep]->GetId() 
      << " " << m_CurrentStateVector[m_TimeStep]->GetName()
      <<" to " << tempNextState->GetId() <<" "<<tempNextState->GetName();

    //first following StateChange(or calling ExecuteOperation(tempNextStateOp)), then operation(action)
    m_CurrentStateVector[m_TimeStep] = tempNextState;
  }

  mitk::Transition::ActionVectorIterator actionIdIterator = tempTransition->GetActionBeginIterator();
  mitk::Transition::ActionVectorConstIterator actionIdIteratorEnd = tempTransition->GetActionEndIterator();
  bool ok = true;

  while ( actionIdIterator != actionIdIteratorEnd ) 
  {
    if ( !ExecuteAction(*actionIdIterator, stateEvent) )
    {
      ok = false;
    }
    actionIdIterator++;
  }
  return ok;
}
コード例 #26
0
ファイル: Movement.c プロジェクト: bowlofstew/ja2
void SoldierTriesToContinueAlongPath(SOLDIERTYPE *pSoldier)
{
	INT16 usNewGridNo,bAPCost;


	// turn off the flag now that we're going to do something about it...
	// ATE: USed to be redundent, now if called befroe NewDest can cause some side efects...
	// AdjustNoAPToFinishMove( pSoldier, FALSE );

	if (pSoldier->bNewSituation == IS_NEW_SITUATION)
	{
		CancelAIAction(pSoldier,DONTFORCE);
		return;
	}

	if (pSoldier->usActionData >= NOWHERE)
	{
		CancelAIAction(pSoldier,DONTFORCE);	
		return;
	}

	if (!NewOKDestination( pSoldier,pSoldier->usActionData, TRUE, pSoldier->bLevel ))
	{
		CancelAIAction(pSoldier,DONTFORCE);
		return;
	}

	if (IsActionAffordable(pSoldier))
	{
		if (pSoldier->bActionInProgress == FALSE)
		{
			// start a move that didn't even get started before...
			// hope this works...
			NPCDoesAct(pSoldier);

			// perform the chosen action
			pSoldier->bActionInProgress = ExecuteAction(pSoldier); // if started, mark us as busy
		}
		else
		{
			// otherwise we shouldn't have to do anything(?)
		}
	}
	else
	{
		CancelAIAction(pSoldier,DONTFORCE);
#ifdef TESTAI
		DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3, 
						String("Soldier (%d) HAS NOT ENOUGH AP to continue along path",pSoldier->ubID) );
#endif
	}

	usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( (UINT8)pSoldier->usPathingData[ pSoldier->usPathIndex ] ) );

	// Find out how much it takes to move here!
	bAPCost = EstimateActionPointCost( pSoldier, usNewGridNo, (INT8)pSoldier->usPathingData[ pSoldier->usPathIndex ], pSoldier->usUIMovementMode, (INT8) pSoldier->usPathIndex, (INT8) pSoldier->usPathDataSize );

	if (pSoldier->bActionPoints >= bAPCost)
	{
		// seems to have enough points...
		NewDest(pSoldier,usNewGridNo);
		// maybe we didn't actually start the action last turn...
		pSoldier->bActionInProgress = TRUE;
#ifdef TESTAI
		DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3, 
						String("Soldier (%d) continues along path",pSoldier->ubID) );
#endif
	}
	else
	 {
		CancelAIAction(pSoldier,DONTFORCE);
#ifdef TESTAI
		DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3, 
						String("Soldier (%d) HAS NOT ENOUGH AP to continue along path",pSoldier->ubID) );
#endif
	 }
}											
コード例 #27
0
ファイル: dlg_torrent.cpp プロジェクト: Greathood/taiga
LRESULT TorrentDialog::OnNotify(int idCtrl, LPNMHDR pnmh) {
  Feed* feed = Aggregator.Get(FEED_CATEGORY_LINK);
  if (!feed) return 0;

  // ListView control
  if (idCtrl == IDC_LIST_TORRENT) {
    switch (pnmh->code) {
      // Column click
      case LVN_COLUMNCLICK: {
        LPNMLISTVIEW lplv = (LPNMLISTVIEW)pnmh;
        int order = 1;
        if (lplv->iSubItem == list_.GetSortColumn()) order = list_.GetSortOrder() * -1;
        switch (lplv->iSubItem) {
          // Episode
          case 1:
            list_.Sort(lplv->iSubItem, order, LIST_SORTTYPE_NUMBER, ListViewCompareProc);
            break;
          // File size
          case 3:
            list_.Sort(lplv->iSubItem, order, LIST_SORTTYPE_FILESIZE, ListViewCompareProc);
            break;
          // Other columns
          default:
            list_.Sort(lplv->iSubItem, order, LIST_SORTTYPE_DEFAULT, ListViewCompareProc);
            break;
        }
        break;
      }

      // Check/uncheck
      case LVN_ITEMCHANGED: {
        if (!list_.IsVisible()) break;
        LPNMLISTVIEW pnmv = reinterpret_cast<LPNMLISTVIEW>(pnmh);
        if (pnmv->uOldState != 0 && (pnmv->uNewState == 0x1000 || pnmv->uNewState == 0x2000)) {
          int checked_count = 0;
          for (int i = 0; i < list_.GetItemCount(); i++) {
            if (list_.GetCheckState(i)) checked_count++;
          }
          if (checked_count == 1) {
            MainDialog.ChangeStatus(L"Marked 1 torrent.");
          } else {
            MainDialog.ChangeStatus(L"Marked " + ToWstr(checked_count) + L" torrents.");
          }
          FeedItem* feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(pnmv->iItem));
          if (feed_item) {
            bool checked = list_.GetCheckState(pnmv->iItem) == TRUE;
            feed_item->state = checked ? FEEDITEM_SELECTED : FEEDITEM_DISCARDED_NORMAL;
          }
        }
        break;
      }

      // Double click
      case NM_DBLCLK: {
        if (list_.GetSelectedCount() > 0) {
          LPNMITEMACTIVATE lpnmitem = reinterpret_cast<LPNMITEMACTIVATE>(pnmh);
          if (lpnmitem->iItem == -1) break;
          FeedItem* feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(lpnmitem->iItem));
          if (feed_item) {
            feed->Download(feed_item->index);
          }
        }
        break;
      }

      // Right click
      case NM_RCLICK: {
        LPNMITEMACTIVATE lpnmitem = reinterpret_cast<LPNMITEMACTIVATE>(pnmh);
        if (lpnmitem->iItem == -1) break;
        FeedItem* feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(lpnmitem->iItem));
        if (feed_item) {
          wstring answer = UI.Menus.Show(m_hWindow, 0, 0, L"TorrentListRightClick");
          if (answer == L"DownloadTorrent") {
            feed->Download(feed_item->index);
          } else if (answer == L"Info") {
            auto anime_id = feed_item->episode_data.anime_id;
            if (anime_id) {
              ExecuteAction(L"Info", 0, anime_id);
            } else {
              ExecuteAction(L"SearchAnime(" + feed_item->episode_data.title + L")");
            }
          } else if (answer == L"DiscardTorrent") {
            feed_item->state = FEEDITEM_DISCARDED_NORMAL;
            list_.SetCheckState(lpnmitem->iItem, FALSE);
            Aggregator.file_archive.push_back(feed_item->title);
          } else if (answer == L"DiscardTorrents") {
            auto anime_item = AnimeDatabase.FindItem(feed_item->episode_data.anime_id);
            if (anime_item) {
              for (int i = 0; i < list_.GetItemCount(); i++) {
                feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(i));
                if (feed_item && feed_item->episode_data.anime_id == anime_item->GetId()) {
                  feed_item->state = FEEDITEM_DISCARDED_NORMAL;
                  list_.SetCheckState(i, FALSE);
                }
              }
              Aggregator.filter_manager.AddFilter(
                FEED_FILTER_ACTION_DISCARD, FEED_FILTER_MATCH_ALL, FEED_FILTER_OPTION_DEFAULT,
                true, L"Discard \"" + anime_item->GetTitle() + L"\"");
              Aggregator.filter_manager.filters.back().AddCondition(
                FEED_FILTER_ELEMENT_META_ID, FEED_FILTER_OPERATOR_EQUALS, 
                ToWstr(anime_item->GetId()));
            }
          } else if (answer == L"SelectFansub") {
            int anime_id = feed_item->episode_data.anime_id;
            wstring group_name = feed_item->episode_data.group;
            if (anime_id > anime::ID_UNKNOWN && !group_name.empty()) {
              for (int i = 0; i < list_.GetItemCount(); i++) {
                feed_item = reinterpret_cast<FeedItem*>(list_.GetItemParam(i));
                if (feed_item && !IsEqual(feed_item->episode_data.group, group_name)) {
                  feed_item->state = FEEDITEM_DISCARDED_NORMAL;
                  list_.SetCheckState(i, FALSE);
                }
              }
              anime::SetFansubFilter(anime_id, group_name);
            }
          } else if (answer == L"MoreTorrents") {
            Search(Settings.RSS.Torrent.search_url, feed_item->episode_data.title);
          } else if (answer == L"SearchMAL") {
            ExecuteAction(L"SearchAnime(" + feed_item->episode_data.title + L")");
          }
        }
        break;
      }

      // Custom draw
      case NM_CUSTOMDRAW: {
        LPNMLVCUSTOMDRAW pCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pnmh);
        switch (pCD->nmcd.dwDrawStage) {
          case CDDS_PREPAINT:
            return CDRF_NOTIFYITEMDRAW;
          case CDDS_ITEMPREPAINT:
            return CDRF_NOTIFYSUBITEMDRAW;
          case CDDS_PREERASE:
          case CDDS_ITEMPREERASE:
            return CDRF_NOTIFYPOSTERASE;

          case CDDS_ITEMPREPAINT | CDDS_SUBITEM: {
            // Alternate background color
            if ((pCD->nmcd.dwItemSpec % 2) && !list_.IsGroupViewEnabled())
              pCD->clrTextBk = ChangeColorBrightness(GetSysColor(COLOR_WINDOW), -0.03f);
            FeedItem* feed_item = reinterpret_cast<FeedItem*>(pCD->nmcd.lItemlParam);
            if (feed_item) {
#ifdef _DEBUG
              // Change background color
              switch (feed_item->state) {
                case FEEDITEM_DISCARDED_NORMAL:
                case FEEDITEM_DISCARDED_INACTIVE:
                case FEEDITEM_DISCARDED_HIDDEN:
                  pCD->clrTextBk = theme::COLOR_LIGHTRED;
                  break;
                case FEEDITEM_SELECTED:
                  pCD->clrTextBk = theme::COLOR_LIGHTGREEN;
                  break;
                default:
                  pCD->clrTextBk = GetSysColor(COLOR_WINDOW);
                  break;
              }
#endif
              // Change text color
              if (feed_item->state == FEEDITEM_DISCARDED_INACTIVE) {
                pCD->clrText = GetSysColor(COLOR_GRAYTEXT);
              } else if (feed_item->episode_data.new_episode) {
                pCD->clrText = GetSysColor(pCD->iSubItem == 1 ? COLOR_HIGHLIGHT : COLOR_WINDOWTEXT);
              }
            }
            return CDRF_NOTIFYPOSTPAINT;
          }
        }
      }
    }
  }

  return 0;
}
コード例 #28
0
AJSVC_ServiceStatus GeneratedMessageProcessor(AJ_BusAttachment* bus, AJ_Message* msg, AJ_Status* msgStatus)
{
    AJSVC_ServiceStatus AJSVC_ServiceStatus = AJSVC_SERVICE_STATUS_HANDLED;

    switch (msg->msgId) {
        GET_WIDGET_VALUE_CASES
        *msgStatus = AJ_BusPropGet(msg, AJCPS_GetWidgetProperty, NULL);
        break;

        GET_WIDGET_ALL_VALUE_CASES
        *msgStatus = AJCPS_GetAllWidgetProperties(msg, msg->msgId);
        break;

        GET_ROOT_VALUE_CASES
        *msgStatus = AJ_BusPropGet(msg, AJCPS_GetRootProperty, NULL);
        break;

        GET_ROOT_ALL_VALUE_CASES
        *msgStatus = AJCPS_GetAllRootProperties(msg, msg->msgId);
        break;

        SET_VALUE_CASES
        {
            SetValueContext context;
            context.sender = msg->sender;
            context.numSignals = 0;
            *msgStatus = AJ_BusPropSet(msg, SetValueProperty, &context);
            if (*msgStatus == AJ_OK && context.numSignals != 0) {
                uint16_t indx;
                for (indx = 0; indx < context.numSignals; indx++) {
                    *msgStatus = AJCPS_SendPropertyChangedSignal(bus, context.signals[indx], AJCPS_GetCurrentSessionId());
                }
            }
        }
        break;

        ACTION_CASES
        {
            ExecuteActionContext context;
            context.numSignals = 0;
            *msgStatus = ExecuteAction(msg, msg->msgId, &context);
            if (*msgStatus == AJ_OK && context.numSignals != 0) {
                uint16_t indx;
                for (indx = 0; indx < context.numSignals; indx++) {
                    if (context.signals[indx].signalType == SIGNAL_TYPE_DATA_CHANGED) {
                        *msgStatus = AJCPS_SendPropertyChangedSignal(bus, context.signals[indx].signalId, AJCPS_GetCurrentSessionId());
                    } else if (context.signals[indx].signalType == SIGNAL_TYPE_DISMISS) {
                        *msgStatus = AJCPS_SendDismissSignal(bus, context.signals[indx].signalId, AJCPS_GetCurrentSessionId());
                    }
                }
            }
        }
        break;

        GET_URL_CASES
        *msgStatus = AJCPS_SendRootUrl(msg, msg->msgId);
        break;

    case AJ_SIGNAL_SESSION_LOST:
        break;

    default:
        AJSVC_ServiceStatus = AJSVC_SERVICE_STATUS_NOT_HANDLED;
        break;
    }

    return AJSVC_ServiceStatus;
}
コード例 #29
0
ファイル: stm.c プロジェクト: alshorin/projects
int STM_Execute1( STM_StateMachine *sm, STM_StateMachine **currSm )
{
	int			action;			/* Action to execute.						*/
	STM_Input	input;			/* Input being processed.					*/
	int			nextState;		/* Next state to change to.					*/
	uint8_t    *stateData;  	/* Ptr to state data for current state.		*/
	STM_StateMachine   *svSm;	/* Saved value of STM_CurrStateMachine		*/

	ASSERT( sm != NULL );
	ASSERT( sm->magic == STM_MAGIC );

	if (( input = GetInput( sm )) == STM_INPUT_NONE )
	{
		/*
		 * No input, indicate that we didn't do anything
		 */

		return FALSE;
	}

	/*
	 * Set the global state machine variable, so that actions which use it
	 * can access this state machine. Save the old value off so that action
	 * routines can execute other state machines.
	 */

	if ( currSm != NULL )
	{
		svSm = *currSm;
		*currSm = sm;
	}

	/*
	 * We've got an input, run it through the state machine
	 */

	DBG_INPUT( "STM %s: processing input %s (%d)\n",
				sm->name, sm->currInputStr, sm->currInput );

	stateData = &sm->stateData[ sm->currState * STM_BytesPerState( sm )];

	nextState = stateData[ STM_NextStateOffset( input )];

	/*
	 * Exit the old state
	 */

	if ( nextState != sm->currState )
	{
		int		exitAction;

		/*
		 * We're leaving the old state, call the exit routine if one is
		 * defined
		 */

		exitAction = stateData[ STM_ExitOffset() ];
		ExecuteAction( sm, exitAction, "exit " );
	}

	/*
	 * Call the action routine
	 */

	action = stateData[ STM_ActionOffset( input )];
	ExecuteAction( sm, action, "" );

	if ( nextState != sm->currState )
	{
		int		enterAction;

		/*
		 * Enter the new state
		 */
	
		DBG_STATE( "STM %s: Changing states from %s (%d) to %s (%d)\n",
				   sm->name,
				   sm->stateStr[ sm->currState ], sm->currState,
				   sm->stateStr[ nextState ], nextState );

		sm->currState = nextState;
		stateData = &sm->stateData[ sm->currState * STM_BytesPerState( sm )];

		/*
		 * We're entering the new state, call the enter routine if one is
		 * defined
		 */

		enterAction = stateData[ STM_EnterOffset() ];
		ExecuteAction( sm, enterAction, "enter " );
	}

	if ( currSm != NULL )
	{
		*currSm = svSm;
	}

	/*
	 * We processed an input, tell the caller
	 */

	sm->currInput = STM_INPUT_NONE;
#if defined( STM_DEBUG )
	sm->currInputStr = "- None -";
#endif

	return TRUE;

} // STM_Execute1
コード例 #30
0
ファイル: evaluator.cpp プロジェクト: karkuspeter/CS6244
bool Evaluator::RunStep(int step, int round) {
	if (target_finish_time_ != -1 && get_time_second() > target_finish_time_) {
		if (!Globals::config.silence && out_)
			*out_ << "Exit. (Total time "
				<< (get_time_second() - EvalLog::curr_inst_start_time)
				<< "s exceeded time limit of "
				<< (target_finish_time_ - EvalLog::curr_inst_start_time) << "s)"
				<< endl
				<< "Total time: Real / CPU = "
				<< (get_time_second() - EvalLog::curr_inst_start_time) << " / "
				<< (double(clock() - start_clockt_) / CLOCKS_PER_SEC) << "s"
				<< endl;
		exit(1);
	}

	double step_start_t = get_time_second();

	double start_t = get_time_second();
	int action = solver_->Search().action;
	double end_t = get_time_second();
	logi << "[RunStep] Time spent in " << typeid(*solver_).name()
		<< "::Search(): " << (end_t - start_t) << endl;

	double reward;
	OBS_TYPE obs;
	start_t = get_time_second();
	bool terminal = ExecuteAction(action, reward, obs);
	end_t = get_time_second();
	logi << "[RunStep] Time spent in ExecuteAction(): " << (end_t - start_t)
		<< endl;

	start_t = get_time_second();
	*out_ << "-----------------------------------Round " << round
				<< " Step " << step << "-----------------------------------"
				<< endl;
	if (!Globals::config.silence && out_) {
		*out_ << "- Action = ";
		model_->PrintAction(action, *out_);
	}

	if (state_ != NULL) {
		if (!Globals::config.silence && out_) {
			*out_ << "- State:\n";
			model_->PrintState(*state_, *out_);
		}
	}

	if (!Globals::config.silence && out_) {
		*out_ << "- Observation = ";
		model_->PrintObs(*state_, obs, *out_);
	}

	if (state_ != NULL) {
		if (!Globals::config.silence && out_)
			*out_ << "- ObsProb = " << model_->ObsProb(obs, *state_, action)
				<< endl;
	}

	ReportStepReward();
	end_t = get_time_second();

	double step_end_t;
	if (terminal) {
		step_end_t = get_time_second();
		logi << "[RunStep] Time for step: actual / allocated = "
			<< (step_end_t - step_start_t) << " / " << EvalLog::allocated_time
			<< endl;
		if (!Globals::config.silence && out_)
			*out_ << endl;
		step_++;
		return true;
	}

	*out_<<endl;

	start_t = get_time_second();
	solver_->Update(action, obs);
	end_t = get_time_second();
	logi << "[RunStep] Time spent in Update(): " << (end_t - start_t) << endl;

	step_++;
	return false;
}