Exemple #1
0
int InputProcessor::ProcessInput(const char *input, const int bytes)
{
	int i, needed = 0;

	/* Process overriding key combinations first */
	i = Process(Bindable_Override, input, bytes);
	if (i > 0) return i;
	if (i < 0) needed = i;
	
	/* Hand of input to a child */
	if (inputchild)
		i = inputchild->ProcessInput(input, bytes);
	if (i > 0) return i;
	if (i < 0) needed = i;

	/* Process other key combinations */
	i = Process(Bindable_Normal, input, bytes);
	if (i > 0) return i;
	if (i < 0) needed = i;

	/* Do non-combo input processing */
	i = ProcessInputText(input, bytes);
	if (i > 0) return i;
	if (i < 0) needed = i;

	return needed;
}
	virtual void SetInputText(FString InInputText, FString InPlainText, bool InForceDisplayTip) override
	{
		this->InputText = InInputText;
		if(InputText == TEXT("/") && !InForceDisplayTip)
		{
			PauseTip = true;
			TipDisplayTime = 1;
			if (!TickDelegate.IsBound())
			{
				TickDelegate = FTickerDelegate::CreateSP(this, &FFriendsChatMarkupServiceImpl::HandleTick);
			}
			TickerHandle = FTicker::GetCoreTicker().AddTicker(TickDelegate);
		}
		else
		{
			PauseTip = false;
			TSharedPtr<FProcessedInput> ValidatedInput = ProcessInputText(InputText, InPlainText);
			if(ValidatedInput.IsValid() && ValidatedInput->MatchedFriends.Num() > 0)
			{
				SetSelectedFriend(ValidatedInput->MatchedFriends[0]);
				ForceDisplayToolTips = false;
			}

			if(InputText.StartsWith("/") && (!ValidatedInput.IsValid() || ValidatedInput->NeedsTip))
			{
				ForceDisplayToolTips = true;
			}
			else if(InputText.IsEmpty() || (ValidatedInput.IsValid() && !ValidatedInput->NeedsTip))
			{
				ForceDisplayToolTips = false;
			}
			GenerateTips();
		}
	}
	bool ValidateSlashMarkup(const FString NewMessage, const FString PlainText)
	{
		TSharedPtr<FProcessedInput> ValidatedInput = ProcessInputText(NewMessage, PlainText);

		if (ValidatedInput.IsValid())
		{
			if (ValidatedInput->ChatChannel == EChatMessageType::Global)
			{
				if(ValidatedInput->Message.IsEmpty())
				{
					NavigationService->ChangeChatChannel(EChatMessageType::Global);
				}
				else
				{
					CommunicationService->SendRoomMessage(FString(), ProcessedInput->Message);
				}
			}
			else if (ValidatedInput->ChatChannel == EChatMessageType::Whisper)
			{
				if(ValidatedInput->ValidFriends.Num())
				{
					if(ProcessedInput->Message.IsEmpty())
					{
						// Sending the selected outgoing friend
						NavigationService->SetOutgoingChatFriend(ProcessedInput->ValidFriends[0]->GetFriendItem());
						NavigationService->ChangeChatChannel(EChatMessageType::Whisper);
					}
					else
					{
						CommunicationService->SendPrivateMessage(ProcessedInput->ValidFriends[0]->GetFriendItem()->GetUniqueID(), FText::FromString(ProcessedInput->Message));
						NavigationService->ChangeViewChannel(EChatMessageType::Whisper);
					}
				}
				else
				{
					// Change outgoing chat channel to last chat friend
					NavigationService->ChangeChatChannel(EChatMessageType::Whisper);
				}
			}
			else if (ValidatedInput->ChatChannel == EChatMessageType::Custom)
			{
				NavigationService->ChangeChatChannel(EChatMessageType::Custom);
			}
			else if(ValidatedInput->ChatChannel == EChatMessageType::Invalid)
			{
				// Handle bad text
			}
			else
			{
				NavigationService->ChangeChatChannel(ValidatedInput->ChatChannel);
			}
			return true;
		}
		return false;
	}
bool InputProcessor::ProcessInput(const TermKeyKey& key)
{
  // process overriding key combinations first
  if (Process(BINDABLE_OVERRIDE, key))
    return true;

  // hand of input to a child
  if (input_child && input_child->ProcessInput(key))
    return true;

  // process other key combinations
  if (Process(BINDABLE_NORMAL, key))
    return true;

  // do non-combo input processing
  TermKeyKey keyn = Keys::RefineKey(key);
  if (keyn.type == TERMKEY_TYPE_UNICODE && ProcessInputText(keyn))
    return true;

  return false;
}