aboutsummaryrefslogtreecommitdiff
path: root/judge/main.ml
diff options
context:
space:
mode:
Diffstat (limited to 'judge/main.ml')
-rw-r--r--judge/main.ml62
1 files changed, 18 insertions, 44 deletions
diff --git a/judge/main.ml b/judge/main.ml
index 6a42ff8..ef73ec5 100644
--- a/judge/main.ml
+++ b/judge/main.ml
@@ -18,47 +18,7 @@ end = struct
module G = C.G
- (* Graphic helpers *)
- let grey = rgb 112 112 112
- let red = rgb 200 0 0
- let green = rgb 0 150 0
-
- let center () = size_x () / 2, size_y () / 2
-
- let fullscreen_msg m =
- clear_graph();
- let tx, ty = text_size m in
- let cx, cy = center () in
- let w, h = tx/2, ty/2 in
- set_color black;
- let cr d =
- draw_rect (cx - w - d) (cy - h - d)
- (2 * (w + d)) (2 * (h + d))
- in cr 20; cr 22;
- moveto (cx - w) (cy - h);
- draw_string m;
- synchronize ()
-
- let tw m = fst (text_size m)
-
- let text_l l x c m =
- set_color c;
- moveto x (size_y() - ((l+1) * 20));
- draw_string m
-
- let text1 l c m =
- text_l l 30 c m
- let text2 l c m =
- text_l l (size_x()/2 - 30 - tw m) c m
- let text3 l c m =
- text_l l (size_x()/2 + 30) c m
- let text4 l c m =
- text_l l (size_x() - 30 - tw m) c m
-
- let hl () =
- draw_poly_line
- [| 10, size_y() - 50;
- size_x() - 10, size_y() - 50 |]
+ open G_util
(* Init/Close *)
let init () =
@@ -76,7 +36,8 @@ end = struct
type view =
| ScoreBoard
| MatchList of bool
- | ViewGame of C.game
+ | ViewLastGame
+ | NavGame of C.game * int
| Question of string * (unit -> unit) * view
let rec handle_events () =
@@ -90,6 +51,8 @@ end = struct
(fun () -> C.add_rounds(); curr_view := MatchList false),
!curr_view
)
+ | MatchList _, 'v' -> curr_view := ViewLastGame
+ | ViewLastGame, '\t' -> curr_view := MatchList false
| Question(_, y, n), 'y' -> y()
| Question(_, y, n), 'n' -> curr_view := n
| v, 'q' ->
@@ -107,7 +70,8 @@ end = struct
begin match !curr_view with
| ScoreBoard -> scoreboard_disp ()
| MatchList f -> matchlist_disp f
- | ViewGame g -> game_disp g
+ | ViewLastGame -> last_game_disp ()
+ | NavGame (g, n) -> nav_game_disp g n
| Question (q, _, _) -> fullscreen_msg (q ^ " (y/n)")
end;
synchronize ()
@@ -171,7 +135,17 @@ end = struct
List.iteri print_g games
(* Game view *)
- and game_disp g =
+ and last_game_disp () =
+ match C.games () with
+ | g::_ ->
+ let p1n, p2n = C.pn g in
+ text1 1 p1c p1n;
+ text2 1 p2c p2n;
+ text4 1 grey "match list >";
+ hl();
+ G.display_game (C.g g) (p1n, p2n)
+ | _ -> ()
+ and nav_game_disp g n =
(* TODO *)
()