Fix colours tab in alt menu not applying colour code changes when not visible

This commit is contained in:
UnknownShadow200 2018-09-15 23:24:55 +10:00
parent 972f51f454
commit c213e84770
6 changed files with 21 additions and 9 deletions

View File

@ -19,7 +19,10 @@ namespace ClassicalSharp.Gui.Widgets {
public void UpdateCols() {
elements[0].Contents = GetColString();
if (!Active || selectedIndex != 0) return;
if (selectedIndex != 0) return;
// defer updating colours tab until visible
if (!Active) { pendingRedraw = true; return; }
Redraw();
}
@ -27,10 +30,12 @@ namespace ClassicalSharp.Gui.Widgets {
readonly Font font;
InputWidget input;
Size elementSize;
bool pendingRedraw;
public void SetActive(bool active) {
Active = active;
Height = active ? (int)texture.Height : 0;
if (active && pendingRedraw) Redraw();
}
public override void Render(double delta) {
@ -46,8 +51,9 @@ namespace ClassicalSharp.Gui.Widgets {
public void Redraw() {
Make(elements[selectedIndex], font);
Width = texture.Width;
Width = texture.Width;
Height = texture.Height;
pendingRedraw = false;
}
unsafe void Make(SpecialInputTab e, Font font) {

View File

@ -77,7 +77,7 @@ namespace ClassicalSharp {
bool insideMap = game.World.IsValidPos(pOrigin);
Vector3 coords;
for (int i = 0; i < 10000; i++) {
for (int i = 0; i < 25000; i++) {
int x = t.X, y = t.Y, z = t.Z;
coords.X = x; coords.Y = y; coords.Z = z;
t.Block = insideMap ?
@ -97,7 +97,7 @@ namespace ClassicalSharp {
t.Step();
}
throw new InvalidOperationException("did over 10000 iterations in CalculatePickedBlock(). " +
throw new InvalidOperationException("did over 25000 iterations in CalculatePickedBlock(). " +
"Something has gone wrong. (dir: " + dir + ")");
}

View File

@ -149,7 +149,7 @@ static bool Picking_RayTrace(Vector3 origin, Vector3 dir, Real32 reach, struct P
Int32 i;
Vector3 coords;
for (i = 0; i < 10000; i++) {
for (i = 0; i < 25000; i++) {
Int32 x = tracer.X, y = tracer.Y, z = tracer.Z;
coords.X = (Real32)x; coords.Y = (Real32)y; coords.Z = (Real32)z;
tracer.Block = insideMap ?
@ -170,7 +170,7 @@ static bool Picking_RayTrace(Vector3 origin, Vector3 dir, Real32 reach, struct P
RayTracer_Step(&tracer);
}
ErrorHandler_Fail("Something went wrong, did over 10,000 iterations in Picking_RayTrace()");
ErrorHandler_Fail("Something went wrong, did over 25,000 iterations in Picking_RayTrace()");
return false;
}

View File

@ -64,8 +64,8 @@ int main(int argc, char** argv) {
String args[PROGRAM_MAX_CMDARGS];
Int32 argsCount = Platform_GetCommandLineArgs(argc, argv, args);
/* NOTE: Make sure to comment this out before pushing a commit */
// String rawArgs = String_FromConst("UnknownShadow200 fff 127.0.0.1 25565");
// argsCount = 4; String_UNSAFE_Split(&rawArgs, ' ', args, &argsCount);
String rawArgs = String_FromConst("UnknownShadow200 fff 127.0.0.1 25565");
argsCount = 4; String_UNSAFE_Split(&rawArgs, ' ', args, &argsCount);
if (argsCount == 0) {
String name = String_FromConst("Singleplayer");

View File

@ -2751,6 +2751,7 @@ static void SpecialInputWidget_Redraw(struct SpecialInputWidget* w) {
SpecialInputWidget_Make(w, &w->Tabs[w->SelectedIndex]);
w->Width = w->Tex.Width;
w->Height = w->Tex.Height;
w->PendingRedraw = false;
}
static void SpecialInputWidget_Init(void* widget) {
@ -2787,13 +2788,17 @@ static bool SpecialInputWidget_MouseDown(void* widget, Int32 x, Int32 y, MouseBu
void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w) {
SpecialInputWidget_UpdateColString(w);
w->Tabs[0].Contents = w->ColString;
if (!w->Active || w->SelectedIndex != 0) return;
if (w->SelectedIndex != 0) return;
/* defer updating colours tab until visible */
if (!w->Active) { w->PendingRedraw = true; return; }
SpecialInputWidget_Redraw(w);
}
void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, bool active) {
w->Active = active;
w->Height = active ? w->Tex.Height : 0;
if (active && w->PendingRedraw) SpecialInputWidget_Redraw(w);
}
struct WidgetVTABLE SpecialInputWidget_VTABLE = {

View File

@ -202,6 +202,7 @@ struct SpecialInputWidget {
Widget_Layout
Size2D ElementSize;
Int32 SelectedIndex;
bool PendingRedraw;
struct InputWidget* AppendObj;
struct Texture Tex;
FontDesc Font;