Ejemplo n.º 1
0
        private static int Execute(CommandLineApplication config, IBudgetFilesFactory budgetFilesFactory, ILog log)
        {
            var yearOption     = YearOption.Create(config);
            var monthOption    = MonthOption.Create(config);
            var currencyOption = CurrencyOption.Create(config);

            if (yearOption.NotExists || monthOption.NotExists || currencyOption.NotExists)
            {
                config.ShowHelp();
                return(ErrorCode.Value);
            }

            var(plannedBudgetFile, realBudgetFile) = budgetFilesFactory.Create(yearOption, monthOption, currencyOption);

            if (plannedBudgetFile.NotExists || realBudgetFile.NotExists)
            {
                plannedBudgetFile.Save();
                realBudgetFile.Save();

                log.Write($"Budget {plannedBudgetFile.Budget} has been created.");
                return(OkCode.Value);
            }

            log.Write($"Budget {plannedBudgetFile.Budget} already exists.");
            return(ErrorCode.Value);
        }
Ejemplo n.º 2
0
        public override void DrawEditor()
        {
            if (error)
            {
                ImGui.Text("Error");
                return;
            }
            if (!ready)
            {
                ImGui.Text("Loading...");
                return;
            }
            ImGui.BeginChild($"###{NameLocalizationKey}Child", new Vector2(-1, 23 * ImGui.GetIO().FontGlobalScale), false, usingTags ? ImGuiWindowFlags.NoInputs : ImGuiWindowFlags.None);

            if (selectedCurrencyOption != null && selectedCurrencyOption.SubOptions.Count > 0)
            {
                ImGui.SetNextItemWidth(ImGui.GetWindowContentRegionWidth() / 2);
            }
            else
            {
                ImGui.SetNextItemWidth(-1);
            }

            if (ImGui.BeginCombo("###SoldbyNPCSearchFilter_selection", selectedCurrencyOption?.Name ?? "Not Selected"))
            {
                foreach (var option in availableOptions)
                {
                    if (ImGui.Selectable(option?.Name ?? "Not Selected", selectedCurrencyOption == option))
                    {
                        selectedCurrencyOption = option;
                        selectedSubOption      = null;
                        Modified = true;
                    }
                }

                ImGui.EndCombo();
            }

            if (selectedCurrencyOption != null && selectedCurrencyOption.SubOptions.Count > 0)
            {
                ImGui.SameLine();
                ImGui.SetNextItemWidth(-1);
                if (ImGui.BeginCombo("###SoldbyNPCSearchFilter_subselection", selectedSubOption?.Name ?? "Any"))
                {
                    foreach (var option in selectedCurrencyOption.SubOptions)
                    {
                        if (ImGui.Selectable(option?.Name ?? "Any", selectedCurrencyOption == option))
                        {
                            selectedSubOption = option;
                            Modified          = true;
                        }
                    }
                    ImGui.EndCombo();
                }
            }


            ImGui.EndChild();
        }
Ejemplo n.º 3
0
 public BrokerAccount(string userName, string password, double fundAmount, CurrencyOption fundCurrency)
 {
     this.userName     = userName;
     this.password     = password;
     this.fundAmount   = fundAmount;
     this.fundCurrency = fundCurrency;
     this.accountId    = Guid.NewGuid();
 }
Ejemplo n.º 4
0
 public override void ClearTags()
 {
     if (usingTags)
     {
         selectedCurrencyOption = nonTagSelection;
         selectedSubOption      = nonTagSubSelection;
         usingTags = false;
     }
 }
Ejemplo n.º 5
0
        public AddCommandBuilder(CommandLineApplication application)
        {
            _application = application;

            _yearOption        = YearOption.Create(application);
            _monthOption       = MonthOption.Create(application);
            _currencyOption    = CurrencyOption.Create(application);
            _amountOption      = AmountOption.Create(application);
            _categoryOption    = CategoryOption.Create(application);
            _descriptionOption = DescriptionOption.Create(application);
        }
Ejemplo n.º 6
0
        public SoldByNPCSearchFilter(ItemSearchPluginConfig config, DataManager dataManager) : base(config)
        {
            this.data = dataManager;

            notSoldByNpcOption = new CurrencyOption {
                Invert = true, Name = "Not sold by NPC", ItemHashSet = soldForAnything, HideIfEmpty = false
            };
            soldByAnyNpcOption = new CurrencyOption {
                Name = "Any Currency", ItemHashSet = soldForAnything, HideIfEmpty = false
            };


            availableOptions.Add(null); // Not Selected Option
            availableOptions.Add(notSoldByNpcOption);
            availableOptions.Add(soldByAnyNpcOption);

            availableOptions.Add(GetCurrencyOption(1, "gil"));
            availableOptions.Add(GetCurrencyOption(29, "mgp"));

            soldForCurrency.Add((uint)SpecialCurrency.GrandCompany, new HashSet <uint>()); // Grand Company Seal
            availableOptions.Add(new CurrencyOption {
                Name        = "Grand Company Seals",
                ItemHashSet = soldForCurrency[(uint)SpecialCurrency.GrandCompany],
                Tag         = "gc",
                SubOptions  = GetGrandCompanyCurrencies()
            });

            soldForCurrency.Add((uint)SpecialCurrency.BeastTribe, new HashSet <uint>()); // Beast Tribe
            availableOptions.Add(new CurrencyOption {
                Name        = "Beast Tribe Currencies",
                ItemHashSet = soldForCurrency[(uint)SpecialCurrency.BeastTribe],
                Tag         = "beasttribe",
                SubOptions  = GetBeastTribeCurrencies()
            });

            availableOptions.Add(GetCurrencyOption(28, "poetics"));
            availableOptions.Add(GetCurrencyOption(40, "allegory"));
            availableOptions.Add(GetCurrencyOption(41, "revelation"));

            Task.Run(() => {
                try {
                    foreach (var gilShopItem in dataManager.Excel.GetSheet <GilShopItem>())
                    {
                        if (!soldForAnything.Contains(gilShopItem.Item.Row))
                        {
                            soldForAnything.Add(gilShopItem.Item.Row);
                        }
                        if (!soldForCurrency[1].Contains(gilShopItem.Item.Row))
                        {
                            soldForCurrency[1].Add(gilShopItem.Item.Row);
                        }
                    }

                    foreach (var gcScripShopItem in dataManager.Excel.GetSheet <GCScripShopItem>())
                    {
                        if (!soldForAnything.Contains(gcScripShopItem.Item.Row))
                        {
                            soldForAnything.Add(gcScripShopItem.Item.Row);
                        }
                        if (!soldForCurrency[(uint)SpecialCurrency.GrandCompany].Contains(gcScripShopItem.Item.Row))
                        {
                            soldForCurrency[(uint)SpecialCurrency.GrandCompany].Add(gcScripShopItem.Item.Row);
                        }

                        var gcScripShopCategory = data.Excel.GetSheet <GCScripShopCategory>().GetRow(gcScripShopItem.RowId);
                        if (gcScripShopCategory == null)
                        {
                            continue;
                        }
                        var grandCompanyID = gcScripShopCategory.GrandCompany.Row;
                        if (grandCompanyID < 1 || grandCompanyID > 3)
                        {
                            continue;
                        }
                        if (!soldForCurrency[19 + grandCompanyID].Contains(gcScripShopItem.Item.Row))
                        {
                            soldForCurrency[19 + grandCompanyID].Add(gcScripShopItem.Item.Row);
                        }
                    }

                    foreach (var specialShop in dataManager.Excel.GetSheet <SpecialShopCustom>())
                    {
                        foreach (var entry in specialShop.Entries)
                        {
                            foreach (var c in entry.Cost)
                            {
                                if (!soldForCurrency.ContainsKey(c.Item.Row))
                                {
                                    continue;
                                }
                                foreach (var r in entry.Result)
                                {
                                    if (!soldForAnything.Contains(r.Item.Row))
                                    {
                                        soldForAnything.Add(r.Item.Row);
                                    }
                                    if (beastTribeCurrencies.Contains(c.Item.Row))
                                    {
                                        if (!soldForCurrency[(uint)SpecialCurrency.BeastTribe].Contains(r.Item.Row))
                                        {
                                            soldForCurrency[(uint)SpecialCurrency.BeastTribe].Add(r.Item.Row);
                                        }
                                    }
                                    if (!soldForCurrency[c.Item.Row].Contains(r.Item.Row))
                                    {
                                        soldForCurrency[c.Item.Row].Add(r.Item.Row);
                                    }
                                }
                            }
                        }
                    }

                    availableOptions.RemoveAll(o => {
                        if (o == null)
                        {
                            return(false);
                        }
                        if (!o.HideIfEmpty)
                        {
                            return(false);
                        }
                        return(o.ItemHashSet.Count == 0);
                    });

                    availableOptions.ForEach(o => {
                        if (o == null)
                        {
                            return;
                        }
                        o.SubOptions.RemoveAll(so => {
                            if (so == null)
                            {
                                return(false);
                            }
                            if (!so.HideIfEmpty)
                            {
                                return(false);
                            }
                            return(so.ItemHashSet.Count == 0);
                        });
                    });

                    ready = true;
                } catch (Exception ex) {
                    error = true;
                    PluginLog.LogError($"{ex}");
                }
            });
        }
Ejemplo n.º 7
0
        public override bool ParseTag(string tag)
        {
            var t = tag.ToLower().Trim();

            var split = t.Split(':');

            split[0] = split[0].Replace(" ", "").Trim();

            if (split[0] != "soldbynpc" && split[0] != "notsoldbynpc")
            {
                return(false);
            }

            Modified = true;
            if (!usingTags)
            {
                nonTagSelection    = selectedCurrencyOption;
                nonTagSubSelection = selectedSubOption;
                usingTags          = true;
            }

            if (split[0].StartsWith("not"))
            {
                selectedCurrencyOption = notSoldByNpcOption;
                selectedSubOption      = null;
                return(true);
            }

            if (split.Length > 1)
            {
                foreach (var o in availableOptions)
                {
                    if (o == null)
                    {
                        continue;
                    }
                    if (o.Tag == split[1])
                    {
                        selectedCurrencyOption = o;
                        return(true);
                    }

                    if (o.SubOptions == null)
                    {
                        continue;
                    }
                    foreach (var so in o.SubOptions)
                    {
                        if (so == null)
                        {
                            continue;
                        }
                        if (so.Tag != split[1])
                        {
                            continue;
                        }
                        selectedCurrencyOption = o;
                        selectedSubOption      = so;
                        return(true);
                    }
                }
            }

            selectedCurrencyOption = soldByAnyNpcOption;
            selectedSubOption      = null;
            return(true);
        }