#include "diagnosticScene.h"

//---------------------------------------
diagnosticScene::diagnosticScene(){

}

//---------------------------------------
void diagnosticScene::exit(){

}

//---------------------------------------
void diagnosticScene::setupScene(){
	sceneName = "diagnostic scene!";
	addAppListener();
	addMouseListener();
	addKeyboardListener();
	setAutoRender(true);
	
}

//---------------------------------------
void diagnosticScene::update(){
	if(pause)return;
	
}

//---------------------------------------
void diagnosticScene::render(){
	if( hide ) return;
	
	glPushMatrix();
	
	ofEnableAlphaBlending();
	for(int i = 0; i < currentCards.size(); i++){
		if( currentCards[i].ptsSet ){
			
			ofSetColor(0, 100, 255);
			ofNoFill();
			ofBeginShape();
			for(int j = 0; j < 4; j++){
				ofVertex(currentCards[i].c[j].x, currentCards[i].c[j].y);
			}
			ofEndShape(true);
			ofBeginShape();
			for(int j = 0; j < 4; j++){
				ofVertex(currentCards[i].sqPts[j].x, currentCards[i].sqPts[j].y);
			}
			ofEndShape(true);
			
			ofSetColor(255,255,0,200);
			ofFill();
			for(int j = 0; j < 4; j++){
				ofCircle(currentCards[i].c[j].x, currentCards[i].c[j].y, 10);
			}
			
			ofSetColor(0,0,0,255);
			ofDrawBitmapString("a",currentCards[i].c[ currentCards[i].pta ].x-3, currentCards[i].c[ currentCards[i].pta ].y);
			ofDrawBitmapString("b",currentCards[i].c[ currentCards[i].ptb ].x-3, currentCards[i].c[ currentCards[i].ptb ].y);
			ofDrawBitmapString("c",currentCards[i].c[ currentCards[i].ptc ].x-3, currentCards[i].c[ currentCards[i].ptc ].y);
			ofDrawBitmapString("d",currentCards[i].c[ currentCards[i].ptd ].x-3, currentCards[i].c[ currentCards[i].ptd ].y);
			
			
			if( currentCards[i].whichCard != -1 ){
				ofSetColor(20, 20, 160, 190);
				ofRect(currentCards[i].center.x-8, currentCards[i].center.y-12, 56, 46);
				ofSetColor(0x00FF00);	
				ofDrawBitmapString(ofToString(currentCards[i].id)+ " act: " + ofToString(currentCards[i].activity) + "\ncard: " + ofToString(currentCards[i].getCard()) + " suit: " + ofToString(currentCards[i].getSuit()), currentCards[i].center.x - 4, currentCards[i].center.y + 2);
			}
			
//			ofSetColor(0xffffff);
//			if( currentCards[i].whichCard != -1 ){
//				int who = currentCards[i].whichCard;
//				newCardBankImages[who].cardImage.draw(640 + currentCards[i].center.x/2, 240+currentCards[i].center.y/2,32,40);
//				//ofCircle(currentCards[i].center.x, currentCards[i].center.y, 40);
//			}	
			
			// useful to toggle this drawin.g
			//currentCards[i].drawAnalysisResults(currentCards[i].center.x/2, currentCards[i].center.y/2);
			
			//				
			//				
			//				if( currentCards[i].whichCard != -1 ){
			//					ofSetColor(20, 20, 160, 190);
			//					ofRect(currentCards[i].center.x-8, currentCards[i].center.y-12, 56, 23);
			//					ofSetColor(0x00FF00);	
			//					ofDrawBitmapString(ofToString(currentCards[i].whichCard)+ " = " + ofToString(currentCards[i].getCard()) + " " + ofToString(currentCards[i].diff, 3), currentCards[i].center.x - 4, currentCards[i].center.y + 2);
			//				}
			//				
			//				for (int j = 0; j < 3; j++){
			//					if( currentCards[i].whichCardHu[j] != -1 ){
			//						ofSetColor(20, 20, 160, 190);
			//						ofRect(currentCards[i].center.x-8, currentCards[i].center.y-12 + (j+1)*15, 56, 23);
			//						ofSetColor(0x00FF00);	
			//						ofDrawBitmapString(ofToString(currentCards[i].whichCardHu[j]) + " " + ofToString(currentCards[i].diffHu[j]*10, 3), currentCards[i].center.x - 4, currentCards[i].center.y + 2 + (1+j)*15);
			//					}
			//				}
			//				
			//				// this should be a function, yikes: 
			//				
			//				ofSetColor(20, 20, 160, 190);
			//				ofRect(currentCards[i].center.x-8, currentCards[i].center.y-12 +60, 56, 23);
			//				ofSetColor(0x00FF00);	
			//				ofDrawBitmapString("pct white " + ofToString(currentCards[i].pctWhitePixels, 4), currentCards[i].center.x - 4, currentCards[i].center.y + 2 + 60);
			//									
			//				ofSetColor(20, 20, 160, 190);
			//				ofRect(currentCards[i].center.x-8, currentCards[i].center.y-12 +75, 56, 23);
			//				ofSetColor(0x00FF00);	
			//				ofDrawBitmapString( ofToString((int)currentCards[i].avgColor.x) + " " + ofToString((int)currentCards[i].avgColor.y) + " " + ofToString((int)currentCards[i].avgColor.z), currentCards[i].center.x - 4, currentCards[i].center.y + 2 + 75);
			//				
			//				ofSetColor(20, 20, 160, 190);
			//				ofRect(currentCards[i].center.x-8, currentCards[i].center.y-12 +90, 56, 23);
			//				ofSetColor(0x00FF00);	
			//				ofDrawBitmapString( currentCards[i].bFaceCard == true ? "face card" : "number card" , currentCards[i].center.x - 4, currentCards[i].center.y + 2 + 90);
			//				
			//				ofSetColor(20, 20, 160, 190);
			//				ofRect(currentCards[i].center.x-8, currentCards[i].center.y-12 +105, 56, 23);
			//				ofSetColor(0x00FF00);	
			//				ofDrawBitmapString( currentCards[i].bRedSuit == true ? "red card" : "black card (or face card)" , currentCards[i].center.x - 4, currentCards[i].center.y + 2 + 105);
			//				
			
		}
	}
	ofDisableAlphaBlending();		
	
	glPopMatrix();	
	
	
	
	if(debug){
		//drawTxtMsg("scene is: "+sceneName, 0, camH-40);
		//drawDebugTxt(0, camH-20);	
	}		
}

//---------------------------------------		
void diagnosticScene::keyPressed( int key ){
	if(pause)return;

}

//---------------------------------------
void diagnosticScene::keyReleased( int key ){
	if(pause)return;
	
}
	
//---------------------------------------
void diagnosticScene::mouseMoved(int x, int y ){
	if(pause)return;
	

}

//---------------------------------------
void diagnosticScene::mouseDragged( int x, int y, int button ){
	if(pause)return;


}

//---------------------------------------
void diagnosticScene::mousePressed( int x, int y, int button ){
	if(pause)return;


}

//---------------------------------------
void diagnosticScene::mouseReleased(int x, int y, int button ){
	if(pause)return;	
	

}	

