class Reviewer < GoWin

include ReviewProtocol

	def initialize (nb)
		@number=nb
		@data={}
		super()


    @top.help_add('command','label'=>'review a game','command'=>proc { TkHtml.new("file://#{$current_path}/../help/editor.html#review") })

    @file_menu=Menu.new
 
    @file_menu.add('command', 'label' => 'Save','command' => proc {save_file})

    @file_menu.add('separator')
    @file_menu.add('command', 'label' => 'Edit','command' => proc { open_editor})
    @file_menu.add('command', 'label' => 'View sgf','command' => proc { view_sgf})
	@file_menu.add('separator')
    @file_menu.add('command', 'label' => 'Quit','command' => proc { quit})


    @top.menubar.add('cascade','menu' => @file_menu, 'label' => 'File')
		end
def quit 
	$igsClient.send("review quit #@number")
	$revobs.delete(@number.to_i)
	super()
end

	def open_win
		super()
    	#open_cmd
    @cmdline=  CmdLine.new(@f2, proc { |msg| send_message(msg)}).pack('fill' =>'x','expand'=>'no')
		@top.title('Reviewer : '+ @number)
	end

  def send_message(msg)
	 $igsClient.send( "review comment #@number #{msg}")
  end



def open_cmd

    @cmd= VTexturedPane.new(@f1,Defaults::DEFS['CommonBackground'],10,5,1,6).pack('fill'=> 'both','expand'=>'yes','side'=>'right')
    navpane = VTexturedPane.new(@cmd, Defaults::DEFS['goreplay-bg'], 5,2,1,0).pack('pady'=>10)
    navpane.add_text(TkDefaults::GUI['GoReplay.title.navigate'])
    navigate= TkFrame.new(navpane,TkDefaults::GUI['GoReplay.frame.navigate'])

    opts=TkDefaults::GUI['GoReplay.button.begin'].update( {'command'=> proc {set_begin;@mid.focus}})
    @b_begin = TkButton.new(navigate,opts).pack('side'=>'left')

    opts=TkDefaults::GUI['GoReplay.button.fastb'].update( {'command'=> proc {set_fastb;@mid.focus}})
    @b_fastb = TkButton.new(navigate,opts).pack('side'=>'left')

    opts=TkDefaults::GUI['GoReplay.button.backward'].update( {'command'=> proc {set_backward;@mid.focus}})
    @b_backw = TkButton.new(navigate,opts).pack('side'=>'left')

    opts=TkDefaults::GUI['GoReplay.button.forward'].update( {'command'=> proc {set_forward;@mid.focus}})
    @b_forw = TkButton.new(navigate,opts).pack('side'=>'left')

    opts=TkDefaults::GUI['GoReplay.button.fastf'].update( {'command'=> proc {set_fastf;@mid.focus}})
    @b_fastf = TkButton.new(navigate,opts).pack('side'=>'left')

    opts=TkDefaults::GUI['GoReplay.button.end'].update( {'command'=> proc {set_end;@mid.focus}})
    @b_end = TkButton.new(navigate,opts).pack('side'=>'left')

    navpane.add(navigate)
	navpane.configure(TkDefaults::GUI['GoReplay.pane.navigate'])
    navpane.reconfigure

end

def create_game
	super()
	@current_node=@last_node
end

def refresh
	set_node(@pos_node)
end

def set_node(node)
    @goban.remove_tag('Graphics')
	@goban.unset_mark

    clear_msg

	#clear_comment
	super(node)
	#config_btns
	if p=(node['W'] or node['B'])
      if p.move_pass
        str =(p.ident== 'W' ? 'white' : 'black') + ' pass'
      else
        str= "(#{p.ident}): #{Grid.to_coords(p.col,p.row,@height)}"
      end
      set_move_label(str)
	end
end

 def set_begin
    @goban.fast_move= true
    while @current_node.prev != @root 
      undo_fast_node
      @current_node = @current_node.prev
    end
    @goban.fast_move=false
    set_backward

  end

end

