#pragma once
#include <sstream>
#include <enginend/engine.h>
extern Color*LOADINGCOLOR[3];
struct logi: public virtual enginend::nodes::twod::textfield {
	logi(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fs,std::string txt) {
		this->pos=Vector2{x,y};this->size=Vector2{w,h};this->content=txt;this->theme=theme;
		this->texture=texture;
		this->fs=fs;
	}
	int delay=0;
		int wait=0,amount=10;
	void draw() override {
		float spacing=fs/2.0f;
		if(++delay>=10){
			Color*tmp=LOADINGCOLOR[2];
			LOADINGCOLOR[2]=LOADINGCOLOR[1];
			LOADINGCOLOR[1]=LOADINGCOLOR[0];
			LOADINGCOLOR[0]=tmp;
			delay=0;
		}
		if(++wait>20){
			wait=0;
			int max=(content.size()/2)*2;
			if(++amount>=max)amount=0;
		}
		int vispos=amount>>1;
		int len=content.size();
		Vector2 charPos=pos;
		for(int i=0;i<len;i++){
			int part=i/2;
			if(part<vispos||(part==vispos&&(amount%2==0||i<vispos*2))){
				char c=content[i];
				char str[2]={c,'\0'};
				Color fc=*LOADINGCOLOR[part%3];
				DrawTextEx(this->theme->font,str,charPos,(float)fs,spacing,fc);
				charPos.x+=MeasureTextEx(this->theme->font,str,(float)fs,spacing).x;
			} else break;
		}
	}
};
