hstzaar 0.8 → 0.8.1
raw patch · 4 files changed
+102/−5 lines, 4 files
Files
- RELEASE-NOTES +3/−0
- hstzaar.cabal +1/−1
- hstzaar.glade +84/−0
- src/GUI.hs +14/−4
RELEASE-NOTES view
@@ -1,3 +1,6 @@+hstzaar 0.8.1 10/08/2011+- added "about this program" dialog + hstzaar 0.8 30/06/2011 - fixed crash on clicking Cancel button of file dialogs - fixed incorrect behaviour of AI Level 2 (wrong comparison)
hstzaar.cabal view
@@ -1,5 +1,5 @@ name: hstzaar-version: 0.8+version: 0.8.1 category: Game
hstzaar.glade view
@@ -148,6 +148,25 @@ </child> </widget> </child>+ <child>+ <widget class="GtkMenuItem" id="menuitem6">+ <property name="visible">True</property>+ <property name="label" translatable="yes">_Help</property>+ <property name="use_underline">True</property>+ <child>+ <widget class="GtkMenu" id="menu3">+ <property name="visible">True</property>+ <child>+ <widget class="GtkMenuItem" id="menu_item_about">+ <property name="visible">True</property>+ <property name="label" translatable="yes">About this program</property>+ <property name="use_underline">True</property>+ </widget>+ </child>+ </widget>+ </child>+ </widget>+ </child> </widget> <packing> <property name="expand">False</property>@@ -200,6 +219,71 @@ <packing> <property name="expand">False</property> <property name="position">2</property>+ </packing>+ </child>+ </widget>+ </child>+ </widget>+ <widget class="GtkAboutDialog" id="aboutdialog1">+ <property name="border_width">5</property>+ <property name="window_position">center</property>+ <property name="type_hint">normal</property>+ <property name="gravity">center</property>+ <property name="program_name">HsTZAAR</property>+ <property name="version">0.0</property>+ <property name="copyright" translatable="yes">Copyright (c) Tom Hawkins & Pedro Vasconcelos 2011</property>+ <property name="comments" translatable="yes">A computer program to play the board game TZAAR designed by Kris Burm in 2007 as the final part of the GIPF series of abstract strategy games.++Programmed using the Haskell programming language, the GTK+ toolkit and the Cairo graphic libraries.+Windows installer assembled using Inno Setup.+</property>+ <property name="website">http://www.dcc.fc.up.pt/~pbv/stuff/hstzaar</property>+ <property name="license" translatable="yes">+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.+3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+SUCH DAMAGE.+</property>+ <property name="authors">Pedro Vasconcelos <pbv@dcc.fc.up.pt>.+Based on the HTZAAR program by Tom Hawkins <tomhawkins.org>.+</property>+ <child internal-child="vbox">+ <widget class="GtkVBox" id="dialog-vbox2">+ <property name="visible">True</property>+ <property name="spacing">2</property>+ <child>+ <placeholder/>+ </child>+ <child internal-child="action_area">+ <widget class="GtkHButtonBox" id="dialog-action_area2">+ <property name="visible">True</property>+ <property name="layout_style">end</property>+ </widget>+ <packing>+ <property name="expand">False</property>+ <property name="pack_type">end</property>+ <property name="position">0</property> </packing> </child> </widget>
src/GUI.hs view
@@ -3,11 +3,12 @@ Pedro Vasconcelos, 2011 -} module GUI (gui) where-+import Data.Version+import Paths_hstzaar(version) import Graphics.UI.Gtk hiding (eventSent,on) import Graphics.UI.Gtk.Gdk.Events import Graphics.UI.Gtk.Glade-import Graphics.Rendering.Cairo+import Graphics.Rendering.Cairo hiding (version) import Data.Function (on) import qualified Data.IntMap as IntMap import Data.IntMap (IntMap, (!))@@ -64,6 +65,7 @@ data GUI = GUI { mainwin :: Window, canvas :: DrawingArea,+ aboutdiag :: AboutDialog, statusbar:: Statusbar, progressbar:: ProgressBar, menu_item_new :: MenuItem,@@ -78,6 +80,7 @@ menu_item_show_moves :: CheckMenuItem, menu_item_random_start :: CheckMenuItem, menu_item_ai_players :: [(RadioMenuItem, AI)],+ menu_item_about :: MenuItem, open_file_chooser :: FileChooserDialog, save_file_chooser :: FileChooserDialog, contextid :: ContextId@@ -110,6 +113,7 @@ Nothing -> error ("unable to open glade file " ++ show path) Just xml -> do mw <- xmlGetWidget xml castToWindow "mainwindow"+ abd <- xmlGetWidget xml castToAboutDialog "aboutdialog1" fr <- xmlGetWidget xml castToFrame "frame1" sb <- xmlGetWidget xml castToStatusbar "statusbar" pb <- xmlGetWidget xml castToProgressBar "progressbar"@@ -123,7 +127,9 @@ msh<- xmlGetWidget xml castToCheckMenuItem "menu_item_show_heights" msm<- xmlGetWidget xml castToCheckMenuItem "menu_item_show_moves" mrs<- xmlGetWidget xml castToCheckMenuItem "menu_item_random_start"+ mab<- xmlGetWidget xml castToMenuItem "menu_item_about" -- fill in dynamic parts+ aboutDialogSetVersion abd (showVersion version) bd <- drawingAreaNew containerAdd fr bd m<- xmlGetWidget xml castToMenu "menu_ai"@@ -145,8 +151,8 @@ fileChooserAddFilter svf ff cid <- statusbarGetContextId sb "status" widgetShowAll mw- return (GUI mw bd sb pb mn mo ms mq mun mre mpa - msh msm mrs (zip (r:rs) (map snd aiPlayers)) opf svf cid)+ return (GUI mw bd abd sb pb mn mo ms mq mun mre mpa + msh msm mrs (zip (r:rs) (map snd aiPlayers)) mab opf svf cid) -- | connect event handlers for GUI elements@@ -162,6 +168,10 @@ return (eventSent x) onDestroy (mainwin gui) mainQuit+ onActivateLeaf (menu_item_about gui) $ + do { dialogRun (aboutdiag gui)+ ; widgetHide (aboutdiag gui)+ } onActivateLeaf (menu_item_quit gui) mainQuit onActivateLeaf (menu_item_new gui) $ newGame gui gameRef onActivateLeaf (menu_item_open gui) $