Beispiel #1
0
        public void drawText()
        {
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);

            GL.Color4(1.0f - (brightness * 0.75f), 1.0f - (brightness * 0.75f), 1.0f, 1.0f);
            GL.PushMatrix();
            GL.Translate(x, y, 0);
            texture.draw();
            GL.PopMatrix();

            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.Texture2D);
        }
Beispiel #2
0
        public void draw(int mouseX, int mouseY, bool mouseDown, int formWidth, int formHeight)
        {
            if (lastAds != Program.theDatabase.advertising)
            {
                createAdvertisements(formWidth);
            }
            GL.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.LoadIdentity();
            GL.Translate(0.0f, 0.0f, -1.0f);
            GL.Color4(1.0f, 1.0f, 1.0f, 0.5f * fading);

            if (Program.currentRenderer is LockScreenRenderer || Program.currentRenderer is SetupScreenRenderer)
            {
                goalScreen = ScreenType.withYouInAMoment;
            }
            if (Program.currentRenderer is SalesScreenRenderer)
            {
                goalScreen = ScreenType.purchase;
            }
            if (Program.currentRenderer is SoldScreenRenderer)
            {
                goalScreen = ScreenType.thanks;
            }

            if (currentScreen != goalScreen)
            {
                fading -= 0.05f;
                if (fading <= 0.0f)
                {
                    fading        = 0.0f;
                    currentScreen = goalScreen;
                }
            }
            if (currentScreen == goalScreen)
            {
                fading += 0.05f;
                if (fading >= 1.0f)
                {
                    fading = 1.0f;
                }
            }

            if (currentScreen == ScreenType.purchase)
            {
                GL.Color4(1.0f, 1.0f, 1.0f, 1.0f * fading);
                purchase.draw();
                GL.PushMatrix();
                GL.Color4(1.0f, 1.0f, 1.0f, 0.5f * fading);
                GL.Translate(formWidth * 0.666f, 0.0f, 0.0f);
                available.draw();
                GL.PopMatrix();

                Decimal t = 0;
                for (int i = 0; i < Program.theDatabase.currentSale.productNames.Length; i++)
                {
                    t += Program.theDatabase.currentSale.productCosts[i];
                    string prodName = Program.theDatabase.currentSale.productNames[i];
                    string prodCost = Program.theDatabase.currentSale.productCosts[i].ToString("c");

                    if (!savedText.ContainsKey(prodName))
                    {
                        savedText[prodName] = GLMethods.generateString(prodName, 40, System.Drawing.Color.White);
                    }
                    if (!savedText.ContainsKey(prodCost))
                    {
                        savedText[prodCost] = GLMethods.generateString(prodCost, 40, System.Drawing.Color.White);
                    }

                    GL.PushMatrix();
                    GL.Translate(0, (50 * i) + 100, 0);
                    GL.Color4(1.0f, 1.0f, 1.0f, 0.75f * fading);
                    savedText[prodName].draw();
                    GL.Translate(formWidth / 3.0f, 0, 0);
                    savedText[prodCost].draw();


                    GL.PopMatrix();
                }

                for (int i = 0; i < Program.theDatabase.allProducts.Length; i++)
                {
                    string prodName = Program.theDatabase.allProducts[i].name;
                    string prodCost = Program.theDatabase.allProducts[i].cost.ToString("c");

                    if (!savedText.ContainsKey(prodName))
                    {
                        savedText[prodName] = GLMethods.generateString(prodName, 40, System.Drawing.Color.White);
                    }
                    if (!savedText.ContainsKey(prodCost))
                    {
                        savedText[prodCost] = GLMethods.generateString(prodCost, 40, System.Drawing.Color.White);
                    }

                    GL.PushMatrix();
                    GL.Translate(formWidth / 2.0f, (50 * i) + 100, 0);
                    GL.Color4(1.0f, 1.0f, 1.0f, 0.333f * fading);
                    savedText[prodName].draw();
                    GL.PopMatrix();

                    GL.PushMatrix();
                    GL.Translate(formWidth * 0.9f, (50 * i) + 100, 0);
                    savedText[prodCost].draw();


                    GL.PopMatrix();
                }
                string totalText = "Total";
                string totalCost = t.ToString("c");

                if (!savedText.ContainsKey(totalText))
                {
                    savedText[totalText] = GLMethods.generateString(totalText, 40, System.Drawing.Color.White);
                }
                if (!savedText.ContainsKey(totalCost))
                {
                    savedText[totalCost] = GLMethods.generateString(totalCost, 40, System.Drawing.Color.White);
                }
                GL.PushMatrix();
                GL.Translate(0, (50 * Program.theDatabase.currentSale.productNames.Length) + 200, 0);
                GL.Color4(1.0f, 0.0f, 0.0f, 0.75f * fading);
                savedText[totalText].draw();
                GL.Translate(formWidth / 3.0f, 0, 0);
                savedText[totalCost].draw();


                GL.PopMatrix();
            }

            if (currentScreen == ScreenType.withYouInAMoment)
            {
                GL.PushMatrix();
                GL.Translate((formWidth / 2) - (withYouInAMoment.getWidth() / 2), (formHeight / 2) - (withYouInAMoment.getHeight() / 2), 0.0f);
                withYouInAMoment.draw();

                GL.PopMatrix();
            }

            if (currentScreen == ScreenType.thanks)
            {
                GL.Color4(1.0f, 1.0f, 1.0f, 0.75f * fading);
                GL.PushMatrix();
                GL.Translate((formWidth / 2) - (thanks.getWidth() / 2), (formHeight / 2) - (thanks.getHeight() / 2), 0.0f);
                thanks.draw();
                GL.PopMatrix();

                if (Program.theDatabase.lastSaleChange > 0)
                {
                    GL.PushMatrix();
                    string change = "Your Change: " + Program.theDatabase.lastSaleChange.ToString("c");

                    if (!savedText.ContainsKey(change))
                    {
                        savedText[change] = GLMethods.generateString(change, 70, System.Drawing.Color.White);
                    }
                    GL.Translate((formWidth / 2) - (savedText[change].getWidth() / 2), ((formHeight / 2) - (thanks.getHeight() / 2)) + thanks.getHeight(), 0);
                    GL.Color4(0.5f, 1.0f, 0.5f, 0.85f * fading);
                    savedText[change].draw();
                    GL.PopMatrix();
                }
            }

            adTimer += 0.02f;
            if (adTimer < 1.0f)
            {
                GL.Color4(1.0f, 1.0f, 1.0f, adTimer);
            }
            else if (adTimer < 5.0f)
            {
                GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);
            }
            else
            {
                if (adTimer >= 6.0f)
                {
                    GL.Color4(0.0f, 0.0f, 0.0f, 0.0f);
                    adTimer = 0.0f;
                    adNum++;
                    if (adNum >= adCount)
                    {
                        adNum = 0;
                    }
                }
                else
                {
                    GL.Color4(1.0f, 1.0f, 1.0f, 6.0f - adTimer);
                }
            }

            if (adCount > 0)
            {
                GL.PushMatrix();
                GL.Translate((formWidth / 2) - (advertisements[adNum].getWidth() / 2), formHeight - thanks.getHeight(), 0.0f);
                advertisements[adNum].draw();

                GL.PopMatrix();
            }
        }
Beispiel #3
0
        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)
        {
            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 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();
            }
        }