From cbd6292b0a0c28f2ec3be418b5df346a3c00dca5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Jun 2019 21:03:06 +0100 Subject: Extract debug functions into a module --- scripts/toy.groovy | 33 --------------------------------- scripts/toy/debug.groovy | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 scripts/toy/debug.groovy (limited to 'scripts') diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 16df507..8ad391b 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -294,11 +294,6 @@ return new Object() { final addActivity = { String name, func -> activityList[name] = func; } - def playActivity = { - final keys = new ArrayList(activityList.keySet()); - final act = getSelectedValue("Choose activity", keys); - activityList[keys[act]](); - }; // Setup def setDefault = { prop, val -> if (loadString(prop) == null) { @@ -308,29 +303,6 @@ return new Object() { def namedEvents = [ permit: { name, arg, schedTime, rt -> givePermission(arg) } ]; - def setupShowState = { - def localTimeStr = localTimeOf(getTime()).format(soonFormatter); - show("localTime: $localTimeStr\noffsetSet: ${localTimeOffset()}\ntime_t: ${getTime()}"); - showButton("OK"); - show( - [CHASTE, COLLARED, CUFFED, CLAMPED, GAGGED, NAKED].collect { - def v = stateIs(it); - return "$it: $v\n".capitalize() - }.join()); - showButton("OK"); - show( - [BALLGAG, COLLAR, CLAMPS, CHASTITY, HANDCUFFS, DILDO].collect { - def v = has(it); - return "$it: $v\n".capitalize() - }.join()); - showButton("OK"); - show( - [BONDAGE, CBT, CHORES, PAIN].collect { - def v = likes(it); - return "$it: $v\n".capitalize() - }.join()); - showButton("OK"); - }; def showFaq = { useUrl("http://toy.randomdan.homeip.net/"); }; @@ -420,11 +392,6 @@ return new Object() { def opts = requestables.values().toList().findAll { it -> !it.cond || it.cond() }; - if (stateIs("DEBUG")) { - opts.push([ lbl: "Status", act: setupShowState ]); - opts.push([ lbl: "Play", act: { playEvent() }, arg: true ]); - opts.push([ lbl: "Activity", act: playActivity ]); - } TOYTOYS.findAll { stateIs(it) }.each { opts.push([ lbl: "May I be un-$it".toString(), act: { requestRelease() }, arg: it ]); }; diff --git a/scripts/toy/debug.groovy b/scripts/toy/debug.groovy new file mode 100644 index 0000000..560fe87 --- /dev/null +++ b/scripts/toy/debug.groovy @@ -0,0 +1,38 @@ +{ toy -> + if (!toy.stateIs("DEBUG")) { + return; + } + toy.metaClass.setupShowState { + def localTimeStr = localTimeOf(getTime()).format(soonFormatter); + show("localTime: $localTimeStr\noffsetSet: ${localTimeOffset()}\ntime_t: ${getTime()}"); + showButton("OK"); + show( + [CHASTE, COLLARED, CUFFED, CLAMPED, GAGGED, NAKED].collect { + def v = stateIs(it); + return "$it: $v\n".capitalize() + }.join()); + showButton("OK"); + show( + [BALLGAG, COLLAR, CLAMPS, CHASTITY, HANDCUFFS, DILDO].collect { + def v = has(it); + return "$it: $v\n".capitalize() + }.join()); + showButton("OK"); + show( + [BONDAGE, CBT, CHORES, PAIN].collect { + def v = likes(it); + return "$it: $v\n".capitalize() + }.join()); + showButton("OK"); + }; + + toy.metaClass.playActivity { + final keys = new ArrayList(activityList.keySet()); + final act = getSelectedValue("Choose activity", keys); + activityList[keys[act]](); + }; + + toy.addRequestable("status", "Status", { toy.setupShowState() }); + toy.addRequestable("play", "Play", { toy.playEvent(true, false) }); + toy.addRequestable("activitity", "Activity", { toy.playActivity() }); +} -- cgit v1.2.3