// standard menu definitions

////  Main  ////

newmenu main
menuitem Multiplayer  [ showmenu multiplayer ]
menuitem Singleplayer [ showmenu singleplayer ]
menuitem Settings     [ showmenu Settings ]
menuitem Demo         [ showmenu [Play demo] ]
menuitem Editing      [ showmenu editing ]
menuitem Help         [ showmenu help ]
menuitem About        [ showmenu about ]
menuitem "Quit AssaultCube"         quit

// curated maps per possible gamemodes
// TODO: the engine can determine possible modes on mapload - a clever method needs to include saving known/established lists to avoid reworking them on each client start.
// Accepting redundancy one could create a list per gamemode; but of the official maps only ac_douze does not fit the basic toggle between with-flags/without-flags maps …
// … so we have two extra lists besides "all" & "flags" to cater to it.

// Add maps to the below list to include them in the normal map menu (also for botmaps). Modes: DM LSS OSOK PF SURV
const __maps_all [ac_africa ac_alcove ac_aqueous ac_arabian ac_arctic ac_arctic2 ac_arid ac_avenue ac_coal ac_complex ac_depot ac_desert ac_desert2 ac_desert3 ac_douze ac_dusk ac_edifice ac_elevation ac_gothic ac_industrial ac_ingress ac_kazemat ac_keller ac_lainio ac_lotus ac_mines ac_nocturne ac_origin ac_outpost ac_power ac_rampart ac_rattrap ac_scaffold ac_shine ac_snow ac_stellar ac_sunset ac_swamp ac_terros ac_toxic ac_urban ac_venison ac_wasteland ac_werk]
// this list is like maps_all (but without ac_douze) that support TDM TLSS TOSOK TPF and TSURV
const __maps_most [ac_africa ac_alcove ac_aqueous ac_arabian ac_arctic ac_arctic2 ac_arid ac_avenue ac_coal ac_complex ac_depot ac_desert ac_desert2 ac_desert3 ac_dusk ac_edifice ac_elevation ac_gothic ac_industrial ac_ingress ac_kazemat ac_keller ac_lainio ac_lotus ac_mines ac_nocturne ac_origin ac_outpost ac_power ac_rampart ac_rattrap ac_scaffold ac_shine ac_snow ac_stellar ac_sunset ac_swamp ac_terros ac_toxic ac_urban ac_venison ac_wasteland ac_werk]
// this list is for maps with flags that support CTF and KTF
const __maps_flags [ac_africa ac_alcove ac_aqueous ac_arabian ac_arctic2 ac_arid ac_avenue ac_coal ac_depot ac_desert3 ac_dusk ac_edifice ac_elevation ac_gothic ac_industrial ac_ingress ac_kazemat ac_keller ac_lainio ac_lotus ac_mines ac_nocturne ac_origin ac_outpost ac_power ac_rampart ac_shine ac_stellar ac_sunset ac_swamp ac_terros ac_urban ac_venison ac_werk]
// this list is like maps_flags (but with ac_douze) that support TKTF
const __maps_tktf [ac_africa ac_alcove ac_aqueous ac_arabian ac_arctic2 ac_arid ac_avenue ac_coal ac_depot ac_desert3 ac_douze ac_dusk ac_edifice ac_elevation ac_gothic ac_industrial ac_ingress ac_kazemat ac_keller ac_lainio ac_lotus ac_mines ac_nocturne ac_origin ac_outpost ac_power ac_rampart ac_shine ac_stellar ac_sunset ac_swamp ac_terros ac_urban ac_venison ac_werk]

// Start maps.
const __genmapitems [
    looplisti $arg1 m [
        menuitemmapload $m [map @m]
        [nextmap_@m] = (at $arg1 (mod (+ $i 1) @(listlen $arg1)))
    ]
]

newmenu all_custom_maps
menutitle "custom maps"
menurenderoffset -20 0
menudirlist "packages/maps" cgz [map $arg1]

newmenu maps
__genmapitems $__maps_all
menuitem [] -1
menuitem "Show all custom maps\i\3" [showmenu all_custom_maps]

newmenu maps_most
menutitle "maps"
__genmapitems $__maps_most
menuitem [] -1
menuitem "Show all custom maps\i\3" [showmenu all_custom_maps]

newmenu maps_flags
menutitle "maps with flags"
__genmapitems $__maps_flags
menuitem [] -1
menuitem "Show all custom maps\i\3" [showmenu all_custom_maps]

newmenu maps_tktf
menutitle "maps with flags"
__genmapitems $__maps_tktf
menuitem [] -1
menuitem "Show all custom maps\i\3" [showmenu all_custom_maps]

////  Main > Play demo  ////

newmenu [Play demo]
menudirlist demos dmo "demo $arg1"


////  Watching demo  //// (in-game menu that opens when pressing escape while watching a demo)

newmenu [Watching demo]
menuitem "Stop watching demo" stopdemo
menuitem "Restart demo" [ demo $curdemofile ]
menuitem "Rewind demo\i\3" [ showmenu rewind ]
menuitemtextinput "Custom description: " [ getalias (concatword "demodesc_" $curdemofile) ] [ alias (concatword "demodesc_" $curdemofile) $arg1 ] [] 100
menuitem "" -1
menuitem "Watch other demo" [ stopdemo; closecurmenu; showmenu [Play demo] ]
menuitem "Search demo\i\3" [ showmenu [search demo] ]
menuitem "" -1
menuitem "\f4Main menu\i\3" [ closecurmenu; showmenu main ]
menuitem "\f3Quit AssaultCube" quit

////  Watching demo > rewind  ////

newmenu rewind
tempalias __setmr "" ; tempalias __rewind ""
menuitemtextinput "Go to [min]: " [ result $__setmr ] [ __setmr = $arg1 ]
menuitem "\f2Confirm" [ setmr $__setmr ]
menuitem "" -1
menuitemtextinput "Rewind (negative value to forward) [s]: " [ result $__rewind ] [ __rewind = $arg1 ]
menuitem "\f2Confirm" [ rewind $__rewind ]
menuitem "" -1
menuitem "Cancel" 0

////  Watching demo > search demo  ////

newmenu [search demo]
alias __searchdemo ""
menuitemtextinput "Part of demo name or description: " "result $__searchdemo" [ __searchdemo = $arg1 ]
menuitem "\f2\t\t    [ Search demo ]" [ showmenu [search specific demo] ]

////  Watching demo > search demo > search specific demo  ////

newmenu [search specific demo]
menudirlist demos dmo "demo $arg1" 0 __searchdemo


////  Main > Help  ////

newmenu help
menuitem "AssaultCube reference" [ showmenu reference ]
menuitem "Search the reference"  [ showmenu [Reference search] ]
menuitem "Keyboard controls"     [ showmenu Keyboard ]
menuitem "View the FAQ\t\t\t\t\t\t" [ load_faq ; showmenu faq ]
menuheader "" "...for further information/help see the README.\n\f4The readme can be found in the base AssaultCube directory."

////  Main > Help > Reference search  ////

newmenu [Reference search]
tempalias __docsearchstring ""
menuitemtextinput "Search reference for: " "result $__docsearchstring" [ __docsearchstring = $arg1 ; showmenu [Reference search results] ]

////  Main > Help > Reference search > Reference search results  ////

newmenu [Reference search results]
menuinit [
    resetcurmenu
    menusynctabstops 1
    if (strlen $__docsearchstring) [
        menuheader "" (concatword "search results for keyword \f2" $__docsearchstring)
        looplist (docfind $__docsearchstring 1) [n l] [
            menuitem (concatword "\fs\f1" $n "\fr \t" (getdoc $n 1)) (concatword "saycommand /" $n)
        ]
    ] closecurmenu
]

////  Main > Help > FAQ  ////
// see opt/faq.cfg


////  Main > About  ////

newmenu about
menuitem "AssaultCube Version 1.3" -1
menuitem "" -1
menuitem  "AssaultCube has been created and nurtured by an international" -1
menuitem  "community of artists and developers since July 2004. We are" -1
menuitem  "people who love building fun games." -1
menuitem "" -1
menuitem  "\f2We are looking for lead developers and lead artists to help us build" -1
menuitem  "\f2the next generation of AssaultCube for Windows, Mac, Linux and Mobile." -1
menuitem "" -1
menuitem "\f5Contributors in alphabetical order:" -1
menuitem "" -1
menuitem "\f0=== Artists ===" -1
menuitem "Antiklimax, Archangel, BenWasHere, Brett, daMfr0, DaylixX," -1
menuitem "DES Clan, DogDancing, ExodusS, fundog, Halo, HitmanDaz[MT]," -1
menuitem "Humus, JCDPC, Jiba, Kothic, Lady NightHawk, leileilol," -1
menuitem "Lewis Communications, makkE, Matthew Welch, MitaMAN, Nieb," -1
menuitem "optus, Protox (PrimoTurbo), R4zor, RatBoy, RaZgRiZ, Ruthless," -1
menuitem "Sanzo, Shadow, sitters, socksky, Snoosnoo, $N!P3R*, Steini, Toca," -1
menuitem "Topher, Undead, wotwot, YesWeCamp (Husk)" -1
menuitem "" -1
menuitem "\f0=== Developers ===" -1
menuitem "absinth, Arghvark, arkefiende, Brahma, Bukz, driAn, eihrul," -1
menuitem "flowtron, GeneralDisarray, grenadier, KanslozeClown, Luc@s," -1
menuitem "Mr.Floppy, RandumKiwi, Ronald_Reagan, SKB, stef, tempest," -1
menuitem "V-Man, VonDrakula, wahnfred" -1
menuitem "" -1
menuitem "\f0=== Platform & Community ===" -1
menuitem "Apollo, dtd, jamz, Medusa, X-Ray_Dog" -1
menuitem "" -1
menuitem "\f0=== Technology ===" -1
menuitem "Cube Engine by aardappel, eihrul and others" -1
menuitem "ENet Networking Library by eihrul" -1
menuitem "GL4ES OpenGL translation by ptitSeb and others" -1
menuitem "SDL2, SDL_Image, OggVorbis, OpenAL-Soft, zlib" -1
menuitem "" -1
menuitem "\f0=== Textures ===" -1
menuitem "3D Cafe, Articool, Boeck, Chris Zastrow, Craig Fortune," -1
menuitem "Digital Flux, DrunkenM, Golgotha team, GRsites, John Solo," -1
menuitem "Kurt Keslar, Lemog 3D, NOCTUA graphics, Rohrschach," -1
menuitem "www.afflict.net, www.imageafter.com, www.mayang.com," -1
menuitem "www.openfootage.net" -1
menuitem "" -1
menuitem "\f0=== Sounds ===" -1
menuitem "DCP, acclivity, Bahutan, cameronmusic, dommygee, droboide," -1
menuitem "ermine, fonogeno, fresco, ignotus, livindead," -1
menuitem "Lukas Zapletal & Ludek Horacek (Music), mich3d, mwl500," -1
menuitem "nicStage, nofeedbak, NoiseCollector, ReWired, Rhedcerulean," -1
menuitem "Syna Max, Tremulous team, vuzz, wildweasel, WIM," -1
menuitem "www.soundsnap.com" -1
menuitem "" -1
menuitem "\f0=== Special Thanks===" -1
menuitem "BrutalSystem, Chris Robinson, Rick Helmus, Verbal_, gibnum1k" -1
menuitem "" -1
menuitem "Please find the project history and licensing information at" -1
menuitem "https://assault.cubers.net/docs/history.html" -1
menuitem "https://assault.cubers.net/docs/license.html" -1
menuitem "" -1
menuitem "\f2We are looking for lead developers and lead artists to help us build" -1
menuitem "\f2the next generation of AssaultCube for Windows, Mac, Linux and Mobile." -1

// Create additional menus...
exec config/menus_bot.cfg
exec config/menus_edit.cfg
exec config/menus_licenses.cfg
exec config/menus_settings.cfg
exec config/menus_auth.cfg
exec config/menus_multiplayer.cfg
exec config/menus_voicecom.cfg
exec config/favourites.cfg

