From ca21b8342ccf0ba5957608c6d8888cc9492d55a0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 3 Dec 2018 20:01:36 +0000 Subject: Tidy please miss options and hide debug choices --- scripts/toy.groovy | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/toy.groovy b/scripts/toy.groovy index e09b5a7..57b720e 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -1082,22 +1082,25 @@ else { final cycleTime = 6; while (true) { + setImage(null); + show(null); if (showButton("Please, Miss?", cycleTime) < cycleTime) { - switch (getSelectedValue("Yes, toy?", [ - "Status", - "Calendar", - "Play", - "Plan begin", - "Confess", - "Back" - ])) { - case 0: setupShowState(); break; - case 1: setupShowCalendar(); break; - case 2: playtime(); break; - case 3: beginPlan(LUNCH); break; - case 4: confess(); break; - case 5: return "toy"; + def opts = [ + [ lbl: "Status", act: setupShowState ], + [ lbl: "Calendar", act: setupShowCalendar ], + [ lbl: "Confess", act: confess ], + [ lbl: "Back", act: null ], + ]; + if (is("DEBUG")) { + opts.push([ lbl: "Play", act: playtime ]); + opts.push([ lbl: "Begin plan", act: beginPlan, arg: LUNCH ]); } + def opt = getSelectedValue("Yes, toy?", opts.collect { it.lbl }); + def act = opts[opt].act; + if (act) + act(opts[opt].arg); + else + return "toy"; } else if (localTime() > 25.75) { // 1:45am bedtime(); -- cgit v1.2.3