Beispiel #1
0
// DEBUG
void UI_Main::PrintDocuments_Cmd( void )
{
	int i;

	if( !self )
		return;

	for( i = 0; i < UI_NUM_CONTEXTS; i++ ) {
		UI_Navigation &navigation = self->navigations[i];

		Com_Printf("Context %i navigation stack:\n", i);
		for( UI_Navigation::iterator it = navigation.begin(); it != navigation.end(); ++it ) {
			NavigationStack *nav = *it;

			nav->printStack();

			DocumentCache *cache = nav->getCache();
			if( cache ) {
				Com_Printf("Document cache:\n");
				cache->printCache();
			}

			Com_Printf("\n");
		}
	}
}
Beispiel #2
0
void UI_Main::M_Menu_Open_f( void )
{
	int i;

	if( !self )
		return;
	if( trap::Cmd_Argc() < 2 )
		return;

	Rocket::Core::URL url;

	url.SetFileName( trap::Cmd_Argv( 1 ) );
	url.SetExtension( "rml" );

	for( i = 2; i < trap::Cmd_Argc() - 1; i += 2 ) {
		url.SetParameter( trap::Cmd_Argv( i ), trap::Cmd_Argv( i+1 ) );
	}

	Rocket::Core::String urlString = url.GetURL();
	//Com_Printf( "UI_Main::M_Menu_Open_f %s\n", urlString.CString() );

	NavigationStack *nav = self->getNavigator();
	if( !nav )
		return;

	nav->pushDocument( urlString.CString() );
	self->showUI( true );
}
Beispiel #3
0
void UI_Main::M_Menu_Open_Cmd_f_( bool modal ) {
	int i;

	if( !self ) {
		return;
	}
	if( trap::Cmd_Argc() < 2 ) {
		return;
	}

	Rocket::Core::URL url;

	url.SetFileName( trap::Cmd_Argv( 1 ) );
	url.SetExtension( "rml" );

	for( i = 2; i < trap::Cmd_Argc() - 1; i += 2 ) {
		url.SetParameter( trap::Cmd_Argv( i ), trap::Cmd_Argv( i + 1 ) );
	}

	Rocket::Core::String urlString = url.GetURL();

	//Com_Printf( "UI_Main::M_Menu_Open_f %s\n", urlString.CString() );

	NavigationStack *nav = self->navigations[UI_CONTEXT_MAIN].front();
	if( !nav ) {
		return;
	}

	nav->pushDocument( urlString.CString(), modal );
	self->showUI( true );
}
Beispiel #4
0
bool UI_Main::haveQuickMenu( void )
{
	NavigationStack *nav = self->navigations[UI_CONTEXT_QUICK].front();
	if( !nav )
		return false;
	return nav->hasDocuments();
}
Beispiel #5
0
void UI_Main::M_Menu_Force_f( void ) {
	if( !self ) {
		return;
	}

	//Com_Printf("UI_Main::M_Menu_Force_F..\n");

	NavigationStack *nav = self->navigations[UI_CONTEXT_MAIN].front();
	if( !nav ) {
		return;
	}

	bool force = atoi( trap::Cmd_Argv( 1 ) ) != 0;
	self->forceUI( force );

	if( !force ) {
		return;
	}

	// if forced, ensure we have at least the default page on stack
	if( !nav->hasDocuments() ) {
		nav->pushDocument( ui_index );
	}
	self->showUI( true );
}
Beispiel #6
0
void UI_Main::showUI( bool show ) {
	// only disable menu if not forced to display it
	if( !show && forceMenu ) {
		return;
	}

	menuVisible = show;
	trap::CL_SetKeyDest( show ? key_menu : key_game );

	if( !show ) {
		cancelTouches( UI_CONTEXT_MAIN );

		UI_Navigation &navigation = navigations[UI_CONTEXT_MAIN];
		NavigationStack *navigator = navigation.front();
		for( UI_Navigation::iterator it = navigation.begin(); it != navigation.end(); ++it ) {
			NavigationStack *stack = *it;
			if( stack->isTopModal() ) {
				stack->popDocument();
			}
			if( stack == navigator ) {
				stack->popAllDocuments();
			}
		}

		rocketModule->hideCursor( UI_CONTEXT_MAIN, RocketModule::HIDECURSOR_REFRESH, 0 );
	}
}
Beispiel #7
0
NavigationStack *UI_Main::createStack( int contextId ) {
	NavigationStack *stack = __new__( NavigationStack )( contextId );
	if( !stack ) {
		return NULL;
	}
	if( contextId < 0 || contextId >= UI_NUM_CONTEXTS ) {
		return NULL;
	}
	stack->setDefaultPath( ui_basepath->string );
	navigations[contextId].push_back( stack );
	return stack;
}
Beispiel #8
0
void UI_Main::preloadUI( void ) {
	int i;
	NavigationStack *navigator;

	for( i = 0; i < UI_NUM_CONTEXTS; i++ ) {
		UI_Navigation &navigation = navigations[i];
		navigator = navigation.front();

		while( !navigation.empty() ) {
			NavigationStack *stack = navigation.front();
			navigation.pop_front();

			// clear the navigation stack
			stack->popAllDocuments();
			if( stack != navigator ) {
				__delete__( stack );
			}
		}

		navigation.push_front( navigator );

		navigator->setDefaultPath( ui_basepath->string );
	}

	// load translation strings

	trap::L10n_ClearDomain();

	// load base UI strings: l10n/ui
	trap::L10n_LoadLangPOFile( "l10n/ui" );

	// load strings provided by the theme: e.g. ui/l10n/porkui

	// initialize with default document

	navigator = navigations[UI_CONTEXT_MAIN].front();

	String l10nLocalPath( navigator->getDefaultPath().c_str() );
	l10nLocalPath += "l10n";
	l10nLocalPath.Erase( 0, 1 );
	trap::L10n_LoadLangPOFile( l10nLocalPath.CString() );

	// postpone displaying the document until the first valid refresh state
	navigator->pushDocument( ui_index, false, false );
	showNavigationStack = navigator->hasDocuments();

	// initial cursor setup
	if( trap::IN_SupportedDevices() & IN_DEVICE_TOUCHSCREEN ) {
		mouseMove( UI_CONTEXT_MAIN, 0, 0, 0, true, false );
	} else {
		mouseMove( UI_CONTEXT_MAIN, 0, refreshState.width >> 1, refreshState.height >> 1, true, true );
	}

	if( !quickMenuURL.Empty() ) {
		navigator = navigations[UI_CONTEXT_QUICK].front();
		navigator->pushDocument( quickMenuURL.CString(), false );
	}

	rocketModule->update();
}
Beispiel #9
0
// DEBUG
void UI_Main::PrintDocuments_Cmd( void )
{
	if( !self )
		return;

	NavigationStack *nav = self->getNavigator();
	if( !nav )
		return;
	Com_Printf("Navigation stack:\n");
	nav->printStack();

	DocumentCache *cache = nav->getCache();
	if( !cache )
		return;
	Com_Printf("Document cache:\n");
	cache->printCache();
}
Beispiel #10
0
void UI_Main::M_Menu_Quick_f( void ) {
	int i;

	if( !self ) {
		return;
	}

	if( !( trap::IN_SupportedDevices() & ( IN_DEVICE_KEYBOARD | IN_DEVICE_TOUCHSCREEN ) ) ) {
		return;
	}

	NavigationStack *nav = self->navigations[UI_CONTEXT_QUICK].front();
	if( !nav ) {
		return;
	}

	if( trap::Cmd_Argc() <= 2 ) {
		self->quickMenuURL = "";
		nav->popAllDocuments();
		return;
	}

	Rocket::Core::URL url;

	url.SetFileName( trap::Cmd_Argv( 1 ) );
	url.SetExtension( "rml" );

	for( i = 2; i < trap::Cmd_Argc() - 1; i += 2 ) {
		url.SetParameter( trap::Cmd_Argv( i ), trap::Cmd_Argv( i + 1 ) );
	}

	Rocket::Core::String urlString = url.GetURL();
	if( urlString == self->quickMenuURL ) {
		return;
	}

	if( nav->hasDocuments() ) {
		nav->popAllDocuments();
	}

	nav->pushDocument( urlString.CString(), false );

	self->quickMenuURL = urlString;
}
Beispiel #11
0
void UI_Main::showUI( bool show )
{
	// only disable menu if not forced to display it
	if( !show && forceMenu )
		return;

	menuVisible = show;
	trap::CL_SetKeyDest( show ? key_menu : key_game );

	if( !show ) {
		cancelTouches( UI_CONTEXT_MAIN );

		UI_Navigation &navigation = navigations[UI_CONTEXT_MAIN];
		NavigationStack *navigator = navigation.front();
		navigator->popAllDocuments();

		rocketModule->hideCursor( UI_CONTEXT_MAIN, RocketModule::HIDECURSOR_REFRESH, 0 );
	}
}
Beispiel #12
0
void UI_Main::drawConnectScreen( const char *serverName, const char *rejectMessage, 
	int downloadType, const char *downloadFilename, float downloadPercent, int downloadSpeed, 
	int connectCount, bool backGround )
{
	DownloadInfo dlinfo( downloadFilename, downloadType );

	dlinfo.setPercent( downloadPercent );
	dlinfo.setSpeed( downloadSpeed );

	this->serverName = serverName ? serverName : "";
	this->rejectMessage = rejectMessage ? rejectMessage : "";
	this->downloadInfo = dlinfo;

	UI_Navigation &navigation = navigations[UI_CONTEXT_MAIN];
	NavigationStack *navigator = navigation.front();
	navigator->pushDocument( ui_connectscreen, false, true );

	forceUI( true );
	showUI( true );
}
Beispiel #13
0
void UI_Main::reloadUI( void )
{
	int i;

	for( i = 0; i < UI_NUM_CONTEXTS; i++ ) {
		UI_Navigation &navigation = navigations[i];
		NavigationStack *navigator = navigation.front();

		while( !navigation.empty() ) {
			NavigationStack *stack = navigation.front();
			navigation.pop_front();

			// clear the navigation stack
			stack->popAllDocuments();
			stack->getCache()->clearCaches();
			if( stack != navigator ) {
				__delete__( stack );
			}
		}

		navigation.push_front( navigator );
	}

	if( serverBrowser ) {
		serverBrowser->stopUpdate();
	}
	if( demos ) {
		demos->Reset();
	}

	destroyDataSources();

	createDataSources();

	preloadUI();

	showUI( true );
}
Beispiel #14
0
void UI_Main::refreshScreen( unsigned int time, int clientState, int serverState, 
	bool demoPlaying, const char *demoName, bool demoPaused, unsigned int demoTime, 
	bool backGround, bool showCursor )
{
	int i;
	UI_Navigation::iterator it, it_next;

	refreshState.time = time;
	refreshState.clientState = clientState;
	refreshState.serverState = serverState;
	refreshState.drawBackground = backGround;

	if( demoPlaying && !demoInfo.getPlaying() ) {
		demoInfo.setName( demoName );
	}
	demoInfo.setTime( demoTime );
	demoInfo.setPaused( demoPaused );
	demoInfo.setPlaying( demoPlaying );

	// postponed showing of the stacked document, we need to set the refresh state first
	if( showNavigationStack ) {
		UI_Navigation &navigation = navigations[UI_CONTEXT_MAIN];
		NavigationStack *navigator = navigation.front();
		navigator->showStack( true );
		showNavigationStack = false;
	}

	// update necessary modules
	if( serverBrowser )
		serverBrowser->updateFrame();
	if( demos )
		demos->UpdateFrame();
	if( ircchannels )
		ircchannels->UpdateFrame();

	if( clientState == CA_ACTIVE && invalidateAjaxCache ) {
		gameajax->FlushCache();
		invalidateAjaxCache = false;
	}

	// TODO: handle the intervalled functions in AS somehow,
	// taking care that they are not called when menu is hidden.
	// i may need to make the interface public..
	BindFrame( asmodule );

	// run incremental garbage collection
	asmodule->garbageCollectOneStep();

	for( i = 0; i < UI_NUM_CONTEXTS; i++ ) {
		UI_Navigation &navigation = navigations[i];
		NavigationStack *navigator = navigation.front();

		// free empty navigation stacks
		for( it = navigation.begin(); it != navigation.end(); it = it_next ) {
			it_next = it;
			it_next++;

			NavigationStack *stack = *it;
			if( stack != navigator && stack->empty() ) {
				__delete__( stack );
				navigation.erase( it );
			}
		}
	}

	// handle main menu context
	if( menuVisible ) {
		NavigationStack *navigator = navigations[UI_CONTEXT_MAIN].front();
		if( !navigator->hasDocuments() ) {
			// no documents on stack, release the key dest
			showUI( false );
		}
		else {
			if( showCursor ) { 
				rocketModule->hideCursor( UI_CONTEXT_MAIN, 0, RocketModule::HIDECURSOR_REFRESH );
				gamepadCursorMove();
			}
			else {
				rocketModule->hideCursor( UI_CONTEXT_MAIN, RocketModule::HIDECURSOR_REFRESH, 0 );
			}
		}
	}

	// rocket update+render
	rocketModule->update();

	if( quickMenuVisible ) {
		rocketModule->render( UI_CONTEXT_QUICK );
	}
	if( menuVisible ) {
		rocketModule->render( UI_CONTEXT_MAIN );
	}

	// mark the top stack document as viwed for history tracking
	for( i = 0; i < UI_NUM_CONTEXTS; i++ ) {
		UI_Navigation &navigation = navigations[i];
		for( it = navigation.begin(); it != navigation.end(); ++it ) {
			(*it)->markTopAsViewed();
		}
	}

	// stuff we need to render without using rocket
	customRender();
}