Sha256: 61eea0d96a15c7152b361e59a8a9d5b75fd65d379ec0bc2be6efa764b7c547bb

Contents?: true

Size: 1.97 KB

Versions: 27

Compression:

Stored size: 1.97 KB

Contents

require 'glimmer-dsl-swt'

require_relative 'klondike_solitaire/model/game'

require_relative 'klondike_solitaire/view/action_panel'
require_relative 'klondike_solitaire/view/tableau'

class KlondikeSolitaire
  include Glimmer::UI::CustomShell
  
  PLAYING_CARD_WIDTH = 50
  PLAYING_CARD_HEIGHT = 80
  PLAYING_CARD_SPACING = 5
  MARGIN = 15
  TABLEAU_WIDTH = 2*MARGIN + 7*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING)
  TABLEAU_HEIGHT = 400

  before_body do
    @game = Model::Game.new
    Display.app_name = 'Glimmer Klondike Solitaire'
    @display = display {
      on_about {
        display_about_dialog
      }
      on_preferences {
        display_about_dialog
      }
    }
  end

  body {
    shell {
      row_layout(:vertical) {
        fill true
        center true
        margin_width 0
        margin_height 0
        margin_top 15
      }
      minimum_size TABLEAU_WIDTH, TABLEAU_HEIGHT
      text "Glimmer Klondike Solitaire"
      background :dark_green
    
      action_panel(game: @game)
      tableau(game: @game) {
        layout_data {
          width TABLEAU_WIDTH
          height TABLEAU_HEIGHT
        }
      }
      
      menu_bar {
        menu {
          text '&Game'
          menu_item {
            text '&Restart'
            accelerator (OS.mac? ? :command : :ctrl), :r
            
            on_widget_selected {
              @game.restart!
            }
          }
          menu_item {
            text 'E&xit'
            accelerator :alt, :f4
            
            on_widget_selected {
              body_root.close
            }
          }
        }
        menu {
          text '&Help'
          menu_item {
            text '&About...'
            on_widget_selected {
              display_about_dialog
            }
          }
        }
      }
    }
  }

  def display_about_dialog
    message_box(body_root) {
      text 'About'
      message "Glimmer Klondike Solitaire\nGlimmer DSL for SWT Elaborate Sample"
    }.open
  end
end

KlondikeSolitaire.launch

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
glimmer-dsl-swt-4.22.0.0 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.16.0 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.2.5 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.2.4 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.2.3 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.2.2 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.2.1 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.2.0 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.1.1 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.1.0 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.0.1 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.21.0.0 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.15.5 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.15.4 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.15.3 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.15.2 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.15.1 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.15.0 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.14.2 samples/elaborate/klondike_solitaire.rb
glimmer-dsl-swt-4.20.14.1 samples/elaborate/klondike_solitaire.rb