class GameDisplay < VTexturedPane

  attr_reader :komi

  def initialize (parent)
    super(parent, Defaults::DEFS['DeepBlue'],0,0,0,0)
    set_fixed_size(100,160)

    @f_inf = add_text(TkDefaults::GUI['GameInfo.text.game_info'])
    @ft_inf = add_text(TkDefaults::GUI['GameInfo.text.game_type'])
    @h_inf = add_text(TkDefaults::GUI['GameInfo.text.handicap_info'])
    @k_inf= add_text(TkDefaults::GUI['GameInfo.text.komi_info'])
    @t_inf = add_text(TkDefaults::GUI['GameInfo.text.time_info'])
    add_text(TkDefaults::GUI['GameInfo.text.byo-yomi'])
    @bt_inf = add_text(TkDefaults::GUI['GameInfo.text.byo_time'])
    @bs_inf = add_text(TkDefaults::GUI['GameInfo.text.byo_stones'])
    @bp_inf = add_text(TkDefaults::GUI['GameInfo.text.byo_number'])

    reconfigure
    set_komi(0.0)
  end

  def set_type(type = '')
    @ft_inf.configure('text' => type)
  end

  def set_number(n)
    @number = n
    @f_inf.configure('text' => 'Game '+ @number.to_s)
  end


  def seconds_to_string(c)
    s = c % 60
    r = ( c - s ) / 60
    m = r % 60
    h = ( r - m ) / 60
    sprintf("%02d:%02d:%02d",h,m,s)
  end

  def set_time(t)
    if t == ''
      @t_inf.configure('text' => '')
    else
      @t_inf.configure('text' => 'time: '+seconds_to_string(t))
    end
  end

  def set_byo_time(t)
    if t == ''
      @bt_inf.configure('text' => '')
    else
      @bt_inf.configure('text' => 'time: '+ seconds_to_string(t)) 
    end

  end


  def set_byo_stones(v)
    @bs_inf.configure('text' => 'stones: '+ v.to_s)
  end

  def set_byo_periods(v)
    @bp_inf.configure('text' => 'periods: '+ v.to_s)
  end
  def set_handi(h)
    @h_inf.configure('text'=>'Handicap: ' + h.to_s)
  end
  def set_komi(k)
    @komi= k
    @k_inf.configure('text'=>'Komi: ' + k.to_s)
  end
end


