Example #1
0
        /// <summary>
        ///     Updates the component draw order.
        /// </summary>
        protected virtual void UpdateDrawOrder()
        {
            var sorted = FrameworkMenu.GetOrderedLists(this.StaticComponents, this.InteractiveComponents);

            this.DrawOrder  = sorted.Value;
            this.EventOrder = sorted.Key;
        }
Example #2
0
        private static void OnAccept(IInteractiveMenuComponent component, IComponentContainer container,
                                     FrameworkMenu menu)
        {
            switch (AwaitingConfirmation)
            {
            case "ship":
                AssociationHandler.Main.Eval = true;
                break;

            case "luck":

                break;

            case "banquet":

                break;

            case "speed":

                break;

            case "douse":

                break;

            case "care":

                break;

            case "weather":

                break;
            }
        }
Example #3
0
 internal static void Example2Clicked(
     IMenuComponent component,
     IComponentContainer container,
     FrameworkMenu menu)
 {
     ExampleList.Visible       = true;
     ExamplePopup.Visible      = false;
     ExamplePopupClose.Visible = false;
 }
        private static List<FrameworkMenu> GetAllMenus(List<FrameworkModule> allModule, ConstructorInfo constructorInfo)
        {
            var ConfigInfo = GlobalServices.GetService<Configs>();
            var menus = new List<FrameworkMenu>();

            if (ConfigInfo.IsQuickDebug)
            {
                menus = new List<FrameworkMenu>();
                foreach (var model in allModule)
                {
                    var modelmenu = new FrameworkMenu
                    {
                        //ID = Guid.NewGuid(),
                        PageName = model.ModuleName
                    };
                    menus.Add(modelmenu);
                    foreach (var action in model.Actions)
                    {
                        var url = string.Empty;
                        if (model.Area == null)
                        {
                            url = $"/{model.ClassName}/{action.MethodName}";
                        }
                        else
                        {
                            url = $"/{model.Area.Prefix}/{model.ClassName}/{action.MethodName}";
                        }
                        menus.Add(new FrameworkMenu
                        {
                            ID = Guid.NewGuid(),
                            ParentId = modelmenu.ID,
                            PageName = action.ActionName,
                            Url = url
                        });
                    }
                }
            }
            else
            {
                try
                {
                    using (var dc = (IDataContext)constructorInfo?.Invoke(new object[] { ConfigInfo.ConnectionStrings.Where(x => x.Key.ToLower() == "default").Select(x => x.Value).FirstOrDefault(), ConfigInfo.DbType }))
                    {
                        menus.AddRange(dc?.Set<FrameworkMenu>()
                                .Include(x => x.Domain)
                                .OrderBy(x => x.DisplayOrder)
                                .ToList());
                    }
                }
                catch { }
            }
            return menus;
        }
 private static void OnContractButton(IInteractiveMenuComponent component, IComponentContainer container,
                                      FrameworkMenu menu)
 {
     for (int i = 0; i < 8; i++)
     {
         if (Bg[i] == component)
         {
             OpenConfirmationMenu(AssociationHandler.Main.AvailableContracts[i]);
             AwaitingConfirmationPos = i;
             break;
         }
     }
 }
Example #6
0
        /// <summary>
        /// 框架必须的存储过程初始化
        /// </summary>
        /// <param name="con"></param>
        //private void SeedDataAndSP(DataContext con)
        //{
        //    string rootPath = AppDomain.CurrentDomain.BaseDirectory;

        //    IDataContext context = con as IDataContext;
        //    context = context.ReCreate();
        //    string sql = string.Empty;
        //    string fullPath = string.Empty;
        //    if (context.Database.Connection is System.Data.SqlClient.SqlConnection)
        //    {
        //        fullPath = rootPath + "SQLScripts\\MSSQL";
        //    }
        //    else if (context.Database.Connection is MySql.Data.MySqlClient.MySqlConnection)
        //    {
        //        fullPath = rootPath + "SQLScripts\\MySQL";
        //    }
        //    else
        //    {
        //        return;
        //    }

        //    if (Directory.Exists(fullPath))
        //    {
        //        List<string> fileList = null;
        //        fileList = Utils.GetAllFilePathRecursion(fullPath, fileList);

        //        foreach (var file in fileList)
        //        {
        //            if (file.ToLower().EndsWith(".sql"))
        //            {
        //                sql = Utils.ReadTxt(file);
        //                try
        //                {
        //                    context.Database.RunSql(sql);
        //                }
        //                catch { }
        //            }
        //        }
        //    }
        //}

        private FrameworkMenu GetFolderMenu(string FolderText, List <FrameworkRole> allowedRoles, List <FrameworkUser> allowedUsers, bool isShowOnMenu = true, bool isInherite = false)
        {
            FrameworkMenu menu = new FrameworkMenu
            {
                MLContents   = new List <FrameworkMenuMLContent>(),
                Children     = new List <FrameworkMenu>(),
                Privileges   = new List <FunctionPrivilege>(),
                ShowOnMenu   = isShowOnMenu,
                IsInherit    = isInherite,
                IsInside     = true,
                FolderOnly   = true,
                IsPublic     = false,
                CreateTime   = DateTime.Now,
                DisplayOrder = 1
            };

            string[] pair = FolderText.Split(';');

            foreach (var ml in pair)
            {
                string[] temp = ml.Split(',');
                if (temp.Length == 2)
                {
                    menu.MLContents.Add(new FrameworkMenuMLContent {
                        LanguageCode = temp[0], PageName = temp[1]
                    });
                }
            }

            if (allowedRoles != null)
            {
                foreach (var role in allowedRoles)
                {
                    menu.Privileges.Add(new FunctionPrivilege {
                        RoleID = role.ID, Allowed = true
                    });
                }
            }
            if (allowedUsers != null)
            {
                foreach (var user in allowedUsers)
                {
                    menu.Privileges.Add(new FunctionPrivilege {
                        UserID = user.ID, Allowed = true
                    });
                }
            }

            return(menu);
        }
        private static void OpenConfirmationMenu(Contract c)
        {
            AwaitingConfirmation = c;
            var menu    = new FrameworkMenu(new Point(185, 35), false);
            var text1   = new TextComponent(new Point(0, 0), "Delivery request: " + c.AmountNeeded + "x " + c.Item.Name);
            var text2   = new TextComponent(new Point(0, 7), "You cannot abandon a contract once you've accepted it.", true, 1F, Color.Red);
            var accept  = new ClickableTextureComponent(new Rectangle(140, 16, 12, 12), Game1.content.Load <Texture2D>("LooseSprites//Cursors").getArea(new Rectangle(128, 256, 64, 64)), OnAccept);
            var decline = new ClickableTextureComponent(new Rectangle(155, 16, 12, 12), Game1.content.Load <Texture2D>("LooseSprites//Cursors").getArea(new Rectangle(192, 256, 64, 64)), OnDecline);

            menu.AddComponent(text1);
            menu.AddComponent(text2);
            menu.AddComponent(accept);
            menu.AddComponent(decline);
            Game1.activeClickableMenu = menu;
        }
Example #8
0
        private static List <FrameworkMenu> GetAllMenus(List <FrameworkModule> allModule)
        {
            var ConfigInfo = GlobalServices.GetService <Configs>();
            var localizer  = GlobalServices.GetService <IStringLocalizer <WalkingTec.Mvvm.Core.Program> >();
            var menus      = new List <FrameworkMenu>();

            if (ConfigInfo.IsQuickDebug)
            {
                menus = new List <FrameworkMenu>();
                var areas = allModule.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").Select(x => x.Area?.AreaName).Distinct().ToList();
                foreach (var area in areas)
                {
                    var modelmenu = new FrameworkMenu
                    {
                        //ID = Guid.NewGuid(),
                        PageName = area ?? localizer["DefaultArea"]
                    };
                    menus.Add(modelmenu);
                    var pages = allModule.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api" && x.Area?.AreaName == area).SelectMany(x => x.Actions).Where(x => x.MethodName.ToLower() == "index").ToList();
                    foreach (var page in pages)
                    {
                        var url = page.Url;
                        menus.Add(new FrameworkMenu
                        {
                            ID       = Guid.NewGuid(),
                            ParentId = modelmenu.ID,
                            PageName = page.Module.ModuleName,
                            Url      = url
                        });
                    }
                }
            }
            else
            {
                try
                {
                    using (var dc = ConfigInfo.ConnectionStrings.Where(x => x.Key.ToLower() == "default").FirstOrDefault().CreateDC())
                    {
                        menus.AddRange(dc?.Set <FrameworkMenu>()
                                       .Include(x => x.Domain)
                                       .OrderBy(x => x.DisplayOrder)
                                       .ToList());
                    }
                }
                catch { }
            }
            return(menus);
        }
Example #9
0
        private static List <FrameworkMenu> GetAllMenus(List <FrameworkModule> allModule, ConstructorInfo constructorInfo)
        {
            var ConfigInfo = GlobalServices.GetService <Configs>();
            var menus      = new List <FrameworkMenu>();

            if (ConfigInfo.IsQuickDebug)
            {
                menus = new List <FrameworkMenu>();
                var areas = allModule.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").Select(x => x.Area?.AreaName).Distinct().ToList();
                foreach (var area in areas)
                {
                    var modelmenu = new FrameworkMenu
                    {
                        //ID = Guid.NewGuid(),
                        PageName = area ?? "默认区域"
                    };
                    menus.Add(modelmenu);
                    var pages = allModule.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api" && x.Area?.AreaName == area).SelectMany(x => x.Actions).Where(x => x.MethodName.ToLower() == "index").ToList();
                    foreach (var page in pages)
                    {
                        var url = page.Url;
                        menus.Add(new FrameworkMenu
                        {
                            ID       = Guid.NewGuid(),
                            ParentId = modelmenu.ID,
                            PageName = page.Module.ModuleName,
                            Url      = url
                        });
                    }
                }
            }
            else
            {
                try
                {
                    using (var dc = (IDataContext)constructorInfo?.Invoke(new object[] { ConfigInfo.ConnectionStrings.Where(x => x.Key.ToLower() == "default").Select(x => x.Value).FirstOrDefault(), ConfigInfo.DbType }))
                    {
                        menus.AddRange(dc?.Set <FrameworkMenu>()
                                       .Include(x => x.Domain)
                                       .OrderBy(x => x.DisplayOrder)
                                       .ToList());
                    }
                }
                catch { }
            }
            return(menus);
        }
        private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
        {
            if (e.KeyPressed.ToString() == "Y")
            {
                Menu = new FrameworkMenu(new Microsoft.Xna.Framework.Point(85, 5 * 11 + 22));
                Menu.AddComponent(new LabelComponent(new Microsoft.Xna.Framework.Point(-3, -16), "Choose destination"));
                clickables.Add(Menu.upperRightCloseButton);

                var r = new ButtonFormComponent(new Microsoft.Xna.Framework.Point(-1, 3 + 11 * 1), 65, "Hello", (t, p, m) => hmm()); //always *4
                var s = new ButtonFormComponent(new Microsoft.Xna.Framework.Point(-1, 3 + 11 * 2), 65, "Bye", (t, p, m) => bleh());  //always *4

                Menu.AddComponent(r);
                Menu.AddComponent(s);
                clickables2.Add(s, 65);
                clickables2.Add(r, 65);
                // clickables.Add(r);
            }
        }
Example #11
0
        private void ShowConfig(string command, string[] args)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }
            FrameworkMenu        Menu              = new FrameworkMenu(new Point(200, 40));
            TextComponent        label             = new TextComponent(new Point(0, 0), "Webhook URL:");
            TextboxFormComponent webhookUrlTextbox = new TextboxFormComponent(new Point(0, 8), 175, null);
            ButtonFormComponent  setButton         = new ButtonFormComponent(new Point(0, 21), "Set", (t, p, m) => this.SetWebhook(webhookUrlTextbox.Value, Game1.player.farmName));
            Texture2D            icon              = this.Helper.Content.Load <Texture2D>("assets/icon.png");
            TextureComponent     iconTexture       = new TextureComponent(new Rectangle(-16, -16, 16, 16), icon);

            Menu.AddComponent(label);
            Menu.AddComponent(webhookUrlTextbox);
            Menu.AddComponent(setButton);
            Menu.AddComponent(iconTexture);
            Game1.activeClickableMenu = Menu;
        }
Example #12
0
        private FrameworkMenu GetMenu(List <FrameworkModule> allModules, string areaName, string controllerName, string actionName, List <FrameworkRole> allowedRoles, List <FrameworkUser> allowedUsers, int displayOrder)
        {
            var           acts = allModules.Where(x => x.ClassName == controllerName && (areaName == null || x.Area.Prefix.ToLower() == areaName.ToLower())).SelectMany(x => x.Actions).ToList();
            var           act  = acts.Where(x => x.MethodName == actionName).SingleOrDefault();
            var           rest = acts.Where(x => x.MethodName != actionName).ToList();
            FrameworkMenu menu = GetMenuFromAction(act, true, allowedRoles, allowedUsers, displayOrder);

            if (menu != null)
            {
                for (int i = 0; i < rest.Count; i++)
                {
                    if (rest[i] != null)
                    {
                        menu.Children.Add(GetMenuFromAction(rest[i], false, allowedRoles, allowedUsers, (i + 1)));
                    }
                }
            }
            return(menu);
        }
        private static void OnAccept(IInteractiveMenuComponent component, IComponentContainer container,
                                     FrameworkMenu menu)
        {
            Menu.AddComponent(Crosses[AwaitingConfirmationPos]);
            AssociationHandler.Main.ActiveContracts.Add(AwaitingConfirmation);
            Bg[AwaitingConfirmationPos].Visible = false;
            AwaitingConfirmation    = null;
            AwaitingConfirmationPos = -1;
            BoardMainMenu.Init();

            if (AssociationHandler.Main.AvailableContracts.Count >= 5)
            {
                Game1.activeClickableMenu = BoardMainMenu.Menu;
            }
            else
            {
                Game1.activeClickableMenu = Menu;
            }
        }
Example #14
0
        public static void Init()
        {
            Menu = new FrameworkMenu(new Point(200, 140));
            int rank = AssociationHandler.Main.Rank;

            Menu.AddComponent(new ButtonFormComponent(new Point(0, 0), 80, "Shipment Eval", OnShipEvalButton));
            Menu.AddComponent(new ButtonFormComponent(new Point(100, 0), 80, "Blessing of Luck", OnLuckButton));

            Menu.AddComponent(new ButtonFormComponent(new Point(0, 20), 80, "Organize Banquet", OnBanquetButton));
            Menu.AddComponent(new ButtonFormComponent(new Point(100, 20), 80, "Speed Boost", OnSpeedButton));

            Menu.AddComponent(new ButtonFormComponent(new Point(0, 40), 80, "Dousing Plane", OnPlaneButton));
            Menu.AddComponent(new ButtonFormComponent(new Point(100, 40), 80, "Care Packages", OnCareButton));

            Menu.AddComponent(new ButtonFormComponent(new Point(0, 60), 80, "Weather Machine", OnWeatherButton));
            Menu.AddComponent(new ButtonFormComponent(new Point(100, 60), 80, "W.I.P.", OnWip1Button));

            Menu.AddComponent(new ButtonFormComponent(new Point(100, 80), 80, "W.I.P.", OnWip2Button));
        }
        /// <summary>
        ///     The draw loop for this component
        /// </summary>
        /// <param name="b">
        ///     The sprite batch to use
        /// </param>
        /// <param name="o">
        ///     The origin for this component
        /// </param>
        public override void Draw(SpriteBatch b, Point o)
        {
            if (!this.Visible)
            {
                return;
            }

            // Draw chrome
            FrameworkMenu.DrawMenuRect(
                b,
                o.X + this.Area.X - Zoom2,
                o.Y + this.Area.Y + Zoom15,
                this.Area.Width,
                this.Area.Height - Zoom15);

            // Draw tabs
            for (var c = 0; c < this.Tabs.Count; c++)
            {
                b.Draw(
                    Game1.mouseCursors,
                    new Rectangle(
                        o.X + this.Area.X + Zoom4 + c * Zoom16,
                        o.Y + this.Area.Y + (c == this.Current ? Zoom2 : 0),
                        Zoom16,
                        Zoom16),
                    Tab,
                    Color.White);
                b.Draw(
                    Game1.objectSpriteSheet,
                    new Rectangle(
                        o.X + this.Area.X + Zoom8 + c * Zoom16,
                        o.Y + this.Area.Y + Zoom5 + (c == this.Current ? Zoom2 : 0),
                        Zoom8,
                        Zoom8),
                    Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, this.Tabs[c].Icon, 16, 16),
                    Color.White);
            }

            // Draw body
            this.CurrentTab?.Draw(b, new Point(o.X + this.Area.X + Zoom5, o.Y + this.Area.Y + Zoom22));
        }
        public static void Init()
        {
            Menu.ClearComponents();
            Menu = new FrameworkMenu(new Point(200, 140));

            AddToMenu(ContractBg);
            AddToMenu(FavorStar);
            AddToMenu(HeaderText);
            AddToMenu(FavorText);
            AddToMenu(SeasonalContracts, 2);
            AddToMenu(YearlyContracts, 2);
            AddToMenu(Reputation);
            AddToMenu(RepAmount, 2);
            AddToMenu(RankDisplay);
            AddToMenu(FavorAmount);
            AddToMenu(ContractButton);
            AddToMenu(ShopButton);
            AddToMenu(HelpButton);

            //TODO yearly contracts
            AddToMenu(new TextComponent(new Point(35, 80), "W.I.P.", true, 4F), 3);

            if (AssociationHandler.Main == null)
            {
                return;
            }

            int i = 0;

            foreach (var contract in AssociationHandler.Main.ActiveContracts)
            {
                foreach (var component in CreateContractBlob(i, contract))
                {
                    AddToMenu(component, 3);
                }

                i++;
            }
        }
        private void checkForBusStop(object sender, EventArgs e)
        {
            if (Game1.player == null)
            {
                return;
            }
            if (Game1.player.currentLocation == null)
            {
                return;
            }
            if (Game1.player.currentLocation.name == "BusStop")
            {
                // Log.AsyncC("Step1");
                MouseState mState = Mouse.GetState();
                if (mState.LeftButton == ButtonState.Pressed)
                {
                    // Log.AsyncC("Step2");
                    // Log.AsyncC(getMouseTile());
                    if (getMouseTile().X == 7 && (getMouseTile().Y == 11 || getMouseTile().Y == 10))
                    {
                        //  Log.AsyncC("Step3");
                        Menu = new FrameworkMenu(new Microsoft.Xna.Framework.Point(85, 5 * 11 + 22));
                        Menu.AddComponent(new LabelComponent(new Microsoft.Xna.Framework.Point(-3, -16), "Choose destination"));
                        clickables.Add(Menu.upperRightCloseButton);

                        var r = new ButtonFormComponent(new Microsoft.Xna.Framework.Point(-1, 3 + 11 * 3), 65, "Sun Drop City", (t, p, m) => hmm());   //always *4
                        var s = new ButtonFormComponent(new Microsoft.Xna.Framework.Point(-1, 3 + 11 * 1), 65, "Pellican Town", (t, p, m) => bleh());  //always *4
                        var d = new ButtonFormComponent(new Microsoft.Xna.Framework.Point(-1, 3 + 11 * 2), 65, "Callico Desert", (t, p, m) => bleh()); //always *4
                        Menu.AddComponent(r);
                        Menu.AddComponent(s);
                        Menu.AddComponent(d);
                        clickables2.Add(s, 65);
                        clickables2.Add(r, 65);
                        clickables2.Add(d, 65);
                    }
                }
            }
        }
        public static void Init()
        {
            for (int i = 0; i < 8; i++)
            {
                if (i <= 3)
                {
                    Bg[i] = new ClickableTextureComponent(new Rectangle(44 * i, 30, 48, 48), Game1.content.Load <Texture2D>("LooseSprites//DialogBoxGreen"), OnContractButton);
                    var temp = new TextureComponent(new Rectangle(44 * i + 8, 30 + 8, 32, 32), Game1.content.Load <Texture2D>("LooseSprites//Cursors").getArea(new Rectangle(268, 470, 16, 16)));
                    temp.Layer = 3;
                    Crosses[i] = temp;
                }
                else
                {
                    Bg[i] = new ClickableTextureComponent(new Rectangle(44 * (i - 4), 75, 48, 48), Game1.content.Load <Texture2D>("LooseSprites//DialogBoxGreen"), OnContractButton);
                    var temp = new TextureComponent(new Rectangle(44 * (i - 4) + 8, 75 + 8, 32, 32), Game1.content.Load <Texture2D>("LooseSprites//Cursors").getArea(new Rectangle(268, 470, 16, 16)));
                    temp.Layer = 3;
                    Crosses[i] = temp;
                }
            }

            if (Menu != null)
            {
                Menu.ClearComponents();
            }
            Menu = new FrameworkMenu(new Point(200, 140), false);
            foreach (var bg in Bg)
            {
                Menu.AddComponent(bg);
            }
            Menu.AddComponent(HeaderText);
            Menu.AddComponent(DescText1);
            Menu.AddComponent(DescText2);
            Menu.AddComponent(DescText3);
            Menu.AddComponent(DescText4);
            Menu.AddComponent(BackButton);
        }
Example #19
0
 internal static void TextboxChanged(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu, string value)
 {
     Console.WriteLine("TextboxChanged: " + value);
 }
 private static void OnDecline(IInteractiveMenuComponent component, IComponentContainer container,
                               FrameworkMenu menu)
 {
     Game1.activeClickableMenu = Menu;
 }
 private static void ButtonClick(IInteractiveMenuComponent component, IComponentContainer container, FrameworkMenu menu)
 {
     //TODO DEBUG
     if (component == ContractButton && Game1.dayOfMonth < 60 && AssociationHandler.Main.ActiveContracts.Count < 5)
     {
         Game1.activeClickableMenu = BoardContractMenu.Menu;
     }
     else if (component == ShopButton)
     {
         Game1.activeClickableMenu = BoardShopMenu.Menu;
     }
     else if (component == HelpButton)
     {
         Game1.activeClickableMenu = BoardHelpMenu.Menu;
     }
 }
Example #22
0
        /*********
        ** Protected methods
        *********/
        private void OnDayStarted(object s, EventArgs e)
        {
            this.Monitor.Log("DayStarted event, preparing custom minecarts...", LogLevel.Trace);
            if (Context.IsMultiplayer)
            {
                this.Monitor.Log("Multiplayer game detected, you are using Extended Minecarts at your own risk!", LogLevel.Warn);
            }
            ModEntry.Destinations = new Dictionary <string, ButtonFormComponent>();
            foreach (KeyValuePair <string, string> item in ModEntry.DestinationData)
            {
                switch (item.Key)
                {
                case "Farm":
                    if (!this.Config.FarmDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Desert":
                    if (!this.Config.DesertDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Woods":
                    if (!this.Config.WoodsDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Beach":
                    if (!this.Config.BeachDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Forest":
                    if (!this.Config.WizardDestinationEnabled)
                    {
                        continue;
                    }
                    break;
                }

                ModEntry.Destinations.Add(item.Key, new ButtonFormComponent(new Point(-1, 3 + 11 * ModEntry.Destinations.Count), 65, item.Value, (t, p, m) => this.AnswerResolver(item.Key)));
            }

            ModEntry.Menu = new FrameworkMenu(new Point(85, ModEntry.Destinations.Count * 11 + 22));
            ModEntry.Menu.AddComponent(new LabelComponent(new Point(-3, -16), this.Helper.Translation.Get("choose-destination")));
            foreach (ButtonFormComponent c in ModEntry.Destinations.Values)
            {
                ModEntry.Menu.AddComponent(c);
            }
            Dictionary <string, string> Status = new Dictionary <string, string>()
            {
                ["Farm"]   = "Unknown",
                ["Desert"] = "Unknown",
                ["Woods"]  = "Unknown",
                ["Forest"] = "Unknown",
                ["Beach"]  = "Unknown"
            };

            // # Farm
            if (this.Config.FarmDestinationEnabled && !this.Config.UseCustomFarmDestination)
            {
                try
                {
                    GameLocation farm = Game1.getFarm();
                    if (!farm.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched"))
                    {
                        if (this.Config.AlternateFarmMinecart)
                        {
                            farm.SetTile(18, 5, "Front", 483, "untitled tile sheet");
                            farm.SetTile(19, 5, "Front", 484, "untitled tile sheet");
                            farm.SetTile(19, 5, "Buildings", 217, "untitled tile sheet");
                            farm.SetTile(20, 5, "Front", 485, "untitled tile sheet");

                            farm.SetTile(18, 6, "Buildings", 508, "untitled tile sheet");
                            farm.SetTile(19, 6, "Back", 509, "untitled tile sheet");
                            farm.SetTile(20, 6, "Buildings", 510, "untitled tile sheet");

                            farm.SetTile(18, 7, "Buildings", 533, "untitled tile sheet");
                            farm.SetTile(19, 7, "Back", 534, "untitled tile sheet");
                            farm.SetTile(20, 7, "Buildings", 535, "untitled tile sheet");

                            farm.SetTile(19, 6, "Buildings", 933, "untitled tile sheet");
                            farm.SetTile(19, 7, "Buildings", 958, "untitled tile sheet");
                            farm.SetTileProperty(19, 7, "Buildings", "Action", "MinecartTransport");
                        }
                        else
                        {
                            // Clear annoying flower
                            farm.removeTile(79, 12, "Buildings");
                            // Cut dark short
                            farm.SetTile(77, 11, "Back", 375, "untitled tile sheet");
                            farm.SetTile(78, 11, "Back", 376, "untitled tile sheet");
                            farm.SetTile(79, 11, "Back", 376, "untitled tile sheet");
                            // Lay tracks
                            farm.SetTile(78, 12, "Back", 729, "untitled tile sheet");
                            farm.SetTile(78, 13, "Back", 754, "untitled tile sheet");
                            farm.SetTile(78, 14, "Back", 755, "untitled tile sheet");
                            farm.SetTile(79, 12, "Back", 730, "untitled tile sheet");
                            // Trim grass
                            farm.SetTile(77, 13, "Back", 175, "untitled tile sheet");
                            farm.SetTile(77, 14, "Back", 175, "untitled tile sheet");
                            farm.SetTile(77, 15, "Back", 175, "untitled tile sheet");
                            farm.SetTile(78, 15, "Back", 175, "untitled tile sheet");
                            farm.SetTile(79, 13, "Back", 175, "untitled tile sheet");
                            farm.SetTile(79, 14, "Back", 175, "untitled tile sheet");
                            farm.SetTile(79, 15, "Back", 175, "untitled tile sheet");
                            // Clean up fence
                            farm.SetTile(78, 11, "Buildings", 436, "untitled tile sheet");
                            farm.removeTile(78, 14, "Buildings");
                            // Plop down minecart
                            farm.SetTile(78, 12, "Buildings", 933, "untitled tile sheet");
                            farm.SetTile(78, 13, "Buildings", 958, "untitled tile sheet");
                            farm.SetTileProperty(78, 13, "Buildings", "Action", "MinecartTransport");
                            // Keep exit clear
                            farm.setTileProperty(78, 14, "Back", "NoFurniture", "T");
                        }
                        Status["Farm"] = "Patched";
                        farm.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true);
                    }
                    else
                    {
                        Status["Farm"] = "Skipped";
                    }
                }
                catch (Exception err)
                {
                    this.Monitor.Log("Could not patch the Farm due to a unknown error", LogLevel.Error, err);
                }
            }
            else
            {
                Status["Farm"] = "Disabled";
            }
            if (this.Config.DesertDestinationEnabled)
            {
                try
                {
                    // # Desert
                    GameLocation desert = Game1.getLocationFromName("Desert");
                    if (!desert.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched"))
                    {
                        TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors");
                        desert.map.AddTileSheet(new TileSheet("z_path_objects_custom_sheet", desert.map, parent.ImageSource, parent.SheetSize, parent.TileSize));
                        desert.map.DisposeTileSheets(Game1.mapDisplayDevice);
                        desert.map.LoadTileSheets(Game1.mapDisplayDevice);
                        if (this.Config.AlternateDesertMinecart)
                        {
                            // Backdrop
                            desert.SetTile(33, 1, "Front", 221, "desert-new");
                            desert.SetTile(34, 1, "Front", 222, "desert-new");
                            desert.SetTile(35, 1, "Front", 223, "desert-new");

                            desert.SetTile(33, 2, "Front", 237, "desert-new");
                            desert.SetTile(34, 2, "Buildings", 254, "desert-new");
                            desert.SetTile(34, 2, "Front", 238, "desert-new");
                            desert.SetTile(35, 2, "Front", 239, "desert-new");

                            desert.SetTile(33, 3, "Buildings", 253, "desert-new");
                            desert.SetTile(34, 3, "Buildings", 254, "desert-new");
                            desert.SetTile(35, 3, "Buildings", 255, "desert-new");

                            desert.SetTile(33, 4, "Buildings", 269, "desert-new");
                            desert.SetTile(34, 4, "Back", 270, "desert-new");
                            desert.SetTile(35, 4, "Buildings", 271, "desert-new");
                            // Cart
                            desert.SetTile(34, 3, "Front", 933, "z_path_objects_custom_sheet");
                            desert.SetTile(34, 4, "Buildings", 958, "z_path_objects_custom_sheet");
                            desert.SetTileProperty(34, 4, "Buildings", "Action", "MinecartTransport");
                        }
                        else
                        {
                            // Backdrop
                            desert.SetTile(33, 39, "Front", 221, "desert-new");
                            desert.SetTile(34, 39, "Front", 222, "desert-new");
                            desert.SetTile(35, 39, "Front", 223, "desert-new");

                            desert.SetTile(33, 40, "Front", 237, "desert-new");
                            desert.SetTile(34, 40, "Buildings", 254, "desert-new");
                            desert.SetTile(34, 40, "Front", 238, "desert-new");
                            desert.SetTile(35, 40, "Front", 239, "desert-new");

                            desert.SetTile(33, 41, "Buildings", 253, "desert-new");
                            desert.SetTile(34, 41, "Buildings", 254, "desert-new");
                            desert.SetTile(35, 41, "Buildings", 255, "desert-new");

                            desert.SetTile(33, 42, "Buildings", 269, "desert-new");
                            desert.SetTile(34, 42, "Back", 270, "desert-new");
                            desert.SetTile(35, 42, "Buildings", 271, "desert-new");
                            // Cart
                            desert.SetTile(34, 41, "Front", 933, "z_path_objects_custom_sheet");
                            desert.SetTile(34, 42, "Buildings", 958, "z_path_objects_custom_sheet");
                            desert.SetTileProperty(34, 42, "Buildings", "Action", "MinecartTransport");
                        }
                        Status["Desert"] = "Patched";
                        desert.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true);
                    }
                    else
                    {
                        Status["Desert"] = "Skipped";
                    }
                }
                catch (Exception err)
                {
                    this.Monitor.Log("Could not patch the Desert due to a unknown error", LogLevel.Error, err);
                }
            }
            else
            {
                Status["Desert"] = "Disabled";
            }
            if (this.Config.WoodsDestinationEnabled)
            {
                try
                {
                    // # Woods
                    GameLocation woods = Game1.getLocationFromName("Woods");
                    if (!woods.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched"))
                    {
                        woods.SetTile(46, 3, "Front", 933, "untitled tile sheet");
                        woods.SetTile(46, 4, "Buildings", 958, "untitled tile sheet");
                        woods.SetTileProperty(46, 4, "Buildings", "Action", "MinecartTransport");
                        Status["Woods"] = "Patched";
                        woods.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true);
                    }
                    else
                    {
                        Status["Woods"] = "Skipped";
                    }
                }
                catch (Exception err)
                {
                    this.Monitor.Log("Could not patch the Woods due to a unknown error", LogLevel.Error, err);
                }
            }
            else
            {
                Status["Woods"] = "Disabled";
            }
            if (this.Config.WizardDestinationEnabled)
            {
                try
                {
                    // # Wizard
                    GameLocation forest = Game1.getLocationFromName("Forest");
                    if (!forest.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched"))
                    {
                        forest.SetTile(13, 37, "Front", 483, "outdoors");
                        forest.SetTile(14, 37, "Front", 484, "outdoors");
                        forest.SetTile(14, 37, "Buildings", 217, "outdoors");
                        forest.SetTile(15, 37, "Front", 485, "outdoors");

                        forest.SetTile(13, 38, "Buildings", 508, "outdoors");
                        forest.SetTile(14, 38, "Back", 509, "outdoors");
                        forest.SetTile(15, 38, "Buildings", 510, "outdoors");

                        forest.SetTile(13, 39, "Buildings", 533, "outdoors");
                        forest.SetTile(15, 39, "Buildings", 535, "outdoors");

                        forest.SetTile(14, 38, "Buildings", 933, "outdoors");
                        forest.SetTile(14, 39, "Buildings", 958, "outdoors");
                        forest.SetTileProperty(14, 39, "Buildings", "Action", "MinecartTransport");
                        Status["Forest"] = "Patched";
                        forest.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true);
                    }
                    else
                    {
                        Status["Forest"] = "Skipped";
                    }
                }
                catch (Exception err)
                {
                    this.Monitor.Log("Could not patch the Forest due to a unknown error", LogLevel.Error, err);
                }
            }
            else
            {
                Status["Forest"] = "Disabled";
            }
            if (this.Config.BeachDestinationEnabled)
            {
                try
                {
                    // # Beach
                    GameLocation beach = Game1.getLocationFromName("Beach");
                    if (!beach.map.Properties.ContainsKey("Entoarox.ExtendedMinecarts.Patched"))
                    {
                        TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors");
                        beach.map.AddTileSheet(new TileSheet("z_path_objects_custom_sheet", beach.map, parent.ImageSource, parent.SheetSize, parent.TileSize));
                        beach.map.DisposeTileSheets(Game1.mapDisplayDevice);
                        beach.map.LoadTileSheets(Game1.mapDisplayDevice);
                        beach.RemoveTile(67, 2, "Buildings");
                        beach.RemoveTile(67, 5, "Buildings");
                        beach.RemoveTile(67, 4, "Buildings");
                        beach.SetTile(67, 2, "Buildings", 933, "z_path_objects_custom_sheet");
                        beach.SetTile(67, 3, "Buildings", 958, "z_path_objects_custom_sheet");
                        beach.SetTileProperty(67, 3, "Buildings", "Action", "MinecartTransport");
                        Status["Beach"] = "Patched";
                        beach.map.Properties.Add("Entoarox.ExtendedMinecarts.Patched", true);
                    }
                    else
                    {
                        Status["Beach"] = "Skipped";
                    }
                }
                catch (Exception err)
                {
                    this.Monitor.Log("Could not patch the Beach due to a unknown error", LogLevel.Error, err);
                }
            }
            else
            {
                Status["Beach"] = "Disabled";
            }
            this.Monitor.Log("Minecart status: " + string.Join(", ", Status.Select(item => $"{item.Key} ({item.Value})")) + '.', LogLevel.Trace);
        }
Example #23
0
        private void GameEvents_UpdateTick(object s, EventArgs e)
        {
            if (!Game1.hasLoadedGame || Game1.CurrentEvent != null)
            {
                return;
            }
            GameEvents.UpdateTick  -= GameEvents_UpdateTick;
            MenuEvents.MenuChanged += MenuEvents_MenuChanged;
            Destinations            = new Dictionary <string, ButtonFormComponent>();
            foreach (KeyValuePair <string, string> item in DestinationData)
            {
                switch (item.Key)
                {
                case "Farm":
                    if (!Config.FarmDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Desert":
                    if (!Config.DesertDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Woods":
                    if (!Config.WoodsDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Beach":
                    if (!Config.BeachDestinationEnabled)
                    {
                        continue;
                    }
                    break;

                case "Forest":
                    if (!Config.WizardDestinationEnabled)
                    {
                        continue;
                    }
                    break;
                }
                Destinations.Add(item.Key, new ButtonFormComponent(new Microsoft.Xna.Framework.Point(-1, 3 + 11 * Destinations.Count), 65, item.Value, (t, p, m) => AnswerResolver(item.Key)));
            }
            Menu = new FrameworkMenu(new Microsoft.Xna.Framework.Point(85, Destinations.Count * 11 + 22));
            Menu.AddComponent(new LabelComponent(new Microsoft.Xna.Framework.Point(-3, -16), "Choose destination"));
            foreach (ButtonFormComponent c in Destinations.Values)
            {
                Menu.AddComponent(c);
            }
            // # Farm
            if (Config.FarmDestinationEnabled && !Config.UseCustomFarmDestination)
            {
                try
                {
                    GameLocation farm = Game1.getFarm();
                    if (Config.AlternateFarmMinecart)
                    {
                        farm.SetTile(18, 5, 483, "Front", "untitled tile sheet");
                        farm.SetTile(19, 5, 484, "Front", "untitled tile sheet");
                        farm.SetTile(19, 5, 217, "Buildings", "untitled tile sheet");
                        farm.SetTile(20, 5, 485, "Front", "untitled tile sheet");

                        farm.SetTile(18, 6, 508, "Buildings", "untitled tile sheet");
                        farm.SetTile(19, 6, 509, "Back", "untitled tile sheet");
                        farm.SetTile(20, 6, 510, "Buildings", "untitled tile sheet");

                        farm.SetTile(18, 7, 533, "Buildings", "untitled tile sheet");
                        farm.SetTile(19, 7, 534, "Back", "untitled tile sheet");
                        farm.SetTile(20, 7, 535, "Buildings", "untitled tile sheet");

                        farm.SetTile(19, 6, 933, "Buildings", "untitled tile sheet");
                        farm.SetTile(19, 7, 958, "Buildings", "MinecartTransport", "untitled tile sheet");
                    }
                    else
                    {
                        // Clear annoying flower
                        farm.removeTile(79, 12, "Buildings");
                        // Cut dark short
                        farm.SetTile(77, 11, 375, "Back", "untitled tile sheet");
                        farm.SetTile(78, 11, 376, "Back", "untitled tile sheet");
                        farm.SetTile(79, 11, 376, "Back", "untitled tile sheet");
                        // Lay tracks
                        farm.SetTile(78, 12, 729, "Back", "untitled tile sheet");
                        farm.SetTile(78, 13, 754, "Back", "untitled tile sheet");
                        farm.SetTile(78, 14, 755, "Back", "untitled tile sheet");
                        farm.SetTile(79, 12, 730, "Back", "untitled tile sheet");
                        // Trim grass
                        farm.SetTile(77, 13, 175, "Back", "untitled tile sheet");
                        farm.SetTile(77, 14, 175, "Back", "untitled tile sheet");
                        farm.SetTile(77, 15, 175, "Back", "untitled tile sheet");
                        farm.SetTile(78, 15, 175, "Back", "untitled tile sheet");
                        farm.SetTile(79, 13, 175, "Back", "untitled tile sheet");
                        farm.SetTile(79, 14, 175, "Back", "untitled tile sheet");
                        farm.SetTile(79, 15, 175, "Back", "untitled tile sheet");
                        // Clean up fence
                        farm.SetTile(78, 11, 436, "Buildings", "untitled tile sheet");
                        farm.removeTile(78, 14, "Buildings");
                        // Plop down minecart
                        farm.SetTile(78, 12, 933, "Buildings", "untitled tile sheet");
                        farm.SetTile(78, 13, 958, "Buildings", "MinecartTransport", "untitled tile sheet");
                        // Keep exit clear
                        farm.setTileProperty(78, 14, "Back", "NoFurniture", "T");
                    }
                }
                catch (Exception err)
                {
                    Monitor.Log(LogLevel.Error, "Could not patch the Farm due to a unknown error", err);
                }
            }
            if (Config.DesertDestinationEnabled)
            {
                try
                {
                    // # Desert
                    GameLocation          desert = Game1.getLocationFromName("Desert");
                    xTile.Tiles.TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors");
                    desert.map.AddTileSheet(new xTile.Tiles.TileSheet("z_path_objects_custom_sheet", desert.map, parent.ImageSource, parent.SheetSize, parent.TileSize));
                    desert.map.DisposeTileSheets(Game1.mapDisplayDevice);
                    desert.map.LoadTileSheets(Game1.mapDisplayDevice);
                    if (Config.AlternateDesertMinecart)
                    {
                        // Backdrop
                        desert.SetTile(33, 1, 221, "Front", "desert-new");
                        desert.SetTile(34, 1, 222, "Front", "desert-new");
                        desert.SetTile(35, 1, 223, "Front", "desert-new");

                        desert.SetTile(33, 2, 237, "Front", "desert-new");
                        desert.SetTile(34, 2, 254, "Buildings", "desert-new");
                        desert.SetTile(34, 2, 238, "Front", "desert-new");
                        desert.SetTile(35, 2, 239, "Front", "desert-new");

                        desert.SetTile(33, 3, 253, "Buildings", "desert-new");
                        desert.SetTile(34, 3, 254, "Buildings", "desert-new");
                        desert.SetTile(35, 3, 255, "Buildings", "desert-new");

                        desert.SetTile(33, 4, 269, "Buildings", "desert-new");
                        desert.SetTile(34, 4, 270, "Back", "desert-new");
                        desert.SetTile(35, 4, 271, "Buildings", "desert-new");
                        // Cart
                        desert.SetTile(34, 3, 933, "Front", "z_path_objects_custom_sheet");
                        desert.SetTile(34, 4, 958, "Buildings", "MinecartTransport", "z_path_objects_custom_sheet");
                    }
                    else
                    {
                        // Backdrop
                        desert.SetTile(33, 39, 221, "Front", "desert-new");
                        desert.SetTile(34, 39, 222, "Front", "desert-new");
                        desert.SetTile(35, 39, 223, "Front", "desert-new");

                        desert.SetTile(33, 40, 237, "Front", "desert-new");
                        desert.SetTile(34, 40, 254, "Buildings", "desert-new");
                        desert.SetTile(34, 40, 238, "Front", "desert-new");
                        desert.SetTile(35, 40, 239, "Front", "desert-new");

                        desert.SetTile(33, 41, 253, "Buildings", "desert-new");
                        desert.SetTile(34, 41, 254, "Buildings", "desert-new");
                        desert.SetTile(35, 41, 255, "Buildings", "desert-new");

                        desert.SetTile(33, 42, 269, "Buildings", "desert-new");
                        desert.SetTile(34, 42, 270, "Back", "desert-new");
                        desert.SetTile(35, 42, 271, "Buildings", "desert-new");
                        // Cart
                        desert.SetTile(34, 41, 933, "Front", "z_path_objects_custom_sheet");
                        desert.SetTile(34, 42, 958, "Buildings", "MinecartTransport", "z_path_objects_custom_sheet");
                    }
                }
                catch (Exception err)
                {
                    Monitor.Log(LogLevel.Error, "Could not patch the Desert due to a unknown error", err);
                }
            }
            if (Config.WoodsDestinationEnabled)
            {
                try
                {
                    // # Woods
                    GameLocation woods = Game1.getLocationFromName("Woods");
                    woods.SetTile(46, 3, 933, "Front", "untitled tile sheet");
                    woods.SetTile(46, 4, 958, "Buildings", "MinecartTransport", "untitled tile sheet");
                }
                catch (Exception err)
                {
                    Monitor.Log(LogLevel.Error, "Could not patch the Woods due to a unknown error", err);
                }
            }
            if (Config.WizardDestinationEnabled)
            {
                try
                {
                    // # Wizard
                    GameLocation forest = Game1.getLocationFromName("Forest");
                    forest.SetTile(13, 37, 483, "Front", "outdoors");
                    forest.SetTile(14, 37, 484, "Front", "outdoors");
                    forest.SetTile(14, 37, 217, "Buildings", "outdoors");
                    forest.SetTile(15, 37, 485, "Front", "outdoors");

                    forest.SetTile(13, 38, 508, "Buildings", "outdoors");
                    forest.SetTile(14, 38, 509, "Back", "outdoors");
                    forest.SetTile(15, 38, 510, "Buildings", "outdoors");

                    forest.SetTile(13, 39, 533, "Buildings", "outdoors");
                    forest.SetTile(15, 39, 535, "Buildings", "outdoors");

                    forest.SetTile(14, 38, 933, "Buildings", "outdoors");
                    forest.SetTile(14, 39, 958, "Buildings", "MinecartTransport", "outdoors");
                }
                catch (Exception err)
                {
                    Monitor.Log(LogLevel.Error, "Could not patch the Forest due to a unknown error", err);
                }
            }
            if (Config.BeachDestinationEnabled)
            {
                try
                {
                    // # Beach
                    GameLocation          beach  = Game1.getLocationFromName("Beach");
                    xTile.Tiles.TileSheet parent = Game1.getLocationFromName("Mountain").map.GetTileSheet("outdoors");
                    beach.map.AddTileSheet(new xTile.Tiles.TileSheet("z_path_objects_custom_sheet", beach.map, parent.ImageSource, parent.SheetSize, parent.TileSize));
                    beach.map.DisposeTileSheets(Game1.mapDisplayDevice);
                    beach.map.LoadTileSheets(Game1.mapDisplayDevice);
                    beach.removeTile(67, 2, "Buildings");
                    beach.removeTile(67, 5, "Buildings");
                    beach.removeTile(67, 4, "Buildings");
                    beach.SetTile(67, 2, 933, "Buildings", "z_path_objects_custom_sheet");
                    beach.SetTile(67, 3, 958, "Buildings", "MinecartTransport", "z_path_objects_custom_sheet");
                }
                catch (Exception err)
                {
                    Monitor.Log(LogLevel.Error, "Could not patch the Beach due to a unknown error", err);
                }
            }
        }
Example #24
0
        private FrameworkMenu GetMenuFromAction(FrameworkAction act, bool isMainLink, List <FrameworkRole> allowedRoles, List <FrameworkUser> allowedUsers, int displayOrder = 1)
        {
            if (act == null)
            {
                return(null);
            }
            FrameworkMenu menu = new FrameworkMenu
            {
                ActionID     = act.ID,
                ModuleID     = act.ModuleID,
                Url          = "/" + act.Module.ClassName + "/" + act.MethodName,
                Privileges   = new List <FunctionPrivilege>(),
                ShowOnMenu   = isMainLink,
                FolderOnly   = false,
                MLContents   = new List <FrameworkMenuMLContent>(),
                Children     = new List <FrameworkMenu>(),
                IsInherit    = true,
                IsPublic     = false,
                IsInside     = true,
                DisplayOrder = displayOrder,
                CreateTime   = DateTime.Now
            };

            if (act.Module.Area != null)
            {
                menu.Url = "/" + act.Module.Area.Prefix + menu.Url;
            }
            if (isMainLink)
            {
                foreach (var ml in act.Module.MLContents)
                {
                    menu.MLContents.Add(new FrameworkMenuMLContent {
                        LanguageCode = ml.LanguageCode, PageName = ml.ModuleName, ModuleName = ml.ModuleName, ActionName = act.MLContents.Where(x => x.LanguageCode == ml.LanguageCode).Select(x => x.ActionName).FirstOrDefault()
                    });
                }
            }
            else
            {
                foreach (var ml in act.MLContents)
                {
                    menu.MLContents.Add(new FrameworkMenuMLContent {
                        LanguageCode = ml.LanguageCode, PageName = ml.ActionName, ActionName = ml.ActionName, ModuleName = act.Module.MLContents.Where(x => x.LanguageCode == ml.LanguageCode).Select(x => x.ModuleName).FirstOrDefault()
                    });
                }
            }
            if (allowedRoles != null)
            {
                foreach (var role in allowedRoles)
                {
                    menu.Privileges.Add(new FunctionPrivilege {
                        RoleID = role.ID, Allowed = true
                    });
                }
            }
            if (allowedUsers != null)
            {
                foreach (var user in allowedUsers)
                {
                    menu.Privileges.Add(new FunctionPrivilege {
                        UserID = user.ID, Allowed = true
                    });
                }
            }
            return(menu);
        }
Example #25
0
        protected override void Seed(DataContext con)
        {
            IDataContext context = con as IDataContext;

            context = context.ReCreate();
            if (context.Set <FrameworkUser>().ToList().Count() > 0)
            {
                return;
            }
            try
            {
                context = context.ReCreate();
                for (int i = 0; i < 1000; i++)
                {
                    context.Set <EncHash>().Add(new EncHash {
                        Key = Guid.NewGuid(), Hash = i
                    });
                }
                context.SaveChanges();

                #region 模块初始化
                context = context.ReCreate();
                foreach (var module in AllModules)
                {
                    module.CreateTime = DateTime.Now;
                    context.Set <FrameworkModule>().Add(module);
                }
                context.SaveChanges();

                #endregion

                #region 角色初始化

                context = context.ReCreate();
                FrameworkRole adminRole = new FrameworkRole
                {
                    RoleCode   = "000001",
                    CreateTime = DateTime.Now,
                    MLContents = new List <FrameworkRoleMLContent>
                    {
                        new FrameworkRoleMLContent {
                            LanguageCode = "zh-cn", RoleName = "管理员"
                        },
                        new FrameworkRoleMLContent {
                            LanguageCode = "en", RoleName = "Administrator"
                        }
                    }
                };

                context.Set <FrameworkRole>().Add(adminRole);
                context.SaveChanges();

                #endregion

                #region 用户初始化

                context = context.ReCreate();
                context.Set <FrameworkRole>().Attach(adminRole);
                FrameworkUser adminUser = new FrameworkUser
                {
                    ITCode        = "admin",
                    Password      = "******",
                    StartWorkDate = DateTime.Now,
                    Roles         = new List <FrameworkRole>(new FrameworkRole[] { adminRole }),
                    Name          = "Admin",
                    CreateTime    = DateTime.Now,
                    IsValid       = true
                };
                context.Set <FrameworkUser>().Add(adminUser);
                context.SaveChanges();
                #endregion

                #region 菜单初始化

                context = context.ReCreate();
                context.Set <FrameworkRole>().Attach(adminRole);

                #region 系统管理

                FrameworkMenu systemManagement = GetFolderMenu("zh-cn,系统管理;en,System Management", new List <FrameworkRole> {
                    adminRole
                }, null);

                FrameworkMenu logList = GetMenu(AllModules, "Admin", "ActionLog", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 1);
                FrameworkMenu companyList = GetMenu(AllModules, null, "FrameworkCompany", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 2);
                FrameworkMenu departmentList = GetMenu(AllModules, null, "FrameworkDepartment", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 3);
                FrameworkMenu roleList = GetMenu(AllModules, "Admin", "FrameworkRole", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 4);
                FrameworkMenu userList = GetMenu(AllModules, null, "FrameworkUser", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 5);
                FrameworkMenu menuList = GetMenu(AllModules, "Admin", "FrameworkMenu", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 6);
                FrameworkMenu dpList = GetMenu(AllModules, "Admin", "DataPrivilege", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 7);
                FrameworkMenu domainList = GetMenu(AllModules, "Admin", "FrameworkDomain", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 8);
                FrameworkMenu emailLogList = GetMenu(AllModules, "Admin", "EmailLog", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 9);
                FrameworkMenu emailTemplateList = GetMenu(AllModules, "Admin", "EmailTemplate", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 10);
                FrameworkMenu noticeList = GetMenu(AllModules, "Admin", "FrameworkNotice", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 11);
                FrameworkMenu monitorList = GetMenu(AllModules, "Admin", "FrameworkServiceMonitor", "Index", new List <FrameworkRole> {
                    adminRole
                }, null, 12);
                //添加HomeController下的通用方法,主要是一些导出的通用函数
                var ExportActs = AllModules.Where(x => x.ClassName == "Home" && x.Area != null && x.Area.Prefix.ToLower() == "webapi").SelectMany(x => x.Actions).ToList();
                foreach (var exp in ExportActs)
                {
                    context.Set <FrameworkMenu>().Add(GetMenuFromAction(exp, false, new List <FrameworkRole> {
                        adminRole
                    }, null));
                }

                List <FrameworkMenu> ToAdd = new List <FrameworkMenu>
                {
                    logList, companyList, departmentList, roleList, userList, menuList, dpList, domainList, emailLogList, emailTemplateList, noticeList, monitorList
                };

                foreach (var item in ToAdd)
                {
                    if (item != null)
                    {
                        systemManagement.Children.Add(item);
                    }
                }

                #endregion

                context.Set <FrameworkMenu>().Add(systemManagement);
                context.SaveChanges();

                #endregion

                #region 数据权限初始化
                //context = context.ReCreate();
                //context.DataPrivileges.Add(
                //    new DataPrivilege
                //    {
                //        TableName = "FrameworkCompany",
                //        User = adminUser,
                //        CreateTime = DateTime.Now
                //    }
                //    );
                //context.Set<DataPrivilege>().Add(
                //    new DataPrivilege
                //    {
                //        TableName = "FrameworkDepartment",
                //        UserID = adminUser.ID,
                //        CreateTime = DateTime.Now
                //    }
                //    );
                //context.SaveChanges();
                #endregion

                #region 框架必须的存储过程初始化

                //SeedDataAndSP(con);

                #endregion
            }
            catch (Exception)
            {
            }
        }
        private void checkForClosure(object sender, EventArgs e)
        {
            if (Menu != null)
            {
                MouseState mState = Mouse.GetState();
                if (mState.LeftButton == ButtonState.Pressed)
                {
                    Point p = new Point();
                    p.X = Game1.getMouseX();
                    p.Y = Game1.getMouseY();


                    if (Menu.upperRightCloseButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
                    {
                        Game1.player.CanMove = true;
                        Menu.exitThisMenu();

                        if (Menu != null)
                        {
                            Menu = null;
                        }
                        return;
                    }

                    foreach (KeyValuePair <ButtonFormComponent, int> v in clickables2)
                    {
                        /*
                         * Log.AsyncC("THIS POINT" + v.Key.GetPosition());
                         * foreach(var q in Menu.InteractiveComponents)
                         * {
                         * Log.AsyncG( q.GetPosition());
                         *
                         * }
                         *
                         * Log.AsyncC("This Mouse" + p);
                         * Log.AsyncC("This Menu Area "+Menu.Area);
                         * Log.AsyncC("This Event Region" + Menu.EventRegion);
                         * Log.AsyncC("This Thing X" + Menu.xPositionOnScreen);
                         * Log.AsyncC("This Thing Y" + Menu.yPositionOnScreen);
                         * Log.AsyncC("This menu width" + Menu.width);
                         */
                        bool b = v.Key.InBounds(p, new Point(0, 0));
                        bool f = isWithinComponentBounds(getMenuMousePoint(), v.Key);
                        //  Log.AsyncC("THIS IS B" + b);
                        //   Log.AsyncG(f);


                        if (f == true)
                        {
                            (v.Key as ButtonFormComponent).LeftClick(new Point(Game1.getMouseX(), Game1.getMouseY()), new Point(0, 0));
                        }

                        //  Menu.getLastClickableComponentInThisListThatContainsThisYCoord(Menu.InteractiveComponents, getMenuMousePoint().Y);
                    }
                }
            }
            else
            {
                return;
            }
        }
Example #27
0
 internal static void CheckboxChanged(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu, bool value)
 {
     Console.WriteLine("CheckBoxChanged: " + (value ? "true" : "false"));
 }
Example #28
0
        internal static void GameEvents_UpdateTick(object s, EventArgs e)
        {
            if (!Farmhand.API.Game.HasLoadedGame || Farmhand.API.Game.CurrentEvent != null)
            {
                return;
            }

            GameEvents.OnAfterUpdateTick -= GameEvents_UpdateTick;
            GameEvents.OnHalfSecondTick  += GameEvents_HalfSecondTick;
            Menu = new FrameworkMenu(new Point(256, 168));
            TablistComponent           tablist = new TablistComponent(new Rectangle(0, 0, Menu.ZoomEventRegion.Width, Menu.ZoomEventRegion.Height));
            Rectangle                  size    = tablist.ZoomEventRegion;
            GenericCollectionComponent page1A  =
                new GenericCollectionComponent(new Rectangle(0, 0, size.Width, size.Height));

            Page1B = new FormCollectionComponent(new Rectangle(0, 0, size.Width / 2, size.Height));
            GenericCollectionComponent page2 =
                new GenericCollectionComponent(new Rectangle(0, 0, size.Width, size.Height));
            GenericCollectionComponent page3 = new ScrollableCollectionComponent(new Rectangle(0, 0, size.Width, size.Height));

            Menu.AddComponent(tablist);

            tablist.AddTab(2, page1A);
            tablist.AddTab(4, page2);
            tablist.AddTab(6, page3);

            page1A.AddComponent(Page1B);
            page1A.AddComponent(
                new ButtonFormComponent(
                    new Point(size.Width / 2, 0),
                    "Toggle Enabled",
                    (t, c, m) =>
            {
                Page1B.Disabled = !Page1B.Disabled;
                Console.WriteLine("Form state changed: " + (Page1B.Disabled ? "Disabled" : "Enabled"));
            }));

            Page1B.AddComponent(new LabelComponent(new Point(0, -38), "Form Components"));
            Page1B.AddComponent(new CheckboxFormComponent(new Point(0, 2), "Example Checkbox", CheckboxChanged));
            Page1B.AddComponent(new PlusMinusFormComponent(new Point(0, 12), 0, 100, PlusMinusChanged));
            Page1B.AddComponent(new SliderFormComponent(new Point(0, 22), 3, IntSliderChanged));
            Page1B.AddComponent(new SliderFormComponent(new Point(0, 32), 12, IntSliderChanged));
            Page1B.AddComponent(new SliderFormComponent(new Point(0, 42), 20, IntSliderChanged));
            Page1B.AddComponent(
                new DropdownFormComponent(
                    new Point(0, 51),
                    new List <string>()
            {
                "First", "Second", "Third", "Fourth"
            },
                    DropdownChanged));
            Page1B.AddComponent(
                new DropdownFormComponent(
                    new Point(0, 65),
                    new List <string>()
            {
                "#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9", "#10", "#11", "#12"
            },
                    DropdownChanged));
            Page1B.AddComponent(new ButtonFormComponent(new Point(0, 78), "Test Button", ButtonClicked));
            Page1B.AddComponent(new TextboxFormComponent(new Point(0, 90), TextboxChanged));
            Page1B.AddComponent(new TextboxFormComponent(new Point(0, 105), TextboxChanged));

            page2.AddComponent(new LabelComponent(new Point(0, -38), "Generic Components"));
            page2.AddComponent(new HeartsComponent(new Point(0, 0), 3, 10));
            page2.AddComponent(new ClickableHeartsComponent(new Point(0, 10), 8, 10, HeartsChanged));
            page2.AddComponent(Prog);
            page2.AddComponent(new TextureComponent(new Rectangle(0, 30, 16, 16), Game1.objectSpriteSheet, new Rectangle(0, 0, 16, 16)));
            page2.AddComponent(new ClickableTextureComponent(new Rectangle(20, 30, 16, 16), Game1.objectSpriteSheet, ButtonClicked, new Rectangle(0, 0, 16, 16)));
            page2.AddComponent(
                new ClickableTextureComponent(
                    new Rectangle(40, 30, 16, 16),
                    Game1.objectSpriteSheet,
                    ButtonClicked,
                    new Rectangle(0, 0, 16, 16),
                    false));
            page2.AddComponent(new TextComponent(new Point(0, 50), "Static text component"));
            page2.AddComponent(new ClickableTextComponent(new Point(0, 60), "Clickable text component", ButtonClicked));
            page2.AddComponent(new ClickableTextComponent(new Point(0, 70), "Clickable text component", ButtonClicked, false));

            for (var c = 0; c < 41; c++)
            {
                page3.AddComponent(new HeartsComponent(new Point(0, 10 * c), c, 40));
            }

            Example = new FrameworkMenu(new Point(256, 128), false);

            ExampleList = new GenericCollectionComponent(new Rectangle(0, 0, Example.ZoomEventRegion.Width, Example.ZoomEventRegion.Height));
            Example.AddComponent(ExampleList);

            Rectangle r = new Rectangle(0, 0, Example.ZoomEventRegion.Width, 32);

            ExampleList.AddComponent(new FrameComponent(r, Game1.mouseCursors, new Rectangle(384, 396, 15, 15)));
            ExampleList.AddComponent(new ClickableTextureComponent(r, Game1.mouseCursors, ExampleClicked, new Rectangle(383, 395, 1, 1), false));

            ExamplePopup =
                new TablistComponent(
                    new Rectangle(0, -10, Example.ZoomEventRegion.Width, Example.ZoomEventRegion.Height + 10));
            Example.AddComponent(ExamplePopup);
            ExamplePopup.Visible = false;

            ExamplePopupClose = new ClickableTextureComponent(new Rectangle(ExamplePopup.ZoomEventRegion.Width, -11, 12, 12), Game1.mouseCursors, Example2Clicked, new Rectangle(337, 494, 12, 12));
            Example.AddComponent(ExamplePopupClose);
            ExamplePopupClose.Visible = false;

            GenericCollectionComponent tab1 = new GenericCollectionComponent(ExamplePopup.ZoomEventRegion);
            GenericCollectionComponent tab2 = new GenericCollectionComponent(ExamplePopup.ZoomEventRegion);

            ExamplePopup.AddTab(102, tab1);
            ExamplePopup.AddTab(112, tab2);

            tab1.AddComponent(new TextComponent(new Point(0, 0), "Example Mod, by Example User", true, 1.5f, Color.Black));
            tab1.AddComponent(new TextComponent(new Point(0, 20), "Example Description for the Example Mod by Example User"));

            tab2.AddComponent(new TextComponent(new Point(0, 0), "Normally the mod-specific config elements would show here"));
        }
Example #29
0
 internal static void ButtonClicked(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu)
 {
     Console.WriteLine("ButtonClicked");
 }
Example #30
0
 internal static void HeartsChanged(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu, int value)
 {
     Console.WriteLine("HeartsChanged: " + value.ToString());
 }