Implemented clock logic.
[kaya.git] / lib / board / example.rb
blobddfda77e26839ea1173cb4f060bb357b6f5c8c15
1 $:.unshift(File.join(File.dirname(__FILE__), '..'))
2 require 'korundum4'
3 require 'board/table'
4 require 'themes/loader'
5 require 'controller'
6 require 'games/chess/main'
7 require 'history'
9 description = "KDE Board Game Suite"
10 version = "1.5"
11 about = KDE::AboutData.new("kaya", "Kaya", KDE.ki18n("Kaya"),
12     version, KDE.ki18n(description), KDE::AboutData::License_GPL, KDE.ki18n("(C) 2009 Paolo Capriotti"))
14 KDE::CmdLineArgs.init(ARGV, about)
16 app = KDE::Application.new
18 class Scene < Qt::GraphicsScene
19   def initialize
20     super
21   end
22 end
24 theme_loader = ThemeLoader.new
25 theme = Struct.new(:pieces, :background).new
26 theme.pieces = theme_loader.get('Fantasy')
27 theme.background = theme_loader.get('Default', Point.new(8, 8))
29 chess = Game.get(:chess)
31 scene = Qt::GraphicsScene.new
33 state = chess.state.new
34 state.setup
36 board = Board.new(scene, theme, chess, state)
37 board.observe :new_move do |data|
38   move = data[:move]
39   puts "execute #{move.src.x}, #{move.src.y}, #{move.dst.x}, #{move.dst.y}"
40 end
42 table = Table.new(scene, board)
43 table.size = Qt::Size.new(500, 500)
45 history = History.new(state)
46 controller = Controller.new(board, history)
48 table.show
50 app.exec