/*
 * Created on 11.02.2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package de.farafin.snEADy;

import de.farafin.snEADy.player.*;

import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


/**
 * @author lars and roland
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public final class C_DebugMonitor extends Frame {

	private static TextArea text;
	private Font[] f=new Font[2];
	private final int STRBUFFCAPACITY=8192;
	private StringBuffer strBuff;

	
	protected C_DebugMonitor(){
		this(800,120);
	}
	protected C_DebugMonitor(int width,int height){
	    
		super("snEADy - Debug Monitor");
		f[0]=new Font("Monospaced",Font.PLAIN,12);
		f[1]=new Font("Helvetica",Font.BOLD,12);

		strBuff=new StringBuffer(STRBUFFCAPACITY);
		
		
		
		this.setBounds(0,0,width,height);
		text=new TextArea();
		text.setFont(f[0]);
		/*
		this.addFocusListener(new FocusListener(){
		    public void focusGained(FocusEvent e){
		        root.transferFocus();
		    }
		    public void focusLost(FocusEvent e){
		        
		    }
		});*/
		add(text,BorderLayout.CENTER);
	   
		addWindowListener(new WindowAdapter(){
		    public void windowClosing(WindowEvent e){
		        setVisible(false);
		    }
		});
		text.setEditable(false);
		//setVisible(true);
	}
	
	
	public void say(String str){
	    
		strBuff.append(str + '\n');
	}
	public void say(Object obj){
		say(obj.toString());
	}
	public void say(SnakeInfo p,String str){
		if (p==null)
			say(str);
		else
			say(p.playerName + ":>" + str);
	}
	public void say(SnakeInfo p,Object obj){
		if (p==null)
			say(obj.toString());
		else
			say(p.playerName + ":>" + obj.toString());
	}
	public void sneadySay(String str){
		//this.setForeground(c[10]);
		say(str);
	}

	public void sayBuffered(){
	    text.append(strBuff.toString());
	    strBuff.delete(0,strBuff.length());
	}
	
	public void sayIm(String str){
		text.append(str + '\n');
	}
	public void sayIm(Object obj){
		sayIm(obj.toString());
	}
	public void sayIm(SnakeInfo p,String str){
		if (p==null)
			sayIm(str);
		else
			sayIm(p.playerName + ":>" + str);
	}
	public void sayIm(SnakeInfo p,Object obj){
		if (p==null)
			sayIm(obj.toString());
		else
			sayIm(p.playerName + ":>" + obj.toString());
	}
	public void sneadySayIm(String str){
		//this.setForeground(c[10]);
		sayIm(str);
	}
}
