Implemented highlighting.
[kaya/ydirson.git] / lib / board / example.rb
blobbc2ebce54c662a101709ab538f2a20d74ef89fd0
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/chess'
7 require 'history'
9 description = "KDE Board Game Suite"
10 version = "1.5"
11 about = KDE::AboutData.new("tagua", "Tagua", KDE.ki18n("Tagua"),
12     version, KDE.ki18n(description),KDE::AboutData::License_GPL,KDE.ki18n("(C) 2003 whoever the author is"))
14 about.addAuthor(KDE.ki18n("author1"), KDE.ki18n("whatever they did"), "email@somedomain")
15 about.addAuthor(KDE.ki18n("author2"), KDE.ki18n("they did something else"), "another@email.address")
17 KDE::CmdLineArgs.init(ARGV, about)
19 app = KDE::Application.new
21 class Scene < Qt::GraphicsScene
22   def initialize
23     super
24   end
25 end
27 theme_loader = ThemeLoader.new
28 theme = Struct.new(:pieces, :background).new
29 theme.pieces = theme_loader.get('Fantasy')
30 theme.background = theme_loader.get('Default', Point.new(8, 8))
32 chess = Game.get(:chess)
34 scene = Qt::GraphicsScene.new
36 state = chess.state.new
37 state.setup
39 board = Board.new(scene, theme, chess, state)
40 board.observe :new_move do |data|
41   move = data[:move]
42   puts "execute #{move.src.x}, #{move.src.y}, #{move.dst.x}, #{move.dst.y}"
43 end
45 table = Table.new(scene, board)
46 table.size = Qt::Size.new(500, 500)
48 history = History.new(state)
49 controller = Controller.new(board, history)
51 table.show
53 app.exec