package com.lloydm.javakogengine_chess; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.Typeface; import android.os.Environment; import android.util.Log; class RenderList { //optimisation for ui //21sep2021 public static int uistartindex; public static int uiendindex = -1; public static int ouistartindex; public static int ouiendindex; public static int uichecksum; public static int ouichecksum; public static int ouilength; public static int uilength; public static boolean uiredraw = true; // public static Bitmap uibmp; public static Canvas uicnv; public static Paint paint_clear; // public static int transitionmode = -1; //18apr2021 public static int HALFTRANSIT = 30;//18apr2021 public static int TRANSITIONRATE = 6;//18apr2021//7oct2021 tripled the rate....//21oct2021 changed from 3 to 6 public static int STARTTRANSITION = 60;//18apr2021 public static int screenshake = 0; public static boolean IGNOREZOOM; public static int RENDERMODE = 0;//22sep2021 public static int RENDERMODE_POOL = 0; public static int RENDERMODE_NONPOOL = 1; public Bitmap texture; public boolean istext; public boolean isrect; public boolean isline; public boolean filled; public int x; public int y; public int w; public int h; public int blend; public int index; public int frame; public int color; public float sx; public float sy; public boolean flipx; public boolean flipy; public float alpha; public float angle; public String text; public Typeface font; public int fontindex;//2apr2021//7apr2021 public boolean drawn; public boolean centre; public boolean ignorezoom; public boolean ignorefontalias; public static Matrix matrix; public static Paint paint0;//normal public static Paint paint1;//blend add public static Paint dpaint; public static Paint paint2;//unfilled public static Paint paintf0;// public static Paint paintf1;// public static Paint paintf2;// public static Canvas dcanvas; public static KRect src; public static KRect dst; public static Rect rsrc; public static Rect rdst; public static Bitmap backbuffer; public static Canvas backbuffercanvas; // public static int renderi = 0; public static int maxrenderi = 0; // public static int offsetx = 0; public static int offsety = 0; // public static boolean threadrunning = false; public static int recordframe = 0; public static int screenshotsurface; //start--------------//2apr2021 public boolean subimage; public int subx; public int suby; public int subw; public int subh; //end----------------//2apr2021 public static int renderframe; public static int pictureframe; ///////////////////Method Definition/////////////////21sep2021 public static void uisetstart() { uistartindex = renderi; uichecksum = 0; } ///////////////////Method Definition/////////////////21sep2021 public static void uisetend() { uiendindex = renderi; } ///////////////////Method Definition/////////////////21sep2021 public static void dirtyui() { uichecksum=ouichecksum-1; } ///////////////////Method Definition/////////////////21sep2021 public static boolean uicheckdirtyandinit() { uilength = uiendindex - uistartindex; if(uilength==ouilength && uichecksum==ouichecksum) { uiredraw = false; } else { uiredraw = true; } ouilength = ouiendindex - ouistartindex; ouistartindex = uistartindex; ouiendindex = uiendindex; ouichecksum = uichecksum; if(uibmp==null) { rsrc = new Rect(); rsrc.left = 0; rsrc.top = 0; rsrc.right = Game.RESOLUTIONX/Game.QUALITY; rsrc.bottom = Game.RESOLUTIONY/Game.QUALITY; uibmp = Bitmap.createBitmap(Game.RESOLUTIONX/Game.QUALITY,Game.RESOLUTIONY/Game.QUALITY,Bitmap.Config.ARGB_8888); uicnv = new Canvas(uibmp); //uicnv.drawRect(rsrc, paint_clear); uicnv.drawARGB(0, 0, 0,0); uiredraw = true; } if(uiredraw==true && rsrc!=null) { rsrc.left = 0; rsrc.top = 0; rsrc.right = Game.RESOLUTIONX/Game.QUALITY; rsrc.bottom = Game.RESOLUTIONY/Game.QUALITY; uicnv.drawARGB(0,0,0,0); } return uiredraw; } ///////////////////Method Definition/////////////////21sep2021 public static void finishui() { uichecksum = 0; uistartindex = 0; uiendindex = -1; } ///////////////////Method Definition/////////////////21sep2021 public static void uichecksum() { return; /* if(renderi>=uistartindex && renderi=0 && renderi0) { screenshake--; int offsetx=(int)(gxscale*(float)(Functions.rand(0,screenshake+1)-screenshake/2)); int offsety=(int)(gyscale*(float)(Functions.rand(0,screenshake+1)-screenshake/2)); Game.renderlist[i].x+=offsetx; Game.renderlist[i].y+=offsety; } // if(Game.renderlist[i].sx<0) { Game.renderlist[i].sx*=-1; Game.renderlist[i].flipx = true; } else { Game.renderlist[i].flipx = false; } if(Game.renderlist[i].sy<0) { Game.renderlist[i].sy*=-1; Game.renderlist[i].flipy = true; } else { Game.renderlist[i].flipy = false; } // if(Game.renderlist[i].isrect) { dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = Game.renderlist[i].w; dst.h = Game.renderlist[i].h; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; if(Game.renderlist[i].filled) { dpaint = paint0; dpaint.setColor(Game.renderlist[i].color); dcanvas.drawRect(dst.left, dst.top, dst.right, dst.bottom, dpaint); } else { dpaint = paint2; dpaint.setColor(Game.renderlist[i].color); dcanvas.drawRect(dst.left, dst.top, dst.right, dst.bottom, dpaint); } } if(Game.renderlist[i].isline) { dpaint = paint0; dpaint.setColor(Game.renderlist[i].color);//16oct2021 dcanvas.drawLine(Game.renderlist[i].x, Game.renderlist[i].y, Game.renderlist[i].x + Game.renderlist[i].w, Game.renderlist[i].y + Game.renderlist[i].h, dpaint); } if(Game.renderlist[i].istext) { if(Game.renderlist[i].text==null) { continue; } if(dpaint==null) { dpaint = paintf1; } if(Game.renderlist[i].font==null) { continue; } if(Game.renderlist[i].font==Game.fonts[Resources.SMALLFONT].font) { dpaint = paintf0; } if(Game.renderlist[i].font==Game.fonts[Resources.FONT].font) { dpaint = paintf1; } if(Game.renderlist[i].font==Game.fonts[Resources.LARGEFONT].font) { dpaint = paintf2; } dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dpaint.setColor(Game.renderlist[i].color); dpaint.getTextBounds(Game.renderlist[i].text, 0,Game.renderlist[i].text.length(), rsrc); dst.w = rsrc.right - rsrc.left; dst.h = rsrc.bottom - rsrc.top; dst.left = dst.x; dst.top = dst.y; dst.right = dst.x + dst.w; dst.bottom = dst.y + dst.h; if(Game.renderlist[i].centre) { dst.left = dst.x - dst.w/2; dcanvas.drawText(Game.renderlist[i].text, dst.left, dst.top, dpaint); } else { dcanvas.drawText(Game.renderlist[i].text, Game.renderlist[i].x, Game.renderlist[i].y, dpaint); } } if(Game.renderlist[i].texture!=null) { switch(Game.renderlist[i].blend) { case 0: dpaint = paint0; break; case 1: dpaint = paint1; break; } //start--------------//2apr2021 if(Game.renderlist[i].subimage) { src.x = Game.renderlist[i].subx; src.y = Game.renderlist[i].suby; src.w = Game.renderlist[i].subw; src.h = Game.renderlist[i].subh; dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = (int)(Game.renderlist[i].subw * Game.renderlist[i].sx); dst.h = (int)(Game.renderlist[i].subh * Game.renderlist[i].sy); dst.x -= dst.w/2; dst.y -= dst.h/2; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; src.left = dst.x; src.top = dst.y; src.bottom = dst.h + dst.y; src.right = dst.x + dst.w; rsrc.left = (int)src.left; rsrc.right = (int)src.right; rsrc.top = (int)src.top; rsrc.bottom = (int)src.bottom; rdst.left = (int)dst.left; rdst.right = (int)dst.right; rdst.top = (int)dst.top; rdst.bottom = (int)dst.bottom; if(!Game.images[Game.renderlist[i].index].beingrecycled) { dcanvas.drawBitmap(Game.renderlist[i].texture, rsrc, rdst, dpaint); } Game.renderlist[i].x = origx; Game.renderlist[i].y = origy; Game.renderlist[i].sx = origsx; Game.renderlist[i].sy = origsy; Game.renderlist[i].w = origw; Game.renderlist[i].h = origh; continue; } //end----------------//2apr2021 if(Game.images[Game.renderlist[i].index].anim) { if(Game.renderlist[i].frame<0)//20sep2021 { Game.renderlist[i].frame = 0; } src.x = Game.images[Game.renderlist[i].index].cwx * (Game.renderlist[i].frame % Game.images[Game.renderlist[i].index].cwn); src.y = Game.images[Game.renderlist[i].index].chy * ((Game.renderlist[i].frame - (Game.renderlist[i].frame % Game.images[Game.renderlist[i].index].cwn))/Game.images[Game.renderlist[i].index].cwn); src.w = Game.images[Game.renderlist[i].index].cwx; src.h = Game.images[Game.renderlist[i].index].chy; dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = (int)(src.w * Game.renderlist[i].sx); dst.h = (int)(src.h * Game.renderlist[i].sy); dst.x -= dst.w/2; dst.y -= dst.h/2; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; src.left = src.x; src.top = src.y; src.bottom = src.h + src.y; src.right = src.x + src.w; rsrc.left = (int)src.left; rsrc.right = (int)src.right; rsrc.top = (int)src.top; rsrc.bottom = (int)src.bottom; rdst.left = (int)dst.left; rdst.right = (int)dst.right; rdst.top = (int)dst.top; rdst.bottom = (int)dst.bottom; if(!Game.images[Game.renderlist[i].index].beingrecycled) { dcanvas.drawBitmap(Game.renderlist[i].texture, rsrc, rdst, dpaint); } } else { src.x = 0; src.y = 0; src.w = Game.images[Game.renderlist[i].index].cwx; src.h = Game.images[Game.renderlist[i].index].chy; dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = (int)(Game.images[Game.renderlist[i].index].cwx * Game.renderlist[i].sx); dst.h = (int)(Game.images[Game.renderlist[i].index].chy * Game.renderlist[i].sy); dst.x -= dst.w/2; dst.y -= dst.h/2; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; src.left = src.x; src.top = src.y; src.bottom = src.h + src.y; src.right = src.x + src.w; rsrc.left = (int)src.left; rsrc.right = (int)src.right; rsrc.top = (int)src.top; rsrc.bottom = (int)src.bottom; rdst.left = (int)dst.left; rdst.right = (int)dst.right; rdst.top = (int)dst.top; rdst.bottom = (int)dst.bottom; if(!Game.images[Game.renderlist[i].index].beingrecycled) { dcanvas.drawBitmap(Game.renderlist[i].texture, rsrc, rdst, dpaint); } } } //start----//19apr2021 //20sep2021 removed as phone screens don't change resolution mid game. Game.renderlist[i].x = origx; Game.renderlist[i].y = origy; Game.renderlist[i].sx = origsx; Game.renderlist[i].sy = origsy; Game.renderlist[i].w = origw; Game.renderlist[i].h = origh; //end------//19apr2021 } if(RenderList.renderi>RenderList.maxrenderi) { RenderList.maxrenderi = RenderList.renderi; } RenderList.renderi = 0; Functions.restoreseed(); Game.SW = MainActivity.actualWidth; Game.SH = MainActivity.actualHeight; } public static void prerender(Game game,Canvas canvas) { if(paint0==null) { // backbuffer = Bitmap.createBitmap(Game.RESOLUTIONX/Game.QUALITY, Game.RESOLUTIONY/Game.QUALITY, Bitmap.Config.ARGB_8888); backbuffercanvas = new Canvas(backbuffer); //matrix = new Matrix(); double dfactor = (((double)Game.RESOLUTIONX/(double)Game.RESOLUTIONY)*((double)Game.RESOLUTIONX/(double)Game.RESOLUTIONY)); dfactor/=((((double)MainActivity.actualWidth/(double)MainActivity.actualHeight))*(((double)MainActivity.actualWidth/(double)MainActivity.actualHeight))); float factor = (float)dfactor; if(Game.LETTERBOX) { factor*=0.65f; } paint0 = new Paint(); paint1 = new Paint(); paint2 = new Paint(); paint2.setStyle(Style.STROKE); PorterDuffXfermode xfer = new PorterDuffXfermode(PorterDuff.Mode.ADD); paint1.setXfermode(xfer); paintf0 = new Paint(); paintf0.setTypeface(Game.fonts[Resources.SMALLFONT].font); paintf0.setTextSize(factor*Game.fonts[Resources.SMALLFONT].ptsize/Game.QUALITY); paintf1 = new Paint(); paintf1.setTypeface(Game.fonts[Resources.FONT].font); paintf1.setTextSize(factor*Game.fonts[Resources.FONT].ptsize/Game.QUALITY); paintf2 = new Paint(); paintf2.setTypeface(Game.fonts[Resources.LARGEFONT].font); paintf2.setTextSize(factor*Game.fonts[Resources.LARGEFONT].ptsize/Game.QUALITY); } dpaint = paint0; dcanvas = canvas; if(src==null) { src = new KRect(); dst = new KRect(); rsrc = new Rect(); rdst = new Rect(); } } ///////////////////Method Definition/////////////// public static void render(Game game) { //////////////////////// //Core Render function that is called in the game //Takes all the drawimage/drawrect/drawtext calls that were stored //in an array and draws them one after the other //start------//15mar2021 renderframe++; //boolean chinese = false; Functions.saveseed(Functions.seed); //if(Translation.GetLanguage().equals("chinesesimplified")) //{ //chinese = true; //} //if(Config.useUNICODE) //{ //chinese = true; //} //end--------//15mar2021 //SDL.SDL_Rect src; //SDL.SDL_Rect dst; int SW = MainActivity.actualWidth; int SH = MainActivity.actualHeight; float gxscale = 1f; float gyscale = 1f; if(dcanvas==backbuffercanvas)// || dcanvas==uicnv) { SW = Game.RESOLUTIONX/Game.QUALITY; SH = Game.RESOLUTIONY/Game.QUALITY; } else { if(backbuffer!=null) { dpaint = paint0; rsrc.left = 0; rsrc.right = Game.RESOLUTIONX/Game.QUALITY; rsrc.top = 0; rsrc.bottom = Game.RESOLUTIONY/Game.QUALITY; rdst.top = 0; rdst.left = 0; rdst.right = SW; rdst.bottom = SH; if(Game.groundbitmap!=null)//14oct2021 { dcanvas.drawBitmap(Game.groundbitmap, rsrc, rdst, dpaint); } dcanvas.drawBitmap(backbuffer, rsrc, rdst, dpaint); Game.SW = SW; Game.SH = SH; return; } } Game.SW = SW; Game.SH = SH; for(int i=0;i=uistartindex && i=uistartindex && i0) { screenshake--; int offsetx=(int)(gxscale*(float)(Functions.rand(0,screenshake+1)-screenshake/2)); int offsety=(int)(gyscale*(float)(Functions.rand(0,screenshake+1)-screenshake/2)); Game.renderlist[i].x+=offsetx; Game.renderlist[i].y+=offsety; } // if(Game.renderlist[i].sx<0) { Game.renderlist[i].sx*=-1; Game.renderlist[i].flipx = true; } else { Game.renderlist[i].flipx = false; } if(Game.renderlist[i].sy<0) { Game.renderlist[i].sy*=-1; Game.renderlist[i].flipy = true; } else { Game.renderlist[i].flipy = false; } // if(Game.renderlist[i].isrect) { dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = Game.renderlist[i].w; dst.h = Game.renderlist[i].h; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; if(Game.renderlist[i].filled) { dpaint = paint0; dpaint.setColor(Game.renderlist[i].color); dcanvas.drawRect(dst.left, dst.top, dst.right, dst.bottom, dpaint); } else { dpaint = paint2; dpaint.setColor(Game.renderlist[i].color); dcanvas.drawRect(dst.left, dst.top, dst.right, dst.bottom, dpaint); } } if(Game.renderlist[i].isline) { dpaint = paint0; dpaint.setColor(Game.renderlist[i].color);//16oct2021 dcanvas.drawLine(Game.renderlist[i].x, Game.renderlist[i].y, Game.renderlist[i].x + Game.renderlist[i].w, Game.renderlist[i].y + Game.renderlist[i].h, dpaint); } if(Game.renderlist[i].istext) { if(Game.renderlist[i].text==null) { continue; } if(dpaint==null) { dpaint = paintf1; } if(Game.renderlist[i].font==null) { continue; } if(Game.renderlist[i].font==Game.fonts[Resources.SMALLFONT].font) { dpaint = paintf0; } if(Game.renderlist[i].font==Game.fonts[Resources.FONT].font) { dpaint = paintf1; } if(Game.renderlist[i].font==Game.fonts[Resources.LARGEFONT].font) { dpaint = paintf2; } dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dpaint.setColor(Game.renderlist[i].color); dpaint.getTextBounds(Game.renderlist[i].text, 0,Game.renderlist[i].text.length(), rsrc); dst.w = rsrc.right - rsrc.left; dst.h = rsrc.bottom - rsrc.top; dst.left = dst.x; dst.top = dst.y; dst.right = dst.x + dst.w; dst.bottom = dst.y + dst.h; if(Game.renderlist[i].centre) { dst.left = dst.x - dst.w/2; dcanvas.drawText(Game.renderlist[i].text, dst.left, dst.top, dpaint); } else { dcanvas.drawText(Game.renderlist[i].text, Game.renderlist[i].x, Game.renderlist[i].y, dpaint); } } if(Game.renderlist[i].texture!=null) { switch(Game.renderlist[i].blend) { case 0: dpaint = paint0; break; case 1: dpaint = paint1; break; } //start--------------//2apr2021 if(Game.renderlist[i].subimage) { src.x = Game.renderlist[i].subx; src.y = Game.renderlist[i].suby; src.w = Game.renderlist[i].subw; src.h = Game.renderlist[i].subh; dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = (int)(Game.renderlist[i].subw * Game.renderlist[i].sx); dst.h = (int)(Game.renderlist[i].subh * Game.renderlist[i].sy); dst.x -= dst.w/2; dst.y -= dst.h/2; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; src.left = dst.x; src.top = dst.y; src.bottom = dst.h + dst.y; src.right = dst.x + dst.w; rsrc.left = (int)src.left; rsrc.right = (int)src.right; rsrc.top = (int)src.top; rsrc.bottom = (int)src.bottom; rdst.left = (int)dst.left; rdst.right = (int)dst.right; rdst.top = (int)dst.top; rdst.bottom = (int)dst.bottom; if(!Game.images[Game.renderlist[i].index].beingrecycled) { dcanvas.drawBitmap(Game.renderlist[i].texture, rsrc, rdst, dpaint); } Game.renderlist[i].x = origx; Game.renderlist[i].y = origy; Game.renderlist[i].sx = origsx; Game.renderlist[i].sy = origsy; Game.renderlist[i].w = origw; Game.renderlist[i].h = origh; continue; } //end----------------//2apr2021 if(Game.images[Game.renderlist[i].index].anim) { if(Game.renderlist[i].frame<0)//20sep2021 { Game.renderlist[i].frame = 0; } src.x = Game.images[Game.renderlist[i].index].cwx * (Game.renderlist[i].frame % Game.images[Game.renderlist[i].index].cwn); src.y = Game.images[Game.renderlist[i].index].chy * ((Game.renderlist[i].frame - (Game.renderlist[i].frame % Game.images[Game.renderlist[i].index].cwn))/Game.images[Game.renderlist[i].index].cwn); src.w = Game.images[Game.renderlist[i].index].cwx; src.h = Game.images[Game.renderlist[i].index].chy; dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = (int)(src.w * Game.renderlist[i].sx); dst.h = (int)(src.h * Game.renderlist[i].sy); dst.x -= dst.w/2; dst.y -= dst.h/2; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; src.left = src.x; src.top = src.y; src.bottom = src.h + src.y; src.right = src.x + src.w; rsrc.left = (int)src.left; rsrc.right = (int)src.right; rsrc.top = (int)src.top; rsrc.bottom = (int)src.bottom; rdst.left = (int)dst.left; rdst.right = (int)dst.right; rdst.top = (int)dst.top; rdst.bottom = (int)dst.bottom; if(!Game.images[Game.renderlist[i].index].beingrecycled) { dcanvas.drawBitmap(Game.renderlist[i].texture, rsrc, rdst, dpaint); } } else { src.x = 0; src.y = 0; src.w = Game.images[Game.renderlist[i].index].cwx; src.h = Game.images[Game.renderlist[i].index].chy; dst.x = Game.renderlist[i].x; dst.y = Game.renderlist[i].y; dst.w = (int)(Game.images[Game.renderlist[i].index].cwx * Game.renderlist[i].sx); dst.h = (int)(Game.images[Game.renderlist[i].index].chy * Game.renderlist[i].sy); dst.x -= dst.w/2; dst.y -= dst.h/2; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; src.left = src.x; src.top = src.y; src.bottom = src.h + src.y; src.right = src.x + src.w; rsrc.left = (int)src.left; rsrc.right = (int)src.right; rsrc.top = (int)src.top; rsrc.bottom = (int)src.bottom; rdst.left = (int)dst.left; rdst.right = (int)dst.right; rdst.top = (int)dst.top; rdst.bottom = (int)dst.bottom; if(!Game.images[Game.renderlist[i].index].beingrecycled) { dcanvas.drawBitmap(Game.renderlist[i].texture, rsrc, rdst, dpaint); } } } //start----//19apr2021 //20sep2021 removed as phone screens don't change resolution mid game. Game.renderlist[i].x = origx; Game.renderlist[i].y = origy; Game.renderlist[i].sx = origsx; Game.renderlist[i].sy = origsy; Game.renderlist[i].w = origw; Game.renderlist[i].h = origh; //end------//19apr2021 } if(RenderList.renderi>RenderList.maxrenderi) { RenderList.maxrenderi = RenderList.renderi; } //start-----//18apr2021 if(transitionmode>=0) { //byte alpha = 255; int alpha = 255; if(transitionmode < HALFTRANSIT) { RenderList.renderi = 0; alpha = transitionmode * 8; } else { alpha = (60 - transitionmode) * 8; } src.x = 0; src.y = 0; src.w = 1; src.h = 1; dst.x = 0; dst.y = 0; dst.w = SW; dst.h = SH; dst.left = dst.x; dst.top = dst.y; dst.bottom = dst.h + dst.y; dst.right = dst.x + dst.w; src.left = dst.x; src.top = dst.y; src.bottom = dst.h + dst.y; src.right = dst.x + dst.w; dcanvas.drawARGB(alpha, 0,0,0); transitionmode-=TRANSITIONRATE; Functions.restoreseed(); return; } else { transitionmode = -1;//7oct2021 } //end-------//18apr2021 RenderList.renderi = 0; Functions.restoreseed(); } //draw an image ///////////////////Method Definition/////////////// public static void drawimage(Game game,Bitmap img,int x,int y,float angle,float scalex,float scaley,int framenumber,int blend,boolean istext,float alpha,int celltype) { //draw an image on the screen RenderList r; if(RenderList.renderi= 0 && celltype < Game.images.length) { Game.images[celltype].drawframe = Game.frame; } //end---------------//28Feb2021 if(RenderList.renderi>=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } // ///////////////////Method Definition/////////////// public static void drawanimimage(Game game,Bitmap img,int x,int y,float angle,float scalex,float scaley,int framenumber,int blend,boolean istext,float alpha,int index) { //draw an animated image on the screen //can be used as an alternative to drawimage, but they are mostly identical now. //RenderList r = new RenderList(); RenderList r; if(RenderList.renderi= 0 && index < Game.images.length) { Game.images[index].drawframe = Game.frame; } //end---------------//28Feb2021 if(RenderList.renderi>=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } ///////////////////Method Definition/////////////// public static void drawsubimage(Game game,Bitmap img,int x,int y,float angle,float scalex,float scaley,int framenumber,int blend,boolean istext,float alpha,int celltype,int ssx,int ssy,int ssw,int ssh)//2apr2021 { //draw an image on the screen RenderList r; if(RenderList.renderi= 0 && celltype < Game.images.length) { Game.images[celltype].drawframe = Game.frame; } //end---------------//28Feb2021 if(RenderList.renderi>=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } // //draw primitives ///////////////////Method Definition/////////////// public static void drawrect(Game game,int x,int y,int w,int h,int color,int blend) { //draw a filled rect on the screen //RenderList r = new RenderList(); RenderList r; if(RenderList.renderi=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } ///////////////////Method Definition/////////////// public static void drawunfilledrect(Game game,int x,int y,int w,int h,int color,int blend) { //draw an unfilled rect on the screen //RenderList r = new RenderList(); RenderList r; if(RenderList.renderi=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } ///////////////////Method Definition/////////////// public static void drawline(Game game,int sx,int sy,int fx,int fy,int color,int blend) { //draw a solid line on the screen //can also draw points. //RenderList r = new RenderList(); RenderList r; if(RenderList.renderi=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } //draw text ///////////////////Method Definition/////////////// public static void drawtext(Game game,int x,int y,final String text,int color,Typeface font,boolean centre) { //draw text with a certain font on the screen //RenderList r = new RenderList(); RenderList r; if(RenderList.renderi=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } ///////////////////Method Definition/////////////// public static void drawtext(Game game,Typeface font,int x,int y,float angle,float scalex,float scaley,boolean centre,int blend,final String text,float alpha,int color) { //alternative drawtext command //RenderList r = new RenderList(); RenderList r; if(RenderList.renderi=RenderList.maxrenderi) { Game.renderlist = (RenderList[]) ArrayResize.Resize(Game.renderlist,Game.renderlist.length + 1); //11apr2021 } Game.renderlist[RenderList.renderi] = r; Game.renderlist[RenderList.renderi].ignorezoom = IGNOREZOOM; uichecksum();//21sep2021 RenderList.renderi++; } //rgb helper functions. ///////////////////Method Definition/////////////// public static int getrgb(int r, int g, int b) { //return the rgb value by its components return Color.argb(255, r, g, b); //return (int)(255 << 24 | (byte)r << 16 | (byte)g << 8 | (byte)b); } ///////////////////Method Definition/////////////// public static int getrgb(byte r,byte g, byte b) { //return the rgb value by its components //return (int)(255 << 24 | r << 16 | g << 8 | b); return Color.argb(255, (int)r, (int)g, (int)b); } ///////////////////Method Definition/////////////// public static byte[] getcomponents(int argb) { //get the components of an argb colour and return an array of alpha, red, green, blue as a bunch of byte values byte[] rgbarray = {0,0,0,0}; rgbarray[0] = (byte)((argb >> 24) & (255)); rgbarray[1] = (byte)((argb >> 16) & (255)); rgbarray[2] = (byte)((argb >> 8) & 255); rgbarray[3] = (byte)((argb & 255)); return rgbarray; } ///////////////////Variables/////////////// public static boolean takingpicture = false; public static long picturetime = 0; public static long picturedelay = 2000; public static int picturecount = 0; ///////////////////Method Definition/////////////// public static void capturesequence(Bitmap inbmp) { if(System.currentTimeMillis()>picturetime || Game.takepicture==true) { picturetime = System.currentTimeMillis() + picturedelay; if(!takingpicture) { screenshot(inbmp); } } } ///////////////////Method Definition/////////////// public static void screenshot(Bitmap inbmp) { if(inbmp==null) { return; } if(takingpicture) { return; } takingpicture = true; picturecount++; if(Game.takepicture)//6oct2021 { picturecount=1; } if(picturecount>100) { //don't reset taking picture since we don't want to take any more than this in this session..... return; } try { final Bitmap bmp1 = inbmp.copy(Bitmap.Config.ARGB_8888, false); new Thread(new Runnable() { @Override public void run() { try { FileOutputStream fos = null; BufferedOutputStream bos = null; File picfolder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + "kogmobilepc/"); picfolder.mkdirs(); if (!picfolder.exists()) { //don't reset takingpicture since we don't want to come in here again...... bmp1.recycle(); return; } if (picfolder.isDirectory()) { // write to it..... pictureframe++; pictureframe%=200; File picfile = new File(picfolder, "img" + pictureframe + ".jpg"); try { fos = new FileOutputStream(picfile); bmp1.compress(CompressFormat.JPEG, 80, fos); bos = new BufferedOutputStream(fos, 8196); bos.flush(); } catch (Exception ef) { Log.e(Config.TAG, "Error opening file for writing"); } finally { try { if (fos != null) { fos.close(); } } catch (Exception e) { Log.e(Config.TAG, "Error with pic saving"); } try { if (bos != null) { bos.close(); } } catch (Exception gg) { Log.e(Config.TAG, "Error with pic saving (bos)"); } try { bmp1.recycle(); } catch (Exception gg) { Log.e(Config.TAG, "Error recycling bitmap..."); } } } } catch (Exception ffg2) { // something went hideously wrong...hideously! Log.e(Config.TAG, "Error...."); } takingpicture = false; } }).start(); } catch(Exception finalbmperror) { //probably errored on bitmap creation...... } } } //