예제 #1
0
 void createTexts()
 {
     withYouInAMoment = GLMethods.generateString(Program.theClientSetup.oneMomentText, 50, System.Drawing.Color.Azure);
     purchase         = GLMethods.generateString(Program.theClientSetup.purchaseText, 70, System.Drawing.Color.White);
     thanks           = GLMethods.generateString(Program.theClientSetup.thankYou, 80, System.Drawing.Color.White);
     available        = GLMethods.generateString(Program.theClientSetup.forSaleText, 80, System.Drawing.Color.White);
 }
        public SalesScreenRenderer()
        {
            background = new ImageTexture(Properties.Resources.background);
            title      = GLMethods.generateString("Sales", 80, System.Drawing.Color.White);

            foreach (Model.Product p in Program.theDatabase.allProducts)
            {
                p.loadImage();
            }

            setupButton          = new Button("Admin Setup", 30, System.Drawing.Color.White, System.Drawing.Color.White, 10, 650);
            setupButton.onClick += setupClicked;
            theButtons.Add(setupButton);
            lockButton          = new Button("Lock", 30, System.Drawing.Color.White, System.Drawing.Color.White, 280, 650);
            lockButton.onClick += lockClicked;
            theButtons.Add(lockButton);
            completeSaleButton          = new Button("Finish Sale", 30, System.Drawing.Color.White, System.Drawing.Color.White, 400, 650);
            completeSaleButton.onClick += completeSaleClicked;
            theButtons.Add(completeSaleButton);
            makeFreeButton          = new Button("Make Free", 30, System.Drawing.Color.White, System.Drawing.Color.White, 400, 600);
            makeFreeButton.onClick += makeFreeClicked;
            theButtons.Add(makeFreeButton);

            foreach (Model.Product z in Program.theDatabase.allProducts)
            {
                if (!z.deleted)
                {
                    ProductButton p = new ProductButton(z.ID, 0, 0, Properties.Resources.UnknownItem);
                    p.onClick += productButtonClicked;
                    productButtons.Add(p);
                }
            }
            updateItems();
        }
        public SetupScreenRenderer()
        {
            background = new ImageTexture(Properties.Resources.background);

            title = GLMethods.generateString("Admin Setup", 80, System.Drawing.Color.Coral);
            setupPasscodesButton = new Button("Setup Passcodes", 30, System.Drawing.Color.Azure, System.Drawing.Color.White, 30, 120);
            setupProductsButton  = new Button("Setup Products", 30, System.Drawing.Color.LightSalmon, System.Drawing.Color.White, 30, 180);
            viewAnalyticsButton  = new Button("View Analytics", 30, System.Drawing.Color.LightSteelBlue, System.Drawing.Color.White, 30, 240);
            setupScreensButton   = new Button("Setup Screens", 30, System.Drawing.Color.LightGreen, System.Drawing.Color.White, 30, 300);
            editSalesButton      = new Button("Edit Sales", 30, System.Drawing.Color.White, System.Drawing.Color.White, 380, 120);

            salesScreenButton = new Button("Return to Sales", 30, System.Drawing.Color.White, System.Drawing.Color.White, 20, 650);

            setupPasscodesButton.onClick += editPasscodesClicked;
            setupProductsButton.onClick  += editProductsClicked;
            viewAnalyticsButton.onClick  += analyticsClicked;
            setupScreensButton.onClick   += editScreensClicked;
            editSalesButton.onClick      += editSalesClicked;

            theButtons.Add(setupProductsButton);
            theButtons.Add(setupPasscodesButton);
            theButtons.Add(viewAnalyticsButton);
            theButtons.Add(salesScreenButton);
            theButtons.Add(setupScreensButton);
            theButtons.Add(editSalesButton);

            salesScreenButton.onClick += returnToSales;
        }
예제 #4
0
 public Button(string text, int size, System.Drawing.Color theColor, System.Drawing.Color borderColor, int x, int y)
 {
     texture          = GLMethods.generateString(text, size, theColor);
     this.borderColor = borderColor;
     this.x           = x;
     this.y           = y;
     this.theColor    = theColor;
 }
예제 #5
0
 void drawString(string s)
 {
     if (!textures.ContainsKey(s))
     {
         textures[s] = GLMethods.generateString(s, 14, System.Drawing.Color.Azure, 128);
     }
     textures[s].draw();
 }
예제 #6
0
 void createAdvertisements(int width)
 {
     for (int i = 0; i < advertisements.Length; i++)
     {
         advertisements[i].Dispose();
     }
     string[] z = Program.theDatabase.advertising.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
     adCount        = z.Length;
     advertisements = new StringTexture[z.Length];
     for (int i = 0; i < z.Length; i++)
     {
         advertisements[i] = GLMethods.generateString(z[i], 60, System.Drawing.Color.White, width);
     }
     lastAds = Program.theDatabase.advertising;
 }
        void updateItems()
        {
            if (Program.theDatabase.currentSale.productIDs == null)
            {
                return;
            }
            foreach (StringTexture t in items)
            {
                t.Dispose();
            }
            items.Clear();

            for (int i = 0; i < Program.theDatabase.currentSale.productIDs.Length; i++)
            {
                Model.Product p = Program.theDatabase.getProduct(Program.theDatabase.currentSale.productIDs[i]);
                string        s = p.cost.ToString("c");
                s = s + " - " + p.name;

                items.Add(GLMethods.generateString(s, 16, System.Drawing.Color.White));
            }

            foreach (Button b in cancelButtons)
            {
                b.Dispose();
            }
            cancelButtons.Clear();

            for (int i = 0; i < Program.theDatabase.currentSale.productIDs.Length; i++)
            {
                Model.Product p = Program.theDatabase.getProduct(Program.theDatabase.currentSale.productIDs[i]);
                cancelButtons.Add(new Button("x", 16, System.Drawing.Color.Red, System.Drawing.Color.Red, 0, 0));
                cancelButtons[i].onClick2 += cancelClicked;
            }
            cancelButtons.Add(new Button("X", 16, System.Drawing.Color.Red, System.Drawing.Color.Red, 0, 0));
            cancelButtons[cancelButtons.Count - 1].onClick2 += cancelClicked;

            Program.theDatabase.saveToDisk();
        }
예제 #8
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();
            }
        }
예제 #9
0
 public SoldScreenRenderer()
 {
     title      = GLMethods.generateString("Sold!", 80, System.Drawing.Color.White);
     background = new ImageTexture(Properties.Resources.background3);
 }
        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();
        }