コード例 #1
0
 public override string ToString()
 {
     if (_lootType == LootType.CURRENCY)
     {
         return(Utils.FormatBigInt(quantity) + " " + Locale.Get(id.ToUpper()));
     }
     else if (_lootType == LootType.ITEM)
     {
         Item i = Item.GetItem(id);
         return(i.name);
     }
     else
     {
         throw new Exception("no tostring method specified for loot type: " + _lootType);
     }
 }
コード例 #2
0
 public Tuple <bool, MessageCallback> CheckKingdom(Kingdom kingdom)
 {
     if (kingdom.Humans.Any())
     {
         return(new Tuple <bool, MessageCallback>(true, new MessageCallback()));
     }
     else
     {
         MessageCallback cb = new MessageCallback()
         {
             Text = Locale.Get("problems.no_people", kingdom.Language),
             From = ECharacter.Knight
         };
         return(new Tuple <bool, MessageCallback>(false, cb));
     }
 }
コード例 #3
0
ファイル: TRPanel.cs プロジェクト: klyte45/TreesRespiration
        private void CreateSlider(UIHelperExtension uiHelper, string labelContent, Action <int> setter, Func <int> getter)
        {
            UILabel  label  = null;
            UISlider slider = uiHelper.AddSlider(Locale.Get(labelContent), 0, 9, 1, getter(), (x) =>
            {
                setter(x < 0.1 ? 0 : 1 << Mathf.RoundToInt(x - 1));
                label.suffix = getter().ToString();
            }, out label);

            slider.width      = PanelWidth - 15;
            label.minimumSize = new Vector2(PanelWidth - 15, 0);
            label.suffix      = getter().ToString();
            label.wordWrap    = false;
            KlyteMonoUtils.LimitWidthAndBox(label);
            ((UIPanel)(label.parent)).autoLayoutPadding = new RectOffset();
        }
コード例 #4
0
        protected override void AsTitleInternal()
        {
            m_child.text = Locale.Get("K45_TLM_AGE_REPORT_COLUMN_CHILD_SHORT");
            m_teens.text = Locale.Get("K45_TLM_AGE_REPORT_COLUMN_TEENS_SHORT");
            m_young.text = Locale.Get("K45_TLM_AGE_REPORT_COLUMN_YOUNG_SHORT");
            m_adult.text = Locale.Get("K45_TLM_AGE_REPORT_COLUMN_ADULT_SHORT");
            m_elder.text = Locale.Get("K45_TLM_AGE_REPORT_COLUMN_ELDER_SHORT");
            m_total.text = Locale.Get("K45_TLM_AGE_REPORT_COLUMN_TOTAL_SHORT");

            m_child.textAlignment = UIHorizontalAlignment.Center;
            m_teens.textAlignment = UIHorizontalAlignment.Center;
            m_young.textAlignment = UIHorizontalAlignment.Center;
            m_adult.textAlignment = UIHorizontalAlignment.Center;
            m_elder.textAlignment = UIHorizontalAlignment.Center;
            m_total.textAlignment = UIHorizontalAlignment.Center;
        }
コード例 #5
0
 public static string GetTabName(this ConfigTabs tab)
 {
     return(tab switch
     {
         ConfigTabs.TransportSystem => Locale.Get("K45_TLM_TRANSPORT_SYSTEM"),
         ConfigTabs.TicketPrices => Locale.Get("K45_TLM_DEFAULT_PRICE"),
         ConfigTabs.NearLines => Locale.Get("K45_TLM_NEAR_LINES_CONFIG"),
         ConfigTabs.Automation => Locale.Get("K45_TLM_AUTOMATION_CONFIG"),
         ConfigTabs.AutoName_PT => Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT"),
         ConfigTabs.AutoName_BD => Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_OTHER"),
         ConfigTabs.AutoName_PA => Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_AREAS"),
         ConfigTabs.Palettes => Locale.Get("K45_TLM_CUSTOM_PALETTE_CONFIG"),
         ConfigTabs.About => Locale.Get("K45_TLM_BETAS_EXTRA_INFO"),
         ConfigTabs.CostPerPassenger => Locale.Get("K45_TLM_COST_PER_PASSENGER_CONFIG"),
         _ => throw new Exception($"Not supported: {tab}"),
     });
コード例 #6
0
        private static UISlider GenerateBudgetMultiplierField(UIHelperExtension uiHelper, string title, OnValueChanged action, out UILabel label, out UIPanel panel)
        {
            UISlider budgetMultiplier = (UISlider)uiHelper.AddSlider(Locale.Get("TLM_BUDGET_MULTIPLIER_LABEL"), 0f, 5, 0.05f, 1, action);

            label                     = budgetMultiplier.transform.parent.GetComponentInChildren <UILabel>();
            label.prefix              = title;
            label.autoSize            = true;
            label.wordWrap            = false;
            label.text                = string.Format(" x{0:0.00}", 0);
            panel                     = budgetMultiplier.GetComponentInParent <UIPanel>();
            panel.width               = 300;
            panel.autoLayoutDirection = LayoutDirection.Horizontal;
            panel.autoLayoutPadding   = new RectOffset(5, 5, 3, 3);
            panel.wrapLayout          = true;
            return(budgetMultiplier);
        }
コード例 #7
0
 public Tuple <bool, MessageCallback> CheckKingdom(Kingdom kingdom)
 {
     if (kingdom.GetResourcesCount(ItemName) >= Count)
     {
         return(new Tuple <bool, MessageCallback>(true, new MessageCallback()));
     }
     else
     {
         MessageCallback cb = new MessageCallback()
         {
             Text = Locale.Get("resources." + ItemName + ".miss", kingdom.Language),
             From = ECharacter.Knight
         };
         return(new Tuple <bool, MessageCallback>(false, cb));
     }
 }
コード例 #8
0
        public static string getTabName(this UiCategoryTab tab)
        {
            switch (tab)
            {
            case UiCategoryTab.LineListing: return(Locale.Get("TLM_LIST_LINES_TOOLTIP"));

            case UiCategoryTab.DepotListing: return(Locale.Get("TLM_LIST_DEPOT_TOOLTIP"));

            case UiCategoryTab.TourListing: return(Locale.Get("TLM_LIST_TOURS_TOOLTIP"));

            case UiCategoryTab.PrefixEditor: return(Locale.Get("TLM_CITY_ASSETS_SELECTION"));

            default:
                throw new Exception($"Not supported: {tab}");
            }
        }
コード例 #9
0
ファイル: Statistics.cs プロジェクト: vitalii2011/RealTime
        private static void RefreshEconomyPanel()
        {
            IEnumerable <UIComponent> components = ToolsModifierControl.economyPanel?
                                                   .GetComponentsInChildren <UIComponent>()?
                                                   .Where(c => !string.IsNullOrEmpty(c.tooltipLocaleID));

            if (components == null)
            {
                return;
            }

            foreach (UIComponent component in components.Where(c => c is UISprite || c is UITextComponent))
            {
                component.tooltip = Locale.Get(component.tooltipLocaleID);
            }
        }
コード例 #10
0
ファイル: ShapeLoader.cs プロジェクト: AlexAbramov/gis
        void CreateLib()
        {
            Rect bounds = new Rect(XTransform(minx), YTransform(miny), XTransform(maxx), YTransform(maxy));

            lib          = new GLib(null, bounds, new Indexer());
            lib.Name     = Locale.Get("_glibdefaultname");
            lib.StyleStr = "pc=red";
            GType type;

            GeomType[] geomTypes = { GeomType.Polygon, GeomType.Polyline, GeomType.Point, GeomType.Caption };
            foreach (GeomType gt in geomTypes)
            {
                type      = new GType(lib, gt);
                type.Name = Locale.Get(gt.ToString());
            }
        }
コード例 #11
0
        public static void GenerateExportButtons(UIHelperExtension helperSettings, string assetKind,
                                                 out UIPanel m_exportButtonContainer, out UIButton m_exportButton, OnButtonClicked OnExport,
                                                 out UIPanel m_exportButtonContainerLocal, out UIButton m_exportButtonLocal, OnButtonClicked OnExportLocal)
        {
            KlyteMonoUtils.CreateUIElement(out m_exportButtonContainer, helperSettings.Self.transform, $"ExportContainer{assetKind}", new Vector4(0, 0, helperSettings.Self.width, 45));
            m_exportButtonContainer.autoLayout        = true;
            m_exportButtonContainer.autoLayoutPadding = new RectOffset(0, 6, 0, 0);
            m_exportButton = UIHelperExtension.AddButton(m_exportButtonContainer, Locale.Get($"K45_ACE_EXPORTDATA_TOASSET{assetKind.ToUpper()}"), OnExport);
            KlyteMonoUtils.LimitWidthAndBox(m_exportButton, m_exportButtonContainer.width * 0.7f);

            KlyteMonoUtils.CreateUIElement(out m_exportButtonContainerLocal, helperSettings.Self.transform, $"ExportContainerLocal{assetKind}", new Vector4(0, 0, helperSettings.Self.width, 45));
            m_exportButtonContainerLocal.autoLayout        = true;
            m_exportButtonContainerLocal.autoLayoutPadding = new RectOffset(0, 6, 0, 0);
            m_exportButtonLocal = UIHelperExtension.AddButton(m_exportButtonContainerLocal, Locale.Get($"K45_ACE_EXPORTDATA_TOLOCAL{assetKind.ToUpper()}"), OnExportLocal);
            KlyteMonoUtils.LimitWidthAndBox(m_exportButtonLocal, m_exportButtonContainerLocal.width * 0.7f);
        }
コード例 #12
0
        private UISlider GenerateVerticalBudgetMultiplierField(UIHelperExtension uiHelper, int idx)
        {
            UISlider bugdetSlider = (UISlider)uiHelper.AddSlider(Locale.Get("TLM_BUDGET_MULTIPLIER_LABEL"), 0f, 5, 0.05f, -1,
                                                                 (x) =>
            {
            });
            UILabel budgetSliderLabel = bugdetSlider.transform.parent.GetComponentInChildren <UILabel>();
            UIPanel budgetSliderPanel = bugdetSlider.GetComponentInParent <UIPanel>();

            budgetSliderPanel.relativePosition = new Vector2(45 * idx + 15, 50);
            budgetSliderPanel.width            = 40;
            budgetSliderPanel.height           = 160;
            bugdetSlider.zOrder          = 0;
            budgetSliderPanel.autoLayout = true;

            bugdetSlider.size = new Vector2(40, 100);
            bugdetSlider.scrollWheelAmount = 0;
            bugdetSlider.orientation       = UIOrientation.Vertical;
            bugdetSlider.clipChildren      = true;
            bugdetSlider.thumbOffset       = new Vector2(0, -100);
            bugdetSlider.color             = Color.black;

            bugdetSlider.thumbObject.width  = 40;
            bugdetSlider.thumbObject.height = 200;
            ((UISprite)bugdetSlider.thumbObject).spriteName = "ScrollbarThumb";
            ((UISprite)bugdetSlider.thumbObject).color      = new Color32(1, 140, 46, 255);

            budgetSliderLabel.textScale     = 0.5f;
            budgetSliderLabel.autoSize      = false;
            budgetSliderLabel.wordWrap      = true;
            budgetSliderLabel.pivot         = UIPivotPoint.TopCenter;
            budgetSliderLabel.textAlignment = UIHorizontalAlignment.Center;
            budgetSliderLabel.text          = string.Format(" x{0:0.00}", 0);
            budgetSliderLabel.prefix        = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL", idx);
            budgetSliderLabel.width         = 40;
            budgetSliderLabel.font          = UIHelperExtension.defaultFontCheckbox;

            var idx_loc = idx;

            bugdetSlider.eventValueChanged += delegate(UIComponent c, float val)
            {
                budgetSliderLabel.text = string.Format(" x{0:0.00}", val);
                setBudgetHour(val, idx_loc);
            };

            return(bugdetSlider);
        }
コード例 #13
0
        private bool Interact(Entity entity)
        {
            var w = entity.GetComponent <ActiveWeaponComponent>();

            if (w.Item != null && w.Item.Scourged)
            {
                entity.GetComponent <DialogComponent>().StartAndClose($"~~{Locale.Get("scourged")}~~", 2);
                return(true);
            }

            var i  = GetComponent <ItemComponent>();
            var w2 = entity.GetComponent <WeaponComponent>();

            if (i.Item != null && w2.Item == null)
            {
                i.Exchange(w2);
                w.RequestSwap();
            }
            else
            {
                i.Exchange(w);
            }

            if (w.Item != null)
            {
                Audio.PlaySfx(w.Item.Data.WeaponType.GetSwapSfx());
                entity.GetComponent <PlayerGraphicsComponent>().AnimateSwap();
            }
            else if (entity.GetComponent <WeaponComponent>().Item != null)
            {
                w.RequestSwap();
            }


            if (i.Item != null)
            {
                itemRegion = i.Item.Region;
            }
            else
            {
                itemRegion = null;
            }

            AddFx();
            return(false);
        }
コード例 #14
0
        public ExecutionResult Train(Dictionary <string, object> dict)
        {
            int count = 1;

            if (dict.ContainsKey("count"))
            {
                count = (int)dict["count"];
            }
            if (!dict.ContainsKey("skill"))
            {
                return(new ExecutionResult(false, new MessageCallback(Locale.Get("jobs.no_job", this.Language), ECharacter.Knight)));
            }
            string             sk   = (string)dict["skill"];
            JobDescription     jb   = ContentManager.GetJobDescriptionBySkill(sk);
            List <IDependency> deps = new List <IDependency>(jb.TrainDepence);

            deps.Add(new HumanDependency());

            foreach (IDependency dep in deps)
            {
                Tuple <bool, MessageCallback> res = dep.CheckKingdom(this);
                if (!res.Item1)
                {
                    return(new ExecutionResult(false, res.Item2));
                }
            }
            Human     h    = dict.Get("human") as Human ?? FindBySkill(sk, false);
            HumanTask task = new HumanTask(h)
            {
                Destination = sk,
                TaskType    = ETask.Training
            };

            task.CalculateTaskTime(h);
            if (!h.AddTask(task))
            {
                return(new ExecutionResult(false, new MessageCallback(
                                               Locale.Get(string.Format("problems.dont_work", h.GetName(Language)), Language),
                                               ECharacter.Knight
                                               )));
            }
            else
            {
                return(new ExecutionResult(new MessageCallback(Locale.Get("answers.yes", this.Language))));
            }
        }
コード例 #15
0
ファイル: BasicIUserMod.cs プロジェクト: klyte45/SuburbStyler
        protected void CreateGroup9(UIHelperExtension helper)
        {
            UIHelperExtension group9 = helper.AddGroupExtended(Locale.Get("SS_BETAS_EXTRA_INFO"));

            Group9SettingsUI(group9);

            group9.AddCheckbox(Locale.Get("SS_DEBUG_MODE"), m_debugMode.value, delegate(bool val) { m_debugMode.value = val; });
            group9.AddLabel(String.Format(Locale.Get("SS_VERSION_SHOW"), fullVersion));
            if (typeof(R) != typeof(SSResourceLoader))
            {
                group9.AddLabel(Locale.Get("SS_ORIGINAL_TLM_VERSION") + " " + string.Join(".", Singleton <R> .instance.loadResourceString("TLMVersion.txt").Split(".".ToCharArray()).Take(3).ToArray()));
            }
            group9.AddButton(Locale.Get("SS_RELEASE_NOTES"), delegate()
            {
                showVersionInfoPopup(true);
            });
        }
コード例 #16
0
    public string GetNameAndCost()
    {
        string txtResult = name + ".";

        if (mpCost > 0)
        {
            txtResult += " " + Locale.Get("MP_COST", mpCost.ToString()) + ".";
        }

        //special text addition for displaying the defend skill
        if (id == SkillId.DEFEND)
        {
            txtResult += " " + Locale.Get("INTERACT_AGAIN_TO_DEFEND");
        }

        return(txtResult);
    }
コード例 #17
0
        private void Awake()
        {
            parent = GetComponentInParent <UIComponent>();
            UIHelperExtension group7 = new UIHelperExtension(parent.GetComponentInChildren <UIScrollablePanel>());

            ((UIScrollablePanel)group7.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIScrollablePanel)group7.Self).wrapLayout          = true;
            ((UIScrollablePanel)group7.Self).width = 730;

            group7.AddLabel(Locale.Get("K45_TLM_AUTOMATION_CONFIG"));
            group7.AddSpace(15);

            TLMConfigOptions.instance.generateCheckboxConfig(group7, Locale.Get("K45_TLM_AUTO_COLOR_ENABLED"), TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED);
            TLMConfigOptions.instance.generateCheckboxConfig(group7, Locale.Get("K45_TLM_AUTO_NAME_ENABLED"), TLMConfigWarehouse.ConfigIndex.AUTO_NAME_ENABLED);
            TLMConfigOptions.instance.generateCheckboxConfig(group7, Locale.Get("K45_TLM_USE_CIRCULAR_AUTO_NAME"), TLMConfigWarehouse.ConfigIndex.CIRCULAR_IN_SINGLE_DISTRICT_LINE);
            TLMConfigOptions.instance.generateCheckboxConfig(group7, Locale.Get("K45_TLM_ADD_LINE_NUMBER_AUTO_NAME"), TLMConfigWarehouse.ConfigIndex.ADD_LINE_NUMBER_IN_AUTONAME);
        }
コード例 #18
0
        private void OnDeleteFromCity() => K45DialogControl.ShowModal(new K45DialogControl.BindProperties
        {
            message     = Locale.Get("K45_WTS_PROMPTDELETEBUILDINGLAYOUT"),
            showButton1 = true,
            showButton2 = true,
            textButton1 = Locale.Get("YES"),
            textButton2 = Locale.Get("NO"),
        }, (x) =>
        {
            if (x == 1)
            {
                WTSVehicleData.Instance.CityDescriptors.Remove(CurrentVehicleInfo.name);
                ReloadVehicle();
            }

            return(true);
        });
コード例 #19
0
 protected override void OnToolRefreshClick(object sender, EventArgs e)
 {
     if (Table.IsEdited)
     {
         var question = new QuestionMessage(Locale.Get("TableEditor", "Continue Rejecting?"), "Check");
         question.Buttons.Add(Command.No);
         question.Buttons.Add(Command.Yes);
         if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
         {
             Table.RejectChanges(GuiEnvironment.User);
         }
     }
     else if (Table.IsSynchronized)
     {
         Table.IsSynchronized = false;
     }
 }
コード例 #20
0
        private void OnDeleteFromCity() => K45DialogControl.ShowModal(new K45DialogControl.BindProperties
        {
            message     = Locale.Get("K45_WTS_PROMPTDELETEHWSHIELDLAYOUT"),
            showButton1 = true,
            showButton2 = true,
            textButton1 = Locale.Get("YES"),
            textButton2 = Locale.Get("NO"),
        }, (x) =>
        {
            if (x == 1)
            {
                WTSHighwayShieldsData.Instance.CityDescriptors.Remove(CurrentSelection);
                ReloadShield();
            }

            return(true);
        });
コード例 #21
0
        public static bool Reroll(Item item, ItemPool pool, Func <ItemData, bool> filter = null)
        {
            var id = Items.Generate(pool, i => i.Id != item.Id && Items.ShouldAppear(i) && (filter == null || filter(i)));

            if (id != null)
            {
                item.LastId = item.Id;
                item.ConvertTo(id);
                item.AutoPickup = false;

                TextParticle.Add(item, Locale.Get("rerolled")).Stacks = false;

                return(true);
            }

            return(false);
        }
コード例 #22
0
ファイル: TypesUserControl.cs プロジェクト: AlexAbramov/gis
 void RemoveType()
 {
     try
     {
         GType type = SelectedType;
         if (type == null)
         {
             return;
         }
         TreeNode node = SelectedNode;
         string   s    = string.Format("{0} '{1}' ?", Locale.Get("_removetypeconf"), type.Name);
         if (MessageBox.Show(s, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             StatVisitor sv = new StatVisitor();
             type.Visit(sv);
             Stat stat       = sv.Stat;
             bool removeFlag = true;
             if (stat.nObjects > 0 || stat.nTypes > 1)
             {
                 s          = string.Format(Locale.Get("_removetypeallconf"), type.Name, stat.nTypes - 1, stat.nObjects);
                 removeFlag = MessageBox.Show(s, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes;
             }
             if (removeFlag)
             {
                 RemoveNode(node);
                 if (App.GetControlsAttr(ControlsAttr.AutoSave))
                 {
                     using (Context context = Lib.GetContext()) type.Remove(context);
                 }
                 else
                 {
                     type.Remove();
                 }
                 if (OnTypeRemoved != null)
                 {
                     OnTypeRemoved(this, new TypeEventArgs(type));
                 }
                 app.CheckRepaint(type);
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
コード例 #23
0
 private void RefreshDropdownLists()
 {
     string[] array = new string[m_transferReasons.Length];
     for (int i = 0; i < m_transferReasons.Length; i++)
     {
         string text = Locale.Get("WAREHOUSEPANEL_RESOURCE", m_transferReasons[i].ToString());
         array[i] = text;
     }
     this.m_dropdownResource.items = array;
     array = new string[this.m_warehouseModes.Length];
     for (int j = 0; j < this.m_warehouseModes.Length; j++)
     {
         string text2 = Locale.Get("WAREHOUSEPANEL_MODE", this.m_warehouseModes[j].ToString());
         array[j] = text2;
     }
     this.m_dropdownMode.items = array;
 }
コード例 #24
0
        public override string GenerateName(ushort buildingID, InstanceID caller)
        {
            if (this.m_info.m_prefabDataIndex == -1)
            {
                return(null);
            }
            Randomizer randomizer = new Randomizer((int)buildingID);
            string     key        = PrefabCollection <BuildingInfo> .PrefabName((uint)this.m_info.m_prefabDataIndex);

            uint num = Locale.CountUnchecked("BUILDING_NAME", key);

            if (num != 0u)
            {
                return(Locale.Get("BUILDING_NAME", key, randomizer.Int32(num)));
            }
            return(BuildingNameGenerator.GenerateName(this.m_info.m_class.m_subService, randomizer));
        }
        public string CustomGetLocalizedStatus(ushort vehicleID, ref Vehicle data, out InstanceID target)
        {
            CitizenManager citizenManager   = Singleton <CitizenManager> .instance;
            ushort         driverInstanceId = GetDriverInstanceId(vehicleID, ref data);
            ushort         targetBuildingId = 0;

            if (driverInstanceId != 0)
            {
                if ((data.m_flags & Vehicle.Flags.Parking) != (Vehicle.Flags) 0)
                {
                    uint citizen = citizenManager.m_instances.m_buffer[(int)driverInstanceId].m_citizen;
                    if (citizen != 0u && citizenManager.m_citizens.m_buffer[citizen].m_parkedVehicle != 0)
                    {
                        target = InstanceID.Empty;
                        return(Locale.Get("VEHICLE_STATUS_PARKING"));
                    }
                }
                targetBuildingId = citizenManager.m_instances.m_buffer[(int)driverInstanceId].m_targetBuilding;
            }
            if (targetBuildingId == 0)
            {
                target = InstanceID.Empty;
                return(Locale.Get("VEHICLE_STATUS_CONFUSED"));
            }
            bool flag = (Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)targetBuildingId].m_flags & Building.Flags.IncomingOutgoing) != Building.Flags.None;

            if (flag)
            {
                target = InstanceID.Empty;
                return(Locale.Get("VEHICLE_STATUS_LEAVING"));
            }
            target          = InstanceID.Empty;
            target.Building = targetBuildingId;

            string ret = Locale.Get("VEHICLE_STATUS_GOINGTO");

            // NON-STOCK CODE START
            if (Options.prohibitPocketCars)
            {
                ret = AdvancedParkingManager.Instance.EnrichLocalizedCarStatus(ret, ref ExtCitizenInstanceManager.Instance.ExtInstances[driverInstanceId]);
            }
            // NON-STOCK CODE END

            return(ret);
        }
コード例 #26
0
ファイル: ShopStand.cs プロジェクト: tesfabpel/BurningKnight
        protected override bool CanTake(Entity entity)
        {
            if (!base.CanTake(entity))
            {
                return(false);
            }

            if (!Sells || Free)
            {
                return(true);
            }

            if (!OkToBuy(entity))
            {
                AnimationUtil.ActionFailed();
                entity.GetComponent <DialogComponent>().StartAndClose($"~~{Locale.Get("scourged")}~~", 2);

                return(false);
            }
            else if (!TryPay(entity))
            {
                AnimationUtil.ActionFailed();

                foreach (var n in GetComponent <RoomComponent>().Room.Tagged[Tags.Npc])
                {
                    if (n is ShopNpc s)
                    {
                        n.GetComponent <DialogComponent>().StartAndClose(s.GetFailDialog(), 3);
                        break;
                    }
                    else if (n is ShopKeeper)
                    {
                        n.GetComponent <DialogComponent>().StartAndClose($"shopkeeper_{Rnd.Int(15, 18)}", 3);
                        break;
                    }
                }

                return(false);
            }

            Sells = false;

            Audio.PlaySfx("item_purchase");
            return(true);
        }
コード例 #27
0
        protected UIButton SpawnEntry(string name, string localeID, string unlockText, string spriteBase, bool enabled)
        {
            UIButton btn;

            if (m_strip.childCount > this.m_objectIndex)
            {
                btn = (m_strip.components[this.m_objectIndex] as UIButton);
            }
            else
            {
                GameObject asGameObject  = UITemplateManager.GetAsGameObject(kSubbarButtonTemplate);
                GameObject asGameObject2 = UITemplateManager.GetAsGameObject(kSubbarPanelTemplate);
                btn = m_strip.AttachUIComponent(asGameObject) as UIButton;
                //btn = m_strip.AddTab(name, asGameObject, asGameObject2, typeof(RoadCustomizerPanel)) as UIButton;
                //btn.eventClick += OnClick;
            }
            btn.isEnabled = enabled;

            btn.atlas = this.m_atlas;
            //btn.gameObject.GetComponent<TutorialUITag>().tutorialTag = name;
            string text = spriteBase + name;

            UIUtils.SetThumbnails(text, sm_thumbnailCoords[text], this.m_atlas);
            btn.normalFgSprite   = text;
            btn.focusedFgSprite  = text; // +"Focused";
            btn.hoveredFgSprite  = text; // +"Hovered";
            btn.pressedFgSprite  = text; // +"Pressed";
            btn.disabledFgSprite = text; // +"Disabled";

            btn.normalBgSprite   = "TabBg";
            btn.focusedBgSprite  = "TabBg" + "Focused";
            btn.hoveredBgSprite  = btn.pressedBgSprite = "TabBg" + "Hovered";
            btn.disabledBgSprite = "TabBg" + "Disabled";

            if (!string.IsNullOrEmpty(localeID) && !string.IsNullOrEmpty(unlockText))
            {
                btn.tooltip = Locale.Get(localeID, name) + " - " + unlockText;
            }
            else if (!string.IsNullOrEmpty(localeID))
            {
                btn.tooltip = Locale.Get(localeID, name);
            }
            this.m_objectIndex++;
            return(btn);
        }
コード例 #28
0
        public override void LoadDefaults()
        {
            if (File.Exists(ElectricRoadsController.DEFAULT_CONFIG_FILE))
            {
                try
                {
                    if (Deserialize(typeof(ClassesData), File.ReadAllBytes(ElectricRoadsController.DEFAULT_CONFIG_FILE)) is ClassesData defaultData)
                    {
                        m_cachedDictDataSaved = defaultData.m_cachedDictDataSaved;
                        eventAllChanged?.Invoke();
                    }
                }
                catch (Exception e)
                {
                    LogUtils.DoErrorLog($"EXCEPTION WHILE LOADING: {e.GetType()} - {e.Message}\n {e.StackTrace}");

                    K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                    {
                        icon               = ElectricRoadsMod.Instance.IconName,
                        title              = Locale.Get("K45_ER_ERROR_LOADING_DEFAULTS_TITLE"),
                        message            = string.Format(Locale.Get("K45_ER_ERROR_LOADING_DEFAULTS_MESSAGE"), ElectricRoadsController.DEFAULT_CONFIG_FILE, e.GetType(), e.Message, e.StackTrace),
                        showButton1        = true,
                        textButton1        = Locale.Get("K45_ER_OK_BUTTON"),
                        showButton2        = true,
                        textButton2        = Locale.Get("K45_ER_OPEN_FOLDER_ON_EXPLORER_BUTTON"),
                        showButton3        = true,
                        textButton3        = Locale.Get("K45_ER_GO_TO_MOD_PAGE_BUTTON"),
                        useFullWindowWidth = true
                    }, (x) =>
                    {
                        if (x == 2)
                        {
                            ColossalFramework.Utils.OpenInFileBrowser(ElectricRoadsController.FOLDER_PATH);
                            return(false);
                        }
                        else if (x == 3)
                        {
                            ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=1689984220");
                            return(false);
                        }
                        return(true);
                    });
                }
            }
        }
コード例 #29
0
        public Image GetImage(string imageName, string parName)
        {
            Image image = null;

            try
            {
                image = sb.ImageIndexer == null ? null : sb.ImageIndexer.GetImage(imageName);
            }
            catch
            {
            }
            if (image == null)
            {
                string msg = string.Format("{0}: {1}{2}={3}", Locale.Get("sbimagenotfound"), prefix, parName, imageName);
                AddErrorMsg(msg);
            }
            return(image);
        }
コード例 #30
0
        public Color GetColor(string colorName, string parName)
        {
            Color c = Color.Empty;

            try
            {
                c = sb.ColorIndexer == null?Color.FromName(colorName) : sb.ColorIndexer.GetColor(colorName);
            }
            catch
            {
            }
            if (c.ToArgb() == 0)
            {
                string msg = string.Format("{0}: {1}{2}={3}", Locale.Get("sbwrongcolorformat"), prefix, parName, colorName);
                AddErrorMsg(msg);
            }
            return(c);
        }