X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=c7d53181cd608a8e6edc80be774a95170b25af58;hb=4a6c501688b7fbd4f46e61aab76611499819e347;hp=8e8677e4525bf718f53597caf83da668e8e18d41;hpb=618fbaec23b593c43d0faef662359743567b87e3;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 8e8677e..c7d5318 100644 --- a/scene.c +++ b/scene.c @@ -268,19 +268,30 @@ void makeMenu() { glutAddMenuEntry("R/G/B/All Light 2", LIGHT_RGBALL_LIGHT_2); // Construct add object submenus - int addObjectSubmenu[6]; + int objectMenuEntriesSize = sizeof(objectMenuEntries) / sizeof(objectMenuEntries[0]); + int menuNumber = objectMenuEntriesSize / 10 + 1; + int addObjectSubmenu[menuNumber-1]; - for( int i = 0; i < 6; i++ ) { + for( int i = 0; i < menuNumber; i++ ) { addObjectSubmenu[i] = glutCreateMenu(processObjectEvents); - for ( int j = i; j < (i+9); j++ ) { + int startNum = i*11 - (i-1); + for ( int j = startNum - 1; j < (startNum+9); j++ ) { + if ( j == objectMenuEntriesSize ) break; // Detect if we've reached the end of the array glutAddMenuEntry( objectMenuEntries[j], j ); } } // Construct add object menu int addObjectMenu = glutCreateMenu(processObjectEvents); - for ( int i = 0; addObjectSubmenu[i]; i++ ) { - glutAddSubMenu( "1", addObjectSubmenu[i] ); + for ( int i = 0; i < menuNumber; i++ ) { + char name[10]; // buffer to hold name + int startNum = i*11 - (i-1); + int endNum = startNum + 9; + if ( i == menuNumber - 1 ) { // We're on the last one + endNum = startNum + 4; + } + sprintf(name, "%d-%d", startNum, endNum); + glutAddSubMenu( name, addObjectSubmenu[i] ); }