LIL is a Language Make games, nicely

The main menu

Next step, we define the elements of the main menu of our application. Again, in operating systems where this doesn't exist, like on iOS, it will be ignored.

fn newGame {
    print "Starting new game...";
    //etc
}
                
@mainMenu {
    #new @menu game {
        label: "Game";

        #new @menuItem new {
            label: "New Game";
            shortcut: "n";
            action: newGame;
        }
    }
}

Mac specific menu

On the Mac platform, the UI convention is to have one first menu that is called like the app itself. It is created automatically and you can add items to it by using "app" in the selector.

Usually, main menu files are put into separate files, one per platform, using the @OS_MAC suffix in this example.

//file: main.lil
#needs "main_menu.lil";

//etc

 

//file: main_menu@OS_MAC.lil
@mainMenu {
    app {
        #new @menuItem about {
            label: "About";
            action: showAboutWindow; //suppose this exists
        }
    }
}

 

//file: main_menu@OS_WINDOWS.lil
@mainMenu {
    #new @menu file {
        label: "File";

        #new @menuItem about {
            label: "About";
            action: showAboutWindow; //suppose this exists
        }
    }
}