MCPcopy Create free account
hub / github.com/NetHack/NetHack / optfn_menustyle

Function optfn_menustyle

src/options.c:2319–2375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2317}
2318
2319staticfn int
2320optfn_menustyle(
2321 int optidx, int req, boolean negated,
2322 char *opts, char *op)
2323{
2324 int tmp;
2325 boolean val_required; /* no initializer based on opts because this can be
2326 called with init and invalid opts and op */
2327
2328 if (req == do_init) {
2329 return optn_ok;
2330 }
2331 if (req == do_set) {
2332 /* menustyle:traditional or combination or full or partial */
2333
2334 val_required = (strlen(opts) > 5 && !negated);
2335 if ((op = string_for_opt(opts, !val_required)) == empty_optstr) {
2336 if (val_required)
2337 return optn_err; /* string_for_opt gave feedback */
2338 tmp = negated ? 'n' : 'f';
2339 } else {
2340 tmp = lowc(*op);
2341 }
2342 switch (tmp) {
2343 case 'n': /* none */
2344 case 't': /* traditional: prompt for class(es) by symbol,
2345 prompt for each item within class(es) one at a time */
2346 flags.menu_style = MENU_TRADITIONAL;
2347 break;
2348 case 'c': /* combination: prompt for class(es) by symbol,
2349 choose items within selected class(es) by menu */
2350 flags.menu_style = MENU_COMBINATION;
2351 break;
2352 case 'f': /* full: choose class(es) by first menu,
2353 choose items within selected class(es) by second menu */
2354 flags.menu_style = MENU_FULL;
2355 break;
2356 case 'p': /* partial: skip class filtering, choose items among all
2357 classes by menu */
2358 flags.menu_style = MENU_PARTIAL;
2359 break;
2360 default:
2361 config_error_add("Unknown %s parameter '%s'", allopt[optidx].name,
2362 op);
2363 return optn_err;
2364 }
2365 return optn_ok;
2366 }
2367 if (req == get_val || req == get_cnf_val) {
2368 Sprintf(opts, "%s", menutype[(int) flags.menu_style][0]);
2369 return optn_ok;
2370 }
2371 if (req == do_handler) {
2372 return handler_menustyle();
2373 }
2374 return optn_ok;
2375}
2376

Callers

nothing calls this directly

Calls 4

string_for_optFunction · 0.85
config_error_addFunction · 0.85
handler_menustyleFunction · 0.85
lowcFunction · 0.70

Tested by

no test coverage detected