From e2dc4e4b9e5d2926127ec6df41d8c1ebf3df1b74 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 14 Sep 2015 22:20:47 -0400 Subject: [PATCH] friendz: set status on key commands Signed-off-by: Jean Privat --- contrib/friendz/src/friendz.nit | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/contrib/friendz/src/friendz.nit b/contrib/friendz/src/friendz.nit index 218e5ce..9e7e00f 100644 --- a/contrib/friendz/src/friendz.nit +++ b/contrib/friendz/src/friendz.nit @@ -777,7 +777,7 @@ class StatusBar do print "***STATUS** {txt}" self.tmp_txt = txt - self.tmp_txt_ttl = 20 + self.tmp_txt_ttl = 60 self.tmp_txt_color = color end @@ -1210,13 +1210,16 @@ redef class Game fun onKeyDown(ev: Event) do var kc = ev.char_code if kc == "e" then + set_tmp("RUN EDITOR") grid_edit = grid.copy(true) edit_grid(grid) else if kc == "c" then if cheated then + set_tmp("CHEAT: OFF") snd_duh.play cheated = false else + set_tmp("CHEAT: ON") snd_win.play cheated = true end @@ -1227,20 +1230,28 @@ redef class Game else solver_pause = not solver_pause end + if solver_pause then + set_tmp("SOLVER: PAUSED") + else + set_tmp("SOLVER: ON") + end #solver.step else if kc == "d" then if solver == null then solver = (new FriendzProblem(grid)).solve solver_pause = true + set_tmp("SOLVER: ON") else + solver_pause = true solver.run_steps(1) + set_tmp("SOLVER: ONE STEP") end else if kc == "+" then solver_steps += 100 - print solver_steps + set_tmp("SOLVER: {solver_steps} STEPS") else if kc == "-" then solver_steps -= 100 - print solver_steps + set_tmp("SOLVER: {solver_steps} STEPS") else for g in entities do if kc == g.shortcut then g.click(ev) @@ -1249,6 +1260,11 @@ redef class Game end end + fun set_tmp(s: String) + do + statusbar.set_tmp(s, "cyan") + end + redef fun load_levels do super -- 1.7.9.5