Ejemplo n.º 1
0
        public static IFunction GetFunction(this AllActions actionType)
        {
            var types    = Assembly.GetExecutingAssembly().GetTypes().Single(x => x.GetCustomAttribute <ActionTypeAttribute>()?.ActionType == actionType);
            var instance = Activator.CreateInstance(types) as IFunction;

            return(instance);
        }
Ejemplo n.º 2
0
        public Func <double, double> GetOperationWithMemory(AllActions actionType)
        {
            if (!_operationsWithMemory.ContainsKey(actionType))
            {
                throw new InvalidOperationException($"Словарь операций не содержит такого ключа {actionType}");
            }

            return(_operationsWithMemory[actionType]);
        }
Ejemplo n.º 3
0
        public static void Invoke <T>(WindowState state) where T : TimelineAction
        {
            var action = AllActions.FirstOrDefault(x => x.GetType() == typeof(T));

            if (action != null && action.CanExecute(state))
            {
                action.Execute(state);
            }
        }
Ejemplo n.º 4
0
        protected override void InitVM()
        {
            if (!string.IsNullOrEmpty(Entity.Icon))
            {
                var res = Entity.Icon.Split(' ');
                IconFont     = res[0];
                IconFontItem = res[1];
            }

            SelectedRolesIds.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleCode != null && x.Allowed == true).Select(x => x.ID).ToList());

            var data    = DC.Set <FrameworkMenu>().AsNoTracking().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = data.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            foreach (var p in AllParents)
            {
                if (p.Text.StartsWith("MenuKey."))
                {
                    p.Text = Localizer[p.Text];
                }
            }

            var modules = Wtm.GlobaInfo.AllModule;

            var toRemove = new List <SimpleModule>();

            foreach (var item in modules)
            {
                if (item.IgnorePrivillege)
                {
                    toRemove.Add(item);
                }
            }
            var m = modules.ToList();

            toRemove.ForEach(x => m.Remove(x));
            AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName);
            if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true))
            {
                if (string.IsNullOrEmpty(SelectedModule))
                {
                    SelectedModule = modules.Where(x => (x.FullName == Entity.ClassName)).FirstOrDefault()?.FullName;
                }
                var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions = mm.ToListItems(y => y.ActionName, y => y.Url);
                if (SelectedActionIDs == null)
                {
                    SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
                }
            }
        }
Ejemplo n.º 5
0
        protected override void InitVM()
        {
            if (!string.IsNullOrEmpty(Entity.ICon))
            {
                var res = Entity.ICon.Split(' ');
                IconFont     = res[0];
                IconFontItem = res[1];
            }
            IConSelectItems = !string.IsNullOrEmpty(IconFont) && IconFontsHelper
                              .IconFontDicItems
                              .ContainsKey(IconFont)
                                ? IconFontsHelper
                              .IconFontDicItems[IconFont]
                              .Select(x => new ComboSelectListItem()
            {
                Text  = x.Text,
                Value = x.Value,
                ICon  = x.ICon
            }).ToList()
                                : new List <ComboSelectListItem>();

            SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList());

            var data    = DC.Set <FrameworkMenu>().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule;

            var m = modules.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").ToList();
            List <FrameworkModule> toremove = new List <FrameworkModule>();

            foreach (var item in m)
            {
                var f = modules.Where(x => x.ClassName == item.ClassName && x.Area?.AreaName == item.Area?.AreaName).FirstOrDefault();
                if (f?.IgnorePrivillege == true)
                {
                    toremove.Add(item);
                }
            }
            toremove.ForEach(x => m.Remove(x));
            AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName);
            if (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true)
            {
                SelectedModule = modules.Where(x => x.IsApi == false && (x.ClassName == Entity.ClassName || x.FullName == Entity.ClassName)).SelectMany(x => x.Actions).FirstOrDefault().Module.FullName;
                var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions        = mm.ToListItems(y => y.ActionName, y => y.Url);
                SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Add a method to be run at the given time. ActionInfo is constructed, set and passed as an argument to the method
        /// </summary>
        /// <param name="method">Action to be executed</param>
        /// <param name="startTime">When to execute the action</param>
        /// <param name="endTime">Keep running the action until this time, default is 0 which means always just run this once</param>
        public void AddMethod(Action <ActionInfo> method, float startTime, float endTime = 0f)
        {
            CinematicAction ca = new CinematicAction()
            {
                Type      = ACTION_TYPE.DELEGATE,
                method    = method,
                startTime = startTime,
                endTime   = endTime
            };

            AllActions.Add(ca);
            if (CurrentTime <= startTime)
            {
                RemainingActions.Add(ca);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Make an action for this CinematicAnimation at the given time.
        /// </summary>
        /// <param name="type">What kind of action is this?</param>
        /// <param name="target">The TransformComponent to act on</param>
        /// <param name="endArgument">Primary argument for the action, like Vector3 for SET_POSITION</param>
        /// <param name="startTime">What time to do this action?</param>
        /// <param name="startArgument">Where should this action start from? null if use whatever we are currently at</param>
        /// <param name="endTime">When to end this action?</param>
        public void AddAction(ACTION_TYPE type, TransformComponent target, object endArgument, float startTime, object startArgument = null, float endTime = 0f)
        {
            CinematicAction ca = new CinematicAction()
            {
                Type                  = type,
                target                = target,
                argument0             = startArgument,
                argument1             = endArgument,
                startTime             = startTime,
                endTime               = endTime,
                relativeStartArgument = startArgument == null
            };

            AllActions.Add(ca);
            if (CurrentTime <= startTime)
            {
                RemainingActions.Add(ca);
            }
        }
Ejemplo n.º 8
0
        protected override void InitVM()
        {
            SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList());

            var data    = DC.Set <FrameworkMenu>().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule;

            if (ControllerName.Contains("WalkingTec.Mvvm.Mvc.Admin.Controllers"))
            {
                var m = modules.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").ToList();
                List <FrameworkModule> toremove = new List <FrameworkModule>();
                foreach (var item in m)
                {
                    var f = modules.Where(x => x.ClassName == item.ClassName && x.Area?.AreaName == item.Area?.AreaName).FirstOrDefault();
                    if (f?.IgnorePrivillege == true)
                    {
                        toremove.Add(item);
                    }
                }
                toremove.ForEach(x => m.Remove(x));
                AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName);
            }
            if (Entity.Url != null)
            {
                if (ControllerName.Contains("WalkingTec.Mvvm.Mvc.Admin.Controllers"))
                {
                    SelectedModule = modules.Where(x => x.IsApi == false).SelectMany(x => x.Actions).Where(x => x.Url == Entity.Url).FirstOrDefault().Module.FullName;
                }
                else
                {
                    SelectedModule = modules.Where(x => x.IsApi == true).SelectMany(x => x.Actions).Where(x => x.Url == Entity.Url).FirstOrDefault().Module.FullName;
                }
                var m = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions        = m.ToListItems(y => y.ActionName, y => y.Url);
                SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void SaveFighterAnimationFile()
        {
            // rendering files not loaded
            if (string.IsNullOrEmpty(AJFilePath))
            {
                return;
            }

            // collect used symbols from all actions
            var usedSymbols = AllActions.Select(e => e.Symbol).ToArray();

            // generate new aj file
            var newAJFile = AJManager.RebuildAJFile(usedSymbols, false);

            // update animation offset and sizes
            foreach (var a in AllActions)
            {
                // don't write subroutines
                if (a.Subroutine)
                {
                    continue;
                }

                // update animation size and offset
                if (!string.IsNullOrEmpty(a.Symbol))
                {
                    var offsize = AJManager.GetOffsetSize(a.Symbol);
                    a.AnimOffset = offsize.Item1;
                    a.AnimSize   = offsize.Item2;
                }
            }

            // save action changes to dat file
            SaveAllActionChanges();

            // dump to file
            File.WriteAllBytes(AJFilePath, newAJFile);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        private void SaveFighterAnimationFile()
        {
            // rendering files not loaded
            if (string.IsNullOrEmpty(AJFilePath))
            {
                return;
            }

            // make sure okay to overwrite
            if (MessageBox.Show($"Is it okay to overwrite {AJFilePath}?", "Save Animation File Changes?", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
            {
                return;
            }

            // collect used symbols from all actions
            var usedSymbols = AllActions.Select(e => e.Symbol);

            // generate new aj file
            Dictionary <string, Tuple <int, int> > animOffsets = new Dictionary <string, Tuple <int, int> >();

            using (MemoryStream ajBuffer = new MemoryStream())
                using (BinaryWriterExt w = new BinaryWriterExt(ajBuffer))
                {
                    // collect used symbols
                    foreach (var sym in usedSymbols)
                    {
                        if (sym != null)
                        {
                            if (SymbolToAnimation.ContainsKey(sym) && !animOffsets.ContainsKey(sym))
                            {
                                // write animation
                                var anim = SymbolToAnimation[sym];
                                animOffsets.Add(sym, new Tuple <int, int>((int)ajBuffer.Position, anim.Length));
                                w.Write(anim);
                                w.Align(0x20, 0xFF);
                            }
                            else
                            if (!animOffsets.ContainsKey(sym))
                            {
                                // animation not found
                                MessageBox.Show($"\"{sym}\" animation not found", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                animOffsets.Add(sym, new Tuple <int, int>(0, 0));
                            }
                        }
                    }

                    // dump to file
                    File.WriteAllBytes(AJFilePath, ajBuffer.ToArray());
                }


            int index = 0;

            foreach (var a in AllActions)
            {
                // don't write subroutines
                if (a.Subroutine)
                {
                    continue;
                }

                // get embedded script
                var ftcmd = new SBM_FighterCommand();
                ftcmd._s = _node.Accessor._s.GetEmbeddedStruct(0x18 * index, ftcmd.TrimmedSize);

                // update symbol name
                ftcmd.Name = a.Symbol;

                if (a.Symbol == null)
                {
                    continue;
                }

                // offset
                var ofst = animOffsets[a.Symbol];

                // update action offset and size
                a.AnimOffset = ofst.Item1;
                a.AnimSize   = ofst.Item2;

                // update file offset and size
                ftcmd.AnimationOffset = a.AnimOffset;
                ftcmd.AnimationSize   = a.AnimSize;

                // resize if needed
                if (_node.Accessor._s.Length <= 0x18 * index + 0x18)
                {
                    _node.Accessor._s.Resize(0x18 * index + 0x18);
                }

                // update script
                _node.Accessor._s.SetEmbededStruct(0x18 * index, ftcmd._s);
                index++;
            }

            MainForm.Instance.SaveDAT();
        }
Ejemplo n.º 11
0
        protected override void InitVM()
        {
            if (!string.IsNullOrEmpty(Entity.ICon))
            {
                var res = Entity.ICon.Split(' ');
                IconFont     = res[0];
                IconFontItem = res[1];
            }
            IConSelectItems = !string.IsNullOrEmpty(IconFont) && IconFontsHelper
                              .IconFontDicItems
                              .ContainsKey(IconFont)
                                ? IconFontsHelper
                              .IconFontDicItems[IconFont]
                              .Select(x => new ComboSelectListItem()
            {
                Text  = x.Text,
                Value = x.Value,
                ICon  = x.ICon
            }).ToList()
                                : new List <ComboSelectListItem>();

            SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList());

            var data    = DC.Set <FrameworkMenu>().AsNoTracking().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = data.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            foreach (var p in AllParents)
            {
                if (p.Text.StartsWith("MenuKey."))
                {
                    if (Localizer[p.Text].ResourceNotFound == true)
                    {
                        p.Text = Core.Program._localizer[p.Text];
                    }
                    else
                    {
                        p.Text = Localizer[p.Text];
                    }
                }
            }

            var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule;

            var toRemove = new List <FrameworkModule>();

            foreach (var item in modules)
            {
                if (item.IgnorePrivillege)
                {
                    toRemove.Add(item);
                }
                else
                {
                    if (!item.IsApi)
                    {
                        continue;
                    }
                    if (item.NameSpace == "WalkingTec.Mvvm.Admin.Api")
                    {
                        if (!item.ModuleName.EndsWith($"({Program._localizer["BuildinApi"]})"))
                        {
                            item.ModuleName += $"({Program._localizer["BuildinApi"]})";
                        }
                    }
                    else if (!item.ModuleName.EndsWith("(api)"))
                    {
                        item.ModuleName += "(api)";
                    }
                }
            }
            var m = modules.ToList();

            toRemove.ForEach(x => m.Remove(x));
            AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName);
            if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true))
            {
                if (string.IsNullOrEmpty(SelectedModule))
                {
                    SelectedModule = modules.Where(x => (x.FullName == Entity.ClassName)).FirstOrDefault()?.FullName;
                }
                var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions = mm.ToListItems(y => y.ActionName, y => y.Url);
                if (SelectedActionIDs == null)
                {
                    SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
                }
            }
        }
Ejemplo n.º 12
0
        public void SetAction(string name, bool value = true)
        {
            var action = AllActions.First(a => a.guiName == name);

            action.Invoke(new KSPActionParam(action.actionGroup, (value ? KSPActionType.Activate : KSPActionType.Deactivate)));
        }
Ejemplo n.º 13
0
 public bool HasAction(string name)
 {
     return(AllActions.Any(x => x.guiName == name));
 }
Ejemplo n.º 14
0
 public ActionHelper(AllActions type, int number)
 {
     _type     = type;
     _number   = number;
     Validator = new ActionHelperValidator();
 }
Ejemplo n.º 15
0
        //--Creature_instance.mColour;
        //--Creature_instance.mSprite;
        //--Creature_instance.mLevel;
        //--Creature_instance.mAncient;

        public CreatureInstance(Creature BaseCreature)
        {
            //AllCreatures temp = new AllCreatures(); CreatureType = temp.GetCreature(0);
            CreatureType = BaseCreature;
            Nickname     = CreatureType.Name;

            //
            AllActions temp2 = new AllActions();

            for (byte i = 0; i < 6; i++)
            {
                if ((BaseCreature.ID - 1) * 6 <= 50)
                {
                    Actions[i] = temp2.GetAction((short)(i + (BaseCreature.ID - 1) * 6));
                }
                else
                {
                    Actions[i] = temp2.GetAction(1);
                }
            }
            Actions[6] = new CreatureAction(
                "Attack",                 //NAME
                CreatureType.Elements[0],
                ActionCategory.PHYSICAL,
                50,                         //SPEED
                0,                          //PRIORITY MODIFIER
                30,                         //POWER
                255,                        //USAGE
                0,                          //MANA
                null
                );

            Actions[7] = new CreatureAction(
                "Switch", //NAME
                CreatureType.Elements[0],
                ActionCategory.DEFENSIVE,
                50,     //SPEED
                -3,     //PRIORITY MODIFIER
                0,      //POWER
                255,    //USAGE
                0,      //MANA
                new BattleEffect(
                    10, //PRIORITY
                    0,  //LIFESPAN
                    new byte[1] {
                9
            },                         //PLACEMENT
                    new EffectScript[1] {
                new EffectScript(EffectTrigger.AFTER_ACTION,
                                 50,                           //SPEED
                                 new byte[1] {
                    0x18
                })
            }
                    )
                );
            Actions[7].IsSwitch = true;
            //

            for (byte i = 0; i < 6; i++)
            {
                ActionAmountUsed[i] = Actions[i].Usage;
                //ActionAmountUsed[i] = Actions[i].Usage; NEED TO SET THIS UP STILL
            }

            foreach (CreatureStats Stat in Enum.GetValues(typeof(CreatureStats)))
            {
                SetSkillPoints(Stat, 1);
                CalculateStat(Stat);
            }

            for (byte i = 0; i < 12; i++)
            {
                hasCondition[i] = false;
            }

            Health = GetTotalStat(CreatureStats.HEALTH);
            Kin    = (short)Math.Floor(1.0 * GetTotalStat(CreatureStats.KIN) / 6);
        }
Ejemplo n.º 16
0
 public ActionTypeAttribute(AllActions actionType)
 {
     ActionType = actionType;
 }