mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-24 10:02:08 -05:00
Fix 'speed on' not reappearing when speeding, going into zone that disables hax, then exiting zone which re-enables hax
This commit is contained in:
parent
cec101ba5c
commit
e01bdcc60c
4 changed files with 55 additions and 52 deletions
|
@ -29,12 +29,12 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
TextAtlas posAtlas;
|
||||
public override void Render(double delta) {
|
||||
UpdateStatus(delta);
|
||||
if (game.HideGui || !game.ShowFPS) return;
|
||||
|
||||
if (game.HideGui || !game.ShowFPS) return;
|
||||
game.Graphics.Texturing = true;
|
||||
status.Render(delta);
|
||||
|
||||
if (!game.ClassicMode && game.Gui.activeScreen == null) {
|
||||
UpdateHackState(false);
|
||||
if (HacksChanged()) { UpdateHackState(); }
|
||||
DrawPosition();
|
||||
hackStates.Render(delta);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
accumulator += delta;
|
||||
if (accumulator < 1) return;
|
||||
|
||||
int fps = (int)(frames / accumulator);
|
||||
int fps = (int)(frames / accumulator);
|
||||
statusBuffer.Clear().AppendNum(fps).Append(" fps, ");
|
||||
|
||||
if (game.ClassicMode) {
|
||||
|
@ -105,7 +105,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
.SetLocation(Anchor.LeftOrTop, Anchor.LeftOrTop, 2, yOffset);
|
||||
hackStates.ReducePadding = true;
|
||||
hackStates.Init();
|
||||
UpdateHackState(true);
|
||||
UpdateHackState();
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
|
@ -144,24 +144,27 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
game.Graphics.UpdateDynamicVb_IndexedTris(game.ModelCache.vb, game.ModelCache.vertices, index);
|
||||
}
|
||||
|
||||
bool speeding, halfSpeeding, noclip, fly;
|
||||
bool speed, halfSpeed, noclip, fly, canSpeed;
|
||||
int lastFov;
|
||||
void UpdateHackState(bool force) {
|
||||
bool HacksChanged() {
|
||||
HacksComponent hacks = game.LocalPlayer.Hacks;
|
||||
if (force || hacks.Speeding != speeding || hacks.HalfSpeeding != halfSpeeding || hacks.Noclip != noclip ||
|
||||
hacks.Flying != fly || game.Fov != lastFov) {
|
||||
speeding = hacks.Speeding; halfSpeeding = hacks.HalfSpeeding; noclip = hacks.Noclip; fly = hacks.Flying;
|
||||
lastFov = game.Fov;
|
||||
statusBuffer.Clear();
|
||||
|
||||
if (game.Fov != game.DefaultFov) statusBuffer.Append("Zoom fov ").AppendNum(lastFov).Append(" ");
|
||||
if (fly) statusBuffer.Append("Fly ON ");
|
||||
|
||||
bool speed = (speeding || halfSpeeding) && (hacks.CanSpeed || hacks.BaseHorSpeed > 1);
|
||||
if (speed) statusBuffer.Append("Speed ON ");
|
||||
if (noclip) statusBuffer.Append("Noclip ON ");
|
||||
hackStates.SetText(statusBuffer.ToString());
|
||||
}
|
||||
return hacks.Speeding != speed || hacks.HalfSpeeding != halfSpeed || hacks.Flying != fly
|
||||
|| hacks.Noclip != noclip || game.Fov != lastFov || hacks.CanSpeed != canSpeed;
|
||||
}
|
||||
|
||||
void UpdateHackState() {
|
||||
HacksComponent hacks = game.LocalPlayer.Hacks;
|
||||
speed = hacks.Speeding; halfSpeed = hacks.HalfSpeeding; fly = hacks.Flying;
|
||||
noclip = hacks.Noclip; lastFov = game.Fov; canSpeed = hacks.CanSpeed;
|
||||
|
||||
statusBuffer.Clear();
|
||||
if (game.Fov != game.DefaultFov) statusBuffer.Append("Zoom fov ").AppendNum(lastFov).Append(" ");
|
||||
if (fly) statusBuffer.Append("Fly ON ");
|
||||
|
||||
bool speeding = (speed || halfSpeed) && (hacks.CanSpeed || hacks.BaseHorSpeed > 1);
|
||||
if (speeding) statusBuffer.Append("Speed ON ");
|
||||
if (noclip) statusBuffer.Append("Noclip ON ");
|
||||
hackStates.SetText(statusBuffer.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,9 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||
|
||||
float lastFogEnd = -1, lastFogDensity = -1;
|
||||
public override void SetFogDensity(float value) {
|
||||
FogParam(FogParameter.FogDensity, value, ref lastFogDensity);
|
||||
if (value == lastFogDensity) return;
|
||||
GL.Fogf(FogParameter.FogDensity, value);
|
||||
lastFogDensity = value;
|
||||
}
|
||||
|
||||
public override void SetFogStart(float value) {
|
||||
|
@ -103,13 +105,9 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||
}
|
||||
|
||||
public override void SetFogEnd(float value) {
|
||||
FogParam(FogParameter.FogEnd, value, ref lastFogEnd);
|
||||
}
|
||||
|
||||
static void FogParam(FogParameter param, float value, ref float last) {
|
||||
if (value == last) return;
|
||||
GL.Fogf(param, value);
|
||||
last = value;
|
||||
if (value == lastFogEnd) return;
|
||||
GL.Fogf(FogParameter.FogEnd, value);
|
||||
lastFogEnd = value;
|
||||
}
|
||||
|
||||
Fog lastFogMode = (Fog)999;
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace OpenTK.Graphics.OpenGL {
|
|||
|
||||
public static void GenBuffers( int n, int* buffers ) {
|
||||
Interop.Calli( n, buffers, GenBuffersAddress );
|
||||
} static IntPtr GenBuffersAddress, GenBuffersARBAddress;
|
||||
} static IntPtr GenBuffersAddress, GenBuffersARBAddress;
|
||||
|
||||
public static int GenLists( int n ) {
|
||||
return Interop.Calli_Int32( n, GenListsAddress );
|
||||
|
|
|
@ -300,7 +300,7 @@ typedef struct StatusScreen_ {
|
|||
TextAtlas PosAtlas;
|
||||
Real64 Accumulator;
|
||||
Int32 Frames, FPS;
|
||||
bool Speeding, HalfSpeeding, Noclip, Fly;
|
||||
bool Speed, HalfSpeed, Noclip, Fly, CanSpeed;
|
||||
Int32 LastFov;
|
||||
} StatusScreen;
|
||||
StatusScreen StatusScreen_Instance;
|
||||
|
@ -358,30 +358,32 @@ void StatusScreen_DrawPosition(StatusScreen* screen) {
|
|||
GfxCommon_UpdateDynamicVb_IndexedTris(ModelCache_Vb, vertices, index);
|
||||
}
|
||||
|
||||
void StatusScreen_UpdateHackState(StatusScreen* screen, bool force) {
|
||||
bool StatusScreen_HacksChanged(StatusScreen* screen) {
|
||||
HacksComp* hacks = &LocalPlayer_Instance.Hacks;
|
||||
if (force || hacks->Speeding != screen->Speeding || hacks->HalfSpeeding != screen->HalfSpeeding
|
||||
|| hacks->Noclip != screen->Noclip || hacks->Flying != screen->Fly || Game_Fov != screen->LastFov) {
|
||||
screen->Speeding = hacks->Speeding; screen->Noclip = hacks->Noclip;
|
||||
screen->HalfSpeeding = hacks->HalfSpeeding; screen->Fly = hacks->Flying;
|
||||
screen->LastFov = Game_Fov;
|
||||
return hacks->Speeding != screen->Speed || hacks->HalfSpeeding != screen->HalfSpeed || hacks->Flying != screen->Fly
|
||||
|| hacks->Noclip != screen->Noclip || Game_Fov != screen->LastFov || hacks->CanSpeed != screen->CanSpeed;
|
||||
}
|
||||
|
||||
UInt8 statusBuffer[String_BufferSize(STRING_SIZE * 2)];
|
||||
String status = String_InitAndClearArray(statusBuffer);
|
||||
void StatusScreen_UpdateHackState(StatusScreen* screen) {
|
||||
HacksComp* hacks = &LocalPlayer_Instance.Hacks;
|
||||
screen->Speed = hacks->Speeding; screen->HalfSpeed = hacks->HalfSpeeding; screen->Fly = hacks->Flying;
|
||||
screen->Noclip = hacks->Noclip; screen->LastFov = Game_Fov; screen->CanSpeed = hacks->CanSpeed;
|
||||
|
||||
if (Game_Fov != Game_DefaultFov) {
|
||||
String_AppendConst(&status, "Zoom fov ");
|
||||
String_AppendInt32(&status, Game_Fov);
|
||||
String_AppendConst(&status, " ");
|
||||
}
|
||||
if (hacks->Flying) String_AppendConst(&status, "Fly ON ");
|
||||
UInt8 statusBuffer[String_BufferSize(STRING_SIZE * 2)];
|
||||
String status = String_InitAndClearArray(statusBuffer);
|
||||
|
||||
bool speed = (hacks->Speeding || hacks->HalfSpeeding) && (hacks->CanSpeed || hacks->BaseHorSpeed > 1);
|
||||
if (speed) String_AppendConst(&status, "Speed ON ");
|
||||
if (hacks->Noclip) String_AppendConst(&status, "Noclip ON ");
|
||||
|
||||
TextWidget_SetText(&screen->HackStates, &status);
|
||||
if (Game_Fov != Game_DefaultFov) {
|
||||
String_AppendConst(&status, "Zoom fov ");
|
||||
String_AppendInt32(&status, Game_Fov);
|
||||
String_AppendConst(&status, " ");
|
||||
}
|
||||
if (hacks->Flying) String_AppendConst(&status, "Fly ON ");
|
||||
|
||||
bool speeding = (hacks->Speeding || hacks->HalfSpeeding) && (hacks->CanSpeed || hacks->BaseHorSpeed > 1);
|
||||
if (speeding) String_AppendConst(&status, "Speed ON ");
|
||||
if (hacks->Noclip) String_AppendConst(&status, "Noclip ON ");
|
||||
|
||||
TextWidget_SetText(&screen->HackStates, &status);
|
||||
}
|
||||
|
||||
void StatusScreen_Update(StatusScreen* screen, Real64 delta) {
|
||||
|
@ -432,7 +434,7 @@ void StatusScreen_ContextRecreated(void* obj) {
|
|||
Widget_SetLocation(&hacks->Base, ANCHOR_LEFT_OR_TOP, ANCHOR_LEFT_OR_TOP, 2, yOffset);
|
||||
hacks->ReducePadding = true;
|
||||
Widget_Init(hacks);
|
||||
StatusScreen_UpdateHackState(screen, true);
|
||||
StatusScreen_UpdateHackState(screen);
|
||||
}
|
||||
|
||||
void StatusScreen_Init(GuiElement* elem) {
|
||||
|
@ -454,7 +456,7 @@ void StatusScreen_Render(GuiElement* elem, Real64 delta) {
|
|||
Widget_Render(&screen->Status, delta);
|
||||
|
||||
if (!Game_ClassicMode && Gui_Active == NULL) {
|
||||
StatusScreen_UpdateHackState(screen, false);
|
||||
if (StatusScreen_HacksChanged(screen)) { StatusScreen_UpdateHackState(screen, false); }
|
||||
StatusScreen_DrawPosition(screen);
|
||||
Widget_Render(&screen->HackStates, delta);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue