//=============================================================================
// SpriteProgress.js
//=============================================================================

/*:ja
 * @plugindesc ゲーム進行状況の表示  
 * @author Milk Force
 * 
 * @help　bitmap.blt で直前の画像が残る問題を解決出来ないので画像をそのまま表示する泥臭い実装とする
 */
var $sprite_progress=null;
(function() {
	'use strict';
	
	var _Spriteset_Base_prototype_createUpperLayer=Spriteset_Base.prototype.createUpperLayer;
	Spriteset_Base.prototype.createUpperLayer = function() {
		_Spriteset_Base_prototype_createUpperLayer.call(this);

		this.addChild($sprite_progress);
	};

})();

function Sprite_Progress() {
	this.initialize.apply(this, arguments);
}

Sprite_Progress.prototype = Object.create(Sprite.prototype);
Sprite_Progress.prototype.constructor = Sprite_Progress;

Sprite_Progress.prototype.initialize = function() {
	Sprite.prototype.initialize.call(this);
	
	this._picID=96;
	this.x=Graphics.width - 176;
	this.y=0;
	
	$gameSwitches.setValue(7,true);//再描画フラグ 状態が替わればEventControlがtrueにする
	this._active=false;//表示中フラグ
	
	this.update();
};


Sprite_Progress.prototype.update = function() {
	Sprite.prototype.update.call(this);
	
	this.visible=$gameSwitches.value(6);
		
	if($gameSwitches.value(7)){
		this.redraw();
		$gameSwitches.setValue(7,false);
		this._active=true;//表示中フラグ
	}
	
	if(!this.visible && this._active){
		for(var i=this._picID;i<=this._picID+3;i++){
			$gameScreen.erasePicture(i);
		}
	}	
};

Sprite_Progress.prototype.redraw = function() {
	//ベース表示
	$gameScreen.showPicture(this._picID,"sys_mp_gage_skin",0,this.x,this.y,100,100,255,0);
	if($gameVariables.value(99)==1){//夜
		$gameScreen.showPicture(this._picID+1,"sys_mp_gage_moon",0,this.x,this.y,100,100,255,0);
	}
	
	//日付表示
	$gameScreen.showPicture(this._picID+2,"sys_day40h_"+$gameVariables.value(100).toString(),0,this.x+46,this.y+5,100,100,255,0);
	//MP表示
	this._showMP();
	
};
Sprite_Progress.prototype._showMP = function() {
	var fileNo=1;
	switch($gameVariables.value(1)){
		case 100: fileNo=100; break;
		case 90: fileNo=90; break;
		case 80: fileNo=80; break;
		case 70: fileNo=70; break;
		case 60: fileNo=60; break;
		case 50: fileNo=50; break;
		case 40: fileNo=40; break;
		case 30: fileNo=30; break;
		case 20: fileNo=20; break;
		case 10: fileNo=10; break;
		case 0: fileNo=0; break;
	}
	
	if(fileNo!=1){
		$gameScreen.showPicture(this._picID+3,"sys_mp_gage_"+fileNo.toString(),0,this.x,this.y,100,100,255,0);
	}
	
};
