--- shaderhud.cpp 2007-09-13 10:37:38.000000000 -0400 +++ shaderhud.cpp 2008-12-23 21:23:28.000000000 -0500 @@ -10,6 +10,9 @@ In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. Only the source code to the module(s) containing the licenced code has to be released. */ + +#include + #include "scripts.h" #include "shadereng.h" #include "shaderplugin.h" @@ -41,43 +44,118 @@ SimpleDynVecClass *Colors; SimpleDynVecClass *HealthColors; SimpleDynVecClass *ShieldColors; +SimpleDynVecClass *BulletColors; +SimpleDynVecClass *ClipColors; SimpleDynVecClass *HealthBarColors; SimpleDynVecClass *ShieldBarColors; +SimpleDynVecClass *BulletBarColors; SimpleDynVecClass *HealthIconColors; SimpleDynVecClass *ShieldIconColors; +SimpleDynVecClass *BulletIconColors; + +// General +bool ShaderCheckMaterial = true; +bool pluginsRequired = false; + +// Mine-Number +Render2DTextClass *MinesRender2DClass = 0; +bool RenderMinesText = false; +unsigned int MinesColor = 0; +Vector2 *MinesPosition = 0; +bool MinesEnabled = false; +Vector2 *MinesOffset = 0; + +// Credits-Number +Render2DTextClass *CreditsRender2DClass = 0; +bool RenderCreditsText = false; +unsigned int CreditsColor = 0; +Vector2 *CreditsPosition = 0; +bool CreditsEnabled = false; +Vector2 *CreditsOffset = 0; + +// Time-Numbers +Render2DTextClass *TimeRender2DClass = 0; +bool RenderTimeText = false; +unsigned int TimeColor = 0; +Vector2 *TimePosition = 0; +bool TimeEnabled = false; +Vector2 *TimeOffset = 0; + +//Compass +Render2DTextClass *CompassRender2DClass = 0; +bool RenderCompassText = false; +unsigned int CompassColor = 0; +Vector2 *CompassPosition = 0; +bool CompassEnabled = false; +//Vector2 *CompassOffset = 0; + +/* +bool CompassEnabled = false; +Vector2 *CompassPosition = 0; +bool RenderCompass = false; +Render2DSentenceClass *CompassRenderer = 0; +unsigned int CompassColor = 0; +*/ + +// Health-Number +bool HealthEnabled = false; unsigned int HealthColorCount; -unsigned int ShieldColorCount; Render2DTextClass *HealthRender2DClass = 0; -Render2DTextClass *ShieldRender2DClass = 0; bool RenderHealthText = false; -bool RenderShieldText = false; unsigned int HealthColor = 0; -unsigned int ShieldColor = 0; Vector2 *HealthPosition = 0; -Vector2 *ShieldPosition = 0; Vector2 *HealthOffset = 0; + +// Shield-Number +bool ShieldEnabled = false; +unsigned int ShieldColorCount; +Render2DTextClass *ShieldRender2DClass = 0; +bool RenderShieldText = false; +unsigned int ShieldColor = 0; +Vector2 *ShieldPosition = 0; Vector2 *ShieldOffset = 0; + +//Bullet-Number +bool BulletEnabled = false; +unsigned int BulletColorCount; Render2DTextClass *BulletRender2DClass = 0; +Vector2 *BulletOffset = 0; bool RenderBulletText = false; unsigned int BulletColor = 0; Vector2 *BulletPosition = 0; + +// Clip-Number +bool ClipEnabled = false; +unsigned int ClipColorCount; Render2DTextClass *ClipRender2DClass = 0; +Vector2 *ClipOffset = 0; bool RenderClipText = false; unsigned int ClipColor = 0; Vector2 *ClipPosition = 0; -Vector2 *WeaponPosition = 0; + +// Weapon-Name +bool WeaponEnabled = false; +Render2DSentenceClass *WeaponNameRenderer = 0; bool RenderWeaponText = false; bool RenderWeaponText2 = false; -Render2DSentenceClass *WeaponNameRenderer = 0; unsigned int WeaponColor = 0; +Vector2 *WeaponPosition = 0; + +// Weapon-Image +bool WeaponImageEnabled = false; Render2DClass *WeaponImageRender2DClass = 0; Vector2 *WeaponImagePosition = 0; bool RenderWeaponImage = false; bool RenderWeaponImage2 = false; unsigned int WeaponImageColor = 0; unsigned int WeaponImageVehicleColor = 0; + +// Textures unsigned int TextureCount = 0; SimpleDynVecClass *HudTextures; + +// Health-Bar +bool HealthBarEnabled = false; char *HealthBarTexture = 0; Render2DClass *HealthBarRender2DClass = 0; RectClass *HealthBarUV = 0; @@ -92,6 +170,9 @@ float HealthBarOffset = 0; float HealthBarLength = 0; bool RenderHealthBarEmpty = false; + +// Shield-Bar +bool ShieldBarEnabled = false; char *ShieldBarTexture = 0; Render2DClass *ShieldBarRender2DClass = 0; RectClass *ShieldBarUV = 0; @@ -106,32 +187,57 @@ float ShieldBarOffset = 0; float ShieldBarLength = 0; bool RenderShieldBarEmpty = false; -bool BulletEnabled = false; -bool ClipEnabled = false; -bool HealthBarEnabled = false; -bool HealthEnabled = false; -bool ShieldBarEnabled = false; -bool ShieldEnabled = false; -bool WeaponEnabled = false; -bool WeaponImageEnabled = false; + +// BulletBar +bool BulletBarEnabled = false; +char *BulletBarTexture = 0; +Render2DClass *BulletBarRender2DClass = 0; +RectClass *BulletBarUV = 0; +Vector2 *BulletBarEmptyUV = 0; +Vector2 *BulletBarPosition = 0; +unsigned int BulletBarColorCount = 0; +unsigned int BulletBarColor = 0; +unsigned int BulletBarEmptyColor = 0; +unsigned int BulletBarStyle = 0; +bool RenderBulletBar = false; +unsigned int BulletBarDirection = 0; +float BulletBarOffset = 0; +float BulletBarLength = 0; +bool RenderBulletBarEmpty = false; + +// HealthIcon bool HealthIconEnabled = false; -bool ShieldIconEnabled = false; Vector2 *HealthIconPosition = 0; -Vector2 *ShieldIconPosition = 0; RectClass *HealthIconUV = 0; -RectClass *ShieldIconUV = 0; unsigned long HealthIconColor = 0; -unsigned long ShieldIconColor = 0; unsigned int HealthIconColorCount = 0; -unsigned int ShieldIconColorCount = 0; -char *ShieldIconTexture = 0; char *HealthIconTexture = 0; Render2DClass *HealthIconRender2DClass = 0; -Render2DClass *ShieldIconRender2DClass = 0; bool RenderHealthIcon = false; + +// Shield Icon +bool ShieldIconEnabled = false; +Vector2 *ShieldIconPosition = 0; +RectClass *ShieldIconUV = 0; +unsigned long ShieldIconColor = 0; +unsigned int ShieldIconColorCount = 0; +char *ShieldIconTexture = 0; +Render2DClass *ShieldIconRender2DClass = 0; bool RenderShieldIcon = false; + +// BulletIcon +bool BulletIconEnabled = false; +Vector2 *BulletIconPosition = 0; +RectClass *BulletIconUV = 0; +unsigned long BulletIconColor = 0; +unsigned int BulletIconColorCount = 0; +char *BulletIconTexture = 0; +Render2DClass *BulletIconRender2DClass = 0; +bool RenderBulletIcon = false; + +// Radar char *BlipTexture; -Vector2 *BlipUV[6] = {0,0,0,0,0,0}; +Vector2 *BlipUV[7] = {0,0,0,0,0,0,0}; unsigned long BlipColor[8] = {0,0,0,0,0,0,0,0}; Vector2 *RadarPosition = 0; Vector2 *BackgroundUV = 0; @@ -139,7 +245,6 @@ unsigned long BackgroundColor = 0; Render2DClass *BackgroundRender2DClass = 0; Render2DClass *BlipRender2DClass = 0; -Render2DClass *CompassRender2DClass = 0; float RadarSize = 0; float RadarWorldSize = 0; bool RenderRadar = false; @@ -147,31 +252,15 @@ bool DrawStar = false; bool DrawCompassLine = false; unsigned long CompassLineColor = 0; +Render2DClass *CompassLineRender2DClass = 0; float CompassLineWidth = 0; bool RadarRotate = 0; -bool CompassEnabled = false; -Vector2 *CompassPosition = 0; -bool RenderCompass = false; -Render2DSentenceClass *CompassRenderer = 0; -unsigned int CompassColor = 0; -bool CreditsEnabled = false; -Vector2 *CreditsPosition = 0; -bool RenderCredits = false; -Render2DSentenceClass *CreditsRenderer = 0; -unsigned int CreditsColor = 0; -unsigned int CreditsStringID = 0; -bool TimeEnabled = false; -Vector2 *TimePosition = 0; -bool RenderTime = false; -Render2DSentenceClass *TimeRenderer = 0; -unsigned int TimeColor = 0; -unsigned int TimeStringID = 0; bool ScrollingMap = false; float MapScale = 0; char *MapTexture; Vector2 *MapOffset; -bool ShaderCheckMaterial = true; -bool pluginsRequired = false; +float RadarX = 0; +float RadarY = 0; void ReadMapINI() { @@ -186,7 +275,11 @@ INIClass *hudini = Get_INI(c); delete[] c; if (!hudini) - { + { + char *c = newstr("HUD.ini"); + INIClass *hudini = Get_INI(c); + delete[] c; + hudini->Get_String("General","ScrollingMapTexture","",MapTexture,260-1); return; } if (ScrollingMap) @@ -205,10 +298,15 @@ Colors = new SimpleDynVecClass; HealthColors = new SimpleDynVecClass; ShieldColors = new SimpleDynVecClass; + BulletColors = new SimpleDynVecClass; + ClipColors = new SimpleDynVecClass; HealthBarColors = new SimpleDynVecClass; ShieldBarColors = new SimpleDynVecClass; + BulletBarColors = new SimpleDynVecClass; HealthIconColors = new SimpleDynVecClass; ShieldIconColors = new SimpleDynVecClass; + BulletIconColors = new SimpleDynVecClass; + unsigned int color = RGB(255,255,255)+0xFF000000; Colors->Add(color); unsigned int colors = hudini->Get_Int("General","ColorCount",0); @@ -223,6 +321,179 @@ Colors->Add(color); } + // Mines-Number + MinesEnabled = hudini->Get_Bool("General","MinesEnabled",false); + if (MinesEnabled) + { + bool MinesVisible = hudini->Get_Bool("General","MinesVisible",true); + float MinesXPos = hudini->Get_Float("General","MinesXPos",118); + float MinesYPos = hudini->Get_Float("General","MinesYPos",717); + if (MinesXPos < 0) + { + MinesXPos += ScreenResolution->Right; + } + if (MinesYPos < 0) + { + MinesYPos += ScreenResolution->Bottom; + } + char MinesFont[100]; + hudini->Get_String("General","MinesFont","FONT12x16.TGA",MinesFont,sizeof(MinesFont)); + unsigned int MinesCol = hudini->Get_Int("General","MinesColor",0); + MinesPosition = new Vector2(MinesXPos,MinesYPos); + RenderMinesText = MinesVisible; + MinesColor = (*Colors)[MinesCol]; + MinesRender2DClass = CreateRender2DTextClass(MinesFont); + } + + // Credits-Number + CreditsEnabled = hudini->Get_Bool("General","CreditsEnabled",false); + if (CreditsEnabled) + { + bool CreditsVisible = hudini->Get_Bool("General","CreditsVisible",true); + float CreditsXPos = hudini->Get_Float("General","CreditsXPos",118); + float CreditsYPos = hudini->Get_Float("General","CreditsYPos",717); + if (CreditsXPos < 0) + { + CreditsXPos += ScreenResolution->Right; + } + if (CreditsYPos < 0) + { + CreditsYPos += ScreenResolution->Bottom; + } + char CreditsFont[100]; + hudini->Get_String("General","CreditsFont","FONT12x16.TGA",CreditsFont,sizeof(CreditsFont)); + unsigned int CreditsCol = hudini->Get_Int("General","CreditsColor",0); + CreditsPosition = new Vector2(CreditsXPos,CreditsYPos); + RenderCreditsText = CreditsVisible; + CreditsColor = (*Colors)[CreditsCol]; + CreditsRender2DClass = CreateRender2DTextClass(CreditsFont); + } + + // Time-Numbers + TimeEnabled = hudini->Get_Bool("General","TimeEnabled",false); + if (TimeEnabled) + { + bool TimeVisible = hudini->Get_Bool("General","TimeVisible",true); + float TimeXPos = hudini->Get_Float("General","TimeXPos",118); + float TimeYPos = hudini->Get_Float("General","TimeYPos",717); + if (TimeXPos < 0) + { + TimeXPos += ScreenResolution->Right; + } + if (TimeYPos < 0) + { + TimeYPos += ScreenResolution->Bottom; + } + char TimeFont[100]; + hudini->Get_String("General","TimeFont","FONT12x16.TGA",TimeFont,sizeof(TimeFont)); + unsigned int TimeCol = hudini->Get_Int("General","TimeColor",0); + TimePosition = new Vector2(TimeXPos,TimeYPos); + RenderTimeText = TimeVisible; + TimeColor = (*Colors)[TimeCol]; + TimeRender2DClass = CreateRender2DTextClass(TimeFont); + } + + // Compass + //CompassEnabled = hudini->Get_Bool("General","CompassEnabled",false); + CompassEnabled = hudini->Get_Bool("General","EnableCompass",false); + if (CompassEnabled) + { + bool CompassVisible = hudini->Get_Bool("General","CompassVisible",true); + float CompassXPos = hudini->Get_Float("General","CompassXPos",118); + float CompassYPos = hudini->Get_Float("General","CompassYPos",717); + if (CompassXPos < 0) + { + CompassXPos += ScreenResolution->Right; + } + if (CompassYPos < 0) + { + CompassYPos += ScreenResolution->Bottom; + } + char CompassFont[100]; + hudini->Get_String("General","CompassFont","FONT12x16.TGA",CompassFont,sizeof(CompassFont)); + unsigned int CompassCol = hudini->Get_Int("General","CompassColor",0); + CompassPosition = new Vector2(CompassXPos,CompassYPos); + RenderCompassText = CompassVisible; + CompassColor = (*Colors)[CompassCol]; + CompassRender2DClass = CreateRender2DTextClass(CompassFont); + } + /* + CompassEnabled = hudini->Get_Bool("General","EnableCompass",false); + if (CompassEnabled) + { + float CompassXPos = hudini->Get_Float("General","CompassXPos",300); + float CompassYPos = hudini->Get_Float("General","CompassYPos",300); + if (CompassXPos < 0) + { + CompassXPos += ScreenResolution->Right; + } + if (CompassYPos < 0) + { + CompassYPos += ScreenResolution->Bottom; + } + RenderCompass = hudini->Get_Bool("General","CompassVisible",true); + unsigned int CompassFont = hudini->Get_Int("General","CompassFont",11); + CompassPosition = new Vector2(CompassXPos,CompassYPos); + unsigned int CompassCol = hudini->Get_Int("General","CompassColor",0); + CompassColor = (*Colors)[CompassCol]; + CompassRenderer = CreateRender2DSentenceClass(CompassFont); + }*/ + + // Bullet-Bar + BulletBarEnabled = hudini->Get_Bool("General","BulletBarEnabled",false); + if (BulletBarEnabled) + { + unsigned int BulletBarCol = hudini->Get_Int("General","BulletBarColor",0); + unsigned int BulletBarEmptyCol = hudini->Get_Int("General","BulletBarEmptyColor",0); + BulletBarColorCount = hudini->Get_Int("General","BulletBarColorCount",0); + for (unsigned int i = 0;i < BulletBarColorCount;i++) + { + char section[10]; + sprintf(section,"BulletBarColor%d",i); + unsigned int index = hudini->Get_Int(section,"Color",0); + float value = hudini->Get_Float(section,"Value",0); + Color *c = new Color; + c->ColorValue = (*Colors)[index]; + c->Value = value; + BulletBarColors->Add(c); + } + BulletBarColor = (*Colors)[BulletBarCol]; + BulletBarEmptyColor = (*Colors)[BulletBarEmptyCol]; + BulletBarRender2DClass = CreateRender2DClass(); + BulletBarTexture = new char[260]; + hudini->Get_String("General","BulletBarTexture","",BulletBarTexture,260-1); + float BulletBarXPos = hudini->Get_Float("General","BulletBarXPos",300); + float BulletBarYPos = hudini->Get_Float("General","BulletBarYPos",300); + if (BulletBarXPos < 0) + { + BulletBarXPos += ScreenResolution->Right; + } + if (BulletBarYPos < 0) + { + BulletBarYPos += ScreenResolution->Bottom; + } + BulletBarPosition = new Vector2(BulletBarXPos,BulletBarYPos); + float BulletBarTop = hudini->Get_Float("General","BulletBarTop",0); + float BulletBarBottom = hudini->Get_Float("General","BulletBarBottom",0); + float BulletBarLeft = hudini->Get_Float("General","BulletBarLeft",0); + float BulletBarRight = hudini->Get_Float("General","BulletBarRight",0); + BulletBarUV = new RectClass(BulletBarLeft,BulletBarTop,BulletBarRight,BulletBarBottom); + float BulletBarEmptyTop = hudini->Get_Float("General","BulletBarEmptyTop",BulletBarTop); + float BulletBarEmptyLeft = hudini->Get_Float("General","BulletBarEmptyLeft",BulletBarLeft); + BulletBarEmptyUV = new Vector2(BulletBarEmptyLeft,BulletBarEmptyTop); + RenderBulletBar = hudini->Get_Bool("General","BulletBarVisible",true); + BulletBarStyle = hudini->Get_Int("General","BulletBarStyle",0); + BulletBarDirection = hudini->Get_Int("General","BulletBarDirection",1); + BulletBarOffset = hudini->Get_Float("General","BulletBarOffset",10); + if (!BulletBarOffset) + { + BulletBarOffset++; + } + BulletBarLength = hudini->Get_Float("General","BulletBarLength",500); + RenderBulletBarEmpty = hudini->Get_Bool("General","BulletBarEmptyVisible",true); + } + + // Health-Number HealthEnabled = hudini->Get_Bool("General","HealthEnabled",false); if (HealthEnabled) { @@ -260,7 +531,8 @@ HealthColor = (*Colors)[HealthCol]; HealthRender2DClass = CreateRender2DTextClass(HealthFont); } - + + // Shield-Number ShieldEnabled = hudini->Get_Bool("General","ShieldEnabled",false); if (ShieldEnabled) { @@ -298,35 +570,16 @@ ShieldColor = (*Colors)[ShieldCol]; ShieldRender2DClass = CreateRender2DTextClass(ShieldFont); } - - BulletEnabled = hudini->Get_Bool("General","BulletEnabled",false); - if (BulletEnabled) - { - float BulletXPos = hudini->Get_Float("General","BulletXPos",100); - float BulletYPos = hudini->Get_Float("General","BulletYPos",100); - if (BulletXPos < 0) - { - BulletXPos += ScreenResolution->Right; - } - if (BulletYPos < 0) - { - BulletYPos += ScreenResolution->Bottom; - } - bool BulletVisible = hudini->Get_Bool("General","BulletVisible",true); - char BulletFont[100]; - hudini->Get_String("General","BulletFont","FONT12x16.TGA",BulletFont,sizeof(BulletFont)); - unsigned int BulletCol = hudini->Get_Int("General","BulletColor",0); - BulletPosition = new Vector2(BulletXPos,BulletYPos); - RenderBulletText = BulletVisible; - BulletColor = (*Colors)[BulletCol]; - BulletRender2DClass = CreateRender2DTextClass(BulletFont); - } - + // Clip-Number (Ammo you have in backpack) ClipEnabled = hudini->Get_Bool("General","ClipEnabled",false); if (ClipEnabled) { - float ClipXPos = hudini->Get_Float("General","ClipXPos",200); - float ClipYPos = hudini->Get_Float("General","ClipYPos",200); + char ClipFont[100]; + hudini->Get_String("General","ClipFont","FONT6x8.TGA",ClipFont,sizeof(ClipFont)); + float ClipXPos = hudini->Get_Float("General","ClipXPos",221); + float ClipYPos = hudini->Get_Float("General","ClipYPos",733); + float ClipXOffset = hudini->Get_Float("General","ClipXOffset",0); + float ClipYOffset = hudini->Get_Float("General","ClipYOffset",0); if (ClipXPos < 0) { ClipXPos += ScreenResolution->Right; @@ -336,15 +589,27 @@ ClipYPos += ScreenResolution->Bottom; } bool ClipVisible = hudini->Get_Bool("General","ClipVisible",true); - char ClipFont[100]; - hudini->Get_String("General","ClipFont","FONT12x16.TGA",ClipFont,sizeof(ClipFont)); unsigned int ClipCol = hudini->Get_Int("General","ClipColor",0); + ClipColorCount = hudini->Get_Int("General","ClipColorCount",0); + for (unsigned int i = 0;i < ClipColorCount;i++) + { + char section[10]; + sprintf(section,"ClipColor%d",i); + unsigned int index = hudini->Get_Int(section,"Color",0); + float value = hudini->Get_Float(section,"Value",0); + Color *c = new Color; + c->ColorValue = (*Colors)[index]; + c->Value = value; + ClipColors->Add(c); + } ClipPosition = new Vector2(ClipXPos,ClipYPos); + ClipOffset = new Vector2(ClipXOffset,ClipYOffset); RenderClipText = ClipVisible; ClipColor = (*Colors)[ClipCol]; ClipRender2DClass = CreateRender2DTextClass(ClipFont); } + // Weapon-Name WeaponEnabled = hudini->Get_Bool("General","WeaponEnabled",false); if (WeaponEnabled) { @@ -367,6 +632,7 @@ WeaponNameRenderer = CreateRender2DSentenceClass(WeaponFont); } + // Weapon-Image WeaponImageEnabled = hudini->Get_Bool("General","WeaponImageEnabled",false); if (WeaponImageEnabled) { @@ -389,7 +655,8 @@ WeaponImageVehicleColor = (*Colors)[WeaponImageVehicleCol]; WeaponImageRender2DClass = CreateRender2DClass(); } - + + // Textures TextureCount = hudini->Get_Int("General","TextureCount",0); HudTextures = new SimpleDynVecClass(); for (unsigned int i = 0;i < TextureCount;i++) @@ -411,6 +678,13 @@ float size = (float)(1.0 / sz); for (unsigned int j = 0;j < t->QuadCount;j++) { + // BuildingsBars of if EnableBuildings=false + //char buildquad[10]; + //sprintf(buildquad,"Quad%dforBuilding",j); + //bool QuadforBuilding = hudini->Get_Bool(section,buildquad,false); + + //if (!showBuildings && QuadforBuilding) + // continue; char entry[50]; sprintf(entry,"Quad%dColor",j); t->Quads[j].Color = (*Colors)[hudini->Get_Int(section,entry,0)]; @@ -448,6 +722,7 @@ HudTextures->Add(t); } + // Health-Bar HealthBarEnabled = hudini->Get_Bool("General","HealthBarEnabled",false); if (HealthBarEnabled) { @@ -501,6 +776,7 @@ RenderHealthBarEmpty = hudini->Get_Bool("General","HealthBarEmptyVisible",true); } + // Shield-Bar ShieldBarEnabled = hudini->Get_Bool("General","ShieldBarEnabled",false); if (ShieldBarEnabled) { @@ -553,72 +829,47 @@ ShieldBarLength = hudini->Get_Float("General","ShieldBarLength",500); RenderShieldBarEmpty = hudini->Get_Bool("General","ShieldBarEmptyVisible",true); } - - CompassEnabled = hudini->Get_Bool("General","EnableCompass",false); - if (CompassEnabled) - { - float CompassXPos = hudini->Get_Float("General","CompassXPos",300); - float CompassYPos = hudini->Get_Float("General","CompassYPos",300); - if (CompassXPos < 0) - { - CompassXPos += ScreenResolution->Right; - } - if (CompassYPos < 0) - { - CompassYPos += ScreenResolution->Bottom; - } - RenderCompass = hudini->Get_Bool("General","CompassVisible",true); - unsigned int CompassFont = hudini->Get_Int("General","CompassFont",11); - CompassPosition = new Vector2(CompassXPos,CompassYPos); - unsigned int CompassCol = hudini->Get_Int("General","CompassColor",0); - CompassColor = (*Colors)[CompassCol]; - CompassRenderer = CreateRender2DSentenceClass(CompassFont); - } - - CreditsEnabled = hudini->Get_Bool("General","EnableCredits",false); - if (CreditsEnabled) + + // Bullet-Number + BulletEnabled = hudini->Get_Bool("General","BulletEnabled",false); + if (BulletEnabled) { - RenderCredits = true; - float CreditsXPos = hudini->Get_Float("General","CreditsXPos",300); - float CreditsYPos = hudini->Get_Float("General","CreditsYPos",300); - if (CreditsXPos < 0) - { - CreditsXPos += ScreenResolution->Right; - } - if (CreditsYPos < 0) + char BulletFont[100]; + hudini->Get_String("General","BulletFont","FONT6x8.TGA",BulletFont,sizeof(BulletFont)); + float BulletXPos = hudini->Get_Float("General","BulletXPos",221); + float BulletYPos = hudini->Get_Float("General","BulletYPos",733); + float BulletXOffset = hudini->Get_Float("General","BulletXOffset",0); + float BulletYOffset = hudini->Get_Float("General","BulletYOffset",0); + if (BulletXPos < 0) { - CreditsYPos += ScreenResolution->Bottom; + BulletXPos += ScreenResolution->Right; } - unsigned int CreditsFont = hudini->Get_Int("General","CreditsFont",11); - CreditsPosition = new Vector2(CreditsXPos,CreditsYPos); - unsigned int CreditsCol = hudini->Get_Int("General","CreditsColor",0); - CreditsColor = (*Colors)[CreditsCol]; - CreditsRenderer = CreateRender2DSentenceClass(CreditsFont); - CreditsStringID = hudini->Get_Int("General","CreditsStringID",0); - } - - TimeEnabled = hudini->Get_Bool("General","EnableTime",false); - if (TimeEnabled) - { - RenderTime = true; - float TimeXPos = hudini->Get_Float("General","TimeXPos",300); - float TimeYPos = hudini->Get_Float("General","TimeYPos",300); - if (TimeXPos < 0) + if (BulletYPos < 0) { - TimeXPos += ScreenResolution->Right; + BulletYPos += ScreenResolution->Bottom; } - if (TimeYPos < 0) + bool BulletVisible = hudini->Get_Bool("General","BulletVisible",true); + unsigned int BulletCol = hudini->Get_Int("General","BulletColor",0); + BulletColorCount = hudini->Get_Int("General","BulletColorCount",0); + for (unsigned int i = 0;i < BulletColorCount;i++) { - TimeYPos += ScreenResolution->Bottom; + char section[10]; + sprintf(section,"BulletColor%d",i); + unsigned int index = hudini->Get_Int(section,"Color",0); + float value = hudini->Get_Float(section,"Value",0); + Color *c = new Color; + c->ColorValue = (*Colors)[index]; + c->Value = value; + BulletColors->Add(c); } - unsigned int TimeFont = hudini->Get_Int("General","TimeFont",11); - TimePosition = new Vector2(TimeXPos,TimeYPos); - unsigned int TimeCol = hudini->Get_Int("General","TimeColor",0); - TimeColor = (*Colors)[TimeCol]; - TimeRenderer = CreateRender2DSentenceClass(TimeFont); - TimeStringID = hudini->Get_Int("General","TimeStringID",0); + BulletPosition = new Vector2(BulletXPos,BulletYPos); + BulletOffset = new Vector2(BulletXOffset,BulletYOffset); + RenderBulletText = BulletVisible; + BulletColor = (*Colors)[BulletCol]; + BulletRender2DClass = CreateRender2DTextClass(BulletFont); } - + + // Radar RadarEnabled = hudini->Get_Bool("General","EnableRadar",false); if (RadarEnabled) { @@ -639,12 +890,12 @@ hudini->Get_String("General","BlipTexture","",BlipTexture,260-1); BackgroundRender2DClass = CreateRender2DClass(); BlipRender2DClass = CreateRender2DClass(); - CompassRender2DClass = CreateRender2DClass(); + CompassLineRender2DClass = CreateRender2DClass(); float BackgroundTop = hudini->Get_Float("General","BackgroundTop",0); float BackgroundLeft = hudini->Get_Float("General","BackgroundLeft",0); BackgroundUV = new Vector2(BackgroundLeft,BackgroundTop); - float RadarX = hudini->Get_Float("General","RadarX",0); - float RadarY = hudini->Get_Float("General","RadarY",0); + RadarX = hudini->Get_Float("General","RadarX",0); + RadarY = hudini->Get_Float("General","RadarY",0); if (RadarX < 0) { RadarX += ScreenResolution->Right; @@ -655,7 +906,7 @@ } RadarPosition = new Vector2(RadarX,RadarY); BlipUV[0] = new Vector2(0,0); - for (unsigned int i = 1; i < 6;i++) + for (unsigned int i = 1; i < 7;i++) { char entry[50]; sprintf(entry,"RadarBlip%dTop",i); @@ -685,6 +936,7 @@ } } + // Health-Icon HealthIconEnabled = hudini->Get_Bool("General","HealthIconEnabled",false); if (HealthIconEnabled) { @@ -724,6 +976,7 @@ RenderHealthIcon = true; } + // Shield-Icon ShieldIconEnabled = hudini->Get_Bool("General","ShieldIconEnabled",false); if (ShieldIconEnabled) { @@ -762,8 +1015,48 @@ ShieldIconUV = new RectClass(ShieldIconLeft,ShieldIconTop,ShieldIconRight,ShieldIconBottom); RenderShieldIcon = true; } - ShaderCheckMaterial = hudini->Get_Bool("General","ShaderCheckMaterial",true); + // Bullet-Icon + BulletIconEnabled = hudini->Get_Bool("General","BulletIconEnabled",false); + if (BulletIconEnabled) + { + unsigned int BulletIconCol = hudini->Get_Int("General","BulletIconColor",0); + BulletIconColorCount = hudini->Get_Int("General","BulletIconColorCount",0); + for (unsigned int i = 0;i < BulletIconColorCount;i++) + { + char section[10]; + sprintf(section,"BulletIconColor%d",i); + unsigned int index = hudini->Get_Int(section,"Color",0); + float value = hudini->Get_Float(section,"Value",0); + Color *c = new Color; + c->ColorValue = (*Colors)[index]; + c->Value = value; + BulletIconColors->Add(c); + } + BulletIconColor = (*Colors)[BulletIconCol]; + BulletIconRender2DClass = CreateRender2DClass(); + BulletIconTexture = new char[260]; + hudini->Get_String("General","BulletIconTexture","",BulletIconTexture,260-1); + float BulletIconXPos = hudini->Get_Float("General","BulletIconXPos",300); + float BulletIconYPos = hudini->Get_Float("General","BulletIconYPos",300); + if (BulletIconXPos < 0) + { + BulletIconXPos += ScreenResolution->Right; + } + if (BulletIconYPos < 0) + { + BulletIconYPos += ScreenResolution->Bottom; + } + BulletIconPosition = new Vector2(BulletIconXPos,BulletIconYPos); + float BulletIconTop = hudini->Get_Float("General","BulletIconTop",0); + float BulletIconBottom = hudini->Get_Float("General","BulletIconBottom",0); + float BulletIconLeft = hudini->Get_Float("General","BulletIconLeft",0); + float BulletIconRight = hudini->Get_Float("General","BulletIconRight",0); + BulletIconUV = new RectClass(BulletIconLeft,BulletIconTop,BulletIconRight,BulletIconBottom); + RenderBulletIcon = true; + } + + ShaderCheckMaterial = hudini->Get_Bool("General","ShaderCheckMaterial",true); int pluginCount = hudini->Get_Int("ShaderPlugins","PluginCount",0); pluginsRequired = hudini->Get_Bool("ShaderPlugins","PluginsRequired",false); for (int i = 1; i < pluginCount + 1; i++) @@ -785,10 +1078,23 @@ } } } -} - -void __declspec(dllexport) UpdateHUD2() -{ +} + +void __declspec(dllexport) UpdateHUD2() +{ + for (unsigned int i = 0;i < TextureCount;i++) + { + (*HudTextures)[i]->TextureRender2DClass->Reset(); + (*HudTextures)[i]->TextureRender2DClass->Set_Texture((*HudTextures)[i]->TextureName); + for (unsigned int j = 0;j < (*HudTextures)[i]->QuadCount;j++) + { + (*HudTextures)[i]->TextureRender2DClass->Add_Quad((*HudTextures)[i]->Quads[j].Position,(*HudTextures)[i]->Quads[j].UV,(*HudTextures)[i]->Quads[j].Color); + } + (*HudTextures)[i]->TextureRender2DClass->Render(); + } + GameObject *obj = (GameObject *)(*TheStar)->obj; + //int myPlayerId = Get_Player_ID(obj); + //{ for (unsigned int i = 0;i < TextureCount;i++) { (*HudTextures)[i]->TextureRender2DClass->Reset(); @@ -799,13 +1105,22 @@ } (*HudTextures)[i]->TextureRender2DClass->Render(); } - GameObject *obj = Get_Vehicle_Return((GameObject *)(*TheStar)->obj); if (RenderHealthBar) { HealthBarRender2DClass->Reset(); HealthBarRender2DClass->Set_Texture(HealthBarTexture); - float health = Commands->Get_Health(obj); - float maxhealth = Commands->Get_Max_Health(obj); + float health = 0; + float maxhealth = 0; + if (Get_Vehicle(obj)) + { + health = Commands->Get_Health(Get_Vehicle(obj)); + maxhealth = Commands->Get_Max_Health(Get_Vehicle(obj)); + } + else + { + health = Commands->Get_Health(obj); + maxhealth = Commands->Get_Max_Health(obj); + } float healthpercent = (health / (maxhealth / 100)); unsigned int color = 0; color = HealthBarColor; @@ -901,8 +1216,18 @@ { ShieldBarRender2DClass->Reset(); ShieldBarRender2DClass->Set_Texture(ShieldBarTexture); - float shield = Commands->Get_Shield_Strength(obj); - float maxshield = Commands->Get_Max_Shield_Strength(obj); + float shield = 0; + float maxshield = 0; + if (Get_Vehicle(obj)) + { + shield = Commands->Get_Shield_Strength(Get_Vehicle(obj)); + maxshield = Commands->Get_Max_Shield_Strength(Get_Vehicle(obj)); + } + else + { + shield = Commands->Get_Shield_Strength(obj); + maxshield = Commands->Get_Max_Shield_Strength(obj); + } float shieldpercent = (shield / (maxshield / 100)); unsigned int color = 0; color = ShieldBarColor; @@ -994,6 +1319,114 @@ } ShieldBarRender2DClass->Render(); } + // BulletBar + if (RenderBulletBar) + { + BulletBarRender2DClass->Reset(); + BulletBarRender2DClass->Set_Texture(BulletBarTexture); + int Bullet = 0; + int maxBullet = 0; + if (Get_Vehicle(obj)) + { + Bullet = Get_Current_Bullets(Get_Vehicle(obj)); + maxBullet = Get_Current_Max_Bullets(Get_Vehicle(obj)); + } + else + { + Bullet = Get_Current_Bullets(obj); + maxBullet = Get_Current_Max_Bullets(obj); + } + float Bulletpercent = (float(Bullet) / (float(maxBullet) / 100)); + unsigned int color = 0; + color = BulletBarColor; + for (unsigned int i = 0;i < BulletBarColorCount;i++) + { + if (Bulletpercent <= (*BulletBarColors)[i]->Value) + { + color = (*BulletBarColors)[i]->ColorValue; + break; + } + } + if (BulletBarRender2DClass->Texture->Initialized == false) + { + BulletBarRender2DClass->Texture->Init(); + } + unsigned int sz = BulletBarRender2DClass->Texture->Width; + float size = (float)(1.0 / sz); + float xsize = BulletBarUV->Right-BulletBarUV->Left; + float ysize = BulletBarUV->Bottom-BulletBarUV->Top; + if (!BulletBarStyle) + { + float fullxsize = xsize * (Bulletpercent / 100); + RectClass UV,Position,EmptyUV,EmptyPosition; + if (Bulletpercent > 0) + { + UV = RectClass(BulletBarUV->Left*size,BulletBarUV->Top*size,(BulletBarUV->Left+fullxsize)*size,BulletBarUV->Bottom*size); + Position = RectClass(BulletBarPosition->X,BulletBarPosition->Y,BulletBarPosition->X+fullxsize,BulletBarPosition->Y+ysize); + BulletBarRender2DClass->Add_Quad(Position,UV,color); + } + if (Bulletpercent < 100) + { + if (RenderBulletBarEmpty) + { + EmptyUV = RectClass((BulletBarEmptyUV->X+fullxsize)*size,BulletBarEmptyUV->Y*size,(BulletBarEmptyUV->X+xsize)*size,(BulletBarEmptyUV->Y+ysize)*size); + EmptyPosition = RectClass(BulletBarPosition->X+fullxsize,BulletBarPosition->Y,BulletBarPosition->X+xsize,BulletBarPosition->Y+ysize); + BulletBarRender2DClass->Add_Quad(EmptyPosition,EmptyUV,BulletBarEmptyColor); + } + } + } + else + { + RectClass UV; + RectClass Position; + UV = RectClass(BulletBarUV->Left*size,BulletBarUV->Top*size,BulletBarUV->Right*size,BulletBarUV->Bottom*size); + Position.Top = BulletBarPosition->Y; + Position.Bottom = Position.Top+ysize; + if (!BulletBarDirection) + { + float length = BulletBarLength * (Bulletpercent / 100); + Position.Left = BulletBarPosition->X; + Position.Right = Position.Left + xsize; + do + { + BulletBarRender2DClass->Add_Quad(Position,UV,color); + Position.Left += BulletBarOffset; + Position.Right = Position.Left + xsize; + } while (Position.Right < BulletBarPosition->X + length); + Position.Left = (BulletBarPosition->X) + length; + Position.Left -= xsize; + Position.Right = Position.Left + xsize; + if (Position.Left > BulletBarPosition->X) + { + BulletBarRender2DClass->Add_Quad(Position,UV,color); + } + } + else if (Bullet > 0) + { + float length = BulletBarLength - (BulletBarLength * (Bulletpercent / 100)); + Position.Right = BulletBarPosition->X + BulletBarLength; + Position.Left = Position.Right - xsize; + if (Position.Left < BulletBarPosition->X + length - xsize) + { + Position.Left = BulletBarPosition->X + length - xsize; + Position.Right = Position.Left + xsize; + } + do + { + BulletBarRender2DClass->Add_Quad(Position,UV,color); + Position.Right -= BulletBarOffset; + Position.Left = Position.Right - xsize; + } while (Position.Left > BulletBarPosition->X + length - xsize); + Position.Right = BulletBarPosition->X + length; + Position.Left = Position.Right + xsize; + if (Position.Right < BulletBarPosition->X + BulletBarLength) + { + BulletBarRender2DClass->Add_Quad(Position,UV,color); + } + } + } + BulletBarRender2DClass->Render(); + } if (RenderHealthIcon) { HealthIconRender2DClass->Reset(); @@ -1064,60 +1497,90 @@ ShieldIconRender2DClass->Add_Quad(Position,UV,color); ShieldIconRender2DClass->Render(); } - if ((RenderWeaponText) || ((RenderWeaponText2) && (Get_Vehicle(obj)))) + // Bullet-Icon + if (RenderBulletIcon) { - GameObject *o = Get_Vehicle(obj); - const wchar_t *name; - if (o) + BulletIconRender2DClass->Reset(); + BulletIconRender2DClass->Set_Texture(BulletIconTexture); + float Bullet = 0; + float maxBullet = 0; + if (Get_Vehicle(obj)) { - name = Get_Wide_Vehicle_Name(o); + Bullet = float(Get_Current_Bullets(Get_Vehicle(obj))); + maxBullet = float(Get_Current_Max_Bullets(Get_Vehicle(obj))); } else { - name = Get_Current_Wide_Translated_Weapon(obj); + Bullet = float(Get_Current_Bullets(obj)); + maxBullet = float(Get_Current_Max_Bullets(obj)); } - Render2DSentenceDrawSentence(WeaponNameRenderer,name,WeaponPosition,WeaponColor); - } - if (RenderCompass) - { - const wchar_t *str = Get_Wide_Translated_String(12640+*CompassPos); - Render2DSentenceDrawSentence(CompassRenderer,str,CompassPosition,CompassColor); - } - if (RenderCredits) - { - const wchar_t *str = Get_Wide_Translated_String(CreditsStringID); - wchar_t str2[100]; - swprintf(str2,100,str,(unsigned int)Commands->Get_Money(obj)); - Render2DSentenceDrawSentence(CreditsRenderer,str2,CreditsPosition,CreditsColor); + float Bulletpercent = (Bullet / (maxBullet / 100)); + unsigned int color = 0; + color = BulletIconColor; + for (unsigned int i = 0;i < BulletIconColorCount;i++) + { + if (Bulletpercent <= (*BulletIconColors)[i]->Value) + { + color = (*BulletIconColors)[i]->ColorValue; + break; + } + } + if (BulletIconRender2DClass->Texture->Initialized == false) + { + BulletIconRender2DClass->Texture->Init(); + } + unsigned int sz = BulletIconRender2DClass->Texture->Width; + float size = (float)(1.0 / sz); + float xsize = BulletIconUV->Right-BulletIconUV->Left; + float ysize = BulletIconUV->Bottom-BulletIconUV->Top; + RectClass UV; + RectClass Position; + UV = RectClass(BulletIconUV->Left*size,BulletIconUV->Top*size,BulletIconUV->Right*size,BulletIconUV->Bottom*size); + Position.Top = BulletIconPosition->Y; + Position.Bottom = Position.Top+ysize; + Position.Left = BulletIconPosition->X; + Position.Right = Position.Left+xsize; + BulletIconRender2DClass->Add_Quad(Position,UV,color); + BulletIconRender2DClass->Render(); } - if (RenderTime) + if ((RenderWeaponText || RenderWeaponText2) && Get_Vehicle(obj)) { - if (The_Game()->TimeLimit_Minutes) + GameObject *o = Get_Vehicle(obj); + const wchar_t *name = 0; + if (o) + name = Get_Wide_Vehicle_Name(o); + else + name = Get_Current_Wide_Translated_Weapon(obj); + if (name) { - float secs = The_Game()->TimeRemaining_Seconds; - const wchar_t *str = Get_Wide_Translated_String(TimeStringID); - int hours,minutes,seconds; - Seconds_To_Hms(secs,hours,minutes,seconds); - wchar_t str2[100]; - wchar_t str3[100]; - swprintf(str3,100,L"%02d:%02d:%02d",hours,minutes,seconds); - swprintf(str2,100,str,str3); - Render2DSentenceDrawSentence(TimeRenderer,str2,TimePosition,TimeColor); + if (_wcsicmp (name, L"No String") != 0) + Render2DSentenceDrawSentence(WeaponNameRenderer,name,WeaponPosition,WeaponColor); } } if (RenderHealthText) { HealthRender2DClass->Reset(); RectClass *r = (RectClass *)((char *)HealthRender2DClass+0x5B8); - float health = Commands->Get_Health(obj); - float maxhealth = Commands->Get_Max_Health(obj); + float health = 0; + float maxhealth = 0; + if (Get_Vehicle(obj)) + { + health = Commands->Get_Health(Get_Vehicle(obj)); + maxhealth = Commands->Get_Max_Health(Get_Vehicle(obj)); + } + else + { + health = Commands->Get_Health(obj); + maxhealth = Commands->Get_Max_Health(obj); + } + float healthpercent = (health / (maxhealth / 100)); r->Right = HealthPosition->X + (healthpercent * HealthOffset->X); r->Left = HealthPosition->X + (healthpercent * HealthOffset->X); r->Top = HealthPosition->Y + (healthpercent * HealthOffset->Y); r->Bottom = HealthPosition->Y + (healthpercent * HealthOffset->Y); char text[10]; - unsigned int h = (unsigned int)health; + unsigned int h = (unsigned int)(health + 0.5f); sprintf(text,"%d",h); unsigned int color = 0; if (!HealthColorCount) @@ -1138,55 +1601,196 @@ HealthRender2DClass->Draw_Text(text,color); HealthRender2DClass->Render(); } + if (RenderMinesText) + { + MinesRender2DClass->Reset(); + RectClass *r = (RectClass *)((char *)MinesRender2DClass+0x5B8); + float Mines = float(Get_C4_Count_Proximity(Get_Player_Type(obj))); + r->Right = MinesPosition->X; + r->Left = MinesPosition->X; + r->Top = MinesPosition->Y; + r->Bottom = MinesPosition->Y; + char text[10]; + unsigned int h = (unsigned int)(Mines + 0.5f); + sprintf(text,"%d",h); + unsigned int color = MinesColor; + MinesRender2DClass->Draw_Text(text,color); + MinesRender2DClass->Render(); + } + if (RenderCreditsText) + { + CreditsRender2DClass->Reset(); + RectClass *r = (RectClass *)((char *)CreditsRender2DClass+0x5B8); + float Credits = float(Commands->Get_Money(obj)); + r->Right = CreditsPosition->X; + r->Left = CreditsPosition->X; + r->Top = CreditsPosition->Y; + r->Bottom = CreditsPosition->Y; + char text[10]; + unsigned int h = (unsigned int)(Credits + 0.5f); + sprintf(text,"%d",h); + unsigned int color = CreditsColor; + CreditsRender2DClass->Draw_Text(text,color); + CreditsRender2DClass->Render(); + } + if (RenderTimeText) + { + if(The_Game()->TimeLimit_Minutes) + { + TimeRender2DClass->Reset(); + RectClass *r = (RectClass *)((char *)TimeRender2DClass+0x5B8); + float secs = The_Game()->TimeRemaining_Seconds; + int hours,minutes,seconds; + Seconds_To_Hms(secs,hours,minutes,seconds); + r->Right = TimePosition->X; + r->Left = TimePosition->X; + r->Top = TimePosition->Y; + r->Bottom = TimePosition->Y; + char text[64]; + sprintf(text,"%02d:%02d:%02d",hours,minutes,seconds); + unsigned int color = TimeColor; + TimeRender2DClass->Draw_Text(text,color); + TimeRender2DClass->Render(); + } + } + + if (RenderCompassText) + { + CompassRender2DClass->Reset(); + RectClass *r = (RectClass *)((char *)CompassRender2DClass+0x5B8); + const wchar_t *Compass = Get_Wide_Translated_String(12640+*CompassPos); + r->Right = CompassPosition->X; + r->Left = CompassPosition->X; + r->Top = CompassPosition->Y; + r->Bottom = CompassPosition->Y; + char text[10]; + sprintf(text,"%ls",Compass); + unsigned int color = CompassColor; + CompassRender2DClass->Draw_Text(text,color); + CompassRender2DClass->Render(); + } + /* + if (RenderCompass) + { + const wchar_t *str = Get_Wide_Translated_String(12640+*CompassPos); + Render2DSentenceDrawSentence(CompassRenderer,str,CompassPosition,CompassColor); + }*/ + if (RenderBulletText) { BulletRender2DClass->Reset(); RectClass *r = (RectClass *)((char *)BulletRender2DClass+0x5B8); - unsigned int bullets = Get_Current_Bullets(Get_Vehicle_Return(obj)); + float bullets = (float)Get_Current_Bullets(Get_Vehicle_Return(obj)); + float totalBullets = (float)Get_Current_Max_Bullets(Get_Vehicle_Return(obj)); + bool repairGun = false; if (bullets == -1) { bullets = 999; } - r->Right = BulletPosition->X; - r->Left = BulletPosition->X; - r->Top = BulletPosition->Y; - r->Bottom = BulletPosition->Y; - char text[10]; - sprintf(text,"%d",bullets); - BulletRender2DClass->Draw_Text(text,BulletColor); + if (totalBullets == -1) + { + totalBullets = 999; + repairGun = true; + } + float bulletpercent = (bullets / (totalBullets / 100)); + r->Right = BulletPosition->X + (bulletpercent * BulletOffset->X); + r->Left = BulletPosition->X + (bulletpercent * BulletOffset->X); + r->Top = BulletPosition->Y + (bulletpercent * BulletOffset->Y); + r->Bottom = BulletPosition->Y + (bulletpercent * BulletOffset->Y); + char text[32]; + //unsigned int s = (unsigned int)(bullets + 0.5f); + if (repairGun) + sprintf(text,"~"); + else + sprintf(text,"%d", (int)bullets); + unsigned int color = 0; + if (!BulletColorCount) + { + color = BulletColor; + } + else + { + for (unsigned int i = 0;i < BulletColorCount;i++) + { + if (bulletpercent < (*BulletColors)[i]->Value) + { + color = (*BulletColors)[i]->ColorValue; + break; + } + } + } + BulletRender2DClass->Draw_Text(text,color); BulletRender2DClass->Render(); } if (RenderClipText) { ClipRender2DClass->Reset(); RectClass *r = (RectClass *)((char *)ClipRender2DClass+0x5B8); - unsigned int Clips = Get_Current_Clip_Bullets(Get_Vehicle_Return(obj)); + float Clips = (float)Get_Current_Clip_Bullets(Get_Vehicle_Return(obj)); + float totalClips = (float)Get_Current_Clip_Max_Bullets(Get_Vehicle_Return(obj)); + bool repairGun = false; if (Clips == -1) { Clips = 999; } - r->Right = ClipPosition->X; - r->Left = ClipPosition->X; - r->Top = ClipPosition->Y; - r->Bottom = ClipPosition->Y; - char text[10]; - sprintf(text,"%d",Clips); - ClipRender2DClass->Draw_Text(text,ClipColor); + if (totalClips == -1) + { + totalClips = 999; + repairGun = true; + } + float Clippercent = (Clips / (totalClips / 100)); + r->Right = ClipPosition->X + (Clippercent * ClipOffset->X); + r->Left = ClipPosition->X + (Clippercent * ClipOffset->X); + r->Top = ClipPosition->Y + (Clippercent * ClipOffset->Y); + r->Bottom = ClipPosition->Y + (Clippercent * ClipOffset->Y); + char text[32]; + //unsigned int s = (unsigned int)(Clips + 0.5f); + if (repairGun) + sprintf(text,"~"); + else + sprintf(text,"%d", (int)Clips); + unsigned int color = 0; + if (!ClipColorCount) + { + color = ClipColor; + } + else + { + for (unsigned int i = 0;i < ClipColorCount;i++) + { + if (Clippercent < (*ClipColors)[i]->Value) + { + color = (*ClipColors)[i]->ColorValue; + break; + } + } + } + ClipRender2DClass->Draw_Text(text,color); ClipRender2DClass->Render(); } if (RenderShieldText) { ShieldRender2DClass->Reset(); RectClass *r = (RectClass *)((char *)ShieldRender2DClass+0x5B8); - float shield = Commands->Get_Shield_Strength(obj); - float maxshield = Commands->Get_Max_Shield_Strength(obj); + float shield = 0; + float maxshield = 0; + if (Get_Vehicle(obj)) + { + shield = Commands->Get_Shield_Strength(Get_Vehicle(obj)); + maxshield = Commands->Get_Max_Shield_Strength(Get_Vehicle(obj)); + } + else + { + shield = Commands->Get_Shield_Strength(obj); + maxshield = Commands->Get_Max_Shield_Strength(obj); + } float shieldpercent = (shield / (maxshield / 100)); r->Right = ShieldPosition->X + (shieldpercent * ShieldOffset->X); r->Left = ShieldPosition->X + (shieldpercent * ShieldOffset->X); r->Top = ShieldPosition->Y + (shieldpercent * ShieldOffset->Y); r->Bottom = ShieldPosition->Y + (shieldpercent * ShieldOffset->Y); char text[10]; - unsigned int s = (unsigned int)shield; + unsigned int s = (unsigned int)(shield + 0.5f); sprintf(text,"%d",s); unsigned int color = 0; if (!ShieldColorCount) @@ -1207,7 +1811,7 @@ ShieldRender2DClass->Draw_Text(text,color); ShieldRender2DClass->Render(); } - if ((RenderWeaponImage) || ((RenderWeaponImage2) && (Get_Vehicle(obj)))) + if (RenderWeaponImage || (RenderWeaponImage2 && Get_Vehicle(obj))) { WeaponImageRender2DClass->Reset(); GameObject *o = Get_Vehicle(obj); @@ -1226,11 +1830,12 @@ { texture = "hud_passseat.tga"; } + RectClass r; - r.Top = WeaponImagePosition->Y + 16; - r.Left = WeaponImagePosition->X + 34; - r.Bottom = WeaponImagePosition->Y + 64 + 16; - r.Right = WeaponImagePosition->X + 64 + 34; + r.Top = WeaponImagePosition->Y + 33; + r.Left = WeaponImagePosition->X + 6; + r.Bottom = WeaponImagePosition->Y + 64 + 33; + r.Right = WeaponImagePosition->X + 64 + 6; WeaponImageRender2DClass->Set_Texture(texture); WeaponImageRender2DClass->Add_Quad(r,WeaponImageVehicleColor); } @@ -1255,17 +1860,20 @@ ch+=0x10; Vector2 *v = (Vector2 *)ch; WeaponImageRender2DClass->Set_Texture(texture); - if (WeaponImageRender2DClass->Texture->Initialized == false) + if (WeaponImageRender2DClass->Texture) { - WeaponImageRender2DClass->Texture->Init(); + if (WeaponImageRender2DClass->Texture->Initialized == false) + { + WeaponImageRender2DClass->Texture->Init(); + } + unsigned int sz = WeaponImageRender2DClass->Texture->Width; + float size = (float)(1.0 / sz); + RectClass uv = RectClass(r->Left*size,r->Top*size,r->Right*size,r->Bottom*size); + RectClass position = RectClass(WeaponImagePosition->X+v->X,WeaponImagePosition->Y+v->Y,WeaponImagePosition->X+v->X,WeaponImagePosition->Y+v->Y); + position.Bottom += r->Bottom-r->Top; + position.Right += r->Right-r->Left; + WeaponImageRender2DClass->Add_Quad(position,uv,WeaponImageColor); } - unsigned int sz = WeaponImageRender2DClass->Texture->Width; - float size = (float)(1.0 / sz); - RectClass uv = RectClass(r->Left*size,r->Top*size,r->Right*size,r->Bottom*size); - RectClass position = RectClass(WeaponImagePosition->X+v->X,WeaponImagePosition->Y+v->Y,WeaponImagePosition->X+v->X,WeaponImagePosition->Y+v->Y); - position.Bottom += r->Bottom-r->Top; - position.Right += r->Right-r->Left; - WeaponImageRender2DClass->Add_Quad(position,uv,WeaponImageColor); } } WeaponImageRender2DClass->Render(); @@ -1273,7 +1881,7 @@ if (RenderRadar) { BackgroundRender2DClass->Reset(); - CompassRender2DClass->Reset(); + CompassLineRender2DClass->Reset(); BlipRender2DClass->Reset(); BlipRender2DClass->Set_Texture(BlipTexture); if (BlipRender2DClass->Texture->Initialized == false) @@ -1355,10 +1963,10 @@ float cf = cos(facing); float sf = sin(facing); Vector2 ce = Vector2((((RadarSize / 2) * cf)+cb.X),(((RadarSize / 2) * sf)+cb.Y)); - CompassRender2DClass->Add_Line(cb,ce,CompassLineWidth,CompassLineColor); + CompassLineRender2DClass->Add_Line(cb,ce,CompassLineWidth,CompassLineColor);; } - CompassRender2DClass->Render(); - float radarfactor = (RadarSize / 2) / RadarWorldSize; + CompassLineRender2DClass->Render(); + float radarfactor = MapScale; if ((RadarIntensity) && (BaseControllerClass::Find_Base(Commands->Get_Player_Type(obj))) && (BaseControllerClass::Find_Base(Commands->Get_Player_Type(obj))->RadarEnabled)) { GenericSLNode *x = BaseGameObjList->HeadNode; @@ -1421,31 +2029,87 @@ { Vector3 v = Commands->Get_Position(o); v.Z = 0; - float distance = Commands->Get_Distance(v,sv); - if (distance < RadarWorldSize) + + float posx = -((sv.X - v.X) * radarfactor); + float posy = ((sv.Y - v.Y) * radarfactor); + if (RadarRotate) + { + float sf = sin(facing); + float cf = cos(facing); + float x2 = (posx * cf) - (posy * sf); + float y = (posx * sf) + (posy * cf); + posx = x2; + posy = y; + } + posx += RadarPosition->X + (RadarSize / 2); + posy += RadarPosition->Y + (RadarSize / 2); + Vector3 targetPos; + targetPos.X = posx; + targetPos.Y = posy; + Vector3 radarMitte; + radarMitte.Y = RadarY + (RadarSize / 2); + radarMitte.X = RadarX + (RadarSize / 2); + + bool inQuader = true; + if (targetPos.X > (radarMitte.X + (RadarSize / 2))) + inQuader = false; + + else if (targetPos.Y > (radarMitte.Y + (RadarSize / 2))) + inQuader = false; + + else if (targetPos.X < (radarMitte.X - (RadarSize / 2))) + inQuader = false; + + else if (targetPos.Y < (radarMitte.Y - (RadarSize / 2))) + inQuader = false; + + if (inQuader) { - float posx = -((sv.X - v.X) * radarfactor); - float posy = ((sv.Y - v.Y) * radarfactor); - if (RadarRotate) + if (Is_Beacon(o)) + { + RectClass uv = RectClass(BlipUV[6]->X*blipsize,BlipUV[6]->Y*blipsize,(BlipUV[6]->X+8)*blipsize,(BlipUV[6]->Y+8)*blipsize); + RectClass screen = RectClass(posx-4,posy-4,posx+4,posy+4); + BlipRender2DClass->Add_Quad(screen,uv,BlipColor[color]); + } + else { - float sf = sin(facing); - float cf = cos(facing); - float x2 = (posx * cf) - (posy * sf); - float y = (posx * sf) + (posy * cf); - posx = x2; - posy = y; + RectClass uv = RectClass(BlipUV[type]->X*blipsize,BlipUV[type]->Y*blipsize,(BlipUV[type]->X+8)*blipsize,(BlipUV[type]->Y+8)*blipsize); + RectClass screen = RectClass(posx-4,posy-4,posx+4,posy+4); + BlipRender2DClass->Add_Quad(screen,uv,BlipColor[color]); } - posx += RadarPosition->X + (RadarSize / 2); - posy += RadarPosition->Y + (RadarSize / 2); - RectClass uv = RectClass(BlipUV[type]->X*blipsize,BlipUV[type]->Y*blipsize,(BlipUV[type]->X+8)*blipsize,(BlipUV[type]->Y+8)*blipsize); - RectClass screen = RectClass(posx-4,posy-4,posx+4,posy+4); - BlipRender2DClass->Add_Quad(screen,uv,BlipColor[color]); if (o == *BracketObj) { + RectClass screen = RectClass(posx-4,posy-4,posx+4,posy+4); RectClass uv2 = RectClass(BlipUV[5]->X*blipsize,BlipUV[5]->Y*blipsize,(BlipUV[5]->X+8)*blipsize,(BlipUV[5]->Y+8)*blipsize); BlipRender2DClass->Add_Quad(screen,uv2,BlipColor[5]); } } + else + { + if (Is_Beacon(o)) + { + if (targetPos.X > (radarMitte.X + (RadarSize / 2))) + posx += (radarMitte.X + (RadarSize / 2)) - posx; + + else if (targetPos.X < (radarMitte.X - (RadarSize / 2))) + posx += (radarMitte.X - (RadarSize / 2)) - posx; + + if (targetPos.Y > (radarMitte.Y + (RadarSize / 2))) + posy += (radarMitte.Y + (RadarSize / 2)) - posy; + + else if (targetPos.Y < (radarMitte.Y - (RadarSize / 2))) + posy += (radarMitte.Y - (RadarSize / 2)) - posy; + + RectClass uv = RectClass(BlipUV[6]->X*blipsize,BlipUV[6]->Y*blipsize,(BlipUV[6]->X+8)*blipsize,(BlipUV[6]->Y+8)*blipsize); + RectClass screen = RectClass(posx-4,posy-4,posx+4,posy+4); + BlipRender2DClass->Add_Quad(screen,uv,BlipColor[color]); + if (o == *BracketObj) + { + RectClass uv2 = RectClass(BlipUV[5]->X*blipsize,BlipUV[5]->Y*blipsize,(BlipUV[5]->X+8)*blipsize,(BlipUV[5]->Y+8)*blipsize); + BlipRender2DClass->Add_Quad(screen,uv2,BlipColor[5]); + } + } + } } x = x->NodeNext; } @@ -1461,6 +2125,7 @@ { return; } + if (HealthEnabled) { unsigned int HealthCol = hudini->Get_Int("General","HealthColor",0); @@ -1475,6 +2140,30 @@ HealthColor = (*Colors)[HealthCol]; } + if (MinesEnabled) + { + unsigned int MinesCol = hudini->Get_Int("General","MinesColor",0); + MinesColor = (*Colors)[MinesCol]; + } + + if (CreditsEnabled) + { + unsigned int CreditsCol = hudini->Get_Int("General","CreditsColor",0); + CreditsColor = (*Colors)[CreditsCol]; + } + + if (TimeEnabled) + { + unsigned int TimeCol = hudini->Get_Int("General","TimeColor",0); + TimeColor = (*Colors)[TimeCol]; + } + + if (CompassEnabled) + { + unsigned int CompassCol = hudini->Get_Int("General","CompassColor",0); + CompassColor = (*Colors)[CompassCol]; + } + if (ShieldEnabled) { unsigned int ShieldCol = hudini->Get_Int("General","ShieldColor",0); @@ -1507,24 +2196,6 @@ WeaponColor = (*Colors)[WeaponCol]; } - if (CompassEnabled) - { - unsigned int CompassCol = hudini->Get_Int("General","CompassColor",0); - CompassColor = (*Colors)[CompassCol]; - } - - if (CreditsEnabled) - { - unsigned int CreditsCol = hudini->Get_Int("General","CreditsColor",0); - CreditsColor = (*Colors)[CreditsCol]; - } - - if (TimeEnabled) - { - unsigned int TimeCol = hudini->Get_Int("General","TimeColor",0); - TimeColor = (*Colors)[TimeCol]; - } - if (WeaponImageEnabled) { unsigned int WeaponImageCol = hudini->Get_Int("General","WeaponImageColor",0); @@ -1540,6 +2211,12 @@ hudini->Get_String(section,"TextureName","",(*HudTextures)[i]->TextureName,260-1); for (unsigned int j = 0;j < (*HudTextures)[i]->QuadCount;j++) { + // Buildings-Bars off if EnableBuilings=false + //char buildquad[10]; + //sprintf(buildquad,"Quad%dforBuilding",j); + //bool QuadforBuilding = hudini->Get_Bool(section,buildquad,false); + //if (!showBuildings && QuadforBuilding) + // continue; char entry[50]; sprintf(entry,"Quad%dColor",j); (*HudTextures)[i]->Quads[j].Color = (*Colors)[hudini->Get_Int(section,entry,0)]; @@ -1578,6 +2255,22 @@ hudini->Get_String("General","ShieldBarTexture","",ShieldBarTexture,260-1); } + if (BulletBarEnabled) + { + unsigned int BulletBarCol = hudini->Get_Int("General","BulletBarColor",0); + unsigned int BulletBarEmptyCol = hudini->Get_Int("General","BulletBarEmptyColor",0); + for (unsigned int i = 0;i < BulletBarColorCount;i++) + { + char section[10]; + sprintf(section,"BulletBarColor%d",i); + unsigned int index = hudini->Get_Int(section,"Color",0); + (*BulletBarColors)[i]->ColorValue = (*Colors)[index]; + } + BulletBarColor = (*Colors)[BulletBarCol]; + BulletBarEmptyColor = (*Colors)[BulletBarEmptyCol]; + hudini->Get_String("General","BulletBarTexture","",BulletBarTexture,260-1); + } + if (HealthIconEnabled) { unsigned int HealthIconCol = hudini->Get_Int("General","HealthIconColor",0); @@ -1592,6 +2285,20 @@ hudini->Get_String("General","HealthIconTexture","",HealthIconTexture,260-1); } + if (BulletIconEnabled) + { + unsigned int BulletIconCol = hudini->Get_Int("General","BulletIconColor",0); + for (unsigned int i = 0;i < BulletIconColorCount;i++) + { + char section[10]; + sprintf(section,"BulletIconColor%d",i); + unsigned int index = hudini->Get_Int(section,"Color",0); + (*BulletIconColors)[i]->ColorValue = (*Colors)[index]; + } + BulletIconColor = (*Colors)[BulletIconCol]; + hudini->Get_String("General","BulletIconTexture","",BulletIconTexture,260-1); + } + if (ShieldIconEnabled) { unsigned int ShieldIconCol = hudini->Get_Int("General","ShieldIconColor",0); @@ -1628,11 +2335,17 @@ void __declspec(dllexport) Cleanup_HUD2() { SAFE_DELETE(Colors); + + for (unsigned int i = 0;i < BulletBarColorCount;i++) + { + SAFE_DELETE((*BulletBarColors)[i]); + } + SAFE_DELETE(BulletBarColors); for (unsigned int i = 0;i < HealthColorCount;i++) { SAFE_DELETE((*HealthColors)[i]); } - SAFE_DELETE(HealthColors); + SAFE_DELETE(HealthColors); for (unsigned int i = 0;i < ShieldColorCount;i++) { SAFE_DELETE((*ShieldColors)[i]); @@ -1652,12 +2365,17 @@ { SAFE_DELETE((*HealthIconColors)[i]); } - SAFE_DELETE(HealthIconColors); + for (unsigned int i = 0;i < BulletIconColorCount;i++) + { + SAFE_DELETE((*BulletIconColors)[i]); + } + SAFE_DELETE(BulletIconColors); for (unsigned int i = 0;i < ShieldIconColorCount;i++) { SAFE_DELETE((*ShieldIconColors)[i]); } SAFE_DELETE(ShieldIconColors); + ///* for (unsigned int i = 0;i < TextureCount;i++) { SAFE_DELETE((*HudTextures)[i]->TextureRender2DClass); @@ -1665,6 +2383,19 @@ SAFE_DELETE_ARRAY((*HudTextures)[i]->Quads); SAFE_DELETE((*HudTextures)[i]); } + //*/ + for (int i = 0;i < 6;i++) + { + SAFE_DELETE(BlipUV[i]); + } + //if (showBuildings) + // return; + ///* + SAFE_DELETE_ARRAY(BulletBarTexture); + SAFE_DELETE(BulletBarPosition); + SAFE_DELETE(BulletBarUV); + SAFE_DELETE(BulletBarEmptyUV); + SAFE_DELETE(BulletBarRender2DClass); SAFE_DELETE(HudTextures); SAFE_DELETE(HealthRender2DClass); SAFE_DELETE(HealthOffset); @@ -1691,16 +2422,19 @@ SAFE_DELETE(ShieldBarEmptyUV); SAFE_DELETE(ShieldBarRender2DClass); SAFE_DELETE(CompassPosition); - SAFE_DELETE(CompassRenderer); + SAFE_DELETE(CompassRender2DClass); + //SAFE_DELETE(CompassRenderer); + SAFE_DELETE(CompassLineRender2DClass); SAFE_DELETE(CreditsPosition); - SAFE_DELETE(CreditsRenderer); + SAFE_DELETE(CreditsRender2DClass); + SAFE_DELETE(MinesPosition); + SAFE_DELETE(MinesRender2DClass); SAFE_DELETE(TimePosition); - SAFE_DELETE(TimeRenderer); + SAFE_DELETE(TimeRender2DClass); SAFE_DELETE_ARRAY(BackgroundTexture); SAFE_DELETE_ARRAY(BlipTexture); SAFE_DELETE(BackgroundRender2DClass); SAFE_DELETE(BlipRender2DClass); - SAFE_DELETE(CompassRender2DClass); SAFE_DELETE(BackgroundUV); SAFE_DELETE(RadarPosition); SAFE_DELETE(HealthIconRender2DClass); @@ -1711,10 +2445,16 @@ SAFE_DELETE_ARRAY(ShieldIconTexture); SAFE_DELETE(ShieldIconPosition); SAFE_DELETE(ShieldIconUV); + SAFE_DELETE(BulletIconRender2DClass); + SAFE_DELETE_ARRAY(BulletIconTexture); + SAFE_DELETE(BulletIconPosition); + SAFE_DELETE(BulletIconUV); + SAFE_DELETE(ShieldIconRender2DClass); for (int i = 0;i < 6;i++) { SAFE_DELETE(BlipUV[i]); } + //*/ } void __declspec(dllexport) Update_Radar_Map(float scale,float offsetx,float offsety,const char *texture) @@ -1728,4 +2468,4 @@ void __declspec(dllexport) Send_HUD_Number(int number) { } -} +} \ No newline at end of file