From d75a04c985f215bd7cc100e975021b16d94e8eff Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 12 Aug 2017 15:11:19 +0200 Subject: [PATCH] After setting/cancelling TBR also check main menu state after cancel. --- .../jotomo/ruffyscripter/commands/SetTbrCommand.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java index a42ec84285..20a68ad026 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java @@ -243,15 +243,19 @@ public class SetTbrCommand implements Command { Object percentageObj = scripter.currentMenu.getAttribute(MenuAttribute.TBR); Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME); + if(percentage==100) { + if (percentageObj != null || durationObj != null) + throw new CommandException().message("TBR cancelled, but main menu shows a running TBR"); + + return new CommandResult().success(true).enacted(true).message("TBR was cancelled"); + } + if(percentageObj == null || !(percentageObj instanceof Double)) throw new CommandException().message("not percentage"); if(((double)percentageObj)!=percentage) throw new CommandException().message("wrong percentage set!"); - if(percentage==100) - return new CommandResult().success(true).enacted(true).message("TBR was cancelled"); - if(durationObj==null || !(durationObj instanceof MenuTime)) throw new CommandException().message("not time"); @@ -259,6 +263,7 @@ public class SetTbrCommand implements Command { if(t.getMinute()+(60*t.getHour())> duration || t.getMinute()+(60*t.getHour())< duration-5) throw new CommandException().message("wrong time set!"); + return new CommandResult().success(true).enacted(true).message( String.format(Locale.US, "TBR set to %d%% for %d min", percentage, duration)); } catch (Exception e) {