From e21c703886917b6ac3d7d0ac2ef777f98ca6d242 Mon Sep 17 00:00:00 2001
From: Paolo Capriotti
Date: Sun, 5 Dec 2010 03:11:42 +0200
Subject: [PATCH] Restore game actions.
---
lib/controller.rb | 1 +
lib/mainwindow.rb | 25 +++++++++++++++++--------
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/lib/controller.rb b/lib/controller.rb
index 075925c..3c13e53 100644
--- a/lib/controller.rb
+++ b/lib/controller.rb
@@ -96,6 +96,7 @@ class Controller
@board.highlight(match.history.move)
end
set_active_actions(@current)
+ fire :reset
end
def back
diff --git a/lib/mainwindow.rb b/lib/mainwindow.rb
index ac3ff01..a5c4b44 100644
--- a/lib/mainwindow.rb
+++ b/lib/mainwindow.rb
@@ -51,6 +51,9 @@ class MainWindow < KDE::XmlGuiWindow
c.on(:changed_active_actions) do
update_active_actions(c)
end
+ c.on(:reset) do
+ update_game_actions(c)
+ end
end
end
@@ -184,8 +187,11 @@ private
@view = MultiView.new(self, movelist_stack, @factories)
@view.create(:name => game.class.plugin_name)
- @view.on(:changed) { update_active_actions(controller) }
- @view.on(:changed) { update_title }
+ @view.on(:changed) do
+ update_active_actions(controller)
+ update_title
+ update_game_actions(controller)
+ end
@view.clean = true
update_title
@@ -380,14 +386,17 @@ private
end
end
- def update_game_actions(match)
+ def update_game_actions(contr)
unplug_action_list('game_actions')
- actions = if match.game.respond_to?(:actions)
- match.game.actions(self, action_collection, controller.policy)
- else
- []
+ if contr.match
+ game = contr.match.game
+ actions = if game.respond_to?(:actions)
+ game.actions(self, action_collection, contr.policy)
+ else
+ []
+ end
+ plug_action_list('game_actions', actions)
end
- plug_action_list('game_actions', actions)
end
def update_title
--
2.11.4.GIT