Example #1
0
void AGameHUD::DrawSelect()
{
	ABaseBuilderPlayerController * Player = Cast<ABaseBuilderPlayerController>(GetWorld()->GetFirstPlayerController());

	if (Player->SelectedBuilding != nullptr)
	{
		FString Description = Player->SelectedBuilding->GetDefaultObject<ABaseBuilding>()->Description;

		FString Text = "Description: " + Description;

		FText SomeText = FText::FromString(Text);

		float XPosition = Canvas->ClipX *0.01;
		float YPosition = Canvas->ClipY*0.85f;

		FLinearColor TheFontColour = FLinearColor(0.0f, 0.0f, 0.0f);
		FCanvasTextItem NewText(FVector2D(XPosition, YPosition), SomeText, Font, TheFontColour);

		//Text Scale
		NewText.Scale.Set(1, 1);

		//Draw
		Canvas->DrawItem(NewText);
	}

}
Example #2
0
/// Returns the size required by a call to RenderText if it were to be done now.
Vector2f TextFont::CalculateRenderSizeUnits(Text & text)
{
	if (text.Length() < 1)
	{
		return Vector2f(scale[0], scale[1]);
	}
	// Set starting variables.
	NewText(text);

	// Go up to and include the NULL-sign!
	for (int i = 0; i < text.ArraySize(); ++i)
	{
		currentCharIndex = i;
		currentChar = text.c_str()[i];
		if (currentChar == '\0')
		{
			EndText();
			break;
		}
		nextChar = text.c_str()[i + 1];
		if (EvaluateSpecialChar())
			continue;
		StartChar();
		// RenderChar();
		EndChar();
		lastChar = currentChar;
	}
	return Vector2f (maxRowSizeX, AbsoluteValue(pivotPoint.y));
}
Example #3
0
void InitGame(Game* game) {
	NewApple(game);
	NewMap(game);
	NewSnake(game);
	NewText(game);
	NewConsts(game);
	game->state = STARTGAME;
}
Example #4
0
// This is called every time WriteChatColor is called by MQ2Main or any plugin, 
// IGNORING FILTERS, IF YOU NEED THEM MAKE SURE TO IMPLEMENT THEM. IF YOU DONT 
// CALL CEverQuest::dsp_chat MAKE SURE TO IMPLEMENT EVENTS HERE 
PLUGIN_API DWORD OnWriteChatColor(PCHAR Line, DWORD Color, DWORD Filter) 
{ 
    //DebugSpewAlways("MQ2ChatWnd::OnWriteChatColor(%s)",Line);

	if (!MQChatWnd) 
    { 
        if (gGameState==GAMESTATE_INGAME) 
        { 
            SetGameState(gGameState); 
        } 
        if (!MQChatWnd) 
        { 
            return 0; 
        } 
    } 
    MQChatWnd->dShow=1; 
    PFILTER pFilter=gpFilters; 
    while (pFilter) 
    { 
        if (!pFilter->pEnabled || (*pFilter->pEnabled)) 
        { 
            if (!_strnicmp(Line,pFilter->FilterText,pFilter->Length)) 
            { 
                return 0; 
            } 
        } 
        pFilter = pFilter->pNext; 
    } 
    Color=pChatManager->GetRGBAFromIndex(Color); 
    CHAR szProcessed[MAX_STRING]; 
	
	pPlugins;
    MQToSTML(Line,szProcessed,MAX_STRING,Color); 
	pPlugins;
    strcat_s(szProcessed,"<br>"); 
    CXStr NewText(szProcessed); 
    DebugTry(ConvertItemTags(NewText,FALSE)); 
    ChatBuffer *pNewBuffer = new ChatBuffer; 
    GetCXStr(NewText.Ptr,pNewBuffer->Text,MAX_STRING); 
    pNewBuffer->pPrev=pPendingChatTail; 
    pNewBuffer->pNext=0; 
    if (pPendingChatTail) 
    { 
        pPendingChatTail->pNext=pNewBuffer; 
    } 
    else 
    { 
        pPendingChat=pNewBuffer; 
    } 
    pPendingChatTail=pNewBuffer; 
    PendingChatLines++; 
    return 0; 
} 
Example #5
0
CDeviceViewText *CDeviceView::AddText(
	HFONT f, COLORREF t, COLORREF b, const POINT &p, LPCTSTR text)
{
	CDeviceViewText *pText = NewText();
	if (!pText)
		return NULL;

	pText->SetLook(f, t, b);
	pText->SetPosition(p);
	pText->SetTextAndResizeTo(text);

	return pText;
}
Example #6
0
CDeviceViewText *CDeviceView::AddText(
	HFONT f, COLORREF t, COLORREF b, const RECT &r, LPCTSTR text)
{
	CDeviceViewText *pText = NewText();
	if (!pText)
		return NULL;

	pText->SetLook(f, t, b);
	pText->SetRect(r);
	pText->SetText(text);

	return pText;
}
Example #7
0
CDeviceViewText *CDeviceView::AddWrappedLineOfText(
	HFONT f, COLORREF t, COLORREF b, LPCTSTR text)
{
	CDeviceViewText *pText = NewText();
	if (!pText)
		return NULL;

	pText->SetLook(f, t, b);
	pText->SetPosition(m_ptNextWLOText);
	pText->SetTextAndResizeToWrapped(text);
	
	m_ptNextWLOText.y += pText->GetHeight();

	return pText;
}
void ConsoleService(bool Broadcast, unsigned int MSG, void *lpData)
{
    if (MSG != CONSOLE_OUTPUT_WITHCODES) {
        return;
    }
    // same as OnWriteChatColor
    if (!MQChatWnd) {
        EQGamestateService(false, GAMESTATESERVICE_CHANGED, (void*)gGameState);
        if (!MQChatWnd) {
            return;
        }
    }
    MQChatWnd->dShow = 1;

    PCHAR pConsOutput = (PCHAR)lpData;
    PFILTER pFilter = gpFilters;

    while (pFilter) {
        if (!pFilter->pEnabled || (*pFilter->pEnabled)) {
            if (!strnicmp(pConsOutput, pFilter->FilterText, pFilter->Length)) {
                return;
            }
        }
        pFilter = pFilter->pNext;
    }
    DWORD Color = pChatManager->GetRGBAFromIndex(USERCOLOR_DEFAULT);

    CHAR szProcessed[MAX_STRING];
    MQToSTML(pConsOutput, szProcessed, MAX_STRING, Color);
    strcat(szProcessed,"<br>");
    CXStr NewText(szProcessed);
    DebugTry(ConvertItemTags(NewText, 0));

    CLock L(&ChatS,1);

    ChatBuffer *pNewBuffer = new ChatBuffer;
    GetCXStr(NewText.Ptr, pNewBuffer->Text, MAX_STRING);
    pNewBuffer->pPrev = pPendingChatTail;
    pNewBuffer->pNext = 0;
    if (pPendingChatTail) {
        pPendingChatTail->pNext = pNewBuffer;
    }
    else {
        pPendingChat = pNewBuffer;
    }
    pPendingChatTail = pNewBuffer;
    PendingChatLines++;
}
Example #9
0
void AGameHUD::DrawResources()
{
	ABaseBuilderPlayerController * Player = Cast<ABaseBuilderPlayerController>(GetWorld()->GetFirstPlayerController());

	int Resources = Player->Money;

	FString Text = "Resources: " + FString::SanitizeFloat(Resources);

	FText SomeText = FText::FromString(Text);

	float XPosition = Canvas->ClipX *0.01;
	float YPosition = Canvas->ClipY*0.05f;

	FLinearColor TheFontColour = FLinearColor(0.0f, 0.0f, 0.0f);
	FCanvasTextItem NewText(FVector2D(XPosition, YPosition), SomeText, Font, TheFontColour);

	//Text Scale
	NewText.Scale.Set(1, 1);

	//Draw
	Canvas->DrawItem(NewText);
}
Example #10
0
void AGameHUD::DrawHealth()
{
	ABaseBuilderPlayerController * Player = Cast<ABaseBuilderPlayerController>(GetWorld()->GetFirstPlayerController());
	if (Player->OwnBase != nullptr)
	{
		int Health = Cast<ABaseBuilding>(Player->OwnBase)->Health;

		FString Text = "Health: " + FString::SanitizeFloat(Health);

		FText SomeText = FText::FromString(Text);

		float XPosition = Canvas->ClipX*0.85f;
		float YPosition = Canvas->ClipY*0.1f;

		FLinearColor TheFontColour = FLinearColor(0.0f, 0.0f, 0.0f);
		FCanvasTextItem NewText(FVector2D(XPosition, YPosition), SomeText, Font, TheFontColour);

		//Text Scale
		NewText.Scale.Set(1, 1);

		//Draw
		Canvas->DrawItem(NewText);
	}
}
Example #11
0
void ITextRenderer::NewText(unsigned int ID, const std::string& str, int x, int y, float scale, float width, ArgbColor color) {
	NewText(ID, CodeConv::ANSItoWIDE(str), x, y, scale, width, color);
}
UObject* UObjectPropertyBase::FindImportedObject( const UProperty* Property, UObject* OwnerObject, UClass* ObjectClass, UClass* RequiredMetaClass, const TCHAR* Text, uint32 PortFlags/*=0*/ )
{
	UObject*	Result = NULL;
	check( ObjectClass->IsChildOf(RequiredMetaClass) );

	bool AttemptNonQualifiedSearch = (PortFlags & PPF_AttemptNonQualifiedSearch) != 0; 

	// if we are importing default properties, first look for a matching subobject by
	// looking through the archetype chain at each outer and stop once the outer chain reaches the owning class's default object
	if (PortFlags & PPF_ParsingDefaultProperties)
	{
		for (UObject* SearchStart = OwnerObject; Result == NULL && SearchStart != NULL; SearchStart = SearchStart->GetOuter())
		{
			UObject* ScopedSearchRoot = SearchStart;
			while (Result == NULL && ScopedSearchRoot != NULL)
			{
				Result = StaticFindObject(ObjectClass, ScopedSearchRoot, Text);
				// don't think it's possible to get a non-subobject here, but it doesn't hurt to check
				if (Result != NULL && !Result->IsTemplate(RF_ClassDefaultObject))
				{
					Result = NULL;
				}

				ScopedSearchRoot = ScopedSearchRoot->GetArchetype();
			}
			if (SearchStart->HasAnyFlags(RF_ClassDefaultObject))
			{
				break;
			}
		}
	}
	
	// if we have a parent, look in the parent, then it's outer, then it's outer, ... 
	// this is because exported object properties that point to objects in the level aren't
	// fully qualified, and this will step up the nested object chain to solve any name
	// collisions within a nested object tree
	UObject* ScopedSearchRoot = OwnerObject;
	while (Result == NULL && ScopedSearchRoot != NULL)
	{
		Result = StaticFindObject(ObjectClass, ScopedSearchRoot, Text);
		// disallow class default subobjects here while importing defaults
		// this prevents the use of a subobject name that doesn't exist in the scope of the default object being imported
		// from grabbing some other subobject with the same name and class in some other arbitrary default object
		if (Result != NULL && (PortFlags & PPF_ParsingDefaultProperties) && Result->IsTemplate(RF_ClassDefaultObject))
		{
			Result = NULL;
		}

		ScopedSearchRoot = ScopedSearchRoot->GetOuter();
	}

	if (Result == NULL)
	{
		// attempt to find a fully qualified object
		Result = StaticFindObject(ObjectClass, NULL, Text);

		if (Result == NULL)
		{
			// match any object of the correct class whose path contains the specified path
			Result = StaticFindObject(ObjectClass, ANY_PACKAGE, Text);
			// disallow class default subobjects here while importing defaults
			if (Result != NULL && (PortFlags & PPF_ParsingDefaultProperties) && Result->IsTemplate(RF_ClassDefaultObject))
			{
				Result = NULL;
			}
		}
	}

	// if we haven;t found it yet, then try to find it without a qualified name
	if (!Result)
	{
		const TCHAR* Dot = FCString::Strrchr(Text, '.');
		if (Dot && AttemptNonQualifiedSearch)
		{
			// search with just the object name
			Result = FindImportedObject(Property, OwnerObject, ObjectClass, RequiredMetaClass, Dot + 1);
		}
		FString NewText(Text);
		// if it didn't have a dot, then maybe they just gave a uasset package name
		if (!Dot && !Result)
		{
			int32 LastSlash = NewText.Find(TEXT("/"), ESearchCase::CaseSensitive, ESearchDir::FromEnd);
			if (LastSlash >= 0)
			{
				NewText += TEXT(".");
				NewText += (Text + LastSlash + 1);
				Dot = FCString::Strrchr(*NewText, '.');
			}
		}
		// If we still can't find it, try to load it. (Only try to load fully qualified names)
		if(!Result && Dot)
		{
#if USE_CIRCULAR_DEPENDENCY_LOAD_DEFERRING
			FLinkerLoad* Linker = (OwnerObject != nullptr) ? OwnerObject->GetClass()->GetLinker() : nullptr;
			const bool bDeferAssetImports = (Linker != nullptr) && (Linker->LoadFlags & LOAD_DeferDependencyLoads);

			if (bDeferAssetImports)
			{
				Result = Linker->RequestPlaceholderValue(ObjectClass, Text);
			}
			
			if (Result == nullptr)
#endif // USE_CIRCULAR_DEPENDENCY_LOAD_DEFERRING
			{
				uint32 LoadFlags = LOAD_NoWarn | LOAD_FindIfFail;

				UE_LOG(LogProperty, Verbose, TEXT("FindImportedObject is attempting to import [%s] (class = %s) with StaticLoadObject"), Text, *GetFullNameSafe(ObjectClass));
				Result = StaticLoadObject(ObjectClass, NULL, Text, NULL, LoadFlags, NULL);

#if USE_DEFERRED_DEPENDENCY_CHECK_VERIFICATION_TESTS
				check(!bDeferAssetImports || !Result || !FBlueprintSupport::IsInBlueprintPackage(Result));
#endif // USE_DEFERRED_DEPENDENCY_CHECK_VERIFICATION_TESTS
			}
		}
	}

	// if we found an object, and we have a parent, make sure we are in the same package if the found object is private, unless it's a cross level property
	if (Result && !Result->HasAnyFlags(RF_Public) && OwnerObject && Result->GetOutermost() != OwnerObject->GetOutermost())
	{
		const UObjectPropertyBase* ObjectProperty = dynamic_cast<const UObjectPropertyBase*>(Property);
		if ( !ObjectProperty || !ObjectProperty->AllowCrossLevel())
		{
			UE_LOG(LogProperty, Warning, TEXT("Illegal TEXT reference to a private object in external package (%s) from referencer (%s).  Import failed..."), *Result->GetFullName(), *OwnerObject->GetFullName());
			Result = NULL;
		}
	}

	check(!Result || Result->IsA(RequiredMetaClass));
	return Result;
}
Example #13
0
/// Renders text ^^
void TextFont::RenderText(Text & text, GraphicsState & graphicsState)
{
	// Set starting variables.
	NewText(text);

	/// One color for all text?
	this->SetColor(text.color);
	
	/// Save old shader!
	Shader * oldShader = ActiveShader();
	// Load shader, set default uniform values, etc.
	if (!PrepareForRender())
		return;

	/// Sort the carets in order to render selected text properly.
	int min, max;
	if (text.caretPosition < text.previousCaretPosition)
	{
		min = text.caretPosition;
		max = text.previousCaretPosition;
	}
	else 
	{
		max = text.caretPosition;
		min = text.previousCaretPosition;
	}

	bool shouldRenderCaret = Timer::GetCurrentTimeMs() % 1000 > 500;
	if (text.Length() == 0 && shouldRenderCaret)
		RenderChar('|');
	for (i = 0; i < text.Length(); ++i)
	{
		if (text.caretPosition == i && shouldRenderCaret)
		{
			RenderChar('|');
		}
		currentCharIndex = i;
		currentChar = text.c_str()[i];
		if (currentChar == 0)
			break;
		nextChar = text.c_str()[i + 1];

		if (EvaluateSpecialChar())
			continue;

		StartChar();				// Move in.
		RenderChar(currentChar);	// Render
		/// If we are between the 2 active carets, render the region the char covers over with a white quad ?
		if (text.previousCaretPosition != -1 && i >= min && i < max)
		{
			RenderSelection(currentChar);			
		}
		EndChar();					// Move out.
		lastChar = currentChar;
	}
	// Caret at the end?
	if (text.caretPosition >= text.Length() && shouldRenderCaret)
	{
		RenderChar('|');
	}
	
	OnEndRender(graphicsState);
	/// Revert to old shader!
	ShadeMan.SetActiveShader(oldShader);
}