public void draw(int mouseX, int mouseY, bool mouseDown, int formWidth, int formHeight) { GL.ClearColor(0.1f, 0.3f, 0.1f, 0.1f); GL.LoadIdentity(); GL.Translate(0.0f, 0.0f, -1.0f); if (inTransition) { GL.Translate((1.0f - transition) * formWidth * 1.2f, 0.0f, 0.0f); transition = ((transition * 0.92f) + 0.08f); GL.ClearColor(0.1f, 0.1f + (transition * 0.2f), 0.1f, 0.1f); if (transition >= 0.999f) { transition = 0.0f; inTransition = false; } } else if (outTransition) { GL.Translate(transition * formWidth * 1.2f, 0.0f, 0.0f); transition = ((transition * 0.92f) + 0.08f); GL.ClearColor(0.1f, 0.3f - (transition * 0.2f), 0.1f, 0.1f); if (transition >= 0.9f) { transition = 0.0f; inTransition = false; Program.currentRenderer.Dispose(); Program.currentRenderer = new SalesScreenRenderer(); ((SalesScreenRenderer)Program.currentRenderer).easingDirection = EasingDirection.right; Program.theDatabase.currentSale = new Model.Sale(); Program.theDatabase.saveToDisk(); } } else { timer += 0.1f; if (timer >= 1.0f) { outTransition = true; } } GL.Clear(ClearBufferMask.ColorBufferBit); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.DstColor, BlendingFactorDest.SrcColor); GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); GL.PushMatrix(); GL.Scale(formWidth, formHeight, 0); background.draw(); GL.PopMatrix(); GL.Disable(EnableCap.Blend); GL.Color4(1.0f, 1.0f, 1.0f, 0.75f); title.draw(); }
public void draw(int mouseX, int mouseY, bool mouseDown, int formWidth, int formHeight) { salesScreenButton.y = formHeight - 90; GL.LoadIdentity(); GL.Translate(0.0f, 0.0f, -1.0f); GL.ClearColor(0.1f, 0.1f, 0.3f, 0.1f); if (inTransition) { GL.Translate(0.0f, (1.0f - transition) * formHeight * 1.2f, 0.0f); transition = ((transition * 0.92f) + 0.08f); GL.ClearColor(0.1f, 0.1f, 0.1f + (transition * 0.2f), 0.1f); if (transition >= 0.999f) { inTransition = false; } } if (outTransition) { GL.Translate(0.0f, transition * formHeight * 1.2f, 0.0f); transition = ((transition * 0.92f) + 0.08f); GL.ClearColor(0.1f, 0.1f, 0.3f - (transition * 0.2f), 0.1f); if (transition >= 0.9f) { Dispose(); Program.currentRenderer = new SalesScreenRenderer(); ((SalesScreenRenderer)Program.currentRenderer).easingDirection = EasingDirection.up; return; } } GL.Clear(ClearBufferMask.ColorBufferBit); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.DstColor, BlendingFactorDest.SrcColor); GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); GL.PushMatrix(); GL.Scale(formWidth, formHeight, 0); background.draw(); GL.PopMatrix(); GL.Disable(EnableCap.Blend); if (phase <= 1.0f) { GL.Color4(1.0f, 1.0f, 1.0f, phase); } else { GL.Color4(1.0f, 1.0f, 1.0f, 0.6f + ((((float)Math.Sin(phase) + 1.0f) / 2.0f) * 0.4f)); } phase += 0.03f; title.draw(); foreach (Button b in theButtons) { b.tick(mouseX, mouseY, mouseDown); b.drawBorder(); b.drawText(); } }
public void draw(int mouseX, int mouseY, bool mouseDown, int formWidth, int formHeight) { int x = 20; int y = 140 + 80 + (int)scrollingPos; for (int g = 0; g < Program.theDatabase.getAllGroups().Length; g++) { string groupName = Program.theDatabase.getAllGroups()[g]; if (groupName != "") { if (!groupTextures.ContainsKey(groupName)) { groupTextures[groupName] = GLMethods.generateString(groupName, 40, System.Drawing.Color.White); } groupLefts[groupName] = x + 40; groupTops[groupName] = y - 80; } for (int i = 0; i < productButtons.Count; i++) { if (Program.theDatabase.getProduct(productButtons[i].productID).group == groupName) { if (y >= (formHeight - 90) || y < 0) { productButtons[i].visible = false; } else { productButtons[i].multBrightness = 1.0f; if (y >= (formHeight - 90) - 256) { productButtons[i].multBrightness = 1.0f - ((y - ((formHeight - 90) - 256)) / 256.0f); } if (y <= 128) { productButtons[i].multBrightness = y / 128.0f; } productButtons[i].visible = true; } productButtons[i].x = x; productButtons[i].y = y; x += 128 + 5; if (x >= formWidth - 373) { x = 20; y += 140; } } } x = 20; y += 140 + 80; } scrollingPos -= scrollingMomentum; scrollingMomentum *= 0.95f; if (scrollingPos < -y - 128) { scrollingMomentum = 0; scrollingPos = -y - 128; } if (scrollingPos >= 0) { scrollingMomentum = 0; scrollingPos = 0; } completeSaleButton.x = formWidth - 220; completeSaleButton.y = formHeight - 60; makeFreeButton.x = formWidth - 220; makeFreeButton.y = formHeight - 120; setupButton.y = formHeight - 60; lockButton.y = formHeight - 60; GL.LoadIdentity(); GL.Translate(0.0f, 0.0f, -1.0f); GL.ClearColor(0.1f, 0.1f, 0.1f, 0.1f); if (inTransition) { if (easingDirection == EasingDirection.up) { GL.Translate(0.0f, (transition - 1.0f) * formHeight * 1.2f, 0.0f); } if (easingDirection == EasingDirection.left) { GL.Translate((1.0f - transition) * formWidth * 1.2f, 0.0f, 0.0f); } if (easingDirection == EasingDirection.right) { GL.Translate(-(1.0f - transition) * formWidth * 1.2f, 0.0f, 0.0f); } transition = ((transition * 0.92f) + 0.08f); if (transition >= 0.999f) { inTransition = false; } } if (outTransition) { if (easingDirection == EasingDirection.up) { GL.Translate(0.0f, -transition * formHeight * 1.2f, 0.0f); } if (easingDirection == EasingDirection.left) { GL.Translate(transition * formWidth * 1.2f, 0.0f, 0.0f); } if (easingDirection == EasingDirection.right) { GL.Translate(-transition * formWidth * 1.2f, 0.0f, 0.0f); } transition = ((transition * 0.92f) + 0.08f); if (transition >= 0.9f) { inTransition = false; Program.currentRenderer = destination; } } GL.Clear(ClearBufferMask.ColorBufferBit); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.DstColor, BlendingFactorDest.SrcColor); GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); GL.PushMatrix(); GL.Scale(formWidth, formHeight, 0); background.draw(); GL.PopMatrix(); GL.Disable(EnableCap.Blend); GL.Color4(1.0f, 1.0f, 1.0f, 0.75f); title.draw(); foreach (string s in groupTextures.Keys) { GL.PushMatrix(); float m = 1.0f; if (groupTops[s] >= (formHeight - 90) - 256) { m = 1.0f - ((groupTops[s] - ((formHeight - 90) - 256)) / 256.0f); } if (groupTops[s] <= 128) { m = groupTops[s] / 128.0f; } GL.Color4(1.0f, 1.0f, 1.0f, 0.75f * m); GL.Translate(groupLefts[s], groupTops[s], 0.0f); groupTextures[s].draw(); GL.PopMatrix(); } GL.Color4(1.0f, 1.0f, 1.0f, 0.75f); foreach (ProductButton p in productButtons) { p.tick(mouseX, mouseY, mouseDown); p.drawBorder(); p.drawContent(); } foreach (Button b in theButtons) { b.tick(mouseX, mouseY, mouseDown); b.drawBorder(); b.drawText(); } for (int i = 0; i < cancelButtons.Count; i++) { cancelButtons[i].x = formWidth - 265; cancelButtons[i].y = 5 + (i * 24); if (i == cancelButtons.Count - 1) { cancelButtons[i].y += 24; cancelButtons[i].x -= 12; } cancelButtons[i].tick(mouseX, mouseY, mouseDown); cancelButtons[i].drawBorder(); cancelButtons[i].drawText(); } if (Program.theDatabase.currentSale.productCosts.Length != items.Count) { updateItems(); } GL.PushMatrix(); GL.Translate(formWidth - 250, 5, 0); GL.Color4(1.0f, 1.0f, 1.0f, 0.75f); Decimal total = 0; for (int i = 0; i < items.Count; i++) { items[i].draw(); GL.Translate(0, 24, 0); total += Program.theDatabase.currentSale.productCosts[i]; } GL.Color4(1.0f, 1.0f, 1.0f, 0.75f); GL.Begin(PrimitiveType.Lines); GL.Vertex2(0, 16); GL.Vertex2(128, 16); GL.End(); GL.Translate(0, 25, 0); if (lastTotal != total) { if (totalDue != null) { totalDue.Dispose(); } totalDue = null; string s = ""; System.Drawing.Color c; c = System.Drawing.Color.Red; s = "Amount Due: " + total.ToString("c"); totalDue = GLMethods.generateString(s, 16, c); lastTotal = total; } totalDue.draw(); GL.PopMatrix(); }
public void drawContent() { if (!visible) { return; } string stock = Program.theDatabase.getProduct(productID).stock.ToString() + " in stock"; string cost = Program.theDatabase.getProduct(productID).cost.ToString("c"); if (Program.theDatabase.getProduct(productID).stock <= 0) { GL.Color4(1.0f, 0.3f, 0.3f, 1.0f * multBrightness); } else { GL.Color4(1.0f - (brightness * 0.75f), 1.0f - (brightness * 0.75f), 1.0f, 1.0f * multBrightness); } GL.PushMatrix(); GL.Translate(x, y + 106, 0.0f); drawString(cost); GL.PopMatrix(); GL.PushMatrix(); GL.Translate(x, y + 86, 0.0f); drawString(stock); GL.PopMatrix(); GL.PushMatrix(); GL.Translate(x, y, 0.0f); if (Program.theDatabase.getProduct(productID).stock <= 0) { GL.Color4(1.0f, 0.0f, 0.0f, 1.0f * multBrightness); } else { GL.Color4(1.0f, 1.0f, 1.0f, 0.5f * multBrightness); } GL.PushMatrix(); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One); GL.Scale(128, 128, 1); Model.Product z = Program.theDatabase.getProduct(productID); if (z.texture == null) { back.draw(); } else { z.texture.draw(); } GL.PopMatrix(); if (Program.theDatabase.getProduct(productID).stock <= 0) { GL.Color4(1.0f, 0.3f, 0.3f, 1.0f * multBrightness); } else { GL.Color4(1.0f - (brightness * 0.75f), 1.0f - (brightness * 0.75f), 1.0f, 1.0f * multBrightness); } drawString(Program.theDatabase.getProduct(productID).name); GL.PopMatrix(); GL.Disable(EnableCap.Blend); }