Пример #1
0
 /// <summary>
 /// Constructor for creating an InvoiceItem.
 /// </summary>
 /// <param name="modifier">The IFundingModifier that generated this InvoiceItem.</param>
 /// <param name="revenue">The revenue tied to this invoice.</param>
 /// <param name="expenses">The expenses tied to this invoice.</param>
 /// <param name="reason">(Optional parameter) The category for the invoice.</param>
 public InvoiceItem(IFundingModifier modifier, double revenue, double expenses, TransactionReasons reason = TransactionReasons.None)
 {
     this.modifier = modifier;
     InvoiceName = modifier != null? modifier.GetName() : string.Empty;
     Revenue = revenue;
     Expenses = expenses;
     InvoiceReason = reason;
     RegisterEvents();
 }
Пример #2
0
 public void PersistenceLoad()
 {
     modifier = BROKE.Instance.fundingModifiers.FirstOrDefault(mod => mod.GetName() == InvoiceName);
     RegisterEvents();
 }
 public SingleToMultiFundingModifier(IFundingModifier modifier)
 {
     this.modifier = modifier;
 }
Пример #4
0
        public void DrawExpenseReportWindow()
        {
            GUIStyle redText = new GUIStyle(GUI.skin.label);
            redText.normal.textColor = Color.red;
            GUIStyle yellowText = new GUIStyle(GUI.skin.label);
            yellowText.normal.textColor = Color.yellow;
            GUIStyle greenText = new GUIStyle(GUI.skin.label);
            greenText.normal.textColor = Color.green;

            GUIStyle redText2 = new GUIStyle(GUI.skin.textArea);
            redText2.normal.textColor = Color.red;
            GUIStyle yellowText2 = new GUIStyle(GUI.skin.textArea);
            yellowText2.normal.textColor = Color.yellow;
            GUIStyle greenText2 = new GUIStyle(GUI.skin.textArea);
            greenText2.normal.textColor = Color.green;

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(GUILayout.Width(WindowWidth));
            GUILayout.Label("Revenue", yellowText);
            //Wrap this in a scrollbar
            revenueScroll = GUILayout.BeginScrollView(revenueScroll, SkinsLibrary.CurrentSkin.textArea);
            double totalRevenue = 0;
            foreach (IFundingModifier FM in fundingModifiers)
            {
                var revenueForFM = InvoiceItems.Where(item => item.InvoiceName == FM.GetName()).Sum(item => item.Revenue);
                totalRevenue += revenueForFM;
                if (revenueForFM != 0)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(FM.GetName(), SkinsLibrary.CurrentSkin.textArea, GUILayout.Width(WindowWidth/2));
                    GUILayout.Label("√" + revenueForFM.ToString("N"), greenText2); //GREEN
                    if (FM.hasMainGUI())
                    {
                        if (selectedMainFM != FM && GUILayout.Button("→", GUILayout.ExpandWidth(false)))
                        {
                            //tell it to display Main stuff for this in a new vertical
                            selectedMainFM = FM;
                            this.WindowRect.width *= 2;
                            //widen the window probably
                        }
                        if (selectedMainFM != null && selectedMainFM == FM && GUILayout.Button("←", GUILayout.ExpandWidth(false)))
                        {
                            //hide side window
                            selectedMainFM = null;
                            this.WindowRect.width /= 2;
                            //maybe reset the width here then
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Total Revenue: ");
            GUILayout.Label("√" + totalRevenue.ToString("N"), greenText);
            GUILayout.EndHorizontal();

            GUILayout.Label("Expenses", yellowText);
            //Wrap this in a scrollbar
            expenseScroll = GUILayout.BeginScrollView(expenseScroll, SkinsLibrary.CurrentSkin.textArea);
            double totalExpenses = 0;
            foreach (IFundingModifier FM in fundingModifiers)
            {
                var expenseForFM = InvoiceItems.Where(item => item.InvoiceName == FM.GetName()).Sum(item => item.Expenses);
                totalExpenses += expenseForFM;
                if (expenseForFM != 0)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(FM.GetName(), SkinsLibrary.CurrentSkin.textArea, GUILayout.Width(WindowWidth / 2));
                    GUILayout.Label("√" + expenseForFM.ToString("N"), redText2); //RED
                    if (FM.hasMainGUI())
                    {
                        if (selectedMainFM != FM && GUILayout.Button("→", GUILayout.ExpandWidth(false)))
                        {
                            //tell it to display Main stuff for this in a new vertical
                            selectedMainFM = FM;
                            this.WindowRect.width *= 2;
                            //widen the window probably
                        }
                        if (selectedMainFM != null && selectedMainFM == FM && GUILayout.Button("←", GUILayout.ExpandWidth(false)))
                        {
                            //hide side window
                            selectedMainFM = null;
                            this.WindowRect.width /= 2;
                            //maybe reset the width here then
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Total Expenses: ");
            GUILayout.Label("√" + totalExpenses.ToString("N"), redText);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Net Revenue: ", yellowText);
            GUILayout.Label("√" + Math.Abs(totalRevenue - totalExpenses).ToString("N"), (totalRevenue - totalExpenses) < 0 ? redText : greenText);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(((Texture)GameDatabase.Instance.GetTexture("BROKE/Textures/gear", false)), GUILayout.ExpandWidth(false)))
            {
                DrawSettings = true;
            }
            payAmountTxt = GUILayout.TextField(payAmountTxt);
            if (GUILayout.Button("Pay", GUILayout.ExpandWidth(false)))
            {
                double toPay;
                if (!double.TryParse(payAmountTxt, out toPay))
                {
                    toPay = -1;
                    payAmountTxt = "Pay Maximum";
                }
                else
                {
                    toPay += PendingRevenue();
                }
                CashInRevenues();
                toPay = Math.Min(toPay, RemainingDebt());
                PayExpenses(toPay);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            //draw main window for the selected FM
            if (selectedMainFM != null)
            {
                GUILayout.BeginVertical(GUILayout.Width(WindowWidth));
                customScroll = GUILayout.BeginScrollView(customScroll);
                //Put it in a scrollview as well
                selectedMainFM.DrawMainGUI();
                GUILayout.EndScrollView();
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
Пример #5
0
 public void DisableFundingModifier(IFundingModifier toDisable)
 {
     disabledFundingModifiers.AddUnique(toDisable.GetConfigName());
     toDisable.OnDisabled();
 }
Пример #6
0
 public bool FMDisabled(IFundingModifier toCheck)
 {
     return disabledFundingModifiers.Contains(toCheck.GetConfigName());
 }
Пример #7
0
 public void EnableFundingModifier(IFundingModifier toEnable)
 {
     disabledFundingModifiers.Remove(toEnable.GetConfigName());
     toEnable.OnEnabled();
 }
Пример #8
0
        public void DrawSettingsWindow()
        {
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            foreach (IFundingModifier FM in fundingModifiers)
            {
                GUILayout.BeginHorizontal(SkinsLibrary.CurrentSkin.textArea);
                GUILayout.Label(FM.GetName(), GUILayout.Width(WindowWidth / 2));
                bool disabled = FMDisabled(FM);
                if (GUILayout.Button(disabled ? "Enable" : "Disable"))
                {
                    if (disabled)
                        EnableFundingModifier(FM);
                    else
                        DisableFundingModifier(FM);
                }
                if (FM.hasSettingsGUI())
                {
                    if (selectedMainFM != FM && GUILayout.Button("→", GUILayout.ExpandWidth(false)))
                    {
                        //tell it to display Main stuff for this in a new vertical
                        selectedMainFM = FM;
                        this.WindowRect.width *= 2;
                        //widen the window probably
                    }
                    if (selectedMainFM != null && selectedMainFM == FM && GUILayout.Button("←", GUILayout.ExpandWidth(false)))
                    {
                        //hide side window
                        selectedMainFM = null;
                        this.WindowRect.width /= 2;
                        //maybe reset the width here then
                    }
                }
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Change Skin"))
            {
                //SkinsLibrary.SetCurrent(SkinsLibrary.List.Keys.ElementAt((SkinsLibrary.List.Values.ToList().IndexOf(SkinsLibrary.CurrentSkin) + 1)%SkinsLibrary.List.Count));
                SelectedSkin++;
                SelectedSkin %= skins.Count;
                SelectSkin(SelectedSkin);
            }

            GUILayout.EndVertical();

            //draw main window for the selected FM
            if (selectedMainFM != null)
            {
                GUILayout.BeginVertical(GUILayout.Width(WindowWidth));
                customScroll = GUILayout.BeginScrollView(customScroll);
                //Put it in a scrollview as well
                selectedMainFM.DrawSettingsGUI();
                GUILayout.EndScrollView();
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }