Example #1
0
// update one of the core menus
void Menu_Update(int id)
{
    switch (id)
    {
        case MENU_UPD_ROOT:
            // right click menu or any of its submenus
            if (MenuExists("Core_root")) {
                ShowMenu(MakeRootMenu("root", menuPath(NULL),
                    default_root_menu, false));
                break;
            }
            // fall though
        case MENU_UPD_CONFIG:
            // the core config menu
            if (MenuExists("Core_configuration"))
                ShowMenu(MakeConfigMenu(false));
            break;

        case MENU_UPD_TASKS:
            // desktop workspaces menu etc.
            if (MenuExists("Core_tasks"))
            {
                if (MenuExists("Core_tasks_workspace"))
                    ShowMenu(MakeDesktopMenu(0, false));
                else
                if (MenuExists("Core_tasks_icons"))
                    ShowMenu(MakeDesktopMenu(1, false));

                if (MenuExists("Core_tasks_menu"))
                    ShowMenu(MakeDesktopMenu(2, false));

                if (MenuExists("Core_tasks_recoverwindows"))
                    ShowMenu(MakeRecoverMenu(false));
            }
            break;
    }
}
Example #2
0
void hkDemoDatabase::rebuildDatabase()
{
	m_demos.clear();

	//
	// Normalize and collect all demo register entries
	// into a temporary array
	//
	hkArray<hkDemoEntry*> demos;	
	hkDemoEntryRegister* e = s_demoList;
	while(e)
	{
		// Convert the file path to Havok path format
		hkArray<char> buffer;
		const char* tmp = hkNativeFileSystem::platformToHavokConvertPath( e->m_demoPath, buffer );
		hkString resourcePath( hkDemoFileSystem::removeDemoBasePath( tmp, buffer ) );

		int lastSlash  = resourcePath.lastIndexOf('/');		
		HK_ASSERT2(0x6e7879d4, lastSlash >= 0,  "probably a metrowerks build with no 'pragma fullpath_file on': " << resourcePath );

		// Copy as the menu path
		hkString menuPath( resourcePath.substr(0, lastSlash) );	// remove the demo filename for the menu

		// If we have a variant, append the variant name
		if( e->m_variantName )
		{
			menuPath += "/";
			menuPath += e->m_variantName;
		}

#ifdef USING_DEMO_FILTERS
		{
			hkString name(menuPath);
			bool valid = false;
			for (int f=0; f < HK_COUNT_OF(demoFilters); f++)
			{
				valid |= name.beginsWith(demoFilters[f]);
			}
			if (!valid)
			{
				e = e->m_next;
				continue;
			}
		}
#endif

		// Store the entry
		hkDemoEntry* entry = new hkDemoEntry();
		entry->m_func = e->m_func;
		entry->m_demoTypeFlags = e->m_demoTypeFlags;
		entry->m_menuPath = menuPath;
		entry->m_demoPath = resourcePath;
		entry->m_variantId = e->m_variantId;
		entry->m_help = e->m_help;
		entry->m_details = e->m_details;

		if ( e->m_createEntryFunc )	// now we have a create other demos function
		{
			e->m_createEntryFunc(*entry, demos);
			delete entry;
		}
		else
		{
			demos.pushBack(entry);
		}
		e = e->m_next;
	}

	HK_ASSERT2(0x4467bbc3, demos.getSize() != 0, "No demos registered!");

	// find a common root for the demos, if any
	m_prefix = findCommonRootPath( demos );

	// strip the common root plus from the names
	int prefixLen = m_prefix.getLength();
	for(int i = 0; i < demos.getSize(); ++i)
	{
		// prune the prefix from each name 
		hkString& n = demos[i]->m_menuPath;
		if( n[0] == '*' ) // this comes from unit tests, */means "put me at the demos level"???
		{
			n.setAsSubstr(2);
		}
		else if( m_prefix.getLength() > 0 )
		{
			n.setAsSubstr( prefixLen, n.getLength() - prefixLen );
		}
	}

	//
	// Sort the array alphabetically and by ID in the same variant group
	//
	hkSort( demos.begin(), demos.getSize(), demoEntryPathAndVariantIdLess() );

	// Collect the menu order files into an array
	extern const char* DemoOrder[];
	// Build the member demos, sorting according to the menu order
	for (int i = 0; DemoOrder[i] != 0; i++)
	{
		// the demos are already sorted alphabetically
		int j=0;
		// look for the first matching path.. 
		while( j < demos.getSize() && !( demos[j]!=HK_NULL && demos[j]->m_menuPath.beginsWith(DemoOrder[i]) ) ) 
			++j;
		// ..and add it together with all the following matching ones
		while( j < demos.getSize() && demos[j]!=HK_NULL && (demos[j]->m_menuPath.beginsWith(DemoOrder[i])) ) 
		{
			m_demos.pushBack( *(demos[j]) );
			delete demos[j];
			demos[j] = HK_NULL;
			++j;
		}
	}

	// Store any leftover demos
	for (int j = 0; j < demos.getSize(); j++)
	{
		if(demos[j] != HK_NULL)
		{
			m_demos.pushBack( *(demos[j]) );
		}
		delete demos[j];
	}
	// cleanup
	demos.clear();

	/*
	//
	// Write the demo list to a file
	//
	hkOstream stream(HK_DEMO_LIST_FILENAME);
	if ( stream.isOk() )
	{
	stream << ";Havok '" << productCode << "' demo list:" << hkendl << hkendl;
	for (int j = 0; j < m_demos.getSize(); j++)
	{
	stream << m_demos[j].m_menuPath << hkendl;
	}
	}
	*/
}
Example #3
0
// show one of the root menus
bool MenuMaker_ShowMenu(int id, const char* param)
{
    char buffer[MAX_PATH];
    Menu *m;
    int x, y, n, flags, toggle;

    static const char * const menu_string_ids[] = {
        "",
        "root",
        "workspaces",
        "icons",
        "tasks",
        "configuration",
        NULL
    };

    enum {
        e_lastmenu,
        e_root,
        e_workspaces,
        e_icons,
        e_tasks,
        e_configuration,
    };

    x = y = flags = n = toggle = 0;


    switch (id)
    {
        case BB_MENU_BROAM: // @ShowMenu ...
            while (param[0] == '-') {
                const char *p = NextToken(buffer, &param, NULL);
                if (0 == strcmp(p, "-at")) {
                    for (;;++param) {
                        if (*param == 'r')
                            flags |= BBMENU_XRIGHT;
                        else if (*param == 'b')
                            flags |= BBMENU_YBOTTOM;
                        else
                            break;
                    }
                    x = atoi(NextToken(buffer, &param, " ,"));
                    param += ',' == *param;
                    y = atoi(NextToken(buffer, &param, NULL));
                    flags |= BBMENU_XY;
                } else if (0 == strcmp(p, "-key")) {
                    flags |= BBMENU_KBD;
                } else if (0 == strcmp(p, "-toggle")) {
                    toggle = 1;
                } else if (0 == strcmp(p, "-pinned")) {
                    flags |= BBMENU_PINNED;
                } else if (0 == strcmp(p, "-ontop")) {
                    flags |= BBMENU_ONTOP;
                } else if (0 == strcmp(p, "-notitle")) {
                    flags |= BBMENU_NOTITLE;
                }
            }
            break;
        case BB_MENU_ROOT: // Main menu
            param = "root";
            break;
        case BB_MENU_TASKS: // Workspaces menu
            param = "workspaces";
            break;
        case BB_MENU_ICONS: // Iconized tasks menu
            param = "icons";
            break;
        case BB_MENU_UPDATE:
            Menu_Update(MENU_UPD_ROOT);
            Menu_All_Redraw(0);
            return false;
        case BB_MENU_SIGNAL: // just to signal e.g. BBSoundFX
            return true;
        default:
            return false;
    }

    // If invoked by kbd and the menu currently has focus,
    // hide it and return
    if (((flags & BBMENU_KBD) || toggle) && Menu_ToggleCheck(param))
        return false;

    //DWORD t1 = GetTickCount();

    switch (get_string_index(param, menu_string_ids))
    {
        case e_root:
        case e_lastmenu:
            m = MakeRootMenu("root", menuPath(NULL), default_root_menu, true);
            break;

        case e_workspaces:
            m = MakeDesktopMenu(0, true);
            break;

        case e_icons:
            m = MakeDesktopMenu(1, true);
            break;

        case e_tasks:
            m = MakeDesktopMenu(2, true);
            break;

        case e_configuration:
            m = MakeConfigMenu(true);
            break;

        default:
            n = get_workspace_number(param); // e.g. 'workspace1'
            if (-1 != n) {
                m = MakeTaskFolder(n, true);
            } else if (FindRCFile(buffer, param, NULL)) {
                m = MakeRootMenu(param, buffer, NULL, true);
            } else {
                const char *cmd = get_special_command(&param, buffer, sizeof buffer);
                m = MakeFolderMenu(NULL, param, cmd);
            }
            break;
    }

    if (NULL == m)
        return false;

    MenuOption(m, flags, x, y);
    ShowMenu(m);

    //dbg_printf("showmenu time %d", GetTickCount() - t1);
    return true;
}