||| Copyright (C) 1998-2007, Sumisho Computer Systems Corp.  All Rights Reserved.
|||
||| Maintained by: Curl Solutions
{curl 5.0, 6.0, 7.0 applet}
{applet manifest = "manifest.mcurl"}

{import * from COM.CURL.CSK.EXTRAS.MAKI}

{api-version-switch
 case "7+" do
    {install-style-sheet {get-default-style-sheet}}
 case "6+" do
    {import * from COM.CURL.GUI.STYLED-CONTROLS}
    {install-style-sheet
        {manifest-url "file", "DEFAULT-STYLE-SHEET"}
    }
}

{set-document-properties
    background= {Color.from-rgb-uint8 52, 131, 153},
    color="white"
}
|| Help button
{let package help-view:View =
    {View 
        title = "Maki Help", 
        {ScrollBox
            height = 6in,
            vstretch? = true,
            {Frame
                background = "white",
                width = 4in,
                margin = .15in,
                {evaluate {url "info.scurl"}}
            }
        },
        {on e:WindowClose at v:View do
            || Instead of destroying the window, just hide it.
            {v.hide}
            {e.consume}
        }
    }
}


||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||| Support for maintaining scores (in file "hiscores.curl":
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{let score-summary:any = {itemize},
    score-summary-frame:Frame = {Frame score-summary}}

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||| User-visible board & commentary:
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

{let board:MakiBoard = {new MakiBoard}}

{VBox
    spacing=10pt,
    halign="center",
    margin=10pt,
    {HBox
        valign="center",
        spacing=10pt,
        || VBox with MakiBoard and control panel
        {VBox
            halign="center",
            spacing=10pt,
            board,
            {HBox
                spacing=10pt,
                {CommandButton
                    label="New Game",
                    {on Action do {board.new-game}}
                },
                {CommandButton
                    label="Restart",
                    {on Action do {board.restart}}
                },
                {CommandButton
                    label="Undo",
                    {on Action do {board.undo}}
                },
                {CommandButton
                    label="Redo",
                    {on Action do {board.redo}}
                },
                {if allow-save? then
                    {CommandButton
                        label="Save",
                        {on Action do
                            {board.save-game}
                            ||{update-scores}
                        }
                    }
                 else
                    {Fill}
                },
                {CommandButton
                    label="Help",
                    {on Action do {help-view.show}}
                }
            }
        }, || VBox
        {VBox
            halign="center",
            spacing=10pt,
            {paragraph
                font-size=11pt,
                font-family="Verdana",
                A {italic popup menu} of commands is available by
                right-clicking this text.

                Your current score is {bold {value board.score}} .

                Game statistics: {board.stats-display}

                {context-popup
                    menu-pane={MenuPane
                                  {MenuAction label="Cancel",
                                      {on Action do  }
                                  },
                                  {MenuAction label="Undo",
                                      {on Action do {board.undo}}
                                  },
                                  {MenuAction label="Redo",
                                      {on Action do {board.redo}}
                                  },
                                  {MenuAction label="Restart",
                                      {on Action do {board.restart}}
                                  },
                                  {MenuAction label="New Game",
                                      {on Action do {board.new-game} }
                                  },
                                  {MenuAction label="Help",
                                      {on Action do {help-view.show} }
                                  }
                              }
                } || context-popup
            } || paragraph
        } || VBox
    }, || HBox


    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    ||| Add the score summary to our page:
    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    {if allow-save? then
        {paragraph
            If you like, you can see if you can beat some scores others `
            have made.  Try:
            {board.scores-display}
        }
     else
        {paragraph }
    }
}


