Example #1
0
void RocketMenuPlugin::HighlightItem(Rocket::Core::Context *context, const Rocket::Core::String& docId, const Rocket::Core::String& elementId) {
    Rocket::Core::ElementDocument *doc = context->GetDocument(docId);
    if (doc != NULL) {
        HighlightItem(doc, elementId);
    } else {
        printf("[ROCK] RocketMenuPlugin::HighlightItem: unable to find document with id='%s'\n", docId.CString());
    }
}
Example #2
0
void RocketMenuPlugin::HighlightPreviousItem(Rocket::Core::Context *context, const Rocket::Core::String& docId) {
    Rocket::Core::ElementDocument *doc = NULL;
    if (docId == "") {
        ContextData *cd = GetContextData(context);
        doc = cd->current_document;
    } else {
        doc = context->GetDocument(docId);
    }
    if (doc != NULL) {
        HighlightPreviousItem(doc);
    } else {
        printf("[ROCK] RocketMenuPlugin::HighlightPreviousItem: document not found: %s\n", docId.CString());
    }
}
Example #3
0
void RocketMenuPlugin::HighlightItem(Rocket::Core::ElementDocument *document, const Rocket::Core::String& id) {
    Rocket::Core::Element *element = document->GetElementById(id);
    if (element != 0) {
        HighlightItem(element);
    } else {
        printf("[ROCK] RocketMenuPlugin::HighlightItem: unable to find element with id='%s'\n", id.CString());
    }
}
Example #4
0
	Rocket::Core::FileHandle Open( const Rocket::Core::String &filePath )
	{
		fileHandle_t fileHandle;
		FS_FOpenFileRead( filePath.CString(), &fileHandle, false );
		return ( Rocket::Core::FileHandle )fileHandle;
	}
Example #5
0
Rocket::Core::String Rocket_QuakeToRML( const char *in, int parseFlags = 0 )
{
	const char *p;
	Rocket::Core::String out;
	Rocket::Core::String spanstr;
	bool span = false;
	bool spanHasContent = false;

	if ( !*in )
	{
		return "";
	}

	for ( p = in; p && *p; ++p )
	{
		if ( *p == '<' )
		{
			if ( span && !spanHasContent )
			{
				spanHasContent = true;
				out.Append( spanstr );
			}
			out.Append( "&lt;" );
		}
		else if ( *p == '>' )
		{
			if ( span && !spanHasContent )
			{
				spanHasContent = true;
				out.Append( spanstr );
			}
			out.Append( "&gt;" );
		}
		else if ( *p == '&' )
		{
			if ( span && !spanHasContent )
			{
				spanHasContent = true;
				out.Append( spanstr );
			}
			out.Append( "&amp;" );
		}
		else if ( *p == '\n' )
		{
			out.Append( span && spanHasContent ? "</span><br />" : "<br />" );
			span = false;
			spanHasContent = false;
		}
		else if ( Q_IsColorString( p ) )
		{
			if ( span && spanHasContent )
			{
				out.Append( "</span>" );
				span = false;
				spanHasContent = false;
			}

			char rgb[32];
			int code = ColorIndex( *++p );

			Com_sprintf( rgb, sizeof( rgb ), "<span style='color: #%02X%02X%02X;'>",
			          (int)( g_color_table[ code ][ 0 ] * 255 ),
			          (int)( g_color_table[ code ][ 1 ] * 255 ),
			          (int)( g_color_table[ code ][ 2 ] * 255 ) );

			// don't add the span yet, because it might be empty
			spanstr = rgb;

			span = true;
			spanHasContent = false;
		}
		else
		{
			if ( span && !spanHasContent )
			{
				out.Append( spanstr );
				spanHasContent = true;
			}
			out.Append( *p );
		}
	}

	if ( span && spanHasContent )
	{
		out.Append( "</span>" );
	}

	// ^^ -> ^
	while ( out.Find( "^^" ) != Rocket::Core::String::npos )
	{
		out = out.Replace( "^^", "^" );
	}

	if ( parseFlags & RP_EMOTICONS )
	{
		// Parse emoticons
		size_t openBracket = 0;
		size_t closeBracket = 0;
		size_t currentPosition = 0;

		while ( 1 )
		{
			Rocket::Core::String emoticon;
			const char *path;

			openBracket = out.Find( "[", currentPosition );
			if ( openBracket == Rocket::Core::String::npos )
			{
				break;
			}

			closeBracket = out.Find( "]", openBracket );
			if ( closeBracket == Rocket::Core::String::npos )
			{
				break;
			}

			emoticon = out.Substring( openBracket + 1, closeBracket - openBracket - 1 );

			// Certain characters are invalid
			if ( emoticon.Empty() || IsInvalidEmoticon( emoticon ) )
			{
				currentPosition = closeBracket + 1;
				continue;
			}

			// TODO: Dont hardcode the extension.
			path =  va( "emoticons/%s.crn", emoticon.CString() );
			if ( FS_FOpenFileRead( path, nullptr, true ) )
			{
				out.Erase( openBracket, closeBracket - openBracket + 1 );
				path = va( "<img class='trem-emoticon' src='/emoticons/%s' />", emoticon.CString() );
				out.Insert( openBracket, path );
				currentPosition = openBracket + strlen( path ) + 1;
			}
			else
			{
				currentPosition = closeBracket + 1;
			}
		}
	}

	return out;
}
Example #6
0
	int TranslateString( Rocket::Core::String &translated, const Rocket::Core::String &input )
	{
		const char* ret = Trans_GettextGame( input.CString() );
		translated = ret;
		return 0;
	}
bool RocketInterface::LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message)
{
    assert(Log::ptr());
    LOG << "[librocket]: " << message.CString();
    return false;
}