swwmgz_m/zscript/dlc1/swwm_dlcweapons_canvas.zsc

293 lines
14 KiB
Text

// RenderTexture code for DLC weapons
// Plasma Blaster
extend Class PlasmaBlast
{
override void RenderTexture( RenderEvent e )
{
// ammo display
// dynamic glow
}
}
extend Class DualPlasmaBlast
{
override void RenderTexture( RenderEvent e )
{
// render right-hand weapon's scripted textures as well
SWWMWeapon(SisterWeapon).RenderTexture(e);
// ammo display
// dynamic glow
}
}
// Sheen HMG
extend Class HeavyMahSheenGun
{
transient ui Canvas AmmoLed;
ui TextureID AmmoLedBase, AmmoLedBar, AmmoLedSpeed, AmmoLedNums;
override void RenderTexture( RenderEvent e )
{
if ( !AmmoLed ) AmmoLed = TexMan.GetCanvas("SHEENLED");
if ( !AmmoLedBase ) AmmoLedBase = TexMan.CheckForTexture("models/canvas/SheenLEDBase.png");
if ( !AmmoLedBar ) AmmoLedBar = TexMan.CheckForTexture("models/canvas/SheenLEDBar.png");
if ( !AmmoLedSpeed ) AmmoLedSpeed = TexMan.CheckForTexture("models/canvas/SheenLEDSpeed.png");
if ( !AmmoLedNums ) AmmoLedNums = TexMan.CheckForTexture("models/canvas/SheenLEDNums.png");
int d1 = Ammo1.Amount%10;
int d2 = (Ammo1.Amount/10)%10;
int d3 = (Ammo1.Amount/100)%10;
AmmoLed.DrawTexture(AmmoLedBase,false,0,0,DTA_Color,0xFF00FF00);
AmmoLed.DrawTexture(AmmoLedSpeed,false,16,16,DTA_SrcHeight,16,DTA_DestHeight,16,DTA_Color,(firespeed==0)?0xFF80FF00:0xFF408000,DTA_LegacyRenderStyle,STYLE_Add);
AmmoLed.DrawTexture(AmmoLedSpeed,false,48,16,DTA_SrcY,16,DTA_SrcHeight,16,DTA_DestHeight,16,DTA_Color,(firespeed==1)?0xFFFFFF00:0xFF808000,DTA_LegacyRenderStyle,STYLE_Add);
AmmoLed.DrawTexture(AmmoLedSpeed,false,80,16,DTA_SrcY,32,DTA_SrcHeight,16,DTA_DestHeight,16,DTA_Color,(firespeed==2)?0xFFFF8000:0xFF804000,DTA_LegacyRenderStyle,STYLE_Add);
if ( incooldown )
AmmoLed.DrawTexture(AmmoLedNums,false,16,32,DTA_SrcX,64,DTA_SrcY,64,DTA_SrcWidth,96,DTA_SrcHeight,64,DTA_DestWidth,96,DTA_DestHeight,64,DTA_Color,((gametic%8)>=4)?0xFFFF0000:0xFF800000,DTA_LegacyRenderStyle,STYLE_Add);
else
{
Vector3 rgb = SWWMUtility.HSVtoRGB(((Ammo1.Amount/4.)/Ammo1.MaxAmount,1.,1.));
Color numcol = Color(255,int(rgb.x*255),int(rgb.y*255),int(rgb.z*255));
Color blkcol = Color(255,int(rgb.x*128),int(rgb.y*128),int(rgb.z*128));
AmmoLed.DrawTexture(AmmoLedNums,false,16,32,DTA_SrcX,(d3%8)*32,DTA_SrcY,(d3/8)*64,DTA_SrcWidth,32,DTA_SrcHeight,64,DTA_DestWidth,32,DTA_DestHeight,64,DTA_Color,(!d3)?blkcol:numcol,DTA_LegacyRenderStyle,STYLE_Add);
AmmoLed.DrawTexture(AmmoLedNums,false,48,32,DTA_SrcX,(d2%8)*32,DTA_SrcY,(d2/8)*64,DTA_SrcWidth,32,DTA_SrcHeight,64,DTA_DestWidth,32,DTA_DestHeight,64,DTA_Color,(!d3&&!d2)?blkcol:numcol,DTA_LegacyRenderStyle,STYLE_Add);
AmmoLed.DrawTexture(AmmoLedNums,false,80,32,DTA_SrcX,(d1%8)*32,DTA_SrcY,(d1/8)*64,DTA_SrcWidth,32,DTA_SrcHeight,64,DTA_DestWidth,32,DTA_DestHeight,64,DTA_Color,(!d3&&!d2&&!d1)?blkcol:numcol,DTA_LegacyRenderStyle,STYLE_Add);
}
double ht = barrelheat*.96;
AmmoLed.DrawTexture(AmmoLedBar,false,16,100,DTA_SrcWidth,ht,DTA_DestWidthF,ht,DTA_Color,0xFFFF0000,DTA_LegacyRenderStyle,STYLE_Add);
}
}
// Quadravol
extend Class Quadravol
{
transient ui Canvas AmmoLed;
ui TextureID AmmoLedBase, AmmoLedRound, AmmoLedCharge;
override void RenderTexture( RenderEvent e )
{
if ( !AmmoLed ) AmmoLed = TexMan.GetCanvas("QUADRLED");
if ( !AmmoLedBase ) AmmoLedBase = TexMan.CheckForTexture("models/canvas/QuadLEDBase.png");
if ( !AmmoLedRound ) AmmoLedRound = TexMan.CheckForTexture("models/canvas/QuadLEDRound.png");
if ( !AmmoLedCharge ) AmmoLedCharge = TexMan.CheckForTexture("models/canvas/QuadLEDCharge.png");
AmmoLed.Clear(0,0,64,64,0xFF101033);
AmmoLed.DrawTexture(AmmoLedBase,false,0,0,DTA_LegacyRenderStyle,STYLE_Shaded,DTA_FillColor,0xFF00FFFF);
Color col;
switch ( chargelevel )
{
default:
col = 0xFF00FF00;
break;
case 1:
case 9:
col = 0xFF0080FF;
break;
case 2:
case 8:
col = 0xFF0000FF;
break;
case 3:
case 7:
col = 0xFF8000FF;
break;
case 4:
case 6:
col = 0xFFFF0080;
break;
case 5:
col = 0xFFFF0000;
break;
}
AmmoLed.DrawTexture(AmmoLedCharge,false,12,4,DTA_SrcX,(chargelevel%4)*64,DTA_SrcY,(chargelevel/4)*64,DTA_SrcWidth,40,DTA_SrcHeight,40,DTA_DestWidth,40,DTA_DestHeight,40,DTA_LegacyRenderStyle,STYLE_Shaded,DTA_FillColor,col);
for ( int i=0; i<clipcount; i++ ) AmmoLed.DrawTexture(AmmoLedRound,false,36-8*i,52,DTA_LegacyRenderStyle,STYLE_Shaded,DTA_FillColor,0xFFFF8000);
if ( chambered ) AmmoLed.DrawTexture(AmmoLedRound,false,52,52,DTA_LegacyRenderStyle,STYLE_Shaded,DTA_FillColor,charged?0xFF404040:0xFFFF8000);
}
}
// Ray-Khom
extend Class RayKhom
{
override void RenderTexture( RenderEvent e )
{
// ammo display
}
}
// Mortal Rifle
extend Class MisterRifle
{
transient ui Canvas TouchScreen, AmmoLed;
ui Font MortalFontSmall, MortalFontMed, MortalFontBig;
ui TextureID MortalBG, MortalIcons[2], AmmoLedFont, FrameTex;
transient ui int oldammo, oldfiremode, oldgrenade;
transient ui int ammoflash, firemodeflash, grenadeflash;
// this also uses the crime clock (oh my)
transient ui int c_year, c_month, c_day, c_hour, c_minute;
transient ui String c_tz;
transient ui bool c_init;
private ui void DrawWindowFrame( int x, int y, int w, int h, int padx = 4, int pady = 4 )
{
if ( !FrameTex ) FrameTex = TexMan.CheckForTexture("models/canvas/MortalFrameTex.png");
x -= padx/2;
y -= pady/2;
w += padx;
h += pady;
TouchScreen.Dim("Black",.8,x,y,w,h);
TouchScreen.DrawTexture(FrameTex,false,x,y,DTA_SrcX,0.,DTA_SrcY,0.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,1);
if ( w > 2 ) TouchScreen.DrawTexture(FrameTex,false,x+1,y,DTA_SrcX,1.,DTA_SrcY,0.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,int(w-2),DTA_DestHeight,1);
if ( h > 2 ) TouchScreen.DrawTexture(FrameTex,false,x,y+1,DTA_SrcX,0.,DTA_SrcY,1.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,int(h-2));
TouchScreen.DrawTexture(FrameTex,false,(x+w)-1,y,DTA_SrcX,2.,DTA_SrcY,0.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,1);
TouchScreen.DrawTexture(FrameTex,false,x,(y+h)-1,DTA_SrcX,0.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,1);
if ( h > 2 ) TouchScreen.DrawTexture(FrameTex,false,(x+w)-1,y+1,DTA_SrcX,2.,DTA_SrcY,1.,DTA_SrcWidth,2.,DTA_SrcHeight,1.,DTA_DestWidth,2,DTA_DestHeight,int(h-2));
if ( w > 2 ) TouchScreen.DrawTexture(FrameTex,false,x+1,(y+h)-1,DTA_SrcX,1.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,2.,DTA_DestWidth,int(w-2),DTA_DestHeight,2);
TouchScreen.DrawTexture(FrameTex,false,(x+w)-1,(y+h)-1,DTA_SrcX,2.,DTA_SrcY,2.,DTA_SrcWidth,2.,DTA_SrcHeight,2.,DTA_DestWidth,2,DTA_DestHeight,2);
}
override void RenderTexture( RenderEvent e )
{
if ( !c_init )
{
c_init = true;
DemolitionistMenu.SetClock(c_year,c_month,c_day,c_hour,c_minute,c_tz);
}
int ingun = min(clipcount+(chambered&&!fired),99);
bool increase = (ingun>oldammo);
if ( ingun != oldammo ) ammoflash = increase?(gametic+30):(gametic+10);
oldammo = ingun;
if ( firemode+1 != oldfiremode ) firemodeflash = gametic+20;
oldfiremode = firemode+1;
int gstate = gchambered?gfired?2:1:0;
if ( gstate != oldgrenade ) grenadeflash = gametic+20;
oldgrenade = gstate;
// Side touchscreen
if ( !TouchScreen ) TouchScreen = TexMan.GetCanvas("MORTLED1");
if ( !MortalFontSmall ) MortalFontSmall = Font.GetFont("MortalFont20");
if ( !MortalFontMed ) MortalFontMed = Font.GetFont("MortalFont40");
if ( !MortalFontBig ) MortalFontBig = Font.GetFont("MortalFont80");
if ( !MortalBG ) MortalBG = TexMan.CheckForTexture("models/canvas/MortalBG.png");
if ( !MortalIcons[0] ) MortalIcons[0] = TexMan.CheckForTexture("models/canvas/MortalFireIcons.png");
if ( !MortalIcons[1] ) MortalIcons[1] = TexMan.CheckForTexture("models/canvas/MortalGrenadeIcons.png");
TouchScreen.DrawTexture(MortalBG,false,0,0);
TouchScreen.Dim("Black",.8,0,0,256,22);
String str = "MR\cu-\c-"..serialnum;
TouchScreen.DrawText(MortalFontSmall,Font.CR_WHITE,8,0,str);
str = DemolitionistMenu.CrimeTime(c_year,c_month,c_day,c_hour,c_minute,c_tz,true);
if ( gametic%32 >= 16 ) str.Replace(":"," ");
else str.Replace(":","\cu:\c-");
TouchScreen.DrawText(MortalFontSmall,Font.CR_WHITE,248-MortalFontSmall.StringWidth(str),0,str);
str = String.Format("%2d",ingun);
int fw = MortalFontBig.StringWidth(str), fh = MortalFontBig.GetHeight();
DrawWindowFrame(80-fw/2,72-fh/2,fw,fh,32);
bool blink = (ingun<=4)&&(gametic%16<=8);
if ( ingun <= 0 ) TouchScreen.DrawText(MortalFontBig,Font.FindFontColor("MiniBlurp"),80-fw/2,72-fh/2,"00",DTA_ColorOverlay,blink?0xA0000000:0x80000000);
else
{
TouchScreen.DrawText(MortalFontBig,Font.FindFontColor("MiniBlurp"),80-fw/2,72-fh/2,str,DTA_ColorOverlay,blink?0x80000000:0x00000000);
if ( ingun < 10 ) TouchScreen.DrawText(MortalFontBig,Font.FindFontColor("MiniBlurp"),80-fw/2,72-fh/2,"0 ",DTA_ColorOverlay,blink?0xA0000000:0x80000000);
}
if ( ammoflash && (gametic < ammoflash) )
{
double alph = (increase?clamp((ammoflash-(gametic+e.fractic))/25.,0.,1.):clamp((ammoflash-(gametic+e.fractic))/5.,0.,1.))**2.;
if ( ingun <= 0 ) TouchScreen.DrawText(MortalFontBig,Font.FindFontColor("MiniWhiteFlash"),80-fw/2,72-fh/2,"00",DTA_ColorOverlay,blink?0xA0000000:0x80000000,DTA_Alpha,alph*.8,DTA_LegacyRenderStyle,STYLE_Add);
else
{
TouchScreen.DrawText(MortalFontBig,Font.FindFontColor("MiniWhiteFlash"),80-fw/2,72-fh/2,str,DTA_ColorOverlay,blink?0x80000000:0x00000000,DTA_Alpha,alph*.8,DTA_LegacyRenderStyle,STYLE_Add);
if ( ingun < 10 ) TouchScreen.DrawText(MortalFontBig,Font.FindFontColor("MiniWhiteFlash"),80-fw/2,72-fh/2,"0 ",DTA_ColorOverlay,blink?0xA0000000:0x80000000,DTA_Alpha,alph*.8,DTA_LegacyRenderStyle,STYLE_Add);
}
}
fw = 64;
fh = 32;
DrawWindowFrame(200-fw/2,72-(fh+8),fw,fh);
TouchScreen.DrawTexture(MortalIcons[0],false,200-fw/2,72-(fh+8),DTA_SrcY,firemode*32,DTA_SrcHeight,32,DTA_DestHeight,32,DTA_SrcX,0,DTA_SrcWidth,64,DTA_DestWidth,64);
if ( firemodeflash && (gametic < firemodeflash) )
{
double alph = clamp((firemodeflash-(gametic+e.fractic))/15.,0.,1.)**2.;
TouchScreen.DrawTexture(MortalIcons[0],false,200-fw/2,72-(fh+8),DTA_SrcY,firemode*32,DTA_SrcHeight,32,DTA_DestHeight,32,DTA_SrcX,64,DTA_SrcWidth,64,DTA_DestWidth,64,DTA_Alpha,alph*.8,DTA_LegacyRenderStyle,STYLE_Add);
}
str = StringTable.Localize("$SWWM_MRMODE"..(firemode+1));
DrawWindowFrame(200-fw/2,72+8,fw,fh);
if ( gchambered )
{
TouchScreen.DrawTexture(MortalIcons[1],false,200-fw/2,72+8,DTA_SrcY,gfired*32,DTA_SrcHeight,32,DTA_DestHeight,32,DTA_SrcX,0,DTA_SrcWidth,64,DTA_DestWidth,64,DTA_ColorOverlay,gfired?0x80000000:0x00000000);
if ( grenadeflash && (gametic < grenadeflash) )
{
double alph = clamp((grenadeflash-(gametic+e.fractic))/15.,0.,1.)**2.;
TouchScreen.DrawTexture(MortalIcons[1],false,200-fw/2,72+8,DTA_SrcY,gfired*32,DTA_SrcHeight,32,DTA_DestHeight,32,DTA_SrcX,64,DTA_SrcWidth,64,DTA_DestWidth,64,DTA_Alpha,alph*(gfired?.4:.8),DTA_LegacyRenderStyle,STYLE_Add);
}
}
if ( lowammotic && (lowammotic > gametic) )
{
// low ammo alert
str = StringTable.Localize("$SWWM_MRLOW");
fw = MortalFontMed.StringWidth(str);
fh = MortalFontMed.GetHeight();
DrawWindowFrame(128-fw/2,72-fh/2,fw,fh,8,4);
TouchScreen.DrawText(MortalFontMed,Font.FindFontColor("MiniBrass"),128-fw/2,72-fh/2,str,DTA_ColorOverlay,(gametic%8>=4)?0x80000000:0x000000);
}
if ( noammotic && (noammotic > gametic) )
{
// empty alert
str = StringTable.Localize("$SWWM_MRNONE");
fw = MortalFontBig.StringWidth(str);
fh = MortalFontBig.GetHeight();
DrawWindowFrame(128-fw/2,72-fh/2,fw,fh,16,8);
TouchScreen.DrawText(MortalFontBig,Font.FindFontColor("MiniRed"),128-fw/2,72-fh/2,str,DTA_ColorOverlay,(gametic%16>=8)?0x80000000:0x000000);
}
if ( prefirecnt > 0 )
{
// charge bar
Font fnt;
int fofs;
if ( prefirecnt >= 100 )
{
str = StringTable.Localize("$SWWM_MRREADY");
fnt = MortalFontMed;
fofs = 0;
}
else
{
str = StringTable.Localize("$SWWM_MRCHARGE");
fnt = MortalFontSmall;
fofs = (MortalFontMed.GetHeight()-MortalFontSmall.GetHeight())/2;
}
int strw = fnt.StringWidth(str);
int strh = MortalFontMed.GetHeight();
fw = max(strw,128);
fh = strh+16;
DrawWindowFrame(128-fw/2,72-fh/2,fw,fh,8,4);
TouchScreen.Dim(0xFF000000,.8,128-52,72+(fh/2-14),104,12);
double bw = PreFireInter.GetValue(e.FracTic);
Color barcol = SWWMUtility.LerpColor(0xFF000080,0xFF00C0FF,bw/100.);
TouchScreen.Dim(barcol,1.,128-50,72+(fh/2-12),int(bw),8);
TouchScreen.DrawText(fnt,Font.FindFontColor("MiniCyanblu"),128-strw/2,72-fh/2+fofs,str);
if ( (prefirecnt >= 100) && ((gametic-holdtic)%32 <= 16) )
{
double alph = clamp(1.-((gametic-holdtic)%32)/16.,0.,1.)**2.;
TouchScreen.Dim(0xFFFFFFFF,alph*.8,128-50,72+(fh/2-12),int(bw),8,STYLE_Add);
TouchScreen.DrawText(fnt,Font.FindFontColor("MiniWhiteFlash"),128-strw/2,72-fh/2+fofs,str,DTA_Alpha,alph*.8,DTA_LegacyRenderStyle,STYLE_Add);
}
}
// Holo sub-screen
if ( !AmmoLed ) AmmoLed = TexMan.GetCanvas("MORTLED2");
if ( !AmmoLedFont ) AmmoLedFont = TexMan.CheckForTexture("models/canvas/MortalFlatChars.png");
AmmoLed.Clear(0,0,64,16,0x00000000);
int dg1 = (ingun/10)%10;
int dg2 = (ingun%10);
AmmoLed.DrawTexture(AmmoLedFont,false,24,0,DTA_SrcX,dg1*8,DTA_SrcWidth,8,DTA_DestWidth,8,DTA_Color,dg1?blink?0xFF400080:0xFF8000FF:blink?0xFF200040:0xFF400080);
AmmoLed.DrawTexture(AmmoLedFont,false,32,0,DTA_SrcX,dg2*8,DTA_SrcWidth,8,DTA_DestWidth,8,DTA_Color,(dg1||dg2)?blink?0xFF400080:0xFF8000FF:blink?0xFF200040:0xFF400080);
if ( gchambered ) AmmoLed.DrawTexture(AmmoLedFont,false,52,0,DTA_SrcX,80+8*gfired,DTA_SrcWidth,8,DTA_DestWidth,8,DTA_Color,gfired?0xFF400080:0xFF8000FF);
AmmoLed.DrawTexture(AmmoLedFont,false,4,0,DTA_SrcX,96+firemode*8,DTA_SrcWidth,8,DTA_DestWidth,8,DTA_Color,0xFF8000FF);
}
}
// Rafan-Kos
extend Class RafanKos
{
override void RenderTexture( RenderEvent e )
{
// ammo display
// dynamic glow
}
}