X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=e6dee1f159de779c0467d25e5b5f1e764eef3237;hb=84de854b0db5bb503f3cdaf5864935dd7af4b303;hp=f6520e79aaa7adee3bfc003edb8ec0287a7d3759;hpb=653cfb2c0e3aacd00fd53d5d03cb9d9da516eac1;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index f6520e7..e6dee1f 100644 --- a/scene.c +++ b/scene.c @@ -268,11 +268,15 @@ 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 + 1 == objectMenuEntriesSize ) break; // Detect if we've reached the end of the array glutAddMenuEntry( objectMenuEntries[j], j ); } } @@ -280,7 +284,10 @@ void makeMenu() { // Construct add object menu int addObjectMenu = glutCreateMenu(processObjectEvents); for ( int i = 0; addObjectSubmenu[i]; i++ ) { - glutAddSubMenu( (char)i, addObjectSubmenu[i] ); + char name[10]; // buffer to hold name + int startNum = i*11 - (i-1); + sprintf(name, "%d-%d", startNum, startNum + 9); + glutAddSubMenu( name, addObjectSubmenu[i] ); }